source: src/libcfa/stdlib@ 17e5e2b

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 17e5e2b was 17e5e2b, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Added proper include guards to cfa headers so they can be added to the c++ include path without issues

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