162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci------------------------------------------------------------------------------- 462306a36Sopenharmony_ciThe macro `BITS64' can be defined to indicate that 64-bit integer types are 562306a36Sopenharmony_cisupported by the compiler. 662306a36Sopenharmony_ci------------------------------------------------------------------------------- 762306a36Sopenharmony_ci*/ 862306a36Sopenharmony_ci#define BITS64 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci/* 1162306a36Sopenharmony_ci------------------------------------------------------------------------------- 1262306a36Sopenharmony_ciEach of the following `typedef's defines the most convenient type that holds 1362306a36Sopenharmony_ciintegers of at least as many bits as specified. For example, `uint8' should 1462306a36Sopenharmony_cibe the most convenient type that can hold unsigned integers of as many as 1562306a36Sopenharmony_ci8 bits. The `flag' type must be able to hold either a 0 or 1. For most 1662306a36Sopenharmony_ciimplementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 1762306a36Sopenharmony_cito the same as `int'. 1862306a36Sopenharmony_ci------------------------------------------------------------------------------- 1962306a36Sopenharmony_ci*/ 2062306a36Sopenharmony_citypedef char flag; 2162306a36Sopenharmony_citypedef unsigned char uint8; 2262306a36Sopenharmony_citypedef signed char int8; 2362306a36Sopenharmony_citypedef int uint16; 2462306a36Sopenharmony_citypedef int int16; 2562306a36Sopenharmony_citypedef unsigned int uint32; 2662306a36Sopenharmony_citypedef signed int int32; 2762306a36Sopenharmony_ci#ifdef BITS64 2862306a36Sopenharmony_citypedef unsigned long long int bits64; 2962306a36Sopenharmony_citypedef signed long long int sbits64; 3062306a36Sopenharmony_ci#endif 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci/* 3362306a36Sopenharmony_ci------------------------------------------------------------------------------- 3462306a36Sopenharmony_ciEach of the following `typedef's defines a type that holds integers 3562306a36Sopenharmony_ciof _exactly_ the number of bits specified. For instance, for most 3662306a36Sopenharmony_ciimplementation of C, `bits16' and `sbits16' should be `typedef'ed to 3762306a36Sopenharmony_ci`unsigned short int' and `signed short int' (or `short int'), respectively. 3862306a36Sopenharmony_ci------------------------------------------------------------------------------- 3962306a36Sopenharmony_ci*/ 4062306a36Sopenharmony_citypedef unsigned char bits8; 4162306a36Sopenharmony_citypedef signed char sbits8; 4262306a36Sopenharmony_citypedef unsigned short int bits16; 4362306a36Sopenharmony_citypedef signed short int sbits16; 4462306a36Sopenharmony_citypedef unsigned int bits32; 4562306a36Sopenharmony_citypedef signed int sbits32; 4662306a36Sopenharmony_ci#ifdef BITS64 4762306a36Sopenharmony_citypedef unsigned long long int uint64; 4862306a36Sopenharmony_citypedef signed long long int int64; 4962306a36Sopenharmony_ci#endif 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#ifdef BITS64 5262306a36Sopenharmony_ci/* 5362306a36Sopenharmony_ci------------------------------------------------------------------------------- 5462306a36Sopenharmony_ciThe `LIT64' macro takes as its argument a textual integer literal and if 5562306a36Sopenharmony_cinecessary ``marks'' the literal as having a 64-bit integer type. For 5662306a36Sopenharmony_ciexample, the Gnu C Compiler (`gcc') requires that 64-bit literals be 5762306a36Sopenharmony_ciappended with the letters `LL' standing for `long long', which is `gcc's 5862306a36Sopenharmony_ciname for the 64-bit integer type. Some compilers may allow `LIT64' to be 5962306a36Sopenharmony_cidefined as the identity macro: `#define LIT64( a ) a'. 6062306a36Sopenharmony_ci------------------------------------------------------------------------------- 6162306a36Sopenharmony_ci*/ 6262306a36Sopenharmony_ci#define LIT64( a ) a##LL 6362306a36Sopenharmony_ci#endif 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* 6662306a36Sopenharmony_ci------------------------------------------------------------------------------- 6762306a36Sopenharmony_ciThe macro `INLINE' can be used before functions that should be inlined. If 6862306a36Sopenharmony_cia compiler does not support explicit inlining, this macro should be defined 6962306a36Sopenharmony_cito be `static'. 7062306a36Sopenharmony_ci------------------------------------------------------------------------------- 7162306a36Sopenharmony_ci*/ 7262306a36Sopenharmony_ci#define INLINE static inline 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* For use as a GCC soft-float library we need some special function names. */ 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci#ifdef __LIBFLOAT__ 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci/* Some 32-bit ops can be mapped straight across by just changing the name. */ 8062306a36Sopenharmony_ci#define float32_add __addsf3 8162306a36Sopenharmony_ci#define float32_sub __subsf3 8262306a36Sopenharmony_ci#define float32_mul __mulsf3 8362306a36Sopenharmony_ci#define float32_div __divsf3 8462306a36Sopenharmony_ci#define int32_to_float32 __floatsisf 8562306a36Sopenharmony_ci#define float32_to_int32_round_to_zero __fixsfsi 8662306a36Sopenharmony_ci#define float32_to_uint32_round_to_zero __fixunssfsi 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* These ones go through the glue code. To avoid namespace pollution 8962306a36Sopenharmony_ci we rename the internal functions too. */ 9062306a36Sopenharmony_ci#define float32_eq ___float32_eq 9162306a36Sopenharmony_ci#define float32_le ___float32_le 9262306a36Sopenharmony_ci#define float32_lt ___float32_lt 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci/* All the 64-bit ops have to go through the glue, so we pull the same 9562306a36Sopenharmony_ci trick. */ 9662306a36Sopenharmony_ci#define float64_add ___float64_add 9762306a36Sopenharmony_ci#define float64_sub ___float64_sub 9862306a36Sopenharmony_ci#define float64_mul ___float64_mul 9962306a36Sopenharmony_ci#define float64_div ___float64_div 10062306a36Sopenharmony_ci#define int32_to_float64 ___int32_to_float64 10162306a36Sopenharmony_ci#define float64_to_int32_round_to_zero ___float64_to_int32_round_to_zero 10262306a36Sopenharmony_ci#define float64_to_uint32_round_to_zero ___float64_to_uint32_round_to_zero 10362306a36Sopenharmony_ci#define float64_to_float32 ___float64_to_float32 10462306a36Sopenharmony_ci#define float32_to_float64 ___float32_to_float64 10562306a36Sopenharmony_ci#define float64_eq ___float64_eq 10662306a36Sopenharmony_ci#define float64_le ___float64_le 10762306a36Sopenharmony_ci#define float64_lt ___float64_lt 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#if 0 11062306a36Sopenharmony_ci#define float64_add __adddf3 11162306a36Sopenharmony_ci#define float64_sub __subdf3 11262306a36Sopenharmony_ci#define float64_mul __muldf3 11362306a36Sopenharmony_ci#define float64_div __divdf3 11462306a36Sopenharmony_ci#define int32_to_float64 __floatsidf 11562306a36Sopenharmony_ci#define float64_to_int32_round_to_zero __fixdfsi 11662306a36Sopenharmony_ci#define float64_to_uint32_round_to_zero __fixunsdfsi 11762306a36Sopenharmony_ci#define float64_to_float32 __truncdfsf2 11862306a36Sopenharmony_ci#define float32_to_float64 __extendsfdf2 11962306a36Sopenharmony_ci#endif 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci#endif 122