Messages in this thread | | | Subject | Re: [PATCH v4] lib/string.c: implement a basic bcmp | From | Rasmus Villemoes <> | Date | Thu, 14 Mar 2019 12:07:22 +0100 |
| |
On 14/03/2019 10.57, David Laight wrote: > From: Nick Desaulniers >> Sent: 13 March 2019 21:14 > ... >> diff --git a/include/linux/string.h b/include/linux/string.h >> index 7927b875f80c..6ab0a6fa512e 100644 >> --- a/include/linux/string.h >> +++ b/include/linux/string.h >> @@ -150,6 +150,9 @@ extern void * memscan(void *,int,__kernel_size_t); >> #ifndef __HAVE_ARCH_MEMCMP >> extern int memcmp(const void *,const void *,__kernel_size_t); >> #endif >> +#ifndef __HAVE_ARCH_BCMP >> +extern int bcmp(const void *,const void *,__kernel_size_t); >> +#endif > > Shouldn't that prototype always be present?
Yes and no. The problem is that asm/string.h may decide to implement bcmp (or memcpy, memset, strcpy, ...) as a macro, which would break rather badly when used to declare the function. And we can't undef the macro temporarily. So I think the convention is that asm/string.h provides the prototype before it #defines the macro, see e.g. arch/x86/include/asm/string_32.h which has a #define of memcpy.
There is a fix for the "may be defined as a function-like macro", which is
extern int (bcmp)(const void *,const void *,__kernel_size_t);
I'd like to see that used rather than the ad hoc convention, but it is of course somewhat unconventional C.
Rasmus
| |