[libc] Rewrite string functions

Some of the C library string functions have an unknown provenance.
Reimplement all such functions to avoid potential licensing
uncertainty.

Remove the inline-assembler versions of strlen(), memswap(), and
strncmp(); these save a minimal amount of space (around 40 bytes in
total) and are not performance-critical.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2015-02-16 17:59:11 +00:00
parent b54167b8b6
commit 8ee39f7432
6 changed files with 400 additions and 432 deletions

View File

@@ -28,8 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
*
*/
#define __HAVE_ARCH_MEMCPY
extern void * __memcpy ( void *dest, const void *src, size_t len );
extern void * __memcpy_reverse ( void *dest, const void *src, size_t len );
@@ -169,8 +167,6 @@ memcpy ( void *dest, const void *src, size_t len ) {
}
}
#define __HAVE_ARCH_MEMMOVE
extern void * __memmove ( void *dest, const void *src, size_t len );
/**
@@ -196,8 +192,6 @@ memmove ( void *dest, const void *src, size_t len ) {
}
}
#define __HAVE_ARCH_MEMSET
/**
* Fill memory region
*
@@ -217,16 +211,4 @@ static inline void * memset ( void *dest, int fill, size_t len ) {
return dest;
}
#define __HAVE_ARCH_MEMSWAP
extern void * memswap ( void *dest, void *src, size_t len );
#define __HAVE_ARCH_STRNCMP
extern int strncmp ( const char *str1, const char *str2, size_t len );
#define __HAVE_ARCH_STRLEN
extern size_t strlen ( const char *string );
#endif /* X86_BITS_STRING_H */