Changeset 45161b4d for src/libcfa


Ignore:
Timestamp:
Apr 13, 2016, 5:08:56 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
b11fac4
Parents:
3849857
Message:

generate implicit typedef right after sue name appears, further fixes storage allocation routines and comments

Location:
src/libcfa
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/rational.c

    r3849857 r45161b4d  
    1111// Created On       : Wed Apr  6 17:54:28 2016
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Fri Apr  8 17:35:05 2016
    14 // Update Count     : 18
     13// Last Modified On : Tue Apr 12 21:26:42 2016
     14// Update Count     : 21
    1515//
    1616
     
    1919#include "stdlib"
    2020
    21 extern "C" {
    22 #include <stdlib.h>                                                                             // exit
    23 } // extern
    24 
    2521
    2622// constants
     
    3026
    3127
    32 // helper
     28// helper routines
    3329
    3430// Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals.
     31// alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
    3532static long int gcd( long int a, long int b ) {
    3633    for ( ;; ) {                                                                                // Euclid's algorithm
  • src/libcfa/stdlib

    r3849857 r45161b4d  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 12 18:22:54 2016
    13 // Update Count     : 77
     12// Last Modified On : Wed Apr 13 14:45:53 2016
     13// Update Count     : 85
    1414//
    1515
     
    1818extern "C" {
    1919#include <stddef.h>                                                                             // size_t
    20 #include <math.h>                                                                               // floor
    2120} // extern "C"
    2221
     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 );
     30} // extern "C"
     31
     32//---------------------------------------
     33
     34extern "C" {
     35void * malloc( size_t );                                                                // use default C routine for void *
     36} // extern "C"
    2337forall( otype T ) T * malloc( void );
    24 extern "C" {
    25 void * malloc( size_t );                                                                // use default C for void *
    26 } // extern "C"
    27 forall( otype T ) T * malloc( size_t size );
    2838forall( otype T ) T * malloc( char fill );
    2939forall( otype T ) T * malloc( T * ptr, size_t size );
    3040forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill );
    31 forall( otype T ) T * calloc( size_t size );
     41extern "C" {
     42void * calloc( size_t nmemb, size_t size );                             // use default C routine for void *
     43} // extern "C"
     44forall( otype T ) T * calloc( size_t nmemb );
     45extern "C" {
     46void * realloc( void * ptr, size_t size );                              // use default C routine for void *
     47} // extern "C"
    3248forall( otype T ) T * realloc( T * ptr, size_t size );
    3349forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill );
     
    85101char abs( char );
    86102extern "C" {
    87 int abs( int );                         // use default C routine for int
     103int abs( int );                                                                                 // use default C routine for int
    88104} // extern "C"
    89105long int abs( long int );
     
    100116float floor( float );
    101117extern "C" {
    102 double floor( double );         // use C routine for double
     118double floor( double );                                                                 // use C routine for double
    103119} // extern "C"
    104120long double floor( long double );
     
    106122float ceil( float );
    107123extern "C" {
    108 double ceil( double );          // use C routine for double
     124double ceil( double );                                                                  // use C routine for double
    109125} // extern "C"
    110126long double ceil( long double );
  • src/libcfa/stdlib.c

    r3849857 r45161b4d  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Apr 12 18:19:22 2016
    13 // Update Count     : 151
     12// Last Modified On : Wed Apr 13 14:49:58 2016
     13// Update Count     : 155
    1414//
    1515
     
    3131    return (T *)malloc( sizeof(T) );
    3232} // malloc
    33 forall( otype T ) T * malloc( size_t size ) {
    34         //printf( "malloc2\n" );
    35     return (T *)(void *)malloc( size );
    36 } // malloc
    3733forall( otype T ) T * malloc( char fill ) {
    3834        //printf( "malloc3\n" );
     
    4137} // malloc
    4238
    43 forall( otype T ) T * calloc( size_t size ) {
     39forall( otype T ) T * calloc( size_t nmemb ) {
    4440        //printf( "calloc\n" );
    45     return (T *)calloc( size, sizeof(T) );
     41    return (T *)calloc( nmemb, sizeof(T) );
    4642} // calloc
    4743
Note: See TracChangeset for help on using the changeset viewer.