@@ -36,6 +36,8 @@ typedef unsigned long long uint64_t;
3636#include <stdint.h>
3737#endif
3838#include <stddef.h>
39+ #define __STDC_WANT_IEC_60559_TYPES_EXT__
40+ #include <float.h>
3941
4042//------------------------- Compiler ------------------------------------------
4143 #if defined(__GNUC__ )
@@ -169,15 +171,19 @@ static ALWAYS_INLINE unsigned short ctou16(const void *cp) { unsigned short
169171static ALWAYS_INLINE unsigned ctou32 (const void * cp ) { unsigned x ; memcpy (& x , cp , sizeof (x )); return x ; }
170172static ALWAYS_INLINE unsigned long long ctou64 (const void * cp ) { unsigned long long x ; memcpy (& x , cp , sizeof (x )); return x ; }
171173static ALWAYS_INLINE size_t ctousz (const void * cp ) { size_t x ; memcpy (& x , cp , sizeof (x )); return x ; }
174+ #ifdef FLT16_MAX
172175static ALWAYS_INLINE _Float16 ctof16 (const void * cp ) { _Float16 x ; memcpy (& x , cp , sizeof (x )); return x ; }
176+ #endif
173177static ALWAYS_INLINE float ctof32 (const void * cp ) { float x ; memcpy (& x , cp , sizeof (x )); return x ; }
174178static ALWAYS_INLINE double ctof64 (const void * cp ) { double x ; memcpy (& x , cp , sizeof (x )); return x ; }
175179
176180static ALWAYS_INLINE void stou16 ( void * cp , unsigned short x ) { memcpy (cp , & x , sizeof (x )); } // ua write
177181static ALWAYS_INLINE void stou32 ( void * cp , unsigned x ) { memcpy (cp , & x , sizeof (x )); }
178182static ALWAYS_INLINE void stou64 ( void * cp , unsigned long long x ) { memcpy (cp , & x , sizeof (x )); }
179183static ALWAYS_INLINE void stousz ( void * cp , size_t x ) { memcpy (cp , & x , sizeof (x )); }
184+ #ifdef FLT16_MAX
180185static ALWAYS_INLINE void stof16 ( void * cp , _Float16 x ) { memcpy (cp , & x , sizeof (x )); }
186+ #endif
181187static ALWAYS_INLINE void stof32 ( void * cp , float x ) { memcpy (cp , & x , sizeof (x )); }
182188static ALWAYS_INLINE void stof64 ( void * cp , double x ) { memcpy (cp , & x , sizeof (x )); }
183189
@@ -227,7 +233,9 @@ struct _PACKED doubleu { double d; };
227233struct _PACKED shortu { unsigned short s ; };
228234struct _PACKED unsignedu { unsigned u ; };
229235struct _PACKED longu { uint64_t l ; };
236+ #ifdef FLT16_MAX
230237struct _PACKED float16u { _Float16 g ; };
238+ #endif
231239struct _PACKED floatu { float f ; };
232240struct _PACKED doubleu { double d ; };
233241
0 commit comments