source: src/libcfa/stdlib @ a9f2c13

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since a9f2c13 was a9f2c13, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

add polymorphic clamp routine to stdlib

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