1 /* 2 * Copyright (c) 2016 Jean-Michel Merliot 3 * Copyright (c) 2021 The DPS8M Development Team 4 * 5 * All rights reserved. 6 * 7 * This software is made available under the terms of the ICU 8 * License, version 1.8.1 or later. For more details, see the 9 * LICENSE.md file at the top-level directory of this distribution. 10 */ 11 12 /* 13 * Defines 128 bits Integer for 32 bits platform 14 */ 15 16 #ifdef NEED_128 17 18 //#define cast_128(x) (* (uint128 *) & (x)) 19 //#define cast_s128(x) (* (int128 *) & (x)) 20 # define cast_128(x) construct_128 ((uint64_t) (x).h, (x).l) 21 # define cast_s128(x) construct_s128 ((int64_t) (x).h, (x).l) 22 23 bool iszero_128 (uint128 w); 24 bool isnonzero_128 (uint128 w); 25 bool iseq_128 (uint128 a, uint128 b); 26 bool isgt_128 (uint128 a, uint128 b); 27 bool islt_128 (uint128 a, uint128 b); 28 bool isge_128 (uint128 a, uint128 b); 29 bool islt_s128 (int128 a, int128 b); 30 bool isgt_s128 (int128 a, int128 b); 31 uint128 and_128 (uint128 a, uint128 b); 32 int128 and_s128 (int128 a, uint128 b); 33 uint128 or_128 (uint128 a, uint128 b); 34 uint128 xor_128 (uint128 a, uint128 b); 35 uint128 add_128 (uint128 a, uint128 b); 36 uint128 subtract_128 (uint128 a, uint128 b); 37 uint128 multiply_128 (uint128 a, uint128 b); 38 int128 multiply_s128 (int128 a, int128 b); 39 uint128 divide_128_16 (uint128 a, uint16_t b, uint16_t * rem); 40 uint128 divide_128_32 (uint128 a, uint32_t b, uint32_t * rem); 41 uint128 divide_128 (uint128 a, uint128 b, uint128 * rem); 42 uint128 complement_128 (uint128 a); 43 uint128 negate_128 (uint128 a); 44 int128 negate_s128 (int128 a); 45 uint128 lshift_128 (uint128 a, unsigned int n); 46 int128 lshift_s128 (int128 a, unsigned int n); 47 uint128 rshift_128 (uint128 a, unsigned int n); 48 int128 rshift_s128 (int128 a, unsigned int n); 49 #else 50 51 /* if (sizeof(long) < 8), I expect we're on a 32 bit system */ 52 53 # if __SIZEOF_LONG__ < 8 && ! defined (__MINGW64__) 54 55 typedef int TItype __attribute__ ((mode (TI))); 56 typedef unsigned int UTItype __attribute__ ((mode (TI))); 57 58 typedef TItype __int128_t ; 59 typedef UTItype __uint128_t ; 60 61 # endif 62 #endif 63