1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun ------------------------------------------------------------------------------- 4*4882a593Smuzhiyun The macro `BITS64' can be defined to indicate that 64-bit integer types are 5*4882a593Smuzhiyun supported by the compiler. 6*4882a593Smuzhiyun ------------------------------------------------------------------------------- 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun #define BITS64 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun /* 11*4882a593Smuzhiyun ------------------------------------------------------------------------------- 12*4882a593Smuzhiyun Each of the following `typedef's defines the most convenient type that holds 13*4882a593Smuzhiyun integers of at least as many bits as specified. For example, `uint8' should 14*4882a593Smuzhiyun be the most convenient type that can hold unsigned integers of as many as 15*4882a593Smuzhiyun 8 bits. The `flag' type must be able to hold either a 0 or 1. For most 16*4882a593Smuzhiyun implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 17*4882a593Smuzhiyun to the same as `int'. 18*4882a593Smuzhiyun ------------------------------------------------------------------------------- 19*4882a593Smuzhiyun */ 20*4882a593Smuzhiyun typedef char flag; 21*4882a593Smuzhiyun typedef unsigned char uint8; 22*4882a593Smuzhiyun typedef signed char int8; 23*4882a593Smuzhiyun typedef int uint16; 24*4882a593Smuzhiyun typedef int int16; 25*4882a593Smuzhiyun typedef unsigned int uint32; 26*4882a593Smuzhiyun typedef signed int int32; 27*4882a593Smuzhiyun #ifdef BITS64 28*4882a593Smuzhiyun typedef unsigned long long int bits64; 29*4882a593Smuzhiyun typedef signed long long int sbits64; 30*4882a593Smuzhiyun #endif 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun /* 33*4882a593Smuzhiyun ------------------------------------------------------------------------------- 34*4882a593Smuzhiyun Each of the following `typedef's defines a type that holds integers 35*4882a593Smuzhiyun of _exactly_ the number of bits specified. For instance, for most 36*4882a593Smuzhiyun implementation of C, `bits16' and `sbits16' should be `typedef'ed to 37*4882a593Smuzhiyun `unsigned short int' and `signed short int' (or `short int'), respectively. 38*4882a593Smuzhiyun ------------------------------------------------------------------------------- 39*4882a593Smuzhiyun */ 40*4882a593Smuzhiyun typedef unsigned char bits8; 41*4882a593Smuzhiyun typedef signed char sbits8; 42*4882a593Smuzhiyun typedef unsigned short int bits16; 43*4882a593Smuzhiyun typedef signed short int sbits16; 44*4882a593Smuzhiyun typedef unsigned int bits32; 45*4882a593Smuzhiyun typedef signed int sbits32; 46*4882a593Smuzhiyun #ifdef BITS64 47*4882a593Smuzhiyun typedef unsigned long long int uint64; 48*4882a593Smuzhiyun typedef signed long long int int64; 49*4882a593Smuzhiyun #endif 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun #ifdef BITS64 52*4882a593Smuzhiyun /* 53*4882a593Smuzhiyun ------------------------------------------------------------------------------- 54*4882a593Smuzhiyun The `LIT64' macro takes as its argument a textual integer literal and if 55*4882a593Smuzhiyun necessary ``marks'' the literal as having a 64-bit integer type. For 56*4882a593Smuzhiyun example, the Gnu C Compiler (`gcc') requires that 64-bit literals be 57*4882a593Smuzhiyun appended with the letters `LL' standing for `long long', which is `gcc's 58*4882a593Smuzhiyun name for the 64-bit integer type. Some compilers may allow `LIT64' to be 59*4882a593Smuzhiyun defined as the identity macro: `#define LIT64( a ) a'. 60*4882a593Smuzhiyun ------------------------------------------------------------------------------- 61*4882a593Smuzhiyun */ 62*4882a593Smuzhiyun #define LIT64( a ) a##LL 63*4882a593Smuzhiyun #endif 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun /* 66*4882a593Smuzhiyun ------------------------------------------------------------------------------- 67*4882a593Smuzhiyun The macro `INLINE' can be used before functions that should be inlined. If 68*4882a593Smuzhiyun a compiler does not support explicit inlining, this macro should be defined 69*4882a593Smuzhiyun to be `static'. 70*4882a593Smuzhiyun ------------------------------------------------------------------------------- 71*4882a593Smuzhiyun */ 72*4882a593Smuzhiyun #define INLINE static inline 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun /* For use as a GCC soft-float library we need some special function names. */ 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun #ifdef __LIBFLOAT__ 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun /* Some 32-bit ops can be mapped straight across by just changing the name. */ 80*4882a593Smuzhiyun #define float32_add __addsf3 81*4882a593Smuzhiyun #define float32_sub __subsf3 82*4882a593Smuzhiyun #define float32_mul __mulsf3 83*4882a593Smuzhiyun #define float32_div __divsf3 84*4882a593Smuzhiyun #define int32_to_float32 __floatsisf 85*4882a593Smuzhiyun #define float32_to_int32_round_to_zero __fixsfsi 86*4882a593Smuzhiyun #define float32_to_uint32_round_to_zero __fixunssfsi 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun /* These ones go through the glue code. To avoid namespace pollution 89*4882a593Smuzhiyun we rename the internal functions too. */ 90*4882a593Smuzhiyun #define float32_eq ___float32_eq 91*4882a593Smuzhiyun #define float32_le ___float32_le 92*4882a593Smuzhiyun #define float32_lt ___float32_lt 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun /* All the 64-bit ops have to go through the glue, so we pull the same 95*4882a593Smuzhiyun trick. */ 96*4882a593Smuzhiyun #define float64_add ___float64_add 97*4882a593Smuzhiyun #define float64_sub ___float64_sub 98*4882a593Smuzhiyun #define float64_mul ___float64_mul 99*4882a593Smuzhiyun #define float64_div ___float64_div 100*4882a593Smuzhiyun #define int32_to_float64 ___int32_to_float64 101*4882a593Smuzhiyun #define float64_to_int32_round_to_zero ___float64_to_int32_round_to_zero 102*4882a593Smuzhiyun #define float64_to_uint32_round_to_zero ___float64_to_uint32_round_to_zero 103*4882a593Smuzhiyun #define float64_to_float32 ___float64_to_float32 104*4882a593Smuzhiyun #define float32_to_float64 ___float32_to_float64 105*4882a593Smuzhiyun #define float64_eq ___float64_eq 106*4882a593Smuzhiyun #define float64_le ___float64_le 107*4882a593Smuzhiyun #define float64_lt ___float64_lt 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun #if 0 110*4882a593Smuzhiyun #define float64_add __adddf3 111*4882a593Smuzhiyun #define float64_sub __subdf3 112*4882a593Smuzhiyun #define float64_mul __muldf3 113*4882a593Smuzhiyun #define float64_div __divdf3 114*4882a593Smuzhiyun #define int32_to_float64 __floatsidf 115*4882a593Smuzhiyun #define float64_to_int32_round_to_zero __fixdfsi 116*4882a593Smuzhiyun #define float64_to_uint32_round_to_zero __fixunsdfsi 117*4882a593Smuzhiyun #define float64_to_float32 __truncdfsf2 118*4882a593Smuzhiyun #define float32_to_float64 __extendsfdf2 119*4882a593Smuzhiyun #endif 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun #endif 122