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