| 1 | // | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo | 
|---|
| 3 | // | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
| 5 | // file "LICENCE" distributed with Cforall. | 
|---|
| 6 | // | 
|---|
| 7 | // stdlib -- | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Peter A. Buhr | 
|---|
| 10 | // Created On       : Thu Jan 28 17:12:35 2016 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr | 
|---|
| 12 | // Last Modified On : Wed May 24 18:06:27 2017 | 
|---|
| 13 | // Update Count     : 115 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #ifndef STDLIB_H | 
|---|
| 17 | #define STDLIB_H | 
|---|
| 18 |  | 
|---|
| 19 | //--------------------------------------- | 
|---|
| 20 |  | 
|---|
| 21 | extern "C" { | 
|---|
| 22 | #ifndef EXIT_FAILURE | 
|---|
| 23 | #define EXIT_FAILURE    1                                                               // failing exit status | 
|---|
| 24 | #define EXIT_SUCCESS    0                                                               // successful exit status | 
|---|
| 25 | #endif // ! EXIT_FAILURE | 
|---|
| 26 | } // extern "C" | 
|---|
| 27 |  | 
|---|
| 28 | //--------------------------------------- | 
|---|
| 29 |  | 
|---|
| 30 | forall( dtype T | sized(T) ) T * malloc( void ); | 
|---|
| 31 | forall( dtype T | sized(T) ) T * malloc( char fill ); | 
|---|
| 32 | forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ); | 
|---|
| 33 | forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill ); | 
|---|
| 34 | extern "C" { void * calloc( size_t nmemb, size_t size ); } // use default C routine for void * | 
|---|
| 35 | forall( dtype T | sized(T) ) T * calloc( size_t nmemb ); | 
|---|
| 36 | extern "C" { void * realloc( void * ptr, size_t size ); } // use default C routine for void * | 
|---|
| 37 | forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ); | 
|---|
| 38 | forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ); | 
|---|
| 39 |  | 
|---|
| 40 | forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ); | 
|---|
| 41 | forall( dtype T | sized(T) ) T * memalign( size_t alignment );          // deprecated | 
|---|
| 42 | forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ); | 
|---|
| 43 |  | 
|---|
| 44 | forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) T * new( Params p ); | 
|---|
| 45 | forall( dtype T | { void ^?{}(T *); } ) void delete( T * ptr ); | 
|---|
| 46 | forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } ) void delete( T * ptr, Params rest ); | 
|---|
| 47 |  | 
|---|
| 48 | //--------------------------------------- | 
|---|
| 49 |  | 
|---|
| 50 | int ato( const char * ptr ); | 
|---|
| 51 | unsigned int ato( const char * ptr ); | 
|---|
| 52 | long int ato( const char * ptr ); | 
|---|
| 53 | unsigned long int ato( const char * ptr ); | 
|---|
| 54 | long long int ato( const char * ptr ); | 
|---|
| 55 | unsigned long long int ato( const char * ptr ); | 
|---|
| 56 | float ato( const char * ptr ); | 
|---|
| 57 | double ato( const char * ptr ); | 
|---|
| 58 | long double ato( const char * ptr ); | 
|---|
| 59 | float _Complex ato( const char * ptr ); | 
|---|
| 60 | double _Complex ato( const char * ptr ); | 
|---|
| 61 | long double _Complex ato( const char * ptr ); | 
|---|
| 62 |  | 
|---|
| 63 | int strto( const char * sptr, char ** eptr, int base ); | 
|---|
| 64 | unsigned int strto( const char * sptr, char ** eptr, int base ); | 
|---|
| 65 | long int strto( const char * sptr, char ** eptr, int base ); | 
|---|
| 66 | unsigned long int strto( const char * sptr, char ** eptr, int base ); | 
|---|
| 67 | long long int strto( const char * sptr, char ** eptr, int base ); | 
|---|
| 68 | unsigned long long int strto( const char * sptr, char ** eptr, int base ); | 
|---|
| 69 | float strto( const char * sptr, char ** eptr ); | 
|---|
| 70 | double strto( const char * sptr, char ** eptr ); | 
|---|
| 71 | long double strto( const char * sptr, char ** eptr ); | 
|---|
| 72 | float _Complex strto( const char * sptr, char ** eptr ); | 
|---|
| 73 | double _Complex strto( const char * sptr, char ** eptr ); | 
|---|
| 74 | long double _Complex strto( const char * sptr, char ** eptr ); | 
|---|
| 75 |  | 
|---|
| 76 | //--------------------------------------- | 
|---|
| 77 |  | 
|---|
| 78 | forall( otype T | { int ?<?( T, T ); } ) | 
|---|
| 79 | T * bsearch( T key, const T * arr, size_t dimension ); | 
|---|
| 80 |  | 
|---|
| 81 | forall( otype T | { int ?<?( T, T ); } ) | 
|---|
| 82 | unsigned int bsearch( T key, const T * arr, size_t dimension ); | 
|---|
| 83 |  | 
|---|
| 84 |  | 
|---|
| 85 | forall( otype T | { int ?<?( T, T ); } ) | 
|---|
| 86 | void qsort( const T * arr, size_t dimension ); | 
|---|
| 87 |  | 
|---|
| 88 | //--------------------------------------- | 
|---|
| 89 |  | 
|---|
| 90 | forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } ) | 
|---|
| 91 | [ T, T ] div( T t1, T t2 ); | 
|---|
| 92 |  | 
|---|
| 93 | //--------------------------------------- | 
|---|
| 94 |  | 
|---|
| 95 | unsigned char abs( signed char ); | 
|---|
| 96 | extern "C" { int abs( int ); }                                                  // use default C routine for int | 
|---|
| 97 | unsigned long int abs( long int ); | 
|---|
| 98 | unsigned long long int abs( long long int ); | 
|---|
| 99 | float abs( float ); | 
|---|
| 100 | double abs( double ); | 
|---|
| 101 | long double abs( long double ); | 
|---|
| 102 | float abs( float _Complex ); | 
|---|
| 103 | double abs( double _Complex ); | 
|---|
| 104 | long double abs( long double _Complex ); | 
|---|
| 105 | forall( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } ) | 
|---|
| 106 | T abs( T ); | 
|---|
| 107 |  | 
|---|
| 108 | //--------------------------------------- | 
|---|
| 109 |  | 
|---|
| 110 | void rand48seed( long int s ); | 
|---|
| 111 | char rand48( void ); | 
|---|
| 112 | int rand48( void ); | 
|---|
| 113 | unsigned int rand48( void ); | 
|---|
| 114 | long int rand48( void ); | 
|---|
| 115 | unsigned long int rand48( void ); | 
|---|
| 116 | float rand48( void ); | 
|---|
| 117 | double rand48( void ); | 
|---|
| 118 | float _Complex rand48( void ); | 
|---|
| 119 | double _Complex rand48( void ); | 
|---|
| 120 | long double _Complex rand48( void ); | 
|---|
| 121 |  | 
|---|
| 122 | //--------------------------------------- | 
|---|
| 123 |  | 
|---|
| 124 | forall( otype T | { int ?<?( T, T ); } ) | 
|---|
| 125 | T min( T t1, T t2 ); | 
|---|
| 126 |  | 
|---|
| 127 | forall( otype T | { int ?>?( T, T ); } ) | 
|---|
| 128 | T max( T t1, T t2 ); | 
|---|
| 129 |  | 
|---|
| 130 | forall( otype T | { T min( T, T ); T max( T, T ); } ) | 
|---|
| 131 | T clamp( T value, T min_val, T max_val ); | 
|---|
| 132 |  | 
|---|
| 133 | forall( otype T ) | 
|---|
| 134 | void swap( T * t1, T * t2 ); | 
|---|
| 135 |  | 
|---|
| 136 | #endif // STDLIB_H | 
|---|
| 137 |  | 
|---|
| 138 | // Local Variables: // | 
|---|
| 139 | // mode: c // | 
|---|
| 140 | // tab-width: 4 // | 
|---|
| 141 | // End: // | 
|---|