uml: backport another upstream patch to fix compile errors
[openwrt.git] / target / linux / uml / patches-4.1 / 001-um-Stop-abusing-__KERNEL__.patch
1 From: Richard Weinberger <richard@nod.at>
2 Date: Sun, 31 May 2015 19:50:57 +0200
3 Subject: [PATCH] um: Stop abusing __KERNEL__
4
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.
8
9 Signed-off-by: Richard Weinberger <richard@nod.at>
10 ---
11
12 --- a/arch/um/drivers/mconsole.h
13 +++ b/arch/um/drivers/mconsole.h
14 @@ -7,7 +7,7 @@
15  #ifndef __MCONSOLE_H__
16  #define __MCONSOLE_H__
17  
18 -#ifndef __KERNEL__
19 +#ifdef __UM_HOST__
20  #include <stdint.h>
21  #define u32 uint32_t
22  #endif
23 --- a/arch/um/include/shared/init.h
24 +++ b/arch/um/include/shared/init.h
25 @@ -40,7 +40,7 @@
26  typedef int (*initcall_t)(void);
27  typedef void (*exitcall_t)(void);
28  
29 -#ifndef __KERNEL__
30 +#ifdef __UM_HOST__
31  #ifndef __section
32  # define __section(S) __attribute__ ((__section__(#S)))
33  #endif
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)
37  
38 -#ifndef __KERNEL__
39 +#ifdef __UM_HOST__
40  
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
45 @@ -17,7 +17,7 @@
46  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
47  
48  /* This is to get size_t */
49 -#ifdef __KERNEL__
50 +#ifndef __UM_HOST__
51  #include <linux/types.h>
52  #else
53  #include <stddef.h>
54 --- a/arch/um/Makefile
55 +++ b/arch/um/Makefile
56 @@ -68,9 +68,10 @@ KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -
57  
58  KBUILD_AFLAGS += $(ARCH_INCLUDE)
59  
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__
67  
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
72 @@ -1,7 +1,7 @@
73  #ifndef _SYSDEP_TLS_H
74  #define _SYSDEP_TLS_H
75  
76 -# ifndef __KERNEL__
77 +#ifdef __UM_HOST__
78  
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 {
82  #endif
83  } user_desc_t;
84  
85 -# else /* __KERNEL__ */
86 +#else /* __UM_HOST__ */
87  
88  typedef struct user_desc user_desc_t;
89  
90 -# endif /* __KERNEL__ */
91 +#endif /* __UM_HOST__ */
92  
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);