Changeset 108b2c7 for libcfa


Ignore:
Timestamp:
Nov 27, 2024, 4:01:37 PM (3 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
71f3d45
Parents:
e25ef8c
Message:

Moved the non-trivial bodies of the power (exponental) functions out of the prelude and into the library. They have caused some issues in debugging there.

Location:
libcfa
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    re25ef8c r108b2c7  
    4444typedef unsigned long long __cfaabi_abi_exception_type_t;
    4545
    46 #include <limits.h>                                                                             // CHAR_BIT
    4746#include "../src/virtual.h"
    4847#include "../src/exception.h"
     
    132131} // distribution
    133132
    134 #define __CFA_EXP__() \
    135         if ( y == 0 ) return 1;                                                         /* convention */ \
    136         __CFA_EXP_INT__(                                                                        /* special cases for integral types */ \
    137                 if ( x == 1 ) return 1;                                                 /* base case */ \
    138                 if ( x == 2 ) return x << (y - 1);                              /* positive shifting */ \
    139                 if ( y >= sizeof(y) * CHAR_BIT ) return 0;              /* immediate overflow, negative exponent > 2^size-1 */ \
    140         ) \
    141         typeof(x) op = 1;                                                                       /* accumulate odd product */ \
    142         typeof(x) w = x; /* FIX-ME: possible bug in the box pass changing value argument through parameter */ \
    143         for ( ; y > 1; y >>= 1 ) {                                                      /* squaring exponentiation, O(log2 y) */ \
    144                 if ( (y & 1) == 1 ) op = op * w;                                /* odd ? */ \
    145                 w = w * w; \
    146         } \
    147         return w * op
    148 #define __CFA_EXP_INT__(...) __VA_ARGS__
     133int ?\?( int x, unsigned int y );
     134long int ?\?( long int x, unsigned long int y );
     135long long int ?\?( long long int x, unsigned long long int y );
     136// unsigned computation may be faster and larger
     137unsigned int ?\?( unsigned int x, unsigned int y );
     138unsigned long int ?\?( unsigned long int x, unsigned long int y );
     139unsigned long long int ?\?( unsigned long long int x, unsigned long long int y );
    149140
    150 static inline {
    151         int ?\?( int x, unsigned int y ) { __CFA_EXP__(); }
    152         long int ?\?( long int x, unsigned long int y ) { __CFA_EXP__(); }
    153         long long int ?\?( long long int x, unsigned long long int y ) { __CFA_EXP__(); }
    154         // unsigned computation may be faster and larger
    155         unsigned int ?\?( unsigned int x, unsigned int y ) { __CFA_EXP__(); }
    156         unsigned long int ?\?( unsigned long int x, unsigned long int y ) { __CFA_EXP__(); }
    157         unsigned long long int ?\?( unsigned long long int x, unsigned long long int y ) { __CFA_EXP__(); }
     141forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) {
     142        OT ?\?( OT x, unsigned int y );
     143        OT ?\?( OT x, unsigned long int y );
     144        OT ?\?( OT x, unsigned long long int y );
    158145} // distribution
    159 
    160 #undef __CFA_EXP_INT__
    161 #define __CFA_EXP_INT__(...)
    162 
    163 static inline forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) {
    164         OT ?\?( OT x, unsigned int y ) { __CFA_EXP__(); }
    165         OT ?\?( OT x, unsigned long int y ) { __CFA_EXP__(); }
    166         OT ?\?( OT x, unsigned long long int y ) { __CFA_EXP__(); }
    167 } // distribution
    168 
    169 #undef __CFA_EXP_INT__
    170 #undef __CFA_EXP__
    171146
    172147static inline {
  • libcfa/src/Makefile.am

    re25ef8c r108b2c7  
    4747        gmp.hfa \
    4848        math.trait.hfa \
    49         math.hfa \
    5049        raii.hfa \
    5150        time_t.hfa \
     
    8180        iterator.hfa \
    8281        limits.hfa \
     82        math.hfa \
    8383        memory.hfa \
    8484        parseargs.hfa \
Note: See TracChangeset for help on using the changeset viewer.