Fix for include/linux/string.h

From: Pavel Roskin (proski@gnu.org)
Date: Sun Jul 30 2000 - 23:07:16 EST


Hello!

Some programs (namely GNU GRUB) don't compile with linux-2.4.0-test5. It
turns out that the following two-liner can only be compiled without
optimization:

================
#include <string.h>
#include <linux/fs.h>
================

Indeed, if we look into /usr/include/bits/string.h (glibc-2.1.3, i386) we
can see that some string functions (notably strpbrk) expand to hairy
macros when __OPTIMIZATION__ is enabled.

I don't want to argue whether it is good or bad, but the fact is that
GLIBC doesn't tolerate redeclarations of some functions.

I must admit that the kernel is wrong here. It declares functions
available exclusively to the kernel code even if __KERNEL__ is not
defined.

The following patch is proposed. More radical solutions (i.e. widening the
area surrounded by ifdef..endif) are left to the exersize for more radical
developers :-)

==================
--- linux.orig/include/linux/string.h Sun Jul 30 19:40:56 2000
+++ linux/include/linux/string.h Sun Jul 30 23:45:50 2000
@@ -8,11 +8,13 @@
 extern "C" {
 #endif
 
+#ifdef __KERNEL__
 extern char * ___strtok;
 extern char * strpbrk(const char *,const char *);
 extern char * strtok(char *,const char *);
 extern char * strsep(char **,const char *);
 extern __kernel_size_t strspn(const char *,const char *);
+#endif
 
 
 /*
==================

Regards,
Pavel Roskin

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jul 31 2000 - 21:00:32 EST