Grow the Montauk libc enough to cross-build binutils 2.43.1 with --host=x86_64-montauk. gas, ld, ar, nm, objcopy, objdump, readelf, ranlib, strip and friends now link as native ET_EXEC Montauk binaries (staged stripped in toolchain/native/, not yet shipped in the image). New libc surface: full Linux errno and signal sets, O_* flags with real O_EXCL/O_APPEND semantics, unlink/rmdir/dup/dup2/getpid/_exit, kill (SYS_KILL), fcntl, fileno/fdopen, putc/getchar/rewind, ctime/asctime, strtoll/strtoull/atoll, bsearch, mkstemp/mktemp, realpath (lexical, drive-prefix aware), mbstowcs/mblen, chmod/fchmod/ umask/utime no-ops (VFS has no modes or settable times), full struct stat with fake inodes, sscanf field widths (bounded conversions), SCN*/PRI* completions, wait/waitpid over SYS_WAITPID, and new headers sys/wait.h, sys/param.h, utime.h, wchar.h, memory.h. fork/exec/pipe are declared but fail with ENOSYS: binutils never spawns, and real process plumbing is the posix_spawn milestone, which needs kernel support (exit status reporting, fd redirection). TCC's montauk_compat.h shims (unlink, chmod, execvp, realpath, fdopen, strtoll, strtoull) are retired in favor of the libc versions. Co-Authored-By: Claude Fable 5 <[email protected]>
92 lines
2.3 KiB
C
92 lines
2.3 KiB
C
#ifndef _LIBC_STDIO_H
|
|
#define _LIBC_STDIO_H
|
|
|
|
#pragma once
|
|
|
|
#include <stdarg.h>
|
|
#include <stddef.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define EOF (-1)
|
|
#define SEEK_SET 0
|
|
#define SEEK_CUR 1
|
|
#define SEEK_END 2
|
|
#define BUFSIZ 1024
|
|
#define FILENAME_MAX 256
|
|
#define L_tmpnam 64
|
|
#define TMP_MAX 10000
|
|
#define _IOFBF 0
|
|
#define _IOLBF 1
|
|
#define _IONBF 2
|
|
|
|
typedef struct _FILE {
|
|
int handle;
|
|
unsigned long pos;
|
|
unsigned long size;
|
|
int eof;
|
|
int error;
|
|
int is_std;
|
|
int ungetc_buf;
|
|
} FILE;
|
|
|
|
extern FILE *stdin;
|
|
extern FILE *stdout;
|
|
extern FILE *stderr;
|
|
|
|
int putc(int c, FILE *stream);
|
|
void rewind(FILE *stream);
|
|
int getchar(void);
|
|
int fileno(FILE *stream);
|
|
FILE *fdopen(int fd, const char *mode);
|
|
|
|
int printf(const char *fmt, ...);
|
|
int fprintf(FILE *stream, const char *fmt, ...);
|
|
int sprintf(char *str, const char *fmt, ...);
|
|
int snprintf(char *str, size_t size, const char *fmt, ...);
|
|
int vprintf(const char *fmt, va_list ap);
|
|
int vfprintf(FILE *stream, const char *fmt, va_list ap);
|
|
int vsprintf(char *str, const char *fmt, va_list ap);
|
|
int vsnprintf(char *str, size_t size, const char *fmt, va_list ap);
|
|
|
|
int puts(const char *s);
|
|
int putchar(int c);
|
|
|
|
FILE *fopen(const char *path, const char *mode);
|
|
int fclose(FILE *stream);
|
|
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
|
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
|
int fseek(FILE *stream, long offset, int whence);
|
|
long ftell(FILE *stream);
|
|
int fflush(FILE *stream);
|
|
FILE *freopen(const char *path, const char *mode, FILE *stream);
|
|
int setvbuf(FILE *stream, char *buf, int mode, size_t size);
|
|
|
|
int rename(const char *oldpath, const char *newpath);
|
|
int remove(const char *path);
|
|
|
|
int sscanf(const char *str, const char *fmt, ...);
|
|
|
|
int feof(FILE *stream);
|
|
int ferror(FILE *stream);
|
|
void clearerr(FILE *stream);
|
|
|
|
int fgetc(FILE *stream);
|
|
int getc(FILE *stream);
|
|
int fputc(int c, FILE *stream);
|
|
int ungetc(int c, FILE *stream);
|
|
char *fgets(char *s, int size, FILE *stream);
|
|
int fputs(const char *s, FILE *stream);
|
|
|
|
void perror(const char *s);
|
|
FILE *tmpfile(void);
|
|
char *tmpnam(char *s);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _LIBC_STDIO_H */
|