source: src/libcfa/stdlib @ f3ddc21

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since f3ddc21 was f3ddc21, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

add polymorphic abs routine and code formatting

  • Property mode set to 100644
File size: 4.8 KB
Line 
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 : Tue May  9 08:42:44 2017
13// Update Count     : 107
14//
15
16#ifndef STDLIB_H
17#define STDLIB_H
18
19//---------------------------------------
20
21extern "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
30extern "C" { void * malloc( size_t ); }                                 // use default C routine for void *
31forall( dtype T | sized(T) ) T * malloc( void );
32forall( dtype T | sized(T) ) T * malloc( char fill );
33forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size );
34forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill );
35extern "C" { void * calloc( size_t nmemb, size_t size ); } // use default C routine for void *
36forall( dtype T | sized(T) ) T * calloc( size_t nmemb );
37extern "C" { void * realloc( void * ptr, size_t size ); } // use default C routine for void *
38forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size );
39forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill );
40
41forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment );
42forall( dtype T | sized(T) ) T * memalign( size_t alignment );          // deprecated
43forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment );
44
45extern "C" {
46void * memset( void * ptr, int fill, size_t size );
47void free( void * ptr );
48} // extern "C"
49
50forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) T * new( Params p );
51forall( dtype T | { void ^?{}(T *); } ) void delete( T * ptr );
52forall( dtype T, ttype Params | { void ^?{}(T *); void delete(Params); } ) void delete( T * ptr, Params rest );
53
54//---------------------------------------
55
56int ato( const char * ptr );
57unsigned int ato( const char * ptr );
58long int ato( const char * ptr );
59unsigned long int ato( const char * ptr );
60long long int ato( const char * ptr );
61unsigned long long int ato( const char * ptr );
62float ato( const char * ptr );
63double ato( const char * ptr );
64long double ato( const char * ptr );
65float _Complex ato( const char * ptr );
66double _Complex ato( const char * ptr );
67long double _Complex ato( const char * ptr );
68
69int strto( const char * sptr, char ** eptr, int base );
70unsigned int strto( const char * sptr, char ** eptr, int base );
71long int strto( const char * sptr, char ** eptr, int base );
72unsigned long int strto( const char * sptr, char ** eptr, int base );
73long long int strto( const char * sptr, char ** eptr, int base );
74unsigned long long int strto( const char * sptr, char ** eptr, int base );
75float strto( const char * sptr, char ** eptr );
76double strto( const char * sptr, char ** eptr );
77long double strto( const char * sptr, char ** eptr );
78float _Complex strto( const char * sptr, char ** eptr );
79double _Complex strto( const char * sptr, char ** eptr );
80long double _Complex strto( const char * sptr, char ** eptr );
81
82//---------------------------------------
83
84forall( otype T | { int ?<?( T, T ); } )
85T * bsearch( T key, const T * arr, size_t dimension );
86
87forall( otype T | { int ?<?( T, T ); } )
88unsigned int bsearch( T key, const T * arr, size_t dimension );
89
90
91forall( otype T | { int ?<?( T, T ); } )
92void qsort( const T * arr, size_t dimension );
93
94//---------------------------------------
95
96forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )
97[ T, T ] div( T t1, T t2 );
98
99//---------------------------------------
100
101unsigned char abs( signed char );
102extern "C" { int abs( int ); }                                                  // use default C routine for int
103unsigned long int abs( long int );
104unsigned long long int abs( long long int );
105float abs( float );
106double abs( double );
107long double abs( long double );
108float abs( float _Complex );
109double abs( double _Complex );
110long double abs( long double _Complex );
111forall ( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )
112T abs( T );
113
114//---------------------------------------
115
116void rand48seed( long int s );
117char rand48();
118int rand48();
119unsigned int rand48();
120long int rand48();
121unsigned long int rand48();
122float rand48();
123double rand48();
124float _Complex rand48();
125double _Complex rand48();
126long double _Complex rand48();
127
128//---------------------------------------
129
130forall( otype T | { int ?<?( T, T ); } )
131T min( T t1, T t2 );
132
133forall( otype T | { int ?>?( T, T ); } )
134T max( T t1, T t2 );
135
136forall( otype T | { T min( T, T ); T max( T, T ); } )
137T clamp( T value, T min_val, T max_val );
138
139forall( otype T )
140void swap( T * t1, T * t2 );
141
142#endif // STDLIB_H
143
144// Local Variables: //
145// mode: c //
146// tab-width: 4 //
147// End: //
Note: See TracBrowser for help on using the repository browser.