From 0b32abca7cef990ed121c920a7832aa35a2661e4 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sat, 2 Sep 2000 13:34:52 +0000 Subject: [PATCH] Bite the bullet and provde memcmp() and memset(), this will be cheaper than all the copy&paste versions we already have :-( --- sys/dev/awi/awivar.h | 16 ---------------- sys/sys/libkern.h | 20 ++++++++++++++++++++ sys/sys/param.h | 9 --------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/sys/dev/awi/awivar.h b/sys/dev/awi/awivar.h index c3a0a48df0fe..8e86f841a006 100644 --- a/sys/dev/awi/awivar.h +++ b/sys/dev/awi/awivar.h @@ -220,19 +220,3 @@ int awi_wep_setalgo __P((struct awi_softc *, int)); int awi_wep_setkey __P((struct awi_softc *, int, unsigned char *, int)); int awi_wep_getkey __P((struct awi_softc *, int, unsigned char *, int *)); struct mbuf *awi_wep_encrypt __P((struct awi_softc *, struct mbuf *, int)); - -#ifdef __FreeBSD__ -/* Provide mem* for compat with NetBSD to fix LINT */ -static __inline int -memcmp(const void *b1, const void *b2, size_t len) -{ - return (bcmp(b1, b2, len)); -} - -static __inline void * -memset(void *b, int c, size_t len) -{ - bzero(b, len); - return (b); -} -#endif diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 340bc68cb73a..e9841d5417fb 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -85,4 +85,24 @@ size_t strlen __P((const char *)); int strncmp __P((const char *, const char *, size_t)); char *strncpy __P((char *, const char *, size_t)); + +static __inline int +memcmp(const void *b1, const void *b2, size_t len) +{ + return (bcmp(b1, b2, len)); +} + +static __inline void * +memset(void *b, int c, size_t len) +{ + char *bb; + + if (c == 0) + bzero(b, len); + else + for (bb = b; len--; ) + *bb++ = c; + return (b); +} + #endif /* !_SYS_LIBKERN_H_ */ diff --git a/sys/sys/param.h b/sys/sys/param.h index 641abf63023c..a567156b7438 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -256,13 +256,4 @@ #ifdef _KERNEL void panic __P((const char *, ...)) __dead2 __printflike(1, 2); #endif - -/* - * Stop people from using memset/memcpy in the kernel - */ -#ifdef _KERNEL -double memset __P((int dont_use_memset_in_kernel, int a, int b, int c)); -#endif - - #endif /* _SYS_PARAM_H_ */