OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [include/] [stdlib.h] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/* Copyright (C) 1991-2002, 2003 Free Software Foundation, Inc.
2
   This file is part of the GNU C Library.
3
 
4
   The GNU C Library is free software; you can redistribute it and/or
5
   modify it under the terms of the GNU Lesser General Public
6
   License as published by the Free Software Foundation; either
7
   version 2.1 of the License, or (at your option) any later version.
8
 
9
   The GNU C Library is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
   Lesser General Public License for more details.
13
 
14
   You should have received a copy of the GNU Lesser General Public
15
   License along with the GNU C Library; if not, write to the Free
16
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17
   02111-1307 USA.  */
18
 
19
/*
20
 *      ISO C99 Standard: 7.20 General utilities        <stdlib.h>
21
 */
22
 
23
#ifndef _STDLIB_H
24
 
25
#include <features.h>
26
 
27
/* Get size_t, wchar_t and NULL from <stddef.h>.  */
28
#define         __need_size_t
29
#ifndef __need_malloc_and_calloc
30
#ifdef __UCLIBC_HAS_WCHAR__
31
# define        __need_wchar_t
32
#endif
33
# define        __need_NULL
34
#endif
35
#include <stddef.h>
36
 
37
__BEGIN_DECLS
38
 
39
#ifndef __need_malloc_and_calloc
40
#define _STDLIB_H       1
41
 
42
#if defined __USE_XOPEN && !defined _SYS_WAIT_H
43
/* XPG requires a few symbols from <sys/wait.h> being defined.  */
44
# include <bits/waitflags.h>
45
# include <bits/waitstatus.h>
46
 
47
# ifdef __USE_BSD
48
 
49
/* Lots of hair to allow traditional BSD use of `union wait'
50
   as well as POSIX.1 use of `int' for the status word.  */
51
 
52
#  if defined __GNUC__ && !defined __cplusplus
53
#   define __WAIT_INT(status)                                                 \
54
  (__extension__ ({ union { __typeof(status) __in; int __i; } __u;            \
55
                    __u.__in = (status); __u.__i; }))
56
#  else
57
#   define __WAIT_INT(status)   (*(int *) &(status))
58
#  endif
59
 
60
/* This is the type of the argument to `wait'.  The funky union
61
   causes redeclarations with ether `int *' or `union wait *' to be
62
   allowed without complaint.  __WAIT_STATUS_DEFN is the type used in
63
   the actual function definitions.  */
64
 
65
#  if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus
66
#   define __WAIT_STATUS        void *
67
#   define __WAIT_STATUS_DEFN   void *
68
#  else
69
/* This works in GCC 2.6.1 and later.  */
70
typedef union
71
  {
72
    union wait *__uptr;
73
    int *__iptr;
74
  } __WAIT_STATUS __attribute__ ((__transparent_union__));
75
#   define __WAIT_STATUS_DEFN   int *
76
#  endif
77
 
78
# else /* Don't use BSD.  */
79
 
80
#  define __WAIT_INT(status)    (status)
81
#  define __WAIT_STATUS         int *
82
#  define __WAIT_STATUS_DEFN    int *
83
 
84
# endif /* Use BSD.  */
85
 
86
/* Define the macros <sys/wait.h> also would define this way.  */
87
# define WEXITSTATUS(status)    __WEXITSTATUS(__WAIT_INT(status))
88
# define WTERMSIG(status)       __WTERMSIG(__WAIT_INT(status))
89
# define WSTOPSIG(status)       __WSTOPSIG(__WAIT_INT(status))
90
# define WIFEXITED(status)      __WIFEXITED(__WAIT_INT(status))
91
# define WIFSIGNALED(status)    __WIFSIGNALED(__WAIT_INT(status))
92
# define WIFSTOPPED(status)     __WIFSTOPPED(__WAIT_INT(status))
93
#endif  /* X/Open and <sys/wait.h> not included.  */
94
 
95
__BEGIN_NAMESPACE_STD
96
/* Returned by `div'.  */
97
typedef struct
98
  {
99
    int quot;                   /* Quotient.  */
100
    int rem;                    /* Remainder.  */
101
  } div_t;
102
 
103
/* Returned by `ldiv'.  */
104
#ifndef __ldiv_t_defined
105
typedef struct
106
  {
107
    long int quot;              /* Quotient.  */
108
    long int rem;               /* Remainder.  */
109
  } ldiv_t;
110
# define __ldiv_t_defined       1
111
#endif
112
__END_NAMESPACE_STD
113
 
114
#if defined __USE_ISOC99 && !defined __lldiv_t_defined
115
__BEGIN_NAMESPACE_C99
116
/* Returned by `lldiv'.  */
117
__extension__ typedef struct
118
  {
119
    long long int quot;         /* Quotient.  */
120
    long long int rem;          /* Remainder.  */
121
  } lldiv_t;
122
# define __lldiv_t_defined      1
123
__END_NAMESPACE_C99
124
#endif
125
 
126
 
127
/* The largest number rand will return (same as INT_MAX).  */
128
#define RAND_MAX        2147483647
129
 
130
 
131
/* We define these the same for all machines.
132
   Changes from this to the outside world should be done in `_exit'.  */
133
#define EXIT_FAILURE    1       /* Failing exit status.  */
134
#define EXIT_SUCCESS    0        /* Successful exit status.  */
135
 
136
 
