Files
MontaukOS/programs/include/libc/stdlib.h
T
danielandClaude Fable 5 f234c67a2b feat: native GCC - cc1, cc1plus and the gcc driver run on MontaukOS
Cross-build GCC 14.2.0 with --host=x86_64-montauk: the driver, cc1,
cc1plus and collect2 now link as static Montauk ET_EXEC binaries
against the hosted libstdc++, and ship in the SDK. Together with the
native binutils, TCC and the target sysroot, MontaukOS carries a
complete self-contained C and C++ toolchain at 0:/sdk.

libc: anonymous mmap/munmap over SYS_ALLOC (GCC's page allocator
wants mmap; SYS_ALLOC memory is page-aligned by construction),
getpagesize, minimal sysconf, MB_CUR_MAX, isascii/toascii, POSIX id
typedefs (ino_t, dev_t, nlink_t, ...), struct stat fields switched to
proper POSIX types (st_size is a signed off_t now), and a
conventional _STDIO_H guard marker so GMP's FILE detection works.

Build recipe and the five host-build gotchas (bundled config.subs,
gettext removal, stdio guard sniffing, endianness cache preset,
sysroot sdk symlink) are documented in toolchain/README.md. The
devkit stages the driver as gcc.elf/g++.elf/cpp.elf, the backends in
the libexec layout the driver expects, a copy of ld where collect2
searches, and a 0:/tmp scratch dir. Ramdisk: 1604 files, 368 MB.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-16 23:51:30 +02:00

87 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);
#define MB_CUR_MAX 1
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 */