]> pd.if.org Git - pdclib/blob - includes/stdlib.h
Added missing float.h. Some touches.
[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 // ----------------------------------------------------------------------------
14 // MACROS
15
16 #define EXIT_FAILURE // TODO
17 #define EXIT_SUCCESS // TODO
18 #define MB_CUR_MAX   // TODO
19 #define NULL         0
20 #define RAND_MAX     // TODO
21
22 // ----------------------------------------------------------------------------
23 // TYPEDEFS
24
25 typedef struct
26 {
27     int quotient;
28     int remainder;
29 } div_t;
30
31 typedef struct
32 {
33     long quotient;
34     long remainder;
35 } ldiv_t;
36
37 typedef struct
38 {   long long quotient;
39     long long remainder;
40 } lldiv_t;
41
42 typedef size_t; // TODO
43
44 #ifndef __cplusplus
45 typedef wchar_t; // TODO
46 #endif // __cplusplus
47
48 // ----------------------------------------------------------------------------
49 // FUNCTIONS - C++
50
51 #ifdef __cplusplus
52
53 long abs( long i );
54 long long abs( long long i );
55
56 ldiv_t div( long numer, long denom );
57 lldiv_t div( long long numer, long long denom );
58
59 #endif // __cplusplus
60
61 // ----------------------------------------------------------------------------
62 // FUNCTIONS - Standard C
63
64 int abs( int i );
65 long long llabs( long long i );
66 long labs( long i );
67
68 div_t div( int numer, int denom );
69 lldiv_t lldiv( long long numer, long long denom );
70 ldiv_t ldiv( long numer, long denom );
71
72 int rand( void );
73 void srand( unsigned int seed );
74
75 double atof( const char * s );
76 int atoi( const char * s );
77 long atol( const char * s );
78 long long atoll( const char * s);
79
80 double strtod( const char * restrict s, char * * restrict endptr );
81 float strtof( const char * restrict s, char * * restrict endptr );
82 long double strtold( const char * restrict s, char * * restrict endptr );
83
84 long long strtoll( const char * restrict s, char * * restrict endptr, int base );
85 unsigned long long strtoull( const char * restrict s, char * * restrict endptr, int base);
86
87 long strtol( const char * restrict s, char * * restrict endptr, int base );
88 unsigned long strtoul( const char * restrict s, char * * restrict endptr, int base);
89
90 void * calloc( size_t nelem, size_t size );
91 void free( void * ptr );
92 void * malloc( size_t size );
93 void * realloc( void * ptr, size_t size );
94
95 int mblen( const char * s, size_t n );
96 size_t mbstowcs( wchar_t * restrict wcs, const char * restrict s, size_t n );
97 int mbtowc( wchar_t * restrict pwc, const char * restrict s, size_t n );
98 size_t wcstombs( char * restrict s, const wchar_t * restrict wcs, size_t n );
99 int wctomb( char * s, wchar_t wchar );
100
101 void _Exit( int status );
102 void exit( int status );
103 void abort( void );
104 char * getenv( const char * name );
105 int system( const char * s );
106
107 #ifdef __cplusplus
108 #define __cppwrapper( x ) extern "C++" x \
109 extern "C" x
110 #else
111 #define __cppwrapper( x ) x
112 #endif // __cplusplus
113
114 __cppwrapper( int atexit( void (*func) ( void ) ) { /* TODO */ }; )
115 __cppwrapper( void * bsearch( const void * key, const void * base, size_t nelem, size_t size, int (*cmp) ( const void * ck, const void * ce) ) { /* TODO */ }; )
116 __cppwrapper( void qsort( void * base, size_t nelem, size_t size, int (*cmp) ( const void * e1, const void * e2) ) { /* TODO */ }; )
117
118 #endif // __STDLIB_H