1 // pragma multi include 2 /* Renames mod_ function names so that the function for the desired 3 arithmetic type/width is used */ 4 5 #undef mod_intinit 6 #undef mod_intclear 7 #undef mod_intset 8 #undef mod_intset_ul 9 #undef mod_intset_uls 10 #undef mod_intget_ul 11 #undef mod_intget_uls 12 #undef mod_intget_double 13 #undef mod_intequal 14 #undef mod_intequal_ul 15 #undef mod_intcmp 16 #undef mod_intcmp_ul 17 #undef mod_intcmp_uint64 18 #undef mod_intfits_ul 19 #undef mod_intadd 20 #undef mod_intsub 21 #undef mod_intbits 22 #undef mod_intshr 23 #undef mod_intshl 24 #undef mod_intdivexact 25 #undef mod_intmod 26 #undef mod_init 27 #undef mod_init_noset0 28 #undef mod_clear 29 #undef mod_set 30 #undef mod_set_ul 31 #undef mod_set_ul_reduced 32 #undef mod_set_int 33 #undef mod_set_int_reduced 34 #undef mod_swap 35 #undef mod_initmod_ul 36 #undef mod_initmod_int 37 #undef mod_getmod_ul 38 #undef mod_getmod_int 39 #undef mod_clearmod 40 #undef mod_get_ul 41 #undef mod_get_int 42 #undef mod_equal 43 #undef mod_is0 44 #undef mod_is1 45 #undef mod_add 46 #undef mod_add1 47 #undef mod_add_ul 48 #undef mod_sub 49 #undef mod_sub_ul 50 #undef mod_neg 51 #undef mod_mul 52 #undef mod_sqr 53 #undef mod_div2 54 #undef mod_div3 55 #undef mod_div5 56 #undef mod_div7 57 #undef mod_div11 58 #undef mod_div13 59 #undef mod_pow_ul 60 #undef mod_2pow_ul 61 #undef mod_pow_mp 62 #undef mod_2pow_mp 63 #undef mod_sprp 64 #undef mod_sprp2 65 #undef mod_isprime 66 #undef mod_gcd 67 #undef mod_inv 68 #undef mod_batchinv 69 #undef mod_jacobi 70 #undef mod_set0 71 #undef mod_set1 72 #undef mod_next 73 #undef mod_finished 74 #undef mod_fprintf 75 #undef mod_printf 76 77 #define mod_intinit MOD_RENAME(intinit) 78 #define mod_intclear MOD_RENAME(intclear) 79 #define mod_intset MOD_RENAME(intset) 80 #define mod_intset_ul MOD_RENAME(intset_ul) 81 #define mod_intset_uls MOD_RENAME(intset_uls) 82 #define mod_intget_ul MOD_RENAME(intget_ul) 83 #define mod_intget_uls MOD_RENAME(intget_uls) 84 #define mod_intget_double MOD_RENAME(intget_double) 85 #define mod_intequal MOD_RENAME(intequal) 86 #define mod_intequal_ul MOD_RENAME(intequal_ul) 87 #define mod_intcmp MOD_RENAME(intcmp) 88 #define mod_intcmp_ul MOD_RENAME(intcmp_ul) 89 #define mod_intcmp_uint64 MOD_RENAME(intcmp_uint64) 90 #define mod_intfits_ul MOD_RENAME(intfits_ul) 91 #define mod_intadd MOD_RENAME(intadd) 92 #define mod_intsub MOD_RENAME(intsub) 93 #define mod_intbits MOD_RENAME(intbits) 94 #define mod_intshr MOD_RENAME(intshr) 95 #define mod_intshl MOD_RENAME(intshl) 96 #define mod_intdivexact MOD_RENAME(intdivexact) 97 #define mod_intmod MOD_RENAME(intmod) 98 #define mod_init MOD_RENAME(init) 99 #define mod_init_noset0 MOD_RENAME(init_noset0) 100 #define mod_clear MOD_RENAME(clear) 101 #define mod_set MOD_RENAME(set) 102 #define mod_set_ul MOD_RENAME(set_ul) 103 #define mod_set_ul_reduced MOD_RENAME(set_ul_reduced) 104 #define mod_set_int MOD_RENAME(set_int) 105 #define mod_set_int_reduced MOD_RENAME(set_int_reduced) 106 #define mod_swap MOD_RENAME(swap) 107 #define mod_initmod_ul MOD_RENAME(initmod_ul) 108 #define mod_initmod_int MOD_RENAME(initmod_int) 109 #define mod_getmod_ul MOD_RENAME(getmod_ul) 110 #define mod_getmod_int MOD_RENAME(getmod_int) 111 #define mod_clearmod MOD_RENAME(clearmod) 112 #define mod_get_ul MOD_RENAME(get_ul) 113 #define mod_get_int MOD_RENAME(get_int) 114 #define mod_equal MOD_RENAME(equal) 115 #define mod_is0 MOD_RENAME(is0) 116 #define mod_is1 MOD_RENAME(is1) 117 #define mod_add MOD_RENAME(add) 118 #define mod_add1 MOD_RENAME(add1) 119 #define mod_add_ul MOD_RENAME(add_ul) 120 #define mod_sub MOD_RENAME(sub) 121 #define mod_sub_ul MOD_RENAME(sub_ul) 122 #define mod_neg MOD_RENAME(neg) 123 #define mod_mul MOD_RENAME(mul) 124 #define mod_sqr MOD_RENAME(sqr) 125 #define mod_div2 MOD_RENAME(div2) 126 #define mod_div3 MOD_RENAME(div3) 127 #define mod_div5 MOD_RENAME(div5) 128 #define mod_div7 MOD_RENAME(div7) 129 #define mod_div11 MOD_RENAME(div11) 130 #define mod_div13 MOD_RENAME(div13) 131 #define mod_pow_ul MOD_RENAME(pow_ul) 132 #define mod_2pow_ul MOD_RENAME(2pow_ul) 133 #define mod_pow_mp MOD_RENAME(pow_mp) 134 #define mod_2pow_mp MOD_RENAME(2pow_mp) 135 #define mod_sprp MOD_RENAME(sprp) 136 #define mod_sprp2 MOD_RENAME(sprp2) 137 #define mod_isprime MOD_RENAME(isprime) 138 #define mod_gcd MOD_RENAME(gcd) 139 #define mod_inv MOD_RENAME(inv) 140 #define mod_batchinv MOD_RENAME(batchinv) 141 #define mod_jacobi MOD_RENAME(jacobi) 142 #define mod_set0 MOD_RENAME(set0) 143 #define mod_set1 MOD_RENAME(set1) 144 #define mod_next MOD_RENAME(next) 145 #define mod_finished MOD_RENAME(finished) 146 #define mod_fprintf gmp_fprintf 147 #define mod_printf gmp_printf 148 149 #ifdef __cplusplus 150 extern "C" { 151 #endif 152 153 /* A function that is not used anywhere. The purpose is solely generating 154 compilation errors if any of the renamed functions, which constitute 155 kind of a definition of the API, are not implemented. */ 156 static inline void * mod_test_if_functions_exist()157mod_test_if_functions_exist() 158 { 159 void *p; 160 p = (void*) &mod_intinit; 161 p = (void*) &mod_intclear; 162 p = (void*) &mod_intset; 163 p = (void*) &mod_intset_ul; 164 p = (void*) &mod_intset_uls; 165 p = (void*) &mod_intget_ul; 166 p = (void*) &mod_intget_uls; 167 p = (void*) &mod_intequal; 168 p = (void*) &mod_intequal_ul; 169 p = (void*) &mod_intcmp; 170 p = (void*) &mod_intcmp_ul; 171 p = (void*) &mod_intcmp_uint64; 172 p = (void*) &mod_intfits_ul; 173 p = (void*) &mod_intadd; 174 p = (void*) &mod_intsub; 175 p = (void*) &mod_intbits; 176 p = (void*) &mod_intshr; 177 p = (void*) &mod_intshl; 178 p = (void*) &mod_intdivexact; 179 p = (void*) &mod_intmod; 180 p = (void*) &mod_init; 181 p = (void*) &mod_init_noset0; 182 p = (void*) &mod_clear; 183 p = (void*) &mod_set; 184 p = (void*) &mod_set_ul; 185 p = (void*) &mod_set_ul_reduced; 186 p = (void*) &mod_set_int; 187 p = (void*) &mod_set_int_reduced; 188 p = (void*) &mod_swap; 189 /* This is implemented only for 1-word arithmetic. 190 FIXME: Since these functions are not generally available, they probably 191 should not be renamed, either. 192 p = &mod_initmod_ul; 193 p = &mod_getmod_ul; 194 */ 195 p = (void*) &mod_initmod_int; 196 p = (void*) &mod_getmod_int; 197 p = (void*) &mod_clearmod; 198 p = (void*) &mod_get_ul; 199 p = (void*) &mod_get_int; 200 p = (void*) &mod_equal; 201 p = (void*) &mod_is0; 202 p = (void*) &mod_is1; 203 p = (void*) &mod_add; 204 p = (void*) &mod_add1; 205 p = (void*) &mod_add_ul; 206 p = (void*) &mod_sub; 207 p = (void*) &mod_sub_ul; 208 p = (void*) &mod_neg; 209 p = (void*) &mod_mul; 210 p = (void*) &mod_sqr; 211 p = (void*) &mod_div2; 212 p = (void*) &mod_div3; 213 p = (void*) &mod_div5; 214 p = (void*) &mod_div7; 215 p = (void*) &mod_div11; 216 p = (void*) &mod_div13; 217 p = (void*) &mod_pow_ul; 218 p = (void*) &mod_2pow_ul; 219 p = (void*) &mod_pow_mp; 220 p = (void*) &mod_2pow_mp; 221 p = (void*) &mod_sprp; 222 p = (void*) &mod_sprp2; 223 p = (void*) &mod_isprime; 224 p = (void*) &mod_gcd; 225 p = (void*) &mod_inv; 226 p = (void*) &mod_batchinv; 227 p = (void*) &mod_jacobi; 228 p = (void*) &mod_set0; 229 p = (void*) &mod_set1; 230 p = (void*) &mod_next; 231 p = (void*) &mod_finished; 232 return p; 233 } 234 235 #ifdef __cplusplus 236 } 237 #endif 238 239