diff --git a/libc/integral/normalize.inc b/libc/integral/normalize.inc index bb062e382..39ac2a177 100644 --- a/libc/integral/normalize.inc +++ b/libc/integral/normalize.inc @@ -79,6 +79,10 @@ #undef __linux__ #endif +#ifdef __gnu_linux__ +#undef __gnu_linux__ +#endif + #ifndef __BIGGEST_ALIGNMENT__ #define __BIGGEST_ALIGNMENT__ 16 #endif diff --git a/libc/tinymath/exp10.c b/libc/tinymath/exp10.c index f42d7d574..443800a66 100644 --- a/libc/tinymath/exp10.c +++ b/libc/tinymath/exp10.c @@ -155,5 +155,6 @@ exp10 (double x) __strong_reference(exp10, pow10); #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 +__weak_reference(exp10, pow10l); __weak_reference(exp10, exp10l); #endif diff --git a/libc/tinymath/exp10l.c b/libc/tinymath/exp10l.c index 1111bde6e..d41fd35d3 100644 --- a/libc/tinymath/exp10l.c +++ b/libc/tinymath/exp10l.c @@ -52,6 +52,6 @@ long double exp10l(long double x) return powl(10.0, x); } -__weak_reference(exp10l, pow10l); +__strong_reference(exp10l, pow10l); #endif /* long double is long */ diff --git a/test/ctl/to_string_test.cc b/test/ctl/to_string_test.cc index 69841c7ad..8970d0a0f 100644 --- a/test/ctl/to_string_test.cc +++ b/test/ctl/to_string_test.cc @@ -116,10 +116,12 @@ main() return 31; if (ctl::to_string(3.14L) != "3.14") return 32; +#if LDBL_MANT_DIG > 64 if (ctl::to_string(LDBL_MAX) != "1.189731495357232e+4932") return 33; if (ctl::to_string(-LDBL_MAX) != "-1.189731495357232e+4932") return 34; +#endif } CheckForMemoryLeaks(); diff --git a/test/libc/tinymath/acosh_test.c b/test/libc/tinymath/acosh_test.c index 008972047..639782c04 100644 --- a/test/libc/tinymath/acosh_test.c +++ b/test/libc/tinymath/acosh_test.c @@ -48,7 +48,9 @@ TEST(acoshf, test) { TEST(acoshl, test) { volatile long double x = 16; EXPECT_STREQ("4", gc(xdtoal(sqrtl(x)))); +#if LDBL_MANT_DIG > 64 EXPECT_STREQ(".9624236501192069", gc(xdtoal(_acoshl(1.5)))); +#endif EXPECT_STREQ("0", gc(xdtoal(_acoshl(1)))); EXPECT_TRUE(isnan(_acoshl(NAN))); EXPECT_TRUE(isnan(_acoshl(.5))); diff --git a/test/libc/tinymath/asinh_test.c b/test/libc/tinymath/asinh_test.c index 1584a1ad6..1a2599534 100644 --- a/test/libc/tinymath/asinh_test.c +++ b/test/libc/tinymath/asinh_test.c @@ -46,8 +46,10 @@ TEST(asinhf, test) { } TEST(asinhl, test) { +#if LDBL_MANT_DIG > 64 EXPECT_STREQ(".4812118250596034", gc(xdtoal(_asinhl(+.5)))); EXPECT_STREQ("-.4812118250596034", gc(xdtoal(_asinhl(-.5)))); +#endif EXPECT_STREQ("0", gc(xdtoal(_asinhl(0)))); EXPECT_STREQ("NAN", gc(xdtoal(_asinhl(NAN)))); EXPECT_STREQ("INFINITY", gc(xdtoal(_asinhl(INFINITY)))); diff --git a/test/libc/tinymath/hypot_test.c b/test/libc/tinymath/hypot_test.c index 802d994ed..37ede41a0 100644 --- a/test/libc/tinymath/hypot_test.c +++ b/test/libc/tinymath/hypot_test.c @@ -99,8 +99,10 @@ TEST(hypotll, test) { EXPECT_STREQ("1.414213562373095", gc(xdtoal(_hypotl(-1, 1)))); EXPECT_STREQ("1.414213626012708", gc(xdtoal(_hypotl(1.0000001, .99999999)))); EXPECT_STREQ("1.414213626012708", gc(xdtoal(_hypotl(.99999999, 1.0000001)))); +#if LDBL_MANT_DIG > 64 EXPECT_STREQ("1.414213562373095e+4931", gc(xdtoal(_hypotl(1e4931L, 1e4931L)))); +#endif EXPECT_STREQ("NAN", gc(xdtoal(_hypotl(0, NAN)))); EXPECT_STREQ("NAN", gc(xdtoal(_hypotl(NAN, 0)))); EXPECT_STREQ("NAN", gc(xdtoal(_hypotl(NAN, NAN)))); diff --git a/tool/cosmocc/bin/cosmocc b/tool/cosmocc/bin/cosmocc index 8020cca6b..0eafccc54 100755 --- a/tool/cosmocc/bin/cosmocc +++ b/tool/cosmocc/bin/cosmocc @@ -139,7 +139,9 @@ for x; do elif [ x"$x" != x"${x#-O}" ]; then # startswith(x, "-O") OPT=$x elif [ x"$x" = x"-c" ]; then - INTENT=cc + if [ x"$INTENT" != x"cpp" ]; then + INTENT=cc + fi elif [ x"$x" = x"-E" ] || [ x"$x" = x"-M" ] || [ x"$x" = x"-MM" ]; then @@ -266,7 +268,9 @@ CC_AARCH64="$BIN/aarch64-linux-cosmo-gcc" if [ x"$PROG" != x"${PROG%++}" ]; then CC_X86_64="$BIN/x86_64-linux-cosmo-g++" CC_AARCH64="$BIN/aarch64-linux-cosmo-g++" - CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit" + if [ x"$INTENT" != x"cpp" ]; then + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit" + fi CPPFLAGS="-isystem $BIN/../include/third_party/libcxx $CPPFLAGS" else CFLAGS="$CFLAGS -Wno-implicit-int" @@ -325,6 +329,9 @@ if [ $INTENT = cpp ]; then if [ -n "$OUTPUT" ]; then ARGS="$ARGS -o$OUTPUT" fi + # undefine cpu-specific and linux-specific defines + # we get rid of long double too to not lead astray + # we shall leave behind unix, __unix, and __unix__ set -- \ "$CC_X86_64" \ -U__k8 \ @@ -333,10 +340,21 @@ if [ $INTENT = cpp ]; then -U__amd64__ \ -U__x86_64 \ -U__x86_64__ \ + -U__MMX__ \ + -U__MMX_WITH_SSE__ \ + -U__SSE_MATH__ \ + -U__SEG_FS \ + -U__SEG_GS \ -U__SSE__ \ + -U__FXSR__ \ -U__SSE2__ \ -U__SSE2_MATH__ \ + -Ulinux \ + -U__linux \ + -U__linux__ \ + -U__gnu_linux__ \ -mno-red-zone \ + -mlong-double-64 \ $PLATFORM \ $CPPFLAGS \ $ARGS diff --git a/tool/emacs/cosmo-cpp-constants.el b/tool/emacs/cosmo-cpp-constants.el index 5c244b7c0..106c8bc17 100644 --- a/tool/emacs/cosmo-cpp-constants.el +++ b/tool/emacs/cosmo-cpp-constants.el @@ -17,6 +17,7 @@ "__GNUC__" "__APPLE__" "__linux__" + "__gnu_linux__" "__HAIKU__" "__CYGWIN__" "__EMSCRIPTEN__" @@ -25,10 +26,13 @@ "__NetBSD__" "__NetBSD_Version__" "__OpenBSD__" + "__Fuchsia__" "__COSMOPOLITAN__" "__COSMOCC__" "__FATCOSMOCC__" "__GLIBC__" + "__ELF__" + "__GNU__" "__linux" "__MACH__" "__GNUG__" @@ -128,6 +132,8 @@ "__ARM_FP16_IEEE" "__ARM_FP_FAST" "__powerpc__" + "__POWERPC__" + "__ppc__" "__powerpc64__" "__POWER9_VECTOR__" "__wasm_simd128__" diff --git a/tool/emacs/cosmo-platform-constants.el b/tool/emacs/cosmo-platform-constants.el index caf232607..48b408b29 100644 --- a/tool/emacs/cosmo-platform-constants.el +++ b/tool/emacs/cosmo-platform-constants.el @@ -5,7 +5,6 @@ '("__cplusplus" "__OBJC__" "__STRICT_ANSI__" - "__ELF__" "__VERSION__" "__OPTIMIZE__" "__OPTIMIZE_SIZE__" @@ -29,6 +28,7 @@ "__LP64__" "__SSP__" "__SSP_ALL__" + "__unix" "__unix__" "__vax__" "__ns16000__"