137
/* Maximum length of a multibyte character in the current locale.  */
138
/* #define      MB_CUR_MAX      (__ctype_get_mb_cur_max ()) */
139
/* extern size_t __ctype_get_mb_cur_max (void) __THROW; */
140
#ifdef __UCLIBC_HAS_WCHAR__
141
/* Maximum length of a multibyte character in the current locale.  */
142
#define MB_CUR_MAX      (_stdlib_mb_cur_max ())
143
extern size_t _stdlib_mb_cur_max (void) __THROW;
144
#endif
145
 
146
 
147
__BEGIN_NAMESPACE_STD
148
#ifdef __UCLIBC_HAS_FLOATS__
149
/* Convert a string to a floating-point number.  */
150
extern double atof (__const char *__nptr) __THROW __attribute_pure__;
151
#endif /* __UCLIBC_HAS_FLOATS__ */
152
/* Convert a string to an integer.  */
153
extern int atoi (__const char *__nptr) __THROW __attribute_pure__;
154
/* Convert a string to a long integer.  */
155
extern long int atol (__const char *__nptr) __THROW __attribute_pure__;
156
__END_NAMESPACE_STD
157
 
158
#if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined __USE_MISC)
159
__BEGIN_NAMESPACE_C99
160
/* Convert a string to a long long integer.  */
161
__extension__ extern long long int atoll (__const char *__nptr)
162
     __THROW __attribute_pure__;
163
__END_NAMESPACE_C99
164
#endif
165
 
166
#ifdef __UCLIBC_HAS_FLOATS__
167
__BEGIN_NAMESPACE_STD
168
/* Convert a string to a floating-point number.  */
169
extern double strtod (__const char *__restrict __nptr,
170
                      char **__restrict __endptr) __THROW;
171
__END_NAMESPACE_STD
172
 
173
#ifdef  __USE_ISOC99
174
__BEGIN_NAMESPACE_C99
175
/* Likewise for `float' and `long double' sizes of floating-point numbers.  */
176
extern float strtof (__const char *__restrict __nptr,
177
                     char **__restrict __endptr) __THROW;
178
 
179
extern long double strtold (__const char *__restrict __nptr,
180
                            char **__restrict __endptr) __THROW;
181
__END_NAMESPACE_C99
182
#endif
183
#endif /* __UCLIBC_HAS_FLOATS__ */
184
 
185
__BEGIN_NAMESPACE_STD
186
/* Convert a string to a long integer.  */
187
extern long int strtol (__const char *__restrict __nptr,
188
                        char **__restrict __endptr, int __base) __THROW;
189
/* Convert a string to an unsigned long integer.  */
190
extern unsigned long int strtoul (__const char *__restrict __nptr,
191
                                  char **__restrict __endptr, int __base)
192
     __THROW;
193
__END_NAMESPACE_C99
194
 
195
#if defined __GLIBC_HAVE_LONG_LONG && defined __USE_BSD
196
/* Convert a string to a quadword integer.  */
197
__extension__
198
extern long long int strtoq (__const char *__restrict __nptr,
199
                             char **__restrict __endptr, int __base) __THROW;
200
/* Convert a string to an unsigned quadword integer.  */
201
__extension__
202
extern unsigned long long int strtouq (__const char *__restrict __nptr,
203
                                       char **__restrict __endptr, int __base)
204
     __THROW;
205
#endif /* GCC and use BSD.  */
206
 
207
#if defined __USE_ISOC99 || (defined __GLIBC_HAVE_LONG_LONG && defined __USE_MISC)
208
__BEGIN_NAMESPACE_C99
209
/* Convert a string to a quadword integer.  */
210
__extension__
211
extern long long int strtoll (__const char *__restrict __nptr,
212
                              char **__restrict __endptr, int __base) __THROW;
213
/* Convert a string to an unsigned quadword integer.  */
214
__extension__
215
extern unsigned long long int strtoull (__const char *__restrict __nptr,
216
                                        char **__restrict __endptr, int __base)
217
     __THROW;
218
__END_NAMESPACE_C99
219
#endif /* ISO C99 or GCC and use MISC.  */
220
 
221
 
222
#ifdef __UCLIBC_HAS_XLOCALE__
223
#ifdef __USE_GNU
224
/* The concept of one static locale per category is not very well
225
   thought out.  Many applications will need to process its data using
226
   information from several different locales.  Another application is
227
   the implementation of the internationalization handling in the
228
   upcoming ISO C++ standard library.  To support this another set of
229
   the functions using locale data exist which have an additional
230
   argument.
231
 
232
   Attention: all these functions are *not* standardized in any form.
233
   This is a proof-of-concept implementation.  */
234
 
235
/* Structure for reentrant locale using functions.  This is an
236
   (almost) opaque type for the user level programs.  */
237
# include <xlocale.h>
238
 
239
/* Special versions of the functions above which take the locale to
240
   use as an additional parameter.  */
241
extern long int strtol_l (__const char *__restrict __nptr,
242
                          char **__restrict __endptr, int __base,
243
                          __locale_t __loc) __THROW;
244
 
245
extern unsigned long int strtoul_l (__const char *__restrict __nptr,
246
                                    char **__restrict __endptr,
247
                                    int __base, __locale_t __loc) __THROW;
248
 
249
__extension__
250
extern long long int strtoll_l (__const char *__restrict __nptr,
251
                                char **__restrict __endptr, int __base,
252
                                __locale_t __loc) __THROW;
253
 
