1 From: Richard Weinberger <richard@nod.at>
2 Date: Sun, 31 May 2015 19:50:57 +0200
3 Subject: [PATCH] um: Stop abusing __KERNEL__
5 Currently UML is abusing __KERNEL__ to distinguish between
6 kernel and host code (os-Linux). It is better to use a custom
7 define such that existing users of __KERNEL__ don't get confused.
9 Signed-off-by: Richard Weinberger <richard@nod.at>
12 --- a/arch/um/drivers/mconsole.h
13 +++ b/arch/um/drivers/mconsole.h
15 #ifndef __MCONSOLE_H__
16 #define __MCONSOLE_H__
23 --- a/arch/um/include/shared/init.h
24 +++ b/arch/um/include/shared/init.h
26 typedef int (*initcall_t)(void);
27 typedef void (*exitcall_t)(void);
32 # define __section(S) __attribute__ ((__section__(#S)))
34 @@ -131,7 +131,7 @@ extern struct uml_param __uml_setup_star
35 #define __uml_postsetup_call __used __section(.uml.postsetup.init)
36 #define __uml_exit_call __used __section(.uml.exitcall.exit)
41 #define __define_initcall(level,fn) \
42 static initcall_t __initcall_##fn __used \
43 --- a/arch/um/include/shared/user.h
44 +++ b/arch/um/include/shared/user.h
46 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
48 /* This is to get size_t */
51 #include <linux/types.h>
54 --- a/arch/um/Makefile
55 +++ b/arch/um/Makefile
56 @@ -68,9 +68,10 @@ KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -
58 KBUILD_AFLAGS += $(ARCH_INCLUDE)
60 -USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
61 - $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
62 - $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
63 +USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
64 + $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \
65 + -D_FILE_OFFSET_BITS=64 -idirafter include \
66 + -D__KERNEL__ -D__UM_HOST__
68 #This will adjust *FLAGS accordingly to the platform.
69 include $(ARCH_DIR)/Makefile-os-$(OS)
70 --- a/arch/x86/um/shared/sysdep/tls.h
71 +++ b/arch/x86/um/shared/sysdep/tls.h
79 /* Change name to avoid conflicts with the original one from <asm/ldt.h>, which
80 * may be named user_desc (but in 2.4 and in header matching its API was named
81 @@ -22,11 +22,11 @@ typedef struct um_dup_user_desc {
85 -# else /* __KERNEL__ */
86 +#else /* __UM_HOST__ */
88 typedef struct user_desc user_desc_t;
90 -# endif /* __KERNEL__ */
91 +#endif /* __UM_HOST__ */
93 extern int os_set_thread_area(user_desc_t *info, int pid);
94 extern int os_get_thread_area(user_desc_t *info, int pid);