libkern: tidy up memset
1. Remove special-casing of 0 as it just results in an extra function call. This is clearly pessimal. 2. Drop the inline stuff. For the most part it is much better served with __builtin_memset (coming later). 3. Move the declaration to systm.h to match other funcs. Archs are encouraged to implement the variant for their own platform so that this implementation can be dropped.
This commit is contained in:
parent
13500cbb61
commit
97e8984893
@ -37,10 +37,7 @@ memset(void *b, int c, size_t len)
|
||||
{
|
||||
char *bb;
|
||||
|
||||
if (c == 0)
|
||||
(bzero)(b, len);
|
||||
else
|
||||
for (bb = (char *)b; len--; )
|
||||
*bb++ = c;
|
||||
for (bb = (char *)b; len--; )
|
||||
*bb++ = c;
|
||||
return (b);
|
||||
}
|
||||
|
@ -224,23 +224,6 @@ uint32_t armv8_crc32c(uint32_t, const unsigned char *, unsigned int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
LIBKERN_INLINE void *memset(void *, int, size_t);
|
||||
#ifdef LIBKERN_BODY
|
||||
LIBKERN_INLINE void *
|
||||
memset(void *b, int c, size_t len)
|
||||
{
|
||||
char *bb;
|
||||
|
||||
if (c == 0)
|
||||
bzero(b, len);
|
||||
else
|
||||
for (bb = (char *)b; len--; )
|
||||
*bb++ = c;
|
||||
return (b);
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline char *
|
||||
index(const char *p, int ch)
|
||||
{
|
||||
|
@ -274,6 +274,7 @@ void bzero(void * _Nonnull buf, size_t len);
|
||||
})
|
||||
void explicit_bzero(void * _Nonnull, size_t);
|
||||
|
||||
void *memset(void * _Nonnull buf, int c, size_t len);
|
||||
void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len);
|
||||
#define memcpy(to, from, len) __builtin_memcpy(to, from, len)
|
||||
void *memmove(void * _Nonnull dest, const void * _Nonnull src, size_t n);
|
||||
|
Loading…
x
Reference in New Issue
Block a user