254
__extension__
255
extern unsigned long long int strtoull_l (__const char *__restrict __nptr,
256
                                          char **__restrict __endptr,
257
                                          int __base, __locale_t __loc)
258
     __THROW;
259
 
260
extern double strtod_l (__const char *__restrict __nptr,
261
                        char **__restrict __endptr, __locale_t __loc)
262
     __THROW;
263
 
264
extern float strtof_l (__const char *__restrict __nptr,
265
                       char **__restrict __endptr, __locale_t __loc) __THROW;
266
 
267
extern long double strtold_l (__const char *__restrict __nptr,
268
                              char **__restrict __endptr,
269
                              __locale_t __loc) __THROW;
270
 
271
/* Internal names to support libstd++. */
272
extern long int __strtol_l (__const char *__restrict __nptr,
273
                          char **__restrict __endptr, int __base,
274
                          __locale_t __loc) __THROW;
275
 
276
extern unsigned long int __strtoul_l (__const char *__restrict __nptr,
277
                                    char **__restrict __endptr,
278
                                    int __base, __locale_t __loc) __THROW;
279
 
280
__extension__
281
extern long long int __strtoll_l (__const char *__restrict __nptr,
282
                                char **__restrict __endptr, int __base,
283
                                __locale_t __loc) __THROW;
284
 
285
__extension__
286
extern unsigned long long int __strtoull_l (__const char *__restrict __nptr,
287
                                          char **__restrict __endptr,
288
                                          int __base, __locale_t __loc)
289
     __THROW;
290
 
291
extern double __strtod_l (__const char *__restrict __nptr,
292
                        char **__restrict __endptr, __locale_t __loc)
293
     __THROW;
294
 
295
extern float __strtof_l (__const char *__restrict __nptr,
296
                       char **__restrict __endptr, __locale_t __loc) __THROW;
297
 
298
extern long double __strtold_l (__const char *__restrict __nptr,
299
                              char **__restrict __endptr,
300
                              __locale_t __loc) __THROW;
301
#endif /* GNU */
302
#endif /* __UCLIBC_HAS_XLOCALE__ */
303
 
304
 
305
#if 0
306
/* The internal entry points for `strtoX' take an extra flag argument
307
   saying whether or not to parse locale-dependent number grouping.  */
308
 
309
extern double __strtod_internal (__const char *__restrict __nptr,
310
                                 char **__restrict __endptr, int __group)
311
     __THROW;
312
extern float __strtof_internal (__const char *__restrict __nptr,
313
                                char **__restrict __endptr, int __group)
314
     __THROW;
315
extern long double __strtold_internal (__const char *__restrict __nptr,
316
                                       char **__restrict __endptr,
317
                                       int __group) __THROW;
318
#ifndef __strtol_internal_defined
319
extern long int __strtol_internal (__const char *__restrict __nptr,
320
                                   char **__restrict __endptr,
321
                                   int __base, int __group) __THROW;
322
# define __strtol_internal_defined      1
323
#endif
324
#ifndef __strtoul_internal_defined
325
extern unsigned long int __strtoul_internal (__const char *__restrict __nptr,
326
                                             char **__restrict __endptr,
327
                                             int __base, int __group) __THROW;
328
# define __strtoul_internal_defined     1
329
#endif
330
#if defined __GNUC__ || defined __USE_ISOC99
331
# ifndef __strtoll_internal_defined
332
__extension__
333
extern long long int __strtoll_internal (__const char *__restrict __nptr,
334
                                         char **__restrict __endptr,
335
                                         int __base, int __group) __THROW;
336
#  define __strtoll_internal_defined    1
337
# endif
338
# ifndef __strtoull_internal_defined
339
__extension__
340
extern unsigned long long int __strtoull_internal (__const char *
341
                                                   __restrict __nptr,
342
                                                   char **__restrict __endptr,
343
                                                   int __base, int __group)
344
     __THROW;
345
#  define __strtoull_internal_defined   1
346
# endif
347
#endif /* GCC */
348
#endif /* 0 */
349
 
350
#if defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ \
351
    && defined __USE_EXTERN_INLINES
352
/* Define inline functions which call the internal entry points.  */
353
 
354
/* __BEGIN_NAMESPACE_STD */
355
/* extern __inline double */
356
/* strtod (__const char *__restrict __nptr, char **__restrict __endptr) __THROW */
357
/* { */
358
/*   return __strtod_internal (__nptr, __endptr, 0); */
359
/* } */
360
/* extern __inline long int */
361
/* strtol (__const char *__restrict __nptr, char **__restrict __endptr, */
362
/*      int __base) __THROW */
363
/* { */
364
/*   return __strtol_internal (__nptr, __endptr, __base, 0); */
365
/* } */
366
/* extern __inline unsigned long int */
367
/* strtoul (__const char *__restrict __nptr, char **__restrict __endptr, */
368
/*       int __base) __THROW */
369
/* { */
370
/*   return __strtoul_internal (__nptr, __endptr, __base, 0); */
371
/* } */
372
/* __END_NAMESPACE_STD */
373
 
374
/* # ifdef __USE_ISOC99 */
375
/* __BEGIN_NAMESPACE_C99 */
376
/* extern __inline float */
377
/* strtof (__const char *__restrict __nptr, char **__restrict __endptr) __THROW */
378
/* { */
379
/*   return __strtof_internal (__nptr, __endptr, 0); */
380
/* } */
381
/* extern __inline long double */
382
/* strtold (__const char *__restrict __nptr, char **__restrict __endptr) __THROW */
383
/* { */
384
/*   return __strtold_internal (__nptr, __endptr, 0); */
385
/* } */
386
/* __END_NAMESPACE_C99 */
387
/* # endif */
388
 
