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]>
51 lines
1.1 KiB
C
51 lines
1.1 KiB
C
#ifndef _LIBC_UNISTD_H
|
|
#define _LIBC_UNISTD_H
|
|
|
|
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <sys/types.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define STDIN_FILENO 0
|
|
#define STDOUT_FILENO 1
|
|
#define STDERR_FILENO 2
|
|
|
|
#define F_OK 0
|
|
#define X_OK 1
|
|
#define W_OK 2
|
|
#define R_OK 4
|
|
|
|
int read(int fd, void *buf, size_t count);
|
|
int write(int fd, const void *buf, size_t count);
|
|
int close(int fd);
|
|
long lseek(int fd, long offset, int whence);
|
|
int chdir(const char *path);
|
|
char *getcwd(char *buf, size_t size);
|
|
int access(const char *path, int mode);
|
|
int isatty(int fd);
|
|
int unlink(const char *path);
|
|
int rmdir(const char *path);
|
|
int dup(int fd);
|
|
int dup2(int oldfd, int newfd);
|
|
pid_t getpid(void);
|
|
void _exit(int status) __attribute__((noreturn));
|
|
pid_t fork(void);
|
|
int execv(const char *path, char *const argv[]);
|
|
int execve(const char *path, char *const argv[], char *const envp[]);
|
|
int execvp(const char *file, char *const argv[]);
|
|
int pipe(int fds[2]);
|
|
|
|
extern char **environ;
|
|
|
|
unsigned int sleep(unsigned int seconds);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _LIBC_UNISTD_H */
|