Changeset 5721a6d for src/libcfa


Ignore:
Timestamp:
Feb 1, 2016, 2:24:50 PM (10 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

Location:
src/libcfa
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/Makefile.am

    rae8b942 r5721a6d  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Fri Jan 29 11:39:09 2016
    14 ## Update Count     : 108
     13## Last Modified On : Sat Jan 30 18:56:45 2016
     14## Update Count     : 110
    1515###############################################################################
    1616
     
    5454
    5555# extension-less header files are overridden by default make rules => explicitly override rule
    56 % : %.c
     56% : %.c ${abs_top_srcdir}/src/driver/cfa-cpp
    5757        true
    5858
  • src/libcfa/Makefile.in

    rae8b942 r5721a6d  
    585585
    586586# extension-less header files are overridden by default make rules => explicitly override rule
    587 % : %.c
     587% : %.c ${abs_top_srcdir}/src/driver/cfa-cpp
    588588        true
    589589
  • src/libcfa/algorithm

    rae8b942 r5721a6d  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jan 29 14:57:51 2016
    13 // Update Count     : 20
     12// Last Modified On : Mon Feb  1 13:41:51 2016
     13// Update Count     : 26
    1414//
     15
     16//---------------------------------------
    1517
    1618forall( type T | { int ?<?( T, T ); } )
     
    1921forall( type T | { int ?>?( T, T ); } )
    2022T max( const T t1, const T t2 );
     23
     24//---------------------------------------
     25
     26forall( type T )
     27void swap( T * t1, T * t2 );
     28
     29//---------------------------------------
    2130
    2231char abs( char );
     
    3342long double _Complex abs( long double _Complex );
    3443
     44//---------------------------------------
     45
     46void randseed( long int s );
     47char random();
     48int random();
     49unsigned int random();
     50long int random();
     51unsigned long int random();
     52float random();
     53double random();
     54float _Complex random();
     55double _Complex random();
     56long double _Complex random();
     57
    3558// Local Variables: //
    3659// mode: c //
  • 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: //
  • src/libcfa/iostream.c

    rae8b942 r5721a6d  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jan 29 15:38:34 2016
    13 // Update Count     : 47
     12// Last Modified On : Mon Feb  1 14:20:30 2016
     13// Update Count     : 60
    1414//
    1515
     
    8383forall( dtype ostype | ostream( ostype ) )
    8484ostype * ?|?( ostype *os, float _Complex c ) {
    85         char buffer[64];
    86         return write( os, buffer, sprintf( buffer, "%g+i%g", crealf( c ), cimagf( c ) ) );
     85        return os | crealf( c ) | (cimagf( c ) < 0 ? "" : "+") | cimagf( c ) | 'i';
    8786} // ?|?
    8887
    8988forall( dtype ostype | ostream( ostype ) )
    9089ostype * ?|?( ostype *os, double _Complex c ) {
    91         char buffer[64];
    92         return write( os, buffer, sprintf( buffer, "%g+i%g", creal( c ), cimag( c ) ) );
     90        return os | creal( c ) | (cimag( c ) < 0 ? "" : "+") | cimag( c ) | 'i';
    9391} // ?|?
    9492
    9593forall( dtype ostype | ostream( ostype ) )
    9694ostype * ?|?( ostype *os, long double _Complex c ) {
    97         char buffer[64];
    98         return write( os, buffer, sprintf( buffer, "%Lg+i%Lg", creall( c ), cimagl( c ) ) );
     95        return os | creall( c ) | (cimagl( c ) < 0 ? "" : "+") | cimagl( c ) | 'i';
    9996} // ?|?
    10097
Note: See TracChangeset for help on using the changeset viewer.