389
/* # ifdef __USE_BSD */
390
/* __extension__ extern __inline long long int */
391
/* strtoq (__const char *__restrict __nptr, char **__restrict __endptr, */
392
/*      int __base) __THROW */
393
/* { */
394
/*   return __strtoll_internal (__nptr, __endptr, __base, 0); */
395
/* } */
396
/* __extension__ extern __inline unsigned long long int */
397
/* strtouq (__const char *__restrict __nptr, char **__restrict __endptr, */
398
/*       int __base) __THROW */
399
/* { */
400
/*   return __strtoull_internal (__nptr, __endptr, __base, 0); */
401
/* } */
402
/* # endif */
403
 
404
/* # if defined __USE_MISC || defined __USE_ISOC99 */
405
/* __BEGIN_NAMESPACE_C99 */
406
/* __extension__ extern __inline long long int */
407
/* strtoll (__const char *__restrict __nptr, char **__restrict __endptr, */
408
/*       int __base) __THROW */
409
/* { */
410
/*   return __strtoll_internal (__nptr, __endptr, __base, 0); */
411
/* } */
412
/* __extension__ extern __inline unsigned long long int */
413
/* strtoull (__const char * __restrict __nptr, char **__restrict __endptr, */
414
/*        int __base) __THROW */
415
/* { */
416
/*   return __strtoull_internal (__nptr, __endptr, __base, 0); */
417
/* } */
418
/* __END_NAMESPACE_C99 */
419
/* # endif */
420
 
421
__BEGIN_NAMESPACE_STD
422
extern __inline double
423
atof (__const char *__nptr) __THROW
424
{
425
  return strtod (__nptr, (char **) NULL);
426
}
427
extern __inline int
428
atoi (__const char *__nptr) __THROW
429
{
430
  return (int) strtol (__nptr, (char **) NULL, 10);
431
}
432
extern __inline long int
433
atol (__const char *__nptr) __THROW
434
{
435
  return strtol (__nptr, (char **) NULL, 10);
436
}
437
__END_NAMESPACE_STD
438
 
439
# if defined __USE_MISC || defined __USE_ISOC99
440
__BEGIN_NAMESPACE_C99
441
__extension__ extern __inline long long int
442
atoll (__const char *__nptr) __THROW
443
{
444
  return strtoll (__nptr, (char **) NULL, 10);
445
}
446
__END_NAMESPACE_C99
447
# endif
448
#endif /* Optimizing and Inlining.  */
449
 
450
 
451
#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
452
/* Convert N to base 64 using the digits "./0-9A-Za-z", least-significant
453
   digit first.  Returns a pointer to static storage overwritten by the
454
   next call.  */
455
extern char *l64a (long int __n) __THROW;
456
 
457
/* Read a number from a string S in base 64 as above.  */
458
extern long int a64l (__const char *__s) __THROW __attribute_pure__;
459
 
460
#endif  /* Use SVID || extended X/Open.  */
461
 
462
#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED || defined __USE_BSD
463
# include <sys/types.h> /* we need int32_t... */
464
 
465
/* These are the functions that actually do things.  The `random', `srandom',
466
   `initstate' and `setstate' functions are those from BSD Unices.
467
   The `rand' and `srand' functions are required by the ANSI standard.
468
   We provide both interfaces to the same random number generator.  */
469
/* Return a random long integer between 0 and RAND_MAX inclusive.  */
470
extern long int random (void) __THROW;
471
 
472
/* Seed the random number generator with the given number.  */
473
extern void srandom (unsigned int __seed) __THROW;
474
 
475
/* Initialize the random number generator to use state buffer STATEBUF,
476
   of length STATELEN, and seed it with SEED.  Optimal lengths are 8, 16,
477
   32, 64, 128 and 256, the bigger the better; values less than 8 will
478
   cause an error and values greater than 256 will be rounded down.  */
479
extern char *initstate (unsigned int __seed, char *__statebuf,
480
                        size_t __statelen) __THROW;
481
 
482
/* Switch the random number generator to state buffer STATEBUF,
483
   which should have been previously initialized by `initstate'.  */
484
extern char *setstate (char *__statebuf) __THROW;
485
 
486
 
487
# ifdef __USE_MISC
488
/* Reentrant versions of the `random' family of functions.
489
   These functions all use the following data structure to contain
490
   state, rather than global state variables.  */
491
 
492
struct random_data
493
  {
494
    int32_t *fptr;              /* Front pointer.  */
495
    int32_t *rptr;              /* Rear pointer.  */
496
    int32_t *state;             /* Array of state values.  */
497
    int rand_type;              /* Type of random number generator.  */
498
    int rand_deg;               /* Degree of random number generator.  */
499
    int rand_sep;               /* Distance between front and rear.  */
500
    int32_t *end_ptr;           /* Pointer behind state table.  */
501
  };
502
 
503
extern int random_r (struct random_data *__restrict __buf,
504
                     int32_t *__restrict __result) __THROW;
505
 
506
extern int srandom_r (unsigned int __seed, struct random_data *__buf) __THROW;
507
 
508
extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
509
                        size_t __statelen,
510
                        struct random_data *__restrict __buf) __THROW;
