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