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]>
85 lines
2.2 KiB
C
85 lines
2.2 KiB
C
#ifndef _LIBC_STDLIB_H
|
|
#define _LIBC_STDLIB_H
|
|
|
|
#pragma once
|
|
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef NULL
|
|
#define NULL ((void *)0)
|
|
#endif
|
|
|
|
#define EXIT_SUCCESS 0
|
|
#define EXIT_FAILURE 1
|
|
#define RAND_MAX 0x7fffffff
|
|
|
|
typedef struct {
|
|
int quot;
|
|
int rem;
|
|
} div_t;
|
|
|
|
typedef struct {
|
|
long quot;
|
|
long rem;
|
|
} ldiv_t;
|
|
|
|
void *malloc(size_t size);
|
|
void free(void *ptr);
|
|
void *calloc(size_t nmemb, size_t size);
|
|
void *realloc(void *ptr, size_t size);
|
|
|
|
int atoi(const char *s);
|
|
long atol(const char *s);
|
|
double atof(const char *s);
|
|
|
|
int abs(int j);
|
|
long labs(long j);
|
|
|
|
void exit(int status);
|
|
void abort(void);
|
|
int atexit(void (*func)(void));
|
|
|
|
char *getenv(const char *name);
|
|
int setenv(const char *name, const char *value, int overwrite);
|
|
int unsetenv(const char *name);
|
|
int putenv(char *string);
|
|
|
|
void qsort(void *base, size_t nmemb, size_t size,
|
|
int (*compar)(const void *, const void *));
|
|
void *bsearch(const void *key, const void *base, size_t nmemb, size_t size,
|
|
int (*compar)(const void *, const void *));
|
|
|
|
long strtol(const char *nptr, char **endptr, int base);
|
|
unsigned long strtoul(const char *nptr, char **endptr, int base);
|
|
long long strtoll(const char *nptr, char **endptr, int base);
|
|
unsigned long long strtoull(const char *nptr, char **endptr, int base);
|
|
long long atoll(const char *nptr);
|
|
int mkstemp(char *template_);
|
|
char *mktemp(char *template_);
|
|
char *realpath(const char *path, char *resolved);
|
|
size_t mbstowcs(wchar_t *dst, const char *src, size_t n);
|
|
int mblen(const char *s, size_t n);
|
|
int mbtowc(wchar_t *pwc, const char *s, size_t n);
|
|
int wctomb(char *s, wchar_t wc);
|
|
double strtod(const char *nptr, char **endptr);
|
|
float strtof(const char *nptr, char **endptr);
|
|
long double strtold(const char *nptr, char **endptr);
|
|
|
|
int rand(void);
|
|
void srand(unsigned int seed);
|
|
|
|
div_t div(int numer, int denom);
|
|
ldiv_t ldiv(long numer, long denom);
|
|
|
|
int system(const char *command);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _LIBC_STDLIB_H */
|