boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

commit bd4fdff0302a2548ae7c5342c91ed819d244ae70
parent e3286d8e0149c9747493d072cb76f709acc99a74
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Wed,  6 May 2026 18:46:38 -0700

libc headers: replace mes-libc/include with hand-rolled cc/include

The mes-libc header tree carried a lot of unused surface area and per-
type guard scaffolding (__MES_DEV_T &c.) that only mattered for the
old per-function .c split. Now that libc.c is one TU, the header set
can be the minimal closure tcc.flat.c + libc.flat.c actually use,
written from scratch with a single owner per type:

  stddef.h     size_t, ptrdiff_t, NULL, offsetof
  sys/types.h  ssize_t, off_t, pid_t, etc. (includes <stddef.h>)
  stdint.h     intN_t / uintN_t / intptr_t / uintptr_t / intmax / uintmax

Three sharp edges this avoids:

  * cc.scm rejects `<sign|long modifier> <typedef>` as type+qual, so a
    second `typedef unsigned long size_t;` from a header that re-
    declares the same type breaks the parse. Single-owner headers mean
    no re-declaration to begin with.

  * tccelf.c carries its own `typedef unsigned long uintptr_t;` gated
    on `__intptr_t_defined`. stdint.h sets that macro so the in-source
    decl is skipped.

  * cc.scm doesn't recognize __builtin_offsetof; offsetof uses the
    standard `(size_t)&((T*)0)->m` form.

assert(x) routes through abort() (now defined in libc.c as
sys_exit(128+SIGABRT), parallel to raise()) instead of the glibc-
internal __assert_fail.

Acceptance: make build/aarch64/podman/boot6/Image — full chain through
boot6 builds clean, fixed point tcc2 == tcc3 in boot4.

Diffstat:
Mbootprep/libc-flatten.sh | 27++++-----------------------
Mbootprep/stage1-flatten.sh | 9+++------
Acc/include/alloca.h | 3+++
Acc/include/assert.h | 9+++++++++
Acc/include/ctype.h | 13+++++++++++++
Acc/include/endian.h | 3+++
Acc/include/errno.h | 41+++++++++++++++++++++++++++++++++++++++++
Acc/include/fcntl.h | 20++++++++++++++++++++
Acc/include/inttypes.h | 25+++++++++++++++++++++++++
Acc/include/limits.h | 23+++++++++++++++++++++++
Acc/include/math.h | 3+++
Acc/include/setjmp.h | 6++++++
Acc/include/stddef.h | 9+++++++++
Acc/include/stdint.h | 38++++++++++++++++++++++++++++++++++++++
Acc/include/stdio.h | 48++++++++++++++++++++++++++++++++++++++++++++++++
Acc/include/stdlib.h | 29+++++++++++++++++++++++++++++
Acc/include/string.h | 25+++++++++++++++++++++++++
Acc/include/sys/stat.h | 37+++++++++++++++++++++++++++++++++++++
Acc/include/sys/time.h | 3+++
Acc/include/sys/types.h | 15+++++++++++++++
Acc/include/time.h | 3+++
Acc/include/unistd.h | 30++++++++++++++++++++++++++++++
Dvendor/mes-libc/include/alloca.h | 44--------------------------------------------
Dvendor/mes-libc/include/assert.h | 35-----------------------------------
Dvendor/mes-libc/include/ctype.h | 51---------------------------------------------------
Dvendor/mes-libc/include/endian.h | 36------------------------------------
Dvendor/mes-libc/include/errno.h | 71-----------------------------------------------------------------------
Dvendor/mes-libc/include/fcntl.h | 87-------------------------------------------------------------------------------
Dvendor/mes-libc/include/inttypes.h | 34----------------------------------
Dvendor/mes-libc/include/limits.h | 40----------------------------------------
Dvendor/mes-libc/include/linux/riscv64/kernel-stat.h | 48------------------------------------------------
Dvendor/mes-libc/include/math.h | 43-------------------------------------------
Dvendor/mes-libc/include/mes/lib-cc.h | 29-----------------------------
Dvendor/mes-libc/include/mes/lib-mini.h | 116-------------------------------------------------------------------------------
Dvendor/mes-libc/include/mes/lib.h | 93-------------------------------------------------------------------------------
Dvendor/mes-libc/include/setjmp.h | 69---------------------------------------------------------------------
Dvendor/mes-libc/include/stddef.h | 47-----------------------------------------------
Dvendor/mes-libc/include/stdint.h | 126-------------------------------------------------------------------------------
Dvendor/mes-libc/include/stdio.h | 99-------------------------------------------------------------------------------
Dvendor/mes-libc/include/stdlib.h | 74--------------------------------------------------------------------------
Dvendor/mes-libc/include/string.h | 62--------------------------------------------------------------
Dvendor/mes-libc/include/sys/mman.h | 43-------------------------------------------
Dvendor/mes-libc/include/sys/resource.h | 60------------------------------------------------------------
Dvendor/mes-libc/include/sys/stat.h | 82-------------------------------------------------------------------------------
Dvendor/mes-libc/include/sys/time.h | 56--------------------------------------------------------
Dvendor/mes-libc/include/sys/types.h | 174-------------------------------------------------------------------------------
Dvendor/mes-libc/include/time.h | 68--------------------------------------------------------------------
Dvendor/mes-libc/include/unistd.h | 110-------------------------------------------------------------------------------
Mvendor/mes-libc/libc.c | 138++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------
49 files changed, 474 insertions(+), 1880 deletions(-)

