18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 48c2ecf20Sopenharmony_ciThe macro `BITS64' can be defined to indicate that 64-bit integer types are 58c2ecf20Sopenharmony_cisupported by the compiler. 68c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 78c2ecf20Sopenharmony_ci*/ 88c2ecf20Sopenharmony_ci#define BITS64 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* 118c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 128c2ecf20Sopenharmony_ciEach of the following `typedef's defines the most convenient type that holds 138c2ecf20Sopenharmony_ciintegers of at least as many bits as specified. For example, `uint8' should 148c2ecf20Sopenharmony_cibe the most convenient type that can hold unsigned integers of as many as 158c2ecf20Sopenharmony_ci8 bits. The `flag' type must be able to hold either a 0 or 1. For most 168c2ecf20Sopenharmony_ciimplementations of C, `flag', `uint8', and `int8' should all be `typedef'ed 178c2ecf20Sopenharmony_cito the same as `int'. 188c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 198c2ecf20Sopenharmony_ci*/ 208c2ecf20Sopenharmony_citypedef char flag; 218c2ecf20Sopenharmony_citypedef unsigned char uint8; 228c2ecf20Sopenharmony_citypedef signed char int8; 238c2ecf20Sopenharmony_citypedef int uint16; 248c2ecf20Sopenharmony_citypedef int int16; 258c2ecf20Sopenharmony_citypedef unsigned int uint32; 268c2ecf20Sopenharmony_citypedef signed int int32; 278c2ecf20Sopenharmony_ci#ifdef BITS64 288c2ecf20Sopenharmony_citypedef unsigned long long int bits64; 298c2ecf20Sopenharmony_citypedef signed long long int sbits64; 308c2ecf20Sopenharmony_ci#endif 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* 338c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 348c2ecf20Sopenharmony_ciEach of the following `typedef's defines a type that holds integers 358c2ecf20Sopenharmony_ciof _exactly_ the number of bits specified. For instance, for most 368c2ecf20Sopenharmony_ciimplementation of C, `bits16' and `sbits16' should be `typedef'ed to 378c2ecf20Sopenharmony_ci`unsigned short int' and `signed short int' (or `short int'), respectively. 388c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 398c2ecf20Sopenharmony_ci*/ 408c2ecf20Sopenharmony_citypedef unsigned char bits8; 418c2ecf20Sopenharmony_citypedef signed char sbits8; 428c2ecf20Sopenharmony_citypedef unsigned short int bits16; 438c2ecf20Sopenharmony_citypedef signed short int sbits16; 448c2ecf20Sopenharmony_citypedef unsigned int bits32; 458c2ecf20Sopenharmony_citypedef signed int sbits32; 468c2ecf20Sopenharmony_ci#ifdef BITS64 478c2ecf20Sopenharmony_citypedef unsigned long long int uint64; 488c2ecf20Sopenharmony_citypedef signed long long int int64; 498c2ecf20Sopenharmony_ci#endif 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#ifdef BITS64 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 548c2ecf20Sopenharmony_ciThe `LIT64' macro takes as its argument a textual integer literal and if 558c2ecf20Sopenharmony_cinecessary ``marks'' the literal as having a 64-bit integer type. For 568c2ecf20Sopenharmony_ciexample, the Gnu C Compiler (`gcc') requires that 64-bit literals be 578c2ecf20Sopenharmony_ciappended with the letters `LL' standing for `long long', which is `gcc's 588c2ecf20Sopenharmony_ciname for the 64-bit integer type. Some compilers may allow `LIT64' to be 598c2ecf20Sopenharmony_cidefined as the identity macro: `#define LIT64( a ) a'. 608c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 618c2ecf20Sopenharmony_ci*/ 628c2ecf20Sopenharmony_ci#define LIT64( a ) a##LL 638c2ecf20Sopenharmony_ci#endif 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* 668c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 678c2ecf20Sopenharmony_ciThe macro `INLINE' can be used before functions that should be inlined. If 688c2ecf20Sopenharmony_cia compiler does not support explicit inlining, this macro should be defined 698c2ecf20Sopenharmony_cito be `static'. 708c2ecf20Sopenharmony_ci------------------------------------------------------------------------------- 718c2ecf20Sopenharmony_ci*/ 728c2ecf20Sopenharmony_ci#define INLINE static inline 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* For use as a GCC soft-float library we need some special function names. */ 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#ifdef __LIBFLOAT__ 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* Some 32-bit ops can be mapped straight across by just changing the name. */ 808c2ecf20Sopenharmony_ci#define float32_add __addsf3 818c2ecf20Sopenharmony_ci#define float32_sub __subsf3 828c2ecf20Sopenharmony_ci#define float32_mul __mulsf3 838c2ecf20Sopenharmony_ci#define float32_div __divsf3 848c2ecf20Sopenharmony_ci#define int32_to_float32 __floatsisf 858c2ecf20Sopenharmony_ci#define float32_to_int32_round_to_zero __fixsfsi 868c2ecf20Sopenharmony_ci#define float32_to_uint32_round_to_zero __fixunssfsi 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* These ones go through the glue code. To avoid namespace pollution 898c2ecf20Sopenharmony_ci we rename the internal functions too. */ 908c2ecf20Sopenharmony_ci#define float32_eq ___float32_eq 918c2ecf20Sopenharmony_ci#define float32_le ___float32_le 928c2ecf20Sopenharmony_ci#define float32_lt ___float32_lt 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* All the 64-bit ops have to go through the glue, so we pull the same 958c2ecf20Sopenharmony_ci trick. */ 968c2ecf20Sopenharmony_ci#define float64_add ___float64_add 978c2ecf20Sopenharmony_ci#define float64_sub ___float64_sub 988c2ecf20Sopenharmony_ci#define float64_mul ___float64_mul 998c2ecf20Sopenharmony_ci#define float64_div ___float64_div 1008c2ecf20Sopenharmony_ci#define int32_to_float64 ___int32_to_float64 1018c2ecf20Sopenharmony_ci#define float64_to_int32_round_to_zero ___float64_to_int32_round_to_zero 1028c2ecf20Sopenharmony_ci#define float64_to_uint32_round_to_zero ___float64_to_uint32_round_to_zero 1038c2ecf20Sopenharmony_ci#define float64_to_float32 ___float64_to_float32 1048c2ecf20Sopenharmony_ci#define float32_to_float64 ___float32_to_float64 1058c2ecf20Sopenharmony_ci#define float64_eq ___float64_eq 1068c2ecf20Sopenharmony_ci#define float64_le ___float64_le 1078c2ecf20Sopenharmony_ci#define float64_lt ___float64_lt 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#if 0 1108c2ecf20Sopenharmony_ci#define float64_add __adddf3 1118c2ecf20Sopenharmony_ci#define float64_sub __subdf3 1128c2ecf20Sopenharmony_ci#define float64_mul __muldf3 1138c2ecf20Sopenharmony_ci#define float64_div __divdf3 1148c2ecf20Sopenharmony_ci#define int32_to_float64 __floatsidf 1158c2ecf20Sopenharmony_ci#define float64_to_int32_round_to_zero __fixdfsi 1168c2ecf20Sopenharmony_ci#define float64_to_uint32_round_to_zero __fixunsdfsi 1178c2ecf20Sopenharmony_ci#define float64_to_float32 __truncdfsf2 1188c2ecf20Sopenharmony_ci#define float32_to_float64 __extendsfdf2 1198c2ecf20Sopenharmony_ci#endif 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci#endif 122