The cross toolchain now builds real hosted C++: std::string, vector, unique_ptr, iostreams and exceptions all work in a plain x86_64-montauk-g++ invocation with no special flags. This is the library that native cc1plus will link against for the GCC self-host. crt1 now runs .preinit_array/.init_array before main and hooks .fini_array through atexit (main returns via exit(), so destructors run on both exit paths). Global constructors and libgcc's eh_frame registration both ride this. GCC is reconfigured with --enable-initfini-array (modern arrays instead of .ctors), --with-newlib (satisfies libstdc++'s crossconfig for unknown hosts), --disable-wchar_t and --disable-libstdcxx-pch; the montauk gcc patch grows a hunk keeping os/generic ctype under --with-newlib (the Montauk libc is not newlib). libc additions harvested by the libstdc++ build: mbtowc/wctomb, strxfrm, strtok/strtok_r, a real vfscanf/fscanf/scanf (character- driven with widths and l/ll; also unblocks gprof later), fgetpos/ fsetpos/setbuf/fpos_t, modf plus the C99 float math variants (acosf..tanhf, hypot/hypotf as wrappers), FP_* classification macros, the full POSIX errno vocabulary, complete DT_* dirent types, and mbstate_t. The SDK ships the real libstdc++.a (was an empty stand-in), the C++ headers at 0:/sdk/include/c++, and cxx-test.elf (global ctor, string, vector+sort, unique_ptr, throw/catch; exits 0 on 5/5). Ramdisk sits at 1571 files, within the 2048 table. Co-Authored-By: Claude Fable 5 <[email protected]>
90 lines
2.2 KiB
C
90 lines
2.2 KiB
C
#ifndef _LIBC_MATH_H
|
|
#define _LIBC_MATH_H
|
|
|
|
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define HUGE_VAL __builtin_huge_val()
|
|
#define INFINITY __builtin_inff()
|
|
#define NAN __builtin_nanf("")
|
|
|
|
/* C99 floating-point classification. */
|
|
#define FP_NAN 0
|
|
#define FP_INFINITE 1
|
|
#define FP_ZERO 2
|
|
#define FP_SUBNORMAL 3
|
|
#define FP_NORMAL 4
|
|
|
|
#define fpclassify(x) \
|
|
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, \
|
|
FP_ZERO, x)
|
|
#define isnan(x) __builtin_isnan(x)
|
|
#define isinf(x) __builtin_isinf(x)
|
|
#define isfinite(x) __builtin_isfinite(x)
|
|
#define isnormal(x) __builtin_isnormal(x)
|
|
#define signbit(x) __builtin_signbit(x)
|
|
|
|
double fabs(double x);
|
|
double frexp(double x, int *exp);
|
|
|
|
/* C89 modf and the C99 float variants assumed by hosted libstdc++
|
|
(--with-newlib crossconfig). The float forms wrap the double
|
|
implementations. */
|
|
double modf(double x, double *iptr);
|
|
float modff(float x, float *iptr);
|
|
double hypot(double x, double y);
|
|
float hypotf(float x, float y);
|
|
float acosf(float x);
|
|
float asinf(float x);
|
|
float atanf(float x);
|
|
float atan2f(float y, float x);
|
|
float coshf(float x);
|
|
float expf(float x);
|
|
float fmodf(float x, float y);
|
|
float frexpf(float x, int *exp);
|
|
float ldexpf(float x, int exp);
|
|
float logf(float x);
|
|
float log10f(float x);
|
|
float powf(float x, float y);
|
|
float sinhf(float x);
|
|
float tanf(float x);
|
|
float tanhf(float x);
|
|
double ldexp(double x, int n);
|
|
long double ldexpl(long double x, int n);
|
|
double floor(double x);
|
|
double ceil(double x);
|
|
double sqrt(double x);
|
|
double sin(double x);
|
|
double cos(double x);
|
|
double tan(double x);
|
|
double asin(double x);
|
|
double acos(double x);
|
|
double atan(double x);
|
|
double atan2(double y, double x);
|
|
double pow(double base, double exp);
|
|
double log(double x);
|
|
double log2(double x);
|
|
double log10(double x);
|
|
double exp(double x);
|
|
double fmod(double x, double y);
|
|
double sinh(double x);
|
|
double cosh(double x);
|
|
double tanh(double x);
|
|
double round(double x);
|
|
|
|
float floorf(float x);
|
|
float ceilf(float x);
|
|
float fabsf(float x);
|
|
float sqrtf(float x);
|
|
float sinf(float x);
|
|
float cosf(float x);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _LIBC_MATH_H */
|