30#ifndef USE_NATIVE_INT128
31#define USE_NATIVE_INT128 0
56#define INT128_HEX_FORMAT "%016" PRIx64 "%016" PRIx64
62my_int128_compare(int128
x, int128
y)
80main(
int argc,
char **argv)
87 count = strtol(argv[1], NULL, 0);
112 t1.i128 += (int128) (
uint64) z;
115 if (t1.hl.hi != t2.hl.hi || t1.hl.lo != t2.hl.lo)
117 printf(INT128_HEX_FORMAT
" + unsigned %016" PRIx64
"\n",
x,
y, z);
118 printf(
"native = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
119 printf(
"result = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
127 t1.i128 += (int128) z;
130 if (t1.hl.hi != t2.hl.hi || t1.hl.lo != t2.hl.lo)
132 printf(INT128_HEX_FORMAT
" + signed %016" PRIx64
"\n",
x,
y, z);
133 printf(
"native = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
134 printf(
"result = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
147 if (t1.hl.hi != t2.hl.hi || t1.hl.lo != t2.hl.lo)
149 printf(INT128_HEX_FORMAT
" + " INT128_HEX_FORMAT
"\n",
x,
y, z, w);
150 printf(
"native = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
151 printf(
"result = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
159 t1.i128 -= (int128) (
uint64) z;
162 if (t1.hl.hi != t2.hl.hi || t1.hl.lo != t2.hl.lo)
164 printf(INT128_HEX_FORMAT
" - unsigned %016" PRIx64
"\n",
x,
y, z);
165 printf(
"native = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
166 printf(
"result = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
174 t1.i128 -= (int128) z;
177 if (t1.hl.hi != t2.hl.hi || t1.hl.lo != t2.hl.lo)
179 printf(INT128_HEX_FORMAT
" - signed %016" PRIx64
"\n",
x,
y, z);
180 printf(
"native = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
181 printf(
"result = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
189 t1.i128 += (int128) z * (int128) w;
192 if (t1.hl.hi != t2.hl.hi || t1.hl.lo != t2.hl.lo)
194 printf(INT128_HEX_FORMAT
" + %016" PRIx64
" * %016" PRIx64
"\n",
x,
y, z, w);
195 printf(
"native = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
196 printf(
"result = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
204 t1.i128 -= (int128) z * (int128) w;
207 if (t1.hl.hi != t2.hl.hi || t1.hl.lo != t2.hl.lo)
209 printf(INT128_HEX_FORMAT
" - %016" PRIx64
" * %016" PRIx64
"\n",
x,
y, z, w);
210 printf(
"native = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
211 printf(
"result = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
218 t1.i128 = t3.i128 / z32;
219 r1 = (
int32) (t3.i128 % z32);
223 if (t1.hl.hi != t2.hl.hi || t1.hl.lo != t2.hl.lo)
225 printf(INT128_HEX_FORMAT
" / signed %08X\n", t3.hl.hi, t3.hl.lo, z32);
226 printf(
"native = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
227 printf(
"result = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
232 printf(INT128_HEX_FORMAT
" %% signed %08X\n", t3.hl.hi, t3.hl.lo, z32);
233 printf(
"native = %08X\n", r1);
234 printf(
"result = %08X\n", r2);
244 if (my_int128_compare(t1.i128, t2.i128) !=
247 printf(
"comparison failure: %d vs %d\n",
248 my_int128_compare(t1.i128, t2.i128),
250 printf(
"arg1 = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
251 printf(
"arg2 = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
258 if (my_int128_compare(t1.i128, t2.i128) !=
261 printf(
"comparison failure: %d vs %d\n",
262 my_int128_compare(t1.i128, t2.i128),
264 printf(
"arg1 = " INT128_HEX_FORMAT
"\n", t1.hl.hi, t1.hl.lo);
265 printf(
"arg2 = " INT128_HEX_FORMAT
"\n", t2.hl.hi, t2.hl.lo);
281 printf(
"skipping tests: no native int128 type\n");
static void int128_sub_uint64(INT128 *i128, uint64 v)
static void int128_add_uint64(INT128 *i128, uint64 v)
static void int128_sub_int64_mul_int64(INT128 *i128, int64 x, int64 y)
static void int128_add_int128(INT128 *i128, INT128 v)
static void int128_sub_int64(INT128 *i128, int64 v)
static int int128_compare(INT128 x, INT128 y)
static void int128_add_int64(INT128 *i128, int64 v)
static void int128_div_mod_int32(INT128 *i128, int32 v, int32 *remainder)
static void int128_add_int64_mul_int64(INT128 *i128, int64 x, int64 y)
int32 pg_prng_int32(pg_prng_state *state)
int64 pg_prng_int64(pg_prng_state *state)
void pg_prng_seed(pg_prng_state *state, uint64 seed)
pg_prng_state pg_global_prng_state
int main(int argc, char **argv)