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