diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-09-16 07:34:32 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-09-16 07:34:32 -0700 |
commit | d041d90629f26b071fb71bebda785eb0b262f806 (patch) | |
tree | 2009abf956bf44714edbf6c9e89d8fdd457e12c7 | |
parent | 60fa0cd314d283c99af60a650ba4f6c04ee1870a (diff) | |
download | txr-d041d90629f26b071fb71bebda785eb0b262f806.tar.gz txr-d041d90629f26b071fb71bebda785eb0b262f806.tar.bz2 txr-d041d90629f26b071fb71bebda785eb0b262f806.zip |
nan-boxing: build on older gcc.
Older GCC 4.x versions do not support diagnostic pragmas
in functions and don't have push pragmas for diagnostics.
* arith.c (flo): Put the diagnostic disabling pragma stuff
outside of the function. Instead saving and restoring
the status with push and pop, we just disable the aliasing
warning and re-instate it as a warning.
* lib.h (c_f): Likewise.
-rw-r--r-- | arith.c | 15 | ||||
-rw-r--r-- | lib.h | 15 |
2 files changed, 16 insertions, 14 deletions
@@ -4268,20 +4268,17 @@ INLINE int bad_float(double d) #define bad_float(d) (0) #endif +#if CONFIG_NAN_BOXING && defined __GNUC__ +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif + val flo(double n) { if (bad_float(n)) { uw_throw(numeric_error_s, lit("out-of-range floating-point result")); } else { #if CONFIG_NAN_BOXING -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif ucnum u = *(ucnum *) &n + NAN_FLNUM_DELTA; -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif return coerce(val, u); #else val obj = make_obj(); @@ -4292,6 +4289,10 @@ val flo(double n) } } +#if CONFIG_NAN_BOXING && defined __GNUC__ +#pragma GCC diagnostic warning "-Wstrict-aliasing" +#endif + double c_flo(val num, val self) { #if CONFIG_NAN_BOXING @@ -621,23 +621,24 @@ INLINE ucnum c_u(val num) #endif } +#if CONFIG_NAN_BOXING && defined __GNUC__ +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif + INLINE double c_f(val num) { #if CONFIG_NAN_BOXING ucnum u = coerce(ucnum, num) - NAN_FLNUM_DELTA; -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#endif return *coerce(double *, &u); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif #else return num->fl.n; #endif } +#if CONFIG_NAN_BOXING && defined __GNUC__ +#pragma GCC diagnostic warning "-Wstrict-aliasing" +#endif + #if SIZEOF_WCHAR_T < 4 && !CONFIG_NAN_BOXING #define lit_noex(strlit) coerce(obj_t *,\ coerce(cnum, L"\0" L ## strlit L"\0" + 1) | \ |