mirror of
https://github.com/postgres/postgres.git
synced 2026-01-26 09:41:40 +03:00
Cleanup NAN code in float.h, too.
In the same spirit as3bf905692, assume that all compilers we still support provide the NAN macro, and get rid of workarounds for that. The C standard allows implementations to omit NAN if the underlying float arithmetic lacks quiet (non-signaling) NaNs. However, we've required that feature for years: the workarounds only supported lack of the macro, not lack of the functionality. I put in a compile-time #error if there's no macro, just for clarity. Also fix up the copies of these functions in ecpglib, and leave a breadcrumb for the next hacker who touches them. History of the hacks being removed here can be found in commits1bc2d544b,4d17a2146,cec8394b5. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/1952095.1759764279@sss.pgh.pa.us
This commit is contained in:
@@ -69,34 +69,23 @@ garbage_left(enum ARRAY_TYPE isarray, char **scan_length, enum COMPAT_MODE compa
|
||||
return false;
|
||||
}
|
||||
|
||||
/* stolen code from src/backend/utils/adt/float.c */
|
||||
#if defined(WIN32) && !defined(NAN)
|
||||
static const uint32 nan[2] = {0xffffffff, 0x7fffffff};
|
||||
|
||||
#define NAN (*(const double *) nan)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Portability wrappers borrowed from src/include/utils/float.h
|
||||
*/
|
||||
static double
|
||||
get_float8_infinity(void)
|
||||
{
|
||||
#ifdef INFINITY
|
||||
return (double) INFINITY;
|
||||
#else
|
||||
return (double) (HUGE_VAL * HUGE_VAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static double
|
||||
get_float8_nan(void)
|
||||
{
|
||||
/* (double) NAN doesn't work on some NetBSD/MIPS releases */
|
||||
#if defined(NAN) && !(defined(__NetBSD__) && defined(__mips__))
|
||||
return (double) NAN;
|
||||
#else
|
||||
return (double) (0.0 / 0.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
check_special_value(char *ptr, double *retval, char **endptr)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user