finally move buildroot-ng to trunk
[openwrt.git] / toolchain / uClibc / patches / 130-ppc_gcc4_fix.patch
1 diff -Nur uClibc-0.9.28/libc/sysdeps/linux/powerpc/bits/syscalls.h uClibc-0.9.28-owrt/libc/sysdeps/linux/powerpc/bits/syscalls.h
2 --- uClibc-0.9.28/libc/sysdeps/linux/powerpc/bits/syscalls.h    2005-08-18 00:49:41.000000000 +0200
3 +++ uClibc-0.9.28-owrt/libc/sysdeps/linux/powerpc/bits/syscalls.h       2006-08-25 17:58:21.000000000 +0200
4 @@ -5,67 +5,164 @@
5  # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
6  #endif
7  
8 +#include <errno.h>
9 +
10  /* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
11   * header files.  It also defines the traditional `SYS_<name>' macros for older
12   * programs.  */
13  #include <bits/sysnum.h>
14  
15 -
16 -#define __STRINGIFY(s) __STRINGIFY2 (s)
17 -#define __STRINGIFY2(s) #s
18 -
19 -#undef JUMPTARGET
20 -#ifdef __PIC__
21 -#define __MAKE_SYSCALL __STRINGIFY(__uClibc_syscall@plt)
22 +/* Define a macro which expands inline into the wrapper code for a system
23 +   call. This use is for internal calls that do not need to handle errors
24 +   normally. It will never touch errno.
25 +   On powerpc a system call basically clobbers the same registers like a
26 +   function call, with the exception of LR (which is needed for the
27 +   "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
28 +   an error return status).  */
29 +
30 +# undef INLINE_SYSCALL
31 +#if 1
32 +# define INLINE_SYSCALL(name, nr, args...)                             \
33 +  ({                                                                   \
34 +    INTERNAL_SYSCALL_DECL (sc_err);                                    \
35 +    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);       \
36 +    if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))                     \
37 +      {                                                                        \
38 +       __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err));          \
39 +       sc_ret = -1L;                                                   \
40 +      }                                                                        \
41 +    sc_ret;                                                            \
42 +  })
43  #else
44 -#define __MAKE_SYSCALL __STRINGIFY(__uClibc_syscall)
45 +# define INLINE_SYSCALL(name, nr, args...)                             \
46 +  ({                                                                   \
47 +    INTERNAL_SYSCALL_DECL (sc_err);                                    \
48 +    long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args);       \
49 +    if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err))                     \
50 +      {                                                                        \
51 +       sc_ret = __syscall_error(INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err));\
52 +      }                                                                        \
53 +    sc_ret;                                                            \
54 +  })
55  #endif
56  
57 -#define unified_syscall_body(name)                     \
58 -       __asm__ (                                       \
59 -       ".section \".text\"\n\t"                        \
60 -       ".align 2\n\t"                                  \
61 -       ".globl " __STRINGIFY(name) "\n\t"              \
62 -       ".type " __STRINGIFY(name) ",@function\n\t"     \
63 -       #name":\tli 0," __STRINGIFY(__NR_##name) "\n\t" \
64 -       "b " __MAKE_SYSCALL "\n\t"              \
65 -       ".size\t" __STRINGIFY(name) ",.""-" __STRINGIFY(name) "\n"      \
66 -       )
67 +/* Define a macro which expands inline into the wrapper code for a system
68 +   call. This use is for internal calls that do not need to handle errors
69 +   normally. It will never touch errno.
70 +   On powerpc a system call basically clobbers the same registers like a
71 +   function call, with the exception of LR (which is needed for the
72 +   "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
73 +   an error return status).  */
74 +
75 +# undef INTERNAL_SYSCALL_DECL
76 +# define INTERNAL_SYSCALL_DECL(err) long int err
77 +
78 +# undef INTERNAL_SYSCALL
79 +# define INTERNAL_SYSCALL_NCS(name, err, nr, args...)                  \
80 +  ({                                                                   \
81 +    register long int r0  __asm__ ("r0");                              \
82 +    register long int r3  __asm__ ("r3");                              \
83 +    register long int r4  __asm__ ("r4");                              \
84 +    register long int r5  __asm__ ("r5");                              \
85 +    register long int r6  __asm__ ("r6");                              \
86 +    register long int r7  __asm__ ("r7");                              \
87 +    register long int r8  __asm__ ("r8");                              \
88 +    register long int r9  __asm__ ("r9");                              \
89 +    register long int r10 __asm__ ("r10");                             \
90 +    register long int r11 __asm__ ("r11");                             \
91 +    register long int r12 __asm__ ("r12");                             \
92 +    LOADARGS_##nr(name, args);                                         \
93 +    __asm__ __volatile__                                               \
94 +      ("sc   \n\t"                                                     \
95 +       "mfcr %0"                                                       \
96 +       : "=&r" (r0),                                                   \
97 +        "=&r" (r3), "=&r" (r4), "=&r" (r5),  "=&r" (r6),  "=&r" (r7),  \
98 +        "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12)  \
99 +       : ASM_INPUT_##nr                                                        \
100 +       : "cr0", "ctr", "memory");                                      \
101 +    err = r0;                                                          \
102 +    (int) r3;                                                          \
103 +  })
104 +# define INTERNAL_SYSCALL(name, err, nr, args...) \
105 +  INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
106 +
107 +# undef INTERNAL_SYSCALL_ERROR_P
108 +# define INTERNAL_SYSCALL_ERROR_P(val, err) \
109 +  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
110 +
111 +# undef INTERNAL_SYSCALL_ERRNO
112 +# define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
113 +
114 +# define LOADARGS_0(name, dummy) \
115 +       r0 = (long int)name
116 +# define LOADARGS_1(name, __arg1) \
117 +       LOADARGS_0(name, 0); \
118 +       r3 = (long int)__arg1
119 +# define LOADARGS_2(name, __arg1, __arg2) \
120 +       LOADARGS_1(name, __arg1); \
121 +       r4 = (long int)__arg2
122 +# define LOADARGS_3(name, __arg1, __arg2, __arg3) \
123 +       LOADARGS_2(name, __arg1, __arg2); \
124 +       r5 = (long int)__arg3
125 +# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
126 +       LOADARGS_3(name, __arg1, __arg2, __arg3); \
127 +       r6 = (long int)__arg4
128 +# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
129 +       LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
130 +       r7 = (long int)__arg5
131 +# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
132 +       LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
133 +       r8 = (long int)__arg6
134 +
135 +# define ASM_INPUT_0 "0" (r0)
136 +# define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
137 +# define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
138 +# define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
139 +# define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
140 +# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
141 +# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
142  
143  #undef _syscall0
144 -#define _syscall0(type,name)                           \
145 -type name(void);                                       \
146 -unified_syscall_body(name)
147 +#define _syscall0(type,name) \
148 +type name(void){ \
149 +  return (type) INLINE_SYSCALL(name, 0); \
150 +}
151  
152  #undef _syscall1
153  #define _syscall1(type,name,type1,arg1) \
154 -type name(type1 arg1);  \
155 -unified_syscall_body(name)
156 +type name(type1 arg1){  \
157 +  return (type) INLINE_SYSCALL(name, 1, arg1); \
158 +}
159  
160  #undef _syscall2
161  #define _syscall2(type,name,type1,arg1,type2,arg2) \
162 -type name(type1 arg1, type2 arg2);      \
163 -unified_syscall_body(name)
164 +type name(type1 arg1, type2 arg2){      \
165 +  return (type) INLINE_SYSCALL(name, 2, arg1, arg2); \
166 +}
167  
168  #undef _syscall3
169  #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
170 -type name(type1 arg1, type2 arg2, type3 arg3);  \
171 -unified_syscall_body(name)
172 +type name(type1 arg1, type2 arg2, type3 arg3){  \
173 +  return (type) INLINE_SYSCALL(name, 3, arg1, arg2, arg3); \
174 +}
175  
176  #undef _syscall4
177  #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
178 -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4);      \
179 -unified_syscall_body(name)
180 +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4){      \
181 +  return (type) INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4); \
182 +}
183  
184  #undef _syscall5
185  #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
186 -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5);  \
187 -unified_syscall_body(name)
188 +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5){  \
189 +  return (type) INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5); \
190 +}
191  
192  #undef _syscall6
193  #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
194 -type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6);      \
195 -unified_syscall_body(name)
196 +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6){      \
197 +  return (type) INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); \
198 +}
199  
200  #endif /* _BITS_SYSCALLS_H */
201  
202 diff -urP uClibc-0.9.28/libc/sysdeps/linux/powerpc/sys/procfs.h uClibc-0.9.28-uint128/libc/sysdeps/linux/powerpc/sys/procfs.h
203 --- uClibc-0.9.28/libc/sysdeps/linux/powerpc/sys/procfs.h       2005-08-18 00:49:41.000000000 +0200
204 +++ uClibc-0.9.28-uint128/libc/sysdeps/linux/powerpc/sys/procfs.h       2005-08-22 17:27:17.000000000 +0200
205 @@ -42,15 +42,10 @@
206  typedef double elf_fpreg_t;
207  typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
208  
209 -/* gcc 3.1 and newer support __uint128_t.  */
210 -#if !__GNUC_PREREQ(3,1)
211 -typedef struct {
212 -      unsigned long u[4];
213 -} __attribute((aligned(16))) __uint128_t;
214 -#endif
215 -
216  /* Altivec registers */
217 -typedef __uint128_t elf_vrreg_t;
218 +typedef struct {
219 +  unsigned int u[4];
220 +} __attribute((aligned (16))) elf_vrreg_t;
221  typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG];
222  
223  struct elf_siginfo