Date: Sat, 2 Jun 2018 17:57:09 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334533 - in head/sys: libkern sys Message-ID: <201806021757.w52Hv9Lh092856@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Sat Jun 2 17:57:09 2018 New Revision: 334533 URL: https://svnweb.freebsd.org/changeset/base/334533 Log: 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. Modified: head/sys/libkern/memset.c head/sys/sys/libkern.h head/sys/sys/systm.h Modified: head/sys/libkern/memset.c ============================================================================== --- head/sys/libkern/memset.c Sat Jun 2 16:28:10 2018 (r334532) +++ head/sys/libkern/memset.c Sat Jun 2 17:57:09 2018 (r334533) @@ -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); } Modified: head/sys/sys/libkern.h ============================================================================== --- head/sys/sys/libkern.h Sat Jun 2 16:28:10 2018 (r334532) +++ head/sys/sys/libkern.h Sat Jun 2 17:57:09 2018 (r334533) @@ -224,23 +224,6 @@ uint32_t armv8_crc32c(uint32_t, const unsigned char *, #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) { Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Sat Jun 2 16:28:10 2018 (r334532) +++ head/sys/sys/systm.h Sat Jun 2 17:57:09 2018 (r334533) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806021757.w52Hv9Lh092856>