Changeset 59239b8
- Timestamp:
- Jan 30, 2017, 12:29:29 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 1e6e231a
- Parents:
- f97b614
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/stdlib
rf97b614 r59239b8 29 29 30 30 extern "C" { void * malloc( size_t ); } // use default C routine for void * 31 forall( otype T) T * malloc( void );32 forall( otype T) T * malloc( char fill );33 forall( otype T) T * malloc( T * ptr, size_t size );34 forall( otype T) T * malloc( T * ptr, size_t size, unsigned char fill );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 ); 35 35 extern "C" { void * calloc( size_t nmemb, size_t size ); } // use default C routine for void * 36 forall( otype T) T * calloc( size_t nmemb );36 forall( dtype T | sized(T) ) T * calloc( size_t nmemb ); 37 37 extern "C" { void * realloc( void * ptr, size_t size ); } // use default C routine for void * 38 forall( otype T) T * realloc( T * ptr, size_t size );39 forall( otype T) T * realloc( T * ptr, size_t size, unsigned char fill );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 ); 40 40 41 forall( otype T) T * aligned_alloc( size_t alignment );42 forall( otype T) T * memalign( size_t alignment ); // deprecated43 forall( otype T) int posix_memalign( T ** ptr, size_t alignment );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 ); 44 44 45 45 extern "C" { … … 48 48 } // extern "C" 49 49 50 forall( otype T, ttype Params| { void ?{}(T *, Params); } ) T * new( Params p );50 forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) T * new( Params p ); 51 51 forall( dtype T | { void ^?{}(T *); } ) void delete( T * ptr ); 52 52 -
src/libcfa/stdlib.c
rf97b614 r59239b8 27 27 } // extern "C" 28 28 29 forall( otype T) T * malloc( void ) {29 forall( dtype T | sized(T) ) T * malloc( void ) { 30 30 //printf( "malloc1\n" ); 31 31 return (T *)malloc( sizeof(T) ); 32 32 } // malloc 33 forall( otype T) T * malloc( char fill ) {33 forall( dtype T | sized(T) ) T * malloc( char fill ) { 34 34 //printf( "malloc3\n" ); 35 35 T * ptr = (T *)malloc( sizeof(T) ); … … 37 37 } // malloc 38 38 39 forall( otype T) T * calloc( size_t nmemb ) {39 forall( dtype T | sized(T) ) T * calloc( size_t nmemb ) { 40 40 //printf( "calloc\n" ); 41 41 return (T *)calloc( nmemb, sizeof(T) ); 42 42 } // calloc 43 43 44 forall( otype T) T * realloc( T * ptr, size_t size ) {44 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size ) { 45 45 //printf( "realloc1\n" ); 46 46 return (T *)(void *)realloc( (void *)ptr, size ); 47 47 } // realloc 48 forall( otype T) T * realloc( T * ptr, size_t size, unsigned char fill ) {48 forall( dtype T | sized(T) ) T * realloc( T * ptr, size_t size, unsigned char fill ) { 49 49 //printf( "realloc2\n" ); 50 50 char * nptr = (T *)(void *)realloc( (void *)ptr, size ); … … 54 54 } // realloc 55 55 56 forall( otype T) T * malloc( T * ptr, size_t size ) {56 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size ) { 57 57 //printf( "malloc4\n" ); 58 58 return (T *)realloc( ptr, size ); 59 59 } // malloc 60 forall( otype T) T * malloc( T * ptr, size_t size, unsigned char fill ) {60 forall( dtype T | sized(T) ) T * malloc( T * ptr, size_t size, unsigned char fill ) { 61 61 //printf( "malloc5\n" ); 62 62 return (T *)realloc( ptr, size, fill ); 63 63 } // malloc 64 64 65 forall( otype T) T * aligned_alloc( size_t alignment ) {65 forall( dtype T | sized(T) ) T * aligned_alloc( size_t alignment ) { 66 66 //printf( "aligned_alloc\n" ); 67 67 return (T *)memalign( alignment, sizeof(T) ); 68 68 } // aligned_alloc 69 69 70 forall( otype T) T * memalign( size_t alignment ) {70 forall( dtype T | sized(T) ) T * memalign( size_t alignment ) { 71 71 //printf( "memalign\n" ); 72 72 return (T *)memalign( alignment, sizeof(T) ); 73 73 } // memalign 74 74 75 forall( otype T) int posix_memalign( T ** ptr, size_t alignment ) {75 forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment ) { 76 76 //printf( "posix_memalign\n" ); 77 77 return posix_memalign( (void **)ptr, alignment, sizeof(T) ); 78 78 } // posix_memalign 79 79 80 forall( otype T, ttype Params| { void ?{}(T *, Params); } )80 forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) 81 81 T * new( Params p ) { 82 82 return ((T*)malloc()){ p }; -
src/tests/dtor-early-exit.c
rf97b614 r59239b8 28 28 // don't want these called 29 29 void ?{}(A * a) { assert( false ); } 30 void ?{}(A * a, char * name) { a->name = name; sout | "construct " | name | endl; a->x = malloc(); }30 void ?{}(A * a, char * name) { a->name = name; sout | "construct " | name | endl; a->x = (int*)malloc(); } 31 31 void ?{}(A * a, char * name, int * ptr) { assert( false ); } 32 32 33 33 A ?=?(A * a, A a) { sout | "assign " | a->name | " " | a.name; return a; } 34 void ?{}(A * a, A a) { sout | "copy construct " | a.name | endl; a->x = malloc(); }34 void ?{}(A * a, A a) { sout | "copy construct " | a.name | endl; a->x = (int*)malloc(); } 35 35 void ^?{}(A * a) { sout | "destruct " | a->name | endl; free(a->x); } 36 36 -
src/tests/tupleVariadic.c
rf97b614 r59239b8 29 29 } 30 30 31 forall( otype T, ttype Params | { void ?{}(T *, Params); })31 forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) 32 32 T * new(Params p); 33 33
Note: See TracChangeset
for help on using the changeset viewer.