Ignore:
Timestamp:
Feb 1, 2016, 2:24:50 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:
2a4b088, b4cd03b7
Parents:
ae8b942
Message:

correctly set type for complex constants, consolidate function name tables, add offsetof, refactor printing complex constants to use basic types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/algorithm.c

    rae8b942 r5721a6d  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jan 29 15:49:59 2016
    13 // Update Count     : 29
     12// Last Modified On : Mon Feb  1 13:42:05 2016
     13// Update Count     : 52
    1414//
    1515
     
    2626} // max
    2727
     28//---------------------------------------
     29
     30forall( type T )
     31void swap( T * t1, T * t2 ) {
     32        T temp = *t1;
     33        *t1 = *t2;
     34        *t2 = temp;
     35} // swap
     36
     37//---------------------------------------
    2838
    2939extern "C" {
     40#define _XOPEN_SOURCE                                                                   // required to access "rand48" routines
    3041#include <stdlib.h>                                                                             // abs, labs, llabs
    3142#include <math.h>                                                                               // fabsf, fabs, fabsl
    3243#include <complex.h>                                                                    // cabsf, cabs, cabsl
     44#undef I                                                                                                // free name
    3345} // extern
    3446
     
    4355long double _Complex abs( long double _Complex v ) { return cabsl( v ); }
    4456
     57//---------------------------------------
     58
     59void randseed( long int s ) { srand48( s ); }
     60char random() { return lrand48(); }
     61int random() { return mrand48(); }
     62unsigned int random() { return lrand48(); }
     63long int random() { return mrand48(); }
     64unsigned long int random() { return lrand48(); }
     65float random() { return (float)drand48(); }                             // otherwise float uses lrand48
     66double random() { return drand48(); }
     67float _Complex random() { return (float)drand48() + (float _Complex)(drand48() * _Complex_I); }
     68double _Complex random() { return drand48() + (double _Complex)(drand48() * _Complex_I); }
     69long double _Complex random() { return (long double)drand48() + (long double _Complex)(drand48() * _Complex_I); }
    4570
    4671// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.