Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003 -------------------------------------------------------------------------------
0004 The macro `BITS64' can be defined to indicate that 64-bit integer types are
0005 supported by the compiler.
0006 -------------------------------------------------------------------------------
0007 */
0008 #define BITS64
0009 
0010 /*
0011 -------------------------------------------------------------------------------
0012 Each of the following `typedef's defines the most convenient type that holds
0013 integers of at least as many bits as specified.  For example, `uint8' should
0014 be the most convenient type that can hold unsigned integers of as many as
0015 8 bits.  The `flag' type must be able to hold either a 0 or 1.  For most
0016 implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
0017 to the same as `int'.
0018 -------------------------------------------------------------------------------
0019 */
0020 typedef char flag;
0021 typedef unsigned char uint8;
0022 typedef signed char int8;
0023 typedef int uint16;
0024 typedef int int16;
0025 typedef unsigned int uint32;
0026 typedef signed int int32;
0027 #ifdef BITS64
0028 typedef unsigned long long int bits64;
0029 typedef signed long long int sbits64;
0030 #endif
0031 
0032 /*
0033 -------------------------------------------------------------------------------
0034 Each of the following `typedef's defines a type that holds integers
0035 of _exactly_ the number of bits specified.  For instance, for most
0036 implementation of C, `bits16' and `sbits16' should be `typedef'ed to
0037 `unsigned short int' and `signed short int' (or `short int'), respectively.
0038 -------------------------------------------------------------------------------
0039 */
0040 typedef unsigned char bits8;
0041 typedef signed char sbits8;
0042 typedef unsigned short int bits16;
0043 typedef signed short int sbits16;
0044 typedef unsigned int bits32;
0045 typedef signed int sbits32;
0046 #ifdef BITS64
0047 typedef unsigned long long int uint64;
0048 typedef signed long long int int64;
0049 #endif
0050 
0051 #ifdef BITS64
0052 /*
0053 -------------------------------------------------------------------------------
0054 The `LIT64' macro takes as its argument a textual integer literal and if
0055 necessary ``marks'' the literal as having a 64-bit integer type.  For
0056 example, the Gnu C Compiler (`gcc') requires that 64-bit literals be
0057 appended with the letters `LL' standing for `long long', which is `gcc's
0058 name for the 64-bit integer type.  Some compilers may allow `LIT64' to be
0059 defined as the identity macro:  `#define LIT64( a ) a'.
0060 -------------------------------------------------------------------------------
0061 */
0062 #define LIT64( a ) a##LL
0063 #endif
0064 
0065 /*
0066 -------------------------------------------------------------------------------
0067 The macro `INLINE' can be used before functions that should be inlined.  If
0068 a compiler does not support explicit inlining, this macro should be defined
0069 to be `static'.
0070 -------------------------------------------------------------------------------
0071 */
0072 #define INLINE static inline
0073 
0074 
0075 /* For use as a GCC soft-float library we need some special function names. */
0076 
0077 #ifdef __LIBFLOAT__
0078 
0079 /* Some 32-bit ops can be mapped straight across by just changing the name. */
0080 #define float32_add         __addsf3
0081 #define float32_sub         __subsf3
0082 #define float32_mul         __mulsf3
0083 #define float32_div         __divsf3
0084 #define int32_to_float32        __floatsisf
0085 #define float32_to_int32_round_to_zero  __fixsfsi
0086 #define float32_to_uint32_round_to_zero __fixunssfsi
0087 
0088 /* These ones go through the glue code.  To avoid namespace pollution
0089    we rename the internal functions too.  */
0090 #define float32_eq          ___float32_eq
0091 #define float32_le          ___float32_le
0092 #define float32_lt          ___float32_lt
0093 
0094 /* All the 64-bit ops have to go through the glue, so we pull the same
0095    trick.  */
0096 #define float64_add         ___float64_add
0097 #define float64_sub         ___float64_sub
0098 #define float64_mul         ___float64_mul
0099 #define float64_div         ___float64_div
0100 #define int32_to_float64        ___int32_to_float64
0101 #define float64_to_int32_round_to_zero  ___float64_to_int32_round_to_zero
0102 #define float64_to_uint32_round_to_zero ___float64_to_uint32_round_to_zero
0103 #define float64_to_float32      ___float64_to_float32
0104 #define float32_to_float64      ___float32_to_float64
0105 #define float64_eq          ___float64_eq
0106 #define float64_le          ___float64_le
0107 #define float64_lt          ___float64_lt
0108 
0109 #if 0
0110 #define float64_add         __adddf3
0111 #define float64_sub         __subdf3
0112 #define float64_mul         __muldf3
0113 #define float64_div         __divdf3
0114 #define int32_to_float64        __floatsidf
0115 #define float64_to_int32_round_to_zero  __fixdfsi
0116 #define float64_to_uint32_round_to_zero __fixunsdfsi
0117 #define float64_to_float32      __truncdfsf2
0118 #define float32_to_float64      __extendsfdf2
0119 #endif
0120 
0121 #endif