511
 
512
extern int setstate_r (char *__restrict __statebuf,
513
                       struct random_data *__restrict __buf) __THROW;
514
# endif /* Use misc.  */
515
#endif  /* Use SVID || extended X/Open || BSD. */
516
 
517
 
518
__BEGIN_NAMESPACE_STD
519
/* Return a random integer between 0 and RAND_MAX inclusive.  */
520
extern int rand (void) __THROW;
521
/* Seed the random number generator with the given number.  */
522
extern void srand (unsigned int __seed) __THROW;
523
__END_NAMESPACE_STD
524
 
525
#ifdef __USE_POSIX
526
/* Reentrant interface according to POSIX.1.  */
527
extern int rand_r (unsigned int *__seed) __THROW;
528
#endif
529
 
530
 
531
#if defined __USE_SVID || defined __USE_XOPEN
532
/* System V style 48-bit random number generator functions.  */
533
 
534
#ifdef __UCLIBC_HAS_FLOATS__
535
/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */
536
extern double drand48 (void) __THROW;
537
extern double erand48 (unsigned short int __xsubi[3]) __THROW;
538
#endif /* __UCLIBC_HAS_FLOATS__ */
539
 
540
/* Return non-negative, long integer in [0,2^31).  */
541
extern long int lrand48 (void) __THROW;
542
extern long int nrand48 (unsigned short int __xsubi[3]) __THROW;
543
 
544
/* Return signed, long integers in [-2^31,2^31).  */
545
extern long int mrand48 (void) __THROW;
546
extern long int jrand48 (unsigned short int __xsubi[3]) __THROW;
547
 
548
/* Seed random number generator.  */
549
extern void srand48 (long int __seedval) __THROW;
550
extern unsigned short int *seed48 (unsigned short int __seed16v[3]) __THROW;
551
extern void lcong48 (unsigned short int __param[7]) __THROW;
552
 
553
# ifdef __USE_MISC
554
/* Data structure for communication with thread safe versions.  This
555
   type is to be regarded as opaque.  It's only exported because users
556
   have to allocate objects of this type.  */
557
struct drand48_data
558
  {
559
    unsigned short int __x[3];  /* Current state.  */
560
    unsigned short int __old_x[3]; /* Old state.  */
561
    unsigned short int __c;     /* Additive const. in congruential formula.  */
562
    unsigned short int __init;  /* Flag for initializing.  */
563
    unsigned long long int __a; /* Factor in congruential formula.  */
564
  };
565
 
566
#ifdef __UCLIBC_HAS_FLOATS__
567
/* Return non-negative, double-precision floating-point value in [0.0,1.0).  */
568
extern int drand48_r (struct drand48_data *__restrict __buffer,
569
                      double *__restrict __result) __THROW;
570
extern int erand48_r (unsigned short int __xsubi[3],
571
                      struct drand48_data *__restrict __buffer,
572
                      double *__restrict __result) __THROW;
573
#endif /* __UCLIBC_HAS_FLOATS__ */
574
 
575
/* Return non-negative, long integer in [0,2^31).  */
576
extern int lrand48_r (struct drand48_data *__restrict __buffer,
577
                      long int *__restrict __result) __THROW;
578
extern int nrand48_r (unsigned short int __xsubi[3],
579
                      struct drand48_data *__restrict __buffer,
580
                      long int *__restrict __result) __THROW;
581
 
582
/* Return signed, long integers in [-2^31,2^31).  */
583
extern int mrand48_r (struct drand48_data *__restrict __buffer,
584
                      long int *__restrict __result) __THROW;
585
extern int jrand48_r (unsigned short int __xsubi[3],
586
                      struct drand48_data *__restrict __buffer,
587
                      long int *__restrict __result) __THROW;
588
 
589
/* Seed random number generator.  */
590
extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
591
     __THROW;
592
 
593
extern int seed48_r (unsigned short int __seed16v[3],
594
                     struct drand48_data *__buffer) __THROW;
595
 
596
extern int lcong48_r (unsigned short int __param[7],
597
                      struct drand48_data *__buffer) __THROW;
598
# endif /* Use misc.  */
599
#endif  /* Use SVID or X/Open.  */
600
 
601
#endif /* don't just need malloc and calloc */
602
 
603
#ifndef __malloc_and_calloc_defined
604
# define __malloc_and_calloc_defined
605
__BEGIN_NAMESPACE_STD
606
/* Allocate SIZE bytes of memory.  */
607
extern void *malloc (size_t __size) __THROW __attribute_malloc__;
608
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
609
extern void *calloc (size_t __nmemb, size_t __size)
610
     __THROW __attribute_malloc__;
611
__END_NAMESPACE_STD
612
#endif
613
 
614
#ifndef __need_malloc_and_calloc
615
__BEGIN_NAMESPACE_STD
616
/* Re-allocate the previously allocated block
617
   in PTR, making the new block SIZE bytes long.  */
618
extern void *realloc (void *__ptr, size_t __size) __THROW __attribute_malloc__;
619
/* Free a block allocated by `malloc', `realloc' or `calloc'.  */
620
extern void free (void *__ptr) __THROW;
621
__END_NAMESPACE_STD
622
 
623
#ifdef  __USE_MISC
624
/* Free a block.  An alias for `free'.  (Sun Unices).  */
625
extern void cfree (void *__ptr) __THROW;
626
#endif /* Use misc.  */
627
 
