Changeset 8a1d62b6


Ignore:
Timestamp:
Jul 19, 2023, 10:20:50 AM (10 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
5a7789f
Parents:
49caf644
Message:

Reorganize ?\? operator to shorten it a bit and move lines of code closer to the comments associated with them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    r49caf644 r8a1d62b6  
    132132} // distribution
    133133
    134 #define __CFA_BASE_COMP_1__() if ( x == 1 ) return 1
    135 #define __CFA_BASE_COMP_2__() if ( x == 2 ) return x << (y - 1)
    136 #define __CFA_EXP_OVERFLOW__() if ( y >= sizeof(y) * CHAR_BIT ) return 0
    137 
    138134#define __CFA_EXP__() \
    139135        if ( y == 0 ) return 1;                                                         /* convention */ \
    140         __CFA_BASE_COMP_1__();                                                          /* base case */ \
    141         __CFA_BASE_COMP_2__();                                                          /* special case, positive shifting for integral types */ \
    142         __CFA_EXP_OVERFLOW__();                                                         /* immediate overflow, negative exponent > 2^size-1 */ \
     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        ) \
    143141        typeof(x) op = 1;                                                                       /* accumulate odd product */ \
    144142        for ( ; y > 1; y >>= 1 ) {                                                      /* squaring exponentiation, O(log2 y) */ \
     
    147145        } \
    148146        return x * op
     147#define __CFA_EXP_INT__(...) __VA_ARGS__
    149148
    150149static inline {
     
    158157} // distribution
    159158
    160 #undef __CFA_BASE_COMP_1__
    161 #undef __CFA_BASE_COMP_2__
    162 #undef __CFA_EXP_OVERFLOW__
    163 #define __CFA_BASE_COMP_1__()
    164 #define __CFA_BASE_COMP_2__()
    165 #define __CFA_EXP_OVERFLOW__()
     159#undef __CFA_EXP_INT__
     160#define __CFA_EXP_INT__(...)
    166161
    167162static inline forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) {
     
    171166} // distribution
    172167
    173 #undef __CFA_BASE_COMP_1__
    174 #undef __CFA_BASE_COMP_2__
    175 #undef __CFA_EXP_OVERFLOW__
     168#undef __CFA_EXP_INT__
     169#undef __CFA_EXP__
    176170
    177171static inline {
Note: See TracChangeset for help on using the changeset viewer.