]> pd.if.org Git - pdclib/blob - includes/stdlib.h
500060ce82f942ff21ee510ecac984390b6c7767
[pdclib] / includes / stdlib.h
1 // ----------------------------------------------------------------------------
2 // $Id$
3 // ----------------------------------------------------------------------------
4 // Public Domain C Library - http://pdclib.sourceforge.net
5 // This code is Public Domain. Use, modify, and redistribute at will.
6 // ----------------------------------------------------------------------------
7 // General utilities
8 // ----------------------------------------------------------------------------
9
10 #ifndef __STDLIB_H
11 #define __STDLIB_H __STDLIB_H
12
13 // TODO: Documentation
14
15 // ----------------------------------------------------------------------------
16 // MACROS
17
18 #include "__NULL.h"
19
20 #define EXIT_FAILURE // TODO
21 #define EXIT_SUCCESS // TODO
22 #define MB_CUR_MAX   // TODO
23 #define RAND_MAX     // TODO
24
25 // ----------------------------------------------------------------------------
26 // TYPEDEFS
27
28 typedef struct
29 {
30     int quotient;
31     int remainder;
32 } div_t;
33
34 typedef struct
35 {
36     long quotient;
37     long remainder;
38 } ldiv_t;
39
40 typedef struct
41 {   long long quotient;
42     long long remainder;
43 } lldiv_t;
44
45 #include "__size_t.h"
46 #include "__wchar_t.h"
47
48 // ----------------------------------------------------------------------------
49 // FUNCTIONS
50
51 int abs( int i );
52 long long llabs( long long i );
53 long labs( long i );
54
55 div_t div( int numer, int denom );
56 lldiv_t lldiv( long long numer, long long denom );
57 ldiv_t ldiv( long numer, long denom );
58
59 int rand( void );
60 void srand( unsigned int seed );
61
62 double atof( const char * s );
63 int atoi( const char * s );
64 long atol( const char * s );
65 long long atoll( const char * s);
66
67 double strtod( const char * restrict s, char * * restrict endptr );
68 float strtof( const char * restrict s, char * * restrict endptr );
69 long double strtold( const char * restrict s, char * * restrict endptr );
70
71 long long strtoll( const char * restrict s, char * * restrict endptr, int base );
72 unsigned long long strtoull( const char * restrict s, char * * restrict endptr, int base);
73
74 long strtol( const char * restrict s, char * * restrict endptr, int base );
75 unsigned long strtoul( const char * restrict s, char * * restrict endptr, int base);
76
77 void * calloc( size_t nelem, size_t size );
78 void free( void * ptr );
79 void * malloc( size_t size );
80 void * realloc( void * ptr, size_t size );
81
82 int mblen( const char * s, size_t n );
83 size_t mbstowcs( wchar_t * restrict wcs, const char * restrict s, size_t n );
84 int mbtowc( wchar_t * restrict pwc, const char * restrict s, size_t n );
85 size_t wcstombs( char * restrict s, const wchar_t * restrict wcs, size_t n );
86 int wctomb( char * s, wchar_t wchar );
87
88 void _Exit( int status );
89 void exit( int status );
90 void abort( void );
91 char * getenv( const char * name );
92 int system( const char * s );
93
94 int atexit( void (*func) ( void ) );
95 void * bsearch( const void * key, const void * base, size_t nelem, size_t size, int (*cmp) ( const void * ck, const void * ce) );
96 void qsort( void * base, size_t nelem, size_t size, int (*cmp) ( const void * e1, const void * e2) );
97
98 #endif // __STDLIB_H