628
#if defined __USE_GNU || defined __USE_BSD || defined __USE_MISC
629
# include <alloca.h>
630
#endif /* Use GNU, BSD, or misc.  */
631
 
632
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
633
/* Allocate SIZE bytes on a page boundary.  The storage cannot be freed.  */
634
extern void *valloc (size_t __size) __THROW __attribute_malloc__;
635
#endif
636
 
637
#ifdef __USE_XOPEN2K
638
/* Allocate memory of SIZE bytes with an alignment of ALIGNMENT.  */
639
extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
640
     __THROW __attribute_malloc__;
641
#if 0
642
/* Cope with autoconf's broken AC_FUNC_MALLOC macro, which
643
 * redefines malloc to rpl_malloc if it does not detect glibc
644
 * style returning-a-valid-pointer-for-malloc(0) behavior.  This
645
 * calls malloc() as usual, but if __size is zero, we allocate and
646
 * return a 1-byte block instead....  sigh... */
647
static __inline void *rpl_malloc (size_t __size)
648
{
649
    if (__size == 0) {
650
        __size++;
651
    }
652
    return malloc(__size);
653
}
654
#endif
655
#endif
656
 
657
__BEGIN_NAMESPACE_STD
658
/* Abort execution and generate a core-dump.  */
659
extern void abort (void) __THROW __attribute__ ((__noreturn__));
660
 
661
 
662
/* Register a function to be called when `exit' is called.  */
663
extern int atexit (void (*__func) (void)) __THROW;
664
__END_NAMESPACE_STD
665
 
666
#ifdef  __USE_MISC
667
/* Register a function to be called with the status
668
   given to `exit' and the given argument.  */
669
extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
670
     __THROW;
671
#endif
672
 
673
__BEGIN_NAMESPACE_STD
674
/* Call all functions registered with `atexit' and `on_exit',
675
   in the reverse of the order in which they were registered
676
   perform stdio cleanup, and terminate program execution with STATUS.  */
677
extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
678
__END_NAMESPACE_STD
679
 
680
#ifdef __USE_ISOC99
681
__BEGIN_NAMESPACE_C99
682
/* Terminate the program with STATUS without calling any of the
683
   functions registered with `atexit' or `on_exit'.  */
684
extern void _Exit (int __status) __THROW __attribute__ ((__noreturn__));
685
__END_NAMESPACE_C99
686
#endif
687
 
688
 
689
__BEGIN_NAMESPACE_STD
690
/* Return the value of envariable NAME, or NULL if it doesn't exist.  */
691
extern char *getenv (__const char *__name) __THROW;
692
__END_NAMESPACE_STD
693
 
694
/* This function is similar to the above but returns NULL if the
695
   programs is running with SUID or SGID enabled.  */
696
extern char *__secure_getenv (__const char *__name) __THROW;
697
 
698
#if defined __USE_SVID || defined __USE_XOPEN
699
/* The SVID says this is in <stdio.h>, but this seems a better place.   */
700
/* Put STRING, which is of the form "NAME=VALUE", in the environment.
701
   If there is no `=', remove NAME from the environment.  */
702
extern int putenv (char *__string) __THROW;
703
#endif
704
 
705
#if defined __USE_BSD || defined __USE_XOPEN2K
706
/* Set NAME to VALUE in the environment.
707
   If REPLACE is nonzero, overwrite an existing value.  */
708
extern int setenv (__const char *__name, __const char *__value, int __replace)
709
     __THROW;
710
 
711
/* Remove the variable NAME from the environment.  */
712
extern int unsetenv (__const char *__name) __THROW;
713
#endif
714
 
715
/* The following is used by uClibc in atexit.c and sysconf.c */
716
/* We have no limit when __UCLIBC_DYNAMIC_ATEXIT__ is enabled.  */
717
#ifdef __UCLIBC_DYNAMIC_ATEXIT__
718
# define __UCLIBC_MAX_ATEXIT     INT_MAX
719
#else
720
# define __UCLIBC_MAX_ATEXIT     20
721
#endif
722
 
723
 
724
#ifdef  __USE_MISC
725
/* The `clearenv' was planned to be added to POSIX.1 but probably
726
   never made it.  Nevertheless the POSIX.9 standard (POSIX bindings
727
   for Fortran 77) requires this function.  */
728
extern int clearenv (void) __THROW;
729
#endif
730
 
731
 
732
#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
733
/* Generate a unique temporary file name from TEMPLATE.
734
   The last six characters of TEMPLATE must be "XXXXXX";
735
   they are replaced with a string that makes the file name unique.
736
   Returns TEMPLATE, or a null pointer if it cannot get a unique file name.  */
737
extern char *mktemp (char *__template) __THROW;
738
 
739
/* Generate a unique temporary file name from TEMPLATE.
740
   The last six characters of TEMPLATE must be "XXXXXX";
741
   they are replaced with a string that makes the filename unique.
742
   Returns a file descriptor open on the file for reading and writing,
743
   or -1 if it cannot create a uniquely-named file.
744
 
745
   This function is a possible cancellation points and therefore not
746
   marked with __THROW.  */
747
# ifndef __USE_FILE_OFFSET64
748
extern int mkstemp (char *__template);
749
# else
750
#  ifdef __REDIRECT
751
extern int __REDIRECT (mkstemp, (char *__template), mkstemp64);
752
#  else
753
#   define mkstemp mkstemp64
754
#  endif
755
# endif
756
# ifdef __USE_LARGEFILE64
757
extern int mkstemp64 (char *__template);
758
# endif
759
#endif
760
 
