1 diff -Naur newlib-1.16.0.orig/newlib/ChangeLog.rtems newlib-1.16.0/newlib/ChangeLog.rtems
2 --- newlib-1.16.0.orig/newlib/ChangeLog.rtems 1970-01-01 01:00:00.000000000 +0100
3 +++ newlib-1.16.0/newlib/ChangeLog.rtems 2009-03-24 04:29:55.000000000 +0100
5 +2009-03-09 Ralf Corsépius <ralf.corsepius@rtems.org>
7 + * libc/machine/powerpc/times.c: Remove.
8 + * libc/machine/powerpc/Makefile.am: Remove times.c.
9 + * libc/machine/powerpc/Makefile.in: Regenerate.
10 diff -Naur newlib-1.16.0.orig/newlib/configure.host newlib-1.16.0/newlib/configure.host
11 --- newlib-1.16.0.orig/newlib/configure.host 2007-11-07 22:42:24.000000000 +0100
12 +++ newlib-1.16.0/newlib/configure.host 2009-03-24 04:29:55.000000000 +0100
14 # NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
16 default_newlib_io_long_long="yes"
17 + default_newlib_io_c99_formats="yes"
18 newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DHAVE_FCNTL"
20 # VxWorks supplies its own version of malloc, and the newlib one
21 diff -Naur newlib-1.16.0.orig/newlib/libc/include/getopt.h newlib-1.16.0/newlib/libc/include/getopt.h
22 --- newlib-1.16.0.orig/newlib/libc/include/getopt.h 2006-01-04 22:21:52.000000000 +0100
23 +++ newlib-1.16.0/newlib/libc/include/getopt.h 2009-03-24 04:29:55.000000000 +0100
26 /* include files needed by this include file */
28 -/* macros defined by this include file */
30 -#define REQUIRED_ARG 1
31 -#define OPTIONAL_ARG 2
33 -/* types defined by this include file */
37 - char *name; /* the name of the long option */
38 - int has_arg; /* one of the above macros */
39 - int *flag; /* determines if getopt_long() returns a
40 - * value for a long option; if it is
41 - * non-NULL, 0 is returned as a function
42 - * value and the value of val is stored in
43 - * the area pointed to by flag. Otherwise,
44 - * val is returned. */
45 - int val; /* determines the value to return if flag is
48 + /* These #defines are to keep the namespace clear... */
49 +#define getopt_r __getopt_r
50 +#define getopt_long_r __getopt_long_r
51 +#define getopt_long_only_r __getopt_long_only_r
58 +#endif /* __cplusplus */
60 +/* types defined by this include file */
63 + char *name; /* the name of the long option */
64 + int has_arg; /* one of the above macros */
65 + int *flag; /* determines if getopt_long() returns a
66 + * value for a long option; if it is
67 + * non-NULL, 0 is returned as a function
68 + * value and the value of val is stored in
69 + * the area pointed to by flag. Otherwise,
70 + * val is returned. */
71 + int val; /* determines the value to return if flag is
76 + /* The getopt_data structure is for reentrancy. Its members are similar to
77 + the externally-defined variables. */
78 + typedef struct getopt_data
81 + int optind, opterr, optopt, optwhere;
84 /* externally-defined variables */
89 /* function prototypes */
90 - int _EXFUN (getopt, (int __argc, char *const __argv[], const char *__optstring));
91 - int _EXFUN (getopt_long, (int __argc, char *const __argv[], const char *__shortopts, const struct option *__longopts, int *__longind));
92 - int _EXFUN (getopt_long_only, (int __argc, char *const __argv[], const char *__shortopts, const struct option *__longopts, int *__longind));
94 + (int __argc, char *const __argv[], const char *__optstring));
96 + int _EXFUN (getopt_long,
97 + (int __argc, char *const __argv[], const char *__shortopts,
98 + const struct option * __longopts, int *__longind));
100 + int _EXFUN (getopt_long_only,
101 + (int __argc, char *const __argv[], const char *__shortopts,
102 + const struct option * __longopts, int *__longind));
104 + int _EXFUN (__getopt_r,
105 + (int __argc, char *const __argv[], const char *__optstring,
106 + struct getopt_data * __data));
108 + int _EXFUN (__getopt_long_r,
109 + (int __argc, char *const __argv[], const char *__shortopts,
110 + const struct option * __longopts, int *__longind,
111 + struct getopt_data * __data));
113 + int _EXFUN (__getopt_long_only_r,
114 + (int __argc, char *const __argv[], const char *__shortopts,
115 + const struct option * __longopts, int *__longind,
116 + struct getopt_data * __data));
122 +#endif /* __cplusplus */
124 #endif /* GETOPT_H */
126 diff -Naur newlib-1.16.0.orig/newlib/libc/include/inttypes.h newlib-1.16.0/newlib/libc/include/inttypes.h
127 --- newlib-1.16.0.orig/newlib/libc/include/inttypes.h 2005-12-16 20:03:12.000000000 +0100
128 +++ newlib-1.16.0/newlib/libc/include/inttypes.h 2009-03-24 04:29:55.000000000 +0100
130 #define SCNxMAX __SCNMAX(x)
133 -#if __have_longlong64
134 -#define __PRIPTR(x) __STRINGIFY(ll##x)
135 -#define __SCNPTR(x) __STRINGIFY(ll##x)
136 +#if __ptrint_t_long_defined
137 +#define __PRIPTR(x) __STRINGIFY(l##x)
138 +#define __SCNPTR(x) __STRINGIFY(l##x)
139 +#elif __ptrint_t_int_defined
140 +#define __PRIPTR(x) __STRINGIFY(x)
141 +#define __SCNPTR(x) __STRINGIFY(x)
143 #define __PRIPTR(x) __STRINGIFY(l##x)
144 #define __SCNPTR(x) __STRINGIFY(l##x)
145 diff -Naur newlib-1.16.0.orig/newlib/libc/include/machine/ieeefp.h newlib-1.16.0/newlib/libc/include/machine/ieeefp.h
146 --- newlib-1.16.0.orig/newlib/libc/include/machine/ieeefp.h 2007-11-07 22:42:24.000000000 +0100
147 +++ newlib-1.16.0/newlib/libc/include/machine/ieeefp.h 2009-03-24 04:29:55.000000000 +0100
149 # define __IEEE_BIG_ENDIAN
152 -# define __IEEE_BIG_ENDIAN
154 +# define __IEEE_LITTLE_ENDIAN
156 +# define __IEEE_BIG_ENDIAN
159 # define __IEEE_BYTES_LITTLE_ENDIAN
162 diff -Naur newlib-1.16.0.orig/newlib/libc/include/machine/setjmp.h newlib-1.16.0/newlib/libc/include/machine/setjmp.h
163 --- newlib-1.16.0.orig/newlib/libc/include/machine/setjmp.h 2007-11-07 22:42:24.000000000 +0100
164 +++ newlib-1.16.0/newlib/libc/include/machine/setjmp.h 2009-03-24 04:29:55.000000000 +0100
167 /* necv70 was 9 as well. */
170 +#if defined(__m68k__) || defined(__mc68000__)
172 * onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
175 # define _CYGWIN_WORKING_SIGSETJMP
178 +#ifdef _POSIX_THREADS
179 +#define __SIGMASK_FUNC pthread_sigmask
181 +#define __SIGMASK_FUNC sigprocmask
184 #if defined(__GNUC__)
186 #define sigsetjmp(env, savemask) \
189 sigjmp_buf *_sjbuf = &(env); \
190 ((*_sjbuf)[_SAVEMASK] = savemask,\
191 - sigprocmask (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
192 + __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
198 sigjmp_buf *_sjbuf = &(env); \
199 ((((*_sjbuf)[_SAVEMASK]) ? \
200 - sigprocmask (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
201 + __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
203 longjmp (*_sjbuf, val)); \
205 @@ -292,15 +298,21 @@
206 #else /* !__GNUC__ */
208 #define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\
209 - sigprocmask (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
210 + __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
213 #define siglongjmp(env, val) ((((env)[_SAVEMASK])?\
214 - sigprocmask (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
215 + __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
220 +/* POSIX _setjmp/_longjmp macros, maintained for XSI compatibility. These
221 + are equivalent to sigsetjmp/siglongjmp when not saving the signal mask.
222 + New applications should use sigsetjmp/siglongjmp instead. */
223 +#define _setjmp(env) sigsetjmp ((env), 0)
224 +#define _longjmp(env, val) siglongjmp ((env), (val))
229 diff -Naur newlib-1.16.0.orig/newlib/libc/include/pthread.h newlib-1.16.0/newlib/libc/include/pthread.h
230 --- newlib-1.16.0.orig/newlib/libc/include/pthread.h 2006-09-14 00:09:27.000000000 +0200
231 +++ newlib-1.16.0/newlib/libc/include/pthread.h 2009-03-24 04:29:55.000000000 +0100
233 int _EXFUN(pthread_getcpuclockid,
234 (pthread_t __pthread_id, clockid_t *__clock_id));
236 -/* CPU-time Clock Thread Creation Attribute, P1003.4b/D8, p. 59 */
238 -int _EXFUN(pthread_attr_setcputime,
239 - (pthread_attr_t *__attr, int __clock_allowed));
241 -int _EXFUN(pthread_attr_getcputime,
242 - (pthread_attr_t *__attr, int *__clock_allowed));
244 #endif /* defined(_POSIX_THREAD_CPUTIME) */
247 diff -Naur newlib-1.16.0.orig/newlib/libc/include/sched.h newlib-1.16.0/newlib/libc/include/sched.h
248 --- newlib-1.16.0.orig/newlib/libc/include/sched.h 2007-09-21 23:02:15.000000000 +0200
249 +++ newlib-1.16.0/newlib/libc/include/sched.h 1970-01-01 01:00:00.000000000 +0100
258 -#include <sys/sched.h>
264 -#endif /* _SCHED_H_ */
265 diff -Naur newlib-1.16.0.orig/newlib/libc/include/stdint.h newlib-1.16.0/newlib/libc/include/stdint.h
266 --- newlib-1.16.0.orig/newlib/libc/include/stdint.h 2006-08-16 23:39:43.000000000 +0200
267 +++ newlib-1.16.0/newlib/libc/include/stdint.h 2009-03-24 04:29:55.000000000 +0100
271 /* This must match size_t in stddef.h, currently long unsigned int */
272 -#define SIZE_MIN (-__STDINT_EXP(LONG_MAX) - 1L)
273 -#define SIZE_MAX __STDINT_EXP(LONG_MAX)
274 +#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
276 /* This must match sig_atomic_t in <signal.h> (currently int) */
277 #define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
279 #define UINTMAX_C(x) x##UL
283 +#include <machine/stdint.h>
288 diff -Naur newlib-1.16.0.orig/newlib/libc/include/sys/features.h newlib-1.16.0/newlib/libc/include/sys/features.h
289 --- newlib-1.16.0.orig/newlib/libc/include/sys/features.h 2007-12-19 19:51:19.000000000 +0100
290 +++ newlib-1.16.0/newlib/libc/include/sys/features.h 2009-03-24 04:29:55.000000000 +0100
292 #define _POSIX_MEMLOCK_RANGE 1
293 #define _POSIX_MEMORY_PROTECTION 1
294 #define _POSIX_MESSAGE_PASSING 1
295 +#define _POSIX_MONOTONIC_CLOCK 200112L
296 #define _POSIX_PRIORITIZED_IO 1
297 #define _POSIX_PRIORITY_SCHEDULING 1
298 #define _POSIX_REALTIME_SIGNALS 1
299 #define _POSIX_SEMAPHORES 1
300 -#define _POSIX_SHARED_MEMORY_OBJECTS 1
301 +/* #define _POSIX_SHARED_MEMORY_OBJECTS 1 */
302 #define _POSIX_SYNCHRONIZED_IO 1
303 #define _POSIX_TIMERS 1
304 #define _POSIX_BARRIERS 200112L
305 diff -Naur newlib-1.16.0.orig/newlib/libc/include/sys/_types.h newlib-1.16.0/newlib/libc/include/sys/_types.h
306 --- newlib-1.16.0.orig/newlib/libc/include/sys/_types.h 2007-09-18 22:05:17.000000000 +0200
307 +++ newlib-1.16.0/newlib/libc/include/sys/_types.h 2009-03-24 04:29:55.000000000 +0100
309 typedef void *_iconv_t;
312 +typedef long * __intptr_t;
313 +typedef unsigned long* __uintptr_t;
315 #endif /* _SYS__TYPES_H */
316 diff -Naur newlib-1.16.0.orig/newlib/libc/include/sys/unistd.h newlib-1.16.0/newlib/libc/include/sys/unistd.h
317 --- newlib-1.16.0.orig/newlib/libc/include/sys/unistd.h 2007-11-08 17:20:12.000000000 +0100
318 +++ newlib-1.16.0/newlib/libc/include/sys/unistd.h 2009-03-24 04:29:55.000000000 +0100
320 pid_t _EXFUN(tcgetpgrp, (int __fildes ));
321 int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
322 char _EXFUN(*ttyname, (int __fildes ));
323 -#if defined(__CYGWIN__)
324 +#if defined(__CYGWIN__) || defined(__rtems__)
325 int _EXFUN(ttyname_r, (int, char *, size_t));
327 int _EXFUN(unlink, (const char *__path ));
328 @@ -219,13 +219,11 @@
329 char * _EXFUN(mktemp, (char *));
332 -#if defined(__CYGWIN__) || defined(__SPU__)
333 +#if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__)
334 void _EXFUN(sync, (void));
335 -#elif defined(__rtems__)
336 -int _EXFUN(sync, (void));
339 -int _EXFUN(readlink, (const char *__path, char *__buf, int __buflen));
340 +ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen));
341 int _EXFUN(symlink, (const char *__name1, const char *__name2));
344 diff -Naur newlib-1.16.0.orig/newlib/libc/include/_syslist.h newlib-1.16.0/newlib/libc/include/_syslist.h
345 --- newlib-1.16.0.orig/newlib/libc/include/_syslist.h 2005-08-22 23:13:35.000000000 +0200
346 +++ newlib-1.16.0/newlib/libc/include/_syslist.h 2009-03-24 04:29:55.000000000 +0100
349 #define _getpid getpid
350 #define _gettimeofday gettimeofday
351 +#define _isatty isatty
355 diff -Naur newlib-1.16.0.orig/newlib/libc/include/time.h newlib-1.16.0/newlib/libc/include/time.h
356 --- newlib-1.16.0.orig/newlib/libc/include/time.h 2005-11-18 16:57:24.000000000 +0100
357 +++ newlib-1.16.0/newlib/libc/include/time.h 2009-03-24 04:29:55.000000000 +0100
362 +#if defined(_POSIX_MONOTONIC_CLOCK)
364 +/* The identifier for the system-wide monotonic clock, which is defined
365 + as a clock whose value cannot be set via clock_settime() and which
366 + cannot have backward clock jumps. */
368 +#define CLOCK_MONOTONIC (clockid_t)4
372 #if defined(_POSIX_CPUTIME)
374 /* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
375 diff -Naur newlib-1.16.0.orig/newlib/libc/machine/arm/machine/endian.h newlib-1.16.0/newlib/libc/machine/arm/machine/endian.h
376 --- newlib-1.16.0.orig/newlib/libc/machine/arm/machine/endian.h 2004-05-07 22:29:24.000000000 +0200
377 +++ newlib-1.16.0/newlib/libc/machine/arm/machine/endian.h 1970-01-01 01:00:00.000000000 +0100
379 -/* ARM configuration file */
381 -#ifndef _MACHINE_ENDIAN_H
382 -# define _MACHINE_ENDIAN_H
385 -#define BYTE_ORDER BIG_ENDIAN
387 -#define BYTE_ORDER LITTLE_ENDIAN
391 diff -Naur newlib-1.16.0.orig/newlib/libc/machine/powerpc/Makefile.am newlib-1.16.0/newlib/libc/machine/powerpc/Makefile.am
392 --- newlib-1.16.0.orig/newlib/libc/machine/powerpc/Makefile.am 2007-05-24 19:33:35.000000000 +0200
393 +++ newlib-1.16.0/newlib/libc/machine/powerpc/Makefile.am 2009-03-24 04:29:55.000000000 +0100
396 AM_CFLAGS = -I $(srcdir)/../../stdio -I $(srcdir)/../../stdlib
398 -lib_a_SOURCES = setjmp.S times.c
399 +lib_a_SOURCES = setjmp.S
400 lib_a_CCASFLAGS=$(AM_CCASFLAGS)
401 lib_a_CFLAGS=$(AM_CFLAGS)
402 lib_a_LIBADD = @extra_objs@
403 diff -Naur newlib-1.16.0.orig/newlib/libc/machine/powerpc/Makefile.in newlib-1.16.0/newlib/libc/machine/powerpc/Makefile.in
404 --- newlib-1.16.0.orig/newlib/libc/machine/powerpc/Makefile.in 2007-12-19 23:36:34.000000000 +0100
405 +++ newlib-1.16.0/newlib/libc/machine/powerpc/Makefile.in 2009-03-24 04:29:55.000000000 +0100
407 DIST_COMMON = $(srcdir)/../../../../config.guess \
408 $(srcdir)/../../../../config.sub $(srcdir)/Makefile.in \
409 $(srcdir)/Makefile.am $(top_srcdir)/configure \
410 - $(am__configure_deps) $(srcdir)/../../../../mkinstalldirs \
411 - $(srcdir)/../../../../compile
412 + $(am__configure_deps) $(srcdir)/../../../../mkinstalldirs
414 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
415 am__aclocal_m4_deps = $(top_srcdir)/../../../acinclude.m4 \
417 LIBRARIES = $(noinst_LIBRARIES)
419 lib_a_AR = $(AR) $(ARFLAGS)
420 -am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-times.$(OBJEXT)
421 +am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT)
422 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
423 DEFAULT_INCLUDES = -I. -I$(srcdir)
426 AM_CCASFLAGS = $(INCLUDES)
427 noinst_LIBRARIES = lib.a
428 AM_CFLAGS = -I $(srcdir)/../../stdio -I $(srcdir)/../../stdlib
429 -lib_a_SOURCES = setjmp.S times.c
430 +lib_a_SOURCES = setjmp.S
431 lib_a_CCASFLAGS = $(AM_CCASFLAGS)
432 lib_a_CFLAGS = $(AM_CFLAGS)
433 lib_a_LIBADD = @extra_objs@
438 -.SUFFIXES: .S .c .o .obj
439 +.SUFFIXES: .S .o .obj
442 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
445 lib_a-setjmp.obj: setjmp.S
446 $(CCAS) $(lib_a_CCASFLAGS) $(CCASFLAGS) -c -o lib_a-setjmp.obj `if test -f 'setjmp.S'; then $(CYGPATH_W) 'setjmp.S'; else $(CYGPATH_W) '$(srcdir)/setjmp.S'; fi`
452 - $(COMPILE) -c `$(CYGPATH_W) '$<'`
454 -lib_a-times.o: times.c
455 - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-times.o `test -f 'times.c' || echo '$(srcdir)/'`times.c
457 -lib_a-times.obj: times.c
458 - $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-times.obj `if test -f 'times.c'; then $(CYGPATH_W) 'times.c'; else $(CYGPATH_W) '$(srcdir)/times.c'; fi`
461 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
462 diff -Naur newlib-1.16.0.orig/newlib/libc/machine/powerpc/times.c newlib-1.16.0/newlib/libc/machine/powerpc/times.c
463 --- newlib-1.16.0.orig/newlib/libc/machine/powerpc/times.c 2002-07-22 22:26:51.000000000 +0200
464 +++ newlib-1.16.0/newlib/libc/machine/powerpc/times.c 1970-01-01 01:00:00.000000000 +0100
466 -/* Time support routines for PowerPC.
468 - * Written by Aldy Hernandez.
473 -#include <sys/time.h>
474 -#include <sys/times.h>
475 -#include <sys/resource.h>
478 -times (struct tms *tp)
480 - struct rusage usage;
483 - /* Newlib's rusage has only 2 fields. We need to make room for
484 - when we call the system's rusage. This should be enough. */
488 - getrusage (RUSAGE_SELF, (void *)&host_ru);
492 - tp->tms_utime = host_ru.r.ru_utime.tv_sec * 1000
493 - + host_ru.r.ru_utime.tv_usec;
494 - tp->tms_stime = host_ru.r.ru_stime.tv_sec * 1000
495 - + host_ru.r.ru_stime.tv_usec;
496 - tp->tms_cutime = 0; /* user time, children */
497 - tp->tms_cstime = 0; /* system time, children */
500 - return tp->tms_utime;
502 diff -Naur newlib-1.16.0.orig/newlib/libc/stdlib/getopt.c newlib-1.16.0/newlib/libc/stdlib/getopt.c
503 --- newlib-1.16.0.orig/newlib/libc/stdlib/getopt.c 2007-05-29 23:26:59.000000000 +0200
504 +++ newlib-1.16.0/newlib/libc/stdlib/getopt.c 2009-03-24 04:29:55.000000000 +0100
510 +#define REQUIRED_ARG 1
511 +#define OPTIONAL_ARG 2
514 typedef enum GETOPT_ORDERING_T
515 @@ -100,16 +103,19 @@
518 /* globally-defined variables */
519 -char *optarg = NULL;
525 +/* static variables */
526 +static int optwhere = 0;
530 /* reverse_argv_elements: reverses num elements starting at argv */
532 -reverse_argv_elements (char ** argv, int num)
533 +reverse_argv_elements (char **argv, int num)
537 @@ -126,281 +132,346 @@
539 permute (char *const argv[], int len1, int len2)
541 - reverse_argv_elements ((char **)argv, len1);
542 - reverse_argv_elements ((char **)argv, len1 + len2);
543 - reverse_argv_elements ((char **)argv, len2);
544 + reverse_argv_elements ((char **) argv, len1);
545 + reverse_argv_elements ((char **) argv, len1 + len2);
546 + reverse_argv_elements ((char **) argv, len2);
549 /* is_option: is this argv-element an option or the end of the option list? */
551 is_option (char *argv_element, int only)
553 - return ((argv_element == NULL)
554 - || (argv_element[0] == '-') || (only && argv_element[0] == '+'));
555 + return ((argv_element == 0)
556 + || (argv_element[0] == '-') || (only && argv_element[0] == '+'));
559 +/* read_globals: read the values from the globals into a getopt_data
562 +read_globals (struct getopt_data *data)
564 + data->optarg = optarg;
565 + data->optind = optind;
566 + data->opterr = opterr;
567 + data->optopt = optopt;
568 + data->optwhere = optwhere;
571 +/* write_globals: write the values into the globals from a getopt_data
574 +write_globals (struct getopt_data *data)
576 + optarg = data->optarg;
577 + optind = data->optind;
578 + opterr = data->opterr;
579 + optopt = data->optopt;
580 + optwhere = data->optwhere;
583 /* getopt_internal: the function that does all the dirty work */
585 getopt_internal (int argc, char *const argv[], const char *shortopts,
586 - const struct option *longopts, int *longind, int only)
587 + const struct option *longopts, int *longind, int only,
588 + struct getopt_data *data)
590 GETOPT_ORDERING_T ordering = PERMUTE;
591 - static size_t optwhere = 0;
592 size_t permute_from = 0;
595 size_t match_chars = 0;
596 - char *possible_arg = NULL;
597 + char *possible_arg = 0;
598 int longopt_match = -1;
604 /* first, deal with silly parameters and easy stuff */
605 - if (argc == 0 || argv == NULL || (shortopts == NULL && longopts == NULL))
607 - if (optind >= argc || argv[optind] == NULL)
608 + if (argc == 0 || argv == 0 || (shortopts == 0 && longopts == 0)
609 + || data->optind >= argc || argv[data->optind] == 0)
611 - if (strcmp (argv[optind], "--") == 0)
612 + if (strcmp (argv[data->optind], "--") == 0)
619 /* if this is our first time through */
621 - optind = optwhere = 1;
622 + if (data->optind == 0)
623 + data->optind = data->optwhere = 1;
625 /* define ordering */
626 - if (shortopts != NULL && (*shortopts == '-' || *shortopts == '+'))
627 + if (shortopts != 0 && (*shortopts == '-' || *shortopts == '+'))
629 ordering = (*shortopts == '-') ? RETURN_IN_ORDER : REQUIRE_ORDER;
633 - ordering = (getenv ("POSIXLY_CORRECT") != NULL) ? REQUIRE_ORDER : PERMUTE;
634 + ordering = (getenv ("POSIXLY_CORRECT") != 0) ? REQUIRE_ORDER : PERMUTE;
637 * based on ordering, find our next option, if we're at the beginning of
641 + if (data->optwhere == 1)
646 - permute_from = optind;
648 - while (!is_option (argv[optind], only))
653 - if (argv[optind] == NULL)
655 - /* no more options */
656 - optind = permute_from;
659 - else if (strcmp (argv[optind], "--") == 0)
661 - /* no more options, but have to get `--' out of the way */
662 - permute (argv + permute_from, num_nonopts, 1);
663 - optind = permute_from + 1;
667 - case RETURN_IN_ORDER:
668 - if (!is_option (argv[optind], only))
670 - optarg = argv[optind++];
671 - return (optopt = 1);
674 - case REQUIRE_ORDER:
675 - if (!is_option (argv[optind], only))
680 + default: /* shouldn't happen */
682 + permute_from = data->optind;
684 + while (!is_option (argv[data->optind], only))
689 + if (argv[data->optind] == 0)
691 + /* no more options */
692 + data->optind = permute_from;
695 + else if (strcmp (argv[data->optind], "--") == 0)
697 + /* no more options, but have to get `--' out of the way */
698 + permute (argv + permute_from, num_nonopts, 1);
699 + data->optind = permute_from + 1;
703 + case RETURN_IN_ORDER:
704 + if (!is_option (argv[data->optind], only))
706 + data->optarg = argv[data->optind++];
707 + return (data->optopt = 1);
710 + case REQUIRE_ORDER:
711 + if (!is_option (argv[data->optind], only))
716 /* we've got an option, so parse it */
718 /* first, is it a long option? */
719 - if (longopts != NULL
720 - && (memcmp (argv[optind], "--", 2) == 0
721 - || (only && argv[optind][0] == '+')) && optwhere == 1)
723 + && (memcmp (argv[data->optind], "--", 2) == 0
724 + || (only && argv[data->optind][0] == '+')) && data->optwhere == 1)
726 /* handle long options */
727 - if (memcmp (argv[optind], "--", 2) == 0)
729 + if (memcmp (argv[data->optind], "--", 2) == 0)
730 + data->optwhere = 2;
732 - possible_arg = strchr (argv[optind] + optwhere, '=');
733 - if (possible_arg == NULL)
735 - /* no =, so next argv might be arg */
736 - match_chars = strlen (argv[optind]);
737 - possible_arg = argv[optind] + match_chars;
738 - match_chars = match_chars - optwhere;
740 + possible_arg = strchr (argv[data->optind] + data->optwhere, '=');
741 + if (possible_arg == 0)
743 + /* no =, so next argv might be arg */
744 + match_chars = strlen (argv[data->optind]);
745 + possible_arg = argv[data->optind] + match_chars;
746 + match_chars = match_chars - data->optwhere;
749 - match_chars = (possible_arg - argv[optind]) - optwhere;
750 - for (optindex = 0; longopts[optindex].name != NULL; optindex++)
752 - if (memcmp (argv[optind] + optwhere,
753 - longopts[optindex].name, match_chars) == 0)
755 - /* do we have an exact match? */
756 - if (match_chars == (int) (strlen (longopts[optindex].name)))
758 - longopt_match = optindex;
761 - /* do any characters match? */
764 - if (longopt_match < 0)
765 - longopt_match = optindex;
768 - /* we have ambiguous options */
770 - fprintf (stderr, "%s: option `%s' is ambiguous "
771 - "(could be `--%s' or `--%s')\n",
774 - longopts[longopt_match].name,
775 - longopts[optindex].name);
776 - return (optopt = '?');
781 + match_chars = (possible_arg - argv[data->optind]) - data->optwhere;
782 + for (optindex = 0; longopts[optindex].name != 0; ++optindex)
785 + (argv[data->optind] + data->optwhere, longopts[optindex].name,
788 + /* do we have an exact match? */
789 + if (match_chars == (int) (strlen (longopts[optindex].name)))
791 + longopt_match = optindex;
794 + /* do any characters match? */
797 + if (longopt_match < 0)
798 + longopt_match = optindex;
801 + /* we have ambiguous options */
803 + fprintf (stderr, "%s: option `%s' is ambiguous "
804 + "(could be `--%s' or `--%s')\n",
806 + argv[data->optind],
807 + longopts[longopt_match].name,
808 + longopts[optindex].name);
809 + return (data->optopt = '?');
814 if (longopt_match >= 0)
815 - has_arg = longopts[longopt_match].has_arg;
816 + has_arg = longopts[longopt_match].has_arg;
819 /* if we didn't find a long option, is it a short option? */
820 - if (longopt_match < 0 && shortopts != NULL)
821 + if (longopt_match < 0 && shortopts != 0)
823 - cp = strchr (shortopts, argv[optind][optwhere]);
826 - /* couldn't find option in shortopts */
829 - "%s: invalid option -- `-%c'\n",
830 - argv[0], argv[optind][optwhere]);
832 - if (argv[optind][optwhere] == '\0')
837 - return (optopt = '?');
839 + cp = strchr (shortopts, argv[data->optind][data->optwhere]);
842 + /* couldn't find option in shortopts */
845 + "%s: invalid option -- `-%c'\n",
846 + argv[0], argv[data->optind][data->optwhere]);
848 + if (argv[data->optind][data->optwhere] == '\0')
851 + data->optwhere = 1;
853 + return (data->optopt = '?');
855 has_arg = ((cp[1] == ':')
856 - ? ((cp[2] == ':') ? OPTIONAL_ARG : REQUIRED_ARG) : NO_ARG);
857 - possible_arg = argv[optind] + optwhere + 1;
859 + ? ((cp[2] == ':') ? OPTIONAL_ARG : REQUIRED_ARG) : NO_ARG);
860 + possible_arg = argv[data->optind] + data->optwhere + 1;
861 + data->optopt = *cp;
863 - /* get argument and reset optwhere */
865 + /* get argument and reset data->optwhere */
870 if (*possible_arg == '=')
872 - if (*possible_arg != '\0')
874 - optarg = possible_arg;
880 + data->optarg = (*possible_arg != '\0') ? possible_arg : 0;
881 + data->optwhere = 1;
884 if (*possible_arg == '=')
887 if (*possible_arg != '\0')
889 - optarg = possible_arg;
892 - else if (optind + 1 >= argc)
896 - fprintf (stderr, "%s: argument required for option `", argv[0]);
897 - if (longopt_match >= 0)
898 - fprintf (stderr, "--%s'\n", longopts[longopt_match].name);
900 - fprintf (stderr, "-%c'\n", *cp);
903 - return (optopt = ':');
906 + data->optarg = possible_arg;
907 + data->optwhere = 1;
909 + else if (data->optind + 1 >= argc)
913 + fprintf (stderr, "%s: argument required for option `", argv[0]);
914 + if (longopt_match >= 0)
915 + fprintf (stderr, "--%s'\n", longopts[longopt_match].name);
917 + fprintf (stderr, "-%c'\n", *cp);
920 + return (data->optopt = ':');
924 - optarg = argv[optind + 1];
929 + data->optarg = argv[data->optind + 1];
931 + data->optwhere = 1;
934 + default: /* shouldn't happen */
936 if (longopt_match < 0)
939 - if (argv[optind][optwhere] == '\0')
944 + if (argv[data->optind][data->optwhere] == '\0')
945 + data->optwhere = 1;
950 + data->optwhere = 1;
955 - /* do we have to permute or otherwise modify optind? */
956 - if (ordering == PERMUTE && optwhere == 1 && num_nonopts != 0)
957 + /* do we have to permute or otherwise modify data->optind? */
958 + if (ordering == PERMUTE && data->optwhere == 1 && num_nonopts != 0)
960 permute (argv + permute_from, num_nonopts, 1 + arg_next);
961 - optind = permute_from + 1 + arg_next;
962 + data->optind = permute_from + 1 + arg_next;
964 - else if (optwhere == 1)
965 - optind = optind + 1 + arg_next;
966 + else if (data->optwhere == 1)
967 + data->optind = data->optind + 1 + arg_next;
970 if (longopt_match >= 0)
972 - if (longind != NULL)
973 - *longind = longopt_match;
974 - if (longopts[longopt_match].flag != NULL)
976 - *(longopts[longopt_match].flag) = longopts[longopt_match].val;
980 + *longind = longopt_match;
981 + if (longopts[longopt_match].flag != 0)
983 + *(longopts[longopt_match].flag) = longopts[longopt_match].val;
987 - return longopts[longopt_match].val;
988 + return longopts[longopt_match].val;
992 + return data->optopt;
996 getopt (int argc, char *const argv[], const char *optstring)
998 - return getopt_internal (argc, argv, optstring, NULL, NULL, 0);
999 + struct getopt_data data;
1002 + read_globals (&data);
1003 + r = getopt_internal (argc, argv, optstring, 0, 0, 0, &data);
1004 + write_globals (&data);
1009 getopt_long (int argc, char *const argv[], const char *shortopts,
1010 - const struct option *longopts, int *longind)
1011 + const struct option *longopts, int *longind)
1013 - return getopt_internal (argc, argv, shortopts, longopts, longind, 0);
1014 + struct getopt_data data;
1017 + read_globals (&data);
1018 + r = getopt_internal (argc, argv, shortopts, longopts, longind, 0, &data);
1019 + write_globals (&data);
1024 getopt_long_only (int argc, char *const argv[], const char *shortopts,
1025 - const struct option *longopts, int *longind)
1026 + const struct option *longopts, int *longind)
1028 + struct getopt_data data;
1031 + read_globals (&data);
1032 + r = getopt_internal (argc, argv, shortopts, longopts, longind, 1, &data);
1033 + write_globals (&data);
1038 +__getopt_r (int argc, char *const argv[], const char *optstring,
1039 + struct getopt_data *data)
1041 + return getopt_internal (argc, argv, optstring, 0, 0, 0, data);
1045 +__getopt_long_r (int argc, char *const argv[], const char *shortopts,
1046 + const struct option *longopts, int *longind,
1047 + struct getopt_data *data)
1049 + return getopt_internal (argc, argv, shortopts, longopts, longind, 0, data);
1053 +__getopt_long_only_r (int argc, char *const argv[], const char *shortopts,
1054 + const struct option *longopts, int *longind,
1055 + struct getopt_data *data)
1057 - return getopt_internal (argc, argv, shortopts, longopts, longind, 1);
1058 + return getopt_internal (argc, argv, shortopts, longopts, longind, 1, data);
1061 /* end of file GETOPT.C */
1062 diff -Naur newlib-1.16.0.orig/newlib/libc/sys/rtems/machine/stdint.h newlib-1.16.0/newlib/libc/sys/rtems/machine/stdint.h
1063 --- newlib-1.16.0.orig/newlib/libc/sys/rtems/machine/stdint.h 1970-01-01 01:00:00.000000000 +0100
1064 +++ newlib-1.16.0/newlib/libc/sys/rtems/machine/stdint.h 2009-03-24 04:29:55.000000000 +0100
1069 +#ifndef _MACHINE_STDINT_H
1070 +#define _MACHINE_STDINT_H
1073 +#error machine/stdint.h is an internal file and must not be directly included
1077 +#error machine/stdint.h is an RTEMS specific internal file and must not be used otherwise
1080 +#if defined(__sparc__) \
1081 + || defined(__powerpc__) || defined(__PPC__) \
1082 + || defined(__mips__) \
1083 + || defined(__sh__) \
1084 + || defined(__AVR__) \
1085 + || defined(_C4x) || defined(_C3x) \
1086 + || defined(__H8300__)
1087 +/* PTRDIFF_TYPE = int */
1088 +#define __ptrint_t_int_defined 1
1091 +#if defined(__i386__) \
1092 + || defined(__m68k__) \
1093 + || defined(__bfin__) \
1094 + || defined(__arm__) \
1095 + || defined(__H8300S__) || defined(__H8300H__)
1096 +/* PTRDIFF_TYPE = long */
1097 +#define __ptrint_t_long_defined 1
1101 diff -Naur newlib-1.16.0.orig/newlib/libc/sys/rtems/sys/param.h newlib-1.16.0/newlib/libc/sys/rtems/sys/param.h
1102 --- newlib-1.16.0.orig/newlib/libc/sys/rtems/sys/param.h 2004-05-07 22:29:24.000000000 +0200
1103 +++ newlib-1.16.0/newlib/libc/sys/rtems/sys/param.h 2009-03-24 04:29:55.000000000 +0100
1105 #include <sys/resource.h>
1106 #include <sys/ucred.h>
1107 #include <sys/uio.h>
1108 -#include <sys/rtprio.h>
1112 diff -Naur newlib-1.16.0.orig/newlib/Makefile.am newlib-1.16.0/newlib/Makefile.am
1113 --- newlib-1.16.0.orig/newlib/Makefile.am 2007-05-24 19:33:29.000000000 +0200
1114 +++ newlib-1.16.0/newlib/Makefile.am 2009-03-24 04:29:55.000000000 +0100
1119 -noinst_DATA = stmp-targ-include
1120 +BUILT_SOURCES = stmp-targ-include
1122 toollib_DATA = $(CRT0) $(CRT1)
1126 $(CRT1_DIR)$(CRT1): ; @true
1129 -all-recursive: stmp-targ-include
1131 # The targ-include directory just holds the includes files for the
1132 # particular system and machine we have been configured for. It is
1133 # used while building.
1134 diff -Naur newlib-1.16.0.orig/newlib/Makefile.in newlib-1.16.0/newlib/Makefile.in
1135 --- newlib-1.16.0.orig/newlib/Makefile.in 2007-12-19 23:36:26.000000000 +0100
1136 +++ newlib-1.16.0/newlib/Makefile.in 2009-03-24 04:29:55.000000000 +0100
1138 pdf-recursive ps-recursive uninstall-info-recursive \
1140 toollibDATA_INSTALL = $(INSTALL_DATA)
1141 -DATA = $(noinst_DATA) $(toollib_DATA)
1142 +DATA = $(toollib_DATA)
1145 DEJATOOL = $(PACKAGE)
1147 @USE_LIBTOOL_FALSE@toollib_LIBRARIES = libm.a \
1148 @USE_LIBTOOL_FALSE@ libc.a
1150 -noinst_DATA = stmp-targ-include
1151 +BUILT_SOURCES = stmp-targ-include
1152 toollib_DATA = $(CRT0) $(CRT1)
1154 # The functions ldexp, frexp and modf are traditionally supplied in
1160 +all: $(BUILT_SOURCES) newlib.h
1161 $(MAKE) $(AM_MAKEFLAGS) all-recursive
1164 @@ -703,14 +703,16 @@
1167 $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
1168 -check: check-recursive
1169 +check: $(BUILT_SOURCES)
1170 + $(MAKE) $(AM_MAKEFLAGS) check-recursive
1171 all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) newlib.h
1172 installdirs: installdirs-recursive
1174 for dir in "$(DESTDIR)$(toollibdir)" "$(DESTDIR)$(toollibdir)" "$(DESTDIR)$(toollibdir)"; do \
1175 test -z "$$dir" || $(mkdir_p) "$$dir"; \
1177 -install: install-recursive
1178 +install: $(BUILT_SOURCES)
1179 + $(MAKE) $(AM_MAKEFLAGS) install-recursive
1180 install-exec: install-exec-recursive
1181 install-data: install-data-recursive
1182 uninstall: uninstall-recursive
1184 maintainer-clean-generic:
1185 @echo "This command is intended for maintainers to use"
1186 @echo "it deletes files that may require special tools to rebuild."
1187 + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
1188 clean: clean-recursive
1190 clean-am: clean-generic clean-libtool clean-toollibLIBRARIES \
1193 $(CRT1_DIR)$(CRT1): ; @true
1195 -all-recursive: stmp-targ-include
1197 # The targ-include directory just holds the includes files for the
1198 # particular system and machine we have been configured for. It is
1199 # used while building.