source: src/libcfa/stdlib@ d3a85240

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since d3a85240 was d3a85240, checked in by Rob Schluntz <rschlunt@…>, 9 years ago

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

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