source: rtems/contrib/crossrpms/patches/newlib-1.16.0-rtems4.9-20080430.diff @ c29338cc

4.104.114.95
Last change on this file since c29338cc was c29338cc, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/01/08 at 08:08:19

Add upstream SIZE_MIN/SIZE_MAX fixes.

  • Property mode set to 100644
File size: 54.5 KB
  • newlib/libc/include/getopt.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/getopt.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/getopt.h
    old new  
    8989
    9090/* include files needed by this include file */
    9191
    92 /* macros defined by this include file */
    93 #define NO_ARG          0
    94 #define REQUIRED_ARG    1
    95 #define OPTIONAL_ARG    2
    96 
    97 /* types defined by this include file */
    98 
    99 struct option
    100 {
    101   char *name;                   /* the name of the long option */
    102   int has_arg;                  /* one of the above macros */
    103   int *flag;                    /* determines if getopt_long() returns a
    104                                  * value for a long option; if it is
    105                                  * non-NULL, 0 is returned as a function
    106                                  * value and the value of val is stored in
    107                                  * the area pointed to by flag.  Otherwise,
    108                                  * val is returned. */
    109   int val;                      /* determines the value to return if flag is
    110                                  * NULL. */
    111 };
     92  /* These #defines are to keep the namespace clear... */
     93#define getopt_r                __getopt_r
     94#define getopt_long_r           __getopt_long_r
     95#define getopt_long_only_r      __getopt_long_only_r
    11296
    11397#ifdef __cplusplus
    11498extern "C"
    11599{
    116 #endif
     100
     101#endif                          /* __cplusplus */
     102
     103/* types defined by this include file */
     104  struct option
     105  {
     106    char *name;                 /* the name of the long option */
     107    int has_arg;                /* one of the above macros */
     108    int *flag;                  /* determines if getopt_long() returns a
     109                                 * value for a long option; if it is
     110                                 * non-NULL, 0 is returned as a function
     111                                 * value and the value of val is stored in
     112                                 * the area pointed to by flag.  Otherwise,
     113                                 * val is returned. */
     114    int val;                    /* determines the value to return if flag is
     115                                 * NULL. */
     116
     117  };
     118
     119  /* The getopt_data structure is for reentrancy. Its members are similar to
     120     the externally-defined variables.  */
     121  typedef struct getopt_data
     122  {
     123    char *optarg;
     124    int optind, opterr, optopt, optwhere;
     125  } getopt_data;
    117126
    118127  /* externally-defined variables */
    119128  extern char *optarg;
     
    122131  extern int optopt;
    123132
    124133  /* function prototypes */
    125   int _EXFUN (getopt, (int __argc, char *const __argv[], const char *__optstring));
    126   int _EXFUN (getopt_long, (int __argc, char *const __argv[], const char *__shortopts, const struct option *__longopts, int *__longind));
    127   int _EXFUN (getopt_long_only, (int __argc, char *const __argv[], const char *__shortopts, const struct option *__longopts, int *__longind));
     134  int _EXFUN (getopt,
     135              (int __argc, char *const __argv[], const char *__optstring));
     136
     137  int _EXFUN (getopt_long,
     138              (int __argc, char *const __argv[], const char *__shortopts,
     139               const struct option * __longopts, int *__longind));
     140
     141  int _EXFUN (getopt_long_only,
     142              (int __argc, char *const __argv[], const char *__shortopts,
     143               const struct option * __longopts, int *__longind));
     144
     145  int _EXFUN (__getopt_r,
     146              (int __argc, char *const __argv[], const char *__optstring,
     147               struct getopt_data * __data));
     148
     149  int _EXFUN (__getopt_long_r,
     150              (int __argc, char *const __argv[], const char *__shortopts,
     151               const struct option * __longopts, int *__longind,
     152               struct getopt_data * __data));
     153
     154  int _EXFUN (__getopt_long_only_r,
     155              (int __argc, char *const __argv[], const char *__shortopts,
     156               const struct option * __longopts, int *__longind,
     157               struct getopt_data * __data));
    128158
    129159#ifdef __cplusplus
    130160};
    131161
    132 #endif
     162#endif /* __cplusplus  */
    133163
    134164#endif /* GETOPT_H */
    135165
  • newlib/libc/include/inttypes.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/inttypes.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/inttypes.h
    old new  
    242242#define SCNxMAX         __SCNMAX(x)
    243243
    244244/* ptr types */
    245 #if __have_longlong64
    246 #define __PRIPTR(x) __STRINGIFY(ll##x)
    247 #define __SCNPTR(x) __STRINGIFY(ll##x)
     245#if __ptrint_t_long_defined
     246#define __PRIPTR(x) __STRINGIFY(l##x)
     247#define __SCNPTR(x) __STRINGIFY(l##x)
     248#elif __ptrint_t_int_defined
     249#define __PRIPTR(x) __STRINGIFY(x)
     250#define __SCNPTR(x) __STRINGIFY(x)
    248251#elif __have_long64
    249252#define __PRIPTR(x) __STRINGIFY(l##x)
    250253#define __SCNPTR(x) __STRINGIFY(l##x)
  • newlib/libc/include/machine/setjmp.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/machine/setjmp.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/machine/setjmp.h
    old new  
    2727
    2828/* necv70 was 9 as well. */
    2929
    30 #ifdef __mc68000__
     30#if defined(__m68k__) || defined(__mc68000__)
    3131/*
    3232 * onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
    3333 * fp2-fp7      for 68881.
     
    268268# define _CYGWIN_WORKING_SIGSETJMP
    269269#endif
    270270
     271#ifdef _POSIX_THREADS
     272#define __SIGMASK_FUNC pthread_sigmask
     273#else
     274#define __SIGMASK_FUNC sigprocmask
     275#endif
     276
    271277#if defined(__GNUC__)
    272278
    273279#define sigsetjmp(env, savemask) \
     
    275281            ({ \
    276282              sigjmp_buf *_sjbuf = &(env); \
    277283              ((*_sjbuf)[_SAVEMASK] = savemask,\
    278               sigprocmask (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
     284              __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
    279285              setjmp (*_sjbuf)); \
    280286            })
    281287
     
    284290            ({ \
    285291              sigjmp_buf *_sjbuf = &(env); \
    286292              ((((*_sjbuf)[_SAVEMASK]) ? \
    287                sigprocmask (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
     293               __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
    288294               : 0), \
    289295               longjmp (*_sjbuf, val)); \
    290296            })
     
    292298#else /* !__GNUC__ */
    293299
    294300#define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\
    295                sigprocmask (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
     301               __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
    296302               setjmp (env))
    297303
    298304#define siglongjmp(env, val) ((((env)[_SAVEMASK])?\
    299                sigprocmask (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
     305               __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
    300306               longjmp (env, val))
    301307
    302308#endif
    303309
     310/* POSIX _setjmp/_longjmp macros, maintained for XSI compatibility.  These
     311   are equivalent to sigsetjmp/siglongjmp when not saving the signal mask.
     312   New applications should use sigsetjmp/siglongjmp instead. */
     313#define _setjmp(env)            sigsetjmp ((env), 0)
     314#define _longjmp(env, val)      siglongjmp ((env), (val))
     315
    304316#ifdef __cplusplus
    305317}
    306318#endif
  • newlib/libc/include/pthread.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/pthread.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/pthread.h
    old new  
    283283int     _EXFUN(pthread_getcpuclockid,
    284284        (pthread_t __pthread_id, clockid_t *__clock_id));
    285285 
    286 /* CPU-time Clock Thread Creation Attribute, P1003.4b/D8, p. 59 */
    287 
    288 int     _EXFUN(pthread_attr_setcputime,
    289         (pthread_attr_t *__attr, int __clock_allowed));
    290 
    291 int     _EXFUN(pthread_attr_getcputime,
    292         (pthread_attr_t *__attr, int *__clock_allowed));
    293 
    294286#endif /* defined(_POSIX_THREAD_CPUTIME) */
    295287
    296288
  • newlib/libc/include/stdint.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/stdint.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/stdint.h
    old new  
    348348#endif
    349349
    350350/* This must match size_t in stddef.h, currently long unsigned int */
    351 #define SIZE_MIN (-__STDINT_EXP(LONG_MAX) - 1L)
    352 #define SIZE_MAX __STDINT_EXP(LONG_MAX)
     351#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
    353352
    354353/* This must match sig_atomic_t in <signal.h> (currently int) */
    355354#define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
     
    393392#define UINTMAX_C(x)    x##UL
    394393#endif
    395394
     395#ifdef __rtems__
     396#include <machine/stdint.h>
     397#endif
    396398
    397399#ifdef __cplusplus
    398400}
  • newlib/libc/include/sys/features.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/sys/features.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/sys/features.h
    old new  
    3838#define _POSIX_MEMLOCK_RANGE            1
    3939#define _POSIX_MEMORY_PROTECTION        1
    4040#define _POSIX_MESSAGE_PASSING          1
     41#define _POSIX_MONOTONIC_CLOCK          200112L
    4142#define _POSIX_PRIORITIZED_IO           1
    4243#define _POSIX_PRIORITY_SCHEDULING      1
    4344#define _POSIX_REALTIME_SIGNALS         1
  • newlib/libc/include/sys/_types.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/sys/_types.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/sys/_types.h
    old new  
    8484typedef void *_iconv_t;
    8585#endif
    8686
     87typedef long * __intptr_t;
     88typedef unsigned long* __uintptr_t;
     89
    8790#endif  /* _SYS__TYPES_H */
  • newlib/libc/include/sys/unistd.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/sys/unistd.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/sys/unistd.h
    old new  
    219219char *  _EXFUN(mktemp, (char *));
    220220#endif
    221221
    222 #if defined(__CYGWIN__) || defined(__SPU__)
     222#if defined(__CYGWIN__) || defined(__SPU__) || defined(__rtems__)
    223223void    _EXFUN(sync, (void));
    224 #elif defined(__rtems__)
    225 int     _EXFUN(sync, (void));
    226224#endif
    227225
    228 int     _EXFUN(readlink, (const char *__path, char *__buf, int __buflen));
     226ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen));
    229227int     _EXFUN(symlink, (const char *__name1, const char *__name2));
    230228
    231229#define F_OK    0
  • newlib/libc/include/_syslist.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/_syslist.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/_syslist.h
    old new  
    1111#define _fstat fstat
    1212#define _getpid getpid
    1313#define _gettimeofday gettimeofday
     14#define _isatty isatty
    1415#define _kill kill
    1516#define _link link
    1617#define _lseek lseek
  • newlib/libc/include/time.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/include/time.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/include/time.h
    old new  
    226226
    227227#endif
    228228
     229#if defined(_POSIX_MONOTONIC_CLOCK)
     230
     231/*  The identifier for the system-wide monotonic clock, which is defined
     232    as a clock whose value cannot be set via clock_settime() and which
     233    cannot have backward clock jumps. */
     234
     235#define CLOCK_MONOTONIC (clockid_t)4
     236
     237#endif
     238
    229239#if defined(_POSIX_CPUTIME)
    230240
    231241/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
  • newlib/libc/machine/arm/machine/endian.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/machine/arm/machine/endian.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/machine/arm/machine/endian.h
    old new  
    1 /* ARM configuration file */
    2 
    3 #ifndef _MACHINE_ENDIAN_H
    4 # define _MACHINE_ENDIAN_H
    5 
    6 #ifdef __ARMEB__
    7 #define BYTE_ORDER BIG_ENDIAN
    8 #else
    9 #define BYTE_ORDER LITTLE_ENDIAN
    10 #endif
    11 
    12 #endif
  • newlib/libc/search/db_local.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/search/db_local.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/search/db_local.h
    old new  
    5050#define MAX_PAGE_NUMBER 0xffffffff      /* >= # of pages in a file */
    5151typedef __uint32_t      pgno_t;
    5252#define MAX_PAGE_OFFSET 65535           /* >= # of bytes in a page */
    53 typedef __uint16_t      indx_t;
     53typedef __uint_least16_t        indx_t;
    5454#define MAX_REC_NUMBER  0xffffffff      /* >= # of records in a tree */
    5555typedef __uint32_t      recno_t;
    5656
     
    191191 *      P_16_COPY       swap from one location to another
    192192 */
    193193#define M_16_SWAP(a) {                                                  \
    194         __uint16_t _tmp = a;                                            \
     194        __uint_least16_t _tmp = a;                                              \
    195195        ((char *)&a)[0] = ((char *)&_tmp)[1];                           \
    196196        ((char *)&a)[1] = ((char *)&_tmp)[0];                           \
    197197}
    198198#define P_16_SWAP(a) {                                                  \
    199         __uint16_t _tmp = *(__uint16_t *)a;                             \
     199        __uint_least16_t _tmp = *(__uint_least16_t *)a;                         \
    200200        ((char *)a)[0] = ((char *)&_tmp)[1];                            \
    201201        ((char *)a)[1] = ((char *)&_tmp)[0];                            \
    202202}
  • newlib/libc/search/extern.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/search/extern.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/search/extern.h
    old new  
    4848int      __delpair(HTAB *, BUFHEAD *, int);
    4949int      __expand_table(HTAB *);
    5050int      __find_bigpair(HTAB *, BUFHEAD *, int, char *, int);
    51 __uint16_t       __find_last_page(HTAB *, BUFHEAD **);
     51__uint_least16_t         __find_last_page(HTAB *, BUFHEAD **);
    5252void     __free_ovflpage(HTAB *, BUFHEAD *);
    5353BUFHEAD *__get_buf(HTAB *, __uint32_t, BUFHEAD *, int);
    5454int      __get_page(HTAB *, char *, __uint32_t, int, int, int);
  • newlib/libc/search/hash_bigkey.c

    diff -uNr newlib-1.16.0.orig/newlib/libc/search/hash_bigkey.c newlib-1.16.0-rtems4.9-20080430/newlib/libc/search/hash_bigkey.c
    old new  
    9292        BUFHEAD *bufp;
    9393        const DBT *key, *val;
    9494{
    95         __uint16_t *p;
     95        __uint_least16_t *p;
    9696        int key_size, n, val_size;
    97         __uint16_t space, move_bytes, off;
     97        __uint_least16_t space, move_bytes, off;
    9898        char *cp, *key_data, *val_data;
    9999
    100100        cp = bufp->page;                /* Character pointer of p. */
    101         p = (__uint16_t *)cp;
     101        p = (__uint_least16_t *)cp;
    102102
    103103        key_data = (char *)key->data;
    104104        key_size = key->size;
     
    136136                                OFFSET(p) = off;
    137137                        } else
    138138                                p[n - 2] = FULL_KEY;
    139                 p = (__uint16_t *)bufp->page;
     139                p = (__uint_least16_t *)bufp->page;
    140140                cp = bufp->page;
    141141                bufp->flags |= BUF_MOD;
    142142        }
     
    166166                        if (!bufp)
    167167                                return (-1);
    168168                        cp = bufp->page;
    169                         p = (__uint16_t *)cp;
     169                        p = (__uint_least16_t *)cp;
    170170                } else
    171171                        p[n] = FULL_KEY_DATA;
    172172                bufp->flags |= BUF_MOD;
     
    191191        BUFHEAD *bufp;
    192192{
    193193        BUFHEAD *last_bfp, *rbufp;
    194         __uint16_t *bp, pageno;
     194        __uint_least16_t *bp, pageno;
    195195        int key_done, n;
    196196
    197197        rbufp = bufp;
    198198        last_bfp = NULL;
    199         bp = (__uint16_t *)bufp->page;
     199        bp = (__uint_least16_t *)bufp->page;
    200200        pageno = 0;
    201201        key_done = 0;
    202202
     
    219219                last_bfp = rbufp;
    220220                if (!rbufp)
    221221                        return (-1);            /* Error. */
    222                 bp = (__uint16_t *)rbufp->page;
     222                bp = (__uint_least16_t *)rbufp->page;
    223223        }
    224224
    225225        /*
     
    234234        pageno = bp[n - 1];
    235235
    236236        /* Now, bp is the first page of the pair. */
    237         bp = (__uint16_t *)bufp->page;
     237        bp = (__uint_least16_t *)bufp->page;
    238238        if (n > 2) {
    239239                /* There is an overflow page. */
    240240                bp[1] = pageno;
     
    272272        char *key;
    273273        int size;
    274274{
    275         __uint16_t *bp;
     275        __uint_least16_t *bp;
    276276        char *p;
    277277        int ksize;
    278         __uint16_t bytes;
     278        __uint_least16_t bytes;
    279279        char *kkey;
    280280
    281         bp = (__uint16_t *)bufp->page;
     281        bp = (__uint_least16_t *)bufp->page;
    282282        p = bufp->page;
    283283        ksize = size;
    284284        kkey = key;
     
    294294                if (!bufp)
    295295                        return (-3);
    296296                p = bufp->page;
    297                 bp = (__uint16_t *)p;
     297                bp = (__uint_least16_t *)p;
    298298                ndx = 1;
    299299        }
    300300
     
    316316 * of the pair; 0 if there isn't any (i.e. big pair is the last key in the
    317317 * bucket)
    318318 */
    319 extern __uint16_t
     319extern __uint_least16_t
    320320__find_last_page(hashp, bpp)
    321321        HTAB *hashp;
    322322        BUFHEAD **bpp;
    323323{
    324324        BUFHEAD *bufp;
    325         __uint16_t *bp, pageno;
     325        __uint_least16_t *bp, pageno;
    326326        int n;
    327327
    328328        bufp = *bpp;
    329         bp = (__uint16_t *)bufp->page;
     329        bp = (__uint_least16_t *)bufp->page;
    330330        for (;;) {
    331331                n = bp[0];
    332332
     
    343343                bufp = __get_buf(hashp, pageno, bufp, 0);
    344344                if (!bufp)
    345345                        return (0);     /* Need to indicate an error! */
    346                 bp = (__uint16_t *)bufp->page;
     346                bp = (__uint_least16_t *)bufp->page;
    347347        }
    348348
    349349        *bpp = bufp;
     
    366366        int set_current;
    367367{
    368368        BUFHEAD *save_p;
    369         __uint16_t *bp, len, off, save_addr;
     369        __uint_least16_t *bp, len, off, save_addr;
    370370        char *tp;
    371371
    372         bp = (__uint16_t *)bufp->page;
     372        bp = (__uint_least16_t *)bufp->page;
    373373        while (bp[ndx + 1] == PARTIAL_KEY) {
    374374                bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
    375375                if (!bufp)
    376376                        return (-1);
    377                 bp = (__uint16_t *)bufp->page;
     377                bp = (__uint_least16_t *)bufp->page;
    378378                ndx = 1;
    379379        }
    380380
     
    382382                bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
    383383                if (!bufp)
    384384                        return (-1);
    385                 bp = (__uint16_t *)bufp->page;
     385                bp = (__uint_least16_t *)bufp->page;
    386386                save_p = bufp;
    387387                save_addr = save_p->addr;
    388388                off = bp[1];
     
    403403                        bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
    404404                        if (!bufp)
    405405                                return (-1);
    406                         bp = (__uint16_t *)bufp->page;
     406                        bp = (__uint_least16_t *)bufp->page;
    407407                } else {
    408408                        /* The data is all on one page. */
    409409                        tp = (char *)bp;
     
    422422                                        if (!hashp->cpage)
    423423                                                return (-1);
    424424                                        hashp->cndx = 1;
    425                                         if (!((__uint16_t *)
     425                                        if (!((__uint_least16_t *)
    426426                                            hashp->cpage->page)[0]) {
    427427                                                hashp->cbucket++;
    428428                                                hashp->cpage = NULL;
     
    454454        BUFHEAD *bufp;
    455455        int len, set;
    456456{
    457         __uint16_t *bp;
     457        __uint_least16_t *bp;
    458458        char *p;
    459459        BUFHEAD *xbp;
    460         __uint16_t save_addr;
     460        __uint_least16_t save_addr;
    461461        int mylen, totlen;
    462462
    463463        p = bufp->page;
    464         bp = (__uint16_t *)p;
     464        bp = (__uint_least16_t *)p;
    465465        mylen = hashp->BSIZE - bp[1];
    466466        save_addr = bufp->addr;
    467467
     
    481481                                    __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
    482482                                if (!hashp->cpage)
    483483                                        return (-1);
    484                                 else if (!((__uint16_t *)hashp->cpage->page)[0]) {
     484                                else if (!((__uint_least16_t *)hashp->cpage->page)[0]) {
    485485                                        hashp->cbucket++;
    486486                                        hashp->cpage = NULL;
    487487                                }
     
    533533        BUFHEAD *xbp;
    534534        char *p;
    535535        int mylen, totlen;
    536         __uint16_t *bp, save_addr;
     536        __uint_least16_t *bp, save_addr;
    537537
    538538        p = bufp->page;
    539         bp = (__uint16_t *)p;
     539        bp = (__uint_least16_t *)p;
    540540        mylen = hashp->BSIZE - bp[1];
    541541
    542542        save_addr = bufp->addr;
     
    579579        SPLIT_RETURN *ret;
    580580{
    581581        BUFHEAD *tmpp;
    582         __uint16_t *tp;
     582        __uint_least16_t *tp;
    583583        BUFHEAD *bp;
    584584        DBT key, val;
    585585        __uint32_t change;
    586         __uint16_t free_space, n, off;
     586        __uint_least16_t free_space, n, off;
    587587
    588588        bp = big_keyp;
    589589
     
    615615            (tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0));
    616616#endif
    617617        tmpp->ovfl = bp;        /* one of op/np point to big_keyp */
    618         tp = (__uint16_t *)tmpp->page;
     618        tp = (__uint_least16_t *)tmpp->page;
    619619#ifdef DEBUG
    620620        assert(FREESPACE(tp) >= OVFLSIZE);
    621621#endif
    622622        n = tp[0];
    623623        off = OFFSET(tp);
    624624        free_space = FREESPACE(tp);
    625         tp[++n] = (__uint16_t)addr;
     625        tp[++n] = (__uint_least16_t)addr;
    626626        tp[++n] = OVFLPAGE;
    627627        tp[0] = n;
    628628        OFFSET(tp) = off;
     
    638638        ret->newp = np;
    639639        ret->oldp = op;
    640640
    641         tp = (__uint16_t *)big_keyp->page;
     641        tp = (__uint_least16_t *)big_keyp->page;
    642642        big_keyp->flags |= BUF_MOD;
    643643        if (tp[0] > 2) {
    644644                /*
  • newlib/libc/search/hash_buf.c

    diff -uNr newlib-1.16.0.orig/newlib/libc/search/hash_buf.c newlib-1.16.0-rtems4.9-20080430/newlib/libc/search/hash_buf.c
    old new  
    176176        BUFHEAD *next_xbp;
    177177        SEGMENT segp;
    178178        int segment_ndx;
    179         __uint16_t oaddr, *shortp;
     179        __uint_least16_t oaddr, *shortp;
    180180
    181181        oaddr = 0;
    182182        bp = LRU;
     
    212212                         * Set oaddr before __put_page so that you get it
    213213                         * before bytes are swapped.
    214214                         */
    215                         shortp = (__uint16_t *)bp->page;
     215                        shortp = (__uint_least16_t *)bp->page;
    216216                        if (shortp[0])
    217217                                oaddr = shortp[shortp[0] - 1];
    218218                        if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page,
     
    255255                                    (oaddr != xbp->addr))
    256256                                        break;
    257257
    258                                 shortp = (__uint16_t *)xbp->page;
     258                                shortp = (__uint_least16_t *)xbp->page;
    259259                                if (shortp[0])
    260260                                        /* set before __put_page */
    261261                                        oaddr = shortp[shortp[0] - 1];
  • newlib/libc/search/hash.c

    diff -uNr newlib-1.16.0.orig/newlib/libc/search/hash.c newlib-1.16.0-rtems4.9-20080430/newlib/libc/search/hash.c
    old new  
    632632{
    633633        BUFHEAD *rbufp;
    634634        BUFHEAD *bufp, *save_bufp;
    635         __uint16_t *bp;
     635        __uint_least16_t *bp;
    636636        int n, ndx, off, size;
    637637        char *kp;
    638         __uint16_t pageno;
     638        __uint_least16_t pageno;
    639639
    640640#ifdef HASH_STATISTICS
    641641        hash_accesses++;
     
    651651
    652652        /* Pin the bucket chain */
    653653        rbufp->flags |= BUF_PIN;
    654         for (bp = (__uint16_t *)rbufp->page, n = *bp++, ndx = 1; ndx < n;)
     654        for (bp = (__uint_least16_t *)rbufp->page, n = *bp++, ndx = 1; ndx < n;)
    655655                if (bp[1] >= REAL_KEY) {
    656656                        /* Real key/data pair */
    657657                        if (size == off - *bp &&
     
    670670                                return (ERROR);
    671671                        }
    672672                        /* FOR LOOP INIT */
    673                         bp = (__uint16_t *)rbufp->page;
     673                        bp = (__uint_least16_t *)rbufp->page;
    674674                        n = *bp++;
    675675                        ndx = 1;
    676676                        off = hashp->BSIZE;
     
    692692                                        return (ERROR);
    693693                                }
    694694                                /* FOR LOOP INIT */
    695                                 bp = (__uint16_t *)rbufp->page;
     695                                bp = (__uint_least16_t *)rbufp->page;
    696696                                n = *bp++;
    697697                                ndx = 1;
    698698                                off = hashp->BSIZE;
     
    726726                save_bufp->flags &= ~BUF_PIN;
    727727                return (ABNORMAL);
    728728        case HASH_GET:
    729                 bp = (__uint16_t *)rbufp->page;
     729                bp = (__uint_least16_t *)rbufp->page;
    730730                if (bp[ndx + 1] < REAL_KEY) {
    731731                        if (__big_return(hashp, rbufp, ndx, val, 0))
    732732                                return (ERROR);
     
    762762        __uint32_t bucket;
    763763        BUFHEAD *bufp;
    764764        HTAB *hashp;
    765         __uint16_t *bp, ndx;
     765        __uint_least16_t *bp, ndx;
    766766
    767767        hashp = (HTAB *)dbp->internal;
    768768        if (flag && flag != R_FIRST && flag != R_NEXT) {
     
    787787                                if (!bufp)
    788788                                        return (ERROR);
    789789                                hashp->cpage = bufp;
    790                                 bp = (__uint16_t *)bufp->page;
     790                                bp = (__uint_least16_t *)bufp->page;
    791791                                if (bp[0])
    792792                                        break;
    793793                        }
     
    797797                                return (ABNORMAL);
    798798                        }
    799799                } else
    800                         bp = (__uint16_t *)hashp->cpage->page;
     800                        bp = (__uint_least16_t *)hashp->cpage->page;
    801801
    802802#ifdef DEBUG
    803803                assert(bp);
     
    808808                            __get_buf(hashp, bp[hashp->cndx], bufp, 0);
    809809                        if (!bufp)
    810810                                return (ERROR);
    811                         bp = (__uint16_t *)(bufp->page);
     811                        bp = (__uint_least16_t *)(bufp->page);
    812812                        hashp->cndx = 1;
    813813                }
    814814                if (!bp[0]) {
  • newlib/libc/search/hash.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/search/hash.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/search/hash.h
    old new  
    102102#define NCACHED 32                      /* number of bit maps and spare
    103103                                         * points */
    104104        int             spares[NCACHED];/* spare pages for overflow */
    105         __uint16_t      bitmaps[NCACHED];       /* address of overflow page
     105        __uint_least16_t        bitmaps[NCACHED];       /* address of overflow page
    106106                                                 * bitmaps */
    107107} HASHHDR;
    108108
  • newlib/libc/search/hash_page.c

    diff -uNr newlib-1.16.0.orig/newlib/libc/search/hash_page.c newlib-1.16.0-rtems4.9-20080430/newlib/libc/search/hash_page.c
    old new  
    7777static __uint32_t       *fetch_bitmap(HTAB *, int);
    7878static __uint32_t        first_free(__uint32_t);
    7979static int       open_temp(HTAB *);
    80 static __uint16_t        overflow_page(HTAB *);
     80static __uint_least16_t  overflow_page(HTAB *);
    8181static void      putpair(char *, const DBT *, const DBT *);
    82 static void      squeeze_key(__uint16_t *, const DBT *, const DBT *);
     82static void      squeeze_key(__uint_least16_t *, const DBT *, const DBT *);
    8383static int       ugly_split
    8484(HTAB *, __uint32_t, BUFHEAD *, BUFHEAD *, int, int);
    8585
    8686#define PAGE_INIT(P) { \
    87         ((__uint16_t *)(P))[0] = 0; \
    88         ((__uint16_t *)(P))[1] = hashp->BSIZE - 3 * sizeof(__uint16_t); \
    89         ((__uint16_t *)(P))[2] = hashp->BSIZE; \
     87        ((__uint_least16_t *)(P))[0] = 0; \
     88        ((__uint_least16_t *)(P))[1] = hashp->BSIZE - 3 * sizeof(__uint_least16_t); \
     89        ((__uint_least16_t *)(P))[2] = hashp->BSIZE; \
    9090}
    9191
    9292/*
     
    9999        char *p;
    100100        const DBT *key, *val;
    101101{
    102         __uint16_t *bp, n, off;
     102        __uint_least16_t *bp, n, off;
    103103
    104         bp = (__uint16_t *)p;
     104        bp = (__uint_least16_t *)p;
    105105
    106106        /* Enter the key first. */
    107107        n = bp[0];
     
    117117
    118118        /* Adjust page info. */
    119119        bp[0] = n;
    120         bp[n + 1] = off - ((n + 3) * sizeof(__uint16_t));
     120        bp[n + 1] = off - ((n + 3) * sizeof(__uint_least16_t));
    121121        bp[n + 2] = off;
    122122}
    123123
     
    132132        BUFHEAD *bufp;
    133133        int ndx;
    134134{
    135         __uint16_t *bp, newoff;
     135        __uint_least16_t *bp, newoff;
    136136        int n;
    137         __uint16_t pairlen;
     137        __uint_least16_t pairlen;
    138138
    139         bp = (__uint16_t *)bufp->page;
     139        bp = (__uint_least16_t *)bufp->page;
    140140        n = bp[0];
    141141
    142142        if (bp[ndx + 1] < REAL_KEY)
     
    167167        }
    168168        /* Finally adjust the page data */
    169169        bp[n] = OFFSET(bp) + pairlen;
    170         bp[n - 1] = bp[n + 1] + pairlen + 2 * sizeof(__uint16_t);
     170        bp[n - 1] = bp[n + 1] + pairlen + 2 * sizeof(__uint_least16_t);
    171171        bp[0] = n - 2;
    172172        hashp->NKEYS--;
    173173
     
    185185        __uint32_t obucket, nbucket;
    186186{
    187187        BUFHEAD *new_bufp, *old_bufp;
    188         __uint16_t *ino;
     188        __uint_least16_t *ino;
    189189        char *np;
    190190        DBT key, val;
    191191        int n, ndx, retval;
    192         __uint16_t copyto, diff, off, moved;
     192        __uint_least16_t copyto, diff, off, moved;
    193193        char *op;
    194194
    195         copyto = (__uint16_t)hashp->BSIZE;
    196         off = (__uint16_t)hashp->BSIZE;
     195        copyto = (__uint_least16_t)hashp->BSIZE;
     196        off = (__uint_least16_t)hashp->BSIZE;
    197197        old_bufp = __get_buf(hashp, obucket, NULL, 0);
    198198        if (old_bufp == NULL)
    199199                return (-1);
     
    204204        old_bufp->flags |= (BUF_MOD | BUF_PIN);
    205205        new_bufp->flags |= (BUF_MOD | BUF_PIN);
    206206
    207         ino = (__uint16_t *)(op = old_bufp->page);
     207        ino = (__uint_least16_t *)(op = old_bufp->page);
    208208        np = new_bufp->page;
    209209
    210210        moved = 0;
     
    246246
    247247        /* Now clean up the page */
    248248        ino[0] -= moved;
    249         FREESPACE(ino) = copyto - sizeof(__uint16_t) * (ino[0] + 3);
     249        FREESPACE(ino) = copyto - sizeof(__uint_least16_t) * (ino[0] + 3);
    250250        OFFSET(ino) = copyto;
    251251
    252252#ifdef DEBUG3
    253253        (void)fprintf(stderr, "split %d/%d\n",
    254             ((__uint16_t *)np)[0] / 2,
    255             ((__uint16_t *)op)[0] / 2);
     254            ((__uint_least16_t *)np)[0] / 2,
     255            ((__uint_least16_t *)op)[0] / 2);
    256256#endif
    257257        /* unpin both pages */
    258258        old_bufp->flags &= ~BUF_PIN;
     
    284284        int moved;              /* Number of pairs moved to new page. */
    285285{
    286286        BUFHEAD *bufp;          /* Buffer header for ino */
    287         __uint16_t *ino;                /* Page keys come off of */
    288         __uint16_t *np;         /* New page */
    289         __uint16_t *op;         /* Page keys go on to if they aren't moving */
     287        __uint_least16_t *ino;          /* Page keys come off of */
     288        __uint_least16_t *np;           /* New page */
     289        __uint_least16_t *op;           /* Page keys go on to if they aren't moving */
    290290
    291291        BUFHEAD *last_bfp;      /* Last buf header OVFL needing to be freed */
    292292        DBT key, val;
    293293        SPLIT_RETURN ret;
    294         __uint16_t n, off, ov_addr, scopyto;
     294        __uint_least16_t n, off, ov_addr, scopyto;
    295295        char *cino;             /* Character value of ino */
    296296
    297297        bufp = old_bufp;
    298         ino = (__uint16_t *)old_bufp->page;
    299         np = (__uint16_t *)new_bufp->page;
    300         op = (__uint16_t *)old_bufp->page;
     298        ino = (__uint_least16_t *)old_bufp->page;
     299        np = (__uint_least16_t *)new_bufp->page;
     300        op = (__uint_least16_t *)old_bufp->page;
    301301        last_bfp = NULL;
    302         scopyto = (__uint16_t)copyto;   /* ANSI */
     302        scopyto = (__uint_least16_t)copyto;     /* ANSI */
    303303
    304304        n = ino[0] - 1;
    305305        while (n < ino[0]) {
     
    310310                        old_bufp = ret.oldp;
    311311                        if (!old_bufp)
    312312                                return (-1);
    313                         op = (__uint16_t *)old_bufp->page;
     313                        op = (__uint_least16_t *)old_bufp->page;
    314314                        new_bufp = ret.newp;
    315315                        if (!new_bufp)
    316316                                return (-1);
    317                         np = (__uint16_t *)new_bufp->page;
     317                        np = (__uint_least16_t *)new_bufp->page;
    318318                        bufp = ret.nextp;
    319319                        if (!bufp)
    320320                                return (0);
    321321                        cino = (char *)bufp->page;
    322                         ino = (__uint16_t *)cino;
     322                        ino = (__uint_least16_t *)cino;
    323323                        last_bfp = ret.nextp;
    324324                } else if (ino[n + 1] == OVFLPAGE) {
    325325                        ov_addr = ino[n];
     
    329329                         */
    330330                        ino[0] -= (moved + 2);
    331331                        FREESPACE(ino) =
    332                             scopyto - sizeof(__uint16_t) * (ino[0] + 3);
     332                            scopyto - sizeof(__uint_least16_t) * (ino[0] + 3);
    333333                        OFFSET(ino) = scopyto;
    334334
    335335                        bufp = __get_buf(hashp, ov_addr, bufp, 0);
    336336                        if (!bufp)
    337337                                return (-1);
    338338
    339                         ino = (__uint16_t *)bufp->page;
     339                        ino = (__uint_least16_t *)bufp->page;
    340340                        n = 1;
    341341                        scopyto = hashp->BSIZE;
    342342                        moved = 0;
     
    364364                                            __add_ovflpage(hashp, old_bufp);
    365365                                        if (!old_bufp)
    366366                                                return (-1);
    367                                         op = (__uint16_t *)old_bufp->page;
     367                                        op = (__uint_least16_t *)old_bufp->page;
    368368                                        putpair((char *)op, &key, &val);
    369369                                }
    370370                                old_bufp->flags |= BUF_MOD;
     
    377377                                            __add_ovflpage(hashp, new_bufp);
    378378                                        if (!new_bufp)
    379379                                                return (-1);
    380                                         np = (__uint16_t *)new_bufp->page;
     380                                        np = (__uint_least16_t *)new_bufp->page;
    381381                                        putpair((char *)np, &key, &val);
    382382                                }
    383383                                new_bufp->flags |= BUF_MOD;
     
    402402        BUFHEAD *bufp;
    403403        const DBT *key, *val;
    404404{
    405         __uint16_t *bp, *sop;
     405        __uint_least16_t *bp, *sop;
    406406        int do_expand;
    407407
    408         bp = (__uint16_t *)bufp->page;
     408        bp = (__uint_least16_t *)bufp->page;
    409409        do_expand = 0;
    410410        while (bp[0] && (bp[2] < REAL_KEY || bp[bp[0]] < REAL_KEY))
    411411                /* Exception case */
     
    417417                        bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
    418418                        if (!bufp)
    419419                                return (-1);
    420                         bp = (__uint16_t *)bufp->page;
     420                        bp = (__uint_least16_t *)bufp->page;
    421421                } else
    422422                        /* Try to squeeze key on this page */
    423423                        if (FREESPACE(bp) > PAIRSIZE(key, val)) {
     
    427427                                bufp = __get_buf(hashp, bp[bp[0] - 1], bufp, 0);
    428428                                if (!bufp)
    429429                                        return (-1);
    430                                 bp = (__uint16_t *)bufp->page;
     430                                bp = (__uint_least16_t *)bufp->page;
    431431                        }
    432432
    433433        if (PAIRFITS(bp, key, val))
     
    437437                bufp = __add_ovflpage(hashp, bufp);
    438438                if (!bufp)
    439439                        return (-1);
    440                 sop = (__uint16_t *)bufp->page;
     440                sop = (__uint_least16_t *)bufp->page;
    441441
    442442                if (PAIRFITS(sop, key, val))
    443443                        putpair((char *)sop, key, val);
     
    468468        HTAB *hashp;
    469469        BUFHEAD *bufp;
    470470{
    471         __uint16_t *sp;
    472         __uint16_t ndx, ovfl_num;
     471        __uint_least16_t *sp;
     472        __uint_least16_t ndx, ovfl_num;
    473473#ifdef DEBUG1
    474474        int tmp1, tmp2;
    475475#endif
    476         sp = (__uint16_t *)bufp->page;
     476        sp = (__uint_least16_t *)bufp->page;
    477477
    478478        /* Check if we are dynamically determining the fill factor */
    479479        if (hashp->FFACTOR == DEF_FFACTOR) {
     
    525525{
    526526        int fd, page, size;
    527527        int rsize;
    528         __uint16_t *bp;
     528        __uint_least16_t *bp;
    529529
    530530        fd = hashp->fp;
    531531        size = hashp->BSIZE;
     
    541541        if ((lseek(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) ||
    542542            ((rsize = read(fd, p, size)) == -1))
    543543                return (-1);
    544         bp = (__uint16_t *)p;
     544        bp = (__uint_least16_t *)p;
    545545        if (!rsize)
    546546                bp[0] = 0;      /* We hit the EOF, so initialize a new page */
    547547        else
     
    600600                        for (i = 0; i < max; i++)
    601601                                M_32_SWAP(((int *)p)[i]);
    602602                } else {
    603                         max = ((__uint16_t *)p)[0] + 2;
     603                        max = ((__uint_least16_t *)p)[0] + 2;
    604604                        for (i = 0; i <= max; i++)
    605                                 M_16_SWAP(((__uint16_t *)p)[i]);
     605                                M_16_SWAP(((__uint_least16_t *)p)[i]);
    606606                }
    607607        }
    608608        if (is_bucket)
     
    643643            hashp->BSIZE - clearbytes);
    644644        ip[clearints - 1] = ALL_SET << (nbits & BYTE_MASK);
    645645        SETBIT(ip, 0);
    646         hashp->BITMAPS[ndx] = (__uint16_t)pnum;
     646        hashp->BITMAPS[ndx] = (__uint_least16_t)pnum;
    647647        hashp->mapp[ndx] = ip;
    648648        return (0);
    649649}
     
    663663        return (i);
    664664}
    665665
    666 static __uint16_t
     666static __uint_least16_t
    667667overflow_page(hashp)
    668668        HTAB *hashp;
    669669{
    670670        __uint32_t *freep;
    671671        int max_free, offset, splitnum;
    672         __uint16_t addr;
     672        __uint_least16_t addr;
    673673        int bit, first_page, free_bit, free_page, i, in_use_bits, j;
    674674#ifdef DEBUG2
    675675        int tmp1, tmp2;
     
    816816        HTAB *hashp;
    817817        BUFHEAD *obufp;
    818818{
    819         __uint16_t addr;
     819        __uint_least16_t addr;
    820820        __uint32_t *freep;
    821821        int bit_address, free_page, free_bit;
    822         __uint16_t ndx;
     822        __uint_least16_t ndx;
    823823
    824824        addr = obufp->addr;
    825825#ifdef DEBUG1
    826826        (void)fprintf(stderr, "Freeing %d\n", addr);
    827827#endif
    828         ndx = (((__uint16_t)addr) >> SPLITSHIFT);
     828        ndx = (((__uint_least16_t)addr) >> SPLITSHIFT);
    829829        bit_address =
    830830            (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1;
    831831         if (bit_address < hashp->LAST_FREED)
     
    883883 */
    884884static void
    885885squeeze_key(sp, key, val)
    886         __uint16_t *sp;
     886        __uint_least16_t *sp;
    887887        const DBT *key, *val;
    888888{
    889889        char *p;
    890         __uint16_t free_space, n, off, pageno;
     890        __uint_least16_t free_space, n, off, pageno;
    891891
    892892        p = (char *)sp;
    893893        n = sp[0];
  • newlib/libc/search/page.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/search/page.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/search/page.h
    old new  
    7474 * You might as well do this up front.
    7575 */
    7676
    77 #define PAIRSIZE(K,D)   (2*sizeof(__uint16_t) + (K)->size + (D)->size)
    78 #define BIGOVERHEAD     (4*sizeof(__uint16_t))
    79 #define KEYSIZE(K)      (4*sizeof(__uint16_t) + (K)->size);
    80 #define OVFLSIZE        (2*sizeof(__uint16_t))
     77#define PAIRSIZE(K,D)   (2*sizeof(__uint_least16_t) + (K)->size + (D)->size)
     78#define BIGOVERHEAD     (4*sizeof(__uint_least16_t))
     79#define KEYSIZE(K)      (4*sizeof(__uint_least16_t) + (K)->size);
     80#define OVFLSIZE        (2*sizeof(__uint_least16_t))
    8181#define FREESPACE(P)    ((P)[(P)[0]+1])
    8282#define OFFSET(P)       ((P)[(P)[0]+2])
    8383#define PAIRFITS(P,K,D) \
    8484        (((P)[2] >= REAL_KEY) && \
    8585            (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P)))
    86 #define PAGE_META(N)    (((N)+3) * sizeof(__uint16_t))
     86#define PAGE_META(N)    (((N)+3) * sizeof(__uint_least16_t))
    8787
    8888typedef struct {
    8989        BUFHEAD *newp;
    9090        BUFHEAD *oldp;
    9191        BUFHEAD *nextp;
    92         __uint16_t next_addr;
     92        __uint_least16_t next_addr;
    9393}       SPLIT_RETURN;
  • newlib/libc/stdlib/getopt.c

    diff -uNr newlib-1.16.0.orig/newlib/libc/stdlib/getopt.c newlib-1.16.0-rtems4.9-20080430/newlib/libc/stdlib/getopt.c
    old new  
    9090#include <getopt.h>
    9191
    9292/* macros */
     93#define NO_ARG                  0
     94#define REQUIRED_ARG            1
     95#define OPTIONAL_ARG            2
    9396
    9497/* types */
    9598typedef enum GETOPT_ORDERING_T
     
    100103} GETOPT_ORDERING_T;
    101104
    102105/* globally-defined variables */
    103 char *optarg = NULL;
     106char *optarg = 0;
    104107int optind = 0;
    105108int opterr = 1;
    106109int optopt = '?';
    107110
     111/* static variables */
     112static int optwhere = 0;
     113
    108114/* functions */
    109115
    110116/* reverse_argv_elements:  reverses num elements starting at argv */
    111117static void
    112 reverse_argv_elements (char ** argv, int num)
     118reverse_argv_elements (char **argv, int num)
    113119{
    114120  int i;
    115121  char *tmp;
     
    126132static void
    127133permute (char *const argv[], int len1, int len2)
    128134{
    129   reverse_argv_elements ((char **)argv, len1);
    130   reverse_argv_elements ((char **)argv, len1 + len2);
    131   reverse_argv_elements ((char **)argv, len2);
     135  reverse_argv_elements ((char **) argv, len1);
     136  reverse_argv_elements ((char **) argv, len1 + len2);
     137  reverse_argv_elements ((char **) argv, len2);
    132138}
    133139
    134140/* is_option: is this argv-element an option or the end of the option list? */
    135141static int
    136142is_option (char *argv_element, int only)
    137143{
    138   return ((argv_element == NULL)
    139           || (argv_element[0] == '-') || (only && argv_element[0] == '+'));
     144  return ((argv_element == 0)
     145          || (argv_element[0] == '-') || (only && argv_element[0] == '+'));
     146}
     147
     148/* read_globals: read the values from the globals into a getopt_data
     149   structure */
     150static void
     151read_globals (struct getopt_data *data)
     152{
     153  data->optarg = optarg;
     154  data->optind = optind;
     155  data->opterr = opterr;
     156  data->optopt = optopt;
     157  data->optwhere = optwhere;
     158}
     159
     160/* write_globals: write the values into the globals from a getopt_data
     161   structure */
     162static void
     163write_globals (struct getopt_data *data)
     164{
     165  optarg = data->optarg;
     166  optind = data->optind;
     167  opterr = data->opterr;
     168  optopt = data->optopt;
     169  optwhere = data->optwhere;
    140170}
    141171
    142172/* getopt_internal:  the function that does all the dirty work */
    143173static int
    144174getopt_internal (int argc, char *const argv[], const char *shortopts,
    145                  const struct option *longopts, int *longind, int only)
     175                 const struct option *longopts, int *longind, int only,
     176                 struct getopt_data *data)
    146177{
    147178  GETOPT_ORDERING_T ordering = PERMUTE;
    148   static size_t optwhere = 0;
    149179  size_t permute_from = 0;
    150180  int num_nonopts = 0;
    151181  int optindex = 0;
    152182  size_t match_chars = 0;
    153   char *possible_arg = NULL;
     183  char *possible_arg = 0;
    154184  int longopt_match = -1;
    155185  int has_arg = -1;
    156   char *cp = NULL;
     186  char *cp = 0;
    157187  int arg_next = 0;
    158188
    159189  /* first, deal with silly parameters and easy stuff */
    160   if (argc == 0 || argv == NULL || (shortopts == NULL && longopts == NULL))
    161     return EOF;
    162   if (optind >= argc || argv[optind] == NULL)
     190  if (argc == 0 || argv == 0 || (shortopts == 0 && longopts == 0)
     191      || data->optind >= argc || argv[data->optind] == 0)
    163192    return EOF;
    164   if (strcmp (argv[optind], "--") == 0)
     193  if (strcmp (argv[data->optind], "--") == 0)
    165194    {
    166       optind++;
     195      data->optind++;
    167196      return EOF;
    168197    }
     198
    169199  /* if this is our first time through */
    170   if (optind == 0)
    171     optind = optwhere = 1;
     200  if (data->optind == 0)
     201    data->optind = data->optwhere = 1;
    172202
    173203  /* define ordering */
    174   if (shortopts != NULL && (*shortopts == '-' || *shortopts == '+'))
     204  if (shortopts != 0 && (*shortopts == '-' || *shortopts == '+'))
    175205    {
    176206      ordering = (*shortopts == '-') ? RETURN_IN_ORDER : REQUIRE_ORDER;
    177207      shortopts++;
    178208    }
    179209  else
    180     ordering = (getenv ("POSIXLY_CORRECT") != NULL) ? REQUIRE_ORDER : PERMUTE;
     210    ordering = (getenv ("POSIXLY_CORRECT") != 0) ? REQUIRE_ORDER : PERMUTE;
    181211
    182212  /*
    183213   * based on ordering, find our next option, if we're at the beginning of
    184214   * one
    185215   */
    186   if (optwhere == 1)
     216  if (data->optwhere == 1)
    187217    {
    188218      switch (ordering)
    189         {
    190         case PERMUTE:
    191           permute_from = optind;
    192           num_nonopts = 0;
    193           while (!is_option (argv[optind], only))
    194             {
    195               optind++;
    196               num_nonopts++;
    197             }
    198           if (argv[optind] == NULL)
    199             {
    200               /* no more options */
    201               optind = permute_from;
    202               return EOF;
    203             }
    204           else if (strcmp (argv[optind], "--") == 0)
    205             {
    206               /* no more options, but have to get `--' out of the way */
    207               permute (argv + permute_from, num_nonopts, 1);
    208               optind = permute_from + 1;
    209               return EOF;
    210             }
    211           break;
    212         case RETURN_IN_ORDER:
    213           if (!is_option (argv[optind], only))
    214             {
    215               optarg = argv[optind++];
    216               return (optopt = 1);
    217             }
    218           break;
    219         case REQUIRE_ORDER:
    220           if (!is_option (argv[optind], only))
    221             return EOF;
    222           break;
    223         }
     219        {
     220        default:                /* shouldn't happen */
     221        case PERMUTE:
     222          permute_from = data->optind;
     223          num_nonopts = 0;
     224          while (!is_option (argv[data->optind], only))
     225            {
     226              data->optind++;
     227              num_nonopts++;
     228            }
     229          if (argv[data->optind] == 0)
     230            {
     231              /* no more options */
     232              data->optind = permute_from;
     233              return EOF;
     234            }
     235          else if (strcmp (argv[data->optind], "--") == 0)
     236            {
     237              /* no more options, but have to get `--' out of the way */
     238              permute (argv + permute_from, num_nonopts, 1);
     239              data->optind = permute_from + 1;
     240              return EOF;
     241            }
     242          break;
     243        case RETURN_IN_ORDER:
     244          if (!is_option (argv[data->optind], only))
     245            {
     246              data->optarg = argv[data->optind++];
     247              return (data->optopt = 1);
     248            }
     249          break;
     250        case REQUIRE_ORDER:
     251          if (!is_option (argv[data->optind], only))
     252            return EOF;
     253          break;
     254        }
    224255    }
    225256  /* we've got an option, so parse it */
    226257
    227258  /* first, is it a long option? */
    228   if (longopts != NULL
    229       && (memcmp (argv[optind], "--", 2) == 0
    230           || (only && argv[optind][0] == '+')) && optwhere == 1)
     259  if (longopts != 0
     260      && (memcmp (argv[data->optind], "--", 2) == 0
     261          || (only && argv[data->optind][0] == '+')) && data->optwhere == 1)
    231262    {
    232263      /* handle long options */
    233       if (memcmp (argv[optind], "--", 2) == 0)
    234         optwhere = 2;
     264      if (memcmp (argv[data->optind], "--", 2) == 0)
     265        data->optwhere = 2;
    235266      longopt_match = -1;
    236       possible_arg = strchr (argv[optind] + optwhere, '=');
    237       if (possible_arg == NULL)
    238         {
    239           /* no =, so next argv might be arg */
    240           match_chars = strlen (argv[optind]);
    241           possible_arg = argv[optind] + match_chars;
    242           match_chars = match_chars - optwhere;
    243         }
     267      possible_arg = strchr (argv[data->optind] + data->optwhere, '=');
     268      if (possible_arg == 0)
     269        {
     270          /* no =, so next argv might be arg */
     271          match_chars = strlen (argv[data->optind]);
     272          possible_arg = argv[data->optind] + match_chars;
     273          match_chars = match_chars - data->optwhere;
     274        }
    244275      else
    245         match_chars = (possible_arg - argv[optind]) - optwhere;
    246       for (optindex = 0; longopts[optindex].name != NULL; optindex++)
    247         {
    248           if (memcmp (argv[optind] + optwhere,
    249                       longopts[optindex].name, match_chars) == 0)
    250             {
    251               /* do we have an exact match? */
    252               if (match_chars == (int) (strlen (longopts[optindex].name)))
    253                 {
    254                   longopt_match = optindex;
    255                   break;
    256                 }
    257               /* do any characters match? */
    258               else
    259                 {
    260                   if (longopt_match < 0)
    261                     longopt_match = optindex;
    262                   else
    263                     {
    264                       /* we have ambiguous options */
    265                       if (opterr)
    266                         fprintf (stderr, "%s: option `%s' is ambiguous "
    267                                  "(could be `--%s' or `--%s')\n",
    268                                  argv[0],
    269                                  argv[optind],
    270                                  longopts[longopt_match].name,
    271                                  longopts[optindex].name);
    272                       return (optopt = '?');
    273                     }
    274                 }
    275             }
    276         }
     276        match_chars = (possible_arg - argv[data->optind]) - data->optwhere;
     277      for (optindex = 0; longopts[optindex].name != 0; ++optindex)
     278        {
     279          if (memcmp
     280              (argv[data->optind] + data->optwhere, longopts[optindex].name,
     281               match_chars) == 0)
     282            {
     283              /* do we have an exact match? */
     284              if (match_chars == (int) (strlen (longopts[optindex].name)))
     285                {
     286                  longopt_match = optindex;
     287                  break;
     288                }
     289              /* do any characters match? */
     290              else
     291                {
     292                  if (longopt_match < 0)
     293                    longopt_match = optindex;
     294                  else
     295                    {
     296                      /* we have ambiguous options */
     297                      if (data->opterr)
     298                        fprintf (stderr, "%s: option `%s' is ambiguous "
     299                                 "(could be `--%s' or `--%s')\n",
     300                                 argv[0],
     301                                 argv[data->optind],
     302                                 longopts[longopt_match].name,
     303                                 longopts[optindex].name);
     304                      return (data->optopt = '?');
     305                    }
     306                }
     307            }
     308        }
    277309      if (longopt_match >= 0)
    278         has_arg = longopts[longopt_match].has_arg;
     310        has_arg = longopts[longopt_match].has_arg;
    279311    }
     312
    280313  /* if we didn't find a long option, is it a short option? */
    281   if (longopt_match < 0 && shortopts != NULL)
     314  if (longopt_match < 0 && shortopts != 0)
    282315    {
    283       cp = strchr (shortopts, argv[optind][optwhere]);
    284       if (cp == NULL)
    285         {
    286           /* couldn't find option in shortopts */
    287           if (opterr)
    288             fprintf (stderr,
    289                      "%s: invalid option -- `-%c'\n",
    290                      argv[0], argv[optind][optwhere]);
    291           optwhere++;
    292           if (argv[optind][optwhere] == '\0')
    293             {
    294               optind++;
    295               optwhere = 1;
    296             }
    297           return (optopt = '?');
    298         }
     316      cp = strchr (shortopts, argv[data->optind][data->optwhere]);
     317      if (cp == 0)
     318        {
     319          /* couldn't find option in shortopts */
     320          if (data->opterr)
     321            fprintf (stderr,
     322                     "%s: invalid option -- `-%c'\n",
     323                     argv[0], argv[data->optind][data->optwhere]);
     324          data->optwhere++;
     325          if (argv[data->optind][data->optwhere] == '\0')
     326            {
     327              data->optind++;
     328              data->optwhere = 1;
     329            }
     330          return (data->optopt = '?');
     331        }
    299332      has_arg = ((cp[1] == ':')
    300                 ? ((cp[2] == ':') ? OPTIONAL_ARG : REQUIRED_ARG) : NO_ARG);
    301       possible_arg = argv[optind] + optwhere + 1;
    302       optopt = *cp;
     333                ? ((cp[2] == ':') ? OPTIONAL_ARG : REQUIRED_ARG) : NO_ARG);
     334      possible_arg = argv[data->optind] + data->optwhere + 1;
     335      data->optopt = *cp;
    303336    }
    304   /* get argument and reset optwhere */
     337
     338  /* get argument and reset data->optwhere */
    305339  arg_next = 0;
    306340  switch (has_arg)
    307341    {
    308342    case OPTIONAL_ARG:
    309343      if (*possible_arg == '=')
    310         possible_arg++;
    311       if (*possible_arg != '\0')
    312         {
    313           optarg = possible_arg;
    314           optwhere = 1;
    315         }
    316       else
    317         optarg = NULL;
     344        possible_arg++;
     345      data->optarg = (*possible_arg != '\0') ? possible_arg : 0;
     346      data->optwhere = 1;
    318347      break;
    319348    case REQUIRED_ARG:
    320349      if (*possible_arg == '=')
    321         possible_arg++;
     350        possible_arg++;
    322351      if (*possible_arg != '\0')
    323         {
    324           optarg = possible_arg;
    325           optwhere = 1;
    326         }
    327       else if (optind + 1 >= argc)
    328         {
    329           if (opterr)
    330             {
    331               fprintf (stderr, "%s: argument required for option `", argv[0]);
    332               if (longopt_match >= 0)
    333                 fprintf (stderr, "--%s'\n", longopts[longopt_match].name);
    334               else
    335                 fprintf (stderr, "-%c'\n", *cp);
    336             }
    337           optind++;
    338           return (optopt = ':');
    339         }
     352        {
     353          data->optarg = possible_arg;
     354          data->optwhere = 1;
     355        }
     356      else if (data->optind + 1 >= argc)
     357        {
     358          if (data->opterr)
     359            {
     360              fprintf (stderr, "%s: argument required for option `", argv[0]);
     361              if (longopt_match >= 0)
     362                fprintf (stderr, "--%s'\n", longopts[longopt_match].name);
     363              else
     364                fprintf (stderr, "-%c'\n", *cp);
     365            }
     366          data->optind++;
     367          return (data->optopt = ':');
     368        }
    340369      else
    341         {
    342           optarg = argv[optind + 1];
    343           arg_next = 1;
    344           optwhere = 1;
    345         }
     370        {
     371          data->optarg = argv[data->optind + 1];
     372          arg_next = 1;
     373          data->optwhere = 1;
     374        }
    346375      break;
     376    default:                    /* shouldn't happen */
    347377    case NO_ARG:
    348378      if (longopt_match < 0)
    349         {
    350           optwhere++;
    351           if (argv[optind][optwhere] == '\0')
    352             optwhere = 1;
    353         }
     379        {
     380          data->optwhere++;
     381          if (argv[data->optind][data->optwhere] == '\0')
     382            data->optwhere = 1;
     383        }
    354384      else
    355         optwhere = 1;
    356       optarg = NULL;
     385        data->optwhere = 1;
     386      data->optarg = 0;
    357387      break;
    358388    }
    359389
    360   /* do we have to permute or otherwise modify optind? */
    361   if (ordering == PERMUTE && optwhere == 1 && num_nonopts != 0)
     390  /* do we have to permute or otherwise modify data->optind? */
     391  if (ordering == PERMUTE && data->optwhere == 1 && num_nonopts != 0)
    362392    {
    363393      permute (argv + permute_from, num_nonopts, 1 + arg_next);
    364       optind = permute_from + 1 + arg_next;
     394      data->optind = permute_from + 1 + arg_next;
    365395    }
    366   else if (optwhere == 1)
    367     optind = optind + 1 + arg_next;
     396  else if (data->optwhere == 1)
     397    data->optind = data->optind + 1 + arg_next;
    368398
    369399  /* finally return */
    370400  if (longopt_match >= 0)
    371401    {
    372       if (longind != NULL)
    373         *longind = longopt_match;
    374       if (longopts[longopt_match].flag != NULL)
    375         {
    376           *(longopts[longopt_match].flag) = longopts[longopt_match].val;
    377           return 0;
    378         }
     402      if (longind != 0)
     403        *longind = longopt_match;
     404      if (longopts[longopt_match].flag != 0)
     405        {
     406          *(longopts[longopt_match].flag) = longopts[longopt_match].val;
     407          return 0;
     408        }
    379409      else
    380         return longopts[longopt_match].val;
     410        return longopts[longopt_match].val;
    381411    }
    382412  else
    383     return optopt;
     413    return data->optopt;
    384414}
    385415
    386416int
    387417getopt (int argc, char *const argv[], const char *optstring)
    388418{
    389   return getopt_internal (argc, argv, optstring, NULL, NULL, 0);
     419  struct getopt_data data;
     420  int r;
     421
     422  read_globals (&data);
     423  r = getopt_internal (argc, argv, optstring, 0, 0, 0, &data);
     424  write_globals (&data);
     425  return r;
    390426}
    391427
    392428int
    393429getopt_long (int argc, char *const argv[], const char *shortopts,
    394              const struct option *longopts, int *longind)
     430             const struct option *longopts, int *longind)
    395431{
    396   return getopt_internal (argc, argv, shortopts, longopts, longind, 0);
     432  struct getopt_data data;
     433  int r;
     434
     435  read_globals (&data);
     436  r = getopt_internal (argc, argv, shortopts, longopts, longind, 0, &data);
     437  write_globals (&data);
     438  return r;
    397439}
    398440
    399441int
    400442getopt_long_only (int argc, char *const argv[], const char *shortopts,
    401                   const struct option *longopts, int *longind)
     443                  const struct option *longopts, int *longind)
     444{
     445  struct getopt_data data;
     446  int r;
     447
     448  read_globals (&data);
     449  r = getopt_internal (argc, argv, shortopts, longopts, longind, 1, &data);
     450  write_globals (&data);
     451  return r;
     452}
     453
     454int
     455__getopt_r (int argc, char *const argv[], const char *optstring,
     456            struct getopt_data *data)
     457{
     458  return getopt_internal (argc, argv, optstring, 0, 0, 0, data);
     459}
     460
     461int
     462__getopt_long_r (int argc, char *const argv[], const char *shortopts,
     463                 const struct option *longopts, int *longind,
     464                 struct getopt_data *data)
     465{
     466  return getopt_internal (argc, argv, shortopts, longopts, longind, 0, data);
     467}
     468
     469int
     470__getopt_long_only_r (int argc, char *const argv[], const char *shortopts,
     471                      const struct option *longopts, int *longind,
     472                      struct getopt_data *data)
    402473{
    403   return getopt_internal (argc, argv, shortopts, longopts, longind, 1);
     474  return getopt_internal (argc, argv, shortopts, longopts, longind, 1, data);
    404475}
    405476
    406477/* end of file GETOPT.C */
  • newlib/libc/sys/rtems/machine/stdint.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/sys/rtems/machine/stdint.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/sys/rtems/machine/stdint.h
    old new  
     1/*
     2 *
     3 */
     4#ifndef _MACHINE_STDINT_H
     5#define _MACHINE_STDINT_H
     6
     7#ifndef _STDINT_H
     8#error machine/stdint.h is an internal file and must not be directly included
     9#endif
     10
     11#ifndef __rtems__
     12#error machine/stdint.h is an RTEMS specific internal file and must not be used otherwise
     13#endif
     14
     15#if defined(__sparc__) \
     16  || defined(__powerpc__) || defined(__PPC__) \
     17  || defined(__mips__) \
     18  || defined(__sh__) \
     19  || defined(__AVR__) \
     20  || defined(_C4x) || defined(_C3x) \
     21  || defined(__H8300__)
     22/* PTRDIFF_TYPE = int */
     23#define __ptrint_t_int_defined 1
     24#endif
     25
     26#if defined(__i386__) \
     27  || defined(__m68k__) \
     28  || defined(__bfin__) \
     29  || defined(__arm__) \
     30  || defined(__H8300S__) || defined(__H8300H__)
     31/* PTRDIFF_TYPE = long */
     32#define __ptrint_t_long_defined 1
     33#endif
     34
     35#endif
  • newlib/libc/sys/rtems/sys/param.h

    diff -uNr newlib-1.16.0.orig/newlib/libc/sys/rtems/sys/param.h newlib-1.16.0-rtems4.9-20080430/newlib/libc/sys/rtems/sys/param.h
    old new  
    9393#include <sys/resource.h>
    9494#include <sys/ucred.h>
    9595#include <sys/uio.h>
    96 #include <sys/rtprio.h>
    9796
    9897#ifndef FALSE
    9998#define FALSE   0
  • newlib/Makefile.am

    diff -uNr newlib-1.16.0.orig/newlib/Makefile.am newlib-1.16.0-rtems4.9-20080430/newlib/Makefile.am
    old new  
    8181        libc.a
    8282endif
    8383
    84 noinst_DATA = stmp-targ-include
     84BUILT_SOURCES = stmp-targ-include
    8585
    8686toollib_DATA = $(CRT0) $(CRT1)
    8787
     
    186186
    187187$(CRT1_DIR)$(CRT1): ; @true
    188188
    189 
    190 all-recursive: stmp-targ-include
    191 
    192189# The targ-include directory just holds the includes files for the
    193190# particular system and machine we have been configured for.  It is
    194191# used while building.
  • newlib/Makefile.in

    diff -uNr newlib-1.16.0.orig/newlib/Makefile.in newlib-1.16.0-rtems4.9-20080430/newlib/Makefile.in
    old new  
    105105        pdf-recursive ps-recursive uninstall-info-recursive \
    106106        uninstall-recursive
    107107toollibDATA_INSTALL = $(INSTALL_DATA)
    108 DATA = $(noinst_DATA) $(toollib_DATA)
     108DATA = $(toollib_DATA)
    109109ETAGS = etags
    110110CTAGS = ctags
    111111DEJATOOL = $(PACKAGE)
     
    339339@USE_LIBTOOL_FALSE@toollib_LIBRARIES = libm.a \
    340340@USE_LIBTOOL_FALSE@     libc.a
    341341
    342 noinst_DATA = stmp-targ-include
     342BUILT_SOURCES = stmp-targ-include
    343343toollib_DATA = $(CRT0) $(CRT1)
    344344
    345345# The functions ldexp, frexp and modf are traditionally supplied in
     
    398398
    399399# dejagnu support
    400400RUNTESTFLAGS =
    401 all: newlib.h
     401all: $(BUILT_SOURCES) newlib.h
    402402        $(MAKE) $(AM_MAKEFLAGS) all-recursive
    403403
    404404.SUFFIXES:
     
    703703        done
    704704check-am:
    705705        $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
    706 check: check-recursive
     706check: $(BUILT_SOURCES)
     707        $(MAKE) $(AM_MAKEFLAGS) check-recursive
    707708all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) newlib.h
    708709installdirs: installdirs-recursive
    709710installdirs-am:
    710711        for dir in "$(DESTDIR)$(toollibdir)" "$(DESTDIR)$(toollibdir)" "$(DESTDIR)$(toollibdir)"; do \
    711712          test -z "$$dir" || $(mkdir_p) "$$dir"; \
    712713        done
    713 install: install-recursive
     714install: $(BUILT_SOURCES)
     715        $(MAKE) $(AM_MAKEFLAGS) install-recursive
    714716install-exec: install-exec-recursive
    715717install-data: install-data-recursive
    716718uninstall: uninstall-recursive
     
    735737maintainer-clean-generic:
    736738        @echo "This command is intended for maintainers to use"
    737739        @echo "it deletes files that may require special tools to rebuild."
     740        -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
    738741clean: clean-recursive
    739742
    740743clean-am: clean-generic clean-libtool clean-toollibLIBRARIES \
     
    853856
    854857$(CRT1_DIR)$(CRT1): ; @true
    855858
    856 all-recursive: stmp-targ-include
    857 
    858859# The targ-include directory just holds the includes files for the
    859860# particular system and machine we have been configured for.  It is
    860861# used while building.
Note: See TracBrowser for help on using the repository browser.