diff --git a/bootprep/libc-flatten.sh b/bootprep/libc-flatten.sh @@ -50,27 +50,17 @@ VENDOR=$ROOT/vendor/mes-libc WORK=$ROOT/build/$ARCH/vendor/mes-libc STAGE=$WORK/libc-stage FLAT=$WORK/libc.flat.c +SYS_INCLUDE=$ROOT/cc/include -[ -d "$VENDOR" ] || { echo "missing $VENDOR" >&2; exit 1; } -[ -d "$VENDOR/include" ] || { echo "missing $VENDOR/include" >&2; exit 1; } -[ -d "$VENDOR/include/linux/$MES_ARCH" ] \ - || { echo "missing $VENDOR/include/linux/$MES_ARCH" >&2; exit 1; } +[ -d "$VENDOR" ] || { echo "missing $VENDOR" >&2; exit 1; } +[ -d "$SYS_INCLUDE" ] || { echo "missing $SYS_INCLUDE" >&2; exit 1; } # --- (1) stage -------------------------------------------------------- mkdir -p "$WORK" rm -rf "$STAGE" mkdir -p "$STAGE" -# cp -R copies symlinks as files; staging is our writable scratch. cp -R "$VENDOR/." "$STAGE/" -# mes's sys/stat.h, signal.h, dirent.h reach for <arch/kernel-stat.h> -# and similar; the per-arch tree under include/linux/<MES_ARCH>/ is what -# they want. Copy the per-arch tree into include/arch so the unprefixed -# `arch/...` includes resolve. (cp -R, not ln -sfn — keeps the dep set -# down to coreutils we already use.) -cp -R "$STAGE/include/linux/$MES_ARCH" "$STAGE/include/arch" - - # --- (2) flatten via host preprocessor -------------------------------- HOST_CC=${HOST_CC:-cc} @@ -82,19 +72,10 @@ HOST_CC=${HOST_CC:-cc} BRIDGE=$ROOT/build/$ARCH/vendor/tcc/stdarg-bridge.h [ -e "$BRIDGE" ] || { echo "missing $BRIDGE — run bootprep/stage1-flatten.sh first" >&2; exit 1; } -# -I order matters: bootprep/include first so our stdarg.h shim -# (routes va_* through __builtin_va_*; see comment in that file) wins -# over mes's. Then $STAGE/include for everything else — <signal.h>, -# <stdio.h>, etc. hit the canonical mes/include versions; arch/<…> -# resolves through the include/arch symlink to include/linux/$MES_ARCH. -# Putting the per-arch directory ahead of include/ makes <signal.h> -# resolve to the partial arch-specific snippet (no stack_t typedef etc) -# and the build breaks. "$HOST_CC" -E -P \ -nostdinc \ -I "$ROOT/bootprep/include" \ - -I "$STAGE/include" \ - -I "$STAGE" \ + -I "$SYS_INCLUDE" \ -D HAVE_CONFIG_H=0 \ -D __linux__=1 \ -D __${MES_ARCH}__=1 \ diff --git a/bootprep/stage1-flatten.sh b/bootprep/stage1-flatten.sh @@ -61,8 +61,7 @@ WORK=$ROOT/build/$BOOT_ARCH/vendor/tcc DISTFILES=$ROOT/vendor/tcc LB_PATCHES=$ROOT/vendor/tcc/patches-lb OUR_PATCHES=$ROOT/vendor/tcc/patches -MES_INCLUDE=$ROOT/vendor/mes-libc/include -MES_INCLUDE_LINUX=$MES_INCLUDE/linux/$MES_ARCH +SYS_INCLUDE=$ROOT/cc/include TCC_TAR=$DISTFILES/0.9.26.tar.gz TCC_PKG=tcc-0.9.26-1147-gee75a10c @@ -70,8 +69,7 @@ TCC_PKG=tcc-0.9.26-1147-gee75a10c [ -r "$TCC_TAR" ] || { echo "missing $TCC_TAR" >&2; exit 1; } [ -d "$LB_PATCHES" ] || { echo "missing $LB_PATCHES" >&2; exit 1; } [ -d "$OUR_PATCHES" ] || { echo "missing $OUR_PATCHES" >&2; exit 1; } -[ -d "$MES_INCLUDE" ] || { echo "missing $MES_INCLUDE" >&2; exit 1; } -[ -d "$MES_INCLUDE_LINUX" ] || { echo "missing $MES_INCLUDE_LINUX" >&2; exit 1; } +[ -d "$SYS_INCLUDE" ] || { echo "missing $SYS_INCLUDE" >&2; exit 1; } # --- (1) unpack ------------------------------------------------------- mkdir -p "$WORK" @@ -312,8 +310,7 @@ FLAT=$WORK/tcc.flat.c -I "$SRC" \ -I "$WORK/mes-overlay" \ -I "$ROOT/bootprep/include" \ - -I "$MES_INCLUDE_LINUX" \ - -I "$MES_INCLUDE" \ + -I "$SYS_INCLUDE" \ -D __linux__=1 \ -D __${CPP_ARCH}__=1 \ -D BOOTSTRAP=1 \ diff --git a/cc/include/alloca.h b/cc/include/alloca.h @@ -0,0 +1,3 @@ +#ifndef _ALLOCA_H +#define _ALLOCA_H +#endif diff --git a/cc/include/assert.h b/cc/include/assert.h @@ -0,0 +1,9 @@ +#ifndef _ASSERT_H +#define _ASSERT_H +void abort(void); +#ifdef NDEBUG +# define assert(x) ((void)0) +#else +# define assert(x) ((x) ? (void)0 : abort()) +#endif +#endif diff --git a/cc/include/ctype.h b/cc/include/ctype.h @@ -0,0 +1,13 @@ +#ifndef _CTYPE_H +#define _CTYPE_H +int isalnum(int); +int isalpha(int); +int isdigit(int); +int islower(int); +int isprint(int); +int isspace(int); +int isupper(int); +int isxdigit(int); +int tolower(int); +int toupper(int); +#endif diff --git a/cc/include/endian.h b/cc/include/endian.h @@ -0,0 +1,3 @@ +#ifndef _ENDIAN_H +#define _ENDIAN_H +#endif diff --git a/cc/include/errno.h b/cc/include/errno.h @@ -0,0 +1,41 @@ +#ifndef _ERRNO_H +#define _ERRNO_H +extern int errno; +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define ERANGE 34 +#define ENAMETOOLONG 36 +#define ENOSYS 38 +#define ENOTEMPTY 39 +#define ELOOP 40 +#define ENOTSUP 95 +#define EOVERFLOW 75 +#endif diff --git a/cc/include/fcntl.h b/cc/include/fcntl.h @@ -0,0 +1,20 @@ +#ifndef _FCNTL_H +#define _FCNTL_H +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 +#define O_EXCL 0200 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +int open(const char *, int, ...); +int creat(const char *, unsigned int); +int fcntl(int, int, ...); +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 +#define FD_CLOEXEC 1 +#endif diff --git a/cc/include/inttypes.h b/cc/include/inttypes.h @@ -0,0 +1,25 @@ +#ifndef _INTTYPES_H +#define _INTTYPES_H +#include <stdint.h> +#define PRId8 "d" +#define PRId16 "d" +#define PRId32 "d" +#define PRId64 "lld" +#define PRIu8 "u" +#define PRIu16 "u" +#define PRIu32 "u" +#define PRIu64 "llu" +#define PRIx8 "x" +#define PRIx16 "x" +#define PRIx32 "x" +#define PRIx64 "llx" +#define PRIX8 "X" +#define PRIX16 "X" +#define PRIX32 "X" +#define PRIX64 "llX" +#define PRIdPTR "ld" +#define PRIuPTR "lu" +#define PRIxPTR "lx" +#define PRIiMAX "lld" +#define PRIuMAX "llu" +#endif diff --git a/cc/include/limits.h b/cc/include/limits.h @@ -0,0 +1,23 @@ +#ifndef _LIMITS_H +#define _LIMITS_H +#define CHAR_BIT 8 +#define SCHAR_MIN (-128) +#define SCHAR_MAX 127 +#define UCHAR_MAX 255U +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX +#define SHRT_MIN (-32768) +#define SHRT_MAX 32767 +#define USHRT_MAX 65535U +#define INT_MIN (-2147483648) +#define INT_MAX 2147483647 +#define UINT_MAX 4294967295U +#define LONG_MIN (-9223372036854775807L-1) +#define LONG_MAX 9223372036854775807L +#define ULONG_MAX 18446744073709551615UL +#define LLONG_MIN (-9223372036854775807LL-1) +#define LLONG_MAX 9223372036854775807LL +#define ULLONG_MAX 18446744073709551615ULL +#define PATH_MAX 4096 +#define NAME_MAX 255 +#endif diff --git a/cc/include/math.h b/cc/include/math.h @@ -0,0 +1,3 @@ +#ifndef _MATH_H +#define _MATH_H +#endif diff --git a/cc/include/setjmp.h b/cc/include/setjmp.h @@ -0,0 +1,6 @@ +#ifndef _SETJMP_H +#define _SETJMP_H +typedef long jmp_buf[32]; +int setjmp(jmp_buf); +void longjmp(jmp_buf, int); +#endif diff --git a/cc/include/stddef.h b/cc/include/stddef.h @@ -0,0 +1,9 @@ +#ifndef _STDDEF_H +#define _STDDEF_H +#ifndef NULL +# define NULL ((void*)0) +#endif +typedef unsigned long size_t; +typedef long ptrdiff_t; +#define offsetof(type, member) ((size_t)&((type *)0)->member) +#endif diff --git a/cc/include/stdint.h b/cc/include/stdint.h @@ -0,0 +1,38 @@ +#ifndef _STDINT_H +#define _STDINT_H +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +typedef long intptr_t; +typedef unsigned long uintptr_t; +typedef long long intmax_t; +typedef unsigned long long uintmax_t; +/* tccelf.c re-typedefs uintptr_t unless __intptr_t_defined is set; + * announce ours so the in-source decl is skipped. */ +#define __intptr_t_defined 1 +#define INT8_MIN (-128) +#define INT16_MIN (-32768) +#define INT32_MIN (-2147483648) +#define INT64_MIN (-9223372036854775807LL-1) +#define INT8_MAX 127 +#define INT16_MAX 32767 +#define INT32_MAX 2147483647 +#define INT64_MAX 9223372036854775807LL +#define UINT8_MAX 255U +#define UINT16_MAX 65535U +#define UINT32_MAX 4294967295U +#define UINT64_MAX 18446744073709551615ULL +#define INTPTR_MIN INT64_MIN +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX +#define SIZE_MAX UINT64_MAX +#define PTRDIFF_MAX INT64_MAX +#define PTRDIFF_MIN INT64_MIN +#endif diff --git a/cc/include/stdio.h b/cc/include/stdio.h @@ -0,0 +1,48 @@ +#ifndef _STDIO_H +#define _STDIO_H +#include <sys/types.h> +typedef struct _IO_FILE FILE; +#define EOF (-1) +#define NULL ((void*)0) +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#define BUFSIZ 8192 +extern FILE *stdin; +extern FILE *stdout; +extern FILE *stderr; +int printf(const char *, ...); +int fprintf(FILE *, const char *, ...); +int sprintf(char *, const char *, ...); +int snprintf(char *, size_t, const char *, ...); +int vprintf(const char *, __builtin_va_list); +int vfprintf(FILE *, const char *, __builtin_va_list); +int vsprintf(char *, const char *, __builtin_va_list); +int vsnprintf(char *, size_t, const char *, __builtin_va_list); +int sscanf(const char *, const char *, ...); +FILE *fopen(const char *, const char *); +FILE *fdopen(int, const char *); +FILE *tmpfile(void); +FILE *popen(const char *, const char *); +int fclose(FILE *); +int pclose(FILE *); +size_t fread(void *, size_t, size_t, FILE *); +size_t fwrite(const void *, size_t, size_t, FILE *); +int fseek(FILE *, long, int); +long ftell(FILE *); +void rewind(FILE *); +int fflush(FILE *); +int feof(FILE *); +int ferror(FILE *); +int fgetc(FILE *); +int fputc(int, FILE *); +char *fgets(char *, int, FILE *); +int fputs(const char *, FILE *); +int puts(const char *); +int putchar(int); +int getchar(void); +void perror(const char *); +int remove(const char *); +int rename(const char *, const char *); +int fileno(FILE *); +#endif diff --git a/cc/include/stdlib.h b/cc/include/stdlib.h @@ -0,0 +1,29 @@ +#ifndef _STDLIB_H +#define _STDLIB_H +#include <sys/types.h> +#define NULL ((void*)0) +void *malloc(size_t); +void *realloc(void *, size_t); +void *calloc(size_t, size_t); +void free(void *); +void exit(int); +void abort(void); +int atoi(const char *); +long atol(const char *); +long strtol(const char *, char **, int); +unsigned long strtoul(const char *, char **, int); +double strtod(const char *, char **); +unsigned long long strtoull(const char *, char **, int); +char *getenv(const char *); +int system(const char *); +void qsort(void *, size_t, size_t, int (*)(void *, void *)); +void *bsearch(void *, void *, size_t, size_t, int (*)(void *, void *)); +int rand(void); +void srand(unsigned int); +int mkstemp(char *); +char *mktemp(char *); +void *alloca(size_t); +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 +#define RAND_MAX 2147483647 +#endif diff --git a/cc/include/string.h b/cc/include/string.h @@ -0,0 +1,25 @@ +#ifndef _STRING_H +#define _STRING_H +#include <sys/types.h> +void *memcpy(void *, const void *, size_t); +void *memmove(void *, const void *, size_t); +void *memset(void *, int, size_t); +int memcmp(const void *, const void *, size_t); +void *memchr(const void *, int, size_t); +size_t strlen(const char *); +char *strcpy(char *, const char *); +char *strncpy(char *, const char *, size_t); +char *strcat(char *, const char *); +char *strncat(char *, const char *, size_t); +int strcmp(const char *, const char *); +int strncmp(const char *, const char *, size_t); +char *strchr(const char *, int); +char *strrchr(const char *, int); +char *strstr(const char *, const char *); +char *strtok(char *, const char *); +char *strerror(int); +char *strdup(const char *); +size_t strspn(const char *, const char *); +size_t strcspn(const char *, const char *); +char *strpbrk(const char *, const char *); +#endif diff --git a/cc/include/sys/stat.h b/cc/include/sys/stat.h @@ -0,0 +1,37 @@ +#ifndef _SYS_STAT_H +#define _SYS_STAT_H +#include <sys/types.h> +struct stat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + long st_atime; + long st_mtime; + long st_ctime; +}; +int stat(const char *, struct stat *); +int fstat(int, struct stat *); +int lstat(const char *, struct stat *); +int mkdir(const char *, mode_t); +int chmod(const char *, mode_t); +#define S_IFMT 0170000 +#define S_IFREG 0100000 +#define S_IFDIR 0040000 +#define S_IFLNK 0120000 +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_IRWXU 0700 +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IXUSR 0100 +#define S_IRWXG 0070 +#define S_IRWXO 0007 +#endif diff --git a/cc/include/sys/time.h b/cc/include/sys/time.h @@ -0,0 +1,3 @@ +#ifndef _SYS_TIME_H +#define _SYS_TIME_H +#endif diff --git a/cc/include/sys/types.h b/cc/include/sys/types.h @@ -0,0 +1,15 @@ +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H +#include <stddef.h> +typedef long ssize_t; +typedef long off_t; +typedef int pid_t; +typedef unsigned int uid_t; +typedef unsigned int gid_t; +typedef unsigned int mode_t; +typedef unsigned long ino_t; +typedef unsigned long dev_t; +typedef unsigned long nlink_t; +typedef long blksize_t; +typedef long blkcnt_t; +#endif diff --git a/cc/include/time.h b/cc/include/time.h @@ -0,0 +1,3 @@ +#ifndef _TIME_H +#define _TIME_H +#endif diff --git a/cc/include/unistd.h b/cc/include/unistd.h @@ -0,0 +1,30 @@ +#ifndef _UNISTD_H +#define _UNISTD_H +#include <sys/types.h> +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +ssize_t read(int, void *, size_t); +ssize_t write(int, const void *, size_t); +int close(int); +off_t lseek(int, off_t, int); +int unlink(const char *); +char *getcwd(char *, size_t); +pid_t getpid(void); +uid_t getuid(void); +int isatty(int); +int dup(int); +int dup2(int, int); +void _exit(int); +int access(const char *, int); +int execv(const char *, char *const[]); +int execve(const char *, char *const[], char *const[]); +int execvp(const char *, char *const[]); +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 +#endif diff --git a/vendor/mes-libc/include/alloca.h b/vendor/mes-libc/include/alloca.h @@ -1,44 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_ALLOCA_H -#define __MES_ALLOCA_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_ALLOCA_H -#include_next <alloca.h> - -#else // ! SYSTEM_LIBC - -#include <sys/types.h> - -#if _ALLOCA_UNSIGNED -void *alloca (unsigned size); -#elif _ALLOCA_CHAR -char *alloca (int); -#else -void *alloca (size_t size); -#endif - -#endif // ! SYSTEM_LIBC - -#endif // __MES_ALLOCA_H diff --git a/vendor/mes-libc/include/assert.h b/vendor/mes-libc/include/assert.h @@ -1,35 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_ASSERT_H -#define __MES_ASSERT_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_ASSERT_H -#include_next <assert.h> -#else // ! SYSTEM_LIBC -#define assert(x) ((x) ? (void)0 : __assert_fail (#x, 0, 0, 0)) -void __assert_fail (char const *s, char const *file, unsigned line, - char const *function); -#endif // ! SYSTEM_LIBC - -#endif // __MES_ASSERT_H diff --git a/vendor/mes-libc/include/ctype.h b/vendor/mes-libc/include/ctype.h @@ -1,51 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_CTYPE_H -#define __MES_CTYPE_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_CTYPE_H -#include_next <ctype.h> - -#else // ! SYSTEM_LIBC -#include <endian.h> - -int isalnum (int c); -int isalpha (int c); -int isascii (int c); -int iscntrl (int c); -int isdigit (int c); -int isgraph (int c); -int islower (int c); -int isnumber (int c, int base); -int isprint (int c); -int ispunct (int c); -int isspace (int c); -int isupper (int c); -int isxdigit (int c); -int tolower (int c); -int toupper (int c); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_CTYPE_H diff --git a/vendor/mes-libc/include/endian.h b/vendor/mes-libc/include/endian.h @@ -1,36 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_ENDIAN_H -#define __MES_ENDIAN_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_ENDIAN_H -#include_next <endian.h> - -#else // ! SYSTEM_LIBC -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif // ! SYSTEM_LIBC - -#endif // __MES_ENDIAN_H diff --git a/vendor/mes-libc/include/errno.h b/vendor/mes-libc/include/errno.h @@ -1,71 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_ERRNO_H -#define __MES_ERRNO_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_ERRNO_H -#include_next <errno.h> -#else // ! SYSTEM_LIBC - -#ifndef __MES_ERRNO_T -#define __MES_ERRNO_T 1 -typedef int error_t; -#endif // !__MES_ERRNO_T - -extern int errno; -#define ENOENT 2 -#define EINTR 4 -#define EIO 5 -#define ENXIO 6 -#define E2BIG 7 -#define ENOEXEC 8 -#define EBADF 9 -#define ECHILD 10 -#define EAGAIN 11 -#define ENOMEM 12 -#define EACCES 13 -#define EEXIST 17 -#define EXDEV 18 -#define ENOTDIR 20 -#define EISDIR 21 -#define EINVAL 22 -#define EMFILE 24 -#define ENOSPC 28 -#define ESPIPE 29 -#define EPIPE 32 -#define ERANGE 34 - -#define ENAMETOOLONG 36 -#define ENOSYS 38 -#define ELOOP 40 - -#if !__MESC__ && ! __M2__ -//extern char const *const sys_errlist[]; -extern char *sys_errlist[]; -extern int sys_nerr; -#endif // !__MESC__ - -#endif // ! SYSTEM_LIBC - -#endif // __MES_ERRNO_H diff --git a/vendor/mes-libc/include/fcntl.h b/vendor/mes-libc/include/fcntl.h @@ -1,87 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com> - * Copyright © 2023 Emily Trau <emily@downunderctf.com> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_FCNTL_H -#define __MES_FCNTL_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_FCNTL_H -#include_next <fcntl.h> - -#else // ! SYSTEM_LIBC - -// *INDENT-OFF* -#if __linux__ -#define O_RDONLY 0 -#define O_WRONLY 1 -#define O_RDWR 2 -#define O_CREAT 0x40 -#define O_EXCL 0x80 -#define O_TRUNC 0x200 -#define O_APPEND 0x400 - -#ifdef __arm__ -#define O_DIRECTORY 0x4000 -#define O_TMPFILE 0x404000 -#else -#define O_DIRECTORY 0x10000 -#define O_TMPFILE 0x410000 -#endif - -#define AT_FDCWD -100 -#define AT_SYMLINK_NOFOLLOW 0x100 -#define AT_REMOVEDIR 0x200 - -#elif __GNU__ -#define O_RDONLY 1 -#define O_WRONLY 2 -#define O_RDWR 3 -#define O_CREAT 0x10 -#define O_APPEND 0x100 -#define O_TRUNC 0x10000 -#else -#error platform not supported -#endif -// *INDENT-ON* - -#define FD_CLOEXEC 1 - -#define F_DUPFD 0 -#define F_GETFD 1 -#define F_SETFD 2 -#define F_GETFL 3 -#define F_SETFL 4 - -#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode) -int dup (int old); -int dup2 (int old, int new); - -#if !__M2__ -int fcntl (int filedes, int command, ...); -int open (char const *s, int flags, ...); -#endif - -#endif // ! SYSTEM_LIBC - -#endif // __MES_FCNTL_H diff --git a/vendor/mes-libc/include/inttypes.h b/vendor/mes-libc/include/inttypes.h @@ -1,34 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_INTTYPES_H -#define __MES_INTTYPES_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_INTTYPES_H -#include_next <inttypes.h> -#else // ! SYSTEM_LIBC - -#include <stdint.h> -#endif // ! SYSTEM_LIBC - -#endif // __MES_INTTYPES_H diff --git a/vendor/mes-libc/include/limits.h b/vendor/mes-libc/include/limits.h @@ -1,40 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_LIMITS_H -#define __MES_LIMITS_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_LIMITS_H -#include_next <limits.h> - -#else // ! SYSTEM_LIBC - -#include <stdint.h> - -#define NAME_MAX 255 -#define PATH_MAX 512 -#define _POSIX_OPEN_MAX 16 - -#endif // ! SYSTEM_LIBC - -#endif // __MES_LIMITS_H diff --git a/vendor/mes-libc/include/linux/riscv64/kernel-stat.h b/vendor/mes-libc/include/linux/riscv64/kernel-stat.h @@ -1,48 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com> - * Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_LINUX_RISCV64_KERNEL_STAT_H -#define __MES_LINUX_RISCV64_KERNEL_STAT_H 1 - -// *INDENT-OFF* -struct stat -{ - unsigned long st_dev; - unsigned long st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned int st_uid; - unsigned int st_gid; - unsigned long st_rdev; - unsigned long __pad; - long st_size; - int st_blksize; - int __pad2; - unsigned long st_blocks; - time_t st_atime; - unsigned long st_atime_usec; - time_t st_mtime; - unsigned long st_mtime_usec; - time_t st_ctime; - unsigned long st_ctime_usec; - unsigned long __foo0; -}; - -#endif // __MES_LINUX_RISCV64_KERNEL_STAT_H diff --git a/vendor/mes-libc/include/math.h b/vendor/mes-libc/include/math.h @@ -1,43 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_MATH_H -#define __MES_MATH_H 1 - -#if SYSTEM_LIBC -#undef __MES_MATH_H -#include_next <math.h> -#else // ! SYSTEM_LIBC - -double atan2 (double y, double x); -double ceil (double x); -double cos (double x); -double exp (double x); -double fabs (double number); -double floor (double x); -double ldexp (double value, int exponent); -double log (double x); -double modf (double value, double *integer_part); -double pow (double base, double power); -double sin (double x); -double sqrt (double x); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_MATH_H diff --git a/vendor/mes-libc/include/mes/lib-cc.h b/vendor/mes-libc/include/mes/lib-cc.h @@ -1,29 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_LIB_CC_H -#define __MES_LIB_CC_H - -#define EOF -1 - -#if __TINYC__ || SYSTEM_LIBC -#define __raise(x) -1 -#endif - -#endif //__MES_LIB_CC_H diff --git a/vendor/mes-libc/include/mes/lib-mini.h b/vendor/mes-libc/include/mes/lib-mini.h @@ -1,116 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2020,2022,2023,2025 Janneke Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __MES_LIB_MINI_H -#define __MES_LIB_MINI_H - -#if HAVE_CONFIG_H -#include <mes/config.h> -#endif - -#ifndef STDIN -#define STDIN 0 -#endif - -#ifndef STDOUT -#define STDOUT 1 -#endif - -#ifndef STDERR -#define STDERR 2 -#endif - -/* M2-Planet does not support pointer arithmetic. Explicitly compensate - for that by multiplying with M2_PTR_SIZE when using (char) - pointers. */ -#if __M2__ -#define M2_PTR_SIZE sizeof (void*) -#else -#define M2_PTR_SIZE 1 -#endif - -extern char **environ; -extern int __stdin; -extern int __stdout; -extern int __stderr; - -void __init_io (int argc, char **argv, char **envp); -int eputs (char const *s); -int puts (char const *s); -int oputs (char const *s); - -#if SYSTEM_LIBC - -#include <stdlib.h> -#include <sys/types.h> -#include <unistd.h> - -#else //!SYSTEM_LIBC - -#ifndef _SIZE_T -#define _SIZE_T -#ifndef __SIZE_T -#define __SIZE_T -#ifndef __MES_SIZE_T -#define __MES_SIZE_T -#undef size_t -#if __M2__ -typedef unsigned size_t; -#else -typedef unsigned long size_t; -#endif -#endif -#endif -#endif - -#ifndef _SSIZE_T -#define _SSIZE_T -#ifndef __SSIZE_T -#define __SSIZE_T -#ifndef __MES_SSIZE_T -#define __MES_SSIZE_T -#undef ssize_t -#if __i386__ -typedef int ssize_t; -#else -typedef long ssize_t; -#endif -#endif -#endif -#endif - -#ifndef __MES_ERRNO_T -#define __MES_ERRNO_T 1 -typedef int error_t; -extern int errno; -#endif // !__MES_ERRNO_T - -#if !__M2__ -extern void (*__call_at_exit) (void); -#endif - -void _exit (int status); -void exit (int status); -size_t strlen (char const *s); -ssize_t _write (int filedes, void const *buffer, size_t size); -ssize_t write (int filedes, void const *buffer, size_t size); -#endif // !SYSTEM_LIBC - -#endif //__MES_LIB_MINI_H diff --git a/vendor/mes-libc/include/mes/lib.h b/vendor/mes-libc/include/mes/lib.h @@ -1,93 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2023 Timothy Sample <samplet@ngyro.com> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __MES_LIB_H -#define __MES_LIB_H - -#include <mes/lib-mini.h> -#include <mes/lib-cc.h> - -#define __FILEDES_MAX 4096 -extern char *__brk; - -char *cast_intp_to_charp (int const *i); -char *cast_long_to_charp (long i); -long cast_charp_to_long (char const *); -long cast_int_to_long (int i); -long cast_voidp_to_long (void const *); - -int __mes_debug (void); -void __ungetc_init (void); -void __ungetc_clear (int filedes); -void __ungetc_set (int filedes, int c); -int __ungetc_p (int filedes); -long abtol (char const **p, int base); -char *itoa (int number); -char *ltoa (long number); -char *ltoab (long x, int base); -char *ntoab (long number, unsigned base, int signed_p); -char *utoa (unsigned number); -int eputc (int c); -int fdgetc (int fd); -char * fdgets (char *s, int count, int fd); -int fdputc (int c, int fd); -int fdputs (char const *s, int fd); -int fdungetc (int c, int fd); -char *_getcwd (char *buffer, size_t size); -int ioctl3 (int filedes, size_t command, long data); -int isnumber (int c, int base); -int mes_open (char const *file_name, int flags, int mask); -int _open2 (char const *file_name, int flags); -int _open3 (char const *file_name, int flags, int mask); -int oputc (int c); -int oputs (char const *s); -char *search_path (char const *file_name); -ssize_t _read (int fd, void *buffer, size_t size); -void assert_msg (int check, char *msg); - -long __mesabi_imod (long a, long b); -long __mesabi_idiv (long a, long b); -void *__memcpy (void *dest, void const *src, size_t n); -void *__memmove (void *dest, void const *src, size_t n); -void *__memset (void *s, int c, size_t n); - -#if !SYSTEM_LIBC -void __assert_fail (char const *s, char const *file, unsigned line, - char const *function); -ssize_t __buffered_read (int filedes, void *buffer, size_t size); -size_t __buffered_read_clear (int filedes); -long brk (void *addr); -#ifndef __raise -int __raise (int signal); -#endif -#endif // !SYSTEM_LIBC - -#if !__M2__ -double abtod (char const **p, int base); -char *dtoab (double number, int base, int signed_p); -char *ultoa (unsigned long number); -unsigned long __mesabi_umod (unsigned long a, unsigned long b); -unsigned long __mesabi_udiv (unsigned long a, unsigned long b); -unsigned long __mesabi_uldiv (unsigned long a, unsigned long b, - unsigned long *remainder); -#endif - -#endif //__MES_LIB_H diff --git a/vendor/mes-libc/include/setjmp.h b/vendor/mes-libc/include/setjmp.h @@ -1,69 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2020 Danny Milosavljevic <dannym@scratchpost.org> - * Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_SETJMP_H -#define __MES_SETJMP_H 1 - -#if SYSTEM_LIBC -#undef __MES_SETJMP_H -#include_next <setjmp.h> -#else // ! SYSTEM_LIBC - -#if __arm__ -#if __GNUC__ || __TINYC__ -#warning "It is not supported to use mes' setjmp implementation together with GCC. Continuing with best-effort implementation." -typedef struct -{ - long __sp; - long __lr; - long __registers[8]; /* Note: Keep in sync with lib/arm-mes-gcc/setjmp.c */ -} __jmp_buf; -#else -typedef struct -{ - long __fp; - long __lr; - long __sp; -} __jmp_buf; -#endif -#elif __riscv && (__GNUC__ || __TINYC__) -typedef struct -{ - long __sp; - long __lr; - long __registers[14]; /* Note: Keep in sync with lib/riscv64-mes-gcc/setjmp.c */ -} __jmp_buf; -#else -typedef struct -{ - long __bp; - long __pc; - long __sp; -} __jmp_buf; -#endif -typedef __jmp_buf jmp_buf[1]; - -void longjmp (jmp_buf env, int val); -int setjmp (jmp_buf env); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SETJMP_H diff --git a/vendor/mes-libc/include/stddef.h b/vendor/mes-libc/include/stddef.h @@ -1,47 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2021 Danny Milosavljevic <dannym@scratchpost.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_STDDEF_H -#define __MES_STDDEF_H 1 - -#if SYSTEM_LIBC -#undef __MES_STDDEF_H -#include_next <stddef.h> -#else // ! SYSTEM_LIBC - -#include <sys/types.h> -#include <stdint.h> -#include <unistd.h> - -#ifndef offsetof -#if __MESC__ -#define offsetof(type, field) (&((type *)0)->field) -#else // !__MESC__ -#define offsetof(type, field) ((size_t)&((type *)0)->field) -#endif // !__MESC__ -#endif // offsetof - -/* Note: on banana gcc, max_align_t is 16 Byte big instead! */ - -typedef double max_align_t; - -#endif // ! SYSTEM_LIBC - -#endif // __MES_STDDEF_H diff --git a/vendor/mes-libc/include/stdint.h b/vendor/mes-libc/include/stdint.h @@ -1,126 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2018 Peter De Wachter <pdewacht@gmail.com> - * Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_STDINT_H -#define __MES_STDINT_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_STDINT_H -#include_next <stdint.h> - -#else // ! SYSTEM_LIBC - -#undef unsigned -#undef uint8_t -#undef int8_t - -#undef uint16_t -#undef int16_t - -#undef uint32_t -#undef int32_t - -#undef uint64_t -#undef int64_t - -#undef uintptr_t -#undef intmax_t -#undef intptr_t -#undef uintmax_t -#undef ptrdiff_t - -typedef unsigned char uint8_t; -typedef signed char int8_t; -typedef unsigned short uint16_t; -typedef short int16_t; -typedef unsigned uint32_t; -typedef int int32_t; -#if __SIZEOF_LONG_LONG__ == 8 -typedef unsigned long long uint64_t; -typedef long long int64_t; -#endif // __SIZEOF_LONG_LONG__ == 8 - -#if __i386__ || __arm__ || __riscv_xlen == 32 -typedef int intmax_t; -typedef unsigned uintmax_t; -#elif __x86_64__ || __riscv_xlen == 64 -typedef long intmax_t; -typedef unsigned long uintmax_t; -#endif - -#include <sys/types.h> - -#define CHAR_BIT 8 -#define SCHAR_MIN (-128) -#define SCHAR_MAX 127 -#define UCHAR_MAX 255 - -/* Check if we are in signed or unsigned char case */ -#if '\xff' > 0 -#define CHAR_MIN 0 -#define CHAR_MAX UCHAR_MAX -#else -#define CHAR_MIN SCHAR_MIN -#define CHAR_MAX SCHAR_MAX -#endif - -#define INT8_MAX 127 -#define INT8_MIN (-INT8_MAX-1) -#define UINT8_MAX 255 - -#define INT16_MAX 32767 -#define INT16_MIN (-INT16_MAX-1) -#define UINT16_MAX 65535 - -#define INT32_MAX 2147483647 -#define INT32_MIN (-INT32_MAX-1) -#define UINT32_MAX 4294967295U - -#define INT64_MAX 9223372036854775807LL -#define INT64_MIN (-INT64_MAX-1) -#define UINT64_MAX 18446744073709551615ULL - -#define INT_MIN -2147483648 -#define INT_MAX 2147483647 -#if __i386__ || __arm__ || __riscv_xlen == 32 -#define LONG_MIN INT_MIN -#define LONG_MAX INT_MAX -#define UINT_MAX UINT32_MAX -#define ULONG_MAX UINT32_MAX -#define LLONG_MIN INT64_MIN -#define LLONG_MAX INT64_MAX -#define SIZE_MAX UINT32_MAX -#elif __x86_64__ || __riscv_xlen == 64 -#define LONG_MIN INT64_MIN -#define LONG_MAX INT64_MAX -#define UINT_MAX UINT32_MAX -#define ULONG_MAX UINT64_MAX -#define LLONG_MIN INT64_MIN -#define LLONG_MAX INT64_MAX -#define SIZE_MAX UINT64_MAX -#endif - -#endif // ! SYSTEM_LIBC - -#endif // __MES_STDINT_H diff --git a/vendor/mes-libc/include/stdio.h b/vendor/mes-libc/include/stdio.h @@ -1,99 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_STDIO_H -#define __MES_STDIO_H 1 - -#include <mes/lib.h> - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_STDIO_H -#include_next <stdio.h> - -#else // ! SYSTEM_LIBC - -#ifndef _IOFBF -#define _IOFBF 0 /* Fully buffered. */ -#define _IOLBF 1 /* Line buffered. */ -#define _IONBF 2 /* No buffering. */ -#endif - -#ifndef BUFSIZ -#define BUFSIZ 256 -#endif - -#ifndef L_tmpnam -#define L_tmpnam 100 -#endif - -#include <sys/types.h> - -#define stdin (FILE*)0 -#define stdout (FILE*)1 -#define stderr (FILE*)2 - -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 - -FILE *fdopen (int fd, char const *mode); -FILE *fopen (char const *file_name, char const *mode); -int eputc (int c); -int eputs (char const *s); -int fclose (FILE * stream); -int feof (FILE * stream); -int ferror (FILE * stream); -int fflush (FILE * stream); -int fgetc (FILE * stream); -char *fgets (char *s, int size, FILE * stream); -int fpurge (FILE * stream); -int fputc (int c, FILE * stream); -int fputs (char const *s, FILE * stream); -int fseek (FILE * stream, long offset, int whence); -int getc (FILE * stream); -int getchar (void); -char *getlogin (void); -int putc (int c, FILE * stream); -int putchar (int c); -int puts (char const *s); -int remove (char const *file_name); -int rename (char const *old_name, char const *new_name); -int setvbuf (FILE * stream, char *buf, int mode, size_t size); -int ungetc (int c, FILE * stream); -long ftell (FILE * stream); -size_t fread (void *ptr, size_t size, size_t count, FILE * stream); -size_t freadahead (FILE * fp); -size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream); -void perror (char const *message); - -#if !__M2__ -int fprintf (FILE * stream, char const *format, ...); -int fscanf (FILE * stream, char const *template, ...); -int printf (char const *format, ...); -int snprintf (char *str, size_t size, char const *format, ...); -int sprintf (char *str, char const *format, ...); -int sscanf (char const *str, char const *format, ...); -#endif // !__M2__ - -#endif // ! SYSTEM_LIBC - -#endif // __MES_STDIO_H diff --git a/vendor/mes-libc/include/stdlib.h b/vendor/mes-libc/include/stdlib.h @@ -1,74 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2024 Andrius Štikonas <andrius@stikonas.eu> - * Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_STDLIB_H -#define __MES_STDLIB_H 1 - -#ifndef __MES_COMPARISON_FN_T -#define __MES_COMPARISON_FN_T -typedef int (*comparison_fn_t) (void const *, void const *); -#endif - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_STDLIB_H -#include_next <stdlib.h> -#else // ! SYSTEM_LIBC - -#include <sys/types.h> -#include <alloca.h> - -#define MB_CUR_MAX 1 - -void abort (void); -double atof (char const *s); -int atoi (char const *s); -int atexit (void (*function) (void)); -void *calloc (size_t nmemb, size_t size); -void _exit (int status); -void exit (int status); -void free (void *ptr); -char *getenv (char const *s); -int putenv (char *s); -int setenv (char const *s, char const *v, int overwrite_p); -void unsetenv (char const *name); -void *malloc (size_t); -void qsort (void *base, size_t nmemb, size_t size, int (*compar) (void const *, void const *)); -int rand (void); -void *realloc (void *p, size_t size); -double strtod (char const *string, char **tailptr); -float strtof (char const *string, char **tailptr); -long double strtold (char const *string, char **tailptr); -long strtol (char const *string, char **tailptr, int base); -long long strtoll (char const *string, char **tailptr, int base); -unsigned long strtoul (char const *string, char **tailptr, int base); -unsigned long long strtoull (char const *string, char **tailptr, int base); - -#define EXIT_FAILURE 1 -#define EXIT_SUCCESS 0 - -void *bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_STDLIB_H diff --git a/vendor/mes-libc/include/string.h b/vendor/mes-libc/include/string.h @@ -1,62 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,20225 janneke Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_STRING_H -#define __MES_STRING_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_STRING_H -#include_next <string.h> - -#else // ! SYSTEM_LIBC - -#include <sys/types.h> - -void *memchr (void const *block, int c, size_t size); -void *memcpy (void *dest, void const *src, size_t n); -void *memmove (void *dest, void const *src, size_t n); -void *memset (void *s, int c, size_t n); -int memcmp (void const *s1, void const *s2, size_t n); -void *memmem (void const *haystack, int haystack_len, void const *needle, int needle_len); -char *strcat (char *dest, char const *src); -char *strchr (char const *s, int c); -int strcasecmp (char const *s1, char const *s2); -int strcmp (char const *, char const *); -char *strcpy (char *dest, char const *src); -size_t strcspn (char const *string, char const *stopset); -size_t strlen (char const *); -char *strncat (char *to, char const *from, size_t size); -char *strncpy (char *to, char const *from, size_t size); -int strncmp (char const *, char const *, size_t); -char *strpbrk (char const *string, char const *stopset); -char *strrchr (char const *s, int c); -size_t strspn (char const *string, char const *skipset); -char *strstr (char const *haystack, char const *needle); -char *strlwr (char *string); -char *strupr (char *string); - - -char *strerror (int errnum); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_STRING_H diff --git a/vendor/mes-libc/include/sys/mman.h b/vendor/mes-libc/include/sys/mman.h @@ -1,43 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_SYS_MMAN_H -#define __MES_SYS_MMAN_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_MMAN_H -#include_next <sys/mman.h> -#else // ! SYSTEM_LIBC - -#ifndef __MES_SIZE_T -#define __MES_SIZE_T -typedef unsigned long size_t; -#endif - -#define PROT_NONE 0 -#define PROT_READ 1 -#define PROT_WRITE 2 -#define PROT_EXEC 4 - -int mprotect (void *addr, size_t len, int prot); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_MMAN_H - diff --git a/vendor/mes-libc/include/sys/resource.h b/vendor/mes-libc/include/sys/resource.h @@ -1,60 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_SYS_RESOURCE_H -#define __MES_SYS_RESOURCE_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_RESOURCE_H -#include_next <sys/resource.h> - -#else // ! SYSTEM_LIBC - -#include <sys/time.h> - -struct rusage -{ - struct timeval ru_utime; - struct timeval ru_stime; - long ru_maxrss; - long ru_ixrss; - long ru_idrss; - long ru_isrss; - long ru_minflt; - long ru_majflt; - long ru_nswap; - long ru_inblock; - long ru_oublock; - long ru_msgsnd; - long ru_msgrcv; - long ru_nsignals; - long ru_nvcsw; - long ru_nivcsw; -}; - -#define RUSAGE_SELF 0 -#define RUSAGE_CHILDREN -1 -#define RLIMIT_NOFILE 1024 -#define OPEN_MAX RLIMIT_NOFILE - -int getrusage (int processes, struct rusage *rusage); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_RESOURCE_H diff --git a/vendor/mes-libc/include/sys/stat.h b/vendor/mes-libc/include/sys/stat.h @@ -1,82 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2024 Janneke Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2022 Dor Askayo <dor.askayo@gmail.com> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_SYS_STAT_H -#define __MES_SYS_STAT_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_STAT_H -#include_next <sys/stat.h> - -#else // ! SYSTEM_LIBC - -#include <time.h> -#include <sys/types.h> - -#ifndef __MES_MODE_T -#define __MES_MODE_T -typedef int mode_t; -#endif - -#include <arch/kernel-stat.h> - -int chmod (char const *file_name, mode_t mode); -int fstat (int filedes, struct stat *buf); -int mkdir (char const *file_name, mode_t mode); -int mknod (char const *file_name, mode_t mode, dev_t dev); -int chown (char const *file_name, uid_t owner, gid_t group); -int rmdir (char const *file_name); -int stat (char const *file_name, struct stat *buf); -int lstat (char const *file_name, struct stat *buf); -mode_t umask (mode_t mask); -int utimensat(int dirfd, char const *file_name, - struct timespec const *times, int flags); - -#define S_IFIFO 0010000 -#define S_IFCHR 0020000 -#define S_IFDIR 0040000 -#define S_IFBLK 0060000 -#define S_IFREG 0100000 -#define S_IFLNK 0120000 -#define S_IFMT 0170000 - -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) - -#define S_IRWXU 00700 -#define S_IXUSR 00100 -#define S_IWUSR 00200 -#define S_IRUSR 00400 - -#define S_ISUID 04000 -#define S_ISGID 02000 -#define S_IXGRP 00010 -#define S_IXOTH 00001 -#define S_IRGRP 00040 -#define S_IROTH 00004 -#define S_IWGRP 00020 -#define S_IWOTH 00002 -#define S_IRWXG 00070 -#define S_IRWXO 00007 - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_STAT_H diff --git a/vendor/mes-libc/include/sys/time.h b/vendor/mes-libc/include/sys/time.h @@ -1,56 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_SYS_TIME_H -#define __MES_SYS_TIME_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_TIME_H -#include_next <sys/time.h> - -#else // ! SYSTEM_LIBC - -struct timeval -{ - long tv_sec; - long tv_usec; -}; - -struct timezone -{ - int tz_minuteswest; - int tz_dsttime; -}; - -struct itimerval -{ - struct timeval it_interval; - struct timeval it_value; -}; - -#define ITIMER_REAL 0 -#define ITIMER_VIRTUAL 1 -#define ITIMER_PROF 2 - -int gettimeofday (struct timeval *tv, struct timezone *tz); -int setitimer (int which, struct itimerval const *new, struct itimerval *old); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_TIME_H diff --git a/vendor/mes-libc/include/sys/types.h b/vendor/mes-libc/include/sys/types.h @@ -1,174 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_SYS_TYPES_H -#define __MES_SYS_TYPES_H 1 - -#include <mes/lib-cc.h> - -#if SYSTEM_LIBC -#undef __MES_SYS_TYPES_H -#include_next <sys/types.h> -#else // ! SYSTEM_LIBC - -#include <endian.h> - -#ifndef __MESCCLIB__ -#define __MESCCLIB__ 15 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef __MES_CLOCK_T -#define __MES_CLOCK_T -#undef clock_t -typedef long clock_t; -#endif - -#ifndef __MES_DEV_T -#define __MES_DEV_T -#undef dev_t -typedef long dev_t; -#endif - -#if !defined (__MES_FILE_T) && ! defined (_FILE_T) -#define __MES_FILE_T -#define _FILE_T -typedef long FILE; -#endif - -#ifndef __MES_GID_T -#define __MES_GID_T -#undef gid_t -typedef unsigned gid_t; -#endif - -#ifndef __MES_INO_T -#define __MES_INO_T -#undef ino_t -#if __M2__ -typedef unsigned ino_t; -#else -typedef unsigned long ino_t; -#endif -#endif - -#if __SIZEOF_LONG_LONG__ == 8 -#ifndef __MES_INO64_T -#define __MES_INO64_T -#undef ino64_t -#if __M2__ -typedef unsigned ino64_t; -#else -typedef unsigned long long ino64_t; -#endif -#endif -#endif // __SIZEOF_LONG_LONG__ == 8 - -#if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined) -#define __MES_INTPTR_T -#define __intptr_t_defined -#undef intptr_t -typedef long intptr_t; -#undef uintptr_t -#if __M2__ -typedef unsigned uintptr_t; -#else -typedef unsigned long uintptr_t; -#endif -#endif - -#ifndef __MES_OFF_T -#define __MES_OFF_T -#undef off_t -typedef long off_t; -#endif - -#if __SIZEOF_LONG_LONG__ == 8 -#ifndef __MES_OFF64_T -#define __MES_OFF64_T -#undef off64_t -#if __M2__ -typedef unsigned off64_t; -#else -typedef unsigned long long off64_t; -#endif -#endif -#endif // __SIZEOF_LONG_LONG__ == 8 - -#ifndef __MES_PID_T -#define __MES_PID_T -#undef pid_t -typedef int pid_t; -#endif - -#ifndef __PTRDIFF_T -#define __PTRDIFF_T -#ifndef __MES_PTRDIFF_T -#define __MES_PTRDIFF_T -#undef ptrdiff_t -typedef long ptrdiff_t; -#endif -#endif - -#ifndef __MES_SIGVAL_T -#define __MES_SIGVAL_T -#undef clock_t -typedef long sigval_t; -#endif - -#ifndef __SIZE_T -#define __SIZE_T -#ifndef __MES_SIZE_T -#define __MES_SIZE_T -#undef size_t -#if __M2__ -typedef unsigned size_t; -#else -typedef unsigned long size_t; -#endif -#endif -#endif - -#ifndef __MES_SSIZE_T -#define __MES_SSIZE_T -#undef ssize_t -typedef long ssize_t; -#endif - -#ifndef __MES_UID_T -#define __MES_UID_T -#undef uid_t -typedef unsigned uid_t; -#endif - -#ifndef __WCHAR_T -#define __WCHAR_T -#ifndef __MES_WCHAR_T -#define __MES_WCHAR_T -#undef wchar_t -typedef int wchar_t; -#endif -#endif - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_TYPES_H diff --git a/vendor/mes-libc/include/time.h b/vendor/mes-libc/include/time.h @@ -1,68 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_TIME_H -#define __MES_TIME_H 1 - -#if SYSTEM_LIBC -#undef __MES_TIME_H -#include_next <time.h> -#else // ! SYSTEM_LIBC - -#ifndef __MES_TIME_T -#define __MES_TIME_T 1 -typedef long clockid_t; -typedef long time_t; -#endif - -struct tm -{ - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - int tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; -}; - -#ifndef __MES_STRUCT_TIMESPEC -#define __MES_STRUCT_TIMESPEC - -struct timespec -{ - long tv_sec; - long tv_nsec; -}; - -#endif // __MES_STRUCT_TIMESPEC - -#define CLOCK_PROCESS_CPUTIME_ID 2 -int clock_gettime (clockid_t clk_id, struct timespec *tp); -struct tm *localtime (time_t const *timep); -struct tm *gmtime (time_t const *time); -time_t mktime (struct tm *broken_time); -int nanosleep (struct timespec const *requested_time, struct timespec const *remaining); -time_t time (time_t * tloc); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_TIME_H diff --git a/vendor/mes-libc/include/unistd.h b/vendor/mes-libc/include/unistd.h @@ -1,110 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2024 Janneke Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2023 Timothy Sample <samplet@ngyro.com> - * - * This file is part of GNU Mes. - * - * GNU Mes is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef __MES_UNISTD_H -#define __MES_UNISTD_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_UNISTD_H -#include_next <unistd.h> - -#else // ! SYSTEM_LIBC - -#if defined (BOOTSTRAP_WITH_POSIX) -#define _POSIX_VERSION 199009L -#endif - -#include <sys/types.h> -#ifndef NULL -#define NULL 0 -#endif - -#ifndef STDIN_FILENO -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 -#endif // STDIN_FILENO - -#ifndef STDIN_FILE_NO -#define STDIN_FILE_NO 0 -#define STDOUT_FILE_NO 1 -#define STDERR_FILE_NO 2 -#endif // STDIN_FILE_NO - -#ifndef R_OK -#define F_OK 0 -#define X_OK 1 -#define W_OK 2 -#define R_OK 4 -#endif - -#ifndef _PC_NAME_MAX -#define _PC_NAME_MAX 3 -#endif -#ifndef _PC_PATH_MAX -#define _PC_PATH_MAX 4 -#endif - -int access (char const *s, int mode); -unsigned int alarm (unsigned int seconds); -int chdir (char const *file_name); -int close (int fd); -int execv (char const *file_name, char *const argv[]); -int execl (char const *file_name, char const *arg, ...); -int execlp (char const *file_name, char const *arg, ...); -int execve (char const *file, char *const argv[], char *const env[]); -int execvp (char const *file, char *const argv[]); -int fork (void); -int fsync (int filedes); -char *getcwd (char *buf, size_t size); -uid_t getuid (void); -gid_t getgid (void); -int setgid (gid_t newgid); -int setuid (uid_t newuid); -uid_t geteuid (void); -gid_t getegid (void); -pid_t getpgrp (void); -pid_t getpid (void); -pid_t getppid (void); -int getpgid (pid_t pid); -int isatty (int fd); -int link (char const *old_name, char const *new_name); -off_t lseek (int fd, off_t offset, int whence); -long pathconf (char const *file_name, int parameter); -int pipe (int filedes[2]); -ssize_t read (int fd, void *buffer, size_t size); -ssize_t readlink (char const *file_name, char *buffer, size_t size); -char *realpath (char const *name, char *resolved); -#if __SBRK_CHAR_PTRDIFF -/* xmalloc in binutils <= 2.10.1 uses this old prototype */ -char *sbrk (ptrdiff_t delta); -#else -void *sbrk (intptr_t delta); -#endif -int symlink (char const *old_name, char const *new_name); -int unlink (char const *file_name); -ssize_t write (int filedes, void const *buffer, size_t size); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_UNISTD_H diff --git a/vendor/mes-libc/libc.c b/vendor/mes-libc/libc.c @@ -1,17 +1,11 @@ /* libc.c — slim libc closure for tcc-boot2. * * What's here: just enough libc for tcc.flat.c, the cc-libc tests, and - * the boot4 hello smoke binary to link. Started from mes-libc 0.24, - * then condensed: dropped the cast_* casting helpers (mescc-only), the - * eputc/oputc/fdputc/fdgetc indirection layer, the __mes_debug logging - * knob, the __ungetc_buf pushback nobody uses, and the per-function - * file split with its duplicated boilerplate. mes-style scope-block - * indentation kept where the body came over verbatim; new code uses - * normal indentation. + * the boot4 hello smoke binary to link. Started from mes-libc 0.24. * * Provides: * syscalls _read _write _open3 close lseek brk unlink _exit - * raise environ getenv __libc_init + * raise abort environ getenv __libc_init * ENOSYS stubs: access execve fsync rmdir stat strtod * I/O stdin/stdout/stderr (FILE *), FILE = long alias for fd * fopen fdopen fclose fflush fseek ftell remove @@ -39,7 +33,6 @@ * License: GPLv3+ (mes upstream); see LICENSE. */ -#include <mes/lib.h> #include <fcntl.h> #include <errno.h> #include <stdio.h> @@ -53,15 +46,12 @@ #include <stddef.h> #include <stdint.h> +#define __FILEDES_MAX 4096 /* ───────── globals ───────────────────────────────────────────────── */ -/* mes's <stdio.h> defines stdin/stdout/stderr as macros expanding to - (FILE *)0/1/2; client code (tcc, cc-libc tests) uses - `extern FILE *stdout` and needs real linkage symbols. Drop the - macros so we can define globals; later TUs that re-include <stdio.h> - hit the include guard and so see the now-undef'd identifiers, - resolving to these at link time. */ +/* Our sysinclude stdio.h declares stdin/stdout/stderr as extern FILE* + (not macros). The #undefs below are no-ops kept for compatibility. */ #undef stdin #undef stdout #undef stderr @@ -172,13 +162,20 @@ raise (int sig) } void +abort (void) +{ + sys_exit (128 + 6); +} + +void __libc_init (int argc, char **argv) { /* Linux exec entry stack: argc, argv[0..argc-1], NULL, envp[..], NULL. :_start passes (argc, argv); environ follows argv's NULL. Without it, getenv() dereferences NULL on first call. */ + char **p; (void) argc; - char **p = argv; + p = argv; while (*p) p++; environ = p + 1; @@ -341,11 +338,12 @@ strstr (char const *hay, char const *needle) void * memmem (void const *hay, int haylen, void const *needle, int needlelen) { - if (needlelen <= 0) return (void *) hay; - if (needlelen > haylen) return 0; char const *h = hay; char const *n = needle; - for (int i = 0; i + needlelen <= haylen; i++) { + int i; + if (needlelen <= 0) return (void *) hay; + if (needlelen > haylen) return 0; + for (i = 0; i + needlelen <= haylen; i++) { int j = 0; while (j < needlelen && h[i + j] == n[j]) j++; @@ -370,6 +368,8 @@ strdup (char const *s) void * malloc (size_t size) { + long want; + char *p; if (!__brk) __brk = (char *) brk (0); /* 16-byte align — matches the largest scalar (long long / pointer / double). */ @@ -377,10 +377,10 @@ malloc (size_t size) /* Linux brk(2) returns the (unchanged) break on failure rather than -1, so compare against the requested address — a refused growth surfaces here as malloc returning NULL. */ - long want = (long) (__brk + size); + want = (long) (__brk + size); if (brk (__brk + size) < want) return 0; - char *p = __brk; + p = __brk; __brk += size; return p; } @@ -438,9 +438,11 @@ atoi (char const *s) long strtol (char const *s, char **tail, int base) { + char const *p; + long r; if (!strncmp (s, "0x", 2)) { s += 2; base = 16; } - char const *p = s; - long r = (long) parse_int_ (&p, base); + p = s; + r = (long) parse_int_ (&p, base); if (tail) *tail = (char *) p; return r; } @@ -473,12 +475,14 @@ qswap_ (char *a, char *b, size_t size) } static size_t -qpart_ (char *base, size_t count, size_t size, int (*cmp) (void const *, void const *)) +qpart_ (char *base, size_t count, size_t size, int (*cmp) (void *, void *)) { char *pivot = base + count * size; size_t i = 0; - for (size_t j = 0; j < count; j++) { - int c = cmp (base + j * size, pivot); + size_t j; + int c; + for (j = 0; j < count; j++) { + c = cmp (base + j * size, pivot); if (c < 0) { qswap_ (base + i * size, base + j * size, size); i++; @@ -492,10 +496,11 @@ qpart_ (char *base, size_t count, size_t size, int (*cmp) (void const *, void co } void -qsort (void *base, size_t count, size_t size, int (*cmp) (void const *, void const *)) +qsort (void *base, size_t count, size_t size, int (*cmp) (void *, void *)) { + size_t p; if (count > 1) { - size_t p = qpart_ (base, count - 1, size, cmp); + p = qpart_ (base, count - 1, size, cmp); qsort (base, p, size, cmp); qsort ((char *) base + p * size, count - p, size, cmp); } @@ -508,7 +513,8 @@ char * getenv (char const *name) { size_t n = strlen (name); - for (char **p = environ; p && *p; p++) { + char **p; + for (p = environ; p && *p; p++) { if (!strncmp (*p, name, n) && (*p)[n] == '=') return *p + n + 1; } @@ -540,8 +546,9 @@ read_cache_init_ (void) static size_t read_cache_clear_ (int fd) { + size_t n; read_cache_init_ (); - size_t n = read_cache[fd].size; + n = read_cache[fd].size; read_cache[fd].size = 0; return n; } @@ -549,10 +556,11 @@ read_cache_clear_ (int fd) static ssize_t read_buffered_ (int fd, void *buf, size_t size) { - read_cache_init_ (); - struct read_buffer *c = &read_cache[fd]; + struct read_buffer *c; char *p = buf; size_t todo = size; + read_cache_init_ (); + c = &read_cache[fd]; if (!c->size && size > READ_BUFFER_MAX) return _read (fd, buf, size); while (c->size > 0 && todo) { @@ -560,9 +568,10 @@ read_buffered_ (int fd, void *buf, size_t size) *p++ = c->bytes[READ_BUFFER_MAX - c->size--]; } if (todo) { + ssize_t got; if (todo > READ_BUFFER_MAX) return size - todo + _read (fd, p, todo); - ssize_t got = _read (fd, c->bytes, READ_BUFFER_MAX); + got = _read (fd, c->bytes, READ_BUFFER_MAX); if (got < 0) return -1; if (got > 0) { c->size = got; @@ -584,9 +593,10 @@ ssize_t write (int fd, void const *buf, size_t size) { size_t skip = read_cache_clear_ (fd); + ssize_t r; if (skip) sys_lseek (fd, -(long) skip, SEEK_CUR); - ssize_t r = _write (fd, buf, size); + r = _write (fd, buf, size); if (r < 0) { errno = -r; return -1; @@ -661,16 +671,18 @@ fgetc (FILE * f) size_t fread (void *data, size_t size, size_t count, FILE * f) { + ssize_t got; if (!size || !count) return 0; - ssize_t got = read_buffered_ ((long) f, data, size * count); + got = read_buffered_ ((long) f, data, size * count); return got > 0 ? got / size : 0; } size_t fwrite (void const *data, size_t size, size_t count, FILE * f) { + ssize_t put; if (!size || !count) return 0; - ssize_t put = write ((long) f, data, size * count); + put = write ((long) f, data, size * count); return put > 0 ? put / size : 0; } @@ -752,11 +764,22 @@ vformat_ (struct sink *s, char const *fmt, va_list ap) { size_t start = s->len; while (*fmt) { + int left, long_p, precision, width; + char pad; + char c; + char nbuf[24]; + char const *body; + size_t bodylen; + char sign; + if (*fmt != '%') { emit_ (s, *fmt++); continue; } fmt++; - int left = 0, long_p = 0, precision = -1, width = -1; - char pad = ' '; + left = 0; long_p = 0; precision = -1; width = -1; + pad = ' '; + body = 0; + bodylen = 0; + sign = 0; if (*fmt == '-') { left = 1; fmt++; } if (*fmt == ' ') { pad = ' '; fmt++; } @@ -783,11 +806,7 @@ vformat_ (struct sink *s, char const *fmt, va_list ap) if (*fmt == 'l') { long_p = 1; fmt++; } if (*fmt == 'l') fmt++; - char c = *fmt; - char nbuf[24]; - char const *body = 0; - size_t bodylen = 0; - char sign = 0; + c = *fmt; switch (c) { case '%': emit_ (s, '%'); break; @@ -825,7 +844,8 @@ vformat_ (struct sink *s, char const *fmt, va_list ap) body = utoa_ (u, base, nbuf); bodylen = strlen (body); if (c == 'X') { - for (char *t = (char *) body; *t; t++) + char *t; + for (t = (char *) body; *t; t++) *t = toupper (*t); } goto numeric_emit; @@ -844,9 +864,11 @@ vformat_ (struct sink *s, char const *fmt, va_list ap) numeric_emit: { int total = (sign ? 1 : 0) + (int) bodylen; + int npad; + int zpad; if (precision < 0) precision = (int) bodylen; - int npad = width > total ? width - (precision > (int) bodylen ? precision : total) : 0; - int zpad = precision > (int) bodylen ? precision - (int) bodylen : 0; + npad = width > total ? width - (precision > (int) bodylen ? precision : total) : 0; + zpad = precision > (int) bodylen ? precision - (int) bodylen : 0; if (!left && pad == ' ') { while (npad-- > 0) emit_ (s, ' '); } @@ -906,8 +928,10 @@ vsprintf (char *str, char const *fmt, va_list ap) int fprintf (FILE * f, char const *fmt, ...) { - va_list ap; va_start (ap, fmt); - int r = vfprintf (f, fmt, ap); + va_list ap; + int r; + va_start (ap, fmt); + r = vfprintf (f, fmt, ap); va_end (ap); return r; } @@ -915,8 +939,10 @@ fprintf (FILE * f, char const *fmt, ...) int printf (char const *fmt, ...) { - va_list ap; va_start (ap, fmt); - int r = vfprintf (stdout, fmt, ap); + va_list ap; + int r; + va_start (ap, fmt); + r = vfprintf (stdout, fmt, ap); va_end (ap); return r; } @@ -924,8 +950,10 @@ printf (char const *fmt, ...) int snprintf (char *str, size_t size, char const *fmt, ...) { - va_list ap; va_start (ap, fmt); - int r = vsnprintf (str, size, fmt, ap); + va_list ap; + int r; + va_start (ap, fmt); + r = vsnprintf (str, size, fmt, ap); va_end (ap); return r; } @@ -933,8 +961,10 @@ snprintf (char *str, size_t size, char const *fmt, ...) int sprintf (char *str, char const *fmt, ...) { - va_list ap; va_start (ap, fmt); - int r = vsprintf (str, fmt, ap); + va_list ap; + int r; + va_start (ap, fmt); + r = vsprintf (str, fmt, ap); va_end (ap); return r; }