]> pd.if.org Git - pdclib/blob - includes/stdlib.h
exit() and its macros were added a bit hasty; fixed.
[pdclib] / includes / stdlib.h
1 /* $Id$ */
2
3 /* Release $Name$ */
4
5 /* General utilities <stdlib.h>
6
7    This file is part of the Public Domain C Library (PDCLib).
8    Permission is granted to use, modify, and / or redistribute at will.
9 */
10
11 #ifndef _PDCLIB_STDLIB_H
12 #define _PDCLIB_STDLIB_H _PDCLIB_STDLIB_H
13
14 #ifndef _PDCLIB_INT_H
15 #define _PDCLIB_INT_H _PDCLIB_INT_H
16 #include <_PDCLIB_int.h>
17 #endif
18
19 typedef struct _PDCLIB_div_t     div_t;
20 typedef struct _PDCLIB_ldiv_t   ldiv_t;
21 typedef struct _PDCLIB_lldiv_t lldiv_t;
22
23 #ifndef _PDCLIB_SIZE_T_DEFINED
24 #define _PDCLIB_SIZE_T_DEFINED _PDCLIB_SIZE_T_DEFINED
25 typedef _PDCLIB_size_t size_t;
26 #endif
27
28 #define NULL         _PDCLIB_NULL
29 #define EXIT_SUCCESS _PDCLIB_SUCCESS
30 #define EXIT_FAILURE _PDCLIB_FAILURE
31
32 /* Numeric conversion functions */
33
34 int atoi( const char * nptr );
35 long int atol( const char * nptr );
36 long long int atoll( const char * nptr );
37
38 long int strtol( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
39 long long int strtoll( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
40 unsigned long int strtoul( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
41 unsigned long long int strtoull( const char * _PDCLIB_restrict nptr, char * * _PDCLIB_restrict endptr, int base );
42
43 /* Pseudo-random sequence generation functions */
44
45 extern unsigned long int _PDCLIB_seed;
46
47 #define RAND_MAX 32767
48
49 int rand();
50 void srand( unsigned int seed );
51
52 /* Memory management functions */
53
54
55 /* Communication with the environment */
56
57 void abort();
58 void exit( int status );
59
60 /* Searching and sorting */
61
62 void * bsearch( const void * key, const void * base, size_t nmemb, size_t size, int (*compar)( const void *, const void * ) );
63 void qsort( void * base, size_t nmemb, size_t size, int (*compar)( const void *, const void * ) );
64
65 /* Integer arithmetic functions */
66
67 int abs( int j );
68 long int labs( long int j );
69 long long int llabs( long long int j );
70
71 div_t div( int numer, int denom );
72 ldiv_t ldiv( long int numer, long int denom );
73 lldiv_t lldiv( long long int numer, long long int denom );
74
75 /* Multibyte / wide character conversion functions */
76
77 /* TODO: Macro MB_CUR_MAX */
78
79 /* Multibyte / wide string conversion functions */
80
81
82 #endif