2 ** Copyright 2002-2003, Travis Geiselbrecht. All rights reserved.
3 ** Copyright 2002, Manuel J. Petit. All rights reserved.
4 ** Distributed under the terms of the NewOS License.
7 #ifndef __newos__libc_stdlib__hh__
8 # define __newos__libc_stdlib__hh__
23 int atoi(char const *);
24 unsigned int atoui(const char *num
);
25 long atol(const char *num
);
26 unsigned long atoul(const char *num
);
28 long strtol(const char *nptr
, char **endptr
, int base
);
29 unsigned long strtoul(const char *nptr
, char **endptr
, int base
);
31 void * malloc(size_t);
33 void * realloc(void *, size_t);
34 void * calloc(size_t, size_t);
36 char *getenv(char const *);
38 void *bsearch(void const *, void const *, size_t, size_t, int (*) (void const *, void const *));
39 void qsort(void *, size_t, size_t, int (*)(void const *, void const *));
41 # define RAND_MAX 0x7fffffff
55 /* terrible hack to get around the different kernel name for malloc and free */
57 # define malloc kmalloc
59 # include <kernel/heap.h>
62 # define max(a, b) ((a) > (b) ? (a) : (b))
63 # define min(a, b) ((a) < (b) ? (a) : (b))
65 // non (C++) standard stuff goes here
69 // define size_t to be correct in C++
70 # define size_t ::std::size_t
73 int setenv(char const *, char const *, int);
74 int putenv(char const *);
75 void unsetenv(char const *);
77 int heapsort(void *, size_t , size_t , int (*)(void const *, void const *));
78 int mergesort(void *, size_t, size_t, int (*)(void const *, void const *));
79 int radixsort(unsigned char const **, int, unsigned char const *, unsigned int);
80 int sradixsort(unsigned char const **, int, unsigned char const *, unsigned int);
82 void * reallocf(void *, size_t);
83 void * memalign(size_t, size_t);
84 void * valloc(size_t);
86 long long strtoll(const char *nptr
, char **endptr
, int base
);
87 unsigned long long strtoull(const char *nptr
, char **endptr
, int base
);
89 /* getopt related items */
96 int getopt(int argc
, char * const *argv
, const char *optstring
);
98 int rand_r(unsigned int *ctx
);
100 void srandom(unsigned long);
111 #endif // end of include gaurd
113 #if defined(__cplusplus) && !defined(_NEWOS_NO_LIBC_COMPAT)
115 //using ::std::atexit;
119 //using ::std::system;
123 using ::std::realloc
;
129 //using ::std::mblen;
130 //using ::std::mbstowcs;
131 //using ::std::mbtowc;
132 //using ::std::strtod;
134 using ::std::strtoul
;
135 //using ::std::wctomb;
136 //using ::std::wcstombs;
138 using ::std::bsearch
;