kern: use optimized memcmp/memcpy implementations
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
#include "kern_libc_config.h"
|
||||
|
||||
/* Note: copied from newlib */
|
||||
#ifdef __cplusplus
|
||||
@@ -58,6 +59,8 @@ QUICKREF
|
||||
#undef TOO_SMALL
|
||||
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE)
|
||||
|
||||
#if MESOSPHERE_LIBC_MEMMOVE_GENERIC
|
||||
|
||||
/*SUPPRESS 20*/
|
||||
void *
|
||||
//__inhibit_loop_to_libcall
|
||||
@@ -147,6 +150,8 @@ memmove (void *dst_void,
|
||||
#endif /* not PREFER_SIZE_OVER_SPEED */
|
||||
}
|
||||
|
||||
#endif /* MESOSPHERE_LIBC_MEMMOVE_GENERIC */
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<memcpy>>---copy memory regions
|
||||
@@ -169,6 +174,8 @@ QUICKREF
|
||||
memcpy ansi pure
|
||||
*/
|
||||
|
||||
#if MESOSPHERE_LIBC_MEMCPY_GENERIC
|
||||
|
||||
void *
|
||||
__attribute__((weak))
|
||||
memcpy (void * dst0,
|
||||
@@ -229,6 +236,8 @@ memcpy (void * dst0,
|
||||
#endif /* not PREFER_SIZE_OVER_SPEED */
|
||||
}
|
||||
|
||||
#endif /* MESOSPHERE_LIBC_MEMCPY_GENERIC */
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<memset>>---set an area of memory
|
||||
@@ -260,6 +269,8 @@ QUICKREF
|
||||
#define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1))
|
||||
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
|
||||
|
||||
#if MESOSPHERE_LIBC_MEMSET_GENERIC
|
||||
|
||||
void *
|
||||
__attribute__((weak))
|
||||
memset (void *m,
|
||||
@@ -322,6 +333,8 @@ memset (void *m,
|
||||
return m;
|
||||
}
|
||||
|
||||
#endif /* MESOSPHERE_LIBC_MEMSET_GENERIC */
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<memcmp>>---compare two memory areas
|
||||
@@ -359,6 +372,8 @@ QUICKREF
|
||||
/* Threshhold for punting to the byte copier. */
|
||||
#define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
|
||||
|
||||
#if MESOSPHERE_LIBC_MEMCMP_GENERIC
|
||||
|
||||
int
|
||||
__attribute__((weak))
|
||||
memcmp (const void *m1,
|
||||
@@ -421,6 +436,8 @@ memcmp (const void *m1,
|
||||
#endif /* not PREFER_SIZE_OVER_SPEED */
|
||||
}
|
||||
|
||||
#endif /* MESOSPHERE_LIBC_MEMCMP_GENERIC */
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<strncpy>>---counted copy string
|
||||
@@ -475,6 +492,8 @@ QUICKREF
|
||||
#undef TOO_SMALL
|
||||
#define TOO_SMALL(LEN) ((LEN) < sizeof (long))
|
||||
|
||||
#if MESOSPHERE_LIBC_STRNCMP_GENERIC
|
||||
|
||||
char *
|
||||
strncpy (char *__restrict dst0,
|
||||
const char *__restrict src0,
|
||||
@@ -534,6 +553,8 @@ strncpy (char *__restrict dst0,
|
||||
#endif /* not PREFER_SIZE_OVER_SPEED */
|
||||
}
|
||||
|
||||
#endif /* MESOSPHERE_LIBC_STRNCPY_GENERIC */
|
||||
|
||||
/*
|
||||
FUNCTION
|
||||
<<strncmp>>---character string compare
|
||||
@@ -581,6 +602,8 @@ QUICKREF
|
||||
#error long int is not a 32bit or 64bit byte
|
||||
#endif
|
||||
|
||||
#if MESOSPHERE_LIBC_STRNCMP_GENERIC
|
||||
|
||||
int
|
||||
strncmp (const char *s1,
|
||||
const char *s2,
|
||||
@@ -643,6 +666,8 @@ strncmp (const char *s1,
|
||||
#endif /* not PREFER_SIZE_OVER_SPEED */
|
||||
}
|
||||
|
||||
#endif /* MESOSPHERE_LIBC_STRNCMP_GENERIC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user