This is the mail archive of the mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] byteorder.h, ntohl, and compiling userspace programs

Dimi Shahbaz wrote:
> I'm trying to build glibc ...
> [but get a compile error:]
> ../inet/netinet/in.h:259: parse error before '(' token
> [caused by linux's #define of ntohl when compiling glibc's
>  function prototype for ntohl]

I think the conflict is with the ntohl macros defined in

These days, I don't see why the Linux kernel headers
should be defining htohl for userspace; libc's headers
do that.  So how about simplifying generic.h so it
only does anything when compiling the kernel:

--- linux/include/linux/byteorder/generic.h.orig	Tue May 14 10:02:49 2002
+++ linux/include/linux/byteorder/generic.h	Tue May 14 10:06:48 2002
@@ -123,6 +123,7 @@
+#if defined(__KERNEL__)
  * Handle ntohl and suches. These have various compatibility
  * issues - like we want to give the prototype even though we
@@ -146,17 +147,11 @@
  * Do the prototypes. Somebody might want to take the
  * address or some such sick thing..
-#if defined(__KERNEL__) || (defined (__GLIBC__) && __GLIBC__ >= 2)
 extern __u32			ntohl(__u32);
 extern __u32			htonl(__u32);
-extern unsigned long int	ntohl(unsigned long int);
-extern unsigned long int	htonl(unsigned long int);
 extern unsigned short int	ntohs(unsigned short int);
 extern unsigned short int	htons(unsigned short int);
 #if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__OPTIMIZE__)
 #define ___htonl(x) __cpu_to_be32(x)
@@ -164,17 +159,14 @@
 #define ___ntohl(x) __be32_to_cpu(x)
 #define ___ntohs(x) __be16_to_cpu(x)
-#if defined(__KERNEL__) || (defined (__GLIBC__) && __GLIBC__ >= 2)
 #define htonl(x) ___htonl(x)
 #define ntohl(x) ___ntohl(x)
-#define htonl(x) ((unsigned long)___htonl(x))
-#define ntohl(x) ((unsigned long)___ntohl(x))
 #define htons(x) ___htons(x)
 #define ntohs(x) ___ntohs(x)
 #endif /* OPTIMIZE */
+#endif /* KERNEL */

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]