quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

ti_mode.c (858B)


      1 #if !defined(__clang__) && !defined(__GNUC__) && !defined(__SIZEOF_INT128__)
      2 # error mode(TI) is a gcc extension, and __int128 is not available
      3 #endif
      4 #if defined(__clang__) && !defined(__x86_64__) && !defined(__aarch64__)
      5 # error clang does not properly handle the 128-bit type on 32-bit systems
      6 #endif
      7 #ifndef NATIVE_LITTLE_ENDIAN
      8 # error libsodium currently expects a little endian CPU for the 128-bit type
      9 #endif
     10 #ifdef __EMSCRIPTEN__
     11 # error emscripten currently doesn't support some operations on integers larger than 64 bits
     12 #endif
     13 #include <stddef.h>
     14 #include <stdint.h>
     15 #if defined(__SIZEOF_INT128__)
     16 typedef unsigned __int128 uint128_t;
     17 #else
     18 typedef unsigned uint128_t __attribute__((mode(TI)));
     19 #endif
     20 void fcontract(uint128_t *t) {
     21   *t += 0x8000000000000 - 1;
     22   *t *= *t;
     23   *t >>= 84;
     24 }
     25 
     26 int main(int argc, char **argv) {
     27   (void) fcontract;
     28 }