Merge commit 'holger/strings'

This commit is contained in:
Michael Brown
2007-08-23 21:51:57 +01:00
14 changed files with 353 additions and 298 deletions

View File

@@ -279,6 +279,31 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr,
/** Apply standard C calling conventions */
#define __cdecl __attribute__ (( cdecl , regparm(0) ))
/**
* Declare a function as pure - i.e. without side effects
*/
#define __pure __attribute__ (( pure ))
/**
* Declare a function as const - i.e. it does not access global memory
* (including dereferencing pointers passed to it) at all.
* Must also not call any non-const functions.
*/
#define __const __attribute__ (( const ))
/**
* Declare a function's pointer parameters as non-null - i.e. force
* compiler to check pointers at compile time and enable possible
* optimizations based on that fact
*/
#define __nonnull __attribute__ (( nonnull ))
/**
* Declare a pointer returned by a function as a unique memory address
* as returned by malloc-type functions.
*/
#define __malloc __attribute__ (( malloc ))
/**
* Declare a function as used.
*

View File

@@ -507,7 +507,7 @@ extern void register_dhcp_options ( struct dhcp_option_block *options );
extern void unregister_dhcp_options ( struct dhcp_option_block *options );
extern void init_dhcp_options ( struct dhcp_option_block *options,
void *data, size_t max_len );
extern struct dhcp_option_block * alloc_dhcp_options ( size_t max_len );
extern struct dhcp_option_block * __malloc alloc_dhcp_options ( size_t max_len );
extern struct dhcp_option *
set_dhcp_option ( struct dhcp_option_block *options, unsigned int tag,
const void *data, size_t len );

View File

@@ -161,7 +161,7 @@ static inline size_t iob_tailroom ( struct io_buffer *iobuf ) {
return ( iobuf->end - iobuf->tail );
}
extern struct io_buffer * alloc_iob ( size_t len );
extern struct io_buffer * __malloc alloc_iob ( size_t len );
extern void free_iob ( struct io_buffer *iobuf );
extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
extern int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len );

View File

@@ -19,7 +19,7 @@
extern size_t freemem;
extern void * alloc_memblock ( size_t size, size_t align );
extern void * __malloc alloc_memblock ( size_t size, size_t align );
extern void free_memblock ( void *ptr, size_t size );
extern void mpopulate ( void *start, size_t len );
extern void mdumpfree ( void );
@@ -35,7 +35,7 @@ extern void mdumpfree ( void );
*
* @c align must be a power of two. @c size may not be zero.
*/
static inline void * malloc_dma ( size_t size, size_t phys_align ) {
static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
return alloc_memblock ( size, phys_align );
}

View File

@@ -7,6 +7,6 @@
*
*/
extern char * readline ( const char *prompt );
extern char * __malloc readline ( const char *prompt );
#endif /* _READLINE_H */

View File

@@ -20,10 +20,10 @@ extern unsigned long strtoul ( const char *p, char **endp, int base );
****************************************************************************
*/
extern void * malloc ( size_t size );
extern void * __malloc malloc ( size_t size );
extern void * realloc ( void *old_ptr, size_t new_size );
extern void free ( void *ptr );
extern void * zalloc ( size_t len );
extern void * __malloc zalloc ( size_t len );
/**
* Allocate cleared memory
@@ -38,7 +38,7 @@ extern void * zalloc ( size_t len );
* function in zalloc(), since in most cases @c nmemb will be 1 and
* doing the multiply is just wasteful.
*/
static inline void * calloc ( size_t nmemb, size_t size ) {
static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
return zalloc ( nmemb * size );
}

View File

@@ -17,33 +17,33 @@
#include <stddef.h>
#include <bits/string.h>
int strnicmp(const char *s1, const char *s2, size_t len);
char * strcpy(char * dest,const char *src);
char * strncpy(char * dest,const char *src,size_t count);
char * strcat(char * dest, const char * src);
char * strncat(char *dest, const char *src, size_t count);
int __attribute__ (( pure )) strcmp(const char * cs,const char * ct);
int __attribute__ (( pure )) strncmp(const char * cs,const char * ct,
size_t count);
char * strchr(const char * s, int c);
char * strrchr(const char * s, int c);
size_t strlen(const char * s);
size_t strnlen(const char * s, size_t count);
size_t strspn(const char *s, const char *accept);
size_t strcspn(const char *s, const char *reject);
char * strpbrk(const char * cs,const char * ct);
char * strtok(char * s,const char * ct);
char * strsep(char **s, const char *ct);
void * memset(void * s,int c,size_t count);
void * memmove(void * dest,const void *src,size_t count);
int __attribute__ (( pure )) memcmp(const void * cs,const void * ct,
size_t count);
void * memscan(void * addr, int c, size_t size);
char * strstr(const char * s1,const char * s2);
void * memchr(const void *s, int c, size_t n);
char * strdup(const char *s);
char * strndup(const char *s, size_t n);
int __pure strnicmp(const char *s1, const char *s2, size_t len) __nonnull;
char * strcpy(char * dest,const char *src) __nonnull;
char * strncpy(char * dest,const char *src,size_t count) __nonnull;
char * strcat(char * dest, const char * src) __nonnull;
char * strncat(char *dest, const char *src, size_t count) __nonnull;
int __pure strcmp(const char * cs,const char * ct) __nonnull;
int __pure strncmp(const char * cs,const char * ct,
size_t count) __nonnull;
char * __pure strchr(const char * s, int c) __nonnull;
char * __pure strrchr(const char * s, int c) __nonnull;
size_t __pure strlen(const char * s) __nonnull;
size_t __pure strnlen(const char * s, size_t count) __nonnull;
size_t __pure strspn(const char *s, const char *accept) __nonnull;
size_t __pure strcspn(const char *s, const char *reject) __nonnull;
char * __pure strpbrk(const char * cs,const char * ct) __nonnull;
char * strtok(char * s,const char * ct) __nonnull;
char * strsep(char **s, const char *ct) __nonnull;
void * memset(void * s,int c,size_t count) __nonnull;
void * memmove(void * dest,const void *src,size_t count) __nonnull;
int __pure memcmp(const void * cs,const void * ct,
size_t count) __nonnull;
void * __pure memscan(const void * addr, int c, size_t size) __nonnull;
char * __pure strstr(const char * s1,const char * s2) __nonnull;
void * __pure memchr(const void *s, int c, size_t n) __nonnull;
char * __malloc strdup(const char *s) __nonnull;
char * __malloc strndup(const char *s, size_t n) __nonnull;
extern const char * strerror ( int errno );
extern const char * __pure strerror ( int errno );
#endif /* ETHERBOOT_STRING */