761
#ifdef __USE_BSD
762
/* Create a unique temporary directory from TEMPLATE.
763
   The last six characters of TEMPLATE must be "XXXXXX";
764
   they are replaced with a string that makes the directory name unique.
765
   Returns TEMPLATE, or a null pointer if it cannot get a unique name.
766
   The directory is created mode 700.  */
767
extern char *mkdtemp (char *__template) __THROW;
768
#endif
769
 
770
 
771
__BEGIN_NAMESPACE_STD
772
/* Execute the given line as a shell command.
773
 
774
   This function is a cancellation point and therefore not marked with
775
   __THROW.  */
776
extern int system (__const char *__command);
777
__END_NAMESPACE_STD
778
 
779
 
780
#if 0
781
/*#ifdef        __USE_GNU*/
782
/* Return a malloc'd string containing the canonical absolute name of the
783
   named file.  The last file name component need not exist, and may be a
784
   symlink to a nonexistent file.  */
785
extern char *canonicalize_file_name (__const char *__name) __THROW;
786
#endif
787
 
788
#if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
789
/* Return the canonical absolute name of file NAME.  The last file name
790
   component need not exist, and may be a symlink to a nonexistent file.
791
   If RESOLVED is null, the result is malloc'd; otherwise, if the canonical
792
   name is PATH_MAX chars or more, returns null with `errno' set to
793
   ENAMETOOLONG; if the name fits in fewer than PATH_MAX chars, returns the
794
   name in RESOLVED.  */
795
extern char *realpath (__const char *__restrict __name,
796
                       char *__restrict __resolved) __THROW;
797
#endif
798
 
799
 
800
/* Shorthand for type of comparison functions.  */
801
#ifndef __COMPAR_FN_T
802
# define __COMPAR_FN_T
803
typedef int (*__compar_fn_t) (__const void *, __const void *);
804
 
805
# ifdef __USE_GNU
806
typedef __compar_fn_t comparison_fn_t;
807
# endif
808
#endif
809
 
810
__BEGIN_NAMESPACE_STD
811
/* Do a binary search for KEY in BASE, which consists of NMEMB elements
812
   of SIZE bytes each, using COMPAR to perform the comparisons.  */
813
extern void *bsearch (__const void *__key, __const void *__base,
814
                      size_t __nmemb, size_t __size, __compar_fn_t __compar);
815
 
816
/* Sort NMEMB elements of BASE, of SIZE bytes each,
817
   using COMPAR to perform the comparisons.  */
818
extern void qsort (void *__base, size_t __nmemb, size_t __size,
819
                   __compar_fn_t __compar);
820
 
821
 
822
/* Return the absolute value of X.  */
823
extern int abs (int __x) __THROW __attribute__ ((__const__));
824
extern long int labs (long int __x) __THROW __attribute__ ((__const__));
825
__END_NAMESPACE_STD
826
 
827
#ifdef __USE_ISOC99
828
__extension__ extern long long int llabs (long long int __x)
829
     __THROW __attribute__ ((__const__));
830
#endif
831
 
832
 
833
__BEGIN_NAMESPACE_STD
834
/* Return the `div_t', `ldiv_t' or `lldiv_t' representation
835
   of the value of NUMER over DENOM. */
836
/* GCC may have built-ins for these someday.  */
837
extern div_t div (int __numer, int __denom)
838
     __THROW __attribute__ ((__const__));
839
extern ldiv_t ldiv (long int __numer, long int __denom)
840
     __THROW __attribute__ ((__const__));
841
__END_NAMESPACE_STD
842
 
843
#ifdef __USE_ISOC99
844
__BEGIN_NAMESPACE_C99
845
__extension__ extern lldiv_t lldiv (long long int __numer,
846
                                    long long int __denom)
847
     __THROW __attribute__ ((__const__));
848
__END_NAMESPACE_C99
849
#endif
850
 
851
 
852
#if 0
853
#ifdef __UCLIBC_HAS_FLOATS__
854
#if defined __USE_SVID || defined __USE_XOPEN_EXTENDED
855
/* Convert floating point numbers to strings.  The returned values are
856
   valid only until another call to the same function.  */
857
 
858
/* Convert VALUE to a string with NDIGIT digits and return a pointer to
859
   this.  Set *DECPT with the position of the decimal character and *SIGN
860
   with the sign of the number.  */
861
extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
862
                   int *__restrict __sign) __THROW;
863
 
864
/* Convert VALUE to a string rounded to NDIGIT decimal digits.  Set *DECPT
865
   with the position of the decimal character and *SIGN with the sign of
866
   the number.  */
867
extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
868
                   int *__restrict __sign) __THROW;
869
 
870
/* If possible convert VALUE to a string with NDIGIT significant digits.
871
   Otherwise use exponential representation.  The resulting string will
872
   be written to BUF.  */
873
extern char *gcvt (double __value, int __ndigit, char *__buf) __THROW;
874
 
875
 
876
# ifdef __USE_MISC
877
/* Long double versions of above functions.  */
878
extern char *qecvt (long double __value, int __ndigit,
879
                    int *__restrict __decpt, int *__restrict __sign) __THROW;
880
extern char *qfcvt (long double __value, int __ndigit,
881
                    int *__restrict __decpt, int *__restrict __sign) __THROW;
882
extern char *qgcvt (long double __value, int __ndigit, char *__buf) __THROW;
883
 
884
 
885
/* Reentrant version of the functions above which provide their own
886
   buffers.  */
887
extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
888
                   int *__restrict __sign, char *__restrict __buf,
889
                   size_t __len) __THROW;
890
extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
891
                   int *__restrict __sign, char *__restrict __buf,
892
                   size_t __len) __THROW;
893
 
894
extern int qecvt_r (long double __value, int __ndigit,
895
                    int *__restrict __decpt, int *__restrict __sign,
896
                    char *__restrict __buf, size_t __len) __THROW;
897
extern int qfcvt_r (long double __value, int __ndigit,
898
                    int *__restrict __decpt, int *__restrict __sign,
899
                    char *__restrict __buf, size_t __len) __THROW;
900
# endif /* misc */
901
#endif  /* use MISC || use X/Open Unix */
902
#endif /* __UCLIBC_HAS_FLOATS__ */
903
#endif
904
 
905
 
906
#ifdef __UCLIBC_HAS_WCHAR__
907
__BEGIN_NAMESPACE_STD
908
/* Return the length of the multibyte character
909
   in S, which is no longer than N.  */
910
extern int mblen (__const char *__s, size_t __n) __THROW;
911
/* Return the length of the given multibyte character,
912
   putting its `wchar_t' representation in *PWC.  */
913
extern int mbtowc (wchar_t *__restrict __pwc,
914
                   __const char *__restrict __s, size_t __n) __THROW;
915
/* Put the multibyte character represented
916
   by WCHAR in S, returning its length.  */
917
extern int wctomb (char *__s, wchar_t __wchar) __THROW;
918
 
919
 
920
/* Convert a multibyte string to a wide char string.  */
921
extern size_t mbstowcs (wchar_t *__restrict  __pwcs,
922
                        __const char *__restrict __s, size_t __n) __THROW;
923
/* Convert a wide char string to multibyte string.  */
924
extern size_t wcstombs (char *__restrict __s,
925
                        __const wchar_t *__restrict __pwcs, size_t __n)
926
     __THROW;
927
__END_NAMESPACE_STD
928
#endif /* __UCLIBC_HAS_WCHAR__ */
929
 
930
 
931
#ifdef __USE_SVID
932
/* Determine whether the string value of RESPONSE matches the affirmation
933
   or negative response expression as specified by the LC_MESSAGES category
934
   in the program's current locale.  Returns 1 if affirmative, 0 if
935
   negative, and -1 if not matching.  */
936
extern int rpmatch (__const char *__response) __THROW;
937
#endif
938
 
939
 
940
#ifdef __USE_XOPEN_EXTENDED
941
/* Parse comma separated suboption from *OPTIONP and match against
942
   strings in TOKENS.  If found return index and set *VALUEP to
943
   optional value introduced by an equal sign.  If the suboption is
944
   not part of TOKENS return in *VALUEP beginning of unknown
945
   suboption.  On exit *OPTIONP is set to the beginning of the next
946
   token or at the terminating NUL character.  */
947
extern int getsubopt (char **__restrict __optionp,
948
                      char *__const *__restrict __tokens,
949
                      char **__restrict __valuep) __THROW;
950
#endif
951
 
952
 
953
#ifdef __USE_XOPEN
954
/* Setup DES tables according KEY.  */
955
extern void setkey (__const char *__key) __THROW;
956
#endif
957
 
958
 
959
/* X/Open pseudo terminal handling.  */
960
 
961
#ifdef __USE_XOPEN2K
962
/* Return a master pseudo-terminal handle.  */
963
extern int posix_openpt (int __oflag) __THROW;
964
#endif
965
 
966
#ifdef __USE_XOPEN
967
/* The next four functions all take a master pseudo-tty fd and
968
   perform an operation on the associated slave:  */
969
 
970
/* Chown the slave to the calling user.  */
971
extern int grantpt (int __fd) __THROW;
972
 
973
/* Release an internal lock so the slave can be opened.
974
   Call after grantpt().  */
975
extern int unlockpt (int __fd) __THROW;
976
 
977
/* Return the pathname of the pseudo terminal slave assoicated with
978
   the master FD is open on, or NULL on errors.
979
   The returned storage is good until the next call to this function.  */
980
extern char *ptsname (int __fd) __THROW;
981
#endif
982
 
983
#ifdef __USE_GNU
984
/* Store at most BUFLEN characters of the pathname of the slave pseudo
985
   terminal associated with the master FD is open on in BUF.
986
   Return 0 on success, otherwise an error number.  */
987
#if 0
988
extern int ptsname_r (int __fd, char *__buf, size_t __buflen) __THROW;
989
#endif
990
 
991
/* Open a master pseudo terminal and return its file descriptor.  */
992
extern int getpt (void) __THROW;
993
#endif
994
 
995
#ifdef __USE_BSD
996
/* Put the 1 minute, 5 minute and 15 minute load averages into the first
997
   NELEM elements of LOADAVG.  Return the number written (never more than
998
   three, but may be less than NELEM), or -1 if an error occurred.  */
999
extern int getloadavg (double __loadavg[], int __nelem) __THROW;
1000
#endif
1001
 
1002
#endif /* don't just need malloc and calloc */
1003
#undef __need_malloc_and_calloc
1004
 
1005
__END_DECLS
1006
 
1007
#endif /* stdlib.h  */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.