- Timestamp:
- Jul 19, 2023, 10:20:50 AM (13 months ago)
- Branches:
- master
- Children:
- 5a7789f
- Parents:
- 49caf644
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
r49caf644 r8a1d62b6 132 132 } // distribution 133 133 134 #define __CFA_BASE_COMP_1__() if ( x == 1 ) return 1135 #define __CFA_BASE_COMP_2__() if ( x == 2 ) return x << (y - 1)136 #define __CFA_EXP_OVERFLOW__() if ( y >= sizeof(y) * CHAR_BIT ) return 0137 138 134 #define __CFA_EXP__() \ 139 135 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 ) \ 143 141 typeof(x) op = 1; /* accumulate odd product */ \ 144 142 for ( ; y > 1; y >>= 1 ) { /* squaring exponentiation, O(log2 y) */ \ … … 147 145 } \ 148 146 return x * op 147 #define __CFA_EXP_INT__(...) __VA_ARGS__ 149 148 150 149 static inline { … … 158 157 } // distribution 159 158 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__(...) 166 161 167 162 static inline forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) { … … 171 166 } // distribution 172 167 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__ 176 170 177 171 static inline {
Note: See TracChangeset
for help on using the changeset viewer.