| ... | @@ -279,24 +279,21 @@ zig_extern void *memset (void *, int, zig_usize); | ... | @@ -279,24 +279,21 @@ zig_extern void *memset (void *, int, zig_usize); |
| 279 | static inline zig_##Type zig_##operation##_##Type(zig_##Type lhs, zig_##RhsType rhs) { \ | 279 | static inline zig_##Type zig_##operation##_##Type(zig_##Type lhs, zig_##RhsType rhs) { \ |
| 280 | return lhs operator rhs; \ | 280 | return lhs operator rhs; \ |
| 281 | } | 281 | } |
| 282 | #define zig_int_operators(w) \ | 282 | #define zig_int_basic_operator(Type, operation, operator) \ |
| 283 | zig_int_operator(u##w, u##w, and, &) \ | 283 | zig_int_operator(Type, Type, operation, operator) |
| 284 | zig_int_operator(i##w, i##w, and, &) \ | 284 | #define zig_int_shift_operator(Type, operation, operator) \ |
| 285 | zig_int_operator(u##w, u##w, or, |) \ | 285 | zig_int_operator(Type, u8, operation, operator) |
| 286 | zig_int_operator(i##w, i##w, or, |) \ | | |
| 287 | zig_int_operator(u##w, u##w, xor, ^) \ | | |
| 288 | zig_int_operator(i##w, i##w, xor, ^) \ | | |
| 289 | zig_int_operator(u##w, u8, shl, <<) \ | | |
| 290 | zig_int_operator(i##w, u8, shl, <<) \ | | |
| 291 | zig_int_operator(u##w, u8, shr, >>) \ | | |
| 292 | zig_int_operator(u##w, u##w, div_floor, /) \ | | |
| 293 | zig_int_operator(u##w, u##w, mod, %) | | |
| 294 | zig_int_operators(8) | | |
| 295 | zig_int_operators(16) | | |
| 296 | zig_int_operators(32) | | |
| 297 | zig_int_operators(64) | | |
| 298 | | | |
| 299 | #define zig_int_helpers(w) \ | 286 | #define zig_int_helpers(w) \ |
| | 287 | zig_int_basic_operator(u##w, and, &) \ |
| | 288 | zig_int_basic_operator(i##w, and, &) \ |
| | 289 | zig_int_basic_operator(u##w, or, |) \ |
| | 290 | zig_int_basic_operator(i##w, or, |) \ |
| | 291 | zig_int_basic_operator(u##w, xor, ^) \ |
| | 292 | zig_int_basic_operator(i##w, xor, ^) \ |
| | 293 | zig_int_shift_operator(u##w, shl, <<) \ |
| | 294 | zig_int_shift_operator(i##w, shl, <<) \ |
| | 295 | zig_int_shift_operator(u##w, shr, >>) \ |
| | 296 | \ |
| 300 | static inline zig_i##w zig_shr_i##w(zig_i##w lhs, zig_u8 rhs) { \ | 297 | static inline zig_i##w zig_shr_i##w(zig_i##w lhs, zig_u8 rhs) { \ |
| 301 | zig_i##w sign_mask = lhs < zig_as_i##w(0) ? -zig_as_i##w(1) : zig_as_i##w(0); \ | 298 | zig_i##w sign_mask = lhs < zig_as_i##w(0) ? -zig_as_i##w(1) : zig_as_i##w(0); \ |
| 302 | return ((lhs ^ sign_mask) >> rhs) ^ sign_mask; \ | 299 | return ((lhs ^ sign_mask) >> rhs) ^ sign_mask; \ |
| ... | @@ -319,10 +316,14 @@ zig_int_operators(64) | ... | @@ -319,10 +316,14 @@ zig_int_operators(64) |
| 319 | return (val & zig_as_u##w(1) << (bits - zig_as_u8(1))) != 0 \ | 316 | return (val & zig_as_u##w(1) << (bits - zig_as_u8(1))) != 0 \ |
| 320 | ? val | zig_minInt(i##w, bits) : val & zig_maxInt(i##w, bits); \ | 317 | ? val | zig_minInt(i##w, bits) : val & zig_maxInt(i##w, bits); \ |
| 321 | } \ | 318 | } \ |
| | 319 | \ |
| | 320 | zig_int_basic_operator(u##w, div_floor, /) \ |
| 322 | \ | 321 | \ |
| 323 | static inline zig_i##w zig_div_floor_i##w(zig_i##w lhs, zig_i##w rhs) { \ | 322 | static inline zig_i##w zig_div_floor_i##w(zig_i##w lhs, zig_i##w rhs) { \ |
| 324 | return lhs / rhs - (((lhs ^ rhs) & (lhs % rhs)) < zig_as_i##w(0)); \ | 323 | return lhs / rhs - (((lhs ^ rhs) & (lhs % rhs)) < zig_as_i##w(0)); \ |
| 325 | } \ | 324 | } \ |
| | 325 | \ |
| | 326 | zig_int_basic_operator(u##w, mod, %) \ |
| 326 | \ | 327 | \ |
| 327 | static inline zig_i##w zig_mod_i##w(zig_i##w lhs, zig_i##w rhs) { \ | 328 | static inline zig_i##w zig_mod_i##w(zig_i##w lhs, zig_i##w rhs) { \ |
| 328 | zig_i##w rem = lhs % rhs; \ | 329 | zig_i##w rem = lhs % rhs; \ |