[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

linux/types.h <-> glibc interferences

Hi folks

linux/types.h exports some POSIX types. It can be asked to stop this
with __KERNEL_STRICT_NAMES. features.h defines this. So currently
anything works if features.h is included before linux/types.h.

This is not properly fixable by the glibc. The attached patch fixes it
in linux, but I'm unsure if this will not break other things like
alternative libc.


You can't evaluate a man by logic alone.
		-- McCoy, "I, Mudd", stardate 4513.3
diff --git a/include/linux/types.h b/include/linux/types.h
index 0351bf2..a9779d6 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -14,10 +14,10 @@
 #include <linux/posix_types.h>
 #include <asm/types.h>
 typedef __u32 __kernel_dev_t;
+#ifdef __KERNEL__
 typedef __kernel_fd_set		fd_set;
 typedef __kernel_dev_t		dev_t;
 typedef __kernel_ino_t		ino_t;
@@ -32,7 +32,6 @@ typedef __kernel_timer_t	timer_t;
 typedef __kernel_clockid_t	clockid_t;
 typedef __kernel_mqd_t		mqd_t;
-#ifdef __KERNEL__
 typedef _Bool			bool;
 typedef __kernel_uid32_t	uid_t;
@@ -46,51 +45,14 @@ typedef __kernel_old_uid_t	old_uid_t;
 typedef __kernel_old_gid_t	old_gid_t;
 #endif /* CONFIG_UID16 */
-/* libc5 includes this file to define uid_t, thus uid_t can never change
- * when it is included by non-kernel code
- */
-typedef __kernel_uid_t		uid_t;
-typedef __kernel_gid_t		gid_t;
-#endif /* __KERNEL__ */
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
 typedef __kernel_loff_t		loff_t;
- * The following typedefs are also protected by individual ifdefs for
- * historical reasons:
- */
-#ifndef _SIZE_T
-#define _SIZE_T
 typedef __kernel_size_t		size_t;
-#ifndef _SSIZE_T
-#define _SSIZE_T
 typedef __kernel_ssize_t	ssize_t;
-#ifndef _PTRDIFF_T
-#define _PTRDIFF_T
 typedef __kernel_ptrdiff_t	ptrdiff_t;
-#ifndef _TIME_T
-#define _TIME_T
 typedef __kernel_time_t		time_t;
-#ifndef _CLOCK_T
-#define _CLOCK_T
 typedef __kernel_clock_t	clock_t;
-#ifndef _CADDR_T
-#define _CADDR_T
 typedef __kernel_caddr_t	caddr_t;
 /* bsd */
 typedef unsigned char		u_char;
@@ -104,27 +66,18 @@ typedef unsigned short		ushort;
 typedef unsigned int		uint;
 typedef unsigned long		ulong;
-#ifndef __BIT_TYPES_DEFINED__
-#define __BIT_TYPES_DEFINED__
+typedef		__u8		uint8_t;
 typedef		__u8		u_int8_t;
 typedef		__s8		int8_t;
+typedef		__u16		uint16_t;
 typedef		__u16		u_int16_t;
 typedef		__s16		int16_t;
+typedef		__u32		uint32_t;
 typedef		__u32		u_int32_t;
 typedef		__s32		int32_t;
-#endif /* !(__BIT_TYPES_DEFINED__) */
-typedef		__u8		uint8_t;
-typedef		__u16		uint16_t;
-typedef		__u32		uint32_t;
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
 typedef		__u64		uint64_t;
 typedef		__u64		u_int64_t;
 typedef		__s64		int64_t;
 /* this is a special 64bit data type that is 8-byte aligned */
 #define aligned_u64 unsigned long long __attribute__((aligned(8)))
@@ -160,7 +113,7 @@ typedef unsigned long blkcnt_t;
 #define pgoff_t unsigned long
-#endif /* __KERNEL_STRICT_NAMES */
+#endif /* __KERNEL__ */
  * Below are truly Linux-specific types that should never collide with
@@ -182,10 +135,8 @@ typedef __u16 __bitwise __le16;
 typedef __u16 __bitwise __be16;
 typedef __u32 __bitwise __le32;
 typedef __u32 __bitwise __be32;
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __u64 __bitwise __le64;
-typedef __u64 __bitwise __be64;
+__extension__ typedef __u64 __bitwise __le64;
+__extension__ typedef __u64 __bitwise __be64;
 typedef __u16 __bitwise __sum16;
 typedef __u32 __bitwise __wsum;
@@ -198,8 +149,6 @@ typedef u64 resource_size_t;
 typedef u32 resource_size_t;
-#endif	/* __KERNEL__ */
 struct ustat {
 	__kernel_daddr_t	f_tfree;
 	__kernel_ino_t		f_tinode;
@@ -207,4 +156,6 @@ struct ustat {
 	char			f_fpack[6];
+#endif	/* __KERNEL__ */
 #endif /* _LINUX_TYPES_H */

Reply to: