Added half type

This commit is contained in:
Andrew Kane
2023-12-03 13:01:47 -08:00
parent 4d6739a7af
commit 422667f6c6
13 changed files with 1071 additions and 58 deletions

28
src/half.h Normal file
View File

@@ -0,0 +1,28 @@
#ifndef HALF_H
#define HALF_H
#define __STDC_WANT_IEC_60559_TYPES_EXT__
#include <float.h>
/* _Float16 and __fp16 are not supported on x86_64 with GCC 11 */
#if defined(__is_identifier)
#if __is_identifier(_Float16)
#define FLT16_SUPPORT
#endif
#elif defined(FLT16_MAX)
#define FLT16_SUPPORT
#endif
#ifdef FLT16_SUPPORT
#define half _Float16
#define HALF_MAX FLT16_MAX
#else
#define half uint16
#define HALF_MAX 65504
#endif
#define PG_GETARG_HALF(n) DatumGetHalf(PG_GETARG_DATUM(n))
#define PG_RETURN_HALF(x) return HalfGetDatum(x)
#endif