From 618b5704e6f85cfe1b6e5c9c9373abe76a8bb628 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sat, 6 Aug 2022 17:48:06 +0200 Subject: c_apply() deprecated: replaced with c_forarray() macro. Updated and improved README.md docs. --- include/stc/crandom.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include/stc/crandom.h') diff --git a/include/stc/crandom.h b/include/stc/crandom.h index 0e34e850..49f6d3ae 100644 --- a/include/stc/crandom.h +++ b/include/stc/crandom.h @@ -145,6 +145,18 @@ STC_DEF stc64_uniform_t stc64_uniform_new(int64_t low, int64_t high) { return dist; } +#if defined(__SIZEOF_INT128__) + #define c_umul128(a, b, lo, hi) \ + do { __uint128_t _z = (__uint128_t)(a)*(b); \ + *(lo) = (uint64_t)_z, *(hi) = _z >> 64; } while(0) +#elif defined(_MSC_VER) && defined(_WIN64) + #include + #define c_umul128(a, b, lo, hi) ((void)(*(lo) = _umul128(a, b, hi))) +#elif defined(__x86_64__) + #define c_umul128(a, b, lo, hi) \ + asm("mulq %3" : "=a"(*(lo)), "=d"(*(hi)) : "a"(a), "rm"(b)) +#endif + /* Int uniform distributed RNG, range [low, high]. */ STC_DEF int64_t stc64_uniform(stc64_t* rng, stc64_uniform_t* d) { #ifdef c_umul128 -- cgit v1.2.3