]> git.pld-linux.org Git - packages/crossm68k-uClibc.git/blob - crossm68k-uClibc-uCLinux.patch
- use preferred %{!?...} instead of %{?!...}
[packages/crossm68k-uClibc.git] / crossm68k-uClibc-uCLinux.patch
1 diff -urN uClibc-0.9.27/extra/Configs/Config.h8300 uClibc-0.9.27-uc0/extra/Configs/Config.h8300
2 --- uClibc-0.9.27/extra/Configs/Config.h8300    2005-01-12 08:59:21.000000000 +0100
3 +++ uClibc-0.9.27-uc0/extra/Configs/Config.h8300        2005-01-26 07:37:19.000000000 +0100
4 @@ -7,7 +7,6 @@
5         bool
6         select ARCH_HAS_NO_MMU
7         select ARCH_HAS_C_SYMBOL_PREFIX
8 -       select HAVE_NO_SHARED
9         select ARCH_HAS_NO_LDSO
10         default y
11  
12 @@ -36,6 +35,14 @@
13  
14  endchoice
15  
16 +config CONFIG_BINFMT_SHARED_FLAT
17 +       bool "Build Shared Library"
18 +       default n
19 +
20 +config UCLIBC_HAS_SOFT_FLOAT
21 +       bool
22 +       default n
23 +
24  config ARCH_CFLAGS
25         string
26  
27 diff -urN uClibc-0.9.27/extra/Configs/Config.in uClibc-0.9.27-uc0/extra/Configs/Config.in
28 --- uClibc-0.9.27/extra/Configs/Config.in       2005-01-12 08:59:21.000000000 +0100
29 +++ uClibc-0.9.27-uc0/extra/Configs/Config.in   2006-02-27 08:31:05.000000000 +0100
30 @@ -383,6 +383,12 @@
31  
32           Unless you use uClibc with C++, you should probably answer N.
33  
34 +config COMPAT_ATEXIT
35 +       bool "Old (visible) atexit Support"
36 +       default n
37 +       help
38 +         Enable this option if you want to update from 0.9.28 to svn/0.9.29, else
39 +         you will be missing atexit() until you rebuild all apps.
40  
41  config HAS_SHADOW
42         bool "Shadow Password Support"
43 diff -urN uClibc-0.9.27/extra/Configs/Config.in.arch uClibc-0.9.27-uc0/extra/Configs/Config.in.arch
44 --- uClibc-0.9.27/extra/Configs/Config.in.arch  2005-01-12 08:59:21.000000000 +0100
45 +++ uClibc-0.9.27-uc0/extra/Configs/Config.in.arch      2006-07-28 07:00:26.000000000 +0200
46 @@ -99,9 +99,9 @@
47           work at all.  You have been warned.
48  
49  config UCLIBC_UCLINUX_BROKEN_MUNMAP
50 -       bool
51 +       bool "If munmap expects 0 for the size"
52         depends on !ARCH_HAS_MMU
53 -       default y
54 +       default n
55  
56  config EXCLUDE_BRK
57         bool
58 diff -urN uClibc-0.9.27/extra/Configs/Config.m68k uClibc-0.9.27-uc0/extra/Configs/Config.m68k
59 --- uClibc-0.9.27/extra/Configs/Config.m68k     2005-01-12 08:59:21.000000000 +0100
60 +++ uClibc-0.9.27-uc0/extra/Configs/Config.m68k 2005-01-26 07:37:19.000000000 +0100
61 @@ -17,9 +17,9 @@
62         bool
63         default y
64  
65 -config ARCH_CFLAGS
66 -       string
67 -       default "-Wa,--bitwise-or"
68 +# config ARCH_CFLAGS
69 +#      string
70 +#      default "-Wa,--bitwise-or"
71  
72  config ARCH_LDFLAGS
73         string
74 diff -urN uClibc-0.9.27/extra/Configs/Config.microblaze uClibc-0.9.27-uc0/extra/Configs/Config.microblaze
75 --- uClibc-0.9.27/extra/Configs/Config.microblaze       2005-01-12 08:59:21.000000000 +0100
76 +++ uClibc-0.9.27-uc0/extra/Configs/Config.microblaze   2005-01-26 07:37:19.000000000 +0100
77 @@ -9,7 +9,7 @@
78  config HAVE_ELF
79         bool
80         select ARCH_HAS_NO_MMU
81 -       select ARCH_HAS_C_SYMBOL_PREFIX
82 +       select ARCH_BIG_ENDIAN
83         select HAVE_NO_SHARED
84         select ARCH_HAS_NO_LDSO
85         default y
86 @@ -18,8 +18,8 @@
87         bool
88         default y
89  
90 -config ARCH_CFLAGS
91 -       string
92 +#config ARCH_CFLAGS
93 +#      string
94  
95  config ARCH_LDFLAGS
96         string
97 @@ -27,7 +27,7 @@
98  config LIBGCC_CFLAGS
99         string
100  
101 -config CROSS
102 -        string
103 -       default "mb-"
104 +config HAVE_ELF
105 +       bool
106 +       default y
107  
108 diff -urN uClibc-0.9.27/extra/Configs/Config.sh uClibc-0.9.27-uc0/extra/Configs/Config.sh
109 --- uClibc-0.9.27/extra/Configs/Config.sh       2005-01-12 08:59:21.000000000 +0100
110 +++ uClibc-0.9.27-uc0/extra/Configs/Config.sh   2005-02-10 03:09:15.000000000 +0100
111 @@ -58,7 +58,6 @@
112  
113  config CONFIG_SH4
114         select ARCH_HAS_MMU
115 -       select FORCE_SHAREABLE_TEXT_SEGMENTS
116         bool "SH4"
117  
118  config CONFIG_SH5
119 diff -urN uClibc-0.9.27/extra/scripts/fix_includes.sh uClibc-0.9.27-uc0/extra/scripts/fix_includes.sh
120 --- uClibc-0.9.27/extra/scripts/fix_includes.sh 2005-01-12 08:59:21.000000000 +0100
121 +++ uClibc-0.9.27-uc0/extra/scripts/fix_includes.sh     2005-07-08 03:26:56.000000000 +0200
122 @@ -51,8 +51,8 @@
123  HAS_MMU="y";
124  while [ -n "$1" ]; do
125      case $1 in
126 -       -k ) shift; if [ -n "$1" ]; then KERNEL_SOURCE=$1; shift; else usage; fi; ;;
127 -       -t ) shift; if [ -n "$1" ]; then TARGET_ARCH=$1; shift; else usage; fi; ;;
128 +       -k ) shift; if [ -n "$1" ]; then KERNEL_SOURCE="$1"; shift; else usage; fi; ;;
129 +       -t ) shift; if [ -n "$1" ]; then TARGET_ARCH="$1"; shift; else usage; fi; ;;
130         -n ) shift; HAS_MMU="n"; ;;
131         -* ) usage; ;;
132         * ) usage; ;;
133 @@ -167,6 +167,11 @@
134  ln -fs $KERNEL_SOURCE/include/asm include/asm
135  fi;
136  
137 +# 2.4 nommu targets may need include/asm-arch
138 +if [ "$HAS_MMU" != "y" ] && [ -d $KERNEL_SOURCE/include/asm-$TARGET_ARCH ]; then
139 +       ln -fs $KERNEL_SOURCE/include/asm-$TARGET_ARCH include/asm-$TARGET_ARCH
140 +fi
141 +       
142  
143  # Annoyingly, 2.6.x kernel headers also need an include/asm-generic/ directory
144  if [ $VERSION -eq 2 ] && [ $PATCHLEVEL -ge 6 ] ; then
145 diff -urN uClibc-0.9.27/include/atomic.h uClibc-0.9.27-uc0/include/atomic.h
146 --- uClibc-0.9.27/include/atomic.h      1970-01-01 01:00:00.000000000 +0100
147 +++ uClibc-0.9.27-uc0/include/atomic.h  2006-01-16 07:46:31.000000000 +0100
148 @@ -0,0 +1,261 @@
149 +/* Internal macros for atomic operations for GNU C Library.
150 +   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
151 +   This file is part of the GNU C Library.
152 +   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
153 +
154 +   The GNU C Library is free software; you can redistribute it and/or
155 +   modify it under the terms of the GNU Lesser General Public
156 +   License as published by the Free Software Foundation; either
157 +   version 2.1 of the License, or (at your option) any later version.
158 +
159 +   The GNU C Library is distributed in the hope that it will be useful,
160 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
161 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
162 +   Lesser General Public License for more details.
163 +
164 +   You should have received a copy of the GNU Lesser General Public
165 +   License along with the GNU C Library; if not, write to the Free
166 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
167 +   02111-1307 USA.  */
168 +
169 +#ifndef _ATOMIC_H
170 +#define _ATOMIC_H      1
171 +
172 +#include <stdlib.h>
173 +
174 +#include <bits/atomic.h>
175 +
176 +/* Wrapper macros to call pre_NN_post (mem, ...) where NN is the
177 +   bit width of *MEM.  The calling macro puts parens around MEM
178 +   and following args.  */
179 +#define __atomic_val_bysize(pre, post, mem, ...)                             \
180 +  ({                                                                         \
181 +    __typeof (*mem) __result;                                                \
182 +    if (sizeof (*mem) == 1)                                                  \
183 +      __result = pre##_8_##post (mem, __VA_ARGS__);                          \
184 +    else if (sizeof (*mem) == 2)                                             \
185 +      __result = pre##_16_##post (mem, __VA_ARGS__);                         \
186 +    else if (sizeof (*mem) == 4)                                             \
187 +      __result = pre##_32_##post (mem, __VA_ARGS__);                         \
188 +    else if (sizeof (*mem) == 8)                                             \
189 +      __result = pre##_64_##post (mem, __VA_ARGS__);                         \
190 +    else                                                                     \
191 +      abort ();                                                                      \
192 +    __result;                                                                \
193 +  })
194 +#define __atomic_bool_bysize(pre, post, mem, ...)                            \
195 +  ({                                                                         \
196 +    int __result;                                                            \
197 +    if (sizeof (*mem) == 1)                                                  \
198 +      __result = pre##_8_##post (mem, __VA_ARGS__);                          \
199 +    else if (sizeof (*mem) == 2)                                             \
200 +      __result = pre##_16_##post (mem, __VA_ARGS__);                         \
201 +    else if (sizeof (*mem) == 4)                                             \
202 +      __result = pre##_32_##post (mem, __VA_ARGS__);                         \
203 +    else if (sizeof (*mem) == 8)                                             \
204 +      __result = pre##_64_##post (mem, __VA_ARGS__);                         \
205 +    else                                                                     \
206 +      abort ();                                                                      \
207 +    __result;                                                                \
208 +  })
209 +
210 +
211 +/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL.
212 +   Return the old *MEM value.  */
213 +#if !defined atomic_compare_and_exchange_val_acq \
214 +    && defined __arch_compare_and_exchange_val_32_acq
215 +# define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
216 +  __atomic_val_bysize (__arch_compare_and_exchange_val,acq,                  \
217 +                      mem, newval, oldval)
218 +#endif
219 +
220 +
221 +#ifndef atomic_compare_and_exchange_val_rel
222 +# define atomic_compare_and_exchange_val_rel(mem, newval, oldval)            \
223 +  atomic_compare_and_exchange_val_acq (mem, newval, oldval)
224 +#endif
225 +
226 +
227 +/* Atomically store NEWVAL in *MEM if *MEM is equal to OLDVAL.
228 +   Return zero if *MEM was changed or non-zero if no exchange happened.  */
229 +#ifndef atomic_compare_and_exchange_bool_acq
230 +# ifdef __arch_compare_and_exchange_bool_32_acq
231 +#  define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
232 +  __atomic_bool_bysize (__arch_compare_and_exchange_bool,acq,                \
233 +                       mem, newval, oldval)
234 +#  else
235 +#   define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
236 +  ({ /* Cannot use __oldval here, because macros later in this file might     \
237 +       call this macro with __oldval argument.  */                           \
238 +     __typeof (oldval) __old = (oldval);                                     \
239 +     atomic_compare_and_exchange_val_acq (mem, newval, __old) != __old;              \
240 +  })
241 +# endif
242 +#endif
243 +
244 +
245 +#ifndef atomic_compare_and_exchange_bool_rel
246 +# define atomic_compare_and_exchange_bool_rel(mem, newval, oldval) \
247 +  atomic_compare_and_exchange_bool_acq (mem, newval, oldval)
248 +#endif
249 +
250 +
251 +/* Store NEWVALUE in *MEM and return the old value.  */
252 +#ifndef atomic_exchange_acq
253 +# define atomic_exchange_acq(mem, newvalue) \
254 +  ({ __typeof (*(mem)) __oldval;                                             \
255 +     __typeof (mem) __memp = (mem);                                          \
256 +     __typeof (*(mem)) __value = (newvalue);                                 \
257 +                                                                             \
258 +     do                                                                              \
259 +       __oldval = (*__memp);                                                 \
260 +     while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp,   \
261 +                                                                   __value,  \
262 +                                                                   __oldval),\
263 +                             0));                                            \
264 +                                                                             \
265 +     __oldval; })
266 +#endif
267 +
268 +#ifndef atomic_exchange_rel
269 +# define atomic_exchange_rel(mem, newvalue) atomic_exchange_acq (mem, newvalue)
270 +#endif
271 +
272 +
273 +/* Add VALUE to *MEM and return the old value of *MEM.  */
274 +#ifndef atomic_exchange_and_add
275 +# define atomic_exchange_and_add(mem, value) \
276 +  ({ __typeof (*(mem)) __oldval;                                             \
277 +     __typeof (mem) __memp = (mem);                                          \
278 +     __typeof (*(mem)) __value = (value);                                    \
279 +                                                                             \
280 +     do                                                                              \
281 +       __oldval = (*__memp);                                                 \
282 +     while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp,   \
283 +                                                                   __oldval  \
284 +                                                                   + __value,\
285 +                                                                   __oldval),\
286 +                             0));                                            \
287 +                                                                             \
288 +     __oldval; })
289 +#endif
290 +
291 +
292 +#ifndef atomic_add
293 +# define atomic_add(mem, value) (void) atomic_exchange_and_add ((mem), (value))
294 +#endif
295 +
296 +
297 +#ifndef atomic_increment
298 +# define atomic_increment(mem) atomic_add ((mem), 1)
299 +#endif
300 +
301 +
302 +#ifndef atomic_increment_val
303 +# define atomic_increment_val(mem) (atomic_exchange_and_add ((mem), 1) + 1)
304 +#endif
305 +
306 +
307 +/* Add one to *MEM and return true iff it's now zero.  */
308 +#ifndef atomic_increment_and_test
309 +# define atomic_increment_and_test(mem) \
310 +  (atomic_exchange_and_add ((mem), 1) + 1 == 0)
311 +#endif
312 +
313 +
314 +#ifndef atomic_decrement
315 +# define atomic_decrement(mem) atomic_add ((mem), -1)
316 +#endif
317 +
318 +
319 +#ifndef atomic_decrement_val
320 +# define atomic_decrement_val(mem) (atomic_exchange_and_add ((mem), -1) - 1)
321 +#endif
322 +
323 +
324 +/* Subtract 1 from *MEM and return true iff it's now zero.  */
325 +#ifndef atomic_decrement_and_test
326 +# define atomic_decrement_and_test(mem) \
327 +  (atomic_exchange_and_add ((mem), -1) == 1)
328 +#endif
329 +
330 +
331 +/* Decrement *MEM if it is > 0, and return the old value.  */
332 +#ifndef atomic_decrement_if_positive
333 +# define atomic_decrement_if_positive(mem) \
334 +  ({ __typeof (*(mem)) __oldval;                                             \
335 +     __typeof (mem) __memp = (mem);                                          \
336 +                                                                             \
337 +     do                                                                              \
338 +       {                                                                     \
339 +        __oldval = *__memp;                                                  \
340 +        if (__builtin_expect (__oldval <= 0, 0))                             \
341 +          break;                                                             \
342 +       }                                                                     \
343 +     while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp,   \
344 +                                                                   __oldval  \
345 +                                                                   - 1,      \
346 +                                                                   __oldval),\
347 +                             0));\
348 +     __oldval; })
349 +#endif
350 +
351 +
352 +#ifndef atomic_add_negative
353 +# define atomic_add_negative(mem, value)                                     \
354 +  ({ __typeof (value) __aan_value = (value);                                 \
355 +     atomic_exchange_and_add (mem, __aan_value) < -__aan_value; })
356 +#endif
357 +
358 +
359 +#ifndef atomic_add_zero
360 +# define atomic_add_zero(mem, value)                                         \
361 +  ({ __typeof (value) __aaz_value = (value);                                 \
362 +     atomic_exchange_and_add (mem, __aaz_value) == -__aaz_value; })
363 +#endif
364 +
365 +
366 +#ifndef atomic_bit_set
367 +# define atomic_bit_set(mem, bit) \
368 +  (void) atomic_bit_test_set(mem, bit)
369 +#endif
370 +
371 +
372 +#ifndef atomic_bit_test_set
373 +# define atomic_bit_test_set(mem, bit) \
374 +  ({ __typeof (*(mem)) __oldval;                                             \
375 +     __typeof (mem) __memp = (mem);                                          \
376 +     __typeof (*(mem)) __mask = ((__typeof (*(mem))) 1 << (bit));            \
377 +                                                                             \
378 +     do                                                                              \
379 +       __oldval = (*__memp);                                                 \
380 +     while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp,   \
381 +                                                                   __oldval  \
382 +                                                                   | __mask, \
383 +                                                                   __oldval),\
384 +                             0));                                            \
385 +                                                                             \
386 +     __oldval & __mask; })
387 +#endif
388 +
389 +
390 +#ifndef atomic_full_barrier
391 +# define atomic_full_barrier() __asm ("" ::: "memory")
392 +#endif
393 +
394 +
395 +#ifndef atomic_read_barrier
396 +# define atomic_read_barrier() atomic_full_barrier ()
397 +#endif
398 +
399 +
400 +#ifndef atomic_write_barrier
401 +# define atomic_write_barrier() atomic_full_barrier ()
402 +#endif
403 +
404 +
405 +#ifndef atomic_delay
406 +# define atomic_delay() do { /* nothing */ } while (0)
407 +#endif
408 +
409 +#endif /* atomic.h */
410 diff -urN uClibc-0.9.27/include/dlfcn.h uClibc-0.9.27-uc0/include/dlfcn.h
411 --- uClibc-0.9.27/include/dlfcn.h       2005-01-12 08:59:21.000000000 +0100
412 +++ uClibc-0.9.27-uc0/include/dlfcn.h   2005-01-26 07:37:19.000000000 +0100
413 @@ -59,7 +59,7 @@
414  /* When any of the above functions fails, call this function
415     to return a string describing the error.  Each call resets
416     the error string so that a following call returns null.  */
417 -extern char *dlerror (void) __THROW;
418 +extern const char *dlerror (void) __THROW;
419  
420  #ifdef __USE_GNU
421  /* Structure containing information about object searched using
422 diff -urN uClibc-0.9.27/include/elf.h uClibc-0.9.27-uc0/include/elf.h
423 --- uClibc-0.9.27/include/elf.h 2005-01-12 08:59:21.000000000 +0100
424 +++ uClibc-0.9.27-uc0/include/elf.h     2005-01-26 07:37:19.000000000 +0100
425 @@ -2546,6 +2546,25 @@
426  #define R_V850_NUM             25
427  
428  
429 +//jari
430 +#define EM_XILINX_MICROBLAZE 0xbaab
431 +
432 +/* Microblaze Relocations */
433 +#define R_MICROBLAZE_NONE 0
434 +#define R_MICROBLAZE_32 1
435 +#define R_MICROBLAZE_32_PCREL 2
436 +#define R_MICROBLAZE_64_PCREL 3
437 +#define R_MICROBLAZE_32_PCREL_LO 4
438 +#define R_MICROBLAZE_64 5
439 +#define R_MICROBLAZE_32_LO 6
440 +#define R_MICROBLAZE_SRO32 7
441 +#define R_MICROBLAZE_SRW32 8
442 +#define R_MICROBLAZE_64_NONE 9
443 +#define R_MICROBLAZE_32_SYM_OP_SYM 10     
444 +/* Keep this the last entry.  */
445 +#define R_MICROBLAZE_NUM 11
446 +
447 +
448  #define R_H8_NONE       0
449  #define R_H8_DIR32      1
450  #define R_H8_DIR32_28   2
451 diff -urN uClibc-0.9.27/include/features.h uClibc-0.9.27-uc0/include/features.h
452 --- uClibc-0.9.27/include/features.h    2005-01-12 08:59:21.000000000 +0100
453 +++ uClibc-0.9.27-uc0/include/features.h        2005-07-08 03:33:44.000000000 +0200
454 @@ -365,6 +365,11 @@
455    extern __typeof (name) aliasname __attribute__ ((alias (#name)));
456  /* This comes between the return type and function name in
457   *    a function definition to make that definition weak.  */
458 +#if __GNUC__ == 2
459 +# define weak_decl(name)       __asm__(".weak " #name ";");
460 +#else
461 +# define weak_decl(name)
462 +#endif
463  # define weak_function __attribute__ ((weak))
464  # define weak_const_function __attribute__ ((weak, __const__))
465  /* Tacking on "\n\t#" to the section name makes gcc put it's bogus
466 diff -urN uClibc-0.9.27/include/net/if_arp.h uClibc-0.9.27-uc0/include/net/if_arp.h
467 --- uClibc-0.9.27/include/net/if_arp.h  2005-01-12 08:59:21.000000000 +0100
468 +++ uClibc-0.9.27-uc0/include/net/if_arp.h      2005-01-26 07:37:19.000000000 +0100
469 @@ -96,7 +96,7 @@
470  #define ARPHRD_ADAPT   264
471  #define ARPHRD_ROSE    270
472  #define ARPHRD_X25     271             /* CCITT X.25.  */
473 -#define ARPHDR_HWX25   272             /* Boards with X.25 in firmware.  */
474 +#define ARPHRD_HWX25   272             /* Boards with X.25 in firmware.  */
475  #define ARPHRD_PPP     512
476  #define ARPHRD_CISCO   513             /* Cisco HDLC.  */
477  #define ARPHRD_HDLC    ARPHRD_CISCO
478 @@ -123,6 +123,7 @@
479  #define ARPHRD_FCPP    784             /* Point to point fibrechanel.  */
480  #define ARPHRD_FCAL    785             /* Fibrechanel arbitrated loop.  */
481  #define ARPHRD_FCPL    786             /* Fibrechanel public loop.  */
482 +#define ARPHRD_FCPFABRIC 787           /* Fibrechanel fabric.  */
483  #define ARPHRD_FCFABRIC 787            /* Fibrechanel fabric.  */
484  #define ARPHRD_IEEE802_TR 800          /* Magic type ident for TR.  */
485  #define ARPHRD_IEEE80211 801           /* IEEE 802.11.  */
486 diff -urN uClibc-0.9.27/include/net/if.h uClibc-0.9.27-uc0/include/net/if.h
487 --- uClibc-0.9.27/include/net/if.h      2005-01-12 08:59:21.000000000 +0100
488 +++ uClibc-0.9.27-uc0/include/net/if.h  2003-09-10 07:17:26.000000000 +0200
489 @@ -75,8 +75,10 @@
490  
491      IFF_PORTSEL = 0x2000,      /* Can set media type.  */
492  # define IFF_PORTSEL   IFF_PORTSEL
493 -    IFF_AUTOMEDIA = 0x4000     /* Auto media select active.  */
494 +    IFF_AUTOMEDIA = 0x4000,    /* Auto media select active.  */
495  # define IFF_AUTOMEDIA IFF_AUTOMEDIA
496 +       IFF_DYNAMIC = 0x8000      /* dialup device with changing addresses*/
497 +# define IFF_DYNAMIC IFF_DYNAMIC
498    };
499  
500  /* The ifaddr structure contains information about one address of an
501 diff -urN uClibc-0.9.27/include/netinet/in.h uClibc-0.9.27-uc0/include/netinet/in.h
502 --- uClibc-0.9.27/include/netinet/in.h  2005-01-12 08:59:21.000000000 +0100
503 +++ uClibc-0.9.27-uc0/include/netinet/in.h      2006-07-06 13:44:28.000000000 +0200
504 @@ -79,6 +79,8 @@
505  #define IPPROTO_PIM            IPPROTO_PIM
506      IPPROTO_COMP = 108,           /* Compression Header Protocol.  */
507  #define IPPROTO_COMP           IPPROTO_COMP
508 +    IPPROTO_SCTP = 132,    /* Stream Control Transmission Protocol.  */
509 +#define IPPROTO_SCTP           IPPROTO_SCTP
510      IPPROTO_RAW = 255,    /* Raw IP packets.  */
511  #define IPPROTO_RAW            IPPROTO_RAW
512      IPPROTO_MAX
513 diff -urN uClibc-0.9.27/include/stdint.h uClibc-0.9.27-uc0/include/stdint.h
514 --- uClibc-0.9.27/include/stdint.h      2005-01-12 08:59:21.000000000 +0100
515 +++ uClibc-0.9.27-uc0/include/stdint.h  2004-05-13 03:48:57.000000000 +0200
516 @@ -238,7 +238,7 @@
517  #  define UINTPTR_MAX          (4294967295U)
518  # endif
519  
520 -#if !defined(__H8300H__) && !defined(__H8300S__) 
521 +#if (__LONG_MAX__ != __LONG_LONG_MAX__) /* long long check */
522  /* Minimum for largest signed integral type.  */
523  # define INTMAX_MIN            (-__INT64_C(9223372036854775807)-1)
524  /* Maximum for largest signed integral type.  */
525 @@ -253,7 +253,7 @@
526  # define INTMAX_MAX            (LONG_LONG_MAX)
527  
528  /* Maximum for largest unsigned integral type.  */
529 -# define UINTMAX_MAX           (LONG_LONG_MAX<<1+1)
530 +# define UINTMAX_MAX           (LONG_LONG_MAX*2+1)
531  #endif
532  
533  /* Limits of other integer types.  */
534 diff -urN uClibc-0.9.27/ldso/ldso/dl-startup.c uClibc-0.9.27-uc0/ldso/ldso/dl-startup.c
535 --- uClibc-0.9.27/ldso/ldso/dl-startup.c        2005-01-12 08:59:21.000000000 +0100
536 +++ uClibc-0.9.27-uc0/ldso/ldso/dl-startup.c    2005-02-10 06:07:27.000000000 +0100
537 @@ -282,7 +282,7 @@
538         SEND_STDERR("scanning DYNAMIC section\n");
539  #endif
540         tpnt->dynamic_addr = dpnt;
541 -#ifdef __mips__
542 +#if defined(__mips__) || defined(__sh__)
543         /* MIPS cannot call functions here, must inline */
544         __dl_parse_dynamic_info(dpnt, tpnt->dynamic_info, NULL);
545  #else
546 diff -urN uClibc-0.9.27/ldso/ldso/ldso.c uClibc-0.9.27-uc0/ldso/ldso/ldso.c
547 --- uClibc-0.9.27/ldso/ldso/ldso.c      2005-01-12 08:59:21.000000000 +0100
548 +++ uClibc-0.9.27-uc0/ldso/ldso/ldso.c  2006-02-27 08:31:07.000000000 +0100
549 @@ -71,8 +71,8 @@
550  {
551  }
552  
553 -static unsigned char *_dl_malloc_addr = 0;     /* Lets _dl_malloc use the already allocated memory page */
554 -static unsigned char *_dl_mmap_zero   = 0;     /* Also used by _dl_malloc */
555 +unsigned char *_dl_malloc_addr = 0;    /* Lets _dl_malloc use the already allocated memory page */
556 +unsigned char *_dl_mmap_zero   = 0;    /* Also used by _dl_malloc */
557  
558  #if defined (__SUPPORT_LD_DEBUG__)
559  static void debug_fini (int status, void *arg)
560 diff -urN uClibc-0.9.27/ldso/ldso/Makefile uClibc-0.9.27-uc0/ldso/ldso/Makefile
561 --- uClibc-0.9.27/ldso/ldso/Makefile    2005-01-12 08:59:21.000000000 +0100
562 +++ uClibc-0.9.27-uc0/ldso/ldso/Makefile        2005-01-26 07:37:20.000000000 +0100
563 @@ -56,7 +56,7 @@
564  OBJS=$(AOBJS) $(COBJS)
565  
566  ifneq ($(strip $(SUPPORT_LD_DEBUG)),y)
567 -LDFLAGS+=-s
568 +# LDFLAGS+=-s
569  endif
570  
571  ifeq ($(strip $(SUPPORT_LD_DEBUG)),y)
572 @@ -70,6 +70,9 @@
573  #This stuff will not work with -fomit-frame-pointer
574  XXFLAGS := $(XXFLAGS:-fomit-frame-pointer=)
575  
576 +#This stuff will not work with -fomit-frame-pointer
577 +XXFLAGS := $(XXFLAGS:-fomit-frame-pointer=)
578 +
579  all: lib
580  
581  lib:: $(OBJS) $(DLINK_OBJS)
582 diff -urN uClibc-0.9.27/ldso/libdl/libdl.c uClibc-0.9.27-uc0/ldso/libdl/libdl.c
583 --- uClibc-0.9.27/ldso/libdl/libdl.c    2005-01-12 08:59:21.000000000 +0100
584 +++ uClibc-0.9.27-uc0/ldso/libdl/libdl.c        2005-01-26 12:53:44.000000000 +0100
585 @@ -547,7 +547,7 @@
586         return do_dlclose(vhandle, 1);
587  }
588  
589 -char *dlerror(void)
590 +const char *dlerror(void)
591  {
592         const char *retval;
593  
594 diff -urN uClibc-0.9.27/libc/inet/rpc/rpc_thread.c uClibc-0.9.27-uc0/libc/inet/rpc/rpc_thread.c
595 --- uClibc-0.9.27/libc/inet/rpc/rpc_thread.c    2005-01-12 08:59:21.000000000 +0100
596 +++ uClibc-0.9.27-uc0/libc/inet/rpc/rpc_thread.c        2005-07-08 03:33:44.000000000 +0200
597 @@ -35,6 +35,7 @@
598  }
599  
600  
601 +weak_decl(__pthread_once)
602  extern int weak_function __pthread_once (pthread_once_t *__once_control,
603                            void (*__init_routine) (void));
604  
605 diff -urN uClibc-0.9.27/libc/misc/assert/__assert.c uClibc-0.9.27-uc0/libc/misc/assert/__assert.c
606 --- uClibc-0.9.27/libc/misc/assert/__assert.c   2005-01-12 08:59:21.000000000 +0100
607 +++ uClibc-0.9.27-uc0/libc/misc/assert/__assert.c       2005-01-26 07:37:22.000000000 +0100
608 @@ -31,6 +31,7 @@
609  #include <stdio.h>
610  #include <stdlib.h>
611  #include <unistd.h>
612 +#include <syslog.h>
613  #include <bits/uClibc_uintmaxtostr.h>
614  
615  /* Get the prototype from assert.h as a double-check. */
616 @@ -65,6 +66,19 @@
617                                 ((function == NULL) ? "?function?" : function),
618                                 assertion
619                                 );
620 +               syslog(LOG_ERR,
621 +#if 0
622 +                               /* TODO: support program_name like glibc? */
623 +                               "%s: %s: %d: %s: Assertion `%s' failed.\n", program_name,
624 +#else
625 +                               "%s: %d: %s: Assertion `%s' failed.\n",
626 +#endif
627 +                               filename,
628 +                               linenumber,
629 +                               /* Function name isn't available with some compilers. */
630 +                               ((function == NULL) ? "?function?" : function),
631 +                               assertion
632 +                               );
633         }
634         abort();
635  }
636 diff -urN uClibc-0.9.27/libc/misc/internals/__errno_location.c uClibc-0.9.27-uc0/libc/misc/internals/__errno_location.c
637 --- uClibc-0.9.27/libc/misc/internals/__errno_location.c        2005-01-12 08:59:21.000000000 +0100
638 +++ uClibc-0.9.27-uc0/libc/misc/internals/__errno_location.c    2005-07-08 03:33:44.000000000 +0200
639 @@ -1,6 +1,7 @@
640  #include <errno.h>
641  #undef errno
642  
643 +weak_decl(__errno_location)
644  int * weak_const_function __errno_location (void)
645  {
646      return &errno;
647 diff -urN uClibc-0.9.27/libc/misc/internals/__h_errno_location.c uClibc-0.9.27-uc0/libc/misc/internals/__h_errno_location.c
648 --- uClibc-0.9.27/libc/misc/internals/__h_errno_location.c      2005-01-12 08:59:21.000000000 +0100
649 +++ uClibc-0.9.27-uc0/libc/misc/internals/__h_errno_location.c  2005-07-08 03:33:44.000000000 +0200
650 @@ -3,6 +3,7 @@
651  #include <netdb.h>
652  #undef h_errno
653  
654 +weak_decl(__h_errno_location)
655  int * weak_const_function __h_errno_location (void)
656  {
657      return &h_errno;
658 diff -urN uClibc-0.9.27/libc/misc/internals/__uClibc_main.c uClibc-0.9.27-uc0/libc/misc/internals/__uClibc_main.c
659 --- uClibc-0.9.27/libc/misc/internals/__uClibc_main.c   2005-01-12 08:59:21.000000000 +0100
660 +++ uClibc-0.9.27-uc0/libc/misc/internals/__uClibc_main.c       2006-04-24 15:45:17.000000000 +0200
661 @@ -33,13 +33,18 @@
662   * Prototypes.
663   */
664  extern int  main(int argc, char **argv, char **envp);
665 +weak_decl(_stdio_init)
666 +weak_decl(__errno_location)
667 +weak_decl(__h_errno_location)
668  extern void weak_function _stdio_init(void);
669  extern int *weak_const_function __errno_location(void);
670  extern int *weak_const_function __h_errno_location(void);
671  #ifdef __UCLIBC_HAS_LOCALE__
672 +weak_decl(_locale_init)
673  extern void weak_function _locale_init(void);
674  #endif
675  #ifdef __UCLIBC_HAS_THREADS__
676 +weak_decl(__pthread_initialize_minimal)
677  extern void weak_function __pthread_initialize_minimal(void);
678  #endif
679  
680 @@ -66,6 +71,7 @@
681  extern int __libc_fcntl(int fd, int cmd, ...);
682  extern int __libc_open(const char *file, int flags, ...);
683  
684 +#ifdef __ARCH_HAS_MMU__
685  static void __check_one_fd(int fd, int mode)
686  {
687      /* Check if the specified fd is already open */
688 @@ -103,6 +109,7 @@
689      }
690      return 1;
691  }
692 +#endif
693  
694  
695  /* __uClibc_init completely initialize uClibc so it is ready to use.
696 diff -urN uClibc-0.9.27/libc/misc/locale/locale.c uClibc-0.9.27-uc0/libc/misc/locale/locale.c
697 --- uClibc-0.9.27/libc/misc/locale/locale.c     2005-01-12 08:59:21.000000000 +0100
698 +++ uClibc-0.9.27-uc0/libc/misc/locale/locale.c 2005-07-08 03:33:45.000000000 +0200
699 @@ -1376,11 +1376,13 @@
700  
701  #ifdef __UCLIBC_HAS_THREADS__
702  
703 +weak_decl(__curlocale)
704  __locale_t weak_const_function __curlocale(void)
705  {
706      return __curlocale_var; /* This is overriden by the thread version. */
707  }
708  
709 +weak_decl(__curlocale_set)
710  __locale_t weak_function __curlocale_set(__locale_t newloc)
711  {
712         __locale_t oldloc = __curlocale_var;
713 diff -urN uClibc-0.9.27/libc/misc/regex/regex.c uClibc-0.9.27-uc0/libc/misc/regex/regex.c
714 --- uClibc-0.9.27/libc/misc/regex/regex.c       2005-01-12 08:59:21.000000000 +0100
715 +++ uClibc-0.9.27-uc0/libc/misc/regex/regex.c   2005-07-08 03:33:45.000000000 +0200
716 @@ -7955,12 +7955,14 @@
717  /* BSD has one and only one pattern buffer.  */
718  static struct re_pattern_buffer re_comp_buf;
719  
720 -char *
721  #ifdef _LIBC
722  /* Make these definitions weak in libc, so POSIX programs can redefine
723     these names if they don't use our functions, and still use
724     regcomp/regexec below without link errors.  */
725 -weak_function
726 +weak_decl(re_comp)
727 +char *weak_function
728 +#else
729 +char *
730  #endif
731  re_comp (s)
732      const char *s;
733 @@ -8009,9 +8011,11 @@
734  }
735  
736  
737 -int
738  #ifdef _LIBC
739 -weak_function
740 +weak_decl(re_exec)
741 +int weak_function
742 +#else
743 +int
744  #endif
745  re_exec (s)
746      const char *s;
747 diff -urN uClibc-0.9.27/libc/misc/time/time.c uClibc-0.9.27-uc0/libc/misc/time/time.c
748 --- uClibc-0.9.27/libc/misc/time/time.c 2005-01-12 08:59:21.000000000 +0100
749 +++ uClibc-0.9.27-uc0/libc/misc/time/time.c     2005-01-26 07:37:23.000000000 +0100
750 @@ -602,7 +602,7 @@
751  {
752         long sec;
753         int i, isdst, isleap, day, day0, monlen, mday;
754 -       int oday;                                       /* Note: oday can be uninitialized. */
755 +       int oday=0;                             /* Note: oday can be uninitialized. */
756  
757         isdst = 0;
758         if (r[1].tzname[0] != 0) {
759 @@ -2003,7 +2003,7 @@
760  {
761         register int *p;
762         time_t t1, t, v;
763 -       int wday;                                       /* Note: wday can be uninitialized. */
764 +       int wday=0;                                     /* Note: wday can be uninitialized. */
765  
766         {
767                 register const uint16_t *vp;
768 diff -urN uClibc-0.9.27/libc/misc/wchar/wchar.c uClibc-0.9.27-uc0/libc/misc/wchar/wchar.c
769 --- uClibc-0.9.27/libc/misc/wchar/wchar.c       2005-01-12 08:59:21.000000000 +0100
770 +++ uClibc-0.9.27-uc0/libc/misc/wchar/wchar.c   2005-07-08 03:33:45.000000000 +0200
771 @@ -1274,6 +1274,7 @@
772         return 0;                       /* No matching codeset! */
773  }
774  
775 +weak_decl(iconv_open)
776  iconv_t weak_function iconv_open(const char *tocode, const char *fromcode)
777  {
778         register _UC_iconv_t *px;
779 @@ -1296,6 +1297,7 @@
780         return (iconv_t)(-1);
781  }
782  
783 +weak_decl(iconv_close)
784  int weak_function iconv_close(iconv_t cd)
785  {
786         free(cd);
787 @@ -1303,6 +1305,7 @@
788         return 0;
789  }
790  
791 +weak_decl(iconv)
792  size_t weak_function iconv(iconv_t cd, char **__restrict inbuf,
793                                                    size_t *__restrict inbytesleft,
794                                                    char **__restrict outbuf,
795 diff -urN uClibc-0.9.27/libc/stdio/Makefile uClibc-0.9.27-uc0/libc/stdio/Makefile
796 --- uClibc-0.9.27/libc/stdio/Makefile   2005-01-12 08:59:21.000000000 +0100
797 +++ uClibc-0.9.27-uc0/libc/stdio/Makefile       2005-07-14 07:40:58.000000000 +0200
798 @@ -130,6 +130,16 @@
799         $(CC) $(CFLAGS) -c $< -o $@
800         $(STRIPTOOL) -x -R .note -R .comment $@
801  
802 +ifeq ($(TARGET_m68k),y)
803 +# The old gcc-2.95.3 m68k-elf compiler (and probably quite a few newer
804 +# versions) have an optimization bug that occassionaly produces a compiler
805 +# internal error. To work around this reduce optimization to -O0 for the
806 +# _fpmaxtostr.o.
807 +_fpmaxtostr.o: _fpmaxtostr.c
808 +       $(CC) $(CFLAGS) -O0 -c $< -o $@
809 +       $(STRIPTOOL) -x -R .note -R .comment $@
810 +endif
811 +
812  %_unlocked.o : %.c
813         $(CC) $(CFLAGS) -D__DO_UNLOCKED -c $< -o $@
814         $(STRIPTOOL) -x -R .note -R .comment $@
815 diff -urN uClibc-0.9.27/libc/stdio/scanf.c uClibc-0.9.27-uc0/libc/stdio/scanf.c
816 --- uClibc-0.9.27/libc/stdio/scanf.c    2005-01-12 08:59:21.000000000 +0100
817 +++ uClibc-0.9.27-uc0/libc/stdio/scanf.c        2005-07-08 06:39:35.000000000 +0200
818 @@ -237,7 +237,9 @@
819         f.__user_locking = 1;           /* Set user locking. */
820         __stdio_init_mutex(&f.__lock);
821  #endif
822 +#ifdef __STDIO_HAS_OPENLIST
823         f.__nextopen = NULL;
824 +#endif
825  
826         /* Set these last since __bufgetc initialization depends on
827          * __user_locking and only gets set if user locking is on. */
828 @@ -284,7 +286,9 @@
829         f.f.__user_locking = 1;         /* Set user locking. */
830         __stdio_init_mutex(&f.f.__lock);
831  #endif
832 +#ifdef __STDIO_HAS_OPENLIST
833         f.f.__nextopen = NULL;
834 +#endif
835  
836         return vfscanf(&f.f, fmt, ap);
837  }
838 @@ -415,7 +419,9 @@
839         f.__user_locking = 1;           /* Set user locking. */
840         __stdio_init_mutex(&f.__lock);
841  #endif
842 +#ifdef __STDIO_HAS_OPENLIST
843         f.__nextopen = NULL;
844 +#endif
845  
846         return vfwscanf(&f, format, arg);
847  }
848 diff -urN uClibc-0.9.27/libc/stdio/vasprintf.c uClibc-0.9.27-uc0/libc/stdio/vasprintf.c
849 --- uClibc-0.9.27/libc/stdio/vasprintf.c        2005-01-12 08:59:21.000000000 +0100
850 +++ uClibc-0.9.27-uc0/libc/stdio/vasprintf.c    2005-07-08 03:32:57.000000000 +0200
851 @@ -17,6 +17,27 @@
852  #warning Skipping vasprintf since no vsnprintf!
853  #else
854  
855 +/**********************************************************************/
856 +/* Deal with pre-C99 compilers. */
857 +
858 +#ifndef va_copy
859 +
860 +#ifdef __va_copy
861 +#define va_copy(A,B)   __va_copy(A,B)
862 +#else
863 +       /* TODO -- maybe create a bits/vacopy.h for arch specific versions
864 +        * to ensure we get the right behavior?  Either that or fall back
865 +        * on the portable (but costly in size) method of using a va_list *.
866 +        * That means a pointer derefs in the va_arg() invocations... */
867 +#warning Neither va_copy (C99/SUSv3) or __va_copy is defined.  Using a simple copy instead.  But you should really check that this is appropriate...
868 +       /* the glibc manual suggests that this will usually suffice when
869 +        __va_copy doesn't exist.  */
870 +#define va_copy(A,B)   A = B
871 +#endif
872 +
873 +#endif /* va_copy */
874 +/**********************************************************************/
875 +
876  int vasprintf(char **__restrict buf, const char * __restrict format,
877                          va_list arg)
878  {
879 diff -urN uClibc-0.9.27/libc/stdio/vdprintf.c uClibc-0.9.27-uc0/libc/stdio/vdprintf.c
880 --- uClibc-0.9.27/libc/stdio/vdprintf.c 2005-01-12 08:59:21.000000000 +0100
881 +++ uClibc-0.9.27-uc0/libc/stdio/vdprintf.c     2005-07-08 06:39:35.000000000 +0200
882 @@ -45,7 +45,9 @@
883         f.__user_locking = 1;           /* Set user locking. */
884         __stdio_init_mutex(&f.__lock);
885  #endif
886 +#ifdef __STDIO_HAS_OPENLIST
887         f.__nextopen = NULL;
888 +#endif
889  
890         rv = vfprintf(&f, format, arg);
891  
892 diff -urN uClibc-0.9.27/libc/stdio/vsnprintf.c uClibc-0.9.27-uc0/libc/stdio/vsnprintf.c
893 --- uClibc-0.9.27/libc/stdio/vsnprintf.c        2005-01-12 08:59:21.000000000 +0100
894 +++ uClibc-0.9.27-uc0/libc/stdio/vsnprintf.c    2005-07-08 06:39:35.000000000 +0200
895 @@ -43,7 +43,9 @@
896         f.__user_locking = 1;           /* Set user locking. */
897         __stdio_init_mutex(&f.__lock);
898  #endif
899 +#ifdef __STDIO_HAS_OPENLIST
900         f.__nextopen = NULL;
901 +#endif
902  
903         if (size > SIZE_MAX - (size_t) buf) {
904                 size = SIZE_MAX - (size_t) buf;
905 @@ -111,7 +113,9 @@
906         f.f.__user_locking = 1;         /* Set user locking. */
907         __stdio_init_mutex(&f.f.__lock);
908  #endif
909 +#ifdef __STDIO_HAS_OPENLIST
910         f.f.__nextopen = NULL;
911 +#endif
912  
913         rv = vfprintf((FILE *) &f, format, arg);
914         if (size) {
915 @@ -195,7 +199,9 @@
916         f.__user_locking = 1;           /* Set user locking. */
917         __stdio_init_mutex(&f.__lock);
918  #endif
919 +#ifdef __STDIO_HAS_OPENLIST
920         f.__nextopen = NULL;
921 +#endif
922  
923         rv = vfprintf(&f, format, arg);
924  
925 diff -urN uClibc-0.9.27/libc/stdlib/atexit.c uClibc-0.9.27-uc0/libc/stdlib/atexit.c
926 --- uClibc-0.9.27/libc/stdlib/atexit.c  2005-01-12 08:59:21.000000000 +0100
927 +++ uClibc-0.9.27-uc0/libc/stdlib/atexit.c      2006-05-25 16:01:12.000000000 +0200
928 @@ -32,6 +32,9 @@
929   * August 2002    Erik Andersen
930   *   Added locking so atexit and friends can be thread safe
931   *
932 + * August 2005    Stephen Warren
933 + *   Added __cxa_atexit and __cxa_finalize support
934 + *
935   */
936  
937  #define _GNU_SOURCE
938 @@ -39,7 +42,7 @@
939  #include <unistd.h>
940  #include <stdlib.h>
941  #include <errno.h>
942 -
943 +#include <atomic.h>
944  
945  #ifdef __UCLIBC_HAS_THREADS__
946  #include <pthread.h>
947 @@ -54,9 +57,12 @@
948  
949  typedef void (*aefuncp) (void);         /* atexit function pointer */
950  typedef void (*oefuncp) (int, void *);  /* on_exit function pointer */
951 +typedef void (*cxaefuncp) (void *);     /* __cxa_atexit function pointer */
952  typedef enum {
953 -       ef_atexit,
954 -       ef_on_exit
955 +    ef_free,
956 +    ef_in_use,
957 +    ef_on_exit,
958 +    ef_cxa_atexit
959  } ef_type; /* exit function types */
960  
961  /* this is in the L_exit object */
962 @@ -67,13 +73,21 @@
963  extern int __exit_count;
964  extern void __exit_handler(int);
965  struct exit_function {
966 -       ef_type type;   /* ef_atexit or ef_on_exit */
967 +        /*
968 +         * 'type' should be of type of the 'enum ef_type' above but since we
969 +         * need this element in an atomic operation we have to use 'long int'.
970 +         */
971 +        long int type; /* enum ef_type */
972         union {
973 -               aefuncp atexit;
974 -               struct {
975 -                       oefuncp func;
976 -                       void *arg;
977 -               } on_exit;
978 +                struct {
979 +                        oefuncp func;
980 +                        void *arg;
981 +                } on_exit;
982 +                struct {
983 +                        cxaefuncp func;
984 +                        void *arg;
985 +                        void* dso_handle;
986 +                } cxa_atexit;
987         } funcs;
988  };
989  #ifdef __UCLIBC_DYNAMIC_ATEXIT__
990 @@ -81,46 +95,41 @@
991  #else
992  extern struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT];
993  #endif
994 +extern struct exit_function *__new_exitfn (void);
995  
996 -#ifdef L_atexit
997 -       /*
998 +/* this is in the L___cxa_atexit object */
999 +extern int __cxa_atexit (cxaefuncp, void *arg, void *dso_handle);
1000 +
1001 +
1002 +/* remove old_atexit after 0.9.29 */
1003 +#if defined(L_atexit) || defined(L_old_atexit)
1004 +extern void *__dso_handle __attribute__ ((__weak__));
1005 +
1006 +/*
1007   * register a function to be called at normal program termination
1008   * (the registered function takes no arguments)
1009 -        */
1010 -int atexit(aefuncp func)
1011 + */
1012 +#ifdef L_atexit
1013 +int attribute_hidden atexit(aefuncp func)
1014 +#else
1015 +int old_atexit(aefuncp func)
1016 +#endif
1017  {
1018 -    struct exit_function *efp;
1019 -
1020 -    LOCK;
1021 -    if (func) {
1022 -#ifdef __UCLIBC_DYNAMIC_ATEXIT__
1023 -       /* If we are out of function table slots, make some more */
1024 -       if (__exit_slots < __exit_count+1) {
1025 -           efp=realloc(__exit_function_table, 
1026 -                                       (__exit_slots+20)*sizeof(struct exit_function));
1027 -           if (efp==NULL) {
1028 -               UNLOCK;
1029 -               __set_errno(ENOMEM);
1030 -               return -1;
1031 -           }
1032 -               __exit_function_table = efp;
1033 -           __exit_slots+=20;
1034 -       }
1035 +    /*
1036 +     * glibc casts aefuncp to cxaefuncp.
1037 +     * This seems dodgy, but I guess callling a function with more
1038 +     * parameters than it needs will work everywhere?
1039 +     */
1040 +#ifdef ARCH_HAS_MMU
1041 +    return __cxa_atexit((cxaefuncp)func, NULL,
1042 +                        &__dso_handle == NULL ? NULL : __dso_handle);
1043  #else
1044 -       if (__exit_count >= __UCLIBC_MAX_ATEXIT) {
1045 -           UNLOCK;
1046 -           __set_errno(ENOMEM);
1047 -           return -1;
1048 -       }
1049 +    return __cxa_atexit((cxaefuncp)func, NULL, NULL);
1050  #endif
1051 -       __exit_cleanup = __exit_handler; /* enable cleanup */
1052 -       efp = &__exit_function_table[__exit_count++];
1053 -       efp->type = ef_atexit;
1054 -       efp->funcs.atexit = func;
1055 -    }
1056 -    UNLOCK;
1057 -    return 0;
1058  }
1059 +#ifndef L_atexit
1060 +weak_alias(old_atexit,atexit);
1061 +#endif
1062  #endif
1063  
1064  #ifdef L_on_exit
1065 @@ -133,41 +142,92 @@
1066  int on_exit(oefuncp func, void *arg)
1067  {
1068      struct exit_function *efp;
1069 +    
1070 +    if (func == NULL) {
1071 +        return 0;
1072 +    }
1073  
1074 -    LOCK;
1075 -    if (func) {
1076 -#ifdef __UCLIBC_DYNAMIC_ATEXIT__
1077 -       /* If we are out of function table slots, make some more */
1078 -       if (__exit_slots < __exit_count+1) {
1079 -           efp=realloc(__exit_function_table, 
1080 -                                       (__exit_slots+20)*sizeof(struct exit_function));
1081 -           if (efp==NULL) {
1082 -               UNLOCK;
1083 -               __set_errno(ENOMEM);
1084 -               return -1;
1085 -           }
1086 -               __exit_function_table=efp;
1087 -           __exit_slots+=20;
1088 -       }
1089 -#else
1090 -       if (__exit_count >= __UCLIBC_MAX_ATEXIT) {
1091 -           UNLOCK;
1092 -           __set_errno(ENOMEM);
1093 -           return -1;
1094 -       }
1095 +    efp = __new_exitfn();
1096 +    if (efp == NULL) {
1097 +        return -1;
1098 +    }
1099 +
1100 +    efp->funcs.on_exit.func = func;
1101 +    efp->funcs.on_exit.arg = arg;
1102 +    /* assign last for thread safety, since we're now unlocked */
1103 +    efp->type = ef_on_exit;
1104 +
1105 +    return 0;
1106 +}
1107  #endif
1108  
1109 -       __exit_cleanup = __exit_handler; /* enable cleanup */
1110 -       efp = &__exit_function_table[__exit_count++];
1111 -       efp->type = ef_on_exit;
1112 -       efp->funcs.on_exit.func = func;
1113 -       efp->funcs.on_exit.arg = arg;
1114 +#ifdef L___cxa_atexit
1115 +extern int __cxa_atexit (cxaefuncp func, void *arg, void *dso_handle)
1116 +{
1117 +    struct exit_function *efp;
1118 +    
1119 +    if (func == NULL) {
1120 +        return 0;
1121      }
1122 -    UNLOCK;
1123 +
1124 +    efp = __new_exitfn();
1125 +    if (efp == NULL) {
1126 +        return -1;
1127 +    }
1128 +
1129 +    efp->funcs.cxa_atexit.func = func;
1130 +    efp->funcs.cxa_atexit.arg = arg;
1131 +    efp->funcs.cxa_atexit.dso_handle = dso_handle;
1132 +    /* assign last for thread safety, since we're now unlocked */
1133 +    efp->type = ef_cxa_atexit;
1134 +
1135      return 0;
1136  }
1137  #endif
1138  
1139 +#ifdef L___cxa_finalize
1140 +/*
1141 + * If D is non-NULL, call all functions registered with `__cxa_atexit'
1142 + *  with the same dso handle.  Otherwise, if D is NULL, call all of the
1143 + *  registered handlers.
1144 + */
1145 +void __cxa_finalize (void *dso_handle)
1146 +{
1147 +    struct exit_function *efp;
1148 +    int exit_count_snapshot = __exit_count;
1149 +
1150 +    /* In reverse order */
1151 +    while (exit_count_snapshot) {
1152 +        efp = &__exit_function_table[--exit_count_snapshot];
1153 +
1154 +        /*
1155 +         * We check dso_handle match before we verify the type of the union entry.
1156 +         * However, the atomic_exchange will validate that we were really "allowed"
1157 +         * to read dso_handle...
1158 +         */
1159 +        if ((dso_handle == NULL || dso_handle == efp->funcs.cxa_atexit.dso_handle)
1160 +            /* We don't want to run this cleanup more than once. */
1161 +            && !atomic_compare_and_exchange_bool_acq(&efp->type, ef_free, ef_cxa_atexit)
1162 +           ) {
1163 +            /* glibc passes status (0) too, but that's not in the prototype */
1164 +            (*efp->funcs.cxa_atexit.func)(efp->funcs.cxa_atexit.arg);
1165 +        }
1166 +    }
1167 +
1168 +#if 0 /* haven't looked into this yet... */
1169 +    /*
1170 +     * Remove the registered fork handlers. We do not have to
1171 +     * unregister anything if the program is going to terminate anyway.
1172 +     */
1173 +#ifdef UNREGISTER_ATFORK
1174 +    if (d != NULL) {
1175 +        UNREGISTER_ATFORK (d);
1176 +    }
1177 +#endif
1178 +#endif
1179 +}
1180 +#endif
1181 +
1182  #ifdef L___exit_handler
1183  int __exit_count = 0; /* Number of registered exit functions */
1184  #ifdef __UCLIBC_DYNAMIC_ATEXIT__
1185 @@ -177,6 +237,45 @@
1186  struct exit_function __exit_function_table[__UCLIBC_MAX_ATEXIT];
1187  #endif
1188  
1189 +/*
1190 + * Find and return a new exit_function pointer, for atexit,
1191 + * onexit and __cxa_atexit to initialize
1192 + */
1193 +struct exit_function *__new_exitfn(void)
1194 +{
1195 +    struct exit_function *efp;
1196 +
1197 +    LOCK;
1198 +
1199 +#ifdef __UCLIBC_DYNAMIC_ATEXIT__
1200 +    /* If we are out of function table slots, make some more */
1201 +    if (__exit_slots < __exit_count+1) {
1202 +        efp=realloc(__exit_function_table, 
1203 +                    (__exit_slots+20)*sizeof(struct exit_function));
1204 +        if (efp == NULL) {
1205 +            UNLOCK;
1206 +            __set_errno(ENOMEM);
1207 +            return 0;
1208 +        }
1209 +        __exit_function_table = efp;
1210 +        __exit_slots += 20;
1211 +    }
1212 +#else
1213 +    if (__exit_count >= __UCLIBC_MAX_ATEXIT) {
1214 +        UNLOCK;
1215 +        __set_errno(ENOMEM);
1216 +        return 0;
1217 +    }
1218 +#endif
1219 +
1220 +    __exit_cleanup = __exit_handler; /* enable cleanup */
1221 +    efp = &__exit_function_table[__exit_count++];
1222 +    efp->type = ef_in_use;
1223 +
1224 +    UNLOCK;
1225 +
1226 +    return efp;
1227 +}
1228  
1229  /*
1230   * Handle the work of executing the registered exit functions
1231 @@ -196,11 +295,12 @@
1232                                 (efp->funcs.on_exit.func) (status, efp->funcs.on_exit.arg);
1233                         }
1234                         break;
1235 -               case ef_atexit:
1236 -                       if (efp->funcs.atexit) {
1237 -                               (efp->funcs.atexit) ();
1238 -                       }
1239 -                       break;
1240 +                case ef_cxa_atexit:
1241 +                        if (efp->funcs.cxa_atexit.func) {
1242 +                                /* glibc passes status too, but that's not in the prototype */
1243 +                                (efp->funcs.cxa_atexit.func) (efp->funcs.cxa_atexit.arg);
1244 +                        }
1245 +                        break;
1246                 }
1247         }
1248  #ifdef __UCLIBC_DYNAMIC_ATEXIT__
1249 @@ -212,6 +312,7 @@
1250  #endif
1251  
1252  #ifdef L_exit
1253 +weak_decl(_stdio_term)
1254  extern void weak_function _stdio_term(void);
1255  void (*__exit_cleanup) (int) = 0;
1256  #ifdef __UCLIBC_HAS_THREADS__
1257 diff -urN uClibc-0.9.27/libc/stdlib/bsd_getpt.c uClibc-0.9.27-uc0/libc/stdlib/bsd_getpt.c
1258 --- uClibc-0.9.27/libc/stdlib/bsd_getpt.c       2005-01-12 08:59:21.000000000 +0100
1259 +++ uClibc-0.9.27-uc0/libc/stdlib/bsd_getpt.c   2004-06-21 01:49:19.000000000 +0200
1260 @@ -35,7 +35,7 @@
1261  
1262  /* Letters indicating the position within a series.  */
1263  #ifndef PTYNAME2
1264 -#define PTYNAME2 "0123456789abcdefghijklmnopqrstuv";
1265 +#define PTYNAME2 "0123456789abcdefghijklmnopqrstuv"
1266  #endif
1267  const char _ptyname2[] = PTYNAME2;
1268  
1269 diff -urN uClibc-0.9.27/libc/stdlib/getpt.c uClibc-0.9.27-uc0/libc/stdlib/getpt.c
1270 --- uClibc-0.9.27/libc/stdlib/getpt.c   2005-01-12 08:59:21.000000000 +0100
1271 +++ uClibc-0.9.27-uc0/libc/stdlib/getpt.c       2004-06-21 01:49:19.000000000 +0200
1272 @@ -82,6 +82,8 @@
1273           close (fd);
1274  #if !defined __UNIX98PTY_ONLY__
1275           have_no_dev_ptmx = 1;
1276 +#else
1277 +         return -1;
1278  #endif
1279  #endif
1280         }
1281 @@ -102,8 +104,8 @@
1282  }
1283  
1284  #if !defined __UNIX98PTY_ONLY__
1285 -# define PTYNAME1 "pqrstuvwxyzabcde";
1286 -# define PTYNAME2 "0123456789abcdef";
1287 +# define PTYNAME1 "pqrstuvwxyzabcde"
1288 +# define PTYNAME2 "0123456789abcdef"
1289  
1290  # define __getpt __bsd_getpt
1291  # include "bsd_getpt.c"
1292 diff -urN uClibc-0.9.27/libc/stdlib/Makefile uClibc-0.9.27-uc0/libc/stdlib/Makefile
1293 --- uClibc-0.9.27/libc/stdlib/Makefile  2005-01-12 08:59:21.000000000 +0100
1294 +++ uClibc-0.9.27-uc0/libc/stdlib/Makefile      2006-02-27 08:31:09.000000000 +0100
1295 @@ -79,7 +79,10 @@
1296  # wcstod wcstof wcstold
1297  
1298  MSRC2 = atexit.c
1299 -MOBJ2 = atexit.o on_exit.o __exit_handler.o exit.o
1300 +MOBJ2 = on_exit.o __cxa_atexit.o __cxa_finalize.o __exit_handler.o exit.o
1301 +ifeq ($(COMPAT_ATEXIT),y)
1302 +MOBJ2 += old_atexit.o
1303 +endif
1304  
1305  CSRC = abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c mkstemp64.c \
1306         rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \
1307 @@ -117,7 +120,7 @@
1308         $(CC) $(CFLAGS) -DL_$* -D__UCLIBC_DO_XLOCALE $< -c -o $*.o
1309         $(STRIPTOOL) -x -R .note -R .comment $*.o
1310  
1311 -$(MOBJ2): $(MSRC2)
1312 +$(MOBJ2) atexit.o: $(MSRC2)
1313         $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
1314         $(STRIPTOOL) -x -R .note -R .comment $*.o
1315  
1316 diff -urN uClibc-0.9.27/libc/stdlib/malloc-simple/alloc.c uClibc-0.9.27-uc0/libc/stdlib/malloc-simple/alloc.c
1317 --- uClibc-0.9.27/libc/stdlib/malloc-simple/alloc.c     2005-01-12 08:59:21.000000000 +0100
1318 +++ uClibc-0.9.27-uc0/libc/stdlib/malloc-simple/alloc.c 2005-07-08 03:33:45.000000000 +0200
1319 @@ -101,6 +101,7 @@
1320  #endif
1321  
1322  #ifdef L_free
1323 +weak_decl(__libc_free_aligned)
1324  extern int weak_function __libc_free_aligned(void *ptr);
1325  void free(void *ptr)
1326  {
1327 @@ -123,7 +124,7 @@
1328  #ifdef L_memalign
1329  #ifdef __UCLIBC_HAS_THREADS__
1330  #include <pthread.h>
1331 -pthread_mutex_t __malloc_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1332 +static pthread_mutex_t __malloc_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1333  # define LOCK  __pthread_mutex_lock(&__malloc_lock)
1334  # define UNLOCK        __pthread_mutex_unlock(&__malloc_lock);
1335  #else
1336 diff -urN uClibc-0.9.27/libc/stdlib/malloc-standard/free.c uClibc-0.9.27-uc0/libc/stdlib/malloc-standard/free.c
1337 --- uClibc-0.9.27/libc/stdlib/malloc-standard/free.c    2005-01-12 08:59:21.000000000 +0100
1338 +++ uClibc-0.9.27-uc0/libc/stdlib/malloc-standard/free.c        2006-02-27 08:31:09.000000000 +0100
1339 @@ -16,6 +16,7 @@
1340  
1341  #include "malloc.h"
1342  
1343 +static int __malloc_trim(size_t pad, mstate av);
1344  
1345  /* ------------------------- malloc_trim -------------------------
1346    malloc_trim(size_t pad);
1347 diff -urN uClibc-0.9.27/libc/stdlib/stdlib.c uClibc-0.9.27-uc0/libc/stdlib/stdlib.c
1348 --- uClibc-0.9.27/libc/stdlib/stdlib.c  2005-01-12 08:59:21.000000000 +0100
1349 +++ uClibc-0.9.27-uc0/libc/stdlib/stdlib.c      2005-01-26 07:37:23.000000000 +0100
1350 @@ -36,7 +36,6 @@
1351  #define _GNU_SOURCE
1352  #include <limits.h>
1353  #include <stdint.h>
1354 -#include <inttypes.h>
1355  #include <ctype.h>
1356  #include <errno.h>
1357  #include <assert.h>
1358 @@ -50,7 +49,10 @@
1359  #define abs __ignore_abs
1360  #endif
1361  #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
1362 +#define strtoimax __ignore_strtoimax
1363 +#define strtoumax __ignore_strtoumax
1364  #define llabs __ignore_llabs
1365 +#define imaxabs __ignore_imaxabs
1366  #define atoll __ignore_atoll
1367  #define strtoll __ignore_strtoll
1368  #define strtoull __ignore_strtoull
1369 @@ -62,6 +64,7 @@
1370  #define wcstoull_l __ignore_wcstoull_l
1371  #endif
1372  
1373 +#include <inttypes.h>
1374  #include <stdlib.h>
1375  #include <locale.h>
1376  
1377 @@ -117,6 +120,9 @@
1378  #endif
1379  #if defined(ULLONG_MAX) && (ULLONG_MAX == ULONG_MAX)
1380  #undef llabs
1381 +#undef imaxabs
1382 +#undef strtoimax
1383 +#undef strtoumax
1384  #undef atoll
1385  #undef strtoll
1386  #undef strtoull
1387 @@ -543,7 +549,7 @@
1388  
1389  #if defined(L__stdlib_strto_ll) || defined(L__stdlib_strto_ll_l)
1390  
1391 -#if defined(ULLONG_MAX) && (LLONG_MAX > LONG_MAX)
1392 +#if defined(ULLONG_MAX) // && (LLONG_MAX > LONG_MAX)
1393  
1394  #if defined(L__stdlib_wcsto_ll) || defined(L__stdlib_wcsto_ll_l)
1395  #define _stdlib_strto_ll _stdlib_wcsto_ll
1396 diff -urN uClibc-0.9.27/libc/sysdeps/linux/alpha/bits/atomic.h uClibc-0.9.27-uc0/libc/sysdeps/linux/alpha/bits/atomic.h
1397 --- uClibc-0.9.27/libc/sysdeps/linux/alpha/bits/atomic.h        1970-01-01 01:00:00.000000000 +0100
1398 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/alpha/bits/atomic.h    2006-01-16 07:46:31.000000000 +0100
1399 @@ -0,0 +1,369 @@
1400 +/* Copyright (C) 2003 Free Software Foundation, Inc.
1401 +   This file is part of the GNU C Library.
1402 +
1403 +   The GNU C Library is free software; you can redistribute it and/or
1404 +   modify it under the terms of the GNU Lesser General Public
1405 +   License as published by the Free Software Foundation; either
1406 +   version 2.1 of the License, or (at your option) any later version.
1407 +
1408 +   The GNU C Library is distributed in the hope that it will be useful,
1409 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1410 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1411 +   Lesser General Public License for more details.
1412 +
1413 +   You should have received a copy of the GNU Lesser General Public
1414 +   License along with the GNU C Library; if not, write to the Free
1415 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1416 +   02111-1307 USA.  */
1417 +
1418 +#include <stdint.h>
1419 +
1420 +typedef int8_t atomic8_t;
1421 +typedef uint8_t uatomic8_t;
1422 +typedef int_fast8_t atomic_fast8_t;
1423 +typedef uint_fast8_t uatomic_fast8_t;
1424 +
1425 +typedef int16_t atomic16_t;
1426 +typedef uint16_t uatomic16_t;
1427 +typedef int_fast16_t atomic_fast16_t;
1428 +typedef uint_fast16_t uatomic_fast16_t;
1429 +
1430 +typedef int32_t atomic32_t;
1431 +typedef uint32_t uatomic32_t;
1432 +typedef int_fast32_t atomic_fast32_t;
1433 +typedef uint_fast32_t uatomic_fast32_t;
1434 +
1435 +typedef int64_t atomic64_t;
1436 +typedef uint64_t uatomic64_t;
1437 +typedef int_fast64_t atomic_fast64_t;
1438 +typedef uint_fast64_t uatomic_fast64_t;
1439 +
1440 +typedef intptr_t atomicptr_t;
1441 +typedef uintptr_t uatomicptr_t;
1442 +typedef intmax_t atomic_max_t;
1443 +typedef uintmax_t uatomic_max_t;
1444 +
1445 +
1446 +#ifdef UP
1447 +# define __MB          /* nothing */
1448 +#else
1449 +# define __MB          "       mb\n"
1450 +#endif
1451 +
1452 +
1453 +/* Compare and exchange.  For all of the "xxx" routines, we expect a
1454 +   "__prev" and a "__cmp" variable to be provided by the enclosing scope,
1455 +   in which values are returned.  */
1456 +
1457 +#define __arch_compare_and_exchange_xxx_8_int(mem, new, old, mb1, mb2) \
1458 +({                                                                     \
1459 +  unsigned long __tmp, __snew, __addr64;                               \
1460 +  __asm__ __volatile__ (                                               \
1461 +               mb1                                                     \
1462 +       "       andnot  %[__addr8],7,%[__addr64]\n"                     \
1463 +       "       insbl   %[__new],%[__addr8],%[__snew]\n"                \
1464 +       "1:     ldq_l   %[__tmp],0(%[__addr64])\n"                      \
1465 +       "       extbl   %[__tmp],%[__addr8],%[__prev]\n"                \
1466 +       "       cmpeq   %[__prev],%[__old],%[__cmp]\n"                  \
1467 +       "       beq     %[__cmp],2f\n"                                  \
1468 +       "       mskbl   %[__tmp],%[__addr8],%[__tmp]\n"                 \
1469 +       "       or      %[__snew],%[__tmp],%[__tmp]\n"                  \
1470 +       "       stq_c   %[__tmp],0(%[__addr64])\n"                      \
1471 +       "       beq     %[__tmp],1b\n"                                  \
1472 +               mb2                                                     \
1473 +       "2:"                                                            \
1474 +       : [__prev] "=&r" (__prev),                                      \
1475 +         [__snew] "=&r" (__snew),                                      \
1476 +         [__tmp] "=&r" (__tmp),                                        \
1477 +         [__cmp] "=&r" (__cmp),                                        \
1478 +         [__addr64] "=&r" (__addr64)                                   \
1479 +       : [__addr8] "r" (mem),                                          \
1480 +         [__old] "Ir" ((uint64_t)(uint8_t)(uint64_t)(old)),            \
1481 +         [__new] "r" (new)                                             \
1482 +       : "memory");                                                    \
1483 +})
1484 +
1485 +#define __arch_compare_and_exchange_xxx_16_int(mem, new, old, mb1, mb2) \
1486 +({                                                                     \
1487 +  unsigned long __tmp, __snew, __addr64;                               \
1488 +  __asm__ __volatile__ (                                               \
1489 +               mb1                                                     \
1490 +       "       andnot  %[__addr16],7,%[__addr64]\n"                    \
1491 +       "       inswl   %[__new],%[__addr16],%[__snew]\n"               \
1492 +       "1:     ldq_l   %[__tmp],0(%[__addr64])\n"                      \
1493 +       "       extwl   %[__tmp],%[__addr16],%[__prev]\n"               \
1494 +       "       cmpeq   %[__prev],%[__old],%[__cmp]\n"                  \
1495 +       "       beq     %[__cmp],2f\n"                                  \
1496 +       "       mskwl   %[__tmp],%[__addr16],%[__tmp]\n"                \
1497 +       "       or      %[__snew],%[__tmp],%[__tmp]\n"                  \
1498 +       "       stq_c   %[__tmp],0(%[__addr64])\n"                      \
1499 +       "       beq     %[__tmp],1b\n"                                  \
1500 +               mb2                                                     \
1501 +       "2:"                                                            \
1502 +       : [__prev] "=&r" (__prev),                                      \
1503 +         [__snew] "=&r" (__snew),                                      \
1504 +         [__tmp] "=&r" (__tmp),                                        \
1505 +         [__cmp] "=&r" (__cmp),                                        \
1506 +         [__addr64] "=&r" (__addr64)                                   \
1507 +       : [__addr16] "r" (mem),                                         \
1508 +         [__old] "Ir" ((uint64_t)(uint16_t)(uint64_t)(old)),           \
1509 +         [__new] "r" (new)                                             \
1510 +       : "memory");                                                    \
1511 +})
1512 +
1513 +#define __arch_compare_and_exchange_xxx_32_int(mem, new, old, mb1, mb2) \
1514 +({                                                                     \
1515 +  __asm__ __volatile__ (                                               \
1516 +               mb1                                                     \
1517 +       "1:     ldl_l   %[__prev],%[__mem]\n"                           \
1518 +       "       cmpeq   %[__prev],%[__old],%[__cmp]\n"                  \
1519 +       "       beq     %[__cmp],2f\n"                                  \
1520 +       "       mov     %[__new],%[__cmp]\n"                            \
1521 +       "       stl_c   %[__cmp],%[__mem]\n"                            \
1522 +       "       beq     %[__cmp],1b\n"                                  \
1523 +               mb2                                                     \
1524 +       "2:"                                                            \
1525 +       : [__prev] "=&r" (__prev),                                      \
1526 +         [__cmp] "=&r" (__cmp)                                         \
1527 +       : [__mem] "m" (*(mem)),                                         \
1528 +         [__old] "Ir" ((uint64_t)(atomic32_t)(uint64_t)(old)),         \
1529 +         [__new] "Ir" (new)                                            \
1530 +       : "memory");                                                    \
1531 +})
1532 +
1533 +#define __arch_compare_and_exchange_xxx_64_int(mem, new, old, mb1, mb2) \
1534 +({                                                                     \
1535 +  __asm__ __volatile__ (                                               \
1536 +               mb1                                                     \
1537 +       "1:     ldq_l   %[__prev],%[__mem]\n"                           \
1538 +       "       cmpeq   %[__prev],%[__old],%[__cmp]\n"                  \
1539 +       "       beq     %[__cmp],2f\n"                                  \
1540 +       "       mov     %[__new],%[__cmp]\n"                            \
1541 +       "       stq_c   %[__cmp],%[__mem]\n"                            \
1542 +       "       beq     %[__cmp],1b\n"                                  \
1543 +               mb2                                                     \
1544 +       "2:"                                                            \
1545 +       : [__prev] "=&r" (__prev),                                      \
1546 +         [__cmp] "=&r" (__cmp)                                         \
1547 +       : [__mem] "m" (*(mem)),                                         \
1548 +         [__old] "Ir" ((uint64_t)(old)),                               \
1549 +         [__new] "Ir" (new)                                            \
1550 +       : "memory");                                                    \
1551 +})
1552 +
1553 +/* For all "bool" routines, we return FALSE if exchange succesful.  */
1554 +
1555 +#define __arch_compare_and_exchange_bool_8_int(mem, new, old, mb1, mb2)        \
1556 +({ unsigned long __prev; int __cmp;                                    \
1557 +   __arch_compare_and_exchange_xxx_8_int(mem, new, old, mb1, mb2);     \
1558 +   !__cmp; })
1559 +
1560 +#define __arch_compare_and_exchange_bool_16_int(mem, new, old, mb1, mb2) \
1561 +({ unsigned long __prev; int __cmp;                                    \
1562 +   __arch_compare_and_exchange_xxx_16_int(mem, new, old, mb1, mb2);    \
1563 +   !__cmp; })
1564 +
1565 +#define __arch_compare_and_exchange_bool_32_int(mem, new, old, mb1, mb2) \
1566 +({ unsigned long __prev; int __cmp;                                    \
1567 +   __arch_compare_and_exchange_xxx_32_int(mem, new, old, mb1, mb2);    \
1568 +   !__cmp; })
1569 +
1570 +#define __arch_compare_and_exchange_bool_64_int(mem, new, old, mb1, mb2) \
1571 +({ unsigned long __prev; int __cmp;                                    \
1572 +   __arch_compare_and_exchange_xxx_64_int(mem, new, old, mb1, mb2);    \
1573 +   !__cmp; })
1574 +
1575 +/* For all "val" routines, return the old value whether exchange
1576 +   successful or not.  */
1577 +
1578 +#define __arch_compare_and_exchange_val_8_int(mem, new, old, mb1, mb2) \
1579 +({ unsigned long __prev; int __cmp;                                    \
1580 +   __arch_compare_and_exchange_xxx_8_int(mem, new, old, mb1, mb2);     \
1581 +   (typeof (*mem))__prev; })
1582 +
1583 +#define __arch_compare_and_exchange_val_16_int(mem, new, old, mb1, mb2) \
1584 +({ unsigned long __prev; int __cmp;                                    \
1585 +   __arch_compare_and_exchange_xxx_16_int(mem, new, old, mb1, mb2);    \
1586 +   (typeof (*mem))__prev; })
1587 +
1588 +#define __arch_compare_and_exchange_val_32_int(mem, new, old, mb1, mb2) \
1589 +({ unsigned long __prev; int __cmp;                                    \
1590 +   __arch_compare_and_exchange_xxx_32_int(mem, new, old, mb1, mb2);    \
1591 +   (typeof (*mem))__prev; })
1592 +
1593 +#define __arch_compare_and_exchange_val_64_int(mem, new, old, mb1, mb2) \
1594 +({ unsigned long __prev; int __cmp;                                    \
1595 +   __arch_compare_and_exchange_xxx_64_int(mem, new, old, mb1, mb2);    \
1596 +   (typeof (*mem))__prev; })
1597 +
1598 +/* Compare and exchange with "acquire" semantics, ie barrier after.  */
1599 +
1600 +#define atomic_compare_and_exchange_bool_acq(mem, new, old)    \
1601 +  __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
1602 +                       mem, new, old, "", __MB)
1603 +
1604 +#define atomic_compare_and_exchange_val_acq(mem, new, old)     \
1605 +  __atomic_val_bysize (__arch_compare_and_exchange_val, int,   \
1606 +                      mem, new, old, "", __MB)
1607 +
1608 +/* Compare and exchange with "release" semantics, ie barrier before.  */
1609 +
1610 +#define atomic_compare_and_exchange_bool_rel(mem, new, old)    \
1611 +  __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
1612 +                       mem, new, old, __MB, "")
1613 +
1614 +#define atomic_compare_and_exchange_val_rel(mem, new, old)     \
1615 +  __atomic_val_bysize (__arch_compare_and_exchange_val, int,   \
1616 +                      mem, new, old, __MB, "")
1617 +
1618 +
1619 +/* Atomically store value and return the previous value.  */
1620 +
1621 +#define __arch_exchange_8_int(mem, value, mb1, mb2)                    \
1622 +({                                                                     \
1623 +  unsigned long __ret, __tmp, __addr64, __sval;                                \
1624 +  __asm__ __volatile__ (                                               \
1625 +               mb1                                                     \
1626 +       "       andnot  %[__addr8],7,%[__addr64]\n"                     \
1627 +       "       insbl   %[__value],%[__addr8],%[__sval]\n"              \
1628 +       "1:     ldq_l   %[__tmp],0(%[__addr64])\n"                      \
1629 +       "       extbl   %[__tmp],%[__addr8],%[__ret]\n"                 \
1630 +       "       mskbl   %[__tmp],%[__addr8],%[__tmp]\n"                 \
1631 +       "       or      %[__sval],%[__tmp],%[__tmp]\n"                  \
1632 +       "       stq_c   %[__tmp],0(%[__addr64])\n"                      \
1633 +       "       beq     %[__tmp],1b\n"                                  \
1634 +               mb2                                                     \
1635 +       : [__ret] "=&r" (__ret),                                        \
1636 +         [__sval] "=&r" (__sval),                                      \
1637 +         [__tmp] "=&r" (__tmp),                                        \
1638 +         [__addr64] "=&r" (__addr64)                                   \
1639 +       : [__addr8] "r" (mem),                                          \
1640 +         [__value] "r" (value)                                         \
1641 +       : "memory");                                                    \
1642 +  __ret; })
1643 +
1644 +#define __arch_exchange_16_int(mem, value, mb1, mb2)                   \
1645 +({                                                                     \
1646 +  unsigned long __ret, __tmp, __addr64, __sval;                                \
1647 +  __asm__ __volatile__ (                                               \
1648 +               mb1                                                     \
1649 +       "       andnot  %[__addr16],7,%[__addr64]\n"                    \
1650 +       "       inswl   %[__value],%[__addr16],%[__sval]\n"             \
1651 +       "1:     ldq_l   %[__tmp],0(%[__addr64])\n"                      \
1652 +       "       extwl   %[__tmp],%[__addr16],%[__ret]\n"                \
1653 +       "       mskwl   %[__tmp],%[__addr16],%[__tmp]\n"                \
1654 +       "       or      %[__sval],%[__tmp],%[__tmp]\n"                  \
1655 +       "       stq_c   %[__tmp],0(%[__addr64])\n"                      \
1656 +       "       beq     %[__tmp],1b\n"                                  \
1657 +               mb2                                                     \
1658 +       : [__ret] "=&r" (__ret),                                        \
1659 +         [__sval] "=&r" (__sval),                                      \
1660 +         [__tmp] "=&r" (__tmp),                                        \
1661 +         [__addr64] "=&r" (__addr64)                                   \
1662 +       : [__addr16] "r" (mem),                                         \
1663 +         [__value] "r" (value)                                         \
1664 +       : "memory");                                                    \
1665 +  __ret; })
1666 +
1667 +#define __arch_exchange_32_int(mem, value, mb1, mb2)                   \
1668 +({                                                                     \
1669 +  signed int __ret, __tmp;                                             \
1670 +  __asm__ __volatile__ (                                               \
1671 +               mb1                                                     \
1672 +       "1:     ldl_l   %[__ret],%[__mem]\n"                            \
1673 +       "       mov     %[__val],%[__tmp]\n"                            \
1674 +       "       stl_c   %[__tmp],%[__mem]\n"                            \
1675 +       "       beq     %[__tmp],1b\n"                                  \
1676 +               mb2                                                     \
1677 +       : [__ret] "=&r" (__ret),                                        \
1678 +         [__tmp] "=&r" (__tmp)                                         \
1679 +       : [__mem] "m" (*(mem)),                                         \
1680 +         [__val] "Ir" (value)                                          \
1681 +       : "memory");                                                    \
1682 +  __ret; })
1683 +
1684 +#define __arch_exchange_64_int(mem, value, mb1, mb2)                   \
1685 +({                                                                     \
1686 +  unsigned long __ret, __tmp;                                          \
1687 +  __asm__ __volatile__ (                                               \
1688 +               mb1                                                     \
1689 +       "1:     ldq_l   %[__ret],%[__mem]\n"                            \
1690 +       "       mov     %[__val],%[__tmp]\n"                            \
1691 +       "       stq_c   %[__tmp],%[__mem]\n"                            \
1692 +       "       beq     %[__tmp],1b\n"                                  \
1693 +               mb2                                                     \
1694 +       : [__ret] "=&r" (__ret),                                        \
1695 +         [__tmp] "=&r" (__tmp)                                         \
1696 +       : [__mem] "m" (*(mem)),                                         \
1697 +         [__val] "Ir" (value)                                          \
1698 +       : "memory");                                                    \
1699 +  __ret; })
1700 +
1701 +#define atomic_exchange_acq(mem, value) \
1702 +  __atomic_val_bysize (__arch_exchange, int, mem, value, "", __MB)
1703 +
1704 +#define atomic_exchange_rel(mem, value) \
1705 +  __atomic_val_bysize (__arch_exchange, int, mem, value, __MB, "")
1706 +
1707 +
1708 +/* Atomically add value and return the previous (unincremented) value.  */
1709 +
1710 +#define __arch_exchange_and_add_8_int(mem, value, mb1, mb2) \
1711 +  ({ __builtin_trap (); 0; })
1712 +
1713 +#define __arch_exchange_and_add_16_int(mem, value, mb1, mb2) \
1714 +  ({ __builtin_trap (); 0; })
1715 +
1716 +#define __arch_exchange_and_add_32_int(mem, value, mb1, mb2)           \
1717 +({                                                                     \
1718 +  signed int __ret, __tmp;                                             \
1719 +  __asm__ __volatile__ (                                               \
1720 +               mb1                                                     \
1721 +       "1:     ldl_l   %[__ret],%[__mem]\n"                            \
1722 +       "       addl    %[__ret],%[__val],%[__tmp]\n"                   \
1723 +       "       stl_c   %[__tmp],%[__mem]\n"                            \
1724 +       "       beq     %[__tmp],1b\n"                                  \
1725 +               mb2                                                     \
1726 +       : [__ret] "=&r" (__ret),                                        \
1727 +         [__tmp] "=&r" (__tmp)                                         \
1728 +       : [__mem] "m" (*(mem)),                                         \
1729 +         [__val] "Ir" ((signed int)(value))                            \
1730 +       : "memory");                                                    \
1731 +  __ret; })
1732 +
1733 +#define __arch_exchange_and_add_64_int(mem, value, mb1, mb2)           \
1734 +({                                                                     \
1735 +  unsigned long __ret, __tmp;                                          \
1736 +  __asm__ __volatile__ (                                               \
1737 +               mb1                                                     \
1738 +       "1:     ldq_l   %[__ret],%[__mem]\n"                            \
1739 +       "       addq    %[__ret],%[__val],%[__tmp]\n"                   \
1740 +       "       stq_c   %[__tmp],%[__mem]\n"                            \
1741 +       "       beq     %[__tmp],1b\n"                                  \
1742 +               mb2                                                     \
1743 +       : [__ret] "=&r" (__ret),                                        \
1744 +         [__tmp] "=&r" (__tmp)                                         \
1745 +       : [__mem] "m" (*(mem)),                                         \
1746 +         [__val] "Ir" ((unsigned long)(value))                         \
1747 +       : "memory");                                                    \
1748 +  __ret; })
1749 +
1750 +/* ??? Barrier semantics for atomic_exchange_and_add appear to be 
1751 +   undefined.  Use full barrier for now, as that's safe.  */
1752 +#define atomic_exchange_and_add(mem, value) \
1753 +  __atomic_val_bysize (__arch_exchange_and_add, int, mem, value, __MB, __MB)
1754 +
1755 +
1756 +/* ??? Blah, I'm lazy.  Implement these later.  Can do better than the
1757 +   compare-and-exchange loop provided by generic code.
1758 +
1759 +#define atomic_decrement_if_positive(mem)
1760 +#define atomic_bit_test_set(mem, bit)
1761 +
1762 +*/
1763 +
1764 +#ifndef UP
1765 +# define atomic_full_barrier() __asm ("mb" : : : "memory");
1766 +# define atomic_read_barrier() __asm ("mb" : : : "memory");
1767 +# define atomic_write_barrier()        __asm ("wmb" : : : "memory");
1768 +#endif
1769 diff -urN uClibc-0.9.27/libc/sysdeps/linux/arm/crt0.S uClibc-0.9.27-uc0/libc/sysdeps/linux/arm/crt0.S
1770 --- uClibc-0.9.27/libc/sysdeps/linux/arm/crt0.S 2005-01-12 08:59:21.000000000 +0100
1771 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/arm/crt0.S     2005-07-08 00:57:15.000000000 +0200
1772 @@ -96,11 +96,14 @@
1773  #ifdef __PIC__
1774         /* Store the address of _init in r3 as an argument to main() */
1775         adr r5, .L_init
1776 -       ldr r3, .L_init
1777 +       ldr r6, .L_init
1778 +       ldr r3, .L_init+4
1779 +       sub r3, r3, r6
1780         add r3, r3, r5
1781  
1782         /* Push _fini onto the stack as the final argument to main() */
1783 -       ldr r4, .L_init + 4
1784 +       ldr r4, .L_init+8
1785 +       sub r4, r4, r6
1786         add r4, r4, r5
1787  #else
1788         /* Store the address of _init in r3 as an argument to main() */
1789 @@ -122,8 +125,9 @@
1790  
1791  #if (defined L_crt1 ) && defined __UCLIBC_CTOR_DTOR__ && defined __PIC__
1792  .L_init:
1793 -       .word _init - .L_init
1794 -       .word _fini - .L_init
1795 +       .word .L_init
1796 +       .word _init
1797 +       .word _fini
1798  #endif
1799  
1800  /* We need this stuff to make gdb behave itself, otherwise
1801 diff -urN uClibc-0.9.27/libc/sysdeps/linux/arm/sys/ucontext.h uClibc-0.9.27-uc0/libc/sysdeps/linux/arm/sys/ucontext.h
1802 --- uClibc-0.9.27/libc/sysdeps/linux/arm/sys/ucontext.h 2005-01-12 08:59:21.000000000 +0100
1803 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/arm/sys/ucontext.h     2005-01-26 07:37:24.000000000 +0100
1804 @@ -87,7 +87,7 @@
1805      unsigned long     uc_flags;
1806      struct ucontext  *uc_link;
1807      stack_t           uc_stack;
1808 -    struct sigcontext uc_mcontext;
1809 +    mcontext_t        uc_mcontext;
1810      sigset_t          uc_sigmask;   /* mask last for extensibility */
1811  } ucontext_t;
1812  
1813 diff -urN uClibc-0.9.27/libc/sysdeps/linux/common/bits/atomic.h uClibc-0.9.27-uc0/libc/sysdeps/linux/common/bits/atomic.h
1814 --- uClibc-0.9.27/libc/sysdeps/linux/common/bits/atomic.h       1970-01-01 01:00:00.000000000 +0100
1815 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/common/bits/atomic.h   2006-01-16 07:46:31.000000000 +0100
1816 @@ -0,0 +1,43 @@
1817 +/* Copyright (C) 2003 Free Software Foundation, Inc.
1818 +   This file is part of the GNU C Library.
1819 +   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
1820 +
1821 +   The GNU C Library is free software; you can redistribute it and/or
1822 +   modify it under the terms of the GNU Lesser General Public
1823 +   License as published by the Free Software Foundation; either
1824 +   version 2.1 of the License, or (at your option) any later version.
1825 +
1826 +   The GNU C Library is distributed in the hope that it will be useful,
1827 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1828 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1829 +   Lesser General Public License for more details.
1830 +
1831 +   You should have received a copy of the GNU Lesser General Public
1832 +   License along with the GNU C Library; if not, write to the Free
1833 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1834 +   02111-1307 USA.  */
1835 +
1836 +#ifndef _BITS_ATOMIC_H
1837 +#define _BITS_ATOMIC_H 1
1838 +
1839 +/* We have by default no support for atomic operations.  So define
1840 +   them non-atomic.  If this is a problem somebody will have to come
1841 +   up with real definitions.  */
1842 +
1843 +/* The only basic operation needed is compare and exchange.  */
1844 +#define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
1845 +  ({ __typeof (mem) __gmemp = (mem);                                 \
1846 +     __typeof (*mem) __gret = *__gmemp;                                      \
1847 +     __typeof (*mem) __gnewval = (newval);                           \
1848 +                                                                     \
1849 +     if (__gret == (oldval))                                         \
1850 +       *__gmemp = __gnewval;                                         \
1851 +     __gret; })
1852 +
1853 +#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval) \
1854 +  ({ __typeof (mem) __gmemp = (mem);                                 \
1855 +     __typeof (*mem) __gnewval = (newval);                           \
1856 +                                                                     \
1857 +     *__gmemp == (oldval) ? (*__gmemp = __gnewval, 0) : 1; })
1858 +
1859 +#endif /* bits/atomic.h */
1860 diff -urN uClibc-0.9.27/libc/sysdeps/linux/common/bits/uClibc_stdio.h uClibc-0.9.27-uc0/libc/sysdeps/linux/common/bits/uClibc_stdio.h
1861 --- uClibc-0.9.27/libc/sysdeps/linux/common/bits/uClibc_stdio.h 2005-01-12 08:59:21.000000000 +0100
1862 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/common/bits/uClibc_stdio.h     2005-07-08 06:39:36.000000000 +0200
1863 @@ -457,6 +457,8 @@
1864  
1865  #else
1866  
1867 +#define __stdin stdin
1868 +
1869  #endif /* __STDIO_GETC_MACRO */
1870  
1871  
1872 @@ -515,5 +517,8 @@
1873  
1874  #  endif
1875  # endif
1876 +#else
1877 +
1878 +#define __stdout stdout
1879  
1880  #endif /* __STDIO_PUTC_MACRO */
1881 diff -urN uClibc-0.9.27/libc/sysdeps/linux/common/cmsg_nxthdr.c uClibc-0.9.27-uc0/libc/sysdeps/linux/common/cmsg_nxthdr.c
1882 --- uClibc-0.9.27/libc/sysdeps/linux/common/cmsg_nxthdr.c       2005-01-12 08:59:21.000000000 +0100
1883 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/common/cmsg_nxthdr.c   2005-02-28 07:06:19.000000000 +0100
1884 @@ -34,7 +34,7 @@
1885    if ((unsigned char *) (cmsg + 1) >= ((unsigned char *) mhdr->msg_control
1886                                        + mhdr->msg_controllen)
1887        || ((unsigned char *) cmsg + CMSG_ALIGN (cmsg->cmsg_len)
1888 -         >= ((unsigned char *) mhdr->msg_control + mhdr->msg_controllen)))
1889 +         > ((unsigned char *) mhdr->msg_control + mhdr->msg_controllen)))
1890      /* No more entries.  */
1891      return NULL;
1892    return cmsg;
1893 diff -urN uClibc-0.9.27/libc/sysdeps/linux/common/create_module.c uClibc-0.9.27-uc0/libc/sysdeps/linux/common/create_module.c
1894 --- uClibc-0.9.27/libc/sysdeps/linux/common/create_module.c     2005-01-12 08:59:21.000000000 +0100
1895 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/common/create_module.c 2005-01-26 12:53:45.000000000 +0100
1896 @@ -32,6 +32,7 @@
1897  #ifdef __NR_create_module
1898  
1899  #if defined(__i386__) || defined(__m68k__) || defined(__arm__) || defined(__cris__) || defined(__i960__)
1900 +#ifdef __NR_create_module
1901  #define __NR___create_module  __NR_create_module
1902  #ifdef __STR_NR_create_module
1903  #define __STR_NR___create_module  __STR_NR_create_module
1904 @@ -51,6 +52,13 @@
1905         }
1906         return ret;
1907  }
1908 +#else
1909 +unsigned long create_module(const char *name, size_t size)
1910 +{
1911 +       __set_errno(ENOSYS);
1912 +       return(-1);
1913 +}
1914 +#endif
1915  #elif defined(__alpha__)
1916  #define __NR___create_module  __NR_create_module
1917  /* Alpha doesn't have the same problem, exactly, but a bug in older
1918 diff -urN uClibc-0.9.27/libc/sysdeps/linux/common/pread_write.c uClibc-0.9.27-uc0/libc/sysdeps/linux/common/pread_write.c
1919 --- uClibc-0.9.27/libc/sysdeps/linux/common/pread_write.c       2005-01-12 08:59:21.000000000 +0100
1920 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/common/pread_write.c   2003-10-08 07:46:43.000000000 +0200
1921 @@ -48,7 +48,7 @@
1922  
1923  ssize_t __libc_pread(int fd, void *buf, size_t count, off_t offset)
1924  { 
1925 -       return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR (offset >> 31, offset)));
1926 +       return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR ((off_t)0, offset)));
1927  }
1928  weak_alias (__libc_pread, pread)
1929  
1930 @@ -73,7 +73,7 @@
1931  
1932  ssize_t __libc_pwrite(int fd, const void *buf, size_t count, off_t offset)
1933  { 
1934 -       return(__syscall_pwrite(fd,buf,count,__LONG_LONG_PAIR (offset >> 31, offset)));
1935 +       return(__syscall_pwrite(fd,buf,count,__LONG_LONG_PAIR ((off_t)0, offset)));
1936  }
1937  weak_alias (__libc_pwrite, pwrite)
1938  
1939 diff -urN uClibc-0.9.27/libc/sysdeps/linux/cris/crt0.c uClibc-0.9.27-uc0/libc/sysdeps/linux/cris/crt0.c
1940 --- uClibc-0.9.27/libc/sysdeps/linux/cris/crt0.c        2005-01-12 08:59:21.000000000 +0100
1941 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/cris/crt0.c    2005-07-08 03:33:45.000000000 +0200
1942 @@ -32,6 +32,8 @@
1943  extern void __uClibc_start_main(int argc, char **argv, char **envp, 
1944         void (*app_init)(void), void (*app_fini)(void))
1945           __attribute__ ((__noreturn__));
1946 +weak_decl(_init)
1947 +weak_decl(_fini)
1948  extern void weak_function _init(void);
1949  extern void weak_function _fini(void);
1950  
1951 diff -urN uClibc-0.9.27/libc/sysdeps/linux/i386/bits/atomic.h uClibc-0.9.27-uc0/libc/sysdeps/linux/i386/bits/atomic.h
1952 --- uClibc-0.9.27/libc/sysdeps/linux/i386/bits/atomic.h 1970-01-01 01:00:00.000000000 +0100
1953 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/i386/bits/atomic.h     2006-01-16 07:46:31.000000000 +0100
1954 @@ -0,0 +1,366 @@
1955 +/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
1956 +   This file is part of the GNU C Library.
1957 +   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
1958 +
1959 +   The GNU C Library is free software; you can redistribute it and/or
1960 +   modify it under the terms of the GNU Lesser General Public
1961 +   License as published by the Free Software Foundation; either
1962 +   version 2.1 of the License, or (at your option) any later version.
1963 +
1964 +   The GNU C Library is distributed in the hope that it will be useful,
1965 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
1966 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1967 +   Lesser General Public License for more details.
1968 +
1969 +   You should have received a copy of the GNU Lesser General Public
1970 +   License along with the GNU C Library; if not, write to the Free
1971 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1972 +   02111-1307 USA.  */
1973 +
1974 +#include <stdint.h>
1975 +
1976 +
1977 +typedef int8_t atomic8_t;
1978 +typedef uint8_t uatomic8_t;
1979 +typedef int_fast8_t atomic_fast8_t;
1980 +typedef uint_fast8_t uatomic_fast8_t;
1981 +
1982 +typedef int16_t atomic16_t;
1983 +typedef uint16_t uatomic16_t;
1984 +typedef int_fast16_t atomic_fast16_t;
1985 +typedef uint_fast16_t uatomic_fast16_t;
1986 +
1987 +typedef int32_t atomic32_t;
1988 +typedef uint32_t uatomic32_t;
1989 +typedef int_fast32_t atomic_fast32_t;
1990 +typedef uint_fast32_t uatomic_fast32_t;
1991 +
1992 +typedef int64_t atomic64_t;
1993 +typedef uint64_t uatomic64_t;
1994 +typedef int_fast64_t atomic_fast64_t;
1995 +typedef uint_fast64_t uatomic_fast64_t;
1996 +
1997 +typedef intptr_t atomicptr_t;
1998 +typedef uintptr_t uatomicptr_t;
1999 +typedef intmax_t atomic_max_t;
2000 +typedef uintmax_t uatomic_max_t;
2001 +
2002 +
2003 +#ifndef LOCK_PREFIX
2004 +# ifdef UP
2005 +#  define LOCK_PREFIX  /* nothing */
2006 +# else
2007 +#  define LOCK_PREFIX "lock;"
2008 +# endif
2009 +#endif
2010 +
2011 +
2012 +#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
2013 +  ({ __typeof (*mem) ret;                                                    \
2014 +     __asm __volatile (LOCK_PREFIX "cmpxchgb %b2, %1"                        \
2015 +                      : "=a" (ret), "=m" (*mem)                              \
2016 +                      : "q" (newval), "m" (*mem), "0" (oldval));             \
2017 +     ret; })
2018 +
2019 +#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
2020 +  ({ __typeof (*mem) ret;                                                    \
2021 +     __asm __volatile (LOCK_PREFIX "cmpxchgw %w2, %1"                        \
2022 +                      : "=a" (ret), "=m" (*mem)                              \
2023 +                      : "r" (newval), "m" (*mem), "0" (oldval));             \
2024 +     ret; })
2025 +
2026 +#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
2027 +  ({ __typeof (*mem) ret;                                                    \
2028 +     __asm __volatile (LOCK_PREFIX "cmpxchgl %2, %1"                         \
2029 +                      : "=a" (ret), "=m" (*mem)                              \
2030 +                      : "r" (newval), "m" (*mem), "0" (oldval));             \
2031 +     ret; })
2032 +
2033 +/* XXX We do not really need 64-bit compare-and-exchange.  At least
2034 +   not in the moment.  Using it would mean causing portability
2035 +   problems since not many other 32-bit architectures have support for
2036 +   such an operation.  So don't define any code for now.  If it is
2037 +   really going to be used the code below can be used on Intel Pentium
2038 +   and later, but NOT on i486.  */
2039 +#if 1
2040 +# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
2041 +  ({ __typeof (*mem) ret = *(mem); abort (); ret = (newval); ret = (oldval); })
2042 +#else
2043 +# ifdef __PIC__
2044 +#  define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
2045 +  ({ __typeof (*mem) ret;                                                    \
2046 +     __asm __volatile ("xchgl %2, %%ebx\n\t"                                 \
2047 +                      LOCK_PREFIX "cmpxchg8b %1\n\t"                         \
2048 +                      "xchgl %2, %%ebx"                                      \
2049 +                      : "=A" (ret), "=m" (*mem)                              \
2050 +                      : "DS" (((unsigned long long int) (newval))            \
2051 +                              & 0xffffffff),                                 \
2052 +                        "c" (((unsigned long long int) (newval)) >> 32),     \
2053 +                        "m" (*mem), "a" (((unsigned long long int) (oldval)) \
2054 +                                         & 0xffffffff),                      \
2055 +                        "d" (((unsigned long long int) (oldval)) >> 32));    \
2056 +     ret; })
2057 +# else
2058 +#  define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
2059 +  ({ __typeof (*mem) ret;                                                    \
2060 +     __asm __volatile (LOCK_PREFIX "cmpxchg8b %1"                            \
2061 +                      : "=A" (ret), "=m" (*mem)                              \
2062 +                      : "b" (((unsigned long long int) (newval))             \
2063 +                             & 0xffffffff),                                  \
2064 +                        "c" (((unsigned long long int) (newval)) >> 32),     \
2065 +                        "m" (*mem), "a" (((unsigned long long int) (oldval)) \
2066 +                                         & 0xffffffff),                      \
2067 +                        "d" (((unsigned long long int) (oldval)) >> 32));    \
2068 +     ret; })
2069 +# endif
2070 +#endif
2071 +
2072 +
2073 +/* Note that we need no lock prefix.  */
2074 +#define atomic_exchange_acq(mem, newvalue) \
2075 +  ({ __typeof (*mem) result;                                                 \
2076 +     if (sizeof (*mem) == 1)                                                 \
2077 +       __asm __volatile ("xchgb %b0, %1"                                     \
2078 +                        : "=r" (result), "=m" (*mem)                         \
2079 +                        : "0" (newvalue), "m" (*mem));                       \
2080 +     else if (sizeof (*mem) == 2)                                            \
2081 +       __asm __volatile ("xchgw %w0, %1"                                     \
2082 +                        : "=r" (result), "=m" (*mem)                         \
2083 +                        : "0" (newvalue), "m" (*mem));                       \
2084 +     else if (sizeof (*mem) == 4)                                            \
2085 +       __asm __volatile ("xchgl %0, %1"                                              \
2086 +                        : "=r" (result), "=m" (*mem)                         \
2087 +                        : "0" (newvalue), "m" (*mem));                       \
2088 +     else                                                                    \
2089 +       {                                                                     \
2090 +        result = 0;                                                          \
2091 +        abort ();                                                            \
2092 +       }                                                                     \
2093 +     result; })
2094 +
2095 +
2096 +#define atomic_exchange_and_add(mem, value) \
2097 +  ({ __typeof (*mem) __result;                                               \
2098 +     __typeof (value) __addval = (value);                                    \
2099 +     if (sizeof (*mem) == 1)                                                 \
2100 +       __asm __volatile (LOCK_PREFIX "xaddb %b0, %1"                         \
2101 +                        : "=r" (__result), "=m" (*mem)                       \
2102 +                        : "0" (__addval), "m" (*mem));                       \
2103 +     else if (sizeof (*mem) == 2)                                            \
2104 +       __asm __volatile (LOCK_PREFIX "xaddw %w0, %1"                         \
2105 +                        : "=r" (__result), "=m" (*mem)                       \
2106 +                        : "0" (__addval), "m" (*mem));                       \
2107 +     else if (sizeof (*mem) == 4)                                            \
2108 +       __asm __volatile (LOCK_PREFIX "xaddl %0, %1"                          \
2109 +                        : "=r" (__result), "=m" (*mem)                       \
2110 +                        : "0" (__addval), "m" (*mem));                       \
2111 +     else                                                                    \
2112 +       {                                                                     \
2113 +        __typeof (mem) __memp = (mem);                                       \
2114 +        __typeof (*mem) __tmpval;                                            \
2115 +        __result = *__memp;                                                  \
2116 +        do                                                                   \
2117 +          __tmpval = __result;                                               \
2118 +        while ((__result = __arch_compare_and_exchange_val_64_acq            \
2119 +                (__memp, __result + __addval, __result)) == __tmpval);       \
2120 +       }                                                                     \
2121 +     __result; })
2122 +
2123 +
2124 +#define atomic_add(mem, value) \
2125 +  (void) ({ if (__builtin_constant_p (value) && (value) == 1)                \
2126 +             atomic_increment (mem);                                         \
2127 +           else if (__builtin_constant_p (value) && (value) == -1)           \
2128 +             atomic_decrement (mem);                                         \
2129 +           else if (sizeof (*mem) == 1)                                      \
2130 +             __asm __volatile (LOCK_PREFIX "addb %b1, %0"                    \
2131 +                               : "=m" (*mem)                                 \
2132 +                               : "ir" (value), "m" (*mem));                  \
2133 +           else if (sizeof (*mem) == 2)                                      \
2134 +             __asm __volatile (LOCK_PREFIX "addw %w1, %0"                    \
2135 +                               : "=m" (*mem)                                 \
2136 +                               : "ir" (value), "m" (*mem));                  \
2137 +           else if (sizeof (*mem) == 4)                                      \
2138 +             __asm __volatile (LOCK_PREFIX "addl %1, %0"                     \
2139 +                               : "=m" (*mem)                                 \
2140 +                               : "ir" (value), "m" (*mem));                  \
2141 +           else                                                              \
2142 +             {                                                               \
2143 +               __typeof (value) __addval = (value);                          \
2144 +               __typeof (mem) __memp = (mem);                                \
2145 +               __typeof (*mem) __oldval = *__memp;                           \
2146 +               __typeof (*mem) __tmpval;                                     \
2147 +               do                                                            \
2148 +                 __tmpval = __oldval;                                        \
2149 +               while ((__oldval = __arch_compare_and_exchange_val_64_acq     \
2150 +                      (__memp, __oldval + __addval, __oldval)) == __tmpval); \
2151 +             }                                                               \
2152 +           })
2153 +
2154 +
2155 +#define atomic_add_negative(mem, value) \
2156 +  ({ unsigned char __result;                                                 \
2157 +     if (sizeof (*mem) == 1)                                                 \
2158 +       __asm __volatile (LOCK_PREFIX "addb %b2, %0; sets %1"                 \
2159 +                        : "=m" (*mem), "=qm" (__result)                      \
2160 +                        : "iq" (value), "m" (*mem));                         \
2161 +     else if (sizeof (*mem) == 2)                                            \
2162 +       __asm __volatile (LOCK_PREFIX "addw %w2, %0; sets %1"                 \
2163 +                        : "=m" (*mem), "=qm" (__result)                      \
2164 +                        : "ir" (value), "m" (*mem));                         \
2165 +     else if (sizeof (*mem) == 4)                                            \
2166 +       __asm __volatile (LOCK_PREFIX "addl %2, %0; sets %1"                  \
2167 +                        : "=m" (*mem), "=qm" (__result)                      \
2168 +                        : "ir" (value), "m" (*mem));                         \
2169 +     else                                                                    \
2170 +       abort ();                                                             \
2171 +     __result; })
2172 +
2173 +
2174 +#define atomic_add_zero(mem, value) \
2175 +  ({ unsigned char __result;                                                 \
2176 +     if (sizeof (*mem) == 1)                                                 \
2177 +       __asm __volatile (LOCK_PREFIX "addb %b2, %0; setz %1"                 \
2178 +                        : "=m" (*mem), "=qm" (__result)                      \
2179 +                        : "ir" (value), "m" (*mem));                         \
2180 +     else if (sizeof (*mem) == 2)                                            \
2181 +       __asm __volatile (LOCK_PREFIX "addw %w2, %0; setz %1"                 \
2182 +                        : "=m" (*mem), "=qm" (__result)                      \
2183 +                        : "ir" (value), "m" (*mem));                         \
2184 +     else if (sizeof (*mem) == 4)                                            \
2185 +       __asm __volatile (LOCK_PREFIX "addl %2, %0; setz %1"                  \
2186 +                        : "=m" (*mem), "=qm" (__result)                      \
2187 +                        : "ir" (value), "m" (*mem));                         \
2188 +     else                                                                    \
2189 +       abort ();                                                             \
2190 +     __result; })
2191 +
2192 +
2193 +#define atomic_increment(mem) \
2194 +  (void) ({ if (sizeof (*mem) == 1)                                          \
2195 +             __asm __volatile (LOCK_PREFIX "incb %b0"                        \
2196 +                               : "=m" (*mem)                                 \
2197 +                               : "m" (*mem));                                \
2198 +           else if (sizeof (*mem) == 2)                                      \
2199 +             __asm __volatile (LOCK_PREFIX "incw %w0"                        \
2200 +                               : "=m" (*mem)                                 \
2201 +                               : "m" (*mem));                                \
2202 +           else if (sizeof (*mem) == 4)                                      \
2203 +             __asm __volatile (LOCK_PREFIX "incl %0"                         \
2204 +                               : "=m" (*mem)                                 \
2205 +                               : "m" (*mem));                                \
2206 +           else                                                              \
2207 +             {                                                               \
2208 +               __typeof (mem) __memp = (mem);                                \
2209 +               __typeof (*mem) __oldval = *__memp;                           \
2210 +               __typeof (*mem) __tmpval;                                     \
2211 +               do                                                            \
2212 +                 __tmpval = __oldval;                                        \
2213 +               while ((__oldval = __arch_compare_and_exchange_val_64_acq     \
2214 +                      (__memp, __oldval + 1, __oldval)) == __tmpval);        \
2215 +             }                                                               \
2216 +           })
2217 +
2218 +
2219 +#define atomic_increment_and_test(mem) \
2220 +  ({ unsigned char __result;                                                 \
2221 +     if (sizeof (*mem) == 1)                                                 \
2222 +       __asm __volatile (LOCK_PREFIX "incb %0; sete %b1"                     \
2223 +                        : "=m" (*mem), "=qm" (__result)                      \
2224 +                        : "m" (*mem));                                       \
2225 +     else if (sizeof (*mem) == 2)                                            \
2226 +       __asm __volatile (LOCK_PREFIX "incw %0; sete %w1"                     \
2227 +                        : "=m" (*mem), "=qm" (__result)                      \
2228 +                        : "m" (*mem));                                       \
2229 +     else if (sizeof (*mem) == 4)                                            \
2230 +       __asm __volatile (LOCK_PREFIX "incl %0; sete %1"                              \
2231 +                        : "=m" (*mem), "=qm" (__result)                      \
2232 +                        : "m" (*mem));                                       \
2233 +     else                                                                    \
2234 +       abort ();                                                             \
2235 +     __result; })
2236 +
2237 +
2238 +#define atomic_decrement(mem) \
2239 +  (void) ({ if (sizeof (*mem) == 1)                                          \
2240 +             __asm __volatile (LOCK_PREFIX "decb %b0"                        \
2241 +                               : "=m" (*mem)                                 \
2242 +                               : "m" (*mem));                                \
2243 +           else if (sizeof (*mem) == 2)                                      \
2244 +             __asm __volatile (LOCK_PREFIX "decw %w0"                        \
2245 +                               : "=m" (*mem)                                 \
2246 +                               : "m" (*mem));                                \
2247 +           else if (sizeof (*mem) == 4)                                      \
2248 +             __asm __volatile (LOCK_PREFIX "decl %0"                         \
2249 +                               : "=m" (*mem)                                 \
2250 +                               : "m" (*mem));                                \
2251 +           else                                                              \
2252 +             {                                                               \
2253 +               __typeof (mem) __memp = (mem);                                \
2254 +               __typeof (*mem) __oldval = *__memp;                           \
2255 +               __typeof (*mem) __tmpval;                                     \
2256 +               do                                                            \
2257 +                 __tmpval = __oldval;                                        \
2258 +               while ((__oldval = __arch_compare_and_exchange_val_64_acq     \
2259 +                      (__memp, __oldval - 1, __oldval)) == __tmpval);        \
2260 +             }                                                               \
2261 +           })
2262 +
2263 +
2264 +#define atomic_decrement_and_test(mem) \
2265 +  ({ unsigned char __result;                                                 \
2266 +     if (sizeof (*mem) == 1)                                                 \
2267 +       __asm __volatile (LOCK_PREFIX "decb %b0; sete %1"                     \
2268 +                        : "=m" (*mem), "=qm" (__result)                      \
2269 +                        : "m" (*mem));                                       \
2270 +     else if (sizeof (*mem) == 2)                                            \
2271 +       __asm __volatile (LOCK_PREFIX "decw %w0; sete %1"                     \
2272 +                        : "=m" (*mem), "=qm" (__result)                      \
2273 +                        : "m" (*mem));                                       \
2274 +     else if (sizeof (*mem) == 4)                                            \
2275 +       __asm __volatile (LOCK_PREFIX "decl %0; sete %1"                              \
2276 +                        : "=m" (*mem), "=qm" (__result)                      \
2277 +                        : "m" (*mem));                                       \
2278 +     else                                                                    \
2279 +       abort ();                                                             \
2280 +     __result; })
2281 +
2282 +
2283 +#define atomic_bit_set(mem, bit) \
2284 +  (void) ({ if (sizeof (*mem) == 1)                                          \
2285 +             __asm __volatile (LOCK_PREFIX "orb %b2, %0"                     \
2286 +                               : "=m" (*mem)                                 \
2287 +                               : "m" (*mem), "ir" (1 << (bit)));             \
2288 +           else if (sizeof (*mem) == 2)                                      \
2289 +             __asm __volatile (LOCK_PREFIX "orw %w2, %0"                     \
2290 +                               : "=m" (*mem)                                 \
2291 +                               : "m" (*mem), "ir" (1 << (bit)));             \
2292 +           else if (sizeof (*mem) == 4)                                      \
2293 +             __asm __volatile (LOCK_PREFIX "orl %2, %0"                      \
2294 +                               : "=m" (*mem)                                 \
2295 +                               : "m" (*mem), "ir" (1 << (bit)));             \
2296 +           else                                                              \
2297 +             abort ();                                                       \
2298 +           })
2299 +
2300 +
2301 +#define atomic_bit_test_set(mem, bit) \
2302 +  ({ unsigned char __result;                                                 \
2303 +     if (sizeof (*mem) == 1)                                                 \
2304 +       __asm __volatile (LOCK_PREFIX "btsb %3, %1; setc %0"                  \
2305 +                        : "=q" (__result), "=m" (*mem)                       \
2306 +                        : "m" (*mem), "ir" (bit));                           \
2307 +     else if (sizeof (*mem) == 2)                                            \
2308 +       __asm __volatile (LOCK_PREFIX "btsw %3, %1; setc %0"                  \
2309 +                        : "=q" (__result), "=m" (*mem)                       \
2310 +                        : "m" (*mem), "ir" (bit));                           \
2311 +     else if (sizeof (*mem) == 4)                                            \
2312 +       __asm __volatile (LOCK_PREFIX "btsl %3, %1; setc %0"                  \
2313 +                        : "=q" (__result), "=m" (*mem)                       \
2314 +                        : "m" (*mem), "ir" (bit));                           \
2315 +     else                                                                    \
2316 +       abort ();                                                             \
2317 +     __result; })
2318 +
2319 +
2320 +#define atomic_delay() asm ("rep; nop")
2321 diff -urN uClibc-0.9.27/libc/sysdeps/linux/m68k/Makefile uClibc-0.9.27-uc0/libc/sysdeps/linux/m68k/Makefile
2322 --- uClibc-0.9.27/libc/sysdeps/linux/m68k/Makefile      2005-01-12 08:59:21.000000000 +0100
2323 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/m68k/Makefile  2005-01-26 07:37:25.000000000 +0100
2324 @@ -33,7 +33,7 @@
2325  SSRC= __longjmp.S bsd-_setjmp.S bsd-setjmp.S clone.S setjmp.S vfork.S
2326  SOBJS=$(patsubst %.S,%.o, $(SSRC))
2327  
2328 -CSRC=ptrace.c brk.c
2329 +CSRC=ptrace.c brk.c syscall.c
2330  COBJS=$(patsubst %.c,%.o, $(CSRC))
2331  
2332  OBJS=$(SOBJS) $(MOBJ) $(COBJS)
2333 diff -urN uClibc-0.9.27/libc/sysdeps/linux/m68k/sys/ucontext.h uClibc-0.9.27-uc0/libc/sysdeps/linux/m68k/sys/ucontext.h
2334 --- uClibc-0.9.27/libc/sysdeps/linux/m68k/sys/ucontext.h        2005-01-12 08:59:21.000000000 +0100
2335 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/m68k/sys/ucontext.h    2006-07-28 08:09:17.000000000 +0200
2336 @@ -79,10 +79,10 @@
2337  /* Structure to describe FPU registers.  */
2338  typedef struct fpregset
2339  {
2340 -  int f_fpregs[8][3];
2341    int f_pcr;
2342    int f_psr;
2343    int f_fpiaddr;
2344 +  int f_fpregs[8][3];
2345  } fpregset_t;
2346  
2347  /* Context to describe whole processor state.  */
2348 @@ -96,14 +96,13 @@
2349  #define MCONTEXT_VERSION 2
2350  
2351  /* Userlevel context.  */
2352 -typedef struct ucontext
2353 -{
2354 -  unsigned long int uc_flags;
2355 +typedef struct ucontext {
2356 +  unsigned long uc_flags;
2357    struct ucontext *uc_link;
2358 -  __sigset_t uc_sigmask;
2359    stack_t uc_stack;
2360    mcontext_t uc_mcontext;
2361 -  long int uc_filler[174];
2362 +  unsigned long uc_filler[80];
2363 +  __sigset_t uc_sigmask;   /* mask last for extensibility */
2364  } ucontext_t;
2365  
2366  #endif /* sys/ucontext.h */
2367 diff -urN uClibc-0.9.27/libc/sysdeps/linux/m68k/syscall.c uClibc-0.9.27-uc0/libc/sysdeps/linux/m68k/syscall.c
2368 --- uClibc-0.9.27/libc/sysdeps/linux/m68k/syscall.c     1970-01-01 01:00:00.000000000 +0100
2369 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/m68k/syscall.c 2004-10-06 10:04:19.000000000 +0200
2370 @@ -0,0 +1,57 @@
2371 +/* syscall for m68k/uClibc
2372 + *
2373 + * Copyright (C) 2004 by Christian Magnusson <mag@mag.cx>
2374 + *
2375 + * This program is free software; you can redistribute it and/or modify it
2376 + * under the terms of the GNU Library General Public License as published by
2377 + * the Free Software Foundation; either version 2 of the License, or (at your
2378 + * option) any later version.
2379 + *
2380 + * This program is distributed in the hope that it will be useful, but WITHOUT
2381 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2382 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
2383 + * for more details.
2384 + *
2385 + * You should have received a copy of the GNU Library General Public License
2386 + * along with this program; if not, write to the Free Software Foundation,
2387 + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2388 + */
2389 +                                                                               
2390 +#include <features.h>
2391 +#include <errno.h>
2392 +#include <sys/types.h>
2393 +#include <sys/syscall.h>
2394 +
2395 +long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
2396 +{
2397 +  long __res;
2398 +  __asm__ __volatile__ ("movel  %7, %%d6\n\t"\
2399 +                        "movel  %6, %%d5\n\t"\
2400 +                        "movel  %5, %%d4\n\t"\
2401 +                        "movel  %4, %%d3\n\t"\
2402 +                        "movel  %3, %%d2\n\t"\
2403 +                        "movel  %2, %%d1\n\t"\
2404 +                        "movel  %1, %%d0\n\t"\
2405 +                        "trap   #0\n\t"\
2406 +                        "movel  %%d0, %0"\
2407 +                        : "=g" (__res)\
2408 +                        : "g" (sysnum),\
2409 +                       "a" ((long)a),\
2410 +                       "a" ((long)b),\
2411 +                       "a" ((long)c),\
2412 +                       "a" ((long)d),\
2413 +                       "a" ((long)e),\
2414 +                       "g" ((long)f)\
2415 +                        : "cc", "%d0", "%d1", "%d2", "%d3",\
2416 +                       "%d4", "%d5", "%d6");
2417 +
2418 +#if 1
2419 +  __syscall_return(long,__res);
2420 +#else                      
2421 +  if ((unsigned long)(__res) >= (unsigned long)(-125)) {
2422 +    errno = -__res;
2423 +    __res = -1;
2424 +  }
2425 +  return (long)__res;
2426 +#endif
2427 +}
2428 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/bits/setjmp.h uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/bits/setjmp.h
2429 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/bits/setjmp.h   2005-01-12 08:59:21.000000000 +0100
2430 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/bits/setjmp.h       2003-12-01 06:55:42.000000000 +0100
2431 @@ -25,12 +25,16 @@
2432      /* Link pointer.  */
2433      void *__lp;
2434  
2435 -    /* Callee-saved registers r18-r30.  */
2436 -    int __regs[13];
2437 +    /* SDA pointers */
2438 +    void *__SDA;
2439 +    void *__SDA2;
2440 +
2441 +    /* Callee-saved registers r18-r31.  */
2442 +    int __regs[14];
2443    } __jmp_buf[1];
2444  #endif
2445  
2446 -#define JB_SIZE                (4 * 15)
2447 +#define JB_SIZE                (4 * 18)
2448  
2449  /* Test if longjmp to JMPBUF would unwind the frame
2450     containing a local variable at ADDRESS.  */
2451 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/clone.c uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/clone.c
2452 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/clone.c 2005-01-12 08:59:21.000000000 +0100
2453 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/clone.c     2005-08-05 03:10:51.000000000 +0200
2454 @@ -19,32 +19,36 @@
2455  int
2456  clone (int (*fn)(void *arg), void *child_stack, int flags, void *arg)
2457  {
2458 -  register unsigned long rval asm (SYSCALL_RET) = -EINVAL;
2459 +  register unsigned long rval = -EINVAL;
2460  
2461    if (fn && child_stack)
2462      {
2463 -      register unsigned long syscall asm (SYSCALL_NUM);
2464 -      register unsigned long arg0 asm (SYSCALL_ARG0);
2465 -      register unsigned long arg1 asm (SYSCALL_ARG1);
2466 +      register unsigned long arg0;
2467 +      register unsigned long arg1;
2468  
2469        /* Clone this thread.  */
2470        arg0 = flags;
2471        arg1 = (unsigned long)child_stack;
2472 -      syscall = __NR_clone;
2473 -      asm volatile ("bralid r17, trap;nop;" 
2474 -                   : "=r" (rval), "=r" (syscall)
2475 -                   : "1" (syscall), "r" (arg0), "r" (arg1)
2476 -                   : SYSCALL_CLOBBERS);
2477 +      asm volatile (   "addik  r12, r0, %1     \n\t"
2478 +                       "addk   r5, r0, %2      \n\t"
2479 +                       "addk   r6, r0, %3      \n\t"
2480 +                       "brki   r14, 0x08       \n\t"
2481 +                       "addk   %0, r3, r0      \n\t"
2482 +                   : "=r" (rval)
2483 +                   : "i" (__NR_clone), "r" (arg0), "r" (arg1)
2484 +                   : "r3", "r5", "r6", "r12", "r14", "cc");
2485  
2486        if (rval == 0)
2487         /* In child thread, call FN and exit.  */
2488         {
2489           arg0 = (*fn) (arg);
2490 -         syscall = __NR_exit;
2491 -         asm volatile ("bralid r17, trap;nop;" 
2492 -                       : "=r" (rval), "=r" (syscall)
2493 -                       : "1" (syscall), "r" (arg0)
2494 -                       : SYSCALL_CLOBBERS);
2495 +         asm volatile ("addik  r12, r0, %1     \n\t"
2496 +                       "addk   r5, r0, %2      \n\t"
2497 +                       "brki   r14, 0x08       \n\t"
2498 +                       "addk   %0, r0, r3      \n\t"
2499 +                       : "=r" (rval)
2500 +                       : "i" (__NR_exit), "r" (arg0)
2501 +                       : "r3", "r5", "r12", "r14", "cc");
2502         }
2503      }
2504  
2505 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/fixdfsi.c uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/fixdfsi.c
2506 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/fixdfsi.c       1970-01-01 01:00:00.000000000 +0100
2507 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/fixdfsi.c   2004-03-02 06:47:36.000000000 +0100
2508 @@ -0,0 +1,85 @@
2509 +/*
2510 +** libgcc support for software floating point.
2511 +** Copyright (C) 1991 by Pipeline Associates, Inc.  All rights reserved.
2512 +** Permission is granted to do *anything* you want with this file,
2513 +** commercial or otherwise, provided this message remains intact.  So there!
2514 +** I would appreciate receiving any updates/patches/changes that anyone
2515 +** makes, and am willing to be the repository for said changes (am I
2516 +** making a big mistake?).
2517 +
2518 +Warning! Only single-precision is actually implemented.  This file
2519 +won't really be much use until double-precision is supported.
2520 +
2521 +However, once that is done, this file might eventually become a
2522 +replacement for libgcc1.c.  It might also make possible
2523 +cross-compilation for an IEEE target machine from a non-IEEE
2524 +host such as a VAX.
2525 +
2526 +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu.
2527 +
2528 +--> Double precision floating support added by James Carlson on 20 April 1998.
2529 +
2530 +**
2531 +** Pat Wood
2532 +** Pipeline Associates, Inc.
2533 +** pipeline!phw@motown.com or
2534 +** sun!pipeline!phw or
2535 +** uunet!motown!pipeline!phw
2536 +**
2537 +** 05/01/91 -- V1.0 -- first release to gcc mailing lists
2538 +** 05/04/91 -- V1.1 -- added float and double prototypes and return values
2539 +**                  -- fixed problems with adding and subtracting zero
2540 +**                  -- fixed rounding in truncdfsf2
2541 +**                  -- fixed SWAP define and tested on 386
2542 +*/
2543 +
2544 +/*
2545 +** The following are routines that replace the libgcc soft floating point
2546 +** routines that are called automatically when -msoft-float is selected.
2547 +** The support single and double precision IEEE format, with provisions
2548 +** for byte-swapped machines (tested on 386).  Some of the double-precision
2549 +** routines work at full precision, but most of the hard ones simply punt
2550 +** and call the single precision routines, producing a loss of accuracy.
2551 +** long long support is not assumed or included.
2552 +** Overall accuracy is close to IEEE (actually 68882) for single-precision
2553 +** arithmetic.  I think there may still be a 1 in 1000 chance of a bit
2554 +** being rounded the wrong way during a multiply.  I'm not fussy enough to
2555 +** bother with it, but if anyone is, knock yourself out.
2556 +**
2557 +** Efficiency has only been addressed where it was obvious that something
2558 +** would make a big difference.  Anyone who wants to do this right for
2559 +** best speed should go in and rewrite in assembler.
2560 +**
2561 +** I have tested this only on a 68030 workstation and 386/ix integrated
2562 +** in with -msoft-float.
2563 +*/
2564 +
2565 +#include "floatlib.h"
2566 +
2567 +/* convert double to int */
2568 +long
2569 +__fixdfsi (double a1)
2570 +{
2571 +  register union double_long dl1;
2572 +  register int exp;
2573 +  register long l;
2574 +
2575 +  dl1.d = a1;
2576 +
2577 +  if (!dl1.l.upper && !dl1.l.lower)
2578 +    return (0);
2579 +
2580 +  exp = EXPD (dl1) - EXCESSD - 31;
2581 +  l = MANTD (dl1);
2582 +
2583 +  if (exp > 0)
2584 +      return SIGND(dl1) ? (1<<31) : ((1ul<<31)-1);
2585 +
2586 +  /* shift down until exp = 0 or l = 0 */
2587 +  if (exp < 0 && exp > -32 && l)
2588 +    l >>= -exp;
2589 +  else
2590 +    return (0);
2591 +
2592 +  return (SIGND (dl1) ? -l : l);
2593 +}
2594 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/floatlib.h uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/floatlib.h
2595 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/floatlib.h      1970-01-01 01:00:00.000000000 +0100
2596 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/floatlib.h  2004-03-02 06:47:36.000000000 +0100
2597 @@ -0,0 +1,144 @@
2598 +/*
2599 +** libgcc support for software floating point.
2600 +** Copyright (C) 1991 by Pipeline Associates, Inc.  All rights reserved.
2601 +** Permission is granted to do *anything* you want with this file,
2602 +** commercial or otherwise, provided this message remains intact.  So there!
2603 +** I would appreciate receiving any updates/patches/changes that anyone
2604 +** makes, and am willing to be the repository for said changes (am I
2605 +** making a big mistake?).
2606 +
2607 +Warning! Only single-precision is actually implemented.  This file
2608 +won't really be much use until double-precision is supported.
2609 +
2610 +However, once that is done, this file might eventually become a
2611 +replacement for libgcc1.c.  It might also make possible
2612 +cross-compilation for an IEEE target machine from a non-IEEE
2613 +host such as a VAX.
2614 +
2615 +If you'd like to work on completing this, please talk to rms@gnu.ai.mit.edu.
2616 +
2617 +--> Double precision floating support added by James Carlson on 20 April 1998.
2618 +
2619 +**
2620 +** Pat Wood
2621 +** Pipeline Associates, Inc.
2622 +** pipeline!phw@motown.com or
2623 +** sun!pipeline!phw or
2624 +** uunet!motown!pipeline!phw
2625 +**
2626 +** 05/01/91 -- V1.0 -- first release to gcc mailing lists
2627 +** 05/04/91 -- V1.1 -- added float and double prototypes and return values
2628 +**                  -- fixed problems with adding and subtracting zero
2629 +**                  -- fixed rounding in truncdfsf2
2630 +**                  -- fixed SWAP define and tested on 386
2631 +*/
2632 +
2633 +/*
2634 +** The following are routines that replace the libgcc soft floating point
2635 +** routines that are called automatically when -msoft-float is selected.
2636 +** The support single and double precision IEEE format, with provisions
2637 +** for byte-swapped machines (tested on 386).  Some of the double-precision
2638 +** routines work at full precision, but most of the hard ones simply punt
2639 +** and call the single precision routines, producing a loss of accuracy.
2640 +** long long support is not assumed or included.
2641 +** Overall accuracy is close to IEEE (actually 68882) for single-precision
2642 +** arithmetic.  I think there may still be a 1 in 1000 chance of a bit
2643 +** being rounded the wrong way during a multiply.  I'm not fussy enough to
2644 +** bother with it, but if anyone is, knock yourself out.
2645 +**
2646 +** Efficiency has only been addressed where it was obvious that something
2647 +** would make a big difference.  Anyone who wants to do this right for
2648 +** best speed should go in and rewrite in assembler.
2649 +**
2650 +** I have tested this only on a 68030 workstation and 386/ix integrated
2651 +** in with -msoft-float.
2652 +*/
2653 +
2654 +#ifndef __FLOAT_LIB_H__
2655 +#define __FLOAT_LIB_H__
2656 +/* the following deal with IEEE single-precision numbers */
2657 +#define EXCESS         126
2658 +#define SIGNBIT                0x80000000
2659 +#define HIDDEN         (1 << 23)
2660 +#define SIGN(fp)       ((fp) & SIGNBIT)
2661 +#define EXP(fp)                (((fp) >> 23) & 0xFF)
2662 +#define MANT(fp)       (((fp) & 0x7FFFFF) | HIDDEN)
2663 +#define PACK(s,e,m)    ((s) | ((e) << 23) | (m))
2664 +
2665 +/* the following deal with IEEE double-precision numbers */
2666 +#define EXCESSD                1022
2667 +#define HIDDEND                (1 << 20)
2668 +#define EXPD(fp)       (((fp.l.upper) >> 20) & 0x7FF)
2669 +#define SIGND(fp)      ((fp.l.upper) & SIGNBIT)
2670 +#define MANTD(fp)      (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \
2671 +                               (fp.l.lower >> 22))
2672 +#define HIDDEND_LL     ((long long)1 << 52)
2673 +#define MANTD_LL(fp)   ((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
2674 +#define PACKD_LL(s,e,m)        (((long long)((s)+((e)<<20))<<32)|(m))
2675 +
2676 +/* define SWAP for 386/960 reverse-byte-order brain-damaged CPUs */
2677 +union double_long {
2678 +    double d;
2679 +#ifdef SWAP
2680 +    struct {
2681 +      unsigned long lower;
2682 +      long upper;
2683 +    } l;
2684 +#else
2685 +    struct {
2686 +      long upper;
2687 +      unsigned long lower;
2688 +    } l;
2689 +#endif
2690 +    long long ll;
2691 +};
2692 +
2693 +union float_long
2694 +  {
2695 +    float f;
2696 +    long l;
2697 +  };
2698 +
2699 +#endif
2700 +
2701 +/* Functions defined in different files */
2702 +
2703 +float __addsf3 (float, float);
2704 +float __subsf3 (float, float);
2705 +long __cmpsf2 (float, float);
2706 +float __mulsf3 (float, float);
2707 +float __divsf3 (float, float);
2708 +double __floatsidf (register long);
2709 +double __floatdidf (register long long);
2710 +float __floatsisf (register long );
2711 +float __floatdisf (register long long );
2712 +float __negsf2 (float);
2713 +double __negdf2 (double);
2714 +double __extendsfdf2 (float);
2715 +float __truncdfsf2 (double);
2716 +long __cmpdf2 (double, double);
2717 +long __fixsfsi (float);
2718 +long __fixdfsi (double);
2719 +long long __fixdfdi (double);
2720 +unsigned long __fixunsdfsi (double);
2721 +unsigned long long __fixunsdfdi (double);
2722 +double __adddf3 (double, double);
2723 +double __subdf3 (double, double);
2724 +double __muldf3 (double, double);
2725 +double __divdf3 (double, double);
2726 +int __gtdf2 (double, double);
2727 +int __gedf2 (double, double);
2728 +int __ltdf2 (double, double);
2729 +int __ledf2 (double, double);
2730 +int __eqdf2 (double, double);
2731 +int __nedf2 (double, double);
2732 +int __gtsf2 (float, float);
2733 +int __gesf2 (float, float);
2734 +int __ltsf2 (float, float);
2735 +int __lesf2 (float, float);
2736 +int __eqsf2 (float, float);
2737 +int __nesf2 (float, float);
2738 +
2739 +
2740 +
2741 +
2742 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/initfini.awk uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/initfini.awk
2743 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/initfini.awk    1970-01-01 01:00:00.000000000 +0100
2744 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/initfini.awk        2005-08-10 13:46:42.000000000 +0200
2745 @@ -0,0 +1,121 @@
2746 +#! /usr/bin/awk -f
2747 +# Contributed by Christian MICHON <christian_michon@yahoo.fr> to
2748 +#   eliminate the compile time dependancy on perl introduced by 
2749 +#   Erik's older initfini.pl 
2750 +# vim:ai:sw=2:
2751 +
2752 +BEGIN \
2753 +{ alignval="";
2754 +  endp=0;
2755 +  end=0;
2756 +  system("touch crt[in].S");
2757 +  system("/bin/rm -f crt[in].S");
2758 +  omitcrti=0;
2759 +  omitcrtn=0;
2760 +  glb_idx = 0;
2761 +  while(getline < "initfini.S")
2762 +  { if(/\.endp/) {endp=1}
2763 +    if(/\.end/) {end=1}
2764 +    if(/\.align/) {alignval=$2}
2765 +# here comes some special stuff for the SuperH targets
2766 +#  We search for all labels, which uses the _GLOBAL_OFFSET_TABLE_
2767 +#  or a call_gmon_start function reference, and store
2768 +#  them in the glb_label array.
2769 +    if(/_init_EPILOG_BEGINS/) {glb_idx=1;glb_idx_arr[glb_idx]=0}
2770 +    if(/_fini_EPILOG_BEGINS/) {glb_idx=2;glb_idx_arr[glb_idx]=0}
2771 +    if(/EPILOG_ENDS/)         {glb_idx=0}
2772 +    if(/_GLOBAL_OFFSET_TABLE_/||/call_gmon_start/) {
2773 +      glb_label[glb_idx,glb_idx_arr[glb_idx]] = last;
2774 +      glb_idx_arr[glb_idx] += 1;
2775 +      glb_label[glb_idx,glb_idx_arr[glb_idx]] = $0;
2776 +      glb_idx_arr[glb_idx] += 1;
2777 +    }
2778 +    last = $1;
2779 +  }
2780 +  close("initfini.S");
2781 +}
2782 +# special rules for the SuperH targets (They do nothing on other targets)
2783 +/SH_GLB_BEGINS/ && glb_idx_arr[1]==0 && glb_idx_arr[2]==0 {omitcrti +=1}
2784 +/_init_SH_GLB/  {glb_idx=1}
2785 +/_fini_SH_GLB/  {glb_idx=2}
2786 +/SH_GLB_ENDS/ {omitcrti -=1}
2787 +/SH_GLB/ \
2788 +{
2789 +  if (glb_idx>0)
2790 +    {
2791 +      for (i=0;i<glb_idx_arr[glb_idx];i+=1) {
2792 +       print glb_label[glb_idx,i] >> "crti.S";
2793 +      }
2794 +      glb_idx = 0;
2795 +    }
2796 +  next;
2797 +}
2798 +# special rules for H8/300 (sorry quick hack)
2799 +/.h8300h/ {end=0}
2800 +
2801 +# rules for all targets
2802 +/HEADER_ENDS/{omitcrti=1;omitcrtn=1;getline}
2803 +/PROLOG_BEGINS/{omitcrti=0;omitcrtn=0;getline}
2804 +/i_am_not_a_leaf/{getline}
2805 +/_init:/||/_fini:/{omitcrtn=1}
2806 +/PROLOG_PAUSES/{omitcrti=1;getline}
2807 +/PROLOG_UNPAUSES/{omitcrti=0;getline}
2808 +/PROLOG_ENDS/{omitcrti=1;getline}
2809 +/EPILOG_BEGINS/{omitcrtn=0;getline}
2810 +/EPILOG_ENDS/{omitcrtn=1;getline}
2811 +/TRAILER_BEGINS/{omitcrti=0;omitcrtn=0;getline}
2812 +/GMON_STUFF_BEGINS/{omitcrtn=1;getline}
2813 +/GMON_STUFF_PAUSES/{omitcrtn=0;getline}
2814 +/GMON_STUFF_UNPAUSES/{omitcrtn=1;getline}
2815 +/GMON_STUFF_ENDS/{omitcrtn=0;getline}
2816 +
2817 +/_GLOBAL_OFFSET_TABLE_/||/gmon_start/ \
2818 +{
2819 +  if(omitcrti==0) {print >> "crti.S";}
2820 +  next;  # no gmon_start or GLOBAL_OFFSET_TABLE references in crtn.S
2821 +}
2822 +
2823 +/END_INIT/ \
2824 +{ if(endp)
2825 +  { gsub("END_INIT",".endp _init",$0)
2826 +  }
2827 +  else
2828 +  { if(end)
2829 +    { gsub("END_INIT",".end _init",$0)
2830 +    }
2831 +    else
2832 +    { gsub("END_INIT","",$0)
2833 +    }
2834 +  }
2835 +}
2836 +
2837 +/END_FINI/ \
2838 +{ if(endp)
2839 +  { gsub("END_FINI",".endp _fini",$0)
2840 +  }
2841 +  else
2842 +  { if(end)
2843 +    { gsub("END_FINI",".end _fini",$0)
2844 +    }
2845 +    else
2846 +    { gsub("END_FINI","",$0)
2847 +    }
2848 +  }
2849 +}
2850 +
2851 +/ALIGN/ \
2852 +{ if(alignval!="")
2853 +  { gsub("ALIGN",sprintf(".align %s",alignval),$0)
2854 +  }
2855 +  else
2856 +  { gsub("ALIGN","",$0)
2857 +  }
2858 +}
2859 +
2860 +omitcrti==0 {print >> "crti.S"}
2861 +omitcrtn==0 {print >> "crtn.S"}
2862 +
2863 +END \
2864 +{ close("crti.S");
2865 +  close("crtn.S");
2866 +}
2867 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/initfini.c uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/initfini.c
2868 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/initfini.c      1970-01-01 01:00:00.000000000 +0100
2869 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/initfini.c  2005-08-10 13:46:42.000000000 +0200
2870 @@ -0,0 +1,172 @@
2871 +/* Special .init and .fini section support.
2872 +   Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
2873 +   This file is part of the GNU C Library.
2874 +
2875 +   The GNU C Library is free software; you can redistribute it and/or
2876 +   modify it under the terms of the GNU Lesser General Public
2877 +   License as published by the Free Software Foundation; either
2878 +   version 2.1 of the License, or (at your option) any later version.
2879 +
2880 +   In addition to the permissions in the GNU Lesser General Public
2881 +   License, the Free Software Foundation gives you unlimited
2882 +   permission to link the compiled version of this file with other
2883 +   programs, and to distribute those programs without any restriction
2884 +   coming from the use of this file.  (The GNU Lesser General Public
2885 +   License restrictions do apply in other respects; for example, they
2886 +   cover modification of the file, and distribution when not linked
2887 +   into another program.)
2888 +
2889 +   The GNU C Library is distributed in the hope that it will be useful,
2890 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
2891 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2892 +   Lesser General Public License for more details.
2893 +
2894 +   You should have received a copy of the GNU Lesser General Public
2895 +   License along with the GNU C Library; if not, write to the Free
2896 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2897 +   02111-1307 USA.  */
2898 +
2899 +/* This file is compiled into assembly code which is then munged by a sed
2900 +   script into two files: crti.s and crtn.s.
2901 +
2902 +   * crti.s puts a function prologue at the beginning of the
2903 +   .init and .fini sections and defines global symbols for
2904 +   those addresses, so they can be called as functions.
2905 +
2906 +   * crtn.s puts the corresponding function epilogues
2907 +   in the .init and .fini sections. */
2908 +
2909 +#include <features.h>
2910 +
2911 +
2912 +/* We use embedded asm for .section unconditionally, as this makes it
2913 +   easier to insert the necessary directives into crtn.S. */
2914 +#define SECTION(x) asm (".section " x );
2915 +
2916 +/* Declare symbols as hidden. Hidden symbols are only seen by
2917 + * the link editor and not by the dynamic loader. */
2918 +#ifdef __HAVE_DOT_HIDDEN__
2919 +#  define HIDDEN(func)  asm (".hidden  " #func );
2920 +#else
2921 +#  define HIDDEN(func)
2922 +#endif
2923 +
2924 +#if defined(__sh__) && !defined(__SH5__)
2925 +  /* The macro insert this sh specific stuff:
2926 +     @_SH_GLB_BEGINS
2927 +          bra     1f
2928 +         nop
2929 +         ALIGN
2930 +     @func_SH_GLB_LABEL
2931 +     1:
2932 +     @_SH_GLB_ENDS
2933 +   */
2934 +#define GLB_STUFF(func)  asm ("\n/*@_SH_GLB_BEGINS*/"); \
2935 +  asm ("\n\tbra\t1f\n\tnop\n\tALIGN\n/*@" #func"_SH_GLB_LABEL*/\n1:"); \
2936 +  asm ("\n/*@_SH_GLB_ENDS*/");
2937 +#else
2938 +#define GLB_STUFF(func)
2939 +#endif
2940 +
2941 +/* The initial common code ends here. */
2942 +asm ("\n/*@HEADER_ENDS*/");
2943 +
2944 +/* To determine whether we need .end and .align: */
2945 +//asm ("\n/*@TESTS_BEGIN*/");
2946 +extern void dummy (void (*foo) (void));
2947 +void
2948 +dummy (void (*foo) (void))
2949 +{
2950 +  if (foo)
2951 +    (*foo) ();
2952 +}
2953 +//asm ("\n/*@TESTS_END*/");
2954 +
2955 +/* The beginning of _init:  */
2956 +asm ("\n/*@_init_PROLOG_BEGINS*/");
2957 +
2958 +#ifdef GMON_SUPPORT
2959 +asm ("\n/*@_init_GMON_STUFF_BEGINS*/");
2960 +static void
2961 +call_gmon_start(void)
2962 +{
2963 +  extern void __gmon_start__ (void) __attribute__ ((weak)); /*weak_extern (__gmon_start__);*/
2964 +  void (*gmon_start) (void) = __gmon_start__;
2965 +
2966 +  if (gmon_start)
2967 +    gmon_start ();
2968 +}
2969 +asm ("\n/*@_init_GMON_STUFF_PAUSES*/");
2970 +#endif
2971 +
2972 +SECTION (".init")
2973 +HIDDEN(_init)
2974 +
2975 +extern void i_am_not_a_leaf (void);
2976 +extern void _init (void);
2977 +void _init (void)
2978 +{
2979 +#ifdef GMON_SUPPORT
2980 +asm ("\n/*@_init_GMON_STUFF_UNPAUSES*/");
2981 +  /* We cannot use the normal constructor mechanism in gcrt1.o because it
2982 +     appears before crtbegin.o in the link, so the header elt of .ctors
2983 +     would come after the elt for __gmon_start__.  One approach is for
2984 +     gcrt1.o to reference a symbol which would be defined by some library
2985 +     module which has a constructor; but then user code's constructors
2986 +     would come first, and not be profiled.  */
2987 +  call_gmon_start ();
2988 +asm ("\n/*@_init_GMON_STUFF_ENDS*/");
2989 +#else
2990 +  asm ("\n/*@_init_PROLOG_PAUSES*/");
2991 +  {
2992 +    /* Let GCC know that _init is not a leaf function by having a dummy
2993 +     * function call here.  We arrange for this call to be omitted from
2994 +     * either crt file.  */
2995 +    i_am_not_a_leaf ();
2996 +  }
2997 +  asm ("\n/*@_init_PROLOG_UNPAUSES*/");
2998 +#endif
2999 +
3000 +  GLB_STUFF(_init)
3001 +  asm ("ALIGN");
3002 +  asm("END_INIT");
3003 +  /* Now the epilog. */
3004 +  asm ("\n/*@_init_PROLOG_ENDS*/");
3005 +  asm ("\n/*@_init_EPILOG_BEGINS*/");
3006 +}
3007 +
3008 +/* End of the _init epilog, beginning of the _fini prolog. */
3009 +asm ("\n/*@_init_EPILOG_ENDS*/");
3010 +asm ("\n/*@_fini_PROLOG_BEGINS*/");
3011 +
3012 +SECTION (".fini")
3013 +HIDDEN(_fini)
3014 +
3015 +extern void i_am_not_a_leaf2 (void);
3016 +extern void _fini (void);
3017 +void _fini (void)
3018 +{
3019 +
3020 +  /* End of the _fini prolog. */
3021 +  GLB_STUFF(_fini)
3022 +  asm ("ALIGN");
3023 +  asm ("END_FINI");
3024 +  asm ("\n/*@_fini_PROLOG_ENDS*/");
3025 +
3026 +  {
3027 +    /* Let GCC know that _fini is not a leaf function by having a dummy
3028 +       function call here.  We arrange for this call to be omitted from
3029 +       either crt file.  */
3030 +    i_am_not_a_leaf2 ();
3031 +  }
3032 +
3033 +  /* Beginning of the _fini epilog. */
3034 +  asm ("\n/*@_fini_EPILOG_BEGINS*/");
3035 +}
3036 +
3037 +/* End of the _fini epilog.  Any further generated assembly (e.g. .ident)
3038 +   is shared between both crt files. */
3039 +asm ("\n/*@_fini_EPILOG_ENDS*/");
3040 +asm ("\n/*@TRAILER_BEGINS*/");
3041 +
3042 +/* End of file. */
3043 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/__longjmp.S uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/__longjmp.S
3044 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/__longjmp.S     2005-01-12 08:59:21.000000000 +0100
3045 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/__longjmp.S 2003-12-01 06:55:42.000000000 +0100
3046 @@ -23,19 +23,21 @@
3047         /* load registers from memory to r5 (arg0)*/
3048         lwi     r1, r5, 0
3049         lwi     r15, r5, 4
3050 -       lwi     r18, r5, 8
3051 -       lwi     r19, r5, 12
3052 -       lwi     r20, r5, 16
3053 -       lwi     r21, r5, 20 
3054 -       lwi     r22, r5, 24 
3055 -       lwi     r23, r5, 28
3056 -       lwi     r24, r5, 32 
3057 -       lwi     r25, r5, 36
3058 -       lwi     r26, r5, 40
3059 -       lwi     r27, r5, 44
3060 -       lwi     r28, r5, 48
3061 -       lwi     r29, r5, 52
3062 -       lwi     r30, r5, 56
3063 +       lwi     r2,  r5, 8
3064 +       lwi     r13, r5, 12
3065 +       lwi     r18, r5, 16
3066 +       lwi     r19, r5, 20
3067 +       lwi     r20, r5, 24
3068 +       lwi     r21, r5, 28
3069 +       lwi     r22, r5, 32
3070 +       lwi     r23, r5, 36
3071 +       lwi     r24, r5, 40
3072 +       lwi     r25, r5, 44
3073 +       lwi     r26, r5, 48
3074 +       lwi     r27, r5, 52
3075 +       lwi     r28, r5, 56
3076 +       lwi     r29, r5, 60
3077 +       lwi     r30, r5, 64
3078         
3079         addi    r3, r0, 1               // return val
3080         rtsd    r15, 8                  // normal return
3081 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/Makefile uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/Makefile
3082 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/Makefile        2005-01-12 08:59:21.000000000 +0100
3083 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/Makefile    2005-08-10 13:46:42.000000000 +0200
3084 @@ -21,7 +21,7 @@
3085  include $(TOPDIR)Rules.mak
3086  
3087  #FIXME -- this arch should include its own crti.S and crtn.S
3088 -UCLIBC_CTOR_DTOR=n
3089 +UCLIBC_CTOR_DTOR=y
3090  
3091  CFLAGS+=-I..
3092  ASFLAGS+=-I.. -D__ASSEMBLER -DASM_GLOBAL_DIRECTIVE=.globl
3093 @@ -35,7 +35,7 @@
3094  SSRC = setjmp.S __longjmp.S vfork.S
3095  SOBJS = $(patsubst %.S,%.o, $(SSRC))
3096  
3097 -CSRC = mmap.c syscall.c clone.c
3098 +CSRC = mmap.c syscall.c clone.c fixdfsi.c
3099  COBJS = $(patsubst %.c,%.o, $(CSRC))
3100  
3101  OBJS = $(SOBJS) $(COBJS)
3102 @@ -46,6 +46,7 @@
3103  
3104  ar-target: $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS)
3105         $(AR) $(ARFLAGS) $(LIBC) $(OBJS)
3106 +       mkdir -p $(TOPDIR)lib/
3107         cp $(CRT0_OBJ) $(TOPDIR)lib/
3108  
3109  $(CRT0_OBJ): $(CRT0_SRC)
3110 @@ -61,25 +62,18 @@
3111         $(STRIPTOOL) -x -R .note -R .comment $*.o
3112  
3113  ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
3114 -crti.o: crti.S
3115 -       $(CC) $(ASFLAGS) -c crti.S -o crti.o
3116 +initfini.S: initfini.c
3117 +       $(CC) $(SAFECFLAGS) -I$(TOPDIR)include -c initfini.c -S -o initfini.S
3118 +
3119 +crti.S crtn.S: initfini.S initfini.awk
3120 +       awk -f initfini.awk initfini.S
3121  
3122  $(TOPDIR)lib/crti.o: crti.o
3123         $(INSTALL) -d $(TOPDIR)lib/
3124 -       cp crti.o $(TOPDIR)lib/
3125 -
3126 -crtn.o: crtn.S
3127 -       $(CC) $(ASFLAGS) -c crtn.S -o crtn.o
3128 +       $(AR) $(ARFLAGS) $(TOPDIR)lib/crti.o
3129  
3130  $(TOPDIR)lib/crtn.o: crtn.o
3131         $(INSTALL) -d $(TOPDIR)lib/
3132 -       cp crtn.o $(TOPDIR)lib/
3133 -else
3134 -$(TOPDIR)lib/crti.o:
3135 -       $(INSTALL) -d $(TOPDIR)lib/
3136 -       $(AR) $(ARFLAGS) $(TOPDIR)lib/crti.o
3137 -$(TOPDIR)lib/crtn.o:
3138 -       $(INSTALL) -d $(TOPDIR)lib/
3139         $(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o
3140  endif
3141  
3142 @@ -89,4 +83,10 @@
3143  clean:
3144         $(RM) *.[oa] *~ core
3145         $(RM) bits/sysnum.h
3146 +       ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
3147 +               $(RM) initfini.S
3148 +               $(RM) crti.S
3149 +               $(RM) crto.S
3150 +       endif
3151 +
3152  
3153 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/setjmp.S uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/setjmp.S
3154 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/setjmp.S        2005-01-12 08:59:21.000000000 +0100
3155 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/setjmp.S    2003-12-01 06:55:42.000000000 +0100
3156 @@ -33,19 +33,22 @@
3157         /* Save registers relative to r5 (arg0)*/
3158         swi     r1, r5, 0                       /* stack pointer */
3159         swi     r15, r5, 4                      /* link register */
3160 -       swi     r18, r5, 8                      /* assembler temp */
3161 -       swi     r19, r5, 12                     /* now call-preserved regs */
3162 -       swi     r20, r5, 16
3163 -       swi     r21, r5, 20
3164 -       swi     r22, r5, 24
3165 -       swi     r23, r5, 28
3166 -       swi     r24, r5, 32
3167 -       swi     r25, r5, 36
3168 -       swi     r26, r5, 40
3169 -       swi     r27, r5, 44
3170 -       swi     r28, r5, 48
3171 -       swi     r29, r5, 52
3172 -       swi     r30, r5, 56
3173 +       swi     r2,  r5, 8                      /* SDA and SDA2 ptrs */
3174 +       swi     r13, r5, 12
3175 +       swi     r18, r5, 16                     /* assembler temp */
3176 +       swi     r19, r5, 20                     /* now call-preserved regs */
3177 +       swi     r20, r5, 24
3178 +       swi     r21, r5, 28
3179 +       swi     r22, r5, 32
3180 +       swi     r23, r5, 36 
3181 +       swi     r24, r5, 40
3182 +       swi     r25, r5, 44
3183 +       swi     r26, r5, 48
3184 +       swi     r27, r5, 52
3185 +       swi     r28, r5, 56
3186 +       swi     r29, r5, 60
3187 +       swi     r30, r5, 64
3188 +       swi     r31, r5, 68
3189  
3190         /* Make a tail call to __sigjmp_save; it takes the same args.  */
3191         braid   C_SYMBOL_NAME(__sigjmp_save)
3192 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/sys/procfs.h uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/sys/procfs.h
3193 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/sys/procfs.h    1970-01-01 01:00:00.000000000 +0100
3194 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/sys/procfs.h        2003-12-01 06:55:42.000000000 +0100
3195 @@ -0,0 +1,130 @@
3196 +/* Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3197 +   This file is part of the GNU C Library.
3198 +
3199 +   The GNU C Library is free software; you can redistribute it and/or
3200 +   modify it under the terms of the GNU Lesser General Public
3201 +   License as published by the Free Software Foundation; either
3202 +   version 2.1 of the License, or (at your option) any later version.
3203 +
3204 +   The GNU C Library is distributed in the hope that it will be useful,
3205 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
3206 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3207 +   Lesser General Public License for more details.
3208 +
3209 +   You should have received a copy of the GNU Lesser General Public
3210 +   License along with the GNU C Library; if not, write to the Free
3211 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3212 +   02111-1307 USA.  */
3213 +
3214 +#ifndef _SYS_PROCFS_H
3215 +#define _SYS_PROCFS_H  1
3216 +
3217 +/* This is somewhat modelled after the file of the same name on SVR4
3218 +   systems.  It provides a definition of the core file format for ELF
3219 +   used on Linux.  It doesn't have anything to do with the /proc file
3220 +   system, even though Linux has one.
3221 +
3222 +   Anyway, the whole purpose of this file is for GDB and GDB only.
3223 +   Don't read too much into it.  Don't use it for anything other than
3224 +   GDB unless you know what you are doing.  */
3225 +
3226 +#include <features.h>
3227 +#include <sys/time.h>
3228 +#include <sys/types.h>
3229 +
3230 +
3231 +/* Type for a general-purpose register.  */
3232 +typedef unsigned long elf_greg_t;
3233 +
3234 +/* This is exactly the same as `struct pt_regs' in the kernel.  */
3235 +struct elf_gregset
3236 +{
3237 +       elf_greg_t gpr[32];     /* General purpose registers.  */
3238 +
3239 +       elf_greg_t pc;          /* program counter */
3240 +       elf_greg_t psw;         /* program status word */
3241 +
3242 +       elf_greg_t kernel_mode; /* 1 if in `kernel mode', 0 if user mode */
3243 +       elf_greg_t single_step; /* 1 if in single step mode */
3244 +};
3245 +
3246 +#define ELF_NGREG (sizeof (struct elf_gregset) / sizeof(elf_greg_t))
3247 +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
3248 +
3249 +/* Register set for the floating-point registers.  */
3250 +typedef void elf_fpregset_t;
3251 +
3252 +struct elf_siginfo
3253 +{
3254 +       int     si_signo;                       /* signal number */
3255 +       int     si_code;                        /* extra code */
3256 +       int     si_errno;                       /* errno */
3257 +};
3258 +
3259 +
3260 +/*
3261 + * Definitions to generate Intel SVR4-like core files.
3262 + * These mostly have the same names as the SVR4 types with "elf_"
3263 + * tacked on the front to prevent clashes with linux definitions,
3264 + * and the typedef forms have been avoided.  This is mostly like
3265 + * the SVR4 structure, but more Linuxy, with things that Linux does
3266 + * not support and which gdb doesn't really use excluded.
3267 + * Fields present but not used are marked with "XXX".
3268 + */
3269 +struct elf_prstatus
3270 +{
3271 +       struct elf_siginfo pr_info;     /* Info associated with signal */
3272 +       short   pr_cursig;              /* Current signal */
3273 +       unsigned long pr_sigpend;       /* Set of pending signals */
3274 +       unsigned long pr_sighold;       /* Set of held signals */
3275 +       __kernel_pid_t  pr_pid;
3276 +       __kernel_pid_t  pr_ppid;
3277 +       __kernel_pid_t  pr_pgrp;
3278 +       __kernel_pid_t  pr_sid;
3279 +       struct timeval pr_utime;        /* User time */
3280 +       struct timeval pr_stime;        /* System time */
3281 +       struct timeval pr_cutime;       /* Cumulative user time */
3282 +       struct timeval pr_cstime;       /* Cumulative system time */
3283 +       elf_gregset_t pr_reg;   /* GP registers */
3284 +       int pr_fpvalid;         /* True if math co-processor being used.  */
3285 +};
3286 +
3287 +#define ELF_PRARGSZ    (80)    /* Number of chars for args */
3288 +
3289 +struct elf_prpsinfo
3290 +{
3291 +       char    pr_state;       /* numeric process state */
3292 +       char    pr_sname;       /* char for pr_state */
3293 +       char    pr_zomb;        /* zombie */
3294 +       char    pr_nice;        /* nice val */
3295 +       unsigned long pr_flag;  /* flags */
3296 +       __kernel_uid_t  pr_uid;
3297 +       __kernel_gid_t  pr_gid;
3298 +       __kernel_pid_t  pr_pid, pr_ppid, pr_pgrp, pr_sid;
3299 +       /* Lots missing */
3300 +       char    pr_fname[16];   /* filename of executable */
3301 +       char    pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
3302 +};
3303 +
3304 +
3305 +/* The rest of this file provides the types for emulation of the
3306 +   Solaris <proc_service.h> interfaces that should be implemented by
3307 +   users of libthread_db.  */
3308 +
3309 +/* Addresses.  */
3310 +typedef void *psaddr_t;
3311 +
3312 +/* Register sets.  Linux has different names.  */
3313 +typedef elf_gregset_t prgregset_t;
3314 +typedef elf_fpregset_t prfpregset_t;
3315 +
3316 +/* We don't have any differences between processes and threads,
3317 +   therefore have only one PID type.  */
3318 +typedef __kernel_pid_t lwpid_t;
3319 +
3320 +/* Process status and info.  In the end we do provide typedefs for them.  */
3321 +typedef struct elf_prstatus prstatus_t;
3322 +typedef struct elf_prpsinfo prpsinfo_t;
3323 +
3324 +
3325 +#endif /* sys/procfs.h */
3326 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/sys/ptrace.h uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/sys/ptrace.h
3327 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/sys/ptrace.h    2005-01-12 08:59:21.000000000 +0100
3328 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/sys/ptrace.h        2003-12-01 06:55:42.000000000 +0100
3329 @@ -1,5 +1,5 @@
3330  /* `ptrace' debugger support interface.  Linux/microblaze version.
3331 -   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
3332 +   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
3333     This file is part of the GNU C Library.
3334  
3335     The GNU C Library is free software; you can redistribute it and/or
3336 @@ -65,12 +65,16 @@
3337    PTRACE_KILL = 8,
3338  #define PT_KILL PTRACE_KILL
3339  
3340 +  /* Single step the process.  */
3341 +  PTRACE_SINGLESTEP = 9,
3342 +#define PT_STEP PTRACE_SINGLESTEP
3343 +
3344    /* Attach to a process that is already running. */
3345 -  PTRACE_ATTACH = 0x10,
3346 +  PTRACE_ATTACH = 16,
3347  #define PT_ATTACH PTRACE_ATTACH
3348  
3349    /* Detach from a process attached to with PTRACE_ATTACH.  */
3350 -  PTRACE_DETACH = 0x11,
3351 +  PTRACE_DETACH = 17,
3352  #define PT_DETACH PTRACE_DETACH
3353  
3354    /* Continue and stop at the next (return from) syscall.  */
3355 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/syscall.c uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/syscall.c
3356 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/syscall.c       2005-01-12 08:59:21.000000000 +0100
3357 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/syscall.c   2005-08-05 03:10:51.000000000 +0200
3358 @@ -26,26 +26,21 @@
3359       off the stack even for (the majority of) system calls with fewer
3360       arguments; hopefully this won't cause any problems.  A1-A4 are in
3361       registers, so they're OK.  */
3362 -  register arg_t a asm (SYSCALL_ARG0) = a1;
3363 -  register arg_t b asm (SYSCALL_ARG1) = a2;
3364 -  register arg_t c asm (SYSCALL_ARG2) = a3;
3365 -  register arg_t d asm (SYSCALL_ARG3) = a4;
3366 -  register arg_t e asm (SYSCALL_ARG4) = a5;
3367 -  register arg_t f asm (SYSCALL_ARG5) = a6;
3368 -  register unsigned long syscall asm (SYSCALL_NUM) = num;
3369 -  register unsigned long ret asm (SYSCALL_RET);
3370 -       unsigned long ret_sav;
3371 +  register unsigned long ret;
3372  
3373 -  *((unsigned long *)0xFFFF4004) = (unsigned int)('+');
3374 -  asm ("brlid r17, 08x; nop;" 
3375 +  asm (        "addk   r5, r0, %2      \n\t"
3376 +       "addk   r6, r0, %3      \n\t"
3377 +       "addk   r7, r0, %4      \n\t"
3378 +       "addk   r8, r0, %5      \n\t"
3379 +       "addk   r9, r0, %6      \n\t"
3380 +       "addk   r10,r0, %7      \n\t"
3381 +       "addk   r12,r0, %1      \n\t"
3382 +       "brki   r14, 0x08       \n\t"
3383 +       "addk   %0, r0, r3      \n\t"
3384         : "=r" (ret)
3385 -       : "r" (syscall), "r" (a), "r" (b), "r" (c), "r" (d), "r" (e), "r" (f)
3386 -       : SYSCALL_CLOBBERS);
3387 +       : "r" (syscall), "r" (a1), "r" (a2), "r" (a3), "r" (a4), "r" (a5),
3388 +               "r" (a6)
3389 +       : "r3", "r5", "r6", "r7", "r8", "r9", "r10", "r12", "r14", "cc");
3390         
3391 -  ret_sav=ret;
3392 -  *((unsigned long *)0xFFFF4004) = (unsigned int)('-');
3393 -
3394 -
3395 -
3396    __syscall_return (long, ret);
3397  }
3398 diff -urN uClibc-0.9.27/libc/sysdeps/linux/microblaze/vfork.S uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/vfork.S
3399 --- uClibc-0.9.27/libc/sysdeps/linux/microblaze/vfork.S 2005-01-12 08:59:21.000000000 +0100
3400 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/microblaze/vfork.S     2005-08-05 03:10:51.000000000 +0200
3401 @@ -29,15 +29,14 @@
3402  
3403  C_ENTRY (__vfork):
3404         addi    r12, r0, SYS_vfork
3405 -       bralid  r17, 0x08;
3406 -       nop
3407 +       brki    r14, 0x08;
3408         addi    r4, r3, 125             // minimum err value
3409         blti    r4, 1f                  // is r3 < -125?
3410 -       rtsd    r15, 8                  // normal return
3411 -       nop
3412 +       bri     2f                      // normal return
3413  1:     sub     r3, r3, r0              // r3 = -r3
3414         swi     r3, r0, C_SYMBOL_NAME(errno);
3415 -       rtsd    r15, 8                  // error return
3416 +                                       // state restore etc
3417 +2:     rtsd    r15, 8                  // error return
3418         nop
3419  C_END(__vfork)
3420  
3421 diff -urN uClibc-0.9.27/libc/sysdeps/linux/mips/bits/atomic.h uClibc-0.9.27-uc0/libc/sysdeps/linux/mips/bits/atomic.h
3422 --- uClibc-0.9.27/libc/sysdeps/linux/mips/bits/atomic.h 1970-01-01 01:00:00.000000000 +0100
3423 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/mips/bits/atomic.h     2006-01-16 07:46:31.000000000 +0100
3424 @@ -0,0 +1,303 @@
3425 +/* Low-level functions for atomic operations. Mips version.
3426 +   Copyright (C) 2005 Free Software Foundation, Inc.
3427 +   This file is part of the GNU C Library.
3428 +
3429 +   The GNU C Library is free software; you can redistribute it and/or
3430 +   modify it under the terms of the GNU Lesser General Public
3431 +   License as published by the Free Software Foundation; either
3432 +   version 2.1 of the License, or (at your option) any later version.
3433 +
3434 +   The GNU C Library is distributed in the hope that it will be useful,
3435 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
3436 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3437 +   Lesser General Public License for more details.
3438 +
3439 +   You should have received a copy of the GNU Lesser General Public
3440 +   License along with the GNU C Library; if not, write to the Free
3441 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3442 +   02111-1307 USA.  */
3443 +
3444 +#ifndef _MIPS_BITS_ATOMIC_H
3445 +#define _MIPS_BITS_ATOMIC_H 1
3446 +
3447 +#include <inttypes.h>
3448 +#include <sgidefs.h>
3449 +
3450 +typedef int32_t atomic32_t;
3451 +typedef uint32_t uatomic32_t;
3452 +typedef int_fast32_t atomic_fast32_t;
3453 +typedef uint_fast32_t uatomic_fast32_t;
3454 +
3455 +typedef int64_t atomic64_t;
3456 +typedef uint64_t uatomic64_t;
3457 +typedef int_fast64_t atomic_fast64_t;
3458 +typedef uint_fast64_t uatomic_fast64_t;
3459 +
3460 +typedef intptr_t atomicptr_t;
3461 +typedef uintptr_t uatomicptr_t;
3462 +typedef intmax_t atomic_max_t;
3463 +typedef uintmax_t uatomic_max_t;
3464 +
3465 +#if _MIPS_SIM == _ABIO32
3466 +#define MIPS_PUSH_MIPS2 ".set  mips2\n\t"
3467 +#else
3468 +#define MIPS_PUSH_MIPS2
3469 +#endif
3470 +
3471 +/* See the comments in <sys/asm.h> about the use of the sync instruction.  */
3472 +#ifndef MIPS_SYNC
3473 +# define MIPS_SYNC     sync
3474 +#endif
3475 +
3476 +#define MIPS_SYNC_STR_2(X) #X
3477 +#define MIPS_SYNC_STR_1(X) MIPS_SYNC_STR_2(X)
3478 +#define MIPS_SYNC_STR MIPS_SYNC_STR_1(MIPS_SYNC)
3479 +
3480 +/* Compare and exchange.  For all of the "xxx" routines, we expect a
3481 +   "__prev" and a "__cmp" variable to be provided by the enclosing scope,
3482 +   in which values are returned.  */
3483 +
3484 +#define __arch_compare_and_exchange_xxx_8_int(mem, newval, oldval, rel, acq) \
3485 +  (abort (), __prev = __cmp = 0)
3486 +
3487 +#define __arch_compare_and_exchange_xxx_16_int(mem, newval, oldval, rel, acq) \
3488 +  (abort (), __prev = __cmp = 0)
3489 +
3490 +#define __arch_compare_and_exchange_xxx_32_int(mem, newval, oldval, rel, acq) \
3491 +     __asm__ __volatile__ (                                                  \
3492 +     ".set     push\n\t"                                                     \
3493 +     MIPS_PUSH_MIPS2                                                         \
3494 +     rel       "\n"                                                          \
3495 +     "1:\t"                                                                  \
3496 +     "ll       %0,%4\n\t"                                                    \
3497 +     "move     %1,$0\n\t"                                                    \
3498 +     "bne      %0,%2,2f\n\t"                                                 \
3499 +     "move     %1,%3\n\t"                                                    \
3500 +     "sc       %1,%4\n\t"                                                    \
3501 +     "beqz     %1,1b\n"                                                      \
3502 +     acq       "\n\t"                                                        \
3503 +     ".set     pop\n"                                                        \
3504 +     "2:\n\t"                                                                \
3505 +             : "=&r" (__prev), "=&r" (__cmp)                                 \
3506 +             : "r" (oldval), "r" (newval), "m" (*mem)                        \
3507 +             : "memory")
3508 +
3509 +#if _MIPS_SIM == _ABIO32
3510 +/* We can't do an atomic 64-bit operation in O32.  */
3511 +#define __arch_compare_and_exchange_xxx_64_int(mem, newval, oldval, rel, acq) \
3512 +  (abort (), __prev = __cmp = 0)
3513 +#else
3514 +#define __arch_compare_and_exchange_xxx_64_int(mem, newval, oldval, rel, acq) \
3515 +     __asm__ __volatile__ ("\n"                                                      \
3516 +     ".set     push\n\t"                                                     \
3517 +     MIPS_PUSH_MIPS2                                                         \
3518 +     rel       "\n"                                                          \
3519 +     "1:\t"                                                                  \
3520 +     "lld      %0,%4\n\t"                                                    \
3521 +     "move     %1,$0\n\t"                                                    \
3522 +     "bne      %0,%2,2f\n\t"                                                 \
3523 +     "move     %1,%3\n\t"                                                    \
3524 +     "scd      %1,%4\n\t"                                                    \
3525 +     "beqz     %1,1b\n"                                                      \
3526 +     acq       "\n\t"                                                        \
3527 +     ".set     pop\n"                                                        \
3528 +     "2:\n\t"                                                                \
3529 +             : "=&r" (__prev), "=&r" (__cmp)                                 \
3530 +             : "r" (oldval), "r" (newval), "m" (*mem)                        \
3531 +             : "memory")
3532 +#endif
3533 +
3534 +/* For all "bool" routines, we return FALSE if exchange succesful.  */
3535 +
3536 +#define __arch_compare_and_exchange_bool_8_int(mem, new, old, rel, acq)        \
3537 +({ typeof (*mem) __prev; int __cmp;                                    \
3538 +   __arch_compare_and_exchange_xxx_8_int(mem, new, old, rel, acq);     \
3539 +   !__cmp; })
3540 +
3541 +#define __arch_compare_and_exchange_bool_16_int(mem, new, old, rel, acq) \
3542 +({ typeof (*mem) __prev; int __cmp;                                    \
3543 +   __arch_compare_and_exchange_xxx_16_int(mem, new, old, rel, acq);    \
3544 +   !__cmp; })
3545 +
3546 +#define __arch_compare_and_exchange_bool_32_int(mem, new, old, rel, acq) \
3547 +({ typeof (*mem) __prev; int __cmp;                                    \
3548 +   __arch_compare_and_exchange_xxx_32_int(mem, new, old, rel, acq);    \
3549 +   !__cmp; })
3550 +
3551 +#define __arch_compare_and_exchange_bool_64_int(mem, new, old, rel, acq) \
3552 +({ typeof (*mem) __prev; int __cmp;                                    \
3553 +   __arch_compare_and_exchange_xxx_64_int(mem, new, old, rel, acq);    \
3554 +   !__cmp; })
3555 +
3556 +/* For all "val" routines, return the old value whether exchange
3557 +   successful or not.  */
3558 +
3559 +#define __arch_compare_and_exchange_val_8_int(mem, new, old, rel, acq) \
3560 +({ typeof (*mem) __prev; int __cmp;                                    \
3561 +   __arch_compare_and_exchange_xxx_8_int(mem, new, old, rel, acq);     \
3562 +   (typeof (*mem))__prev; })
3563 +
3564 +#define __arch_compare_and_exchange_val_16_int(mem, new, old, rel, acq) \
3565 +({ typeof (*mem) __prev; int __cmp;                                    \
3566 +   __arch_compare_and_exchange_xxx_16_int(mem, new, old, rel, acq);    \
3567 +   (typeof (*mem))__prev; })
3568 +
3569 +#define __arch_compare_and_exchange_val_32_int(mem, new, old, rel, acq) \
3570 +({ typeof (*mem) __prev; int __cmp;                                    \
3571 +   __arch_compare_and_exchange_xxx_32_int(mem, new, old, rel, acq);    \
3572 +   (typeof (*mem))__prev; })
3573 +
3574 +#define __arch_compare_and_exchange_val_64_int(mem, new, old, rel, acq) \
3575 +({ typeof (*mem) __prev; int __cmp;                                    \
3576 +   __arch_compare_and_exchange_xxx_64_int(mem, new, old, rel, acq);    \
3577 +   (typeof (*mem))__prev; })
3578 +
3579 +/* Compare and exchange with "acquire" semantics, ie barrier after.  */
3580 +
3581 +#define atomic_compare_and_exchange_bool_acq(mem, new, old)    \
3582 +  __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
3583 +                       mem, new, old, "", MIPS_SYNC_STR)
3584 +
3585 +#define atomic_compare_and_exchange_val_acq(mem, new, old)     \
3586 +  __atomic_val_bysize (__arch_compare_and_exchange_val, int,   \
3587 +                      mem, new, old, "", MIPS_SYNC_STR)
3588 +
3589 +/* Compare and exchange with "release" semantics, ie barrier before.  */
3590 +
3591 +#define atomic_compare_and_exchange_bool_rel(mem, new, old)    \
3592 +  __atomic_bool_bysize (__arch_compare_and_exchange_bool, int, \
3593 +                       mem, new, old, MIPS_SYNC_STR, "")
3594 +
3595 +#define atomic_compare_and_exchange_val_rel(mem, new, old)     \
3596 +  __atomic_val_bysize (__arch_compare_and_exchange_val, int,   \
3597 +                      mem, new, old, MIPS_SYNC_STR, "")
3598 +
3599 +
3600 +
3601 +/* Atomic exchange (without compare).  */
3602 +
3603 +#define __arch_exchange_xxx_8_int(mem, newval, rel, acq) \
3604 +  (abort (), 0)
3605 +
3606 +#define __arch_exchange_xxx_16_int(mem, newval, rel, acq) \
3607 +  (abort (), 0)
3608 +
3609 +#define __arch_exchange_xxx_32_int(mem, newval, rel, acq) \
3610 +({ typeof (*mem) __prev; int __cmp;                                          \
3611 +     __asm__ __volatile__ ("\n"                                                      \
3612 +     ".set     push\n\t"                                                     \
3613 +     MIPS_PUSH_MIPS2                                                         \
3614 +     rel       "\n"                                                          \
3615 +     "1:\t"                                                                  \
3616 +     "ll       %0,%3\n\t"                                                    \
3617 +     "move     %1,%2\n\t"                                                    \
3618 +     "sc       %1,%3\n\t"                                                    \
3619 +     "beqz     %1,1b\n"                                                      \
3620 +     acq       "\n\t"                                                        \
3621 +     ".set     pop\n"                                                        \
3622 +     "2:\n\t"                                                                \
3623 +             : "=&r" (__prev), "=&r" (__cmp)                                 \
3624 +             : "r" (newval), "m" (*mem)                                      \
3625 +             : "memory");                                                    \
3626 +  __prev; })
3627 +
3628 +#if _MIPS_SIM == _ABIO32
3629 +/* We can't do an atomic 64-bit operation in O32.  */
3630 +#define __arch_exchange_xxx_64_int(mem, newval, rel, acq) \
3631 +  (abort (), 0)
3632 +#else
3633 +#define __arch_exchange_xxx_64_int(mem, newval, rel, acq) \
3634 +({ typeof (*mem) __prev; int __cmp;                                          \
3635 +     __asm__ __volatile__ ("\n"                                                      \
3636 +     ".set     push\n\t"                                                     \
3637 +     MIPS_PUSH_MIPS2                                                         \
3638 +     rel       "\n"                                                          \
3639 +     "1:\n"                                                                  \
3640 +     "lld      %0,%3\n\t"                                                    \
3641 +     "move     %1,%2\n\t"                                                    \
3642 +     "scd      %1,%3\n\t"                                                    \
3643 +     "beqz     %1,1b\n"                                                      \
3644 +     acq       "\n\t"                                                        \
3645 +     ".set     pop\n"                                                        \
3646 +     "2:\n\t"                                                                \
3647 +             : "=&r" (__prev), "=&r" (__cmp)                                 \
3648 +             : "r" (newval), "m" (*mem)                                      \
3649 +             : "memory");                                                    \
3650 +  __prev; })
3651 +#endif
3652 +
3653 +#define atomic_exchange_acq(mem, value) \
3654 +  __atomic_val_bysize (__arch_exchange_xxx, int, mem, value, "", MIPS_SYNC_STR)
3655 +
3656 +#define atomic_exchange_rel(mem, value) \
3657 +  __atomic_val_bysize (__arch_exchange_xxx, int, mem, value, MIPS_SYNC_STR, "")
3658 +
3659 +
3660 +/* Atomically add value and return the previous (unincremented) value.  */
3661 +
3662 +#define __arch_exchange_and_add_8_int(mem, newval, rel, acq) \
3663 +  (abort (), (typeof(*mem)) 0)
3664 +
3665 +#define __arch_exchange_and_add_16_int(mem, newval, rel, acq) \
3666 +  (abort (), (typeof(*mem)) 0)
3667 +
3668 +#define __arch_exchange_and_add_32_int(mem, value, rel, acq) \
3669 +({ typeof (*mem) __prev; int __cmp;                                          \
3670 +     __asm__ __volatile__ ("\n"                                                      \
3671 +     ".set     push\n\t"                                                     \
3672 +     MIPS_PUSH_MIPS2                                                         \
3673 +     rel       "\n"                                                          \
3674 +     "1:\t"                                                                  \
3675 +     "ll       %0,%3\n\t"                                                    \
3676 +     "addu     %1,%0,%2\n\t"                                                 \
3677 +     "sc       %1,%3\n\t"                                                    \
3678 +     "beqz     %1,1b\n"                                                      \
3679 +     acq       "\n\t"                                                        \
3680 +     ".set     pop\n"                                                        \
3681 +     "2:\n\t"                                                                \
3682 +             : "=&r" (__prev), "=&r" (__cmp)                                 \
3683 +             : "r" (value), "m" (*mem)                                       \
3684 +             : "memory");                                                    \
3685 +  __prev; })
3686 +
3687 +#if _MIPS_SIM == _ABIO32
3688 +/* We can't do an atomic 64-bit operation in O32.  */
3689 +#define __arch_exchange_and_add_64_int(mem, value, rel, acq) \
3690 +  (abort (), (typeof(*mem)) 0)
3691 +#else
3692 +#define __arch_exchange_and_add_64_int(mem, value, rel, acq) \
3693 +({ typeof (*mem) __prev; int __cmp;                                          \
3694 +     __asm__ __volatile__ (                                                  \
3695 +     ".set     push\n\t"                                                     \
3696 +     MIPS_PUSH_MIPS2                                                         \
3697 +     rel       "\n"                                                          \
3698 +     "1:\t"                                                                  \
3699 +     "lld      %0,%3\n\t"                                                    \
3700 +     "daddu    %1,%0,%2\n\t"                                                 \
3701 +     "scd      %1,%3\n\t"                                                    \
3702 +     "beqz     %1,1b\n"                                                      \
3703 +     acq       "\n\t"                                                        \
3704 +     ".set     pop\n"                                                        \
3705 +     "2:\n\t"                                                                \
3706 +             : "=&r" (__prev), "=&r" (__cmp)                                 \
3707 +             : "r" (value), "m" (*mem)                                       \
3708 +             : "memory");                                                    \
3709 +  __prev; })
3710 +#endif
3711 +
3712 +/* ??? Barrier semantics for atomic_exchange_and_add appear to be 
3713 +   undefined.  Use full barrier for now, as that's safe.  */
3714 +#define atomic_exchange_and_add(mem, value) \
3715 +  __atomic_val_bysize (__arch_exchange_and_add, int, mem, value,             \
3716 +                      MIPS_SYNC_STR, MIPS_SYNC_STR)
3717 +
3718 +/* TODO: More atomic operations could be implemented efficiently; only the
3719 +   basic requirements are done.  */
3720 +
3721 +#define atomic_full_barrier() \
3722 +  __asm__ __volatile__ (".set push\n\t"                                              \
3723 +                       MIPS_PUSH_MIPS2                                       \
3724 +                       MIPS_SYNC_STR "\n\t"                                  \
3725 +                       ".set pop" : : : "memory")
3726 +
3727 +#endif /* bits/atomic.h */
3728 diff -urN uClibc-0.9.27/libc/sysdeps/linux/sh/bits/atomic.h uClibc-0.9.27-uc0/libc/sysdeps/linux/sh/bits/atomic.h
3729 --- uClibc-0.9.27/libc/sysdeps/linux/sh/bits/atomic.h   1970-01-01 01:00:00.000000000 +0100
3730 +++ uClibc-0.9.27-uc0/libc/sysdeps/linux/sh/bits/atomic.h       2006-01-16 07:46:31.000000000 +0100
3731 @@ -0,0 +1,419 @@
3732 +/* Atomic operations used inside libc.  Linux/SH version.
3733 +   Copyright (C) 2003 Free Software Foundation, Inc.
3734 +   This file is part of the GNU C Library.
3735 +
3736 +   The GNU C Library is free software; you can redistribute it and/or
3737 +   modify it under the terms of the GNU Lesser General Public
3738 +   License as published by the Free Software Foundation; either
3739 +   version 2.1 of the License, or (at your option) any later version.
3740 +
3741 +   The GNU C Library is distributed in the hope that it will be useful,
3742 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
3743 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3744 +   Lesser General Public License for more details.
3745 +
3746 +   You should have received a copy of the GNU Lesser General Public
3747 +   License along with the GNU C Library; if not, write to the Free
3748 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3749 +   02111-1307 USA.  */
3750 +
3751 +#include <stdint.h>
3752 +
3753 +
3754 +typedef int8_t atomic8_t;
3755 +typedef uint8_t uatomic8_t;
3756 +typedef int_fast8_t atomic_fast8_t;
3757 +typedef uint_fast8_t uatomic_fast8_t;
3758 +
3759 +typedef int16_t atomic16_t;
3760 +typedef uint16_t uatomic16_t;
3761 +typedef int_fast16_t atomic_fast16_t;
3762 +typedef uint_fast16_t uatomic_fast16_t;
3763 +
3764 +typedef int32_t atomic32_t;
3765 +typedef uint32_t uatomic32_t;
3766 +typedef int_fast32_t atomic_fast32_t;
3767 +typedef uint_fast32_t uatomic_fast32_t;
3768 +
3769 +typedef int64_t atomic64_t;
3770 +typedef uint64_t uatomic64_t;
3771 +typedef int_fast64_t atomic_fast64_t;
3772 +typedef uint_fast64_t uatomic_fast64_t;
3773 +
3774 +typedef intptr_t atomicptr_t;
3775 +typedef uintptr_t uatomicptr_t;
3776 +typedef intmax_t atomic_max_t;
3777 +typedef uintmax_t uatomic_max_t;
3778 +
3779 +/* SH kernel has implemented a gUSA ("g" User Space Atomicity) support
3780 +   for the user space atomicity. The atomicity macros use this scheme.
3781 +
3782 +  Reference:
3783 +    Niibe Yutaka, "gUSA: Simple and Efficient User Space Atomicity
3784 +    Emulation with Little Kernel Modification", Linux Conference 2002,
3785 +    Japan. http://lc.linux.or.jp/lc2002/papers/niibe0919h.pdf (in
3786 +    Japanese).
3787 +
3788 +    B.N. Bershad, D. Redell, and J. Ellis, "Fast Mutual Exclusion for
3789 +    Uniprocessors",  Proceedings of the Fifth Architectural Support for
3790 +    Programming Languages and Operating Systems (ASPLOS), pp. 223-233,
3791 +    October 1992. http://www.cs.washington.edu/homes/bershad/Papers/Rcs.ps
3792 +
3793 +  SuperH ABI:
3794 +      r15:    -(size of atomic instruction sequence) < 0
3795 +      r0:     end point
3796 +      r1:     saved stack pointer
3797 +*/
3798 +
3799 +#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
3800 +  ({ __typeof (*(mem)) __result; \
3801 +     __asm __volatile ("\
3802 +       .align 2\n\
3803 +       mova 1f,r0\n\
3804 +       nop\n\
3805 +       mov r15,r1\n\
3806 +       mov #-8,r15\n\
3807 +     0: mov.b @%1,%0\n\
3808 +       cmp/eq %0,%3\n\
3809 +       bf 1f\n\
3810 +       mov.b %2,@%1\n\
3811 +     1: mov r1,r15"\
3812 +       : "=&r" (__result) : "r" (mem), "r" (newval), "r" (oldval) \
3813 +       : "r0", "r1", "t", "memory"); \
3814 +     __result; })
3815 +
3816 +#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \
3817 +  ({ __typeof (*(mem)) __result; \
3818 +     __asm __volatile ("\
3819 +       .align 2\n\
3820 +       mova 1f,r0\n\
3821 +       nop\n\
3822 +       mov r15,r1\n\
3823 +       mov #-8,r15\n\
3824 +     0: mov.w @%1,%0\n\
3825 +       cmp/eq %0,%3\n\
3826 +       bf 1f\n\
3827 +       mov.w %2,@%1\n\
3828 +     1: mov r1,r15"\
3829 +       : "=&r" (__result) : "r" (mem), "r" (newval), "r" (oldval) \
3830 +       : "r0", "r1", "t", "memory"); \
3831 +     __result; })
3832 +
3833 +#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \
3834 +  ({ __typeof (*(mem)) __result; \
3835 +     __asm __volatile ("\
3836 +       .align 2\n\
3837 +       mova 1f,r0\n\
3838 +       nop\n\
3839 +       mov r15,r1\n\
3840 +       mov #-8,r15\n\
3841 +     0: mov.l @%1,%0\n\
3842 +       cmp/eq %0,%3\n\
3843 +       bf 1f\n\
3844 +       mov.l %2,@%1\n\
3845 +     1: mov r1,r15"\
3846 +       : "=&r" (__result) : "r" (mem), "r" (newval), "r" (oldval) \
3847 +       : "r0", "r1", "t", "memory"); \
3848 +     __result; })
3849 +
3850 +/* XXX We do not really need 64-bit compare-and-exchange.  At least
3851 +   not in the moment.  Using it would mean causing portability
3852 +   problems since not many other 32-bit architectures have support for
3853 +   such an operation.  So don't define any code for now.  */
3854 +
3855 +# define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
3856 +  (abort (), (__typeof (*mem)) 0)
3857 +
3858 +#define atomic_exchange_and_add(mem, value) \
3859 +  ({ __typeof (*(mem)) __result, __tmp, __value = (value); \
3860 +     if (sizeof (*(mem)) == 1) \
3861 +       __asm __volatile ("\
3862 +         .align 2\n\
3863 +         mova 1f,r0\n\
3864 +         mov r15,r1\n\
3865 +         mov #-6,r15\n\
3866 +       0: mov.b @%2,%0\n\
3867 +         add %0,%1\n\
3868 +         mov.b %1,@%2\n\
3869 +       1: mov r1,r15"\
3870 +       : "=&r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
3871 +       : "r0", "r1", "memory"); \
3872 +     else if (sizeof (*(mem)) == 2) \
3873 +       __asm __volatile ("\
3874 +         .align 2\n\
3875 +         mova 1f,r0\n\
3876 +         mov r15,r1\n\
3877 +         mov #-6,r15\n\
3878 +       0: mov.w @%2,%0\n\
3879 +         add %0,%1\n\
3880 +         mov.w %1,@%2\n\
3881 +       1: mov r1,r15"\
3882 +       : "=&r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
3883 +       : "r0", "r1", "memory"); \
3884 +     else if (sizeof (*(mem)) == 4) \
3885 +       __asm __volatile ("\
3886 +         .align 2\n\
3887 +         mova 1f,r0\n\
3888 +         mov r15,r1\n\
3889 +         mov #-6,r15\n\
3890 +       0: mov.l @%2,%0\n\
3891 +         add %0,%1\n\
3892 +         mov.l %1,@%2\n\
3893 +       1: mov r1,r15"\
3894 +       : "=&r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
3895 +       : "r0", "r1", "memory"); \
3896 +     else \
3897 +       { \
3898 +        __typeof (mem) memp = (mem); \
3899 +        do \
3900 +          __result = *memp; \
3901 +        while (__arch_compare_and_exchange_val_64_acq \
3902 +                (memp, __result + __value, __result) == __result); \
3903 +        (void) __value; \
3904 +       } \
3905 +     __result; })
3906 +
3907 +#define atomic_add(mem, value) \
3908 +  (void) ({ __typeof (*(mem)) __tmp, __value = (value); \
3909 +           if (sizeof (*(mem)) == 1) \
3910 +             __asm __volatile ("\
3911 +               .align 2\n\
3912 +               mova 1f,r0\n\
3913 +               mov r15,r1\n\
3914 +               mov #-6,r15\n\
3915 +            0: mov.b @%1,r2\n\
3916 +               add r2,%0\n\
3917 +               mov.b %0,@%1\n\
3918 +            1: mov r1,r15"\
3919 +               : "=&r" (__tmp) : "r" (mem), "0" (__value) \
3920 +               : "r0", "r1", "r2", "memory"); \
3921 +           else if (sizeof (*(mem)) == 2) \
3922 +             __asm __volatile ("\
3923 +               .align 2\n\
3924 +               mova 1f,r0\n\
3925 +               mov r15,r1\n\
3926 +               mov #-6,r15\n\
3927 +            0: mov.w @%1,r2\n\
3928 +               add r2,%0\n\
3929 +               mov.w %0,@%1\n\
3930 +            1: mov r1,r15"\
3931 +               : "=&r" (__tmp) : "r" (mem), "0" (__value) \
3932 +               : "r0", "r1", "r2", "memory"); \
3933 +           else if (sizeof (*(mem)) == 4) \
3934 +             __asm __volatile ("\
3935 +               .align 2\n\
3936 +               mova 1f,r0\n\
3937 +               mov r15,r1\n\
3938 +               mov #-6,r15\n\
3939 +            0: mov.l @%1,r2\n\
3940 +               add r2,%0\n\
3941 +               mov.l %0,@%1\n\
3942 +            1: mov r1,r15"\
3943 +               : "=&r" (__tmp) : "r" (mem), "0" (__value) \
3944 +               : "r0", "r1", "r2", "memory"); \
3945 +           else \
3946 +             { \
3947 +               __typeof (*(mem)) oldval; \
3948 +               __typeof (mem) memp = (mem); \
3949 +               do \
3950 +                 oldval = *memp; \
3951 +               while (__arch_compare_and_exchange_val_64_acq \
3952 +                       (memp, oldval + __value, oldval) == oldval); \
3953 +               (void) __value; \
3954 +             } \
3955 +           })
3956 +
3957 +#define atomic_add_negative(mem, value) \
3958 +  ({ unsigned char __result; \
3959 +     __typeof (*(mem)) __tmp, __value = (value); \
3960 +     if (sizeof (*(mem)) == 1) \
3961 +       __asm __volatile ("\
3962 +         .align 2\n\
3963 +         mova 1f,r0\n\
3964 +         mov r15,r1\n\
3965 +         mov #-6,r15\n\
3966 +       0: mov.b @%2,r2\n\
3967 +         add r2,%1\n\
3968 +         mov.b %1,@%2\n\
3969 +       1: mov r1,r15\n\
3970 +         shal %1\n\
3971 +         movt %0"\
3972 +       : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
3973 +       : "r0", "r1", "r2", "t", "memory"); \
3974 +     else if (sizeof (*(mem)) == 2) \
3975 +       __asm __volatile ("\
3976 +         .align 2\n\
3977 +         mova 1f,r0\n\
3978 +         mov r15,r1\n\
3979 +         mov #-6,r15\n\
3980 +       0: mov.w @%2,r2\n\
3981 +         add r2,%1\n\
3982 +         mov.w %1,@%2\n\
3983 +       1: mov r1,r15\n\
3984 +         shal %1\n\
3985 +         movt %0"\
3986 +       : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
3987 +       : "r0", "r1", "r2", "t", "memory"); \
3988 +     else if (sizeof (*(mem)) == 4) \
3989 +       __asm __volatile ("\
3990 +         .align 2\n\
3991 +         mova 1f,r0\n\
3992 +         mov r15,r1\n\
3993 +         mov #-6,r15\n\
3994 +       0: mov.l @%2,r2\n\
3995 +         add r2,%1\n\
3996 +         mov.l %1,@%2\n\
3997 +       1: mov r1,r15\n\
3998 +         shal %1\n\
3999 +         movt %0"\
4000 +       : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
4001 +       : "r0", "r1", "r2", "t", "memory"); \
4002 +     else \
4003 +       abort (); \
4004 +     __result; })
4005 +
4006 +#define atomic_add_zero(mem, value) \
4007 +  ({ unsigned char __result; \
4008 +     __typeof (*(mem)) __tmp, __value = (value); \
4009 +     if (sizeof (*(mem)) == 1) \
4010 +       __asm __volatile ("\
4011 +         .align 2\n\
4012 +         mova 1f,r0\n\
4013 +         mov r15,r1\n\
4014 +         mov #-6,r15\n\
4015 +       0: mov.b @%2,r2\n\
4016 +         add r2,%1\n\
4017 +         mov.b %1,@%2\n\
4018 +       1: mov r1,r15\n\
4019 +         tst %1,%1\n\
4020 +         movt %0"\
4021 +       : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
4022 +       : "r0", "r1", "r2", "t", "memory"); \
4023 +     else if (sizeof (*(mem)) == 2) \
4024 +       __asm __volatile ("\
4025 +         .align 2\n\
4026 +         mova 1f,r0\n\
4027 +         mov r15,r1\n\
4028 +         mov #-6,r15\n\
4029 +       0: mov.w @%2,r2\n\
4030 +         add r2,%1\n\
4031 +         mov.w %1,@%2\n\
4032 +       1: mov r1,r15\n\
4033 +         tst %1,%1\n\
4034 +         movt %0"\
4035 +       : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
4036 +       : "r0", "r1", "r2", "t", "memory"); \
4037 +     else if (sizeof (*(mem)) == 4) \
4038 +       __asm __volatile ("\
4039 +         .align 2\n\
4040 +         mova 1f,r0\n\
4041 +         mov r15,r1\n\
4042 +         mov #-6,r15\n\
4043 +       0: mov.l @%2,r2\n\
4044 +         add r2,%1\n\
4045 +         mov.l %1,@%2\n\
4046 +       1: mov r1,r15\n\
4047 +         tst %1,%1\n\
4048 +         movt %0"\
4049 +       : "=r" (__result), "=&r" (__tmp) : "r" (mem), "1" (__value) \
4050 +       : "r0", "r1", "r2", "t", "memory"); \
4051 +     else \
4052 +       abort (); \
4053 +     __result; })
4054 +
4055 +#define atomic_increment_and_test(mem) atomic_add_zero((mem), 1)
4056 +#define atomic_decrement_and_test(mem) atomic_add_zero((mem), -1)
4057 +
4058 +#define atomic_bit_set(mem, bit) \
4059 +  (void) ({ unsigned int __mask = 1 << (bit); \
4060 +           if (sizeof (*(mem)) == 1) \
4061 +             __asm __volatile ("\
4062 +               .align 2\n\
4063 +               mova 1f,r0\n\
4064 +               mov r15,r1\n\
4065 +               mov #-6,r15\n\
4066 +            0: mov.b @%0,r2\n\
4067 +               or %1,r2\n\
4068 +               mov.b r2,@%0\n\
4069 +            1: mov r1,r15"\
4070 +               : : "r" (mem), "r" (__mask) \
4071 +               : "r0", "r1", "r2", "memory"); \
4072 +           else if (sizeof (*(mem)) == 2) \
4073 +             __asm __volatile ("\
4074 +               .align 2\n\
4075 +               mova 1f,r0\n\
4076 +               mov r15,r1\n\
4077 +               mov #-6,r15\n\
4078 +            0: mov.w @%0,r2\n\
4079 +               or %1,r2\n\
4080 +               mov.w r2,@%0\n\
4081 +            1: mov r1,r15"\
4082 +               : : "r" (mem), "r" (__mask) \
4083 +               : "r0", "r1", "r2", "memory"); \
4084 +           else if (sizeof (*(mem)) == 4) \
4085 +             __asm __volatile ("\
4086 +               .align 2\n\
4087 +               mova 1f,r0\n\
4088 +               mov r15,r1\n\
4089 +               mov #-6,r15\n\
4090 +            0: mov.l @%0,r2\n\
4091 +               or %1,r2\n\
4092 +               mov.l r2,@%0\n\
4093 +            1: mov r1,r15"\
4094 +               : : "r" (mem), "r" (__mask) \
4095 +               : "r0", "r1", "r2", "memory"); \
4096 +           else \
4097 +             abort (); \
4098 +           })
4099 +
4100 +#define atomic_bit_test_set(mem, bit) \
4101 +  ({ unsigned int __mask = 1 << (bit); \
4102 +     unsigned int __result = __mask; \
4103 +     if (sizeof (*(mem)) == 1) \
4104 +       __asm __volatile ("\
4105 +         .align 2\n\
4106 +         mova 1f,r0\n\
4107 +         nop\n\
4108 +         mov r15,r1\n\
4109 +         mov #-8,r15\n\
4110 +       0: mov.b @%2,r2\n\
4111 +         or r2,%1\n\
4112 +         and r2,%0\n\
4113 +         mov.b %1,@%2\n\
4114 +       1: mov r1,r15"\
4115 +       : "=&r" (__result), "=&r" (__mask) \
4116 +       : "r" (mem), "0" (__result), "1" (__mask) \
4117 +       : "r0", "r1", "r2", "memory"); \
4118 +     else if (sizeof (*(mem)) == 2) \
4119 +       __asm __volatile ("\
4120 +         .align 2\n\
4121 +         mova 1f,r0\n\
4122 +         nop\n\
4123 +         mov r15,r1\n\
4124 +         mov #-8,r15\n\
4125 +       0: mov.w @%2,r2\n\
4126 +         or r2,%1\n\
4127 +         and r2,%0\n\
4128 +         mov.w %1,@%2\n\
4129 +       1: mov r1,r15"\
4130 +       : "=&r" (__result), "=&r" (__mask) \
4131 +       : "r" (mem), "0" (__result), "1" (__mask) \
4132 +       : "r0", "r1", "r2", "memory"); \
4133 +     else if (sizeof (*(mem)) == 4) \
4134 +       __asm __volatile ("\
4135 +         .align 2\n\
4136 +         mova 1f,r0\n\
4137 +         nop\n\
4138 +         mov r15,r1\n\
4139 +         mov #-8,r15\n\
4140 +       0: mov.l @%2,r2\n\
4141 +         or r2,%1\n\
4142 +         and r2,%0\n\
4143 +         mov.l %1,@%2\n\
4144 +       1: mov r1,r15"\
4145 +       : "=&r" (__result), "=&r" (__mask) \
4146 +       : "r" (mem), "0" (__result), "1" (__mask) \
4147 +       : "r0", "r1", "r2", "memory"); \
4148 +     else \
4149 +       abort (); \
4150 +     __result; })
4151 diff -urN uClibc-0.9.27/libcrypt/md5.c uClibc-0.9.27-uc0/libcrypt/md5.c
4152 --- uClibc-0.9.27/libcrypt/md5.c        2005-01-12 08:59:21.000000000 +0100
4153 +++ uClibc-0.9.27-uc0/libcrypt/md5.c    2003-07-14 17:11:41.000000000 +0200
4154 @@ -111,6 +111,11 @@
4155   * a multiple of 4.
4156   */
4157  
4158 +static void __md5_Encode (unsigned char *output, u_int32_t *input,
4159 +                                                       unsigned int len);
4160 +static void __md5_Decode (u_int32_t *output, const unsigned char *input,
4161 +                                                       unsigned int len);
4162 +
4163  static void
4164  __md5_Encode (output, input, len)
4165         unsigned char *output;
4166 diff -urN uClibc-0.9.27/libpthread/linuxthreads/internals.h uClibc-0.9.27-uc0/libpthread/linuxthreads/internals.h
4167 --- uClibc-0.9.27/libpthread/linuxthreads/internals.h   2005-01-12 08:59:21.000000000 +0100
4168 +++ uClibc-0.9.27-uc0/libpthread/linuxthreads/internals.h       2005-09-16 08:11:17.000000000 +0200
4169 @@ -259,7 +259,10 @@
4170  extern char *__pthread_initial_thread_bos;
4171  #ifndef __ARCH_HAS_MMU__
4172  extern char *__pthread_initial_thread_tos;
4173 -#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) if ((tos)>=__pthread_initial_thread_bos && (bos)<=__pthread_initial_thread_tos) __pthread_initial_thread_bos = (tos)+1
4174 +#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \
4175 +    if ((tos)>=__pthread_initial_thread_bos \
4176 +       && (bos)<__pthread_initial_thread_tos) \
4177 +       __pthread_initial_thread_bos = (tos)+1
4178  #else
4179  #define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */
4180  #endif /* __ARCH_HAS_MMU__ */
4181 diff -urN uClibc-0.9.27/libpthread/linuxthreads/pthread.c uClibc-0.9.27-uc0/libpthread/linuxthreads/pthread.c
4182 --- uClibc-0.9.27/libpthread/linuxthreads/pthread.c     2005-01-12 08:59:21.000000000 +0100
4183 +++ uClibc-0.9.27-uc0/libpthread/linuxthreads/pthread.c 2005-01-26 07:37:27.000000000 +0100
4184 @@ -33,7 +33,6 @@
4185  #include "restart.h"
4186  #include "debug.h"      /* added to linuxthreads -StS */
4187  
4188 -
4189  /* Mods for uClibc: Some includes */
4190  #include <signal.h>
4191  #include <sys/types.h>
4192 @@ -224,15 +223,8 @@
4193     platform does not support any real-time signals we will define the
4194     values to some unreasonable value which will signal failing of all
4195     the functions below.  */
4196 -#ifndef __NR_rt_sigaction
4197 -static int current_rtmin = -1;
4198 -static int current_rtmax = -1;
4199 -int __pthread_sig_restart = SIGUSR1;
4200 -int __pthread_sig_cancel = SIGUSR2;
4201 -int __pthread_sig_debug;
4202 -#else
4203  
4204 -#if __SIGRTMAX - __SIGRTMIN >= 3
4205 +#if defined(__NR_rt_sigaction) && __SIGRTMAX - __SIGRTMIN >= 3
4206  static int current_rtmin = __SIGRTMIN + 3;
4207  static int current_rtmax = __SIGRTMAX;
4208  int __pthread_sig_restart = __SIGRTMIN;
4209 @@ -250,7 +242,6 @@
4210  void (*__pthread_restart)(pthread_descr) = __pthread_restart_old;
4211  void (*__pthread_suspend)(pthread_descr) = __pthread_suspend_old;
4212  int (*__pthread_timedsuspend)(pthread_descr, const struct timespec *) = __pthread_timedsuspend_old;
4213 -
4214  #endif
4215  
4216  /* Return number of available real-time signal with highest priority.  */
4217 @@ -275,7 +266,6 @@
4218         return -1;
4219      return high ? current_rtmin++ : current_rtmax--;
4220  }
4221 -#endif
4222  
4223  /* Initialize the pthread library.
4224     Initialization is split in two functions:
4225 @@ -889,7 +879,7 @@
4226         struct timespec reltime;
4227  
4228         /* Compute a time offset relative to now.  */
4229 -       __gettimeofday (&now, NULL);
4230 +       gettimeofday (&now, NULL);
4231         reltime.tv_nsec = abstime->tv_nsec - now.tv_usec * 1000;
4232         reltime.tv_sec = abstime->tv_sec - now.tv_sec;
4233         if (reltime.tv_nsec < 0) {
4234 diff -urN uClibc-0.9.27/libpthread/linuxthreads/restart.h uClibc-0.9.27-uc0/libpthread/linuxthreads/restart.h
4235 --- uClibc-0.9.27/libpthread/linuxthreads/restart.h     2005-01-12 08:59:21.000000000 +0100
4236 +++ uClibc-0.9.27-uc0/libpthread/linuxthreads/restart.h 2003-03-04 12:22:10.000000000 +0100
4237 @@ -15,6 +15,10 @@
4238  #include <signal.h>
4239  #include <sys/syscall.h>
4240  
4241 +#ifdef arm
4242 +#undef __NR_rt_sigaction
4243 +#endif
4244 +
4245  /* Primitives for controlling thread execution */
4246  
4247  static inline void restart(pthread_descr th)
4248 diff -urN uClibc-0.9.27/libpthread/linuxthreads/sysdeps/h8300/pt-machine.h uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/h8300/pt-machine.h
4249 --- uClibc-0.9.27/libpthread/linuxthreads/sysdeps/h8300/pt-machine.h    1970-01-01 01:00:00.000000000 +0100
4250 +++ uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/h8300/pt-machine.h        2004-05-13 03:48:57.000000000 +0200
4251 @@ -0,0 +1,58 @@
4252 +/* Machine-dependent pthreads configuration and inline functions.
4253 +   m68k version.
4254 +   Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc.
4255 +   This file is part of the GNU C Library.
4256 +   Contributed by Richard Henderson <rth@tamu.edu>.
4257 +
4258 +   The GNU C Library is free software; you can redistribute it and/or
4259 +   modify it under the terms of the GNU Lesser General Public License as
4260 +   published by the Free Software Foundation; either version 2.1 of the
4261 +   License, or (at your option) any later version.
4262 +
4263 +   The GNU C Library is distributed in the hope that it will be useful,
4264 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4265 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4266 +   Lesser General Public License for more details.
4267 +
4268 +   You should have received a copy of the GNU Lesser General Public
4269 +   License along with the GNU C Library; see the file COPYING.LIB.  If
4270 +   not, write to the Free Software Foundation, Inc.,
4271 +   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
4272 +
4273 +#ifndef _PT_MACHINE_H
4274 +#define _PT_MACHINE_H   1
4275 +
4276 +#ifndef PT_EI
4277 +# define PT_EI extern inline
4278 +#endif
4279 +
4280 +extern long int testandset (int *spinlock);
4281 +
4282 +/* Spinlock implementation; required.  */
4283 +PT_EI long int
4284 +testandset (int *spinlock)
4285 +{
4286 +  char ret;
4287 +
4288 +  __asm__ __volatile__(
4289 +      "sub.w %0,%0\n\t"
4290 +      "stc ccr,@-sp\n\t"
4291 +      "orc #0x80,ccr\n\t"
4292 +      "bld #0,@%2\n\t"
4293 +      "bset #0,@%2\n\t"
4294 +      "rotxl.w %0\n\t"
4295 +      "ldc @+sp,ccr\n\t"
4296 +      :"=r"(ret),"=m"(*spinlock)
4297 +      :"g"(spinlock)
4298 +      :"cc");
4299 +
4300 +  return ret;
4301 +}
4302 +
4303 +
4304 +/* Get some notion of the current stack.  Need not be exactly the top
4305 +   of the stack, just something somewhere in the current frame.  */
4306 +#define CURRENT_STACK_FRAME  stack_pointer
4307 +register char * stack_pointer __asm__ ("%sp");
4308 +
4309 +#endif /* pt-machine.h */
4310 diff -urN uClibc-0.9.27/libpthread/linuxthreads/sysdeps/h8300/sigcontextinfo.h uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/h8300/sigcontextinfo.h
4311 --- uClibc-0.9.27/libpthread/linuxthreads/sysdeps/h8300/sigcontextinfo.h        1970-01-01 01:00:00.000000000 +0100
4312 +++ uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/h8300/sigcontextinfo.h    2004-05-13 03:48:57.000000000 +0200
4313 @@ -0,0 +1,26 @@
4314 +/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
4315 +   This file is part of the GNU C Library.
4316 +   Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>, 1998.
4317 +
4318 +   The GNU C Library is free software; you can redistribute it and/or
4319 +   modify it under the terms of the GNU Lesser General Public
4320 +   License as published by the Free Software Foundation; either
4321 +   version 2.1 of the License, or (at your option) any later version.
4322 +
4323 +   The GNU C Library is distributed in the hope that it will be useful,
4324 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4325 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4326 +   Lesser General Public License for more details.
4327 +
4328 +   You should have received a copy of the GNU Lesser General Public
4329 +   License along with the GNU C Library; if not, write to the Free
4330 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4331 +   02111-1307 USA.  */
4332 +
4333 +#define SIGCONTEXT int _code, struct sigcontext *
4334 +#define SIGCONTEXT_EXTRA_ARGS _code,
4335 +#define GET_PC(ctx)    ((void *) (ctx)->sc_pc)
4336 +#define GET_FRAME(ctx) ((void *) __builtin_frame_address (1))
4337 +#define GET_STACK(ctx) ((void *) (ctx)->sc_usp)
4338 +#define CALL_SIGHANDLER(handler, signo, ctx) \
4339 +  (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx))
4340 diff -urN uClibc-0.9.27/libpthread/linuxthreads/sysdeps/h8300/stackinfo.h uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/h8300/stackinfo.h
4341 --- uClibc-0.9.27/libpthread/linuxthreads/sysdeps/h8300/stackinfo.h     1970-01-01 01:00:00.000000000 +0100
4342 +++ uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/h8300/stackinfo.h 2004-05-13 03:48:57.000000000 +0200
4343 @@ -0,0 +1,28 @@
4344 +/* Copyright (C) 1999 Free Software Foundation, Inc.
4345 +   This file is part of the GNU C Library.
4346 +
4347 +   The GNU C Library is free software; you can redistribute it and/or
4348 +   modify it under the terms of the GNU Lesser General Public
4349 +   License as published by the Free Software Foundation; either
4350 +   version 2.1 of the License, or (at your option) any later version.
4351 +
4352 +   The GNU C Library is distributed in the hope that it will be useful,
4353 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4354 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4355 +   Lesser General Public License for more details.
4356 +
4357 +   You should have received a copy of the GNU Lesser General Public
4358 +   License along with the GNU C Library; if not, write to the Free
4359 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4360 +   02111-1307 USA.  */
4361 +
4362 +/* This file contains a bit of information about the stack allocation
4363 +   of the processor.  */
4364 +
4365 +#ifndef _STACKINFO_H
4366 +#define _STACKINFO_H   1
4367 +
4368 +/* On m68k the stack grows down.  */
4369 +#define _STACK_GROWS_DOWN      1
4370 +
4371 +#endif /* stackinfo.h */
4372 diff -urN uClibc-0.9.27/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h
4373 --- uClibc-0.9.27/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h       1970-01-01 01:00:00.000000000 +0100
4374 +++ uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h   2005-08-05 03:10:51.000000000 +0200
4375 @@ -0,0 +1,105 @@
4376 +/*
4377 + * sysdeps/microblaze/pt-machine.h -- microblaze-specific pthread definitions
4378 + *
4379 + *  Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au>
4380 + *  Copyright (C) 2002  NEC Electronics Corporation
4381 + *  Copyright (C) 2002  Miles Bader <miles@gnu.org>
4382 + *
4383 + * This file is subject to the terms and conditions of the GNU Lesser
4384 + * General Public License.  See the file COPYING.LIB in the main
4385 + * directory of this archive for more details.
4386 + *
4387 + * Written by Miles Bader <miles@gnu.org>
4388 + */
4389 +
4390 +#ifndef PT_EI
4391 +# define PT_EI extern inline
4392 +#endif
4393 +
4394 +extern long int testandset (int *spinlock);
4395 +extern int __compare_and_swap (long *ptr, long old, long new);
4396 +
4397 +/* Get some notion of the current stack.  Need not be exactly the top
4398 +   of the stack, just something somewhere in the current frame.  */
4399 +#define CURRENT_STACK_FRAME  __stack_pointer
4400 +register char *__stack_pointer __asm__ ("r1");
4401 +
4402 +#define HAS_COMPARE_AND_SWAP
4403 +#define HAS_COMPARE_AND_SWAP_WITH_RELEASE_SEMANTICS
4404 +#define IMPLEMENT_TAS_WITH_CAS
4405 +
4406 +/* Atomically:  If *PTR == OLD, set *PTR to NEW and return true,
4407 +   otherwise do nothing and return false.  */
4408 +PT_EI int __compare_and_swap (long *ptr, long old, long new)
4409 +{
4410 +  unsigned long psw;
4411 +
4412 +  /* disable interrupts  */
4413 +  /* This is ugly ugly ugly! */
4414 +  __asm__ __volatile__ ("mfs   %0, rmsr;"
4415 +                       "andi   r3, %0, ~2;"
4416 +                       "mts    rmsr, r3;"
4417 +                       : "=&r" (psw)
4418 +                       :
4419 +                       : "r3");
4420 +
4421 +  if (likely (*ptr == old))
4422 +    {
4423 +      *ptr = new;
4424 +      __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
4425 +      return 1;
4426 +    }
4427 +  else
4428 +    {
4429 +      __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
4430 +      return 0;
4431 +    }
4432 +}
4433 +
4434 +/* like above's __compare_and_swap() but it first syncs the memory
4435 +   (This is also the difference between both functions in e.g.
4436 +    ../powerpc/pt-machine.h) 
4437 +   Doing this additional sync fixes a hang of __pthread_alt_unlock()
4438 +   (Falk Brettschneider <fbrettschneider@baumeroptronic.de>) */
4439 +PT_EI int
4440 +__compare_and_swap_with_release_semantics (long *p,
4441 +                                          long oldval, long newval)
4442 +{
4443 +  __asm__ __volatile__ ("" : : : "memory"); /*MEMORY_BARRIER ();*/
4444 +  return __compare_and_swap (p, oldval, newval);
4445 +}
4446 +
4447 +
4448 +#ifndef IMPLEMENT_TAS_WITH_CAS
4449 +/* Spinlock implementation; required.  */ 
4450 +PT_EI long int testandset (int *spinlock)
4451 +{
4452 +       char ret;
4453 +       unsigned psw;
4454 +
4455 +       /* disable interrupts */
4456 +       __asm__ __volatile__ ("mfs      %0, rmsr;"
4457 +                             "andi     r3, %0, ~2;"
4458 +                              "mts     rmsr, r3;"
4459 +                       : "=&r" (psw)
4460 +                       :
4461 +                       : "r3");
4462 +
4463 +       if(*spinlock)
4464 +       {
4465 +               /* Enable ints */
4466 +               __asm__ __volatile__ ("mts      rmsr, %0;" :: "r" (psw));
4467 +               ret=1;
4468 +       }
4469 +       else
4470 +       {
4471 +               *spinlock=1;
4472 +               /* Enable ints */
4473 +               __asm__ __volatile__ ("mts      rmsr, %0;" :: "r" (psw));
4474 +               ret=0;
4475 +       }
4476 +
4477 +  return ret;
4478 +}
4479 +
4480 +#endif
4481 diff -urN uClibc-0.9.27/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h
4482 --- uClibc-0.9.27/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h   1970-01-01 01:00:00.000000000 +0100
4483 +++ uClibc-0.9.27-uc0/libpthread/linuxthreads/sysdeps/microblaze/sigcontextinfo.h       2003-12-01 06:55:43.000000000 +0100
4484 @@ -0,0 +1,17 @@
4485 +/*
4486 + * sysdeps/v850/sigcontextinfo.h -- v850-specific pthread signal definitions
4487 + *
4488 + *  Copyright (C) 2002  NEC Electronics Corporation
4489 + *  Copyright (C) 2002  Miles Bader <miles@gnu.org>
4490 + *
4491 + * This file is subject to the terms and conditions of the GNU Lesser
4492 + * General Public License.  See the file COPYING.LIB in the main
4493 + * directory of this archive for more details.
4494 + *
4495 + * Written by Miles Bader <miles@gnu.org>
4496 + */
4497 +
4498 +#include <signal.h>
4499 +
4500 +#define SIGCONTEXT struct sigcontext *
4501 +#define SIGCONTEXT_EXTRA_ARGS
4502 diff -urN uClibc-0.9.27/librt/kernel-posix-timers.h uClibc-0.9.27-uc0/librt/kernel-posix-timers.h
4503 --- uClibc-0.9.27/librt/kernel-posix-timers.h   2005-01-12 08:59:21.000000000 +0100
4504 +++ uClibc-0.9.27-uc0/librt/kernel-posix-timers.h       2005-07-08 00:55:16.000000000 +0200
4505 @@ -5,6 +5,7 @@
4506  #include <setjmp.h>
4507  #include <signal.h>
4508  #include <sys/types.h>
4509 +#include <pthread.h>
4510  
4511  /* Type of timers in the kernel */
4512  typedef int kernel_timer_t;
4513 diff -urN uClibc-0.9.27/Makefile uClibc-0.9.27-uc0/Makefile
4514 --- uClibc-0.9.27/Makefile      2005-01-12 08:59:21.000000000 +0100
4515 +++ uClibc-0.9.27-uc0/Makefile  2005-08-12 04:14:26.000000000 +0200
4516 @@ -40,7 +40,7 @@
4517  # In this section, we need .config
4518  -include .config.cmd
4519  
4520 -shared:
4521 +shared: $(SHARED_TARGET)
4522  ifeq ($(strip $(HAVE_SHARED)),y)
4523         @$(MAKE) -C libc shared
4524         @$(MAKE) -C ldso shared
4525 @@ -66,6 +66,8 @@
4526         @echo Finally finished compiling...
4527         @echo
4528  
4529 +UCLIBC_VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL)
4530 +
4531  include/bits/uClibc_config.h: .config
4532         @if [ ! -x ./extra/config/conf ] ; then \
4533             $(MAKE) -C extra/config conf; \
4534 @@ -359,4 +361,49 @@
4535  
4536  .PHONY: dummy subdirs release distclean clean config oldconfig menuconfig
4537  
4538 +ifneq ($(SHARED_TARGET),)
4539 +lib/main.o: $(ROOTDIR)/lib/libc/main.c
4540 +       $(CC) $(CFLAGS) $(ARCH_CFLAGS) -c -o $@ $(ROOTDIR)/lib/libc/main.c
4541 +
4542 +bogus $(SHARED_TARGET): lib/libc.a lib/main.o Makefile
4543 +       make -C $(ROOTDIR) relink
4544 +       $(CC) -nostartfiles -o $(SHARED_TARGET) $(ARCH_CFLAGS)          \
4545 +                       -mid-shared-library -mshared-library-id=0               \
4546 +                       -Wl,-elf2flt -nostdlib -Wl,-shared-lib-id,${LIBID}      \
4547 +                       lib/main.o                                              \
4548 +                       -Wl,--whole-archive,lib/libc.a,-lgcc,--no-whole-archive
4549 +       $(OBJCOPY) -L _GLOBAL_OFFSET_TABLE_ -L main -L __main -L _start \
4550 +                       -L __uClibc_main -L __uClibc_start_main -L lib_main     \
4551 +                       -L _exit_dummy_ref                                      \
4552 +                       -L __do_global_dtors -L __do_global_ctors               \
4553 +                       -L __CTOR_LIST__ -L __DTOR_LIST__                       \
4554 +                       -L _current_shared_library_a5_offset_                   \
4555 +                       $(SHARED_TARGET).gdb
4556 +       $(LN) -sf $(SHARED_TARGET).gdb .
4557 +endif
4558 +
4559 +#
4560 +# Target for uClinux distro
4561 +#
4562 +.PHONY: romfs
4563 +romfs:
4564 +       [ -e $(ROMFSDIR)/lib ] || mkdir $(ROMFSDIR)/lib
4565 +       if [ "$(SHARED_TARGET)" ]; then \
4566 +               $(ROMFSINST) $(SHARED_TARGET) /lib/lib$(LIBID).so; \
4567 +       fi
4568 +ifeq ($(strip $(HAVE_SHARED)),y)
4569 +       set -e; for i in lib/lib*-$(UCLIBC_VERSION).so lib/*.so.*; do \
4570 +               if [ -L $$i ]; then \
4571 +                       $(ROMFSINST) -s `readlink $$i` /$$i; \
4572 +               else \
4573 +                       $(ROMFSINST) -p 755 $$i /lib; \
4574 +               fi; \
4575 +       done
4576 +       set -e; if [ -x lib/ld-uClibc-$(UCLIBC_VERSION).so ] ; then \
4577 +           $(ROMFSINST) -p 755 lib/ld-uClibc-$(UCLIBC_VERSION).so /lib; \
4578 +               $(ROMFSINST) -s \
4579 +                       /lib/ld-uClibc-$(UCLIBC_VERSION).so \
4580 +                       /lib/ld-linux.so.2; \
4581 +       fi
4582 +endif
4583  
4584 diff -urN uClibc-0.9.27/Rules.mak uClibc-0.9.27-uc0/Rules.mak
4585 --- uClibc-0.9.27/Rules.mak     2005-01-12 08:59:21.000000000 +0100
4586 +++ uClibc-0.9.27-uc0/Rules.mak 2005-07-08 03:28:17.000000000 +0200
4587 @@ -218,7 +218,10 @@
4588  # If -msoft-float isn't supported, we want an error anyway.
4589  # Hmm... might need to revisit this for arm since it has 2 different
4590  # soft float encodings.
4591 +# msoft-float changes m68k target arch, do not add it
4592 +ifneq ($(strip $(TARGET_ARCH)),m68k)
4593      CPU_CFLAGS += -msoft-float
4594 +endif
4595  ifeq ($(strip $(TARGET_ARCH)),arm)
4596  # No longer needed with current toolchains, but leave it here for now.
4597  # If anyone is actually still using gcc 2.95 (say), they can uncomment it.
4598 @@ -251,7 +254,7 @@
4599      LDFLAGS:= $(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc
4600      STRIPTOOL:= true -Since_we_are_debugging
4601  else
4602 -    LDFLAGS := $(CPU_LDFLAGS-y) -s -shared --warn-common --warn-once -z combreloc
4603 +    LDFLAGS := $(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc
4604  endif
4605  
4606  ifeq ($(UCLIBC_BUILD_RELRO),y)
4607 @@ -264,7 +267,7 @@
4608  
4609  # Sigh, some stupid versions of gcc can't seem to cope with '-iwithprefix include'
4610  #CFLAGS+=-iwithprefix include
4611 -CFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
4612 +CFLAGS+=-isystem $(shell $(CC) -print-file-name=include || echo)
4613  
4614  ifneq ($(DOASSERTS),y)
4615      CFLAGS += -DNDEBUG
4616 @@ -292,7 +295,7 @@
4617  endif
4618  
4619  LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
4620 -LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
4621 +LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name || echo)
4622  LIBGCC_DIR:=$(dir $(LIBGCC))
4623  
4624  ########################################
4625 @@ -301,11 +304,13 @@
4626  #
4627  
4628  ifeq ($(CONFIG_BINFMT_SHARED_FLAT),y)
4629 -  # For the shared version of this, we specify no stack and its library ID
4630 -  FLTFLAGS += -s 0
4631 -  LIBID=1
4632 -  export LIBID FLTFLAGS
4633 -  SHARED_TARGET = lib/libc
4634 +  ifndef DISABLE_SHARED_LIBS
4635 +    # For the shared version of this, we specify no stack and its library ID
4636 +    FLTFLAGS += -s 0
4637 +    LIBID=1
4638 +    export LIBID FLTFLAGS
4639 +    SHARED_TARGET = lib/libc
4640 +  endif
4641  endif
4642  
4643  TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
This page took 0.744022 seconds and 3 git commands to generate.