1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
8 // ----------------------------------------------------------------------------
11 #define __STDLIB_H __STDLIB_H
13 // TODO: Documentation, C++ handling
15 // ----------------------------------------------------------------------------
18 #define EXIT_FAILURE // TODO
19 #define EXIT_SUCCESS // TODO
20 #define MB_CUR_MAX // TODO
22 #define RAND_MAX // TODO
24 // ----------------------------------------------------------------------------
44 typedef size_t; // TODO - personality?
47 typedef wchar_t; // TODO - personality?
50 // ----------------------------------------------------------------------------
56 long long abs( long long i );
58 ldiv_t div( long numer, long denom );
59 lldiv_t div( long long numer, long long denom );
63 // ----------------------------------------------------------------------------
64 // FUNCTIONS - Standard C
67 long long llabs( long long i );
70 div_t div( int numer, int denom );
71 lldiv_t lldiv( long long numer, long long denom );
72 ldiv_t ldiv( long numer, long denom );
75 void srand( unsigned int seed );
77 double atof( const char * s );
78 int atoi( const char * s );
79 long atol( const char * s );
80 long long atoll( const char * s);
82 double strtod( const char * restrict s, char * * restrict endptr );
83 float strtof( const char * restrict s, char * * restrict endptr );
84 long double strtold( const char * restrict s, char * * restrict endptr );
86 long long strtoll( const char * restrict s, char * * restrict endptr, int base );
87 unsigned long long strtoull( const char * restrict s, char * * restrict endptr, int base);
89 long strtol( const char * restrict s, char * * restrict endptr, int base );
90 unsigned long strtoul( const char * restrict s, char * * restrict endptr, int base);
92 void * calloc( size_t nelem, size_t size );
93 void free( void * ptr );
94 void * malloc( size_t size );
95 void * realloc( void * ptr, size_t size );
97 int mblen( const char * s, size_t n );
98 size_t mbstowcs( wchar_t * restrict wcs, const char * restrict s, size_t n );
99 int mbtowc( wchar_t * restrict pwc, const char * restrict s, size_t n );
100 size_t wcstombs( char * restrict s, const wchar_t * restrict wcs, size_t n );
101 int wctomb( char * s, wchar_t wchar );
103 void _Exit( int status );
104 void exit( int status );
106 char * getenv( const char * name );
107 int system( const char * s );
110 #define __cppwrapper( x ) extern "C++" x \
113 #define __cppwrapper( x ) x
114 #endif // __cplusplus
116 __cppwrapper( int atexit( void (*func) ( void ) ) { /* TODO */ }; )
117 __cppwrapper( void * bsearch( const void * key, const void * base, size_t nelem, size_t size, int (*cmp) ( const void * ck, const void * ce) ) { /* TODO */ }; )
118 __cppwrapper( void qsort( void * base, size_t nelem, size_t size, int (*cmp) ( const void * e1, const void * e2) ) { /* TODO */ }; )