From e4804d80cb2a50be7e1afa00798e045453b533c3 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Mon, 26 Nov 2007 10:45:51 +0000 Subject: [PATCH] allow strcmp() and memcpy() be macros --- include/system.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/system.h b/include/system.h index 411b92d..1b81ba4 100644 --- a/include/system.h +++ b/include/system.h @@ -134,12 +134,18 @@ static inline void *_inline_memcpy(void *dst_, const void *src_, size_t len) return dst_; } -#define memcpy(dst, src, len) \ - ( __builtin_constant_p(len) \ - ? memcpy(dst, src, len) \ - : ((__builtin_constant_p((len) < 16) && ((len) < 16)) \ - ? _inline_memcpy(dst, src, len) \ - : memcpy(dst, src, len))) +static inline void *_own_memcpy(void *dst, const void *src, size_t len) +{ + if (!__builtin_constant_p(len) + && __builtin_constant_p(len < 16) + && len < 16) + return _inline_memcpy(dst, src, len); + else + return memcpy(dst, src, len); +} + +#undef memcpy +#define memcpy(d, s, n) _own_memcpy(d, s, n) #endif @@ -154,6 +160,7 @@ static inline int _inline_strcmp(const char *a, const char *b) return strcmp(a, b); } +#undef strcmp #define strcmp(a, b) _inline_strcmp(a, b) -- 2.40.0