mirror of
git://repo.or.cz/tinycc.git
synced 2026-11-05 05:36:35 +08:00
win32: allow self-host with tcc 0.9.27 - part 2 of 2
Commitcb39bc4("Calculate hex floating point with 128 bits instead of 64 bits.", 2025-05-27) started using ldexpl in tccpp.c, however, older tcc like 0.9.27 (2017) don't have it on windows - ldexpl was added to win32/include/math.h (in tcc_libm.h) in commitb11144d(2020). So copy the current ldexpl definition from current tcc_libm.h into tccpp.c - but under a different name.
This commit is contained in:
parent
a667b53fcb
commit
ff85981b6c
43
tccpp.c
43
tccpp.c
@ -21,6 +21,49 @@
|
|||||||
#define USING_GLOBALS
|
#define USING_GLOBALS
|
||||||
#include "tcc.h"
|
#include "tcc.h"
|
||||||
|
|
||||||
|
#if defined(_WIN32) && defined (__TINYC__)
|
||||||
|
/* allow self-host build with tcc 0.97 - doesn't have ldexpl in tcc_libm.h .
|
||||||
|
*
|
||||||
|
* we can't feature-test whether we have ldexpl, and our ./configure also
|
||||||
|
* can't perform such tests (and it's also not used by win32/build-tcc.bat),
|
||||||
|
* so define it unconditionally if we're compiling using tcc on windows
|
||||||
|
* (otherwise the platform's math.h should already have ldexpl).
|
||||||
|
*
|
||||||
|
* we could instead include win32/include/math.h (specifically tcc_libm.h),
|
||||||
|
* but this requires working around include guards and redefinitions,
|
||||||
|
* so KISS - copy the tcc_libm.h definitions here with a different name.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef ldexpl
|
||||||
|
#define ldexpl ldexpl_local
|
||||||
|
|
||||||
|
/* MUSL scalbn - (renamed) copied from win32/include/tcc/tcc_libm.h */
|
||||||
|
static double scalbn_local(double x, int n) {
|
||||||
|
union {double f; uint64_t i;} u;
|
||||||
|
if (n > 1023) {
|
||||||
|
x *= 0x1p1023, n -= 1023;
|
||||||
|
if (n > 1023) {
|
||||||
|
x *= 0x1p1023, n -= 1023;
|
||||||
|
if (n > 1023) n = 1023;
|
||||||
|
}
|
||||||
|
} else if (n < -1022) {
|
||||||
|
x *= 0x1p-1022 * 0x1p53, n += 1022 - 53;
|
||||||
|
if (n < -1022) {
|
||||||
|
x *= 0x1p-1022 * 0x1p53, n += 1022 - 53;
|
||||||
|
if (n < -1022) n = -1022;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
u.i = (0x3ffull + n) << 52;
|
||||||
|
return x * u.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (windows long double is the same type as double - 64bit) */
|
||||||
|
/* (renamed) copied from win32/include/tcc/tcc_libm.h */
|
||||||
|
static long double ldexpl_local(long double x, int exp) {
|
||||||
|
return scalbn_local(x, exp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* #define to 1 to enable (see parse_pp_string()) */
|
/* #define to 1 to enable (see parse_pp_string()) */
|
||||||
#define ACCEPT_LF_IN_STRINGS 0
|
#define ACCEPT_LF_IN_STRINGS 0
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user