Changeset 0fc52b6 for src


Ignore:
Timestamp:
Jul 12, 2018, 9:14:07 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
3007c0b, 8f91c9ae
Parents:
777ed2b
Message:

first attmept to refactor common routines between stdlib and math

Location:
src/libcfa
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/Makefile.am

    r777ed2b r0fc52b6  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Thu Apr 12 14:38:34 2018
    14 ## Update Count     : 231
     13## Last Modified On : Thu Jul 12 08:04:35 2018
     14## Update Count     : 234
    1515###############################################################################
    1616
     
    4646CC = ${abs_top_srcdir}/src/driver/cfa
    4747
    48 headers = fstream iostream iterator limits rational time stdlib \
     48headers = fstream iostream iterator limits rational time stdlib common \
    4949          containers/maybe containers/pair containers/result containers/vector
    5050
     
    9696cfa_includedir = $(CFA_INCDIR)
    9797nobase_cfa_include_HEADERS =    \
    98         ${headers}                      \
    99         ${stdhdr}                       \
    100         math                            \
    101         gmp                             \
    102         time_t.h                        \
    103         clock                   \
     98        ${headers}              \
     99        ${stdhdr}               \
     100        math                    \
     101        gmp                     \
     102        time_t.h                \
    104103        bits/align.h            \
    105         bits/containers.h               \
     104        bits/containers.h       \
    106105        bits/defs.h             \
    107106        bits/debug.h            \
  • src/libcfa/Makefile.in

    r777ed2b r0fc52b6  
    150150am__libcfa_d_a_SOURCES_DIST = libcfa-prelude.c interpose.c \
    151151        bits/debug.c fstream.c iostream.c iterator.c limits.c \
    152         rational.c time.c stdlib.c containers/maybe.c \
     152        rational.c time.c stdlib.c common.c containers/maybe.c \
    153153        containers/pair.c containers/result.c containers/vector.c \
    154154        concurrency/coroutine.c concurrency/thread.c \
     
    167167        libcfa_d_a-limits.$(OBJEXT) libcfa_d_a-rational.$(OBJEXT) \
    168168        libcfa_d_a-time.$(OBJEXT) libcfa_d_a-stdlib.$(OBJEXT) \
     169        libcfa_d_a-common.$(OBJEXT) \
    169170        containers/libcfa_d_a-maybe.$(OBJEXT) \
    170171        containers/libcfa_d_a-pair.$(OBJEXT) \
     
    186187am__libcfa_a_SOURCES_DIST = libcfa-prelude.c interpose.c bits/debug.c \
    187188        fstream.c iostream.c iterator.c limits.c rational.c time.c \
    188         stdlib.c containers/maybe.c containers/pair.c \
     189        stdlib.c common.c containers/maybe.c containers/pair.c \
    189190        containers/result.c containers/vector.c \
    190191        concurrency/coroutine.c concurrency/thread.c \
     
    201202        libcfa_a-iterator.$(OBJEXT) libcfa_a-limits.$(OBJEXT) \
    202203        libcfa_a-rational.$(OBJEXT) libcfa_a-time.$(OBJEXT) \
    203         libcfa_a-stdlib.$(OBJEXT) containers/libcfa_a-maybe.$(OBJEXT) \
     204        libcfa_a-stdlib.$(OBJEXT) libcfa_a-common.$(OBJEXT) \
     205        containers/libcfa_a-maybe.$(OBJEXT) \
    204206        containers/libcfa_a-pair.$(OBJEXT) \
    205207        containers/libcfa_a-result.$(OBJEXT) \
     
    263265  esac
    264266am__nobase_cfa_include_HEADERS_DIST = fstream iostream iterator limits \
    265         rational time stdlib containers/maybe containers/pair \
     267        rational time stdlib common containers/maybe containers/pair \
    266268        containers/result containers/vector concurrency/coroutine \
    267269        concurrency/thread concurrency/kernel concurrency/monitor \
    268270        concurrency/mutex ${shell find stdhdr -type f -printf "%p "} \
    269         math gmp time_t.h clock bits/align.h bits/containers.h \
    270         bits/defs.h bits/debug.h bits/locks.h concurrency/invoke.h
     271        math gmp time_t.h bits/align.h bits/containers.h bits/defs.h \
     272        bits/debug.h bits/locks.h concurrency/invoke.h
    271273HEADERS = $(nobase_cfa_include_HEADERS)
    272274am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
     
    422424EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@
    423425AM_CCASFLAGS = @CFA_FLAGS@
    424 headers = fstream iostream iterator limits rational time stdlib \
     426headers = fstream iostream iterator limits rational time stdlib common \
    425427        containers/maybe containers/pair containers/result \
    426428        containers/vector $(am__append_3)
     
    435437cfa_includedir = $(CFA_INCDIR)
    436438nobase_cfa_include_HEADERS = \
    437         ${headers}                      \
    438         ${stdhdr}                       \
    439         math                            \
    440         gmp                             \
    441         time_t.h                        \
    442         clock                   \
     439        ${headers}              \
     440        ${stdhdr}               \
     441        math                    \
     442        gmp                     \
     443        time_t.h                \
    443444        bits/align.h            \
    444         bits/containers.h               \
     445        bits/containers.h       \
    445446        bits/defs.h             \
    446447        bits/debug.h            \
     
    610611
    611612@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-assert.Po@am__quote@
     613@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-common.Po@am__quote@
    612614@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-exception.Po@am__quote@
    613615@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-fstream.Po@am__quote@
     
    622624@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-virtual.Po@am__quote@
    623625@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-assert.Po@am__quote@
     626@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-common.Po@am__quote@
    624627@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-exception.Po@am__quote@
    625628@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-fstream.Po@am__quote@
     
    826829@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-stdlib.obj `if test -f 'stdlib.c'; then $(CYGPATH_W) 'stdlib.c'; else $(CYGPATH_W) '$(srcdir)/stdlib.c'; fi`
    827830
     831libcfa_d_a-common.o: common.c
     832@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-common.o -MD -MP -MF $(DEPDIR)/libcfa_d_a-common.Tpo -c -o libcfa_d_a-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c
     833@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-common.Tpo $(DEPDIR)/libcfa_d_a-common.Po
     834@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='common.c' object='libcfa_d_a-common.o' libtool=no @AMDEPBACKSLASH@
     835@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     836@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c
     837
     838libcfa_d_a-common.obj: common.c
     839@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-common.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-common.Tpo -c -o libcfa_d_a-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi`
     840@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-common.Tpo $(DEPDIR)/libcfa_d_a-common.Po
     841@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='common.c' object='libcfa_d_a-common.obj' libtool=no @AMDEPBACKSLASH@
     842@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     843@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi`
     844
    828845containers/libcfa_d_a-maybe.o: containers/maybe.c
    829846@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT containers/libcfa_d_a-maybe.o -MD -MP -MF containers/$(DEPDIR)/libcfa_d_a-maybe.Tpo -c -o containers/libcfa_d_a-maybe.o `test -f 'containers/maybe.c' || echo '$(srcdir)/'`containers/maybe.c
     
    11471164@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    11481165@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-stdlib.obj `if test -f 'stdlib.c'; then $(CYGPATH_W) 'stdlib.c'; else $(CYGPATH_W) '$(srcdir)/stdlib.c'; fi`
     1166
     1167libcfa_a-common.o: common.c
     1168@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-common.o -MD -MP -MF $(DEPDIR)/libcfa_a-common.Tpo -c -o libcfa_a-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c
     1169@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-common.Tpo $(DEPDIR)/libcfa_a-common.Po
     1170@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='common.c' object='libcfa_a-common.o' libtool=no @AMDEPBACKSLASH@
     1171@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1172@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c
     1173
     1174libcfa_a-common.obj: common.c
     1175@am__fastdepCC_TRUE@    $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-common.obj -MD -MP -MF $(DEPDIR)/libcfa_a-common.Tpo -c -o libcfa_a-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi`
     1176@am__fastdepCC_TRUE@    $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-common.Tpo $(DEPDIR)/libcfa_a-common.Po
     1177@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(AM_V_CC)source='common.c' object='libcfa_a-common.obj' libtool=no @AMDEPBACKSLASH@
     1178@AMDEP_TRUE@@am__fastdepCC_FALSE@       DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     1179@am__fastdepCC_FALSE@   $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi`
    11491180
    11501181containers/libcfa_a-maybe.o: containers/maybe.c
  • src/libcfa/math

    r777ed2b r0fc52b6  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug  7 07:51:15 2017
    13 // Update Count     : 108
     12// Last Modified On : Wed Jul 11 21:12:54 2018
     13// Update Count     : 109
    1414//
    1515
     
    348348static inline long double scalbln( long double x, long int exp ) { return scalblnl( x, exp ); }
    349349
     350//---------------------------------------
     351
     352#include "common"
     353
    350354// Local Variables: //
    351355// mode: c //
  • src/libcfa/stdlib

    r777ed2b r0fc52b6  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  5 07:41:03 2018
    13 // Update Count     : 332
     12// Last Modified On : Thu Jul 12 08:03:58 2018
     13// Update Count     : 337
    1414//
    1515
    1616#pragma once
    1717
    18 #include <stdlib.h>                                                                             // allocation, strto*, *abs
     18#include <stdlib.h>                                                                             // allocation, strto*, ato*
    1919extern "C" {
    2020        void * memalign( size_t align, size_t size );           // malloc.h
     
    227227        size_t bsearchu( K key, const E * vals, size_t dim );
    228228} // distribution
    229 
    230 //---------------------------------------
    231 
    232 [ int, int ] div( int num, int denom );
    233 [ long int, long int ] div( long int num, long int denom );
    234 [ long long int, long long int ] div( long long int num, long long int denom );
    235 forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )
    236 [ T, T ] div( T num, T demon );
    237 
    238 //---------------------------------------
    239 
    240 extern "C" { int abs( int ); }                                                  // use default C routine for int
    241 static inline {
    242         unsigned char abs( signed char v ) { return abs( (int)v ); }
    243         unsigned long int abs( long int v ) { return labs( v ); }
    244         unsigned long long int abs( long long int v ) { return llabs( v ); }
    245 } // distribution
    246 
    247 extern "C" {                                                                                    // use default C routine for int
    248         double fabs( double );
    249         float fabsf( float );
    250         long double fabsl( long double );
    251 } // extern "C"
    252 static inline {
    253         float abs( float x ) { return fabsf( x ); }
    254         double abs( double x ) { return fabs( x ); }
    255         long double abs( long double x ) { return fabsl( x ); }
    256 } // distribution
    257 
    258 extern "C" {                                                                                    // use default C routine for int
    259         double cabs( double _Complex );
    260         float cabsf( float _Complex );
    261         long double cabsl( long double _Complex );
    262 } // extern "C"
    263 static inline {
    264         float abs( float _Complex x ) { return cabsf( x ); }
    265         double abs( double _Complex x ) { return cabs( x ); }
    266         long double abs( long double _Complex x ) { return cabsl( x ); }
    267 } // distribution
    268 
    269 forall( otype T | { void ?{}( T &, zero_t ); int ?<?( T, T ); T -?( T ); } )
    270 T abs( T );
    271229
    272230//---------------------------------------
     
    303261//---------------------------------------
    304262
    305 static inline {
    306         forall( otype T | { int ?<?( T, T ); } )
    307         T min( T t1, T t2 ) { return t1 < t2 ? t1 : t2; }
    308 
    309         forall( otype T | { int ?>?( T, T ); } )
    310         T max( T t1, T t2 ) { return t1 > t2 ? t1 : t2; }
    311 
    312         forall( otype T | { T min( T, T ); T max( T, T ); } )
    313         T clamp( T value, T min_val, T max_val ) { return max( min_val, min( value, max_val ) ); }
    314 
    315         forall( otype T )
    316         void swap( T & v1, T & v2 ) { T temp = v1; v1 = v2; v2 = temp; }
    317 } // distribution
     263#include "common"
    318264
    319265// Local Variables: //
  • src/libcfa/stdlib.c

    r777ed2b r0fc52b6  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul  3 08:17:30 2018
    13 // Update Count     : 457
     12// Last Modified On : Thu Jul 12 08:03:59 2018
     13// Update Count     : 458
    1414//
    1515
     
    241241//---------------------------------------
    242242
    243 [ int, int ] div( int num, int denom ) { div_t qr = div( num, denom ); return [ qr.quot, qr.rem ]; }
    244 [ long int, long int ] div( long int num, long int denom ) { ldiv_t qr = ldiv( num, denom ); return [ qr.quot, qr.rem ]; }
    245 [ long long int, long long int ] div( long long int num, long long int denom ) { lldiv_t qr = lldiv( num, denom ); return [ qr.quot, qr.rem ]; }
    246 forall( otype T | { T ?/?( T, T ); T ?%?( T, T ); } )
    247 [ T, T ] div( T num, T denom ) { return [ num / denom, num % denom ]; }
    248 
    249 //---------------------------------------
    250 
    251243extern "C" {                                                                                    // override C version
    252244        void srandom( unsigned int seed ) { srand48( (long int)seed ); }
Note: See TracChangeset for help on using the changeset viewer.