boot2

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

commit e3286d8e0149c9747493d072cb76f709acc99a74
parent e33c8d156b4908f97cefbbaf230a2721719e92fd
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Wed,  6 May 2026 17:03:30 -0700

mes-libc: collapse to single-file libc.c, drop unused sources/headers

Reverse-engineered tcc's actual libc dependency closure by compiling
tcc.flat.c freestanding with clang -nostdinc -isystem mes-libc/include
and reading llvm-nm undefs (44 symbols + the cc-libc test deps + boot4
hello's strdup). Replaced the per-function tree (105 .c files across
ctype/ string/ mes/ stdlib/ linux/ posix/ stdio/ + boot2-syscall.c) and
the unified-libc.c shim with a single hand-written libc.c.

The new file drops the mes-internal scaffolding tcc never touches:
the cast_intp_to_charp/cast_long_to_charp casting helpers (mescc-only),
the eputc/oputc/fdputc/fdgetc indirection layer, the __mes_debug logging
knob, the __ungetc_buf pushback nobody uses, itoa/ltoa/ultoa/utoa, and
the mes/* duplicate copyright blocks. fputc/fputs/puts now call _write
directly; vfprintf and vsnprintf share one vformat_() with a sink
abstraction (was 280 lines duplicated).

Header tree pruned the same way: alloca/assert/ctype/endian/errno/fcntl/
inttypes/limits/math/setjmp/stddef/stdint/stdio/stdlib/string/time/
unistd at top level, mes/{lib,lib-cc,lib-mini}.h, sys/{mman,resource,
stat,time,types}.h, linux/riscv64/kernel-stat.h. Everything else gone.

The .c-file patches (malloc-max-align, malloc-brk-check, strstr-drop-mman,
ntoab-inline-defined, printf-mes-varargs, sprintf-mes-varargs,
snprintf-mes-varargs, printf-int-promo, vsnprintf-int-promo) are baked
into libc.c; libc-flatten.sh no longer rewrites sources before
flattening. Header patches (libmini-write-proto, lib-mes-debug-proto)
applied in-place too. patches/ directory removed.

One non-obvious bug surfaced during boot4: kernel-recycled fd numbers
inherit stale buffered bytes if _open3 doesn't clear the per-fd read
cache. Mes's _open3 already did this; my first rewrite forgot, and
tcc1's "out/sys_stubs.o: error: unrecognized file type" came from a
read of the second file's first 64 bytes returning leftover bytes from
the first file's tail.

vendor/mes-libc/ goes from ~2.4MB (115 files) to 168KB (28 files).
libc.flat.c shrinks from 58954 bytes to 32505 bytes; libc.P1pp from
333877 to 201681; tcc0 from 2069136 to 2010600.

Acceptance:
  make test SUITE=cc-libc ARCH=aarch64    18/18 PASS
  ./boot/boot.sh aarch64                  end-to-end OK in 49s,
                                          fixed point tcc2 == tcc3

Diffstat:
Mbootprep/libc-flatten.sh | 115++++++++++---------------------------------------------------------------------
Dvendor/mes-libc/boot2-syscall.c | 260-------------------------------------------------------------------------------
Dvendor/mes-libc/ctype/isalnum.c | 27---------------------------
Dvendor/mes-libc/ctype/isalpha.c | 27---------------------------
Dvendor/mes-libc/ctype/isascii.c | 27---------------------------
Dvendor/mes-libc/ctype/iscntrl.c | 27---------------------------
Dvendor/mes-libc/ctype/isdigit.c | 28----------------------------
Dvendor/mes-libc/ctype/isgraph.c | 27---------------------------
Dvendor/mes-libc/ctype/islower.c | 27---------------------------
Dvendor/mes-libc/ctype/isnumber.c | 34----------------------------------
Dvendor/mes-libc/ctype/isprint.c | 27---------------------------
Dvendor/mes-libc/ctype/ispunct.c | 27---------------------------
Dvendor/mes-libc/ctype/isspace.c | 27---------------------------
Dvendor/mes-libc/ctype/isupper.c | 27---------------------------
Dvendor/mes-libc/ctype/isxdigit.c | 28----------------------------
Dvendor/mes-libc/ctype/tolower.c | 29-----------------------------
Dvendor/mes-libc/ctype/toupper.c | 29-----------------------------
Dvendor/mes-libc/include/ar.h | 56--------------------------------------------------------
Dvendor/mes-libc/include/argz.h | 40----------------------------------------
Dvendor/mes-libc/include/dirent.h | 87-------------------------------------------------------------------------------
Dvendor/mes-libc/include/dirstream.h | 55-------------------------------------------------------
Dvendor/mes-libc/include/dlfcn.h | 44--------------------------------------------
Dvendor/mes-libc/include/features.h | 28----------------------------
Dvendor/mes-libc/include/float.h | 34----------------------------------
Dvendor/mes-libc/include/getopt.h | 62--------------------------------------------------------------
Dvendor/mes-libc/include/gnu/hurd-types.h | 393-------------------------------------------------------------------------------
Dvendor/mes-libc/include/gnu/hurd.h | 90-------------------------------------------------------------------------------
Dvendor/mes-libc/include/gnu/syscall.h | 144-------------------------------------------------------------------------------
Dvendor/mes-libc/include/gnu/x86/kernel-stat.h | 30------------------------------
Dvendor/mes-libc/include/gnu/x86/signal.h | 90-------------------------------------------------------------------------------
Dvendor/mes-libc/include/grp.h | 45---------------------------------------------
Dvendor/mes-libc/include/libgen.h | 34----------------------------------
Dvendor/mes-libc/include/linux/SYSCALLS | 111-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/arm/kernel-stat.h | 79-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/arm/signal.h | 51---------------------------------------------------
Dvendor/mes-libc/include/linux/arm/syscall.h | 122-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/m2/kernel-stat.h | 47-----------------------------------------------
Dvendor/mes-libc/include/linux/riscv32/kernel-stat.h | 46----------------------------------------------
Dvendor/mes-libc/include/linux/riscv64/signal.h | 89-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/riscv64/syscall.h | 106-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/syscall.h | 33---------------------------------
Dvendor/mes-libc/include/linux/x86/kernel-stat.h | 79-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/x86/signal.h | 90-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/x86/syscall.h | 124-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/x86_64/kernel-stat.h | 51---------------------------------------------------
Dvendor/mes-libc/include/linux/x86_64/signal.h | 102-------------------------------------------------------------------------------
Dvendor/mes-libc/include/linux/x86_64/syscall.h | 104-------------------------------------------------------------------------------
Dvendor/mes-libc/include/locale.h | 45---------------------------------------------
Dvendor/mes-libc/include/m2/types.h | 145-------------------------------------------------------------------------------
Dvendor/mes-libc/include/mach/mach-init.h | 50--------------------------------------------------
Dvendor/mes-libc/include/memory.h | 36------------------------------------
Dvendor/mes-libc/include/mes/builtins.h | 211-------------------------------------------------------------------------------
Dvendor/mes-libc/include/mes/cc.h | 42------------------------------------------
Dvendor/mes-libc/include/mes/config.h | 3---
Dvendor/mes-libc/include/mes/constants.h | 59-----------------------------------------------------------
Mvendor/mes-libc/include/mes/lib-mini.h | 4++--
Mvendor/mes-libc/include/mes/lib.h | 4++--
Dvendor/mes-libc/include/mes/mes.h | 213-------------------------------------------------------------------------------
Dvendor/mes-libc/include/mes/mescc-builtins.h | 40----------------------------------------
Dvendor/mes-libc/include/mes/symbols.h | 141-------------------------------------------------------------------------------
Dvendor/mes-libc/include/pwd.h | 46----------------------------------------------
Dvendor/mes-libc/include/signal.h | 193-------------------------------------------------------------------------------
Dvendor/mes-libc/include/stdbool.h | 36------------------------------------
Dvendor/mes-libc/include/stdnoreturn.h | 34----------------------------------
Dvendor/mes-libc/include/strings.h | 28----------------------------
Dvendor/mes-libc/include/sys/cdefs.h | 28----------------------------
Dvendor/mes-libc/include/sys/dir.h | 32--------------------------------
Dvendor/mes-libc/include/sys/file.h | 32--------------------------------
Dvendor/mes-libc/include/sys/ioctl.h | 41-----------------------------------------
Dvendor/mes-libc/include/sys/param.h | 31-------------------------------
Dvendor/mes-libc/include/sys/select.h | 30------------------------------
Dvendor/mes-libc/include/sys/timeb.h | 28----------------------------
Dvendor/mes-libc/include/sys/times.h | 53-----------------------------------------------------
Dvendor/mes-libc/include/sys/ucontext.h | 28----------------------------
Dvendor/mes-libc/include/sys/user.h | 111-------------------------------------------------------------------------------
Dvendor/mes-libc/include/sys/utsname.h | 49-------------------------------------------------
Dvendor/mes-libc/include/sys/wait.h | 45---------------------------------------------
Dvendor/mes-libc/include/termio.h | 72------------------------------------------------------------------------
Avendor/mes-libc/libc.c | 964+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dvendor/mes-libc/linux/malloc.c | 44--------------------------------------------
Dvendor/mes-libc/mes/__assert_fail.c | 48------------------------------------------------
Dvendor/mes-libc/mes/__buffered_read.c | 109-------------------------------------------------------------------------------
Dvendor/mes-libc/mes/__init_io.c | 30------------------------------
Dvendor/mes-libc/mes/__mes_debug.c | 36------------------------------------
Dvendor/mes-libc/mes/abtol.c | 68--------------------------------------------------------------------
Dvendor/mes-libc/mes/cast.c | 57---------------------------------------------------------
Dvendor/mes-libc/mes/dtoab.c | 46----------------------------------------------
Dvendor/mes-libc/mes/eputc.c | 27---------------------------
Dvendor/mes-libc/mes/eputs.c | 30------------------------------
Dvendor/mes-libc/mes/fdgetc.c | 88-------------------------------------------------------------------------------
Dvendor/mes-libc/mes/fdgets.c | 40----------------------------------------
Dvendor/mes-libc/mes/fdputc.c | 29-----------------------------
Dvendor/mes-libc/mes/fdputs.c | 30------------------------------
Dvendor/mes-libc/mes/fdungetc.c | 37-------------------------------------
Dvendor/mes-libc/mes/globals.c | 27---------------------------
Dvendor/mes-libc/mes/itoa.c | 27---------------------------
Dvendor/mes-libc/mes/ltoa.c | 27---------------------------
Dvendor/mes-libc/mes/ltoab.c | 27---------------------------
Dvendor/mes-libc/mes/mes_open.c | 49-------------------------------------------------
Dvendor/mes-libc/mes/ntoab.c | 92-------------------------------------------------------------------------------
Dvendor/mes-libc/mes/oputc.c | 27---------------------------
Dvendor/mes-libc/mes/oputs.c | 30------------------------------
Dvendor/mes-libc/mes/search-path.c | 66------------------------------------------------------------------
Dvendor/mes-libc/mes/ultoa.c | 27---------------------------
Dvendor/mes-libc/mes/utoa.c | 27---------------------------
Dvendor/mes-libc/patches/lib-mes-debug-proto.after | 2--
Dvendor/mes-libc/patches/lib-mes-debug-proto.before | 2--
Dvendor/mes-libc/patches/libmini-write-proto.after | 1-
Dvendor/mes-libc/patches/libmini-write-proto.before | 1-
Dvendor/mes-libc/patches/libmini-write-proto2.after | 1-
Dvendor/mes-libc/patches/libmini-write-proto2.before | 1-
Dvendor/mes-libc/patches/malloc-brk-check.after | 10----------
Dvendor/mes-libc/patches/malloc-brk-check.before | 5-----
Dvendor/mes-libc/patches/malloc-max-align.after | 5-----
Dvendor/mes-libc/patches/malloc-max-align.before | 5-----
Dvendor/mes-libc/patches/ntoab-inline-defined.after | 4----
Dvendor/mes-libc/patches/ntoab-inline-defined.before | 5-----
Dvendor/mes-libc/patches/printf-int-promo.after | 43-------------------------------------------
Dvendor/mes-libc/patches/printf-int-promo.before | 30------------------------------
Dvendor/mes-libc/patches/printf-mes-varargs.after | 2--
Dvendor/mes-libc/patches/printf-mes-varargs.before | 5-----
Dvendor/mes-libc/patches/snprintf-mes-varargs.after | 2--
Dvendor/mes-libc/patches/snprintf-mes-varargs.before | 5-----
Dvendor/mes-libc/patches/sprintf-mes-varargs.after | 2--
Dvendor/mes-libc/patches/sprintf-mes-varargs.before | 5-----
Dvendor/mes-libc/patches/strstr-drop-mman.after | 2--
Dvendor/mes-libc/patches/strstr-drop-mman.before | 3---
Dvendor/mes-libc/patches/vsnprintf-int-promo.after | 43-------------------------------------------
Dvendor/mes-libc/patches/vsnprintf-int-promo.before | 34----------------------------------
Dvendor/mes-libc/posix/buffered-read.c | 48------------------------------------------------
Dvendor/mes-libc/posix/execvp.c | 53-----------------------------------------------------
Dvendor/mes-libc/posix/getcwd.c | 33---------------------------------
Dvendor/mes-libc/posix/getenv.c | 49-------------------------------------------------
Dvendor/mes-libc/posix/open.c | 54------------------------------------------------------
Dvendor/mes-libc/posix/sbrk.c | 36------------------------------------
Dvendor/mes-libc/posix/write.c | 41-----------------------------------------
Dvendor/mes-libc/stdio/clearerr.c | 29-----------------------------
Dvendor/mes-libc/stdio/fclose.c | 29-----------------------------
Dvendor/mes-libc/stdio/fdopen.c | 27---------------------------
Dvendor/mes-libc/stdio/feof.c | 30------------------------------
Dvendor/mes-libc/stdio/ferror.c | 30------------------------------
Dvendor/mes-libc/stdio/fflush.c | 32--------------------------------
Dvendor/mes-libc/stdio/fgetc.c | 27---------------------------
Dvendor/mes-libc/stdio/fgets.c | 28----------------------------
Dvendor/mes-libc/stdio/fileno.c | 27---------------------------
Dvendor/mes-libc/stdio/fopen.c | 74--------------------------------------------------------------------------
Dvendor/mes-libc/stdio/fprintf.c | 33---------------------------------
Dvendor/mes-libc/stdio/fputc.c | 27---------------------------
Dvendor/mes-libc/stdio/fputs.c | 27---------------------------
Dvendor/mes-libc/stdio/fread.c | 76----------------------------------------------------------------------------
Dvendor/mes-libc/stdio/fseek.c | 41-----------------------------------------
Dvendor/mes-libc/stdio/ftell.c | 29-----------------------------
Dvendor/mes-libc/stdio/fwrite.c | 52----------------------------------------------------
Dvendor/mes-libc/stdio/getc.c | 27---------------------------
Dvendor/mes-libc/stdio/perror.c | 30------------------------------
Dvendor/mes-libc/stdio/printf.c | 39---------------------------------------
Dvendor/mes-libc/stdio/putc.c | 27---------------------------
Dvendor/mes-libc/stdio/remove.c | 34----------------------------------
Dvendor/mes-libc/stdio/snprintf.c | 39---------------------------------------
Dvendor/mes-libc/stdio/sprintf.c | 39---------------------------------------
Dvendor/mes-libc/stdio/ungetc.c | 27---------------------------
Dvendor/mes-libc/stdio/vfprintf.c | 252-------------------------------------------------------------------------------
Dvendor/mes-libc/stdio/vprintf.c | 29-----------------------------
Dvendor/mes-libc/stdio/vsnprintf.c | 275-------------------------------------------------------------------------------
Dvendor/mes-libc/stdio/vsprintf.c | 28----------------------------
Dvendor/mes-libc/stdlib/__exit.c | 27---------------------------
Dvendor/mes-libc/stdlib/abort.c | 32--------------------------------
Dvendor/mes-libc/stdlib/atoi.c | 28----------------------------
Dvendor/mes-libc/stdlib/atol.c | 27---------------------------
Dvendor/mes-libc/stdlib/calloc.c | 31-------------------------------
Dvendor/mes-libc/stdlib/exit.c | 35-----------------------------------
Dvendor/mes-libc/stdlib/free.c | 26--------------------------
Dvendor/mes-libc/stdlib/puts.c | 28----------------------------
Dvendor/mes-libc/stdlib/qsort.c | 80-------------------------------------------------------------------------------
Dvendor/mes-libc/stdlib/realloc.c | 34----------------------------------
Dvendor/mes-libc/stdlib/strtof.c | 27---------------------------
Dvendor/mes-libc/stdlib/strtol.c | 40----------------------------------------
Dvendor/mes-libc/stdlib/strtoll.c | 27---------------------------
Dvendor/mes-libc/stdlib/strtoul.c | 27---------------------------
Dvendor/mes-libc/stdlib/strtoull.c | 27---------------------------
Dvendor/mes-libc/string/memchr.c | 37-------------------------------------
Dvendor/mes-libc/string/memcmp.c | 40----------------------------------------
Dvendor/mes-libc/string/memcpy.c | 44--------------------------------------------
Dvendor/mes-libc/string/memmem.c | 60------------------------------------------------------------
Dvendor/mes-libc/string/memmove.c | 33---------------------------------
Dvendor/mes-libc/string/memset.c | 40----------------------------------------
Dvendor/mes-libc/string/strcat.c | 31-------------------------------
Dvendor/mes-libc/string/strchr.c | 34----------------------------------
Dvendor/mes-libc/string/strcmp.c | 33---------------------------------
Dvendor/mes-libc/string/strcpy.c | 37-------------------------------------
Dvendor/mes-libc/string/strcspn.c | 33---------------------------------
Dvendor/mes-libc/string/strdup.c | 32--------------------------------
Dvendor/mes-libc/string/strerror.c | 81-------------------------------------------------------------------------------
Dvendor/mes-libc/string/strlen.c | 32--------------------------------
Dvendor/mes-libc/string/strncat.c | 33---------------------------------
Dvendor/mes-libc/string/strncmp.c | 37-------------------------------------
Dvendor/mes-libc/string/strncpy.c | 36------------------------------------
Dvendor/mes-libc/string/strpbrk.c | 33---------------------------------
Dvendor/mes-libc/string/strrchr.c | 40----------------------------------------
Dvendor/mes-libc/string/strspn.c | 33---------------------------------
Dvendor/mes-libc/string/strstr.c | 29-----------------------------
Dvendor/mes-libc/string/strupr.c | 34----------------------------------
Dvendor/mes-libc/unified-libc.c | 150-------------------------------------------------------------------------------
203 files changed, 982 insertions(+), 9780 deletions(-)

diff --git a/bootprep/libc-flatten.sh b/bootprep/libc-flatten.sh @@ -1,16 +1,21 @@ #!/bin/sh -## libc-flatten.sh — flatten the vendored mes-libc + boot2-syscall.c -## into a single libc.flat.c using the host preprocessor. Mirrors -## stage1-flatten.sh; runs on the host, no container — hence the -## non-`boot-` name (the convention in boot/ is that boot-*.sh -## runs inside the minimal container). +## libc-flatten.sh — flatten the slimmed mes-libc closure (vendor/mes-libc/ +## libc.c, a single TU folding boot2-syscall.c plus every mes .c file +## tcc.flat.c actually references) into libc.flat.c using the host +## preprocessor. Mirrors stage1-flatten.sh; runs on the host, no +## container — hence the non-`boot-` name (boot-*.sh runs inside the +## minimal container). ## ## Steps: ## 1. stage vendor/mes-libc → build/<arch>/vendor/mes-libc/libc-stage/ -## 2. apply simple-patches (literal-block replacement, idempotent) -## 3. HOST_CC -E -nostdinc -I staging/include … staging/unified-libc.c +## (still a copy: we tweak the per-arch include layout there) +## 2. HOST_CC -E -nostdinc -I staging/include … staging/libc.c ## → build/<arch>/vendor/mes-libc/libc.flat.c ## +## The .c-file patches that used to live in step (2) are now baked into +## vendor/mes-libc/libc.c directly; libc-flatten.sh no longer rewrites +## sources before flattening. +## ## Stage 4 (cc.scm libc.flat.c → libc.P1pp) is a separate Makefile rule ## that reuses scripts/boot-build-cc.sh inside the per-arch container. ## @@ -66,99 +71,7 @@ cp -R "$VENDOR/." "$STAGE/" cp -R "$STAGE/include/linux/$MES_ARCH" "$STAGE/include/arch" -# --- (2) patches ------------------------------------------------------ -# Same literal-block replacer as stage1-flatten.sh apply_simple_patch. -apply_simple_patch() { - target=$1; before=$2; after=$3 - [ -r "$target" ] || { echo "patch target missing: $target" >&2; exit 1; } - [ -r "$before" ] || { echo "patch before missing: $before" >&2; exit 1; } - [ -r "$after" ] || { echo "patch after missing: $after" >&2; exit 1; } - awk -v BFILE="$before" -v AFILE="$after" ' - BEGIN { - while ((getline line < BFILE) > 0) bef = bef line "\n"; - close(BFILE); - while ((getline line < AFILE) > 0) aft = aft line "\n"; - close(AFILE); - } - { src = src $0 "\n" } - END { - if (index(src, aft) > 0) { - printf "%s", src; - exit 0; - } - i = index(src, bef); - if (i == 0) { print "patch did not match" > "/dev/stderr"; exit 1 } - printf "%s%s%s", - substr(src, 1, i - 1), - aft, - substr(src, i + length(bef)); - } - ' "$target" > "$target.new" - mv "$target.new" "$target" -} - -PATCHES=$STAGE/patches -apply_simple_patch \ - "$STAGE/linux/malloc.c" \ - "$PATCHES/malloc-max-align.before" \ - "$PATCHES/malloc-max-align.after" -apply_simple_patch \ - "$STAGE/linux/malloc.c" \ - "$PATCHES/malloc-brk-check.before" \ - "$PATCHES/malloc-brk-check.after" -apply_simple_patch \ - "$STAGE/string/strstr.c" \ - "$PATCHES/strstr-drop-mman.before" \ - "$PATCHES/strstr-drop-mman.after" -apply_simple_patch \ - "$STAGE/include/mes/lib-mini.h" \ - "$PATCHES/libmini-write-proto.before" \ - "$PATCHES/libmini-write-proto.after" -apply_simple_patch \ - "$STAGE/include/mes/lib-mini.h" \ - "$PATCHES/libmini-write-proto2.before" \ - "$PATCHES/libmini-write-proto2.after" -apply_simple_patch \ - "$STAGE/include/mes/lib.h" \ - "$PATCHES/lib-mes-debug-proto.before" \ - "$PATCHES/lib-mes-debug-proto.after" -apply_simple_patch \ - "$STAGE/mes/ntoab.c" \ - "$PATCHES/ntoab-inline-defined.before" \ - "$PATCHES/ntoab-inline-defined.after" -# stdio/{printf,sprintf,snprintf}.c carry a mes-mescc-specific -# `ap += (__FOO_VARARGS + ...)` block guarded by `__GNUC__ && __x86_64__`. -# That arithmetic is meaningful only inside mes's compiler; under stock -# gcc preprocessing for amd64 it expands to a reference to an undefined -# `__FOO_VARARGS` and breaks cc.scm. Strip the block — the va_start that -# follows handles varargs correctly under any standard C compiler. -apply_simple_patch \ - "$STAGE/stdio/printf.c" \ - "$PATCHES/printf-mes-varargs.before" \ - "$PATCHES/printf-mes-varargs.after" -apply_simple_patch \ - "$STAGE/stdio/sprintf.c" \ - "$PATCHES/sprintf-mes-varargs.before" \ - "$PATCHES/sprintf-mes-varargs.after" -apply_simple_patch \ - "$STAGE/stdio/snprintf.c" \ - "$PATCHES/snprintf-mes-varargs.before" \ - "$PATCHES/snprintf-mes-varargs.after" -# stdio/vfprintf.c and stdio/vsnprintf.c read every integer / char -# variadic via `va_arg(ap, long)`. On amd64 SysV an `int` arg occupies -# an 8-byte reg-save slot whose upper 32 bits are unspecified — tcc's -# codegen (and most other compilers') doesn't sign-extend ints into -# the slot. Reading as `long` then leaks the garbage upper bits. Track -# the `l` length modifier and dispatch the va_arg type accordingly. -apply_simple_patch \ - "$STAGE/stdio/vfprintf.c" \ - "$PATCHES/printf-int-promo.before" \ - "$PATCHES/printf-int-promo.after" -apply_simple_patch \ - "$STAGE/stdio/vsnprintf.c" \ - "$PATCHES/vsnprintf-int-promo.before" \ - "$PATCHES/vsnprintf-int-promo.after" -# --- (3) flatten via host preprocessor -------------------------------- +# --- (2) flatten via host preprocessor -------------------------------- HOST_CC=${HOST_CC:-cc} # Bridge file: post-patch tcc <stdarg.h>. Written by stage1-flatten.sh, @@ -187,7 +100,7 @@ BRIDGE=$ROOT/build/$ARCH/vendor/tcc/stdarg-bridge.h -D __${MES_ARCH}__=1 \ -D __riscv_xlen=64 \ -D inline= \ - "$STAGE/unified-libc.c" > "$FLAT.body" + "$STAGE/libc.c" > "$FLAT.body" # Prepend the bridge, guarded by !CCSCM (cc.scm predefines CCSCM and # handles __builtin_va_* natively, so it must skip this block). Under diff --git a/vendor/mes-libc/boot2-syscall.c b/vendor/mes-libc/boot2-syscall.c @@ -1,260 +0,0 @@ -/* boot2-syscall.c — replaces mes's per-arch inline-asm syscall wrappers - * with C wrappers that call P1pp's labelled syscall entry points. - * - * The P1pp labels (sys_read / sys_write / sys_open / sys_close / - * sys_lseek / sys_brk / sys_unlink / sys_exit) are defined in - * P1/P1pp.P1pp and resolved at the linker stage thanks to cc.scm's - * external-linkage rule (commit 6488cca). - * - * Layering: - * public libc (read, write, open, …) — comes from the posix layer - * └─ low-level _read, _write, _open3 — provided here - * └─ named sys_* labels — provided by P1pp.P1pp - * - * mes's linux/{brk,close,lseek,_open3,_read,unlink}.c are NOT vendored; - * the equivalents live here and bypass mes's _sys_callN indirection. - * mes's linux/<arch>-mes-{mescc,gcc}/{syscall,_exit,_write,…}.c are - * also unused — those are the inline-asm files we replace. - */ - -#include <mes/lib.h> -#include <fcntl.h> -#include <errno.h> -#include <stdio.h> -#include <unistd.h> -#include <sys/stat.h> - -/* mes's <stdio.h> defines stdin/stdout/stderr as macros expanding to - * (FILE*)0/1/2. That works for libc's own .c files, but client code - * (cc-libc tests, eventually tcc-boot2's compiled output) that uses - * `extern FILE *stdout;` needs a real linkage symbol. Drop the macros - * after libc's headers have set their guards, then define globals - * with the same initializer values. mes's libc bodies that already - * referenced `stdout` had the macro substitution happen on their - * #include path; subsequent .c files re-include <stdio.h> but hit - * the include guard and so see the now-undef'd identifiers, which - * resolve to our globals at link time (same numeric value, same fd). */ -#undef stdin -#undef stdout -#undef stderr -FILE *stdin = (FILE *) 0; -FILE *stdout = (FILE *) 1; -FILE *stderr = (FILE *) 2; - -/* `__stdout` and friends (the int-typed fd globals oputs / fdputs read) - * are file-scope initialized in mes/mes_open.c — but that initializer - * is gated behind `#if SYSTEM_LIBC`, which we don't define. Without - * SYSTEM_LIBC we'd be left with only mes/globals.c's tentative - * `int __stdout;`, which zero-inits — meaning oputs("ok") writes to - * fd 0 (read-only stdin) and silently no-ops. unified-libc.c includes - * boot2-syscall.c before globals.c, so cc.scm's redecl-merge sees - * the proper definition first and absorbs the later tentative. */ -int __stdin = 0; -int __stdout = 1; -int __stderr = 2; - -extern long sys_read (long fd, long buf, long n); -extern long sys_write (long fd, long buf, long n); -extern long sys_open (long path, long flags, long mode); -extern long sys_close (long fd); -extern long sys_lseek (long fd, long off, long whence); -extern long sys_brk (long addr); -extern long sys_unlink (long path); -extern long sys_exit (long code); - -/* mes/globals.c already provides `int errno;` and the FILE-helper - * indirections (__buffered_read_clear, __ungetc_clear, __ungetc_init). - * mes/__buffered_read.c and mes/fdgetc.c implement them. */ - -ssize_t -_read (int filedes, void *buffer, size_t size) -{ - return sys_read (filedes, (long) buffer, (long) size); -} - -ssize_t -_write (int filedes, void const *buffer, size_t size) -{ - return sys_write (filedes, (long) buffer, (long) size); -} - -int -_open3 (char const *file_name, int flags, int mask) -{ - int r = sys_open ((long) file_name, flags, mask); - __ungetc_init (); - if (r > 2) - { - if (r >= __FILEDES_MAX) - { - errno = EMFILE; - return -1; - } - __ungetc_clear (r); - __buffered_read_clear (r); - } - return r; -} - -int -close (int filedes) -{ - long r = sys_close (filedes); - if (r < 0) - { - errno = -r; - return -1; - } - errno = 0; - return (int) r; -} - -off_t -_lseek (int filedes, off_t offset, int whence) -{ - return sys_lseek (filedes, offset, whence); -} - -off_t -lseek (int filedes, off_t offset, int whence) -{ - /* mirrors mes's linux/lseek.c: drain the per-fd read buffer before - * letting the kernel see a positional move; SEEK_CUR offsets must - * back out the buffered-but-not-yet-consumed bytes. */ - size_t skip = __buffered_read_clear (filedes); - if (whence == SEEK_CUR) - offset -= skip; - return sys_lseek (filedes, offset, whence); -} - -long -brk (void *addr) -{ - return sys_brk ((long) addr); -} - -int -unlink (char const *file_name) -{ - long r = sys_unlink ((long) file_name); - if (r < 0) - { - errno = -r; - return -1; - } - errno = 0; - return 0; -} - -void -_exit (int status) -{ - sys_exit (status); -} - -/* Linux aarch64/amd64/riscv64 stack at exec entry: - * [sp] = argc - * [sp + 8 * (1)] = argv[0] - * ... - * [sp + 8 * (argc+1)] = NULL (terminates argv) - * [sp + 8 * (argc+2)] = envp[0] - * Our :_start passes (a0=argc, a1=argv) to :p1_main. envp follows - * argv's NULL terminator, so we compute it from argv. tcc's getenv - * walks the resulting environ; without initialization it dereferences - * NULL on the first call and segfaults during tcc_new(). */ -extern char **environ; - -void -__libc_init (int argc, char **argv) -{ - (void) argc; - char **p = argv; - while (*p) - p++; - environ = p + 1; -} - -/* ---- ENOSYS stubs for libc-internal references not exercised by ---- - * tcc-boot2's golden path. The mes libc transitively pulls these in - * (posix/getcwd.c → _getcwd, posix/execvp.c → execve, stdlib/abort.c - * → raise, …). Providing -ENOSYS stubs keeps the link clean; if any - * of these surfaces in a real workload, replace the stub with a P1pp - * label and a thin wrapper above. */ - -#define ENOSYS 38 - -char * -_getcwd (char *buffer, size_t size) -{ - (void) buffer; (void) size; - errno = ENOSYS; - return 0; -} - -int -access (char const *path, int mode) -{ - (void) path; (void) mode; - errno = ENOSYS; - return -1; -} - -void -assert_msg (int check, char *msg) -{ - if (!check) - { - sys_write (2, (long) msg, 0); - sys_exit (1); - } -} - -int -execve (char const *file, char *const argv[], char *const envp[]) -{ - (void) file; (void) argv; (void) envp; - errno = ENOSYS; - return -1; -} - -int -fsync (int filedes) -{ - (void) filedes; - return 0; -} - -int -raise (int sig) -{ - /* abort() calls raise(SIGABRT); take that as a hard exit. */ - sys_exit (128 + sig); - return -1; -} - -int -rmdir (char const *file_name) -{ - (void) file_name; - errno = ENOSYS; - return -1; -} - -int -stat (char const *file_name, struct stat *buf) -{ - (void) file_name; (void) buf; - errno = ENOSYS; - return -1; -} - -double -strtod (char const *string, char **tailptr) -{ - /* tcc.flat.c never reaches strtod under our defines (HAVE_FLOAT off), - * and stdlib/strtof.c only forwards. cc.scm rejects FP literals, so - * we cast a zero int — same numeric value, no `0.0` token. */ - if (tailptr) - *tailptr = (char *) string; - return (double) 0; -} diff --git a/vendor/mes-libc/ctype/isalnum.c b/vendor/mes-libc/ctype/isalnum.c @@ -1,27 +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/>. - */ - -#include <ctype.h> - -int -isalnum (int c) -{ - return isdigit (c) || isalpha (c); -} diff --git a/vendor/mes-libc/ctype/isalpha.c b/vendor/mes-libc/ctype/isalpha.c @@ -1,27 +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/>. - */ - -#include <ctype.h> - -int -isalpha (int c) -{ - return islower (c) || isupper (c); -} diff --git a/vendor/mes-libc/ctype/isascii.c b/vendor/mes-libc/ctype/isascii.c @@ -1,27 +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/>. - */ - -#include <ctype.h> - -int -isascii (int c) -{ - return c >= 0 && c <= 127; -} diff --git a/vendor/mes-libc/ctype/iscntrl.c b/vendor/mes-libc/ctype/iscntrl.c @@ -1,27 +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/>. - */ - -#include <ctype.h> - -int -iscntrl (int c) -{ - return c >= 0 && c < 32; -} diff --git a/vendor/mes-libc/ctype/isdigit.c b/vendor/mes-libc/ctype/isdigit.c @@ -1,28 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2023 Rick Masters <grick23@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/>. - */ - -#include <mes/lib.h> - -int -isdigit (int c) -{ - return c >= '0' && c <= '9'; -} diff --git a/vendor/mes-libc/ctype/isgraph.c b/vendor/mes-libc/ctype/isgraph.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <ctype.h> - -int -isgraph (int c) -{ - return c > 32 && c < 127; -} diff --git a/vendor/mes-libc/ctype/islower.c b/vendor/mes-libc/ctype/islower.c @@ -1,27 +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/>. - */ - -#include <ctype.h> - -int -islower (int c) -{ - return c >= 'a' && c <= 'z'; -} diff --git a/vendor/mes-libc/ctype/isnumber.c b/vendor/mes-libc/ctype/isnumber.c @@ -1,34 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <ctype.h> - -int -isnumber (int c, int base) -{ - if (base == 2) - return (c >= '0') && (c <= '1'); - if (base == 8) - return (c >= '0') && (c <= '7'); - if (base == 10) - return isdigit (c); - if (base == 16) - return isxdigit (c); -} diff --git a/vendor/mes-libc/ctype/isprint.c b/vendor/mes-libc/ctype/isprint.c @@ -1,27 +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/>. - */ - -#include <ctype.h> - -int -isprint (int c) -{ - return c >= 32 && c < 127; -} diff --git a/vendor/mes-libc/ctype/ispunct.c b/vendor/mes-libc/ctype/ispunct.c @@ -1,27 +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/>. - */ - -#include <ctype.h> - -int -ispunct (int c) -{ - return isprint (c) && !isspace (c) && !isalnum (c); -} diff --git a/vendor/mes-libc/ctype/isspace.c b/vendor/mes-libc/ctype/isspace.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -int -isspace (int c) -{ - return (c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r' || c == ' '); -} diff --git a/vendor/mes-libc/ctype/isupper.c b/vendor/mes-libc/ctype/isupper.c @@ -1,27 +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/>. - */ - -#include <ctype.h> - -int -isupper (int c) -{ - return c >= 'A' && c <= 'Z'; -} diff --git a/vendor/mes-libc/ctype/isxdigit.c b/vendor/mes-libc/ctype/isxdigit.c @@ -1,28 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> -#include <ctype.h> - -int -isxdigit (int c) -{ - return isdigit (c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); -} diff --git a/vendor/mes-libc/ctype/tolower.c b/vendor/mes-libc/ctype/tolower.c @@ -1,29 +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/>. - */ - -#include <ctype.h> - -int -tolower (int c) -{ - if (isupper (c)) - return c + ('a' - 'A'); - return c; -} diff --git a/vendor/mes-libc/ctype/toupper.c b/vendor/mes-libc/ctype/toupper.c @@ -1,29 +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/>. - */ - -#include <ctype.h> - -int -toupper (int c) -{ - if (islower (c)) - return c - ('a' - 'A'); - return c; -} diff --git a/vendor/mes-libc/include/ar.h b/vendor/mes-libc/include/ar.h @@ -1,56 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright (C) 1996 Free Software Foundation, Inc. - * 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_AR_H -#define __MES_AR_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_AR_H -#include_next <ar.h> - -#else // ! SYSTEM_LIBC - -// Taken from GNU C Library 2.2.5 - -/* Archive files start with the ARMAG identifying string. Then follows a - `struct ar_hdr', and as many bytes of member file data as its `ar_size' - member indicates, for each member file. */ - -#define ARMAG "!<arch>\n" /* String that begins an archive file. */ -#define SARMAG 8 /* Size of that string. */ - -#define ARFMAG "`\n" /* String in ar_fmag at end of each header. */ - -struct ar_hdr -{ - char ar_name[16]; /* Member file name, sometimes / terminated. */ - char ar_date[12]; /* File date, decimal seconds since Epoch. */ - char ar_uid[6], ar_gid[6]; /* User and group IDs, in ASCII decimal. */ - char ar_mode[8]; /* File mode, in ASCII octal. */ - char ar_size[10]; /* File size, in ASCII decimal. */ - char ar_fmag[2]; /* Always contains ARFMAG. */ -}; - -#endif // ! SYSTEM_LIBC - -#endif // __MES_ARGZ_H diff --git a/vendor/mes-libc/include/argz.h b/vendor/mes-libc/include/argz.h @@ -1,40 +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_ARGZ_H -#define __MES_ARGZ_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_ARGZ_H -#include_next <argz.h> - -#else // ! SYSTEM_LIBC - -#include <mes/lib-mini.h> - -size_t __argz_count (char const *argz, size_t len); -void __argz_extract (char const *argz, size_t len, char **argv); -size_t __argz_extract_count (char const *argz, size_t len, char **argv); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_ARGZ_H diff --git a/vendor/mes-libc/include/dirent.h b/vendor/mes-libc/include/dirent.h @@ -1,87 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright (C) 1991, 1992 Free Software Foundation, Inc. - * Copyright © 2018,2024 Janneke Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2024 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_DIRENT_H -#define __MES_DIRENT_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_DIRENT_H -#include_next <dirent.h> - -#else // ! SYSTEM_LIBC - -#include <arch/syscall.h> -#include <dirstream.h> - -// Taken from GNU C Library 1.06.4, 2.2.5 - -/* - * POSIX Standard: 5.1.2 Directory Operations <dirent.h> - */ - -#include <stddef.h> - -int __getdirentries (int filedes, char *buffer, size_t nbytes, off_t * basep); - -// FIXME move to include/<kernel>/<arch>/dirent.h? -struct dirent -{ - ino_t d_ino; -#if defined (SYS_getdents64) && (__SIZEOF_LONG__ == 4 || __arm__ || __i386__) - // FIXME: redefine ino_t to ino64_t instead? - int d_ino_h; -#endif - off_t d_off; -#if defined (SYS_getdents64) && (__SIZEOF_LONG__ == 4 || __arm__ || __i386__) - // FIXME: redefine off_t to off64_t instead? - int d_off_h; -#endif - unsigned short int d_reclen; -#if defined (SYS_getdents64) - unsigned char d_type; -#endif - char d_name[256]; -}; - -/* Open a directory stream on NAME. - Return a DIR stream on the directory, or NULL if it could not be opened. */ -DIR *opendir (char const *name); - -/* Close the directory stream DIRP. - Return 0 if successful, -1 if not. */ -int closedir (DIR * dirp); - -/* Read a directory entry from DIRP. - Return a pointer to a `struct dirent' describing the entry, - or NULL for EOF or error. The storage returned may be overwritten - by a later readdir call on the same DIR stream. */ -struct dirent *readdir (DIR * dirp); - -/* Rewind DIRP to the beginning of the directory. */ -extern void rewinddir (DIR * dirp); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_DIRENT_H diff --git a/vendor/mes-libc/include/dirstream.h b/vendor/mes-libc/include/dirstream.h @@ -1,55 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - *Copyright (C) 1993, 1995, 1996 Free Software Foundation, Inc. - * 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_DIRSTREAM_H -#define __MES_DIRSTREAM_H 1 - -#if SYSTEM_LIBC && HAVE_DIRSTREAM_H -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_DIRSTREAM_H -#include_next <dirstream.h> - -#else // ! SYSTEM_LIBC - -#include <sys/types.h> - -// Taken from GNU C Library 2.2.5 - -/* Directory stream type. */ -struct __dirstream -{ - int fd; /* File descriptor. */ - - char *data; /* Directory block. */ - size_t allocation; /* Space allocated for the block. */ - size_t size; /* Total valid data in the block. */ - size_t offset; /* Current offset into the block. */ - - off_t filepos; /* Position of next entry to read. */ -}; - -typedef struct __dirstream DIR; - -#endif // ! SYSTEM_LIBC - -#endif // __MES_DIRSTREAM_H diff --git a/vendor/mes-libc/include/dlfcn.h b/vendor/mes-libc/include/dlfcn.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_DLFCN_H -#define __MES_DLFCN_H 1 - -#if SYSTEM_LIBC -#undef __MES_DLFCN_H -#include_next <dlfcn.h> - -#else // ! SYSTEM_LIBC - -#define RTLD_LAZY 0x00001 -#define RTLD_NOW 0x00002 -#define RTLD_BINDING_MASK 0x3 -#define RTLD_NOLOAD 0x00004 -#define RTLD_DEEPBIND 0x00008 -#define RTLD_GLOBAL 0x00100 -#define RTLD_LOCAL 0 -#define RTLD_NODELETE 0x01000 -#define RTLD_DEFAULT 0 - -void *dlopen (char const *filename, int flags); -int dlclose (void *handle); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_DLFCN_H diff --git a/vendor/mes-libc/include/features.h b/vendor/mes-libc/include/features.h @@ -1,28 +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_FEATURES_H -#define __MES_FEATURES_H 1 - -#if SYSTEM_LIBC -#undef __MES_FEATURES_H -#include_next <features.h> -#endif // (SYSTEM_LIBC) - -#endif // __MES_FEATURES_H diff --git a/vendor/mes-libc/include/float.h b/vendor/mes-libc/include/float.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_FLOAT_H -#define __MES_FLOAT_H 1 - -#if SYSTEM_LIBC -#undef __MES_FLOAT_H -#include_next <float.h> -#else // ! SYSTEM_LIBC - -#define MIN_EXP -1021 -#define DBL_MIN_EXP -1021 -#define LDBL_MIN_EXP -1021 - -#endif // ! SYSTEM_LIBC - -#endif // __MES_FLOAT_H diff --git a/vendor/mes-libc/include/getopt.h b/vendor/mes-libc/include/getopt.h @@ -1,62 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. - * 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_GETOPT_H -#define __MES_GETOPT_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_GETOPT_H -#include_next <getopt.h> - -#else // ! SYSTEM_LIBC -#include <endian.h> -int isdigit (int); -int isxdigit (int); - -char *optarg; -int optind; -int opterr; -struct option -{ - char const *name; - int has_arg; - int *flag; - int val; -}; - -enum _argtype -{ - no_argument, - required_argument, - optional_argument -}; - -int getopt (int argc, char *const *argv, char const *options); -int getopt_long (int argc, char *const *argv, char const *options, - struct option const *long_options, int *opt_index); -int getopt_long_only (int argc, char *const *argv, char const *options, - struct option const *long_options, int *opt_index); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_GETOPT_H diff --git a/vendor/mes-libc/include/gnu/hurd-types.h b/vendor/mes-libc/include/gnu/hurd-types.h @@ -1,393 +0,0 @@ -/* C declarations for Hurd server interfaces - Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2001, 2002, - 2010 Free Software Foundation, Inc. - -This file is part of the GNU Hurd. - -The GNU Hurd 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 2, or (at your option) -any later version. - -The GNU Hurd 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 the GNU Hurd; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _HURD_TYPES_H -#define _HURD_TYPES_H - -#ifndef _FILE_OFFSET_BITS -#define _FILE_OFFSET_BITS 32 -#endif - -#include <time.h> /* For struct timespec. */ -#include <mach/std_types.h> /* For mach_port_t et al. */ -#include <mach/message.h> /* For mach_msg_id_t et al. */ -#include <sys/types.h> /* For pid_t and uid_t. */ - -/* A string identifying this release of the GNU Hurd. Our - interpretation of the term "release" is that it refers to a set of - server interface definitions. A "version" in Posix terminology is - a distribution of the Hurd; there may be more than one distribution - without changing the release number. */ -#define HURD_RELEASE "0.0" - - -/* Simple type declarations */ - -/* These types identify certain kinds of ports used by the Hurd. */ -typedef mach_port_t file_t; -typedef mach_port_t fsys_t; -typedef mach_port_t io_t; -typedef mach_port_t process_t; -typedef mach_port_t auth_t; -typedef mach_port_t socket_t; -typedef mach_port_t pf_t; /* Protocol family */ -typedef mach_port_t addr_port_t; -typedef mach_port_t startup_t; -typedef mach_port_t fs_notify_t; -typedef mach_port_t exec_startup_t; -typedef mach_port_t interrupt_t; -typedef mach_port_t proccoll_t; -typedef mach_port_t ctty_t; - -#include <errno.h> /* Defines `error_t'. */ - -/* These names exist only because of MiG deficiencies. - You should not use them in C source; use the normal C types instead. */ -typedef char *data_t; -typedef const char *const_data_t; -typedef char string_t [1024]; -typedef int *intarray_t; -typedef const int *const_intarray_t; -typedef int *fd_mask_t; -typedef const int *const_fd_mask_t; -typedef mach_port_t *portarray_t; -typedef const mach_port_t *const_portarray_t; -typedef pid_t *pidarray_t; -typedef const pid_t *const_pidarray_t; -typedef uid_t *idarray_t; -typedef const uid_t *const_idarray_t; -#if 0 -typedef __loff_t *off_array_t; -typedef const __loff_t *const_off_array_t; -#endif -typedef struct rusage rusage_t; -typedef struct flock flock_t; -typedef struct utsname utsname_t; -#if _FILE_OFFSET_BITS == 64 -typedef struct stat io_statbuf_t; -typedef struct statfs fsys_statfsbuf_t; -#else -typedef struct stat64 io_statbuf_t; -typedef struct statfs64 fsys_statfsbuf_t; -#endif -typedef struct timespec timespec_t; - - -/* Parameters and flags in RPC calls */ - -/* Many such parameters and flags are also defined in various libc - headers. */ - -/* Bits for flags in fs.defs:file_exec_paths and exec.defs:exec_* calls: */ -#define EXEC_NEWTASK 0x00000001 /* Create new task; kill old one. */ -#define EXEC_SECURE 0x00000002 /* Use secure values of portarray, etc. */ -#define EXEC_DEFAULTS 0x00000004 /* Use defaults for unspecified ports. */ -#define EXEC_SIGTRAP 0x00000008 /* Simulate SIGTRAP on startup. */ -/* This flag is passed through by the exec server but not examined by it. */ -#define EXEC_STACK_ARGS 0x00000010 /* Use arguments from stack, not RPC. */ - -/* Bits for flags in fs.defs:file_set_translator call: */ -#define FS_TRANS_FORCE 0x00000001 /* Must use translator(no sht circuit) */ -#define FS_TRANS_EXCL 0x00000002 /* Don't do it if already translated. */ -#define FS_TRANS_SET 0x00000004 /* Set or clear translator */ -#define FS_TRANS_ORPHAN 0x00000008 /* Orphan the active translator. */ - -/* Values for retry field in fs.defs:dir_lookup call: */ -enum retry_type -{ - FS_RETRY_NORMAL = 1, /* Retry normally if retry_name is not null. */ - FS_RETRY_REAUTH = 2, /* Retry after reauthenticating retry port. - Even if the retry name is null, a retry - is still necessary with this code after the - reauthentication is complete. */ - FS_RETRY_MAGICAL = 3, /* Retry string is magical. */ - /* "tty" means controlling tty; - - "fd/%u" means file descriptor N; - - "machtype/..." means replace `machtype' with the numbers in decimal - returned by the user's kernel as the cpu_type (N) and - cpu_subtype (M) (producing N/M/...) and then retry - as for FS_RETRY_NORMAL. - - "/..." means retry "...", but starting from the users root directory. - - "pid/..." means replace `pid' with the PID of the current process in %u - format and then retry as for FS_RETRY_NORMAL. - */ -}; -typedef enum retry_type retry_type; - -/* Types for fs_notify.defs:dir_changed call: */ -enum dir_changed_type -{ - DIR_CHANGED_NULL, /* Always sent first for sync. */ - DIR_CHANGED_NEW, /* Specified name has been added. */ - DIR_CHANGED_UNLINK, /* Specified name has been removed. */ - DIR_CHANGED_RENUMBER, /* Name has been the target of rename. */ -}; -typedef enum dir_changed_type dir_changed_type_t; - -/* Types for fs_notify.defs:file_changed call: */ -enum file_changed_type -{ - FILE_CHANGED_NULL, /* Always sent first for sync. */ - FILE_CHANGED_WRITE, /* File data has been written. */ - FILE_CHANGED_EXTEND, /* File has grown. */ - FILE_CHANGED_TRUNCATE, /* File has been truncated. */ - FILE_CHANGED_META, /* Stat information has changed, and none - of the previous three apply. Not sent - for changes in node times. */ -}; -typedef enum file_changed_type file_changed_type_t; - -/* Select types for io.defs:io_select call: */ -#define SELECT_READ 0x00000001 -#define SELECT_WRITE 0x00000002 -#define SELECT_URG 0x00000004 - -/* Flags for fsys.defs:fsys_goaway. Also, these flags are sent as the - oldtrans_flags in fs.defs:file_set_translator to describe how to - terminate the old translator. */ -#define FSYS_GOAWAY_NOWAIT 0x00000001 /* Return immediately. */ -#define FSYS_GOAWAY_NOSYNC 0x00000002 /* Don't update physical media. */ -#define FSYS_GOAWAY_FORCE 0x00000004 /* Go away despite current users. */ -#define FSYS_GOAWAY_UNLINK 0x00000008 /* Go away only if non-directory. */ -#define FSYS_GOAWAY_RECURSE 0x00000010 /* Shutdown children too. */ - -/* Types of ports the terminal driver can run on top of; - used in term.defs:term_get_bottom_type. */ -enum term_bottom_type -{ - TERM_ON_MACHDEV, - TERM_ON_HURDIO, - TERM_ON_MASTERPTY, -}; - -/* Types of storage, as returned by file_get_storage_info. - - STORAGE_DEVICE is a mach device_t (for random access devices) - STORAGE_HURD_FILE is a hurd file_t (as if a file were mapped) - STORAGE_TASK is a task_t (the storage is in the vm of the task) - STORAGE_MEMORY is a memory object port - STORAGE_ZERO is a fixed-size constant source of zeros - STORAGE_INTERLEAVE is a set of other storage types interleaved at a fixed - interval - STORAGE_CONCAT is a set of other storage types concatenated end-to-end - STORAGE_LAYER is a set of storage types, representing the same address - range; all will be written too, and will be read in turn until one - succeeds - STORAGE_REMAP is a layer on top of another store that remaps its blocks - STORAGE_COPY is a memory snapshot of another store - STORAGE_NETWORK means that the file is stored elsewhere on the - network; all the remaining fields contan type-specific information. - STORAGE_OTHER means none of these apply; and should be used when no - meaningful answer can be given - - The vectors returned by file_get_storage_info encode each of the above - (note that the first int is always the storage type). There are four: - ports, ints, offsets (off_t), and data (char); each type of store uses the - following entries in each vector: - - -type- -ports- -ints- -offsets- -data- -kids- - device DEVICE TY, FL, BS, NR, NL, ML NR * (OFFS, LEN) NL + ML - - file FILE TY, FL, BS, NR, NL, ML NR * (OFFS, LEN) NL + ML - - memory MEMOBJ TY, FL, BS, NR, NL, ML NR * (OFFS, LEN) NL + ML - - task TASK TY, FL, BS, NR, NL, ML NR * (OFFS, LEN) NL + ML - - (the data for the above is a name (incl '\0') and a misc data block) - null - TY, FL SIZE - - - (BS is 1) - ileave - TY, FL, IL, NC - - NC - (BS is the LCM of its children; SIZE is the minimum of theirs * IL) - concat - TY, FL, NC - - NC - (BS is the LCM of its children; SIZE is the sum of theirs) - layer - TY, FL, NC - - NC - (BS is the LCM of its children; SIZE is the minimum of theirs) - remap - TY, FL, NR NR * (OFFS, LEN) - 1 - (BS and SIZE are that of the child) - copy - TY, FL, SIZE - DATA - - (DATA is preceded by padding to the next page boundary, and is - SIZE bytes long itself) - - For ileave, concat, and layer, the children are encoded following the parent. - The first int must always be TY. - - key: TY = type code, FL = flags, BS = block size, NR = num runs, - NL = name len, ML = misc len, NC = num children, - IL = interleave (bytes), SIZE = Size of storage (blocks), - LEN = run length (blocks), OFFS = run offset (blocks), - - The NR * (OFFS, LEN) offsets for some of the types is the set of block - ranges in the underlying address space that, concatenated, make up the - contents of the storage -- for instance, doing file_get_storage_info on a - file may return storage of type STORAGE_DEVICE, and the accompanying block - ranges are the set of blocks on the given device that correspond to that - file. Any OFFS == -1 designates a hole in the address range. Note that - the total size (SIZE) for these types is the sum of their LEN's. - - The optional NAME returned by some types (if NL != 0) is a type specific - name for the same object referenced by the port also returned. E.g.: - device -- The mach device name - file -- The file name (unreliable, as the root may not be the same) - task -- The pid - Unless it is MACH_PORT_NULL, the port should generally be used instead of - trying to regenerate it from the associated name, which is intended more for - printing messages, etc. */ -enum file_storage_class -{ - STORAGE_OTHER, - STORAGE_DEVICE, - STORAGE_HURD_FILE, - STORAGE_NETWORK, - STORAGE_MEMORY, - STORAGE_TASK, - STORAGE_ZERO, - STORAGE_CONCAT, - STORAGE_INTERLEAVE, - STORAGE_LAYER, - STORAGE_REMAP, - STORAGE_COPY, -}; - -/* Flags for the flags word returned by some types . */ -#define STORAGE_MUTATED 0x00000001 /* data as stored is munged from file */ - -/* Data types */ - -#include <mach/task_info.h> -#include <mach/thread_info.h> -#ifndef THREAD_SCHED_INFO -#include <mach/policy.h> -#endif - -/* Flags sent in proc_getprocinfo request. */ -#define PI_FETCH_TASKINFO 0x0001 -#define PI_FETCH_TASKEVENTS 0x0020 -#define PI_FETCH_THREADS 0x0002 -#define PI_FETCH_THREAD_BASIC 0x0004 -#define PI_FETCH_THREAD_SCHED 0x0008 -#define PI_FETCH_THREAD_WAITS 0x0010 - -struct procinfo -{ - int state; - uid_t owner; - pid_t ppid; - pid_t pgrp; - pid_t session; - pid_t logincollection; - int exitstatus; - int sigcode; - - int nthreads; /* size of pi_threadinfos */ - - struct task_basic_info taskinfo; - struct task_events_info taskevents; -#ifdef TASK_SCHED_TIMESHARE_INFO - struct policy_timeshare_base timeshare_base_info; -#endif - struct - { - int died; /* this thread died in the middle of call */ - mach_msg_id_t rpc_block; /* thread is blocked on this RPC */ - struct thread_basic_info pis_bi; -#ifdef THREAD_SCHED_INFO - struct thread_sched_info pis_si; -#else - struct policy_infos pis_pi; -#endif - } threadinfos[0]; -}; -typedef int *procinfo_t; -typedef const int *const_procinfo_t; - -/* Bits in struct procinfo state: */ -#define PI_STOPPED 0x00000001 /* Proc server thinks is stopped. */ -#define PI_EXECED 0x00000002 /* Has called proc_exec. */ -#define PI_WAITING 0x00000004 /* Process is waiting for child to exit */ -#define PI_ORPHAN 0x00000008 /* Process group is orphaned. */ -#define PI_NOMSG 0x00000010 /* Process has no message port. */ -#define PI_SESSLD 0x00000020 /* Session leader. */ -#define PI_NOTOWNED 0x0000040 /* Process has no owner. */ -#define PI_NOPARENT 0x0000080 /* Hasn't identified a parent. */ -#define PI_ZOMBIE 0x00000100 /* Has no associated task. */ -#define PI_TRACED 0x00000200 /* Process is being traced */ -#define PI_GETMSG 0x00000400 /* Process is blocked in proc_getmsgport. */ -#define PI_LOGINLD 0x00000800 /* Process is leader of login collection */ - - -/* Conventions */ - - -/* st_fstype in struct stat and fsys_stb_type in fsys_statfsbuf is one of: */ -#define FSTYPE_UFS 0x00000000 /* 4.x BSD Fast File System */ -#define FSTYPE_NFS 0x00000001 /* Network File System ala Sun */ -#define FSTYPE_GFS 0x00000002 /* GNU file system */ -#define FSTYPE_LFS 0x00000003 /* Logging File System ala Sprite */ -#define FSTYPE_SYSV 0x00000004 /* Old U*x filesystem ala System V */ -#define FSTYPE_FTP 0x00000005 /* Transparent FTP */ -#define FSTYPE_TAR 0x00000006 /* Transparent TAR */ -#define FSTYPE_AR 0x00000007 /* Transparent AR */ -#define FSTYPE_CPIO 0x00000008 /* Transparent CPIO */ -#define FSTYPE_MSLOSS 0x00000009 /* MS-DOS */ -#define FSTYPE_CPM 0x0000000a /* CP/M */ -#define FSTYPE_HFS 0x0000000b /* Don't ask */ -#define FSTYPE_DTFS 0x0000000c /* used by desktop to provide more info */ -#define FSTYPE_GRFS 0x0000000d /* GNU Remote File System */ -#define FSTYPE_TERM 0x0000000e /* GNU Terminal driver */ -#define FSTYPE_DEV 0x0000000f /* GNU Special file server */ -#define FSTYPE_PROC 0x00000010 /* /proc filesystem ala Version 9 */ -#define FSTYPE_IFSOCK 0x00000011 /* PF_LOCAL socket naming point */ -#define FSTYPE_AFS 0x00000012 /* Andrew File System 3.xx */ -#define FSTYPE_DFS 0x00000013 /* Distributed File Sys (OSF) == AFS 4.xx */ -#define FSTYPE_PROC9 0x00000014 /* /proc filesystem ala Plan 9 */ -#define FSTYPE_SOCKET 0x00000015 /* io_t that isn't a file but a socket */ -#define FSTYPE_MISC 0x00000016 /* generic trivfs server */ -#define FSTYPE_EXT2FS 0x00000017 /* Linux filesystem by Remy Card */ -#define FSTYPE_HTTP 0x00000018 /* Transparent HTTP */ -#define FSTYPE_MEMFS 0x00000019 /* In-core filesystem */ -#define FSTYPE_ISO9660 0x0000001a /* ISO9660 */ - -/* Standard port assignments for file_exec_paths and exec_* */ -enum - { - INIT_PORT_CWDIR, - INIT_PORT_CRDIR, - INIT_PORT_AUTH, - INIT_PORT_PROC, - INIT_PORT_CTTYID, - /* If MACH_PORT_NULL is given for the bootstrap port, - the bootstrap port of the old task is used. */ - INIT_PORT_BOOTSTRAP, - INIT_PORT_MAX - }; - -/* Standard ints for file_exec_paths and exec_* */ -enum - { - INIT_UMASK, - INIT_SIGMASK, - INIT_SIGIGN, - INIT_SIGPENDING, - INIT_TRACEMASK, - INIT_INT_MAX, - }; - -#endif // _HURD_TYPES_H diff --git a/vendor/mes-libc/include/gnu/hurd.h b/vendor/mes-libc/include/gnu/hurd.h @@ -1,90 +0,0 @@ -/* - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2019,2024 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_GNU_HURD_H -#define __MES_GNU_HURD_H - -#define _GNU_SOURCE 1 -#define __USE_GNU 1 - -#include <errno.h> -#include <sys/types.h> - -#ifndef _BITS_TYPES_H -#ifndef _LOFF_T -#define _LOFF_T -typedef off64_t loff_t; -#endif -#endif - -#include <mach/mach_types.h> -#include <mach/message.h> -#include <mach/port.h> - -struct hurd_startup_data - { - int flags; - - mach_port_t *dtable; - mach_msg_type_number_t dtable_count; - - char *argp; - int arg_size; - - char *envp; - int env_size; - - mach_port_t *portarray; - mach_msg_type_number_t portarray_count; - - int *intarray; - mach_msg_type_number_t intarray_count; - - vm_address_t stack_base; - vm_size_t stack_count; - - vm_address_t phdr; - vm_size_t phdr_count; - - vm_address_t user_entry; - }; - -#define _HURD_DTABLE_MAX 1024 -extern mach_port_t _hurd_dtable[_HURD_DTABLE_MAX]; -extern int _hurd_dtable_count; -extern struct hurd_startup_data _hurd_startup_data; - -#define _HURD_ARGV_MAX 1000 -#define _HURD_ENVV_MAX 1000 -extern size_t __argc; -extern char *__argv[_HURD_ARGV_MAX]; -extern char *__envv[_HURD_ENVV_MAX]; - -mach_port_t fd_get (int filedes); -error_t fd_write (mach_port_t port, void const *buffer, size_t *size, loff_t offset); -error_t fd_read (mach_port_t port, void *buffer, size_t *size, loff_t offset); - -#include <sys/stat.h> -#include <gnu/hurd-types.h> - -kern_return_t __dir_lookup (file_t start_dir, string_t file_name, int flags, mode_t mode, retry_type *do_retry, string_t retry_name, mach_port_t *port); -mach_port_t __mach_reply_port (); - -#endif // __MES_GNU_HURD_H diff --git a/vendor/mes-libc/include/gnu/syscall.h b/vendor/mes-libc/include/gnu/syscall.h @@ -1,144 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2019,2024 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_GNU_SYSCALL_H -#define __MES_GNU_SYSCALL_H - -#define _GNU_SOURCE 1 -#define __USE_GNU 1 - -#include <mach/mach_types.h> -#include <mach/port.h> -#include <mach/message.h> -#include <gnu/hurd.h> -#include <gnu/hurd-types.h> - -// mach/mach.defs -enum - { - SYS__task_terminate = 2008, - SYS__vm_allocate = 2021, - SYS__vm_statistics = 2030, - SYS__task_get_special_port = 2058, - }; - -// hurd/fsys.defs -enum - { - SYS__dir_lookup = 20018, - }; - -// hurd/io.defs -enum - { - SYS__io_write = 21000, - SYS__io_read, - }; - -// hurd/process.defs -enum - { - SYS__proc_mark_exit = 24025, - }; - -// hurd/startup.defs -enum - { - SYS__exec_startup_get_info = 30500, - }; - -extern mach_msg_type_t mach_msg_type_int32; -extern mach_msg_type_t mach_msg_type_int64; -extern mach_msg_type_long_t mach_msg_type_pointer; - -struct mach_msg -{ - mach_msg_header_t header; -}; - -struct mach_msg_1 -{ - mach_msg_header_t header; - mach_msg_type_t type_one; int one; -}; - -struct mach_msg_2 -{ - mach_msg_header_t header; - mach_msg_type_t type_one; int one; - mach_msg_type_t type_two; int two; -}; - -struct mach_msg_loff_int -{ - mach_msg_header_t header; - mach_msg_type_t type_one; loff_t one; - mach_msg_type_t type_two; int two; -}; - -struct mach_msg_startup_info -{ - mach_msg_header_t header; - mach_msg_type_t RetCodeType; - kern_return_t RetCode; - mach_msg_type_t user_entryType; - vm_address_t user_entry; - mach_msg_type_t phdrType; - vm_address_t phdr; - mach_msg_type_t phdr_sizeType; - vm_size_t phdr_size; - mach_msg_type_t stack_baseType; - vm_address_t stack_base; - mach_msg_type_t stack_sizeType; - vm_size_t stack_size; - mach_msg_type_t flagsType; - int flags; - mach_msg_type_long_t argvType; - char *argv; - mach_msg_type_long_t envpType; - char *envp; - mach_msg_type_long_t dtableType; - mach_port_t *dtable; - mach_msg_type_long_t portarrayType; - mach_port_t *portarray; - mach_msg_type_long_t intarrayType; - int *intarray; -}; - -kern_return_t __syscall (mach_port_t port, int sys_call); -kern_return_t __syscall2 (mach_port_t port, int sys_call, int one, int two); -kern_return_t __syscall_get (mach_port_t port, int sys_call, mach_msg_header_t *message, size_t size); -kern_return_t __syscall_put (mach_port_t port, int sys_call, mach_msg_header_t *message, size_t size); - -// mach.defs -kern_return_t __task_terminate (mach_port_t task); -kern_return_t __task_get_special_port (mach_port_t task, int which, mach_port_t *port); -kern_return_t __vm_allocate (mach_port_t task, vm_address_t *address, vm_size_t size, boolean_t anywhere); -kern_return_t __vm_statistics (mach_port_t task, vm_statistics_data_t *vm_stats); - -// process.defs -kern_return_t __proc_mark_exit (mach_port_t process, int one, int two); -kern_return_t __exec_startup_get_data (mach_port_t bootstrap, struct hurd_startup_data *data); - -// io.c -kern_return_t __io_read (io_t io, data_t *data, size_t *read, loff_t offset, vm_size_t size); -kern_return_t __io_write (io_t io_object, const_data_t data, size_t size, loff_t offset, vm_size_t *wrote); - -#endif // __MES_GNU_SYSCALL_H diff --git a/vendor/mes-libc/include/gnu/x86/kernel-stat.h b/vendor/mes-libc/include/gnu/x86/kernel-stat.h @@ -1,30 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2022,2024 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_GNU_X86_KERNEL_STAT_H -#define __MES_GNU_X86_KERNEL_STAT_H 1 - -#include <arch/syscall.h> - -struct stat -{ - mode_t st_mode; -}; - -#endif // __MES_GNU_X86_KERNEL_STAT_H diff --git a/vendor/mes-libc/include/gnu/x86/signal.h b/vendor/mes-libc/include/gnu/x86/signal.h @@ -1,90 +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/>. - */ -#define EBX 0 -#define ECX 1 -#define EDX 2 -#define ESI 3 -#define EDI 4 -#define EBP 5 -#define EAX 6 -#define DS 7 -#define ES 8 -#define FS 9 -#define GS 10 -#define ORIG_EAX 11 -#define EIP 12 -#define CS 13 -#define EFL 14 -#define UESP 15 -#define SS 16 -#define FRAME_SIZE 17 - -/* Type for general register. */ -typedef int greg_t; - -/* Number of general registers. */ -#define NGREG 19 - -/* Container for all general registers. */ -typedef greg_t gregset_t[NGREG]; - -/* Definitions taken from the kernel headers. */ -struct _libc_fpreg -{ - unsigned short int significand[4]; - unsigned short int exponent; -}; - -struct _libc_fpstate -{ - unsigned long int cw; - unsigned long int sw; - unsigned long int tag; - unsigned long int ipoff; - unsigned long int cssel; - unsigned long int dataoff; - unsigned long int datasel; - struct _libc_fpreg _st[8]; - unsigned long int status; -}; - -/* Structure to describe FPU registers. */ -typedef struct _libc_fpstate *fpregset_t; - -typedef struct -{ - gregset_t gregs; - /* Due to Linux's history we have to use a pointer here. The SysV/i386 - ABI requires a struct with the values. */ - fpregset_t fpregs; - unsigned long int oldmask; - unsigned long int cr2; -} mcontext_t; - -/* Userlevel context. */ -typedef struct ucontext -{ - unsigned long int uc_flags; - struct ucontext *uc_link; - stack_t uc_stack; - mcontext_t uc_mcontext; - sigset_t uc_sigmask; - struct _libc_fpstate __fpregs_mem; -} ucontext_t; diff --git a/vendor/mes-libc/include/grp.h b/vendor/mes-libc/include/grp.h @@ -1,45 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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_GRP_H -#define __MES_GRP_H 1 - -#if SYSTEM_LIBC -#undef __MES_GRP_H -#include_next <grp.h> -#else // ! SYSTEM_LIBC - -#include <sys/types.h> - -struct group -{ - char *gr_name; - gid_t gr_gid; - char **gr_mem; -}; - -struct group *getgrent (void); -void endgrent (void); -void setgrent (void); -struct group *getgrgid (gid_t gid); -struct group *getgrnam (char const *name); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_GRP_H diff --git a/vendor/mes-libc/include/libgen.h b/vendor/mes-libc/include/libgen.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_LIBGEN_H -#define __MES_LIBGEN_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_LIBGEN_H -#include_next <libgen.h> - -#else // ! SYSTEM_LIBC -char *dirname (char *); -#endif // ! SYSTEM_LIBC - -#endif // __MES_LIBGEN_H diff --git a/vendor/mes-libc/include/linux/SYSCALLS b/vendor/mes-libc/include/linux/SYSCALLS @@ -1,111 +0,0 @@ -#+COMMENT: -*- org -*- -#+TITLE: Linux System Calls - -|---------------+----------+-----+--------+-----+---------| -| name | old | x86 | x86_64 | arm | riscv64 | -|---------------+----------+-----+--------+-----+---------| -| libc-mini | | | | | | -|---------------+----------+-----+--------+-----+---------| -| exit | | 1 | 60 | 1 | 1 | -| write | | 4 | 1 | 4 | 4 | -|---------------+----------+-----+--------+-----+---------| -| libc | | | | | | -|---------------+----------+-----+--------+-----+---------| -| fork | | 2 | 57 | 2 | 2 | -| read | | 3 | 0 | 3 | 3 | -| open | | 5 | 2 | 5 | 5 | -| waitpid | | 7 | | | | -| wait4 | waitpid | 114 | 61 | 114 | 114 | -| execve | | 11 | 59 | 11 | 11 | -| chmod | | 15 | 90 | 15 | 15 | -| access | | 33 | 21 | 33 | 33 | -| brk | | 45 | 12 | 45 | 45 | -| ioctl | | 54 | 16 | 54 | 54 | -| fsync | | 118 | 74 | 118 | 118 | -| getcwd | | 183 | 79 | 183 | 183 | -| dup | | 41 | 32 | 41 | 41 | -| dup2 | | 63 | 33 | 63 | 63 | -| unlink | | 10 | 87 | 10 | 10 | -| gettimeofday | time | 78 | 96 | 78 | 78 | -| clock_gettime | | 265 | 228 | 263 | 260 | -| time | | 13 | 201 | 13 | | -|---------------+----------+-----+--------+-----+---------| -| libc+tcc | | | | | | -|---------------+----------+-----+--------+-----+---------| -| close | | 6 | 3 | 6 | 6 | -| lseek | | 19 | 8 | 19 | 19 | -| rmdir | | 40 | 84 | 40 | 40 | -| stat | | 106 | 4 | 106 | 106 | -|---------------+----------+-----+--------+-----+---------| -| libc+GNU | | | | | | -|---------------+----------+-----+--------+-----+---------| -| chdir | | 12 | 80 | 12 | 12 | -| link | | 9 | 86 | 9 | 9 | -| getpid | | 20 | 39 | 20 | 20 | -| getuid | | 24 | 102 | 24 | 199 | -| kill | | 37 | 62 | 37 | 37 | -| rename | | 38 | 82 | 38 | 38 | -| mkdir | | 39 | 83 | 39 | 39 | -| pipe | | 42 | 22 | 42 | 42 | -| getgid | | 47 | 104 | 47 | 200 | -| signal | | 48 | | | 48 | -| sigaction | | 67 | | 67 | 67 | -| rt_sigaction | | 174 | 13 | 174 | 174 | -| signal | | 48 | | | 48 | -| fcntl | | 55 | 72 | 55 | 55 | -| getrusage | | 77 | 98 | 77 | 77 | -| lstat | | 107 | 6 | 107 | 107 | -| setitimer | | 104 | 38 | 104 | 104 | -| fstat | | 108 | 5 | 108 | 108 | -| nanosleep | | 162 | 35 | 162 | 162 | -| getdents | | 141 | 78 | 141 | 141 | -|---------------+----------+-----+--------+-----+---------| -| GNU+bash | | | | | | -|---------------+----------+-----+--------+-----+---------| -| setuid | | 23 | 105 | 23 | 213 | -| geteuid | | 49 | 107 | 49 | 201 | -| getegid | | 50 | 108 | 50 | 202 | -| setgid | | 46 | 106 | 46 | 214 | -| getppid | | 64 | 110 | 64 | 64 | -|---------------+----------+-----+--------+-----+---------| -| GNU+make | | | | | | -|---------------+----------+-----+--------+-----+---------| -| sigprocmask | | 126 | | 126 | 126 | -|---------------+----------+-----+--------+-----+---------| -| GNU+tar | | | | | | -|---------------+----------+-----+--------+-----+---------| -| symlink | | 83 | 88 | 83 | 83 | -| readlink | | 85 | 89 | 85 | 85 | -| mknod | | 14 | 133 | 14 | 14 | -|---------------+----------+-----+--------+-----+---------| -| new | | | | | | -|---------------+----------+-----+--------+-----+---------| -| clone | fork | 120 | 56 | 120 | 120 | -| getdents64 | getdents | 220 | 217 | 217 | 220 | -| openat | open | 295 | 257 | 322 | 288 | -| mkdirat | mkdir | 296 | 258 | 323 | 289 | -| mknodat | mknod | 297 | 259 | 324 | 290 | -| unlinkat | rmdir | 301 | 263 | 328 | 294 | -| unlinkat | unlink | 301 | 263 | 328 | 294 | -| renameat | rename | 302 | 264 | 329 | 295 | -| linkat | link | 303 | 265 | 330 | 296 | -| symlinkat | symlink | 304 | 266 | 331 | 297 | -| readlinkat | readlink | 305 | 267 | 332 | 298 | -| fchmodat | chmod | 306 | 268 | 333 | 299 | -| faccessat | access | 307 | 269 | 334 | 300 | -| dup3 | dup2 | 330 | 292 | 358 | 326 | -| pipe2 | pipe | 331 | 293 | 359 | 325 | -|---------------+----------+-----+--------+-----+---------| - -* Sources - -https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tbl -https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_32.tbl -https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_64.tbl - -* Legalese -Copyright © 2022 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]> - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright - notice and this notice are preserved. diff --git a/vendor/mes-libc/include/linux/arm/kernel-stat.h b/vendor/mes-libc/include/linux/arm/kernel-stat.h @@ -1,79 +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_LINUX_ARM_KERNEL_STAT_H -#define __MES_LINUX_ARM_KERNEL_STAT_H 1 - -// https://github.com/torvalds/linux/blob/master/arch/arm/include/uapi/asm/stat.h - -#include <arch/syscall.h> - -#if __SIZEOF_LONG_LONG__ != 8 - -// *INDENT-OFF* -struct stat -{ - unsigned long st_dev; - unsigned long st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned long st_rdev; - unsigned long st_size; - unsigned long st_blksize; - unsigned long st_blocks; - unsigned long st_atime; - unsigned long st_atime_usec; - unsigned long st_mtime; - unsigned long st_mtime_usec; - unsigned long st_ctime; - unsigned long st_ctime_usec; - unsigned long __pad0; - unsigned long __pad1; -}; - -#else // __SIZEOF_LONG_LONG__ == 8 - -struct stat -{ - unsigned long long st_dev; - unsigned char __pad0[4]; - unsigned long __st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned long st_uid; - unsigned long st_gid; - unsigned long long st_rdev; - unsigned char __pad3[4]; - long long st_size; - unsigned long st_blksize; - unsigned long long st_blocks; - unsigned long st_atime; - unsigned long st_atime_nsec; - unsigned long st_mtime; - unsigned int st_mtime_nsec; - unsigned long st_ctime; - unsigned long st_ctime_nsec; - unsigned long long st_ino; -}; - -#endif // __SIZEOF_LONG_LONG__ == 8 - -#endif // __MES_LINUX_ARM_KERNEL_STAT_H diff --git a/vendor/mes-libc/include/linux/arm/signal.h b/vendor/mes-libc/include/linux/arm/signal.h @@ -1,51 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech> - * Copyright © 2024 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/>. - */ - -// Taken from musl libc (4a16ddf5) - -typedef int greg_t; -typedef int gregset_t[18]; -typedef struct sigcontext -{ - unsigned long trap_no, error_code, oldmask; - unsigned long arm_r0, arm_r1, arm_r2, arm_r3; - unsigned long arm_r4, arm_r5, arm_r6, arm_r7; - unsigned long arm_r8, arm_r9, arm_r10, arm_fp; - unsigned long arm_ip, arm_sp, arm_lr, arm_pc; - unsigned long arm_cpsr, fault_address; -} mcontext_t; - -struct sigaltstack -{ - void *ss_sp; - int ss_flags; - size_t ss_size; -}; - -typedef struct __ucontext -{ - unsigned long uc_flags; - struct __ucontext *uc_link; - stack_t uc_stack; - mcontext_t uc_mcontext; - sigset_t uc_sigmask; - unsigned long long uc_regspace[64]; -} ucontext_t; diff --git a/vendor/mes-libc/include/linux/arm/syscall.h b/vendor/mes-libc/include/linux/arm/syscall.h @@ -1,122 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018,2022,2024 Janneke Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2020 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/>. - */ -/* Commentary: - * See https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tbl - * https://github.com/torvalds/linux/raw/v4.19/arch/arm/tools/syscall.tbl - * - * Code: - */ -#ifndef __MES_LINUX_ARM_SYSCALL_H -#define __MES_LINUX_ARM_SYSCALL_H 1 - -/* libc-mini */ -#ifndef SYS_exit -#define SYS_exit 0x01 -#endif -#ifndef SYS_write -#define SYS_write 0x04 -#endif - -/* libc */ -#define SYS_fork 0x02 -#define SYS_read 0x03 -#define SYS_open 0x05 -//#define SYS_waitpid -#define SYS_wait4 0x72 -#define SYS_execve 0x0b -#define SYS_chmod 0x0f -#define SYS_access 0x21 -#define SYS_brk 0x2d -#define SYS_ioctl 0x36 -#define SYS_fsync 0x76 -#define SYS_getcwd 0xb7 -#define SYS_dup 0x29 -#define SYS_dup2 0x3f -#define SYS_unlink 0x0a -#define SYS_gettimeofday 0x4e -#define SYS_clock_gettime 0x107 -#define SYS_newuname 0x7a - -/* libc+tcc */ -#define SYS_close 0x06 -#define SYS_lseek 0x13 -#define SYS_rmdir 0x28 -#define SYS_stat 0x6a - -/* libc+gnu */ -#define SYS_chdir 0x0c -#define SYS_link 0x09 -#define SYS_getpid 0x14 -#define SYS_getuid 0x18 -#define SYS_kill 0x25 -#define SYS_rename 0x26 -#define SYS_mkdir 0x27 -#define SYS_pipe 0x2a -#define SYS_getgid 0x2f -#define SYS_rt_sigaction 0xae -#define SYS_rt_sigreturn 0xad -#define SYS_fcntl 0x37 -#define SYS_getrusage 0x4d -#define SYS_lstat 0x6b -#define SYS_setitimer 0x68 -#define SYS_fstat 0x6c -#define SYS_nanosleep 0xa2 -#define SYS_getdents 0x8d - -/* bash */ -#define SYS_setuid 0x17 -#define SYS_setgid 0x2e -#define SYS_geteuid 0x31 -#define SYS_getegid 0x32 -#define SYS_getppid 0x40 - -/* make+WITH_GLIBC */ -#define SYS_rt_sigprocmask 0xaf - -/* tar */ -#define SYS_symlink 0x53 -#define SYS_readlink 0x55 -#define SYS_mknod 0x0e - -/* gash */ -#define SYS_umask 0x3c -#define SYS_utimensat 0x15c - -#if __SIZEOF_LONG_LONG__ == 8 - -#define SYS_stat64 0xc3 -#define SYS_lstat64 0xc4 -#define SYS_fstat64 0xc5 -#define SYS_fcntl64 0xdd -#define SYS_getdents64 0xdc - -#undef SYS_stat -#define SYS_stat SYS_stat64 - -#undef SYS_lstat -#define SYS_lstat SYS_lstat64 - -#undef SYS_fstat -#define SYS_fstat SYS_fstat64 - -#endif // __SIZEOF_LONG_LONG__ == 8 - -#endif /* __MES_LINUX_ARM_SYSCALL_H */ diff --git a/vendor/mes-libc/include/linux/m2/kernel-stat.h b/vendor/mes-libc/include/linux/m2/kernel-stat.h @@ -1,47 +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 __LINUX_M2_KERNEL_STAT_H -#define __LINUX_M2_KERNEL_STAT_H - -/* https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/stat.h */ - -/* *INDENT-OFF* */ -struct stat -{ - unsigned st_dev; - unsigned st_ino; - char st_mode[2]; - char st_nlink[2]; - char st_uid[2]; - char st_gid[2]; - unsigned st_rdev; - unsigned st_size; - unsigned st_blksize; - unsigned st_blocks; - unsigned st_atime; - unsigned st_atime_usec; - unsigned st_mtime; - unsigned st_mtime_usec; - unsigned st_ctime; - unsigned st_ctime_usec; - unsigned __pad0; - unsigned __pad1; -}; -#endif /* __LINUX_M2_KERNEL_STAT_H */ diff --git a/vendor/mes-libc/include/linux/riscv32/kernel-stat.h b/vendor/mes-libc/include/linux/riscv32/kernel-stat.h @@ -1,46 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2021 W. J. van der Laan <laanwj@protonmail.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_LINUX_RISCV32_KERNEL_STAT_H -#define __MES_LINUX_RISCV32_KERNEL_STAT_H 1 - -// *INDENT-OFF* -struct stat -{ - unsigned long st_dev; - unsigned long st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned long st_rdev; - long st_size; /* Linux: unsigned long; glibc: off_t (i.e. signed) */ - unsigned long st_blksize; - unsigned long st_blocks; - time_t st_atime; /* Linux: unsigned long; glibc: time_t */ - unsigned long st_atime_usec; - time_t st_mtime; /* Linux: unsigned long; glibc: time_t */ - unsigned long st_mtime_usec; - time_t st_ctime; /* Linux: unsigned long; glibc: time_t */ - unsigned long st_ctime_usec; - unsigned long __foo0; - unsigned long __foo1; -}; - -#endif // __MES_LINUX_RISCV32_KERNEL_STAT_H diff --git a/vendor/mes-libc/include/linux/riscv64/signal.h b/vendor/mes-libc/include/linux/riscv64/signal.h @@ -1,89 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * 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/>. - */ - -// Taken from musl libc (4a16ddf5) - -#define REG_PC 0 -#define REG_RA 1 -#define REG_SP 2 -#define REG_TP 4 -#define REG_S0 8 -#define REG_A0 10 - -typedef unsigned long __riscv_mc_gp_state[32]; - -struct __riscv_mc_f_ext_state -{ - unsigned int __f[32]; - unsigned int __fcsr; -}; - -struct __riscv_mc_d_ext_state -{ - unsigned long long __f[32]; - unsigned int __fcsr; -}; - -struct __riscv_mc_q_ext_state -{ - unsigned long long __f[64]; // __attribute__((aligned(16))) - unsigned int __fcsr; - unsigned int __reserved[3]; -}; - -union __riscv_mc_fp_state -{ - struct __riscv_mc_f_ext_state __f; - struct __riscv_mc_d_ext_state __d; - struct __riscv_mc_q_ext_state __q; -}; - -typedef struct mcontext_t -{ - __riscv_mc_gp_state __gregs; - union __riscv_mc_fp_state __fpregs; -} mcontext_t; - -typedef unsigned long greg_t; -typedef unsigned long gregset_t[32]; -typedef union __riscv_mc_fp_state fpregset_t; - -struct sigcontext -{ - gregset_t gregs; - fpregset_t fpregs; -}; - -struct sigaltstack -{ - void *ss_sp; - int ss_flags; - size_t ss_size; -}; - -typedef struct __ucontext -{ - unsigned long uc_flags; - struct __ucontext *uc_link; - stack_t uc_stack; - sigset_t uc_sigmask; - mcontext_t uc_mcontext; -} ucontext_t; - diff --git a/vendor/mes-libc/include/linux/riscv64/syscall.h b/vendor/mes-libc/include/linux/riscv64/syscall.h @@ -1,106 +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 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_LINUX_RISCV_SYSCALL_H -#define __MES_LINUX_RISCV_SYSCALL_H 1 - -/** RISC-V uses the asm-generic syscalls (asm-generic/unistd.h) with the - following configuration for 64-bit: - * #define __ARCH_WANT_NEW_STAT - * #define __ARCH_WANT_SET_GET_RLIMIT - * #define __ARCH_WANT_SYS_CLONE3 - */ - -#define MAKESTRING(s) #s -#define MAKESTRING2(s) MAKESTRING (rd_a7 ! ## s addi) -#define RISCV_SYSCALL(s) MAKESTRING2 (s) - -// libc-mini -#ifndef SYS_exit -#define SYS_exit 93 -#endif -#ifndef SYS_write -#define SYS_write 64 -#endif - -// libc -#define SYS_clone 220 -#define SYS_read 63 -#define SYS_openat 56 -#define SYS_wait4 260 -#define SYS_execve 221 -#define SYS_fchmodat 53 -#define SYS_faccessat 48 -#define SYS_brk 214 -#define SYS_ioctl 29 -#define SYS_fsync 82 -#define SYS_newuname 160 - -// libc+tcc -#define SYS_close 57 -#define SYS_lseek 62 -#define SYS_unlinkat 35 -#define SYS_gettimeofday 169 -#define SYS_getcwd 17 - -// libc+gnu - -#define SYS_chdir 49 -#define SYS_linkat 37 -#define SYS_getpid 172 -#define SYS_getuid 174 -#define SYS_kill 129 -#define SYS_renameat2 276 -#define SYS_mkdirat 34 -#define SYS_dup 23 -#define SYS_pipe2 59 -#define SYS_getgid 176 -#define SYS_rt_sigaction 134 -#define SYS_fcntl 25 -#define SYS_dup3 24 -#define SYS_getrusage 165 -#define SYS_newfstatat 79 -#define SYS_setitimer 103 -#define SYS_fstat 80 -#define SYS_nanosleep 101 -#define SYS_getdents64 61 -#define SYS_clock_gettime 113 - -// bash -#define SYS_setuid 146 -#define SYS_geteuid 175 -#define SYS_getegid 177 -#define SYS_setgid 144 -#define SYS_getppid 173 - -// make+POSIX -#define SYS_rt_sigprocmask 135 - -// tar -#define SYS_symlinkat 36 -#define SYS_readlinkat 78 -#define SYS_mknodat 33 - -/* gash */ -#define SYS_umask 166 -#define SYS_utimensat 88 - -#endif // __MES_LINUX_RISCV_SYSCALL_H diff --git a/vendor/mes-libc/include/linux/syscall.h b/vendor/mes-libc/include/linux/syscall.h @@ -1,33 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2021 W. J. van der Laan <laanwj@protonmail.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_SYSCALL_H -#define __MES_SYSCALL_H - -long _sys_call (long sys_call); -long _sys_call1 (long sys_call, long one); -long _sys_call2 (long sys_call, long one, long two); -long _sys_call3 (long sys_call, long one, long two, long three); -long _sys_call4 (long sys_call, long one, long two, long three, long four); -long _sys_call5 (long sys_call, long one, long two, long three, long four, long five); -long _sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six); - -#endif //__MES_SYSCALL_H diff --git a/vendor/mes-libc/include/linux/x86/kernel-stat.h b/vendor/mes-libc/include/linux/x86/kernel-stat.h @@ -1,79 +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_LINUX_X86_KERNEL_STAT_H -#define __MES_LINUX_X86_KERNEL_STAT_H 1 - -// https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/stat.h - -#include <arch/syscall.h> - -#if __SIZEOF_LONG_LONG__ != 8 - -// *INDENT-OFF* -struct stat -{ - unsigned long st_dev; - unsigned long st_ino; - unsigned short st_mode; - unsigned short st_nlink; - unsigned short st_uid; - unsigned short st_gid; - unsigned long st_rdev; - unsigned long st_size; - unsigned long st_blksize; - unsigned long st_blocks; - unsigned long st_atime; - unsigned long st_atime_usec; - unsigned long st_mtime; - unsigned long st_mtime_usec; - unsigned long st_ctime; - unsigned long st_ctime_usec; - unsigned long __pad0; - unsigned long __pad1; -}; - -#else // __SIZEOF_LONG_LONG__ == 8 - -struct stat -{ - unsigned long long st_dev; - unsigned char __pad0[4]; - unsigned long __st_ino; - unsigned int st_mode; - unsigned int st_nlink; - unsigned long st_uid; - unsigned long st_gid; - unsigned long long st_rdev; - unsigned char __pad3[4]; - long long st_size; - unsigned long st_blksize; - unsigned long long st_blocks; - unsigned long st_atime; - unsigned long st_atime_nsec; - unsigned long st_mtime; - unsigned int st_mtime_nsec; - unsigned long st_ctime; - unsigned long st_ctime_nsec; - unsigned long long st_ino; -}; - -#endif // __SIZEOF_LONG_LONG__ == 8 - -#endif // __MES_LINUX_X86_KERNEL_STAT_H diff --git a/vendor/mes-libc/include/linux/x86/signal.h b/vendor/mes-libc/include/linux/x86/signal.h @@ -1,90 +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/>. - */ -#define EBX 0 -#define ECX 1 -#define EDX 2 -#define ESI 3 -#define EDI 4 -#define EBP 5 -#define EAX 6 -#define DS 7 -#define ES 8 -#define FS 9 -#define GS 10 -#define ORIG_EAX 11 -#define EIP 12 -#define CS 13 -#define EFL 14 -#define UESP 15 -#define SS 16 -#define FRAME_SIZE 17 - -/* Type for general register. */ -typedef int greg_t; - -/* Number of general registers. */ -#define NGREG 19 - -/* Container for all general registers. */ -typedef greg_t gregset_t[NGREG]; - -/* Definitions taken from the kernel headers. */ -struct _libc_fpreg -{ - unsigned short int significand[4]; - unsigned short int exponent; -}; - -struct _libc_fpstate -{ - unsigned long int cw; - unsigned long int sw; - unsigned long int tag; - unsigned long int ipoff; - unsigned long int cssel; - unsigned long int dataoff; - unsigned long int datasel; - struct _libc_fpreg _st[8]; - unsigned long int status; -}; - -/* Structure to describe FPU registers. */ -typedef struct _libc_fpstate *fpregset_t; - -typedef struct -{ - gregset_t gregs; - /* Due to Linux's history we have to use a pointer here. The SysV/i386 - ABI requires a struct with the values. */ - fpregset_t fpregs; - unsigned long int oldmask; - unsigned long int cr2; -} mcontext_t; - -/* Userlevel context. */ -typedef struct ucontext -{ - unsigned long int uc_flags; - struct ucontext *uc_link; - stack_t uc_stack; - mcontext_t uc_mcontext; - sigset_t uc_sigmask; - struct _libc_fpstate __fpregs_mem; -} ucontext_t; diff --git a/vendor/mes-libc/include/linux/x86/syscall.h b/vendor/mes-libc/include/linux/x86/syscall.h @@ -1,124 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2022,2024 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/>. - */ -/* Commentary: - * See https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_32.tbl - * https://github.com/torvalds/linux/raw/v4.19/arch/x86/entry/syscalls/syscall_32.tbl - * - * Code: - */ -#ifndef __MES_LINUX_X86_SYSCALL_H -#define __MES_LINUX_X86_SYSCALL_H 1 - -/* libc-mini */ -#ifndef SYS_exit -#define SYS_exit 0x01 -#endif -#ifndef SYS_write -#define SYS_write 0x04 -#endif - -/* libc */ -#define SYS_fork 0x02 -#define SYS_read 0x03 -#define SYS_open 0x05 -#define SYS_waitpid 0x07 -#define SYS_wait4 0x72 -#define SYS_execve 0x0b -#define SYS_chmod 0x0f -#define SYS_access 0x21 -#define SYS_brk 0x2d -#define SYS_ioctl 0x36 -#define SYS_fsync 0x76 -#define SYS_getcwd 0xb7 -#define SYS_dup 0x29 -#define SYS_dup2 0x3f -#define SYS_unlink 0x0a -#define SYS_gettimeofday 0x4e -#define SYS_clock_gettime 0x109 -#define SYS_time 0x0d -#define SYS_newuname 0x7a - -/* libc+tcc */ -#define SYS_close 0x06 -#define SYS_lseek 0x13 -#define SYS_rmdir 0x28 -#define SYS_stat 0x6a - -/* libc+gnu */ -#define SYS_chdir 0x0c -#define SYS_link 0x09 -#define SYS_getpid 0x14 -#define SYS_getuid 0x18 -#define SYS_kill 0x25 -#define SYS_rename 0x26 -#define SYS_mkdir 0x27 -#define SYS_pipe 0x2a -#define SYS_getgid 0x2f -#define SYS_signal 0x30 -#define SYS_sigaction 0x43 -#define SYS_rt_sigaction 0xae -#define SYS_signal 0x30 -#define SYS_fcntl 0x37 -#define SYS_getrusage 0x4d -#define SYS_lstat 0x6b -#define SYS_setitimer 0x68 -#define SYS_fstat 0x6c -#define SYS_nanosleep 0xa2 -#define SYS_getdents 0x8d - -/* bash */ -#define SYS_setuid 0x17 -#define SYS_geteuid 0x31 -#define SYS_getegid 0x32 -#define SYS_setgid 0x3e -#define SYS_getppid 0x40 - -/* make+POSIX */ -#define SYS_sigprocmask 0x7e - -/* tar */ -#define SYS_symlink 0x53 -#define SYS_readlink 0x55 -#define SYS_mknod 0x0e - -/* gash */ -#define SYS_umask 0x3c -#define SYS_utimensat 0x140 - -#if __SIZEOF_LONG_LONG__ == 8 - -#define SYS_stat64 0xc3 -#define SYS_lstat64 0xc4 -#define SYS_fstat64 0xc5 -#define SYS_fcntl64 0xdd -#define SYS_getdents64 0xdc - -#undef SYS_stat -#define SYS_stat SYS_stat64 - -#undef SYS_lstat -#define SYS_lstat SYS_lstat64 - -#undef SYS_fstat -#define SYS_fstat SYS_fstat64 - -#endif // __SIZEOF_LONG_LONG__ == 8 - -#endif /* __MES_LINUX_X86_SYSCALL_H */ diff --git a/vendor/mes-libc/include/linux/x86_64/kernel-stat.h b/vendor/mes-libc/include/linux/x86_64/kernel-stat.h @@ -1,51 +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_LINUX_X86_64_KERNEL_STAT_H -#define __MES_LINUX_X86_64_KERNEL_STAT_H 1 - -// https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/stat.h - -// *INDENT-OFF* -struct stat -{ - unsigned long st_dev; - unsigned long st_ino; - unsigned long st_nlink; - unsigned int st_mode; - unsigned int st_uid; - unsigned int st_gid; - unsigned int __pad0; - unsigned long st_rdev; - long st_size; - long st_blksize; - long st_blocks; - unsigned long st_atime; - unsigned long st_atime_nsec; - unsigned long st_mtime; - unsigned long st_mtime_nsec; - unsigned long st_ctime; - unsigned long st_ctime_nsec; - unsigned long __pad1; - unsigned long __pad2; - unsigned long __pad3; - unsigned long __pad4; -}; - -#endif // __MES_LINUX_X86_64_KERNEL_STAT_H diff --git a/vendor/mes-libc/include/linux/x86_64/signal.h b/vendor/mes-libc/include/linux/x86_64/signal.h @@ -1,102 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * 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/>. - */ - -// Taken from musl libc (4a16ddf5) and simplified - -#define REG_R8 0 -#define REG_R9 1 -#define REG_R10 2 -#define REG_R11 3 -#define REG_R12 4 -#define REG_R13 5 -#define REG_R14 6 -#define REG_R15 7 -#define REG_RDI 8 -#define REG_RSI 9 -#define REG_RBP 10 -#define REG_RBX 11 -#define REG_RDX 12 -#define REG_RAX 13 -#define REG_RCX 14 -#define REG_RSP 15 -#define REG_RIP 16 -#define REG_EFL 17 -#define REG_CSGSFS 18 -#define REG_ERR 19 -#define REG_TRAPNO 20 -#define REG_OLDMASK 21 -#define REG_CR2 22 - -typedef long long greg_t; -typedef long long gregset_t[23]; - -struct __st -{ - unsigned short significand[4], exponent, padding[3]; -}; - -struct _xmm -{ - unsigned element[4]; -}; - -typedef struct _fpstate -{ - unsigned short cwd, swd, ftw, fop; - unsigned long long rip, rdp; - unsigned mxcsr, mxcr_mask; - struct __st _st[8]; - struct _xmm _xmm[16]; - unsigned padding[24]; -} *fpregset_t; - -struct sigcontext -{ - unsigned long r8, r9, r10, r11, r12, r13, r14, r15; - unsigned long rdi, rsi, rbp, rbx, rdx, rax, rcx, rsp, rip, eflags; - unsigned short cs, gs, fs, __pad0; - unsigned long err, trapno, oldmask, cr2; - struct _fpstate *fpstate; - unsigned long __reserved1[8]; -}; - -typedef struct -{ - gregset_t gregs; - fpregset_t fpregs; - unsigned long long __reserved1[8]; -} mcontext_t; - -struct sigaltstack -{ - void *ss_sp; - int ss_flags; - size_t ss_size; -}; - -typedef struct __ucontext -{ - unsigned long uc_flags; - struct __ucontext *uc_link; - stack_t uc_stack; - mcontext_t uc_mcontext; - sigset_t uc_sigmask; - unsigned long __fpregs_mem[64]; -} ucontext_t; diff --git a/vendor/mes-libc/include/linux/x86_64/syscall.h b/vendor/mes-libc/include/linux/x86_64/syscall.h @@ -1,104 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2024 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/>. - */ -/* Commentary: - * See https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_64.tbl - * https://github.com/torvalds/linux/raw/v4.19/arch/x86/entry/syscalls/syscall_64.tbl - * - * Code: - */ -#ifndef __MES_LINUX_X86_64_SYSCALL_H -#define __MES_LINUX_X86_64_SYSCALL_H 1 - -// libc-mini -#ifndef SYS_write -#define SYS_write 0x01 -#endif -#ifndef SYS_exit -#define SYS_exit 0x3c -#endif - -// libc -#define SYS_fork 0x39 -#define SYS_read 0x00 -#define SYS_open 0x02 -//#define SYS_waitpid -#define SYS_wait4 0x3d -#define SYS_execve 0x3b -#define SYS_chmod 0x5a -#define SYS_access 0x15 -#define SYS_brk 0x0c -#define SYS_ioctl 0x10 -#define SYS_fsync 0x4a -#define SYS_getcwd 0x4f -#define SYS_dup 0x20 -#define SYS_dup2 0x21 -#define SYS_unlink 0x57 -#define SYS_gettimeofday 0x60 -#define SYS_clock_gettime 0xe4 -#define SYS_time 0xc9 -#define SYS_newuname 0x3f - -// libc+tcc -#define SYS_close 0x03 -#define SYS_lseek 0x08 -#define SYS_rmdir 0x54 -#define SYS_stat 0x04 - -// libc+gnu -#define SYS_chdir 0x50 -#define SYS_link 0x56 -#define SYS_getpid 0x27 -#define SYS_getuid 0x66 -#define SYS_kill 0x3e -#define SYS_rename 0x52 -#define SYS_mkdir 0x53 -#define SYS_pipe 0x16 -#define SYS_getgid 0x68 -#define SYS_rt_sigaction 0x0d -#define SYS_rt_sigreturn 0x0f -#define SYS_fcntl 0x48 -#define SYS_getrusage 0x62 -#define SYS_lstat 0x06 -#define SYS_setitimer 0x26 -#define SYS_fstat 0x05 -#define SYS_nanosleep 0x33 -#define SYS_getdents64 0xd9 - -// bash -#define SYS_setuid 0x69 -#define SYS_setgid 0x6a -#define SYS_geteuid 0x6b -#define SYS_getegid 0x6c -#define SYS_getppid 0x6e - -// make+SYSTEM_LIBC -#define SYS_rt_sigprocmask 0x0e - -// tar -#define SYS_symlink 0x58 -#define SYS_readlink 0x59 -#define SYS_mknod 0x85 - -/* gash */ -#define SYS_umask 0x5f -#define SYS_utimensat 0x118 - -#endif // __MES_LINUX_X86_64_SYSCALL_H diff --git a/vendor/mes-libc/include/locale.h b/vendor/mes-libc/include/locale.h @@ -1,45 +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_LOCALE_H -#define __MES_LOCALE_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_LOCALE_H -#include_next <locale.h> - -#else // ! SYSTEM_LIBC - -// *INDENT-OFF* -#ifndef LC_ALL -#define LC_CTYPE 0 -#define LC_NUMERIC 1 -#define LC_COLLATE 3 -#define LC_ALL 6 -#endif -// *INDENT-ON* - -char *setlocale (int category, char const *locale); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_LOCALE_H diff --git a/vendor/mes-libc/include/m2/types.h b/vendor/mes-libc/include/m2/types.h @@ -1,145 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2022,2023 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 __M2_TYPES_H -#define __M2_TYPES_H 1 - -// FIXME M2_Planet chokes on -1, even inside #if ! __M2__ -#if __arm__ || __i386__ -#define EOF 0xffffffff -#else -#define EOF 0xffffffffffffffff -#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 -typedef unsigned ino_t; -#endif - -#if __SIZEOF_LONG_LONG__ == 8 -#ifndef __MES_INO64_T -#define __MES_INO64_T -#undef ino64_t -typedef unsigned ino64_t; -#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 -typedef unsigned uintptr_t; -#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 -typedef unsigned off64_t; -#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 -typedef unsigned size_t; -#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 // __M2_TYPES_H diff --git a/vendor/mes-libc/include/mach/mach-init.h b/vendor/mes-libc/include/mach/mach-init.h @@ -1,50 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 1993-2016 Free Software Foundation, Inc. - * Copyright © 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/>. - */ - -/** Commentary: - Taken from GNU C Library - Declarations and macros for the basic Mach things set at startup. - */ - -#ifndef _MACH_INIT_H - -#define _MACH_INIT_H 1 - -#include <mach/mach_types.h> - -/* Return the current task's task port. */ -extern mach_port_t mach_task_self (void); -extern mach_port_t mach_host_self (void); - -/* Kernel page size. */ -extern vm_size_t __vm_page_size; -extern vm_size_t vm_page_size; - -/* Round the address X up to a page boundary. */ -#define round_page(x) \ - ((((vm_offset_t) (x) + __vm_page_size - 1) / __vm_page_size) * \ - __vm_page_size) - -/* Truncate the address X down to a page boundary. */ -#define trunc_page(x) \ - ((((vm_offset_t) (x)) / __vm_page_size) * __vm_page_size) - -#endif /* mach_init.h */ diff --git a/vendor/mes-libc/include/memory.h b/vendor/mes-libc/include/memory.h @@ -1,36 +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_MEMORY_H -#define __MES_MEMORY_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_MEMORY_H -#include_next <memory.h> - -#else // ! SYSTEM_LIBC - -#include <string.h> - -#endif // ! SYSTEM_LIBC - -#endif // __MES_MEMORY_H diff --git a/vendor/mes-libc/include/mes/builtins.h b/vendor/mes-libc/include/mes/builtins.h @@ -1,211 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2020,2022,2023 Janneke Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2022,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_BUILTINS_H -#define __MES_BUILTINS_H - -/* src/builtins.c */ -struct scm *make_builtin (struct scm *builtin_type, struct scm *name, struct scm *arity, struct scm *function); -struct scm *builtin_name (struct scm *builtin); -struct scm *builtin_arity (struct scm *builtin); -struct scm *builtin_p (struct scm *x); -struct scm *builtin_printer (struct scm *builtin); -/* src/core.c */ -struct scm *car (struct scm *x); -struct scm *cdr (struct scm *x); -struct scm *list (struct scm *x); -struct scm *null_p (struct scm *x); -struct scm *eq_p (struct scm *x, struct scm *y); -struct scm *values (struct scm *x); -struct scm *acons (struct scm *key, struct scm *value, struct scm *alist); -struct scm *length (struct scm *x); -struct scm *error (struct scm *key, struct scm *x); -struct scm *append2 (struct scm *x, struct scm *y); -struct scm *append_reverse (struct scm *x, struct scm *y); -struct scm *reverse_x_ (struct scm *x, struct scm *t); -struct scm *assq (struct scm *x, struct scm *a); -struct scm *assoc (struct scm *x, struct scm *a); -/* src/display.c */ -struct scm *display_ (struct scm *x); -struct scm *display_error_ (struct scm *x); -struct scm *display_port_ (struct scm *x, struct scm *p); -struct scm *write_ (struct scm *x); -struct scm *write_error_ (struct scm *x); -struct scm *write_port_ (struct scm *x, struct scm *p); -/* src/eval-apply.c */ -struct scm *pairlis (struct scm *x, struct scm *y, struct scm *a); -struct scm *set_car_x (struct scm *x, struct scm *e); -struct scm *set_cdr_x (struct scm *x, struct scm *e); -struct scm *add_formals (struct scm *formals, struct scm *x); -struct scm *eval_apply (); -struct scm *primitive_load (struct scm *filename); -struct scm *make_binding (struct scm *name, struct scm *variable); -/* src/gc.c */ -struct scm *gc_stats (); -struct scm *cons (struct scm *x, struct scm *y); -struct scm *gc_check (); -struct scm *gc (); -/* src/hash.c */ -struct scm *hashq (struct scm *x, struct scm *size); -struct scm *hash (struct scm *x, struct scm *size); -struct scm *hashq_get_handle (struct scm *table, struct scm *key); -struct scm *hashq_ref_ (struct scm *table, struct scm *key, struct scm *dflt); -struct scm *hash_ref_ (struct scm *table, struct scm *key, struct scm *dflt); -struct scm *hashq_create_handle_x (struct scm *table, struct scm *key, struct scm *init); -struct scm *hash_create_handle_x (struct scm *table, struct scm *key, struct scm *init); -struct scm *hashq_set_x (struct scm *table, struct scm *key, struct scm *value); -struct scm *hash_set_x (struct scm *table, struct scm *key, struct scm *value); -struct scm *hash_remove_x (struct scm *table, struct scm *key); -struct scm *hash_table_printer (struct scm *table); -struct scm *make_hash_table (struct scm *x); -struct scm *hash_buckets (struct scm *table); -struct scm *hash_table_p (struct scm *x); -struct scm *hash_clear_x (struct scm *table); -/* src/lib.c */ -struct scm *type_ (struct scm *x); -struct scm *car_ (struct scm *x); -struct scm *cdr_ (struct scm *x); -struct scm *xassq (struct scm *x, struct scm *a); -struct scm *memq (struct scm *x, struct scm *a); -struct scm *equal2_p (struct scm *a, struct scm *b); -struct scm *last_pair (struct scm *x); -struct scm *pair_p (struct scm *x); -struct scm *char_to_integer (struct scm *x); -struct scm *integer_to_char (struct scm *x); -struct scm *make_bytevector (struct scm *args); -struct scm *bytevector_u8_ref (struct scm *bv, struct scm *k); -struct scm *bytevector_u8_set_x (struct scm *bv, struct scm *k, struct scm *value); -/* src/math.c */ -struct scm *greater_p (struct scm *x); -struct scm *less_p (struct scm *x); -struct scm *is_p (struct scm *x); -struct scm *minus (struct scm *x); -struct scm *plus (struct scm *x); -struct scm *divide (struct scm *x); -struct scm *modulo (struct scm *a, struct scm *b); -struct scm *multiply (struct scm *x); -struct scm *logand (struct scm *x); -struct scm *logior (struct scm *x); -struct scm *lognot (struct scm *x); -struct scm *logxor (struct scm *x); -struct scm *ash (struct scm *n, struct scm *count); -/* src/module.c */ -struct scm *initial_module (); -struct scm *current_module (); -struct scm *set_current_module (struct scm *module); -/* src/posix.c */ -struct scm *abort_ (); -struct scm *exit_ (struct scm *x); -struct scm *peek_byte (); -struct scm *read_byte (); -struct scm *unread_byte (struct scm *i); -struct scm *peek_char (); -struct scm *read_char (struct scm *port); -struct scm *unread_char (struct scm *i); -struct scm *write_char (struct scm *i); -struct scm *write_byte (struct scm *x); -struct scm *getenv_ (struct scm *s); -struct scm *setenv_ (struct scm *s, struct scm *v); -struct scm *access_p (struct scm *file_name, struct scm *mode); -struct scm *current_input_port (); -struct scm *open_ (struct scm *file_name, struct scm *flags); -struct scm *open_input_file (struct scm *file_name); -struct scm *open_input_string (struct scm *string); -struct scm *set_current_input_port (struct scm *port); -struct scm *current_output_port (); -struct scm *current_error_port (); -struct scm *open_output_file (struct scm *x); -struct scm *set_current_output_port (struct scm *port); -struct scm *set_current_error_port (struct scm *port); -struct scm *chmod_ (struct scm *file_name, struct scm *mode); -struct scm *isatty_p (struct scm *port); -struct scm *primitive_fork (); -struct scm *primitive_exit (struct scm *status); -struct scm *execl_ (struct scm *file_name, struct scm *args); -struct scm *execle_ (struct scm *file_name, struct scm *args, struct scm *env); -struct scm *waitpid_ (struct scm *pid, struct scm *options); -struct scm *current_time (); -struct scm *gettimeofday_ (); -struct scm *get_internal_run_time (); -struct scm *getcwd_ (); -struct scm *dup_ (struct scm *port); -struct scm *dup2_ (struct scm *old, struct scm *new); -struct scm *delete_file (struct scm *file_name); -struct scm *uname_ (); -/* src/reader.c */ -struct scm *read_input_file_env_ (struct scm *e, struct scm *a); -struct scm *read_input_file_env (struct scm *a); -struct scm *read_env (struct scm *a); -struct scm *reader_read_sexp (struct scm *c, struct scm *s, struct scm *a); -struct scm *reader_read_character (); -struct scm *reader_read_binary (); -struct scm *reader_read_octal (); -struct scm *reader_read_hex (); -struct scm *reader_read_string (); -/* src/stack.c */ -struct scm *frame_printer (struct scm *frame); -struct scm *make_stack (struct scm *stack); -struct scm *stack_length (struct scm *stack); -struct scm *stack_ref (struct scm *stack, struct scm *index); -/* src/string.c */ -struct scm *string_equal_p (struct scm *a, struct scm *b); -struct scm *symbol_to_string (struct scm *symbol); -struct scm *symbol_to_keyword (struct scm *symbol); -struct scm *keyword_to_string (struct scm *keyword); -struct scm *string_to_symbol (struct scm *string); -struct scm *make_symbol (struct scm *string); -struct scm *string_to_list (struct scm *string); -struct scm *list_to_string (struct scm *list); -struct scm *read_string (struct scm *port); -struct scm *string_append (struct scm *x); -struct scm *string_length (struct scm *string); -struct scm *string_ref (struct scm *str, struct scm *k); -struct scm *string_set_x (struct scm *str, struct scm *k, struct scm *c); -/* src/struct.c */ -struct scm *make_struct (struct scm *type, struct scm *fields, struct scm *printer); -struct scm *struct_length (struct scm *x); -struct scm *struct_ref (struct scm *x, struct scm *i); -struct scm *struct_set_x (struct scm *x, struct scm *i, struct scm *e); -/* src/variable.c */ -struct scm *make_variable (struct scm *var); -struct scm *variable_p (struct scm *x); -struct scm *variable_ref (struct scm *var); -struct scm *variable_set_x (struct scm *var, struct scm *value); -struct scm *variable_printer (struct scm *var); -/* src/vector.c */ -struct scm *make_vector (struct scm *x); -struct scm *vector_length (struct scm *x); -struct scm *vector_ref (struct scm *x, struct scm *i); -struct scm *vector_entry (struct scm *x); -struct scm *vector_set_x (struct scm *x, struct scm *i, struct scm *e); -struct scm *list_to_vector (struct scm *x); -struct scm *vector_to_list (struct scm *v); - -/* This is a conditional compilation hack for M2-Planet in bootstrap - mode. The following file will not be included in the M2-Planet build - of Mes, as M2-Planet will ignore the preprocessor directive. Other - builds of Mes will include it. The code in the file relies on system - interfaces supported by MesCC but not M2-Planet. Note that we use - the full include path here, as otherwise NYACC can't find it when - this file is included from elsewhere (possibly a bug). */ -#include "mes/mescc-builtins.h" - -#endif /* __MES_BUILTINS_H */ diff --git a/vendor/mes-libc/include/mes/cc.h b/vendor/mes-libc/include/mes/cc.h @@ -1,42 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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_CC_H -#define __MES_CC_H - -typedef struct scm* SCM; - -#if __MESC__ -typedef long FUNCTION; -typedef long function0_t; -typedef long function1_t; -typedef long function2_t; -typedef long function3_t; -typedef long functionn_t; -#else // !__MESC__ -typedef SCM (*FUNCTION) (void); -typedef SCM (*function0_t) (void); -typedef SCM (*function1_t) (SCM); -typedef SCM (*function2_t) (SCM, SCM); -typedef SCM (*function3_t) (SCM, SCM, SCM); -typedef SCM (*functionn_t) (SCM); -#endif // !__MESC__ - -#endif //__MES_CC_H diff --git a/vendor/mes-libc/include/mes/config.h b/vendor/mes-libc/include/mes/config.h @@ -1,3 +0,0 @@ -/* Empty config.h shim. mes/lib-mini.h includes this when HAVE_CONFIG_H - * is set; live-bootstrap and our boot-build-libc.sh both treat it as - * a stub that exists only to satisfy the include. */ diff --git a/vendor/mes-libc/include/mes/constants.h b/vendor/mes-libc/include/mes/constants.h @@ -1,59 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,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_CONSTANTS_H -#define __MES_CONSTANTS_H - -/* Cell types */ - -#define TCHAR 0 - -#define TBYTES 1 -#define TCLOSURE 2 -#define TCONTINUATION 3 -#define TKEYWORD 4 -#define TMACRO 5 -#define TNUMBER 6 -#define TPAIR 7 -#define TPORT 8 -#define TREF 9 -#define TSPECIAL 10 -#define TSTRING 11 -#define TSTRUCT 12 -#define TSYMBOL 13 -#define TVALUES 14 -#define TBINDING 15 -#define TVECTOR 16 -#define TBROKEN_HEART 17 - -/* Struct types */ - -#define STRUCT_TYPE 0 -#define STRUCT_PRINTER 1 - -#define GC_FRAME_SIZE 5 -#define GC_FRAME_PROCEDURE 4 - -#define MODULE_OBARRAY 3 -#define MODULE_USES 4 -#define MODULE_BINDER 5 -#define MODULE_EVAL_CLOSURE 6 - -#endif /* __MES_CONSTANTS_H */ diff --git a/vendor/mes-libc/include/mes/lib-mini.h b/vendor/mes-libc/include/mes/lib-mini.h @@ -51,7 +51,7 @@ extern int __stdin; extern int __stdout; extern int __stderr; -void __init_io (); +void __init_io (int argc, char **argv, char **envp); int eputs (char const *s); int puts (char const *s); int oputs (char const *s); @@ -109,7 +109,7 @@ extern void (*__call_at_exit) (void); void _exit (int status); void exit (int status); size_t strlen (char const *s); -ssize_t _write (); +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 diff --git a/vendor/mes-libc/include/mes/lib.h b/vendor/mes-libc/include/mes/lib.h @@ -34,8 +34,8 @@ 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 __ungetc_init (); +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); diff --git a/vendor/mes-libc/include/mes/mes.h b/vendor/mes-libc/include/mes/mes.h @@ -1,213 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2022 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_MES_H -#define __MES_MES_H - -#include <sys/types.h> -#include "mes/cc.h" - -struct scm -{ - long type; - union - { - struct scm *car; - long car_value; - char *bytes; - long length; - struct scm *ref; - struct scm *binding; - struct scm *macro; - long port; - }; - union - { - struct scm *cdr; - long cdr_value; - struct scm *closure; - struct scm *continuation; - char *name; - struct scm *string; - struct scm *structure; - long value; - FUNCTION function; - struct scm *vector; - long lexical_p; /* for bindings */ - }; -}; - -/* M2-Planet does not support pointer arithmetic. Explicitly compensate - for that by multiplying with M2_CELL_SIZE when using cell - pointers. */ -#if __M2__ -#define M2_CELL_SIZE sizeof (struct scm) -#else -#define M2_CELL_SIZE 1 -#endif - -/* mes */ -extern char *g_datadir; -extern int g_debug; -extern char *g_buf; -extern int g_continuations; -extern struct scm *g_symbols; -extern struct scm *g_symbol_max; -extern int g_mini; - -/* a/env */ -extern struct scm *R0; -/* param 1 */ -extern struct scm *R1; -/* save 2 */ -extern struct scm *R2; -/* continuation */ -extern struct scm *R3; -/* initial module obarray */ -extern struct scm *M0; -/* current module */ -extern struct scm *M1; -/* macro */ -extern struct scm *g_macros; -extern struct scm *g_ports; - -/* gc */ -extern size_t ARENA_SIZE; -extern size_t MAX_ARENA_SIZE; -extern size_t STACK_SIZE; -extern size_t JAM_SIZE; -extern size_t GC_SAFETY; -extern size_t MAX_STRING; -extern char *g_arena; -extern struct scm *cell_arena; -extern struct scm *cell_zero; - -extern struct scm *g_free; -extern struct scm *g_symbol; - -extern struct scm **g_stack_array; -extern struct scm *g_cells; -extern struct scm *g_news; -extern long g_stack; -extern size_t gc_count; -extern struct timespec *gc_start_time; -extern struct timespec *gc_end_time; -extern size_t gc_time; - -extern char **__execl_c_argv; -extern char **__execle_c_env; -extern char *__open_boot_buf; -extern char *__open_boot_file_name; -extern char *__setenv_buf; -extern char *__reader_read_char_buf; -extern struct timespec *g_start_time; -extern struct timeval *__gettimeofday_time; -extern struct timespec *__get_internal_run_time_ts; -extern struct utsname *__uts; - -extern struct scm *scm_hash_table_type; -extern struct scm *scm_variable_type; - -struct scm *cast_charp_to_scmp (char const *i); -struct scm **cast_charp_to_scmpp (char const *i); -char *cast_voidp_to_charp (void const *i); -long cast_scmp_to_long (struct scm *i); -char *cast_scmp_to_charp (struct scm *i); - -struct scm *alloc (long n); -struct scm *apply (struct scm *f, struct scm *x, struct scm *a); -struct scm *apply_builtin (struct scm *fn, struct scm *x); -struct scm *apply_builtin0 (struct scm *fn); -struct scm *apply_builtin1 (struct scm *fn, struct scm *x); -struct scm *apply_builtin2 (struct scm *fn, struct scm *x, struct scm *y); -struct scm *apply_builtin3 (struct scm *fn, struct scm *x, struct scm *y, struct scm *z); -struct scm *builtin_name (struct scm *builtin); -struct scm *cstring_to_list (char const *s); -struct scm *cstring_to_symbol (char const *s); -struct scm *cell_ref (struct scm *cell, long index); -struct scm *current_module_variable (struct scm *name, struct scm *define_p); -struct scm *standard_eval_closure (struct scm *name, struct scm *define_p); -struct scm *standard_interface_eval_closure (struct scm *name, struct scm *define_p); -struct scm *module_make_local_var_x (struct scm *module, struct scm *name); -struct scm *module_variable (struct scm *module, struct scm *name); -struct scm *fdisplay_ (struct scm *, int, int); -struct scm *init_symbols (); -struct scm *init_time (struct scm *a); -struct scm *lookup_binding (struct scm *name, struct scm *define_p); -struct scm *lookup_value (struct scm *name); -struct scm *make_builtin_type (); -struct scm *make_bytes (size_t length); -struct scm *make_cell (long type, struct scm *car, struct scm *cdr); -struct scm *make_pointer_cell (long type, long car, void *cdr); -struct scm *make_value_cell (long type, long car, long cdr); -struct scm *make_char (int n); -struct scm *make_continuation (long n); -struct scm *make_hash_table_ (long size); -struct scm *make_hash_table_type (); -struct scm *make_initial_module (struct scm *a); -struct scm *make_macro (struct scm *name, struct scm *x); -struct scm *make_number (long n); -struct scm *make_ref (struct scm *x); -struct scm *make_string (char const *s, size_t length); -struct scm *make_string0 (char const *s); -struct scm *make_string_port (struct scm *x); -struct scm *make_variable_type (); -struct scm *make_vector_ (long k, struct scm *e); -struct scm *mes_builtins (struct scm *a); -struct scm *push_cc (struct scm *p1, struct scm *p2, struct scm *a, struct scm *c); -struct scm *set_x (struct scm *x, struct scm *e, int define_p); -struct scm *struct_ref_ (struct scm *x, long i); -struct scm *struct_set_x_ (struct scm *x, long i, struct scm *e); -struct scm *vector_ref_ (struct scm *x, long i); -struct scm *vector_set_x_ (struct scm *x, long i, struct scm *e); -FUNCTION builtin_function (struct scm *builtin); -void assert_num (long pos, struct scm *x); -void assert_range (int assert, long x); -void assert_struct (long pos, struct scm *x); -#if 0 -void assert_type (long type, char const *name_name, struct scm *x) -#endif -char *cell_bytes (struct scm *x); -int peekchar (); -int readchar (); -int unreadchar (); -long gc_free (); -long length__ (struct scm *x); -size_t bytes_cells (size_t length); -void assert_max_string (size_t i, char const *msg, char const *string); -void assert_msg (int check, char *msg); -void assert_number (char const *name, struct scm *x); -void copy_cell (struct scm *to, struct scm *from); -void gc_ (); -void gc_dump_arena (struct scm *cells, long size); -void gc_init (); -void gc_peek_frame (); -void gc_pop_frame (); -void gc_push_frame (); -void gc_stats_ (char const* where); -void init_symbols_ (); -long seconds_and_nanoseconds_to_long (long s, long ns); - -#include "mes/builtins.h" -#include "mes/constants.h" -#include "mes/symbols.h" - -#endif /* __MES_MES_H */ diff --git a/vendor/mes-libc/include/mes/mescc-builtins.h b/vendor/mes-libc/include/mes/mescc-builtins.h @@ -1,40 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2022,2023 Timothy Sample <samplet@ngyro.com> - * Copyright © 2023 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/>. - */ - -struct scm *getpid_ (); -struct scm *environ_ (struct scm *args); -struct scm *opendir_ (struct scm *args); -struct scm *closedir_ (struct scm *args); -struct scm *readdir_ (struct scm *args); -struct scm *pipe_ (); -struct scm *close_port (struct scm *port); -struct scm *seek (struct scm *port, struct scm *offset, struct scm *whence); -struct scm *chdir_ (struct scm *file_name); -struct scm *stat_ (struct scm *args); -struct scm *lstat_ (struct scm *args); -struct scm *rename_file (struct scm *old_name, struct scm *new_name); -struct scm *mkdir_ (struct scm *file_name); -struct scm *rmdir_ (struct scm *file_name); -struct scm *link_ (struct scm *old_name, struct scm *new_name); -struct scm *symlink_ (struct scm *old_name, struct scm *new_name); -struct scm *umask_ (struct scm *mode); -struct scm *utime_ (struct scm *file_name, struct scm *actime, struct scm *modtime); -struct scm *sleep_ (struct scm *seconds); diff --git a/vendor/mes-libc/include/mes/symbols.h b/vendor/mes-libc/include/mes/symbols.h @@ -1,141 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2021,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_SYMBOLS_H -#define __MES_SYMBOLS_H - -extern struct scm *cell_nil; -extern struct scm *cell_f; -extern struct scm *cell_t; -extern struct scm *cell_dot; -extern struct scm *cell_arrow; -extern struct scm *cell_undefined; -extern struct scm *cell_unspecified; -extern struct scm *cell_closure; -extern struct scm *cell_circular; - -extern struct scm *cell_vm_apply; -extern struct scm *cell_vm_apply2; -extern struct scm *cell_vm_begin; -extern struct scm *cell_vm_begin_eval; -extern struct scm *cell_vm_begin_expand; -extern struct scm *cell_vm_begin_expand_eval; -extern struct scm *cell_vm_begin_expand_macro; -extern struct scm *cell_vm_begin_read_input_file; -extern struct scm *cell_vm_call_with_current_continuation2; -extern struct scm *cell_vm_call_with_values2; -extern struct scm *cell_vm_eval; -extern struct scm *cell_vm_eval2; -extern struct scm *cell_vm_eval_check_func; -extern struct scm *cell_vm_eval_define; -extern struct scm *cell_vm_eval_macro_expand_eval; -extern struct scm *cell_vm_eval_macro_expand_expand; -extern struct scm *cell_vm_eval_set_x; -extern struct scm *cell_vm_evlis; -extern struct scm *cell_vm_evlis2; -extern struct scm *cell_vm_evlis3; -extern struct scm *cell_vm_if; -extern struct scm *cell_vm_if_expr; -extern struct scm *cell_vm_macro_expand; -extern struct scm *cell_vm_macro_expand_car; -extern struct scm *cell_vm_macro_expand_cdr; -extern struct scm *cell_vm_macro_expand_define; -extern struct scm *cell_vm_macro_expand_define_macro; -extern struct scm *cell_vm_macro_expand_lambda; -extern struct scm *cell_vm_macro_expand_set_x; -extern struct scm *cell_vm_return; - -extern struct scm *cell_symbol_lambda; -extern struct scm *cell_symbol_begin; -extern struct scm *cell_symbol_if; -extern struct scm *cell_symbol_quote; -extern struct scm *cell_symbol_define; -extern struct scm *cell_symbol_define_macro; -extern struct scm *cell_symbol_quasiquote; -extern struct scm *cell_symbol_unquote; -extern struct scm *cell_symbol_unquote_splicing; -extern struct scm *cell_symbol_syntax; -extern struct scm *cell_symbol_quasisyntax; -extern struct scm *cell_symbol_unsyntax; -extern struct scm *cell_symbol_unsyntax_splicing; -extern struct scm *cell_symbol_set_x; -extern struct scm *cell_symbol_sc_expand; -extern struct scm *cell_symbol_macro_expand; -extern struct scm *cell_symbol_portable_macro_expand; -extern struct scm *cell_symbol_sc_expander_alist; -extern struct scm *cell_symbol_call_with_values; -extern struct scm *cell_symbol_call_with_current_continuation; -extern struct scm *cell_symbol_current_environment; -extern struct scm *cell_symbol_car; -extern struct scm *cell_symbol_cdr; -extern struct scm *cell_symbol_not_a_number; -extern struct scm *cell_symbol_not_a_pair; -extern struct scm *cell_symbol_system_error; -extern struct scm *cell_symbol_throw; -extern struct scm *cell_symbol_unbound_variable; -extern struct scm *cell_symbol_wrong_number_of_args; -extern struct scm *cell_symbol_wrong_type_arg; -extern struct scm *cell_symbol_buckets; -extern struct scm *cell_symbol_builtin; -extern struct scm *cell_symbol_frame; -extern struct scm *cell_symbol_hashq_table; -extern struct scm *cell_symbol_procedure; -extern struct scm *cell_symbol_record_type; -extern struct scm *cell_symbol_size; -extern struct scm *cell_symbol_stack; -extern struct scm *cell_symbol_argv; -extern struct scm *cell_symbol_mes_datadir; -extern struct scm *cell_symbol_mes_version; -extern struct scm *cell_symbol_internal_time_units_per_second; -extern struct scm *cell_symbol_compiler; -extern struct scm *cell_symbol_arch; -extern struct scm *cell_symbol_variable; -extern struct scm *cell_symbol_standard_eval_closure; -extern struct scm *cell_symbol_standard_interface_eval_closure; -extern struct scm *cell_type_bytes; -extern struct scm *cell_type_char; -extern struct scm *cell_type_closure; -extern struct scm *cell_type_continuation; -extern struct scm *cell_type_function; -extern struct scm *cell_type_keyword; -extern struct scm *cell_type_macro; -extern struct scm *cell_type_number; -extern struct scm *cell_type_pair; -extern struct scm *cell_type_port; -extern struct scm *cell_type_ref; -extern struct scm *cell_type_special; -extern struct scm *cell_type_string; -extern struct scm *cell_type_struct; -extern struct scm *cell_type_symbol; -extern struct scm *cell_type_values; -extern struct scm *cell_type_binding; -extern struct scm *cell_type_vector; -extern struct scm *cell_type_broken_heart; -extern struct scm *cell_symbol_program; -extern struct scm *cell_symbol_test; - -// CONSTANT SYMBOL_MAX 113 -#define SYMBOL_MAX 113 - -#define CELL_UNSPECIFIED 7 - -#define CELL_SYMBOL_RECORD_TYPE 77 - -#endif /* __MES_SYMBOLS_H */ diff --git a/vendor/mes-libc/include/pwd.h b/vendor/mes-libc/include/pwd.h @@ -1,46 +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_PWD_H -#define __MES_PWD_H 1 - -#if SYSTEM_LIBC -#undef __MES_PWD_H -#include_next <pwd.h> -#else // ! SYSTEM_LIBC - -#include <sys/types.h> - -struct passwd -{ - char *pw_name; - char *pw_passwd; - uid_t pw_uid; - gid_t pw_gid; - char *pw_gecos; - char *pw_dir; - char *pw_shell; -}; - -struct passwd *getpwuid (); - - -#endif // ! SYSTEM_LIBC - -#endif // __MES_PWD_H diff --git a/vendor/mes-libc/include/signal.h b/vendor/mes-libc/include/signal.h @@ -1,193 +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_SIGNAL_H -#define __MES_SIGNAL_H 1 - -#if SYSTEM_LIBC -#undef __MES_SIGNAL_H -#include_next <signal.h> -#else //! SYSTEM_LIBC - -#define _NSIG 64 - -#define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long))) - -#if !__M2__ -typedef struct -{ - unsigned long items[_SIGSET_NITEMS]; -} sigset_t; -#endif -typedef long stack_t; - -#include <sys/types.h> - -// *INDENT-OFF* -#define NSIG 30 -#define SIGHUP 1 -#define SIGINT 2 -#define SIGQUIT 3 -#define SIGILL 4 -#define SIGTRAP 5 -#define SIGABRT 6 -#define SIGIOT 6 -#define SIGBUS 7 -#define SIGFPE 8 -#define SIGKILL 9 -#define SIGUSR1 10 -#define SIGSEGV 11 -#define SIGUSR2 12 -#define SIGPIPE 13 -#define SIGALRM 14 -#define SIGTERM 15 -#define SIGSTKFLT 16 -#define SIGCHLD 17 -#define SIGCONT 18 -#define SIGSTOP 19 -#define SIGTSTP 20 -#define SIGTTIN 21 -#define SIGTTOU 22 -#define SIGURG 23 -#define SIGXCPU 24 -#define SIGXFSZ 25 -#define SIGVTALRM 26 -#define SIGPROF 27 -#define SIGWINCH 28 -#define SIGIO 29 -#define SIGPOLL SIGIO - -#define FPE_INTDIV 1 -#define FPE_INTOVF 2 -#define FPE_FLTDIV 3 -#define FPE_FLTOVF 4 -#define FPE_FLTUND 5 -#define FPE_FLTRES 6 -#define FPE_FLTINV 7 -#define FPE_FLTSUB 8 - -#define SA_NOCLDSTOP 0x00000001 -#define SA_NOCLDWAIT 0x00000002 -#define SA_SIGINFO 0x00000004 -#define SA_RESTORER 0x04000000 -#define SA_ONSTACK 0x08000000 -#define SA_RESTART 0x10000000 -#define SA_NODEFER 0x40000000 -#define SA_RESETHAND 0x80000000 - -#define SA_NOMASK SA_NODEFER -#define SA_ONESHOT SA_RESETHAND - -#if !__M2__ // lacks short, casts -typedef struct siginfo_t -{ - int si_signo; - int si_errno; - int si_code; - int si_trapno; - pid_t si_pid; - uid_t si_uid; - int si_status; - clock_t si_utime; - clock_t si_stime; - sigval_t si_value; - int si_int; - void *si_ptr; - int si_overrun; - int si_timerid; - void *si_addr; - long si_band; - int si_fd; - short si_addr_lsb; - void *si_lower; - void *si_upper; - int si_pkey; - void *si_call_addr; - int si_syscall; - unsigned int si_arch; -} siginfo_t; -// *INDENT-ON* - -#if __M2__ || __MESC__ -typedef long sighandler_t; -#else -typedef void (*sighandler_t) (int); -#endif - -#if __i386__ || __x86_64__ -struct sigaction -{ - union - { - sighandler_t sa_handler; - void (*sa_sigaction) (int signum, siginfo_t *, void *); - }; - unsigned long sa_flags; -#if __x86_64__ - long _foo0; -#endif - sigset_t sa_mask; -#if __x86_64__ - long _foo1[15]; -#endif - //unsigned long sa_flags; // x86? - void (*sa_restorer) (void); -}; -#else /* uapi */ -struct sigaction -{ - union - { - sighandler_t sa_handler; - void (*sa_sigaction) (int signum, siginfo_t *, void *); - }; - unsigned long sa_flags; - void (*sa_restorer) (void); - sigset_t sa_mask; -}; -#endif - -#define SIG_DFL ((sighandler_t)0) -#define SIG_IGN ((sighandler_t)1) -#define SIG_ERR ((sighandler_t)-1) - -#include <arch/signal.h> - -int kill (pid_t pid, int signum); -int raise (int); -int sigaction (int signum, struct sigaction const *act, struct sigaction *oldact); -int sigaddset (sigset_t * set, int signum); -#if __MESC__ -void *signal (int signum, void *action); -#else -sighandler_t signal (int signum, sighandler_t action); -#endif -int sigemptyset (sigset_t * set); -#ifndef SIG_BLOCK -#define SIG_BLOCK 0 -#define SIG_UNBLOCK 1 -#define SIG_SETMASK 2 -#endif -int sigprocmask (int how, sigset_t const *set, sigset_t * oldset); - -#endif // !__M2__ - -#endif //! SYSTEM_LIBC - -#endif // __MES_SIGNAL_H diff --git a/vendor/mes-libc/include/stdbool.h b/vendor/mes-libc/include/stdbool.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_STDBOOL_H -#define __MES_STDBOOL_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_STDBOOL_H -#include_next <stdbool.h> - -#else // ! SYSTEM_LIBC -typedef int bool; -#define false 0 -#define true 1 -#endif // ! SYSTEM_LIBC - -#endif // __MES_STDBOOL_H diff --git a/vendor/mes-libc/include/stdnoreturn.h b/vendor/mes-libc/include/stdnoreturn.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_STDNORETURN_H -#define __MES_STDNORETURN_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_STDNORETURN_H -#include_next <stdnoreturn.h> - -#else // ! SYSTEM_LIBC -// whut? -#endif // ! SYSTEM_LIBC - -#endif // __MES_STDNORETURN_H diff --git a/vendor/mes-libc/include/strings.h b/vendor/mes-libc/include/strings.h @@ -1,28 +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_STRINGS_H -#define __MES_STRINGS_H 1 - -#if SYSTEM_LIBC -#undef __MES_STRINGS_H -#include_next <strings.h> -#endif // (SYSTEM_LIBC) - -#endif // __MES_STRINGS_H diff --git a/vendor/mes-libc/include/sys/cdefs.h b/vendor/mes-libc/include/sys/cdefs.h @@ -1,28 +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_CDEFS_H -#define __MES_SYS_CDEFS_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_CDEFS_H -#include_next <sys/cdefs.h> -#endif // (SYSTEM_LIBC) - -#endif // __MES_SYS_CDEFS_H diff --git a/vendor/mes-libc/include/sys/dir.h b/vendor/mes-libc/include/sys/dir.h @@ -1,32 +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_DIR_H -#define __MES_SYS_DIR_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_DIR_H -#include_next <sys/dir.h> - -#else // ! SYSTEM_LIBC - - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_DIR_H diff --git a/vendor/mes-libc/include/sys/file.h b/vendor/mes-libc/include/sys/file.h @@ -1,32 +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_FILE_H -#define __MES_SYS_FILE_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_FILE_H -#include_next <sys/file.h> - -#else // ! SYSTEM_LIBC - - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_FILE_H diff --git a/vendor/mes-libc/include/sys/ioctl.h b/vendor/mes-libc/include/sys/ioctl.h @@ -1,41 +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_IOCTL_H -#define __MES_SYS_IOCTL_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_IOCTL_H -#include_next <sys/ioctl.h> - -#else // ! SYSTEM_LIBC - -#define TCGETS 0x5401 -#define TCGETA 0x5405 -#if __M2__ -int ioctl (int fd, unsigned request, long data); -int ioctl3 (int fd, unsigned request, long data); -#else -int ioctl (int fd, unsigned long request, ...); -int ioctl3 (int fd, unsigned long request, long data); -#endif - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_IOCTL_H diff --git a/vendor/mes-libc/include/sys/param.h b/vendor/mes-libc/include/sys/param.h @@ -1,31 +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_PARAM_H -#define __MES_SYS_PARAM_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_PARAM_H -#include_next <sys/param.h> - -#else // ! SYSTEM_LIBC - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_PARAM_H diff --git a/vendor/mes-libc/include/sys/select.h b/vendor/mes-libc/include/sys/select.h @@ -1,30 +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_SELECT_H -#define __MES_SYS_SELECT_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_SELECT_H -#include_next <sys/select.h> -#else //! SYSTEM_LIBC -typedef int fd_set; -#endif //! SYSTEM_LIBC - -#endif // __MES_SYS_SELECT_H diff --git a/vendor/mes-libc/include/sys/timeb.h b/vendor/mes-libc/include/sys/timeb.h @@ -1,28 +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_TIMEB_H -#define __MES_SYS_TIMEB_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_TIMEB_H -#include_next <sys/timeb.h> -#endif // (SYSTEM_LIBC) - -#endif // __MES_SYS_TIMEB_H diff --git a/vendor/mes-libc/include/sys/times.h b/vendor/mes-libc/include/sys/times.h @@ -1,53 +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_TIMES_H -#define __MES_SYS_TIMES_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_TIMES_H -#include_next <sys/times.h> - -#else // ! SYSTEM_LIBC - -#ifndef __MES_CLOCK_T -#define __MES_CLOCK_T -#undef clock_t -typedef long clock_t; -#endif - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#ifndef HZ -#define HZ 100 -#endif - -struct tms -{ - clock_t tms_utime; - clock_t tms_stime; - clock_t tms_cutime; - clock_t tms_cstime; -}; - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_TIMES_H diff --git a/vendor/mes-libc/include/sys/ucontext.h b/vendor/mes-libc/include/sys/ucontext.h @@ -1,28 +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_UCONTEXT_H -#define __MES_SYS_UCONTEXT_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_UCONTEXT_H -#include_next <sys/ucontext.h> -#endif // (SYSTEM_LIBC) - -#endif // __MES_SYS_UCONTEXT_H diff --git a/vendor/mes-libc/include/sys/user.h b/vendor/mes-libc/include/sys/user.h @@ -1,111 +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_USER_H -#define __MES_SYS_USER_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_USER_H -#include_next <sys/user.h> - -#else // ! SYSTEM_LIBC - -/* These are the 32-bit x86 structures. */ -struct user_fpregs_struct -{ - long int cwd; - long int swd; - long int twd; - long int fip; - long int fcs; - long int foo; - long int fos; - long int st_space[20]; -}; - -struct user_fpxregs_struct -{ - unsigned short int cwd; - unsigned short int swd; - unsigned short int twd; - unsigned short int fop; - long int fip; - long int fcs; - long int foo; - long int fos; - long int mxcsr; - long int reserved; - long int st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ - long int xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */ - long int padding[56]; -}; - -struct user_regs_struct -{ - long int ebx; - long int ecx; - long int edx; - long int esi; - long int edi; - long int ebp; - long int eax; - long int xds; - long int xes; - long int xfs; - long int xgs; - long int orig_eax; - long int eip; - long int xcs; - long int eflags; - long int esp; - long int xss; -}; - -// *INDENT-OFF* -struct user -{ - struct user_regs_struct regs; - int u_fpvalid; - struct user_fpregs_struct i387; - unsigned long int u_tsize; - unsigned long int u_dsize; - unsigned long int u_ssize; - unsigned long int start_code; - unsigned long int start_stack; - long int signal; - int reserved; - struct user_regs_struct *u_ar0; - struct user_fpregs_struct *u_fpstate; - unsigned long int magic; - char u_comm [32]; - int u_debugreg [8]; -}; - -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) -#define NBPG PAGE_SIZE -#define UPAGES 1 -#define HOST_TEXT_START_ADDR (u.start_code) -#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) -// *INDENT-ON* - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_USER_H diff --git a/vendor/mes-libc/include/sys/utsname.h b/vendor/mes-libc/include/sys/utsname.h @@ -1,49 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2023 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_UTSNAME_H -#define __MES_SYS_UTSNAME_H 1 - -#if SYSTEM_LIBC -#undef __MES_SYS_UTSNAME_H -#include_next <sys/utsname.h> - -#else // ! SYSTEM_LIBC - -#define _UTSNAME_LENGTH 65 - -struct utsname -{ - char sysname[_UTSNAME_LENGTH]; - char nodename[_UTSNAME_LENGTH]; - char release[_UTSNAME_LENGTH]; - char version[_UTSNAME_LENGTH]; - char machine[_UTSNAME_LENGTH]; -#ifdef _GNU_SOURCE - char domainname[_UTSNAME_LENGTH]; -#else - char __domainname[_UTSNAME_LENGTH]; -#endif -}; - -int uname (struct utsname *uts); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_UTSNAME_H diff --git a/vendor/mes-libc/include/sys/wait.h b/vendor/mes-libc/include/sys/wait.h @@ -1,45 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019,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_WAIT_H -#define __MES_SYS_WAIT_H 1 - -#include <sys/resource.h> - -#if SYSTEM_LIBC -#undef __MES_SYS_WAIT_H -#include_next <sys/wait.h> -#else // ! SYSTEM_LIBC - -#ifndef __MES_PID_T -#define __MES_PID_T -typedef int pid_t; -#endif - -#define WNOHANG 1 -#define W_EXITCODE(status, signal) ((status) << 8 | (signal)) - -pid_t waitpid (pid_t pid, int *status_ptr, int options); -pid_t wait (int *status_ptr); -pid_t wait4 (pid_t pid, int *wstatus, int options, - struct rusage *rusage); - -#endif // ! SYSTEM_LIBC - -#endif // __MES_SYS_WAIT_H diff --git a/vendor/mes-libc/include/termio.h b/vendor/mes-libc/include/termio.h @@ -1,72 +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_TERMIO_H -#define __MES_TERMIO_H 1 - -#if SYSTEM_LIBC -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif -#undef __MES_TERMIO_H -#include_next <termio.h> - -#else // ! SYSTEM_LIBC - -#define TIOCGWINSZ 0x5413 -#define TCGETA 0x5405 -#define TCSETAW 0x5407 - -#define VTIME 5 -#define VMIN 6 - -#define ISIG 0000001 -#define ICANON 0000002 -#define ECHO 0000010 -#define ECHOK 0000040 -#define ECHONL 0000100 - -#define ISTRIP 0000040 -#define INLCR 0000100 -#define ICRNL 0000400 - -#define CS8 0000060 -#define PARENB 0000400 - -struct winsize -{ - unsigned short ws_row; - unsigned short ws_col; - unsigned short ws_xpixel; - unsigned short ws_ypixel; -}; - -struct termio -{ - unsigned short c_iflag; - unsigned short c_oflag; - unsigned short c_cflag; - unsigned short c_lflag; - unsigned char c_line; - unsigned char c_cc[8]; -}; - -#endif // ! SYSTEM_LIBC - -#endif // __MES_TERMIO_H diff --git a/vendor/mes-libc/libc.c b/vendor/mes-libc/libc.c @@ -0,0 +1,964 @@ +/* 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. + * + * Provides: + * syscalls _read _write _open3 close lseek brk unlink _exit + * raise 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 + * fread fwrite fputs fputc fgetc puts strdup + * fprintf printf snprintf sprintf + * vfprintf vsnprintf vprintf vsprintf + * stdlib malloc free realloc qsort exit atoi + * strtol strtoul strtoull strtof + * string strlen strcmp strcpy strncmp strncpy strchr strrchr + * strstr strcat strdup memmem + * ctype isdigit islower isnumber isspace isxdigit toupper + * assertions __assert_fail + * + * External: memcpy memmove memset memcmp come from libp1pp / cc/mem.c. + * sys_read sys_write sys_open sys_close sys_lseek sys_brk + * sys_unlink sys_exit are P1pp.P1pp labels. + * + * Order constraints: + * 1. The syscall + FILE-globals block has to come first — globals + * (errno, stdin/stdout/stderr, __brk, __FILEDES_MAX-sized arrays) + * are referenced by everything below. + * 2. malloc must precede the file-IO helpers because __read_cache is + * lazy-malloc'd on first read. + * + * License: GPLv3+ (mes upstream); see LICENSE. + */ + +#include <mes/lib.h> +#include <fcntl.h> +#include <errno.h> +#include <stdio.h> +#include <unistd.h> +#include <sys/stat.h> +#include <ctype.h> +#include <string.h> +#include <stdlib.h> +#include <limits.h> +#include <stdarg.h> +#include <stddef.h> +#include <stdint.h> + + +/* ───────── 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. */ +#undef stdin +#undef stdout +#undef stderr +FILE *stdin = (FILE *) 0; +FILE *stdout = (FILE *) 1; +FILE *stderr = (FILE *) 2; + +int errno; +char *__brk = 0; +char **environ; + + +/* ───────── P1pp syscall labels and thin wrappers ─────────────────── */ + +/* forward decl: defined in the stdio block, but _open3/close need it. */ +static size_t read_cache_clear_ (int fd); + +extern long sys_read (long fd, long buf, long n); +extern long sys_write (long fd, long buf, long n); +extern long sys_open (long path, long flags, long mode); +extern long sys_close (long fd); +extern long sys_lseek (long fd, long off, long whence); +extern long sys_brk (long addr); +extern long sys_unlink (long path); +extern long sys_exit (long code); + +ssize_t +_read (int fd, void *buf, size_t n) +{ + return sys_read (fd, (long) buf, (long) n); +} + +ssize_t +_write (int fd, void const *buf, size_t n) +{ + return sys_write (fd, (long) buf, (long) n); +} + +int +_open3 (char const *path, int flags, int mode) +{ + long r = sys_open ((long) path, flags, mode); + if (r >= __FILEDES_MAX) { + errno = EMFILE; + return -1; + } + /* fd numbers are kernel-recycled; if we hand out a fd whose previous + life left bytes in the per-fd read buffer, the next read on the + new file picks them up and tcc_object_type sees a corrupted ELF + header. Mes's _open3 clears the cache for the same reason. */ + if (r > 2) + read_cache_clear_ (r); + return (int) r; +} + +int +close (int fd) +{ + long r = sys_close (fd); + if (r < 0) { + errno = -r; + return -1; + } + errno = 0; + return (int) r; +} + +/* mes's lseek drains a per-fd read buffer before letting the kernel + see the seek; we replicate that in fseek directly (it owns the + buffer state), so this layer is just the raw syscall. */ +off_t +_lseek (int fd, off_t off, int whence) +{ + return sys_lseek (fd, off, whence); +} + +long +brk (void *addr) +{ + return sys_brk ((long) addr); +} + +int +unlink (char const *path) +{ + long r = sys_unlink ((long) path); + if (r < 0) { + errno = -r; + return -1; + } + errno = 0; + return 0; +} + +void +_exit (int status) +{ + sys_exit (status); +} + +/* abort() (mes's version) calls raise(SIGABRT). We don't ship signals + so just exit; tcc's tcc_error path goes here on hard failures. */ +int +raise (int sig) +{ + sys_exit (128 + sig); + return -1; +} + +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. */ + (void) argc; + char **p = argv; + while (*p) + p++; + environ = p + 1; +} + +/* Stubs for libc-internal references not exercised by the tcc-boot2 + golden path (fread/fopen/etc. include <sys/stat.h>; the closure + we pull in references these). If any surfaces in a real workload, + replace with a P1pp label + thin wrapper. */ +char * +_getcwd (char *buf, size_t size) +{ + (void) buf; (void) size; errno = ENOSYS; return 0; +} + +int +access (char const *path, int mode) +{ + (void) path; (void) mode; errno = ENOSYS; return -1; +} + +int +execve (char const *path, char *const argv[], char *const envp[]) +{ + (void) path; (void) argv; (void) envp; errno = ENOSYS; return -1; +} + +int +fsync (int fd) +{ + (void) fd; return 0; +} + +int +rmdir (char const *path) +{ + (void) path; errno = ENOSYS; return -1; +} + +int +stat (char const *path, struct stat *buf) +{ + (void) path; (void) buf; errno = ENOSYS; return -1; +} + +double +strtod (char const *s, char **tail) +{ + /* tcc.flat.c never reaches strtod under our defines (HAVE_FLOAT off); + stdlib/strtof.c only forwards. cc.scm rejects FP literals, so we + cast a zero int — same numeric value, no `0.0` token. */ + if (tail) + *tail = (char *) s; + return (double) 0; +} + + +/* ───────── ctype ────────────────────────────────────────────────── */ + +int isdigit (int c) { return c >= '0' && c <= '9'; } +int islower (int c) { return c >= 'a' && c <= 'z'; } +int isspace (int c) { return c == ' ' || (c >= '\t' && c <= '\r'); } +int isxdigit (int c) { return isdigit (c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); } +int toupper (int c) { return islower (c) ? c - 'a' + 'A' : c; } + +int +isnumber (int c, int base) +{ + if (base <= 10) + return c >= '0' && c < '0' + base; + return isdigit (c) + || (c >= 'a' && c < 'a' + base - 10) + || (c >= 'A' && c < 'A' + base - 10); +} + + +/* ───────── string ───────────────────────────────────────────────── */ + +size_t +strlen (char const *s) +{ + size_t n = 0; + while (s[n]) + n++; + return n; +} + +int +strcmp (char const *a, char const *b) +{ + while (*a && *a == *b) { a++; b++; } + return *(unsigned char *) a - *(unsigned char *) b; +} + +int +strncmp (char const *a, char const *b, size_t n) +{ + while (n && *a && *a == *b) { a++; b++; n--; } + if (!n) return 0; + return *(unsigned char *) a - *(unsigned char *) b; +} + +char * +strcpy (char *dst, char const *src) +{ + char *r = dst; + while ((*dst++ = *src++)) ; + return r; +} + +char * +strncpy (char *dst, char const *src, size_t n) +{ + char *r = dst; + while (n && (*dst++ = *src++)) n--; + while (n--) *dst++ = 0; + return r; +} + +char * +strcat (char *dst, char const *src) +{ + char *r = dst; + while (*dst) dst++; + while ((*dst++ = *src++)) ; + return r; +} + +char * +strchr (char const *s, int c) +{ + for (; *s; s++) + if (*s == (char) c) + return (char *) s; + return c ? 0 : (char *) s; +} + +char * +strrchr (char const *s, int c) +{ + char const *last = 0; + for (; *s; s++) + if (*s == (char) c) + last = s; + if (!c) return (char *) s; + return (char *) last; +} + +char * +strstr (char const *hay, char const *needle) +{ + size_t n = strlen (needle); + if (!n) return (char *) hay; + for (; *hay; hay++) + if (!strncmp (hay, needle, n)) + return (char *) hay; + return 0; +} + +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 j = 0; + while (j < needlelen && h[i + j] == n[j]) + j++; + if (j == needlelen) + return (char *) h + i; + } + return 0; +} + +char * +strdup (char const *s) +{ + size_t n = strlen (s) + 1; + char *p = malloc (n); + if (p) memcpy (p, s, n); + return p; +} + + +/* ───────── malloc — bump allocator on top of brk ─────────────────── */ + +void * +malloc (size_t size) +{ + if (!__brk) + __brk = (char *) brk (0); + /* 16-byte align — matches the largest scalar (long long / pointer / double). */ + __brk = (char *) (((uintptr_t) __brk + 16 - 1) & -16); + /* 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); + if (brk (__brk + size) < want) + return 0; + char *p = __brk; + __brk += size; + return p; +} + +void +free (void *p) +{ + (void) p; /* bump allocator; reclamation is not implemented. */ +} + +void * +realloc (void *p, size_t size) +{ + void *q = malloc (size); + if (p && q) + memcpy (q, p, size); + return q; +} + + +/* ───────── stdlib: integer parsing and exit ──────────────────────── */ + +/* Internal parser shared by atoi / strtol / strtoul / strtoull and the + width/precision parser inside vformat_. `long long` accumulator so + values that don't fit in 32-bit signed don't sign-extend through the + parse — tcc3 needs this for `-Wl,-Ttext=0x80200000` and the like. */ +static long long +parse_int_ (char const **p, int base) +{ + char const *s = *p; + long long n = 0; + int neg = 0; + if (base == 0) base = 10; + while (isspace (*s)) s++; + if (*s == '+') s++; + else if (*s == '-') { neg = 1; s++; } + while (isnumber (*s, base)) { + int d; + if (*s >= 'a') d = *s - 'a' + 10; + else if (*s >= 'A') d = *s - 'A' + 10; + else d = *s - '0'; + n = n * base + d; + s++; + } + *p = s; + return neg ? -n : n; +} + +int +atoi (char const *s) +{ + return (int) parse_int_ (&s, 10); +} + +long +strtol (char const *s, char **tail, int base) +{ + if (!strncmp (s, "0x", 2)) { s += 2; base = 16; } + char const *p = s; + long r = (long) parse_int_ (&p, base); + if (tail) *tail = (char *) p; + return r; +} + +unsigned long strtoul (char const *s, char **tail, int base) { return strtol (s, tail, base); } +unsigned long long strtoull (char const *s, char **tail, int base) { return strtol (s, tail, base); } +float strtof (char const *s, char **tail) { return strtod (s, tail); } + +void (*__call_at_exit) (void); + +void +exit (int status) +{ + if (__call_at_exit) + __call_at_exit (); + _exit (status); + /* not reached */ + while (1) ; +} + +/* qsort: lifted from mes — straightforward Lomuto-partition recursion. */ +static void +qswap_ (char *a, char *b, size_t size) +{ + do { + char t = *a; + *a++ = *b; + *b++ = t; + } while (--size); +} + +static size_t +qpart_ (char *base, size_t count, size_t size, int (*cmp) (void const *, void const *)) +{ + char *pivot = base + count * size; + size_t i = 0; + for (size_t j = 0; j < count; j++) { + int c = cmp (base + j * size, pivot); + if (c < 0) { + qswap_ (base + i * size, base + j * size, size); + i++; + } else if (c == 0) { + i++; + } + } + if (cmp (pivot, base + i * size) < 0) + qswap_ (base + i * size, pivot, size); + return i; +} + +void +qsort (void *base, size_t count, size_t size, int (*cmp) (void const *, void const *)) +{ + if (count > 1) { + size_t p = qpart_ (base, count - 1, size, cmp); + qsort (base, p, size, cmp); + qsort ((char *) base + p * size, count - p, size, cmp); + } +} + + +/* ───────── getenv ────────────────────────────────────────────────── */ + +char * +getenv (char const *name) +{ + size_t n = strlen (name); + for (char **p = environ; p && *p; p++) { + if (!strncmp (*p, name, n) && (*p)[n] == '=') + return *p + n + 1; + } + return 0; +} + + +/* ───────── stdio: FILE * = (long) fd ─────────────────────────────── */ + +/* Block-buffered read, per fd. Without it, tcc lexing tcc.flat.c does + ~500K single-byte syscalls; with a 128-byte cache it's ~4K. */ +#define READ_BUFFER_MAX 128 + +struct read_buffer { + ssize_t size; + char bytes[READ_BUFFER_MAX]; +}; +static struct read_buffer *read_cache; + +static void +read_cache_init_ (void) +{ + if (!read_cache) + read_cache = malloc (sizeof (struct read_buffer) * __FILEDES_MAX); +} + +/* Returns how many buffered bytes were dropped — fseek/lseek need that + to back out the unconsumed portion. */ +static size_t +read_cache_clear_ (int fd) +{ + read_cache_init_ (); + size_t n = read_cache[fd].size; + read_cache[fd].size = 0; + return n; +} + +static ssize_t +read_buffered_ (int fd, void *buf, size_t size) +{ + read_cache_init_ (); + struct read_buffer *c = &read_cache[fd]; + char *p = buf; + size_t todo = size; + if (!c->size && size > READ_BUFFER_MAX) + return _read (fd, buf, size); + while (c->size > 0 && todo) { + todo--; + *p++ = c->bytes[READ_BUFFER_MAX - c->size--]; + } + if (todo) { + if (todo > READ_BUFFER_MAX) + return size - todo + _read (fd, p, todo); + ssize_t got = _read (fd, c->bytes, READ_BUFFER_MAX); + if (got < 0) return -1; + if (got > 0) { + c->size = got; + if (got < READ_BUFFER_MAX) + memmove (c->bytes + READ_BUFFER_MAX - got, c->bytes, got); + return size - todo + read_buffered_ (fd, p, todo); + } + } + return size - todo; +} + +ssize_t +read (int fd, void *buf, size_t size) +{ + return read_buffered_ (fd, buf, size); +} + +ssize_t +write (int fd, void const *buf, size_t size) +{ + size_t skip = read_cache_clear_ (fd); + if (skip) + sys_lseek (fd, -(long) skip, SEEK_CUR); + ssize_t r = _write (fd, buf, size); + if (r < 0) { + errno = -r; + return -1; + } + errno = 0; + return r; +} + +off_t +lseek (int fd, off_t off, int whence) +{ + size_t skip = read_cache_clear_ (fd); + if (whence == SEEK_CUR) + off -= skip; + return sys_lseek (fd, off, whence); +} + +int +open (char const *path, int flags, ...) +{ + int mode = 0; + if (flags & O_CREAT) { + va_list ap; + va_start (ap, flags); + mode = va_arg (ap, int); + va_end (ap); + } + return _open3 (path, flags, mode); +} + +FILE * +fopen (char const *path, char const *opentype) +{ + int fd; + int mode = 0600; + if ((opentype[0] == 'a' || !strcmp (opentype, "r+")) && !access (path, O_RDONLY)) { + int flags = O_RDWR; + if (opentype[0] == 'a') flags |= O_APPEND; + fd = _open3 (path, flags, mode); + } else if (opentype[0] == 'w' || opentype[0] == 'a' || !strcmp (opentype, "r+")) { + int flags = strchr (opentype, '+') ? O_RDWR | O_CREAT : O_WRONLY | O_CREAT | O_TRUNC; + fd = _open3 (path, flags, mode); + } else { + fd = _open3 (path, O_RDONLY, 0); + } + if (fd < 0) fd = 0; + return (FILE *) (long) fd; +} + +FILE *fdopen (int fd, char const *mode) { (void) mode; return (FILE *) (long) fd; } + +int fclose (FILE * f) { return close ((long) f); } +int fflush (FILE * f) { int fd = (long) f; return fd < 3 ? 0 : fsync (fd); } + +long ftell (FILE * f) { return lseek ((long) f, 0, SEEK_CUR); } + +int +fseek (FILE * f, long off, int whence) +{ + return lseek ((long) f, off, whence) >= 0 ? 0 : -1; +} + +int +fgetc (FILE * f) +{ + unsigned char c; + if (read_buffered_ ((long) f, &c, 1) != 1) + return -1; + return c; +} + +size_t +fread (void *data, size_t size, size_t count, FILE * f) +{ + if (!size || !count) return 0; + ssize_t 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) +{ + if (!size || !count) return 0; + ssize_t put = write ((long) f, data, size * count); + return put > 0 ? put / size : 0; +} + +int +fputc (int c, FILE * f) +{ + unsigned char b = c; + return write ((long) f, &b, 1) == 1 ? c : -1; +} + +int +fputs (char const *s, FILE * f) +{ + size_t n = strlen (s); + return (size_t) write ((long) f, s, n) == n ? (int) n : -1; +} + +int +puts (char const *s) +{ + if (fputs (s, stdout) < 0) return -1; + return fputc ('\n', stdout); +} + +int +remove (char const *path) +{ + return unlink (path); +} + + +/* ───────── printf family ─────────────────────────────────────────── */ + +/* One sink type for both fd-backed (fprintf/printf) and buffer-backed + (snprintf/sprintf) output. emit_() drops bytes once a buffer sink + is full; vsnprintf still has to count them so the C99 return value + (bytes that would have been written) is correct. */ +struct sink { + int fd; /* -1 if buffer sink */ + char *buf; + size_t cap; /* SIZE_MAX for unbounded sprintf */ + size_t len; /* bytes counted (may exceed cap) */ +}; + +static void +emit_ (struct sink *s, char c) +{ + if (s->fd >= 0) { + sys_write (s->fd, (long) &c, 1); + } else if (s->len < s->cap) { + s->buf[s->len] = c; + } + s->len++; +} + +static void +emit_str_ (struct sink *s, char const *p, size_t n) +{ + while (n--) emit_ (s, *p++); +} + +/* unsigned 64-bit → ASCII into `out` (at least 24 bytes). Returns + pointer to first character; signed prefix is added by caller. */ +static char * +utoa_ (unsigned long long u, unsigned base, char *out) +{ + char *p = out + 23; + *p = 0; + do { + unsigned d = u % base; + u /= base; + *--p = d > 9 ? 'a' + d - 10 : '0' + d; + } while (u); + return p; +} + +static int +vformat_ (struct sink *s, char const *fmt, va_list ap) +{ + size_t start = s->len; + while (*fmt) { + if (*fmt != '%') { emit_ (s, *fmt++); continue; } + fmt++; + + int left = 0, long_p = 0, precision = -1, width = -1; + char pad = ' '; + + if (*fmt == '-') { left = 1; fmt++; } + if (*fmt == ' ') { pad = ' '; fmt++; } + if (*fmt == '0') { pad = '0'; fmt++; } + if (*fmt >= '0' && *fmt <= '9') { + width = (int) parse_int_ (&fmt, 10); + } else if (*fmt == '*') { + width = va_arg (ap, int); + fmt++; + } + if (*fmt == '.') { + fmt++; + if (*fmt >= '0' && *fmt <= '9') { + precision = (int) parse_int_ (&fmt, 10); + } else if (*fmt == '*') { + precision = va_arg (ap, int); + fmt++; + } + } + /* `l` length modifier; LP64 → ll == l, so collapse. Tracking it + matters: amd64 SysV spills an `int` arg into the low 32 bits of + an 8-byte slot, leaving the upper bits unspecified. va_arg(long) + on a `%d` would then leak garbage. */ + 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; + + switch (c) { + case '%': emit_ (s, '%'); break; + case 'c': emit_ (s, (char) va_arg (ap, int)); break; + + case 's': { + body = va_arg (ap, char const *); + if (!body) body = "(null)"; + bodylen = strlen (body); + if (precision >= 0 && (size_t) precision < bodylen) + bodylen = precision; + goto pad_emit; + } + + case 'd': case 'i': { + long long v = long_p ? va_arg (ap, long long) : (long long) va_arg (ap, int); + unsigned long long u = v < 0 ? -(unsigned long long) v : (unsigned long long) v; + if (v < 0) sign = '-'; + body = utoa_ (u, 10, nbuf); + bodylen = strlen (body); + goto numeric_emit; + } + + case 'u': case 'o': case 'x': case 'X': case 'p': { + unsigned long long u; + unsigned base = c == 'o' ? 8 : (c == 'x' || c == 'X' || c == 'p') ? 16 : 10; + if (c == 'p') { + u = (unsigned long long) (uintptr_t) va_arg (ap, void *); + long_p = 1; + } else if (long_p) { + u = (unsigned long long) va_arg (ap, unsigned long long); + } else { + u = (unsigned long long) va_arg (ap, unsigned int); + } + body = utoa_ (u, base, nbuf); + bodylen = strlen (body); + if (c == 'X') { + for (char *t = (char *) body; *t; t++) + *t = toupper (*t); + } + goto numeric_emit; + } + + default: + /* Unsupported specifier — emit %X for diagnostics. tcc's only + use of an exotic specifier is %p in an unreachable error + path. */ + emit_ (s, '%'); + emit_ (s, c); + break; + } + fmt++; + continue; + + numeric_emit: { + int total = (sign ? 1 : 0) + (int) bodylen; + 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; + if (!left && pad == ' ') { + while (npad-- > 0) emit_ (s, ' '); + } + if (sign) emit_ (s, sign); + if (!left && pad == '0') { + while (npad-- > 0) emit_ (s, '0'); + } + while (zpad-- > 0) emit_ (s, '0'); + emit_str_ (s, body, bodylen); + while (left && npad-- > 0) emit_ (s, ' '); + fmt++; + continue; + } + + pad_emit: { + int npad = width > (int) bodylen ? width - (int) bodylen : 0; + if (!left) while (npad-- > 0) emit_ (s, pad); + emit_str_ (s, body, bodylen); + if (left) while (npad-- > 0) emit_ (s, pad); + fmt++; + continue; + } + } + if (s->fd < 0 && s->len < s->cap) + s->buf[s->len] = 0; + else if (s->fd < 0 && s->cap) + s->buf[s->cap - 1] = 0; + return (int) (s->len - start); +} + +int +vfprintf (FILE * f, char const *fmt, va_list ap) +{ + struct sink s = { .fd = (int) (long) f, .buf = 0, .cap = 0, .len = 0 }; + return vformat_ (&s, fmt, ap); +} + +int +vprintf (char const *fmt, va_list ap) +{ + return vfprintf (stdout, fmt, ap); +} + +int +vsnprintf (char *str, size_t size, char const *fmt, va_list ap) +{ + struct sink s = { .fd = -1, .buf = str, .cap = size, .len = 0 }; + return vformat_ (&s, fmt, ap); +} + +int +vsprintf (char *str, char const *fmt, va_list ap) +{ + return vsnprintf (str, (size_t) -1, fmt, ap); +} + +int +fprintf (FILE * f, char const *fmt, ...) +{ + va_list ap; va_start (ap, fmt); + int r = vfprintf (f, fmt, ap); + va_end (ap); + return r; +} + +int +printf (char const *fmt, ...) +{ + va_list ap; va_start (ap, fmt); + int r = vfprintf (stdout, fmt, ap); + va_end (ap); + return r; +} + +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_end (ap); + return r; +} + +int +sprintf (char *str, char const *fmt, ...) +{ + va_list ap; va_start (ap, fmt); + int r = vsprintf (str, fmt, ap); + va_end (ap); + return r; +} + + +/* ───────── assertions ────────────────────────────────────────────── */ + +void +__assert_fail (char const *msg, char const *file, unsigned line, char const *func) +{ + fprintf (stderr, "%s:%u:", file, line); + if (func) fprintf (stderr, "%s:", func); + fprintf (stderr, "assert fail: %s\n", msg); + exit (1); +} + +/* mes/lib.h declares assert_msg as the no-include-needed assert form + used inside libc. Provide a body here so anything still calling it + (e.g. mes-style builtins under cc.scm) links. */ +void +assert_msg (int check, char *msg) +{ + if (!check) { + fputs (msg, stderr); + exit (1); + } +} diff --git a/vendor/mes-libc/linux/malloc.c b/vendor/mes-libc/linux/malloc.c @@ -1,44 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2021,2022 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/>. - */ - -#include <mes/lib.h> -#include <string.h> -#include <stddef.h> -#include <stdint.h> - -char *__brk = 0; - -void * -malloc (size_t size) -{ - if (!__brk) - __brk = cast_long_to_charp (brk (0)); -#if !__M2__ - /* align what we give back. */ - __brk = (char*) (((uintptr_t) __brk - + sizeof (max_align_t) - 1) & -sizeof (max_align_t)); -#endif - if (brk (__brk + size) == -1) - return 0; - char *p = __brk; - __brk = __brk + size; - return p; -} diff --git a/vendor/mes-libc/mes/__assert_fail.c b/vendor/mes-libc/mes/__assert_fail.c @@ -1,48 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,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/>. - */ - -#include <mes/lib.h> -#include <assert.h> - -void -__assert_fail (char const *msg, char const *file, unsigned line, - char const *function) -{ - if (file && *file) - { - eputs (file); - eputs (":"); - } - if (line) - { - eputs (itoa (line)); - eputs (":"); - } - if (function && *function) - { - eputs (function); - eputs (":"); - } - eputs ("assert fail: "); - eputs (msg); - eputs ("\n"); - char *fail = 0; - fail[0] = 0; -} diff --git a/vendor/mes-libc/mes/__buffered_read.c b/vendor/mes-libc/mes/__buffered_read.c @@ -1,109 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib.h> -#include <stdlib.h> -#include <string.h> - -#if !__MESC__ -#define __READ_BUFFER_MAX 128 -int __read_buffer_max; -#else /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */ -#define __READ_BUFFER_MAX 100 -#define __read_buffer_max 100 -#endif - -struct __read_buffer -{ - ssize_t size; - char string[__READ_BUFFER_MAX]; -}; - -struct __read_buffer *__read_cache = 0; - -void -__buffered_read_init (int filedes) -{ - if (!__read_cache) - { - __read_cache = (struct __read_buffer *) malloc (sizeof (struct __read_buffer) * __FILEDES_MAX); -#if !__MESC__ - __read_buffer_max = __READ_BUFFER_MAX; - char *p = getenv ("MES_READ_BUFFER"); - if (p) - { - __read_buffer_max = atoi (p); - if (__read_buffer_max < 0) - __read_buffer_max = 0; - if (__read_buffer_max > __READ_BUFFER_MAX) - __read_buffer_max = __READ_BUFFER_MAX; - } -#endif - } -} - -size_t -__buffered_read_clear (int filedes) -{ - __buffered_read_init (filedes); - size_t size = __read_cache[filedes].size; - __read_cache[filedes].size = 0; - return size; -} - -ssize_t -__buffered_read (int filedes, void *buffer, size_t size) -{ - size_t todo = size; - __buffered_read_init (filedes); - struct __read_buffer *cache = &__read_cache[filedes]; - char *p = buffer; - if (!cache->size && size > __read_buffer_max) - return _read (filedes, buffer, size); - while (cache->size > 0 && todo) - { - todo--; - *p++ = cache->string[__read_buffer_max - cache->size--]; - } - if (todo) - { -#if !__MESC__ - if (todo > __read_buffer_max) - return size - todo + _read (filedes, p, todo); - if (__mes_debug () > 4) - { - eputs ("__buffered_read: "); - eputs (itoa (__read_buffer_max)); - eputs ("\n"); - } -#endif - ssize_t bytes = _read (filedes, cache->string, __read_buffer_max); - if (bytes < 0) - return -1; - if (bytes) - { - cache->size = bytes; - if (bytes < __read_buffer_max) - memmove (cache->string + __read_buffer_max - bytes, cache->string, bytes); - return size - todo + __buffered_read (filedes, p, todo); - } - } - return size - todo; -} diff --git a/vendor/mes-libc/mes/__init_io.c b/vendor/mes-libc/mes/__init_io.c @@ -1,30 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2023 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/>. - */ - -#include "mes/lib-mini.h" - -void -__init_io (int argc, char** argv, char** envp) -{ - __stdin = 0; - __stdout = 1; - __stderr = 2; - environ = envp; -} diff --git a/vendor/mes-libc/mes/__mes_debug.c b/vendor/mes-libc/mes/__mes_debug.c @@ -1,36 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include "mes/lib.h" -#include <stdlib.h> - -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -int -__mes_debug () -{ - static int __mes_debug = -1; - if (__mes_debug == -1) - { - char *p = getenv ("MES_DEBUG"); - __mes_debug = p ? MAX (atoi (p), 1) : 0; - } - return __mes_debug; -} diff --git a/vendor/mes-libc/mes/abtol.c b/vendor/mes-libc/mes/abtol.c @@ -1,68 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2022,2023 Rick Masters <grick23@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/>. - */ - -#include <mes/lib.h> -#include <ctype.h> - -long -abtol (char const **p, int base) -{ - char const *s = p[0]; - /* `long long` (≥64-bit) accumulator so values that don't fit in 32-bit - * signed don't sign-extend through the parse. Affects every mes-libc - * number parser (strtol/strtoul/strtoull, vfprintf field widths, …). - * Without it, tcc3 mishandles `-Wl,-Ttext=0x80200000` (riscv64 OpenSBI - * kernel base) and `.quad 0x00af9a000000ffff` in amd64 kernel.S. */ - long long i = 0; - int sign_p = 0; - int m = '0'; - if (base == 0) - base = 10; - while (isspace (s[0]) != 0) - s = s + 1; - if (s[0] != 0 && s[0] == '+') - s = s + 1; - if (s[0] != 0 && s[0] == '-') - { - sign_p = 1; - s = s + 1; - } - while (isnumber (s[0], base) != 0) - { - i = i * base; - if (s[0] >= 'a') - m = 'a' - 10; - else - { - if (s[0] >= 'A') - m = 'A' - 10; - else - m = '0'; - } - i = i + s[0] - m; - s = s + 1; - } - p[0] = s; - if (sign_p != 0) - return -i; - - return i; -} diff --git a/vendor/mes-libc/mes/cast.c b/vendor/mes-libc/mes/cast.c @@ -1,57 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib.h> - -#undef cast_intp_to_charp -#undef cast_long_to_charp -#undef cast_charp_to_long -#undef cast_int_to_long -#undef cast_voidp_to_long - -char* -cast_intp_to_charp (int const *i) -{ - return (char*)i; -} - -char* -cast_long_to_charp (long i) -{ - return (char*)i; -} - -long -cast_charp_to_long (char const *i) -{ - return (long)i; -} - -long -cast_int_to_long (int i) -{ - return (long)i; -} - -long -cast_voidp_to_long (void const *i) -{ - return (long)i; -} diff --git a/vendor/mes-libc/mes/dtoab.c b/vendor/mes-libc/mes/dtoab.c @@ -1,46 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> -#include <limits.h> -#include <string.h> - -char * -dtoab (double d, int base, int signed_p) -{ - static char dtoa_buf[40]; - long i = (long) d; - char *p = ntoab (i, base, signed_p); - strcpy (dtoa_buf, p); - long f = (d - (double) i) * (double) 100000000; - if (f) - { - if (f < 0) - f = -f; - strcat (dtoa_buf, "."); - p = ntoab (f, base, 1); - strcat (dtoa_buf, p); - p = strchr (dtoa_buf, 0); - p--; - while (*p && *p == '0') - *p-- = 0; - } - return dtoa_buf; -} diff --git a/vendor/mes-libc/mes/eputc.c b/vendor/mes-libc/mes/eputc.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -int -eputc (int c) -{ - return fdputc (c, __stderr); -} diff --git a/vendor/mes-libc/mes/eputs.c b/vendor/mes-libc/mes/eputs.c @@ -1,30 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib-mini.h> -#include <string.h> - -int -eputs (char const *s) -{ - int i = strlen (s); - write (__stderr, s, i); - return 0; -} diff --git a/vendor/mes-libc/mes/fdgetc.c b/vendor/mes-libc/mes/fdgetc.c @@ -1,88 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> -#include <errno.h> -#include <limits.h> -#include <stdlib.h> -#include <string.h> -#include <sys/resource.h> -#include <unistd.h> - -int *__ungetc_buf; - -int -__ungetc_p (int filedes) -{ - if (__ungetc_buf == 0) - __ungetc_init (); - return __ungetc_buf[filedes] >= 0; -} - -void -__ungetc_init () -{ - if (__ungetc_buf == 0) - { - int save_errno = errno; - __ungetc_buf = malloc ((__FILEDES_MAX + 1) * sizeof (int)); - errno = save_errno; - memset (__ungetc_buf, -1, (__FILEDES_MAX + 1) * sizeof (int)); - } -} - -void -__ungetc_clear (int filedes) -{ - if (__ungetc_buf == 0) - __ungetc_init (); - __ungetc_buf[filedes] = -1; -} - -void -__ungetc_set (int filedes, int c) -{ - if (__ungetc_buf == 0) - __ungetc_init (); - __ungetc_buf[filedes] = c; -} - -int -fdgetc (int fd) -{ - if (__ungetc_buf == 0) - __ungetc_init (); - - char c; - int i = __ungetc_buf[fd]; - if (i >= 0) - __ungetc_buf[fd] = -1; - else - { - int r = read (fd, &c, 1); - if (r < 1) - return -1; - i = c; - } - if (i < 0) - i = i + 256; - - return i; -} diff --git a/vendor/mes-libc/mes/fdgets.c b/vendor/mes-libc/mes/fdgets.c @@ -1,40 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib.h> -#include <stdio.h> - -char * -fdgets (char *s, int count, int fd) -{ - int c = 0; - char *p = s; - while (--count > 0 && c != '\n') - { - c = fdgetc (fd); - if (c == EOF) - break; - *p++ = c; - } - if (p == s && (c == EOF || count == -1)) - return 0; - *p = 0; - return s; -} diff --git a/vendor/mes-libc/mes/fdputc.c b/vendor/mes-libc/mes/fdputc.c @@ -1,29 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -int -fdputc (int c, int fd) -{ - char *p = cast_intp_to_charp (&c); - write (fd, p, 1); - return 0; -} diff --git a/vendor/mes-libc/mes/fdputs.c b/vendor/mes-libc/mes/fdputs.c @@ -1,30 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> -#include <string.h> - -int -fdputs (char const *s, int fd) -{ - int i = strlen (s); - write (fd, s, i); - return 0; -} diff --git a/vendor/mes-libc/mes/fdungetc.c b/vendor/mes-libc/mes/fdungetc.c @@ -1,37 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -int -fdungetc (int c, int fd) -{ - if (c == -1) - return c; - else if (__ungetc_p (fd)) - { - eputs (" ***MES C LIB*** fdungetc ungetc buffer overflow fd="); - eputs (itoa (fd)); - eputs ("\n"); - assert_msg (0, "0"); - } - __ungetc_set (fd, c); - return c; -} diff --git a/vendor/mes-libc/mes/globals.c b/vendor/mes-libc/mes/globals.c @@ -1,27 +0,0 @@ -/* - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib-mini.h> - -int errno; -char **environ; -int __stdin; -int __stdout; -int __stderr; diff --git a/vendor/mes-libc/mes/itoa.c b/vendor/mes-libc/mes/itoa.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -char * -itoa (int x) -{ - return ntoab (x, 10, 1); -} diff --git a/vendor/mes-libc/mes/ltoa.c b/vendor/mes-libc/mes/ltoa.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib.h> - -char * -ltoa (long x) -{ - return ntoab (x, 10, 1); -} diff --git a/vendor/mes-libc/mes/ltoab.c b/vendor/mes-libc/mes/ltoab.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -char * -ltoab (long x, int base) -{ - return ntoab (x, base, 1); -} diff --git a/vendor/mes-libc/mes/mes_open.c b/vendor/mes-libc/mes/mes_open.c @@ -1,49 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> -#include <stdlib.h> - -#if SYSTEM_LIBC -#include <fcntl.h> -#include <stdarg.h> -// The Mes C Library defines and initializes these in crt1 -int __stdin = STDIN; -int __stdout = STDOUT; -int __stderr = STDERR; - -int -mes_open (char const *file_name, int flags, int mask) -{ - int filedes = open (file_name, flags, mask); - if (filedes > 2) - __ungetc_clear (filedes); - return filedes; -} - -#else // !SYSTEM_LIBC - -int -mes_open (char const *file_name, int flags, int mask) -{ - return _open3 (file_name, flags, mask); -} - -#endif // !SYSTEM_LIBC diff --git a/vendor/mes-libc/mes/ntoab.c b/vendor/mes-libc/mes/ntoab.c @@ -1,92 +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 © 2024 Michael Forney <mforney@mforney.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/>. - */ - -#include <mes/lib.h> -#include <assert.h> -#include <stdlib.h> -#include <string.h> - -#if __MESC__ && __arm__ -#define __MESC__and__arm__ -#endif - -#if __TINYC__ && __arm__ && BOOTSTRAP -#define __TINYC__and__arm__and__BOOTSTRAP -#endif - -#define __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP !defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP) - -// FIXME: M2-Planet 1.10.0 crashes on this... -// #if __M2__ || (!defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP)) -#if __M2__ || __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP -size_t -__mesabi_uldiv (size_t a, size_t b, size_t *remainder) -{ - remainder[0] = a % b; - return a / b; -} -#endif - -char *__itoa_buf; - -char * -ntoab (long x, unsigned base, int signed_p) -{ - if (__itoa_buf == 0) - __itoa_buf = malloc (24); - char *p = __itoa_buf + 23; - - assert_msg (base >= 8, "base >= 8"); - - int sign_p = 0; - size_t i; - size_t u; - size_t b = base; - if (signed_p != 0 && x < 0) - { - sign_p = 1; - /* Avoid LONG_MIN */ - u = (-(x + 1)); - u = u + 1; - } - else - u = x; - - p[0] = 0; - do - { - p = p - 1; - u = __mesabi_uldiv (u, b, &i); - if (i > 9) - p[0] = 'a' + i - 10; - else - p[0] = '0' + i; - } - while (u != 0); - - if (sign_p && p[0] != '0') - { - p = p - 1; - p[0] = '-'; - } - - return p; -} diff --git a/vendor/mes-libc/mes/oputc.c b/vendor/mes-libc/mes/oputc.c @@ -1,27 +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/>. - */ - -#include <mes/lib.h> - -int -oputc (int c) -{ - return fdputc (c, __stdout); -} diff --git a/vendor/mes-libc/mes/oputs.c b/vendor/mes-libc/mes/oputs.c @@ -1,30 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib-mini.h> -#include <string.h> - -int -oputs (char const *s) -{ - int i = strlen (s); - write (__stdout, s, i); - return 0; -} diff --git a/vendor/mes-libc/mes/search-path.c b/vendor/mes-libc/mes/search-path.c @@ -1,66 +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/>. - */ - -#include <mes/lib.h> -#include <string.h> -#include <stdlib.h> -#include <unistd.h> - -char * -search_path (char const *file_name) -{ - static char buf[256]; - char *path = getenv ("PATH"); - if (__mes_debug ()) - { - eputs ("\n search-path: "); - eputs (file_name); - eputs ("\n"); - } - while (*path) - { - char *end = strchr (path, ':'); - if (!end) - end = strchr (path, '\0'); - strncpy (buf, path, end - path); - buf[end - path] = 0; - if (__mes_debug ()) - { - eputs (" dir: "); - eputs (buf); - eputs ("\n"); - } - if (buf[end - path] != '/') - strcat (buf, "/"); - strcat (buf, file_name); - if (!access (buf, X_OK)) - { - if (__mes_debug ()) - { - eputs (" found: "); - eputs (buf); - eputs ("\n"); - } - return buf; - } - path = end + 1; - } - return 0; -} diff --git a/vendor/mes-libc/mes/ultoa.c b/vendor/mes-libc/mes/ultoa.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib.h> - -char * -ultoa (unsigned long x) -{ - return ntoab (x, 10, 1); -} diff --git a/vendor/mes-libc/mes/utoa.c b/vendor/mes-libc/mes/utoa.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -char * -utoa (unsigned x) -{ - return ntoab (x, 10, 0); -} diff --git a/vendor/mes-libc/patches/lib-mes-debug-proto.after b/vendor/mes-libc/patches/lib-mes-debug-proto.after @@ -1,2 +0,0 @@ -int __mes_debug (void); -void __ungetc_init (void); diff --git a/vendor/mes-libc/patches/lib-mes-debug-proto.before b/vendor/mes-libc/patches/lib-mes-debug-proto.before @@ -1,2 +0,0 @@ -int __mes_debug (); -void __ungetc_init (); diff --git a/vendor/mes-libc/patches/libmini-write-proto.after b/vendor/mes-libc/patches/libmini-write-proto.after @@ -1 +0,0 @@ -void __init_io (int argc, char **argv, char **envp); diff --git a/vendor/mes-libc/patches/libmini-write-proto.before b/vendor/mes-libc/patches/libmini-write-proto.before @@ -1 +0,0 @@ -void __init_io (); diff --git a/vendor/mes-libc/patches/libmini-write-proto2.after b/vendor/mes-libc/patches/libmini-write-proto2.after @@ -1 +0,0 @@ -ssize_t _write (int filedes, void const *buffer, size_t size); diff --git a/vendor/mes-libc/patches/libmini-write-proto2.before b/vendor/mes-libc/patches/libmini-write-proto2.before @@ -1 +0,0 @@ -ssize_t _write (); diff --git a/vendor/mes-libc/patches/malloc-brk-check.after b/vendor/mes-libc/patches/malloc-brk-check.after @@ -1,10 +0,0 @@ - /* Linux's raw brk(2) doesn't return -1 on failure; it returns the - * unchanged break (i.e. < requested). Compare against the requested - * address so a refused growth surfaces as malloc returning NULL - * instead of silently handing out a pointer past the break. */ - long _new = (long) (__brk + size); - if (brk (__brk + size) < _new) - return 0; - char *p = __brk; - __brk = __brk + size; - return p; diff --git a/vendor/mes-libc/patches/malloc-brk-check.before b/vendor/mes-libc/patches/malloc-brk-check.before @@ -1,5 +0,0 @@ - if (brk (__brk + size) == -1) - return 0; - char *p = __brk; - __brk = __brk + size; - return p; diff --git a/vendor/mes-libc/patches/malloc-max-align.after b/vendor/mes-libc/patches/malloc-max-align.after @@ -1,5 +0,0 @@ -#if !__M2__ - /* align what we give back. cc.scm has no max_align_t; 16 is the - * largest scalar alignment we hand out (long long / pointer / double). */ - __brk = (char*) (((uintptr_t) __brk + 16 - 1) & -16); -#endif diff --git a/vendor/mes-libc/patches/malloc-max-align.before b/vendor/mes-libc/patches/malloc-max-align.before @@ -1,5 +0,0 @@ -#if !__M2__ - /* align what we give back. */ - __brk = (char*) (((uintptr_t) __brk - + sizeof (max_align_t) - 1) & -sizeof (max_align_t)); -#endif diff --git a/vendor/mes-libc/patches/ntoab-inline-defined.after b/vendor/mes-libc/patches/ntoab-inline-defined.after @@ -1,4 +0,0 @@ -/* boot2: drop the helper macro — wrapping `defined()` in a #define body - * is UB per ISO C and triggers -Wexpansion-to-defined. The mes author's - * FIXME comment already had the inlined form; we just promote it. */ -#if __M2__ || (!defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP)) diff --git a/vendor/mes-libc/patches/ntoab-inline-defined.before b/vendor/mes-libc/patches/ntoab-inline-defined.before @@ -1,5 +0,0 @@ -#define __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP !defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP) - -// FIXME: M2-Planet 1.10.0 crashes on this... -// #if __M2__ || (!defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP)) -#if __M2__ || __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP diff --git a/vendor/mes-libc/patches/printf-int-promo.after b/vendor/mes-libc/patches/printf-int-promo.after @@ -1,43 +0,0 @@ - /* boot2: track the `l` length modifier so %d/%c read the - correct width. amd64 SysV stores int varargs as a 32-bit - write into an 8-byte reg-save slot — upper bits unspecified. - Reading via va_arg(ap, long) for plain %d / %c picks up - garbage. long==int64 on all our LP64 targets, so `ll` and - `l` collapse to one case. */ - int long_p = 0; - if (c == 'l') - { - long_p = 1; - c = *++p; - } - if (c == 'l') - c = *++p; - switch (c) - { - case '%': - { - fputc (*p, f); - count++; - break; - } - case 'c': - { - char _c; - _c = va_arg (ap, int); - fputc (_c, f); - break; - } - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - { - long d; - if (long_p) - d = va_arg (ap, long); - else if (c == 'd' || c == 'i' || c == 'o') - d = va_arg (ap, int); - else - d = va_arg (ap, unsigned int); diff --git a/vendor/mes-libc/patches/printf-int-promo.before b/vendor/mes-libc/patches/printf-int-promo.before @@ -1,30 +0,0 @@ - if (c == 'l') - c = *++p; - if (c == 'l') - { - eputs ("vfprintf: skipping second: l\n"); - c = *++p; - } - switch (c) - { - case '%': - { - fputc (*p, f); - count++; - break; - } - case 'c': - { - char _c; - _c = va_arg (ap, long); - fputc (_c, f); - break; - } - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - { - long d = va_arg (ap, long); diff --git a/vendor/mes-libc/patches/printf-mes-varargs.after b/vendor/mes-libc/patches/printf-mes-varargs.after @@ -1,2 +0,0 @@ -/* boot2: drop mes-mescc-specific x86_64 va_list pre-offset; va_start - below handles varargs correctly under any standard C compiler. */ diff --git a/vendor/mes-libc/patches/printf-mes-varargs.before b/vendor/mes-libc/patches/printf-mes-varargs.before @@ -1,5 +0,0 @@ -#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC -#define __FUNCTION_ARGS 1 - ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3; -#undef __FUNCTION_ARGS -#endif diff --git a/vendor/mes-libc/patches/snprintf-mes-varargs.after b/vendor/mes-libc/patches/snprintf-mes-varargs.after @@ -1,2 +0,0 @@ -/* boot2: drop mes-mescc-specific x86_64 va_list pre-offset; va_start - below handles varargs correctly under any standard C compiler. */ diff --git a/vendor/mes-libc/patches/snprintf-mes-varargs.before b/vendor/mes-libc/patches/snprintf-mes-varargs.before @@ -1,5 +0,0 @@ -#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC -#define __FUNCTION_ARGS 3 - ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3; -#undef __FUNCTION_ARGS -#endif diff --git a/vendor/mes-libc/patches/sprintf-mes-varargs.after b/vendor/mes-libc/patches/sprintf-mes-varargs.after @@ -1,2 +0,0 @@ -/* boot2: drop mes-mescc-specific x86_64 va_list pre-offset; va_start - below handles varargs correctly under any standard C compiler. */ diff --git a/vendor/mes-libc/patches/sprintf-mes-varargs.before b/vendor/mes-libc/patches/sprintf-mes-varargs.before @@ -1,5 +0,0 @@ -#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC -#define __FUNCTION_ARGS 2 - ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3; -#undef __FUNCTION_ARGS -#endif diff --git a/vendor/mes-libc/patches/strstr-drop-mman.after b/vendor/mes-libc/patches/strstr-drop-mman.after @@ -1,2 +0,0 @@ -#include <stdlib.h> -#include <string.h> diff --git a/vendor/mes-libc/patches/strstr-drop-mman.before b/vendor/mes-libc/patches/strstr-drop-mman.before @@ -1,3 +0,0 @@ -#include <stdlib.h> -#include <string.h> -#include <sys/mman.h> diff --git a/vendor/mes-libc/patches/vsnprintf-int-promo.after b/vendor/mes-libc/patches/vsnprintf-int-promo.after @@ -1,43 +0,0 @@ - /* boot2: track the `l` length modifier so %d / %c read the - correct width. See printf-int-promo.after for rationale. */ - int long_p = 0; - if (c == 'l') - { - long_p = 1; - c = *++p; - } - if (c == 'l') - c = *++p; - if (c == 'l') - c = *++p; - switch (c) - { - case '%': - { - if (count < size) - *str++ = *p; - count++; - break; - } - case 'c': - { - c = va_arg (ap, int); - if (count < size) - *str++ = c; - count++; - break; - } - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - { - long d; - if (long_p) - d = va_arg (ap, long); - else if (c == 'd' || c == 'i' || c == 'o') - d = va_arg (ap, int); - else - d = va_arg (ap, unsigned int); diff --git a/vendor/mes-libc/patches/vsnprintf-int-promo.before b/vendor/mes-libc/patches/vsnprintf-int-promo.before @@ -1,34 +0,0 @@ - if (c == 'l') - c = *++p; - if (c == 'l') - c = *++p; - if (c == 'l') - { - eputs ("vsnprintf: skipping second: l\n"); - c = *++p; - } - switch (c) - { - case '%': - { - if (count < size) - *str++ = *p; - count++; - break; - } - case 'c': - { - c = va_arg (ap, long); - if (count < size) - *str++ = c; - count++; - break; - } - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - { - long d = va_arg (ap, long); diff --git a/vendor/mes-libc/posix/buffered-read.c b/vendor/mes-libc/posix/buffered-read.c @@ -1,48 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> -#include <fcntl.h> - -ssize_t -read (int filedes, void *buffer, size_t size) -{ - ssize_t bytes = __buffered_read (filedes, buffer, size); - if (__mes_debug () > 4) - { - if (bytes == 1) - { - eputs ("read fd="); - eputs (itoa ((int) filedes)); - eputs (" c="); - eputc (*(char *) buffer); - eputs ("\n"); - } - else - { - eputs ("read fd="); - eputs (itoa ((int) filedes)); - eputs (" bytes="); - eputs (itoa (bytes)); - eputs ("\n"); - } - } - return bytes; -} diff --git a/vendor/mes-libc/posix/execvp.c b/vendor/mes-libc/posix/execvp.c @@ -1,53 +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/>. - */ - -#include <mes/lib.h> -#include <errno.h> -#include <string.h> -#include <unistd.h> - -int -execvp (char const *file_name, char *const argv[]) -{ - if (!strchr (file_name, '/')) - file_name = search_path (file_name); - if (!file_name) - { - errno = ENOENT; - return -1; - } - if (__mes_debug ()) - { - eputs (" EXEC: "); - eputs (file_name); - eputs ("\n"); - int i = 0; - while (argv[i]) - { - eputs (" arg["); - eputs (itoa (i)); - eputs ("]: "); - eputs (argv[i]); - eputs ("\n"); - i++; - } - } - return execve (file_name, argv, environ); -} diff --git a/vendor/mes-libc/posix/getcwd.c b/vendor/mes-libc/posix/getcwd.c @@ -1,33 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2020,2021,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/>. - */ - -#include <mes/lib.h> -#include <limits.h> -#include <sys/types.h> -#include <mes/lib.h> - -char * -getcwd (char *buffer, size_t size) -{ - static char buf[PATH_MAX]; - if (buffer == 0) - buffer = buf; - return _getcwd (buffer, size); -} diff --git a/vendor/mes-libc/posix/getenv.c b/vendor/mes-libc/posix/getenv.c @@ -1,49 +0,0 @@ -/* - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2020,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/>. - */ - -#include <mes/lib.h> -#include <string.h> -#include <stdlib.h> - -char * -getenv (char const *s) -{ - /* eputs ("\ngetenv s="); eputs (s); eputs ("\n"); */ - char **p = environ; - char *q; - int length = strlen (s); - - while (p[0] != 0) - { - /* eputs ("getenv p[0]="); eputs (p[0]); eputs ("\n"); */ - if (strncmp (s, p[0], length) == 0) - { - /* eputs ("found!\n"); */ - q = p[0] + length; - if (q[0] == '=') - return q + 1; - } - /* else */ - /* eputs ("not found!\n"); */ - p = p + M2_PTR_SIZE; - } - - return 0; -} diff --git a/vendor/mes-libc/posix/open.c b/vendor/mes-libc/posix/open.c @@ -1,54 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,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/>. - */ - -#include <mes/lib.h> -#include <fcntl.h> -#include <stdarg.h> - -int -_open2 (char const *file_name, int flags) -{ - int mask = 0777; - return _open3 (file_name, flags, mask); -} - -#if __M2__ -int -open (char const *file_name, int flags, int mask) -{ - return _open3 (file_name, flags, mask); -} -#else // !__M2__ -int -open (char const *file_name, int flags, ...) -{ - if (flags & O_CREAT) - { - va_list ap; - va_start (ap, flags); - int mask = va_arg (ap, int); - int r = _open3 (file_name, flags, mask); - va_end (ap); - return r; - } - else - return _open2 (file_name, flags); -} -#endif // !__M2__ diff --git a/vendor/mes-libc/posix/sbrk.c b/vendor/mes-libc/posix/sbrk.c @@ -1,36 +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/>. - */ - -#include <mes/lib.h> -#include <unistd.h> -#include <stdlib.h> - -#if __SBRK_CHAR_PTRDIFF -char * -sbrk (ptrdiff_t) -#else -void * -sbrk (intptr_t delta) -#endif -{ - if (delta >= 0) - return malloc (delta); - return __brk; -} diff --git a/vendor/mes-libc/posix/write.c b/vendor/mes-libc/posix/write.c @@ -1,41 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> -#include <errno.h> -#include <stdio.h> -#include <unistd.h> - -ssize_t -write (int filedes, void const *buffer, size_t size) -{ - size_t skip = __buffered_read_clear (filedes); - if (skip) - lseek (filedes, -skip, SEEK_CUR); - int r = _write (filedes, buffer, size); - if (r < 0) - { - errno = -r; - r = -1; - } - else - errno = 0; - return r; -} diff --git a/vendor/mes-libc/stdio/clearerr.c b/vendor/mes-libc/stdio/clearerr.c @@ -1,29 +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/>. - */ - -#include <mes/lib.h> -#include <errno.h> -#include <stdio.h> - -void -clearerr (FILE * stream) -{ - errno = 0; -} diff --git a/vendor/mes-libc/stdio/fclose.c b/vendor/mes-libc/stdio/fclose.c @@ -1,29 +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/>. - */ - -#include <stdio.h> -#include <unistd.h> - -int -fclose (FILE * stream) -{ - int fd = (long) stream; - return close (fd); -} diff --git a/vendor/mes-libc/stdio/fdopen.c b/vendor/mes-libc/stdio/fdopen.c @@ -1,27 +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/>. - */ - -#include <stdio.h> - -FILE * -fdopen (int fd, char const *mode) -{ - return (FILE *) (long) fd; -} diff --git a/vendor/mes-libc/stdio/feof.c b/vendor/mes-libc/stdio/feof.c @@ -1,30 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <stdio.h> - -int -feof (FILE * stream) -{ - int c = fgetc (stream); - if (c != EOF) - ungetc (c, stream); - return c == EOF; -} diff --git a/vendor/mes-libc/stdio/ferror.c b/vendor/mes-libc/stdio/ferror.c @@ -1,30 +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/>. - */ - -#include <stdio.h> - -int -ferror (FILE * stream) -{ - int fd = (long) stream; - if (fd == -1) - return -1; - return 0; -} diff --git a/vendor/mes-libc/stdio/fflush.c b/vendor/mes-libc/stdio/fflush.c @@ -1,32 +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/>. - */ - -#include <stdio.h> -#include <sys/stat.h> -#include <unistd.h> - -int -fflush (FILE * stream) -{ - int filedes = (long) stream; - if (filedes < 3) - return 0; - return fsync (filedes); -} diff --git a/vendor/mes-libc/stdio/fgetc.c b/vendor/mes-libc/stdio/fgetc.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <stdio.h> - -int -fgetc (FILE * stream) -{ - return fdgetc ((long) stream); -} diff --git a/vendor/mes-libc/stdio/fgets.c b/vendor/mes-libc/stdio/fgets.c @@ -1,28 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib.h> -#include <stdio.h> - -char * -fgets (char *s, int count, FILE * stream) -{ - return fdgets (s, count, (int) (long) stream); -} diff --git a/vendor/mes-libc/stdio/fileno.c b/vendor/mes-libc/stdio/fileno.c @@ -1,27 +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/>. - */ - -#include <stdio.h> - -int -fileno (FILE * stream) -{ - return (int) (long) stream; -} diff --git a/vendor/mes-libc/stdio/fopen.c b/vendor/mes-libc/stdio/fopen.c @@ -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 © 2018 Jeremiah Orians <jeremiah@pdp10.guru> - * - * 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/>. - */ - -#include <mes/lib.h> -#include <assert.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -FILE * -fopen (char const *file_name, char const *opentype) -{ - if (__mes_debug ()) - { - eputs ("fopen "); - eputs (file_name); - eputs (" "); - eputs (opentype); - eputs ("\n"); - } - - int fd; - int mode = 0600; - if ((opentype[0] == 'a' || !strcmp (opentype, "r+")) && !access (file_name, O_RDONLY)) - { - int flags = O_RDWR; - if (opentype[0] == 'a') - flags |= O_APPEND; - fd = _open3 (file_name, flags, mode); - } - else if (opentype[0] == 'w' || opentype[0] == 'a' || !strcmp (opentype, "r+")) - { - char *plus_p = strchr (opentype, '+'); - int flags = plus_p ? O_RDWR | O_CREAT : O_WRONLY | O_CREAT | O_TRUNC; - fd = _open3 (file_name, flags, mode); - } - else - fd = _open3 (file_name, O_RDONLY, 0); - - if (__mes_debug ()) - { - eputs (" => fd="); - eputs (itoa (fd)); - eputs ("\n"); - } - - if (!fd) - { - eputs (" ***MES LIB C*** fopen of stdin: signal me in band\n"); - assert (0); - } - if (fd < 0) - fd = 0; - return (FILE *) (long) fd; -} diff --git a/vendor/mes-libc/stdio/fprintf.c b/vendor/mes-libc/stdio/fprintf.c @@ -1,33 +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/>. - */ - -#include <mes/lib.h> -#include <stdarg.h> -#include <stdio.h> - -int -fprintf (FILE * stream, char const *format, ...) -{ - va_list ap; - va_start (ap, format); - int r = vfprintf (stream, format, ap); - va_end (ap); - return r; -} diff --git a/vendor/mes-libc/stdio/fputc.c b/vendor/mes-libc/stdio/fputc.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <stdio.h> - -int -fputc (int c, FILE * stream) -{ - return fdputc (c, (long) stream); -} diff --git a/vendor/mes-libc/stdio/fputs.c b/vendor/mes-libc/stdio/fputs.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <stdio.h> - -int -fputs (char const *s, FILE * stream) -{ - return fdputs (s, (long) stream); -} diff --git a/vendor/mes-libc/stdio/fread.c b/vendor/mes-libc/stdio/fread.c @@ -1,76 +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/>. - */ - -#include <mes/lib.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -int -__fungetc_p (FILE * stream) -{ - return __ungetc_p ((int) (long) stream); -} - -size_t -fread (void *data, size_t size, size_t count, FILE * stream) -{ - if (!size || !count) - return 0; - - size_t todo = size * count; - char *buf = (char *) data; - - int bytes = 0; - while (__fungetc_p (stream) && todo-- && ++bytes) - *buf++ = fgetc (stream); - int filedes = (long) stream; - if (todo) - { - int r = read (filedes, buf, todo); - if (r < 0 && !bytes) - bytes = r; - else - bytes += r; - } - - if (__mes_debug ()) - { - static char debug_buf[4096]; - eputs ("fread fd="); - eputs (itoa (filedes)); - eputs (" bytes="); - eputs (itoa (bytes)); - eputs ("\n"); - if (bytes > 0 && bytes < sizeof (debug_buf)) - { - strncpy (debug_buf, data, bytes); - buf[bytes] = 0; - eputs ("fread buf="); - eputs (debug_buf); - eputs ("\n"); - } - } - - if (bytes > 0) - return bytes / size; - - return 0; -} diff --git a/vendor/mes-libc/stdio/fseek.c b/vendor/mes-libc/stdio/fseek.c @@ -1,41 +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/>. - */ - -#include <mes/lib.h> -#include <stdio.h> -#include <unistd.h> - -int -fseek (FILE * stream, long offset, int whence) -{ - int filedes = (long) stream; - off_t pos = lseek (filedes, offset, whence); - if (__mes_debug ()) - { - eputs ("fread fd="); - eputs (itoa (filedes)); - eputs (" =>"); - eputs (itoa (pos)); - eputs ("\n"); - } - if (pos >= 0) - return 0; - return -1; -} diff --git a/vendor/mes-libc/stdio/ftell.c b/vendor/mes-libc/stdio/ftell.c @@ -1,29 +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/>. - */ - -#include <fcntl.h> -#include <stdio.h> -#include <unistd.h> - -long -ftell (FILE * stream) -{ - return lseek ((int) (long) stream, 0, SEEK_CUR); -} diff --git a/vendor/mes-libc/stdio/fwrite.c b/vendor/mes-libc/stdio/fwrite.c @@ -1,52 +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/>. - */ - -#include <mes/lib.h> -#include <stdio.h> -#include <unistd.h> - -size_t -fwrite (void const *data, size_t size, size_t count, FILE * stream) -{ - if (__mes_debug () > 1) - { - eputs ("fwrite "); - eputs (itoa ((int) (long) stream)); - eputs (" "); - eputs (itoa (size)); - eputs ("\n"); - } - - if (!size || !count) - return 0; - int filedes = (long) stream; - int bytes = write (filedes, data, size * count); - - if (__mes_debug () > 2) - { - eputs (" => "); - eputs (itoa (bytes)); - eputs ("\n"); - } - - if (bytes > 0) - return bytes / size; - return 0; -} diff --git a/vendor/mes-libc/stdio/getc.c b/vendor/mes-libc/stdio/getc.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <stdio.h> - -int -getc (FILE * stream) -{ - return fdgetc ((long) stream); -} diff --git a/vendor/mes-libc/stdio/perror.c b/vendor/mes-libc/stdio/perror.c @@ -1,30 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> - -void -perror (char const *message) -{ - fprintf (stderr, "%s: %s\n", strerror (errno), message); -} diff --git a/vendor/mes-libc/stdio/printf.c b/vendor/mes-libc/stdio/printf.c @@ -1,39 +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/>. - */ - -#include <mes/lib.h> -#include <stdarg.h> -#include <stdio.h> - -int -printf (char const *format, ...) -{ - va_list ap; - int r; -#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC -#define __FUNCTION_ARGS 1 - ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3; -#undef __FUNCTION_ARGS -#endif - va_start (ap, format); - r = vprintf (format, ap); - va_end (ap); - return r; -} diff --git a/vendor/mes-libc/stdio/putc.c b/vendor/mes-libc/stdio/putc.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <stdio.h> - -int -putc (int c, FILE * stream) -{ - return fdputc (c, (long) stream); -} diff --git a/vendor/mes-libc/stdio/remove.c b/vendor/mes-libc/stdio/remove.c @@ -1,34 +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/>. - */ - -#include <stdio.h> -#include <sys/stat.h> -#include <unistd.h> - -int -remove (char const *file_name) -{ - struct stat buf; - if (stat (file_name, &buf) < 0) - return -1; - if (S_ISDIR (buf.st_mode)) - return rmdir (file_name); - return unlink (file_name); -} diff --git a/vendor/mes-libc/stdio/snprintf.c b/vendor/mes-libc/stdio/snprintf.c @@ -1,39 +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/>. - */ - -#include <mes/lib.h> -#include <stdarg.h> -#include <stdio.h> - -int -snprintf (char *str, size_t size, char const *format, ...) -{ - va_list ap; - int r; -#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC -#define __FUNCTION_ARGS 3 - ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3; -#undef __FUNCTION_ARGS -#endif - va_start (ap, format); - r = vsnprintf (str, size, format, ap); - va_end (ap); - return r; -} diff --git a/vendor/mes-libc/stdio/sprintf.c b/vendor/mes-libc/stdio/sprintf.c @@ -1,39 +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/>. - */ - -#include <mes/lib.h> -#include <stdarg.h> -#include <stdio.h> - -int -sprintf (char *str, char const *format, ...) -{ - va_list ap; - int r; -#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC -#define __FUNCTION_ARGS 2 - ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3; -#undef __FUNCTION_ARGS -#endif - va_start (ap, format); - r = vsprintf (str, format, ap); - va_end (ap); - return r; -} diff --git a/vendor/mes-libc/stdio/ungetc.c b/vendor/mes-libc/stdio/ungetc.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <stdio.h> - -int -ungetc (int c, FILE * stream) -{ - return fdungetc (c, (long) stream); -} diff --git a/vendor/mes-libc/stdio/vfprintf.c b/vendor/mes-libc/stdio/vfprintf.c @@ -1,252 +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/>. - */ - -#include <mes/lib.h> -#include <stdarg.h> -#include <stdio.h> -#include <string.h> - -int -vfprintf (FILE * f, char const *format, va_list ap) -{ - int fd = (long) f; - char const *p = format; - int count = 0; - while (*p) - if (*p != '%') - { - count++; - fputc (*p++, f); - } - else - { - p++; - char c = *p; - int left_p = 0; - int precision = -1; - int width = -1; - if (c == '-') - { - left_p = 1; - c = *++p; - } - char pad = ' '; - if (c == ' ') - { - pad = c; - c = *p++; - } - if (c == '0') - { - pad = c; - c = *p++; - } - if (c >= '0' && c <= '9') - { - width = abtol (&p, 10); - c = *p; - } - else if (c == '*') - { - width = va_arg (ap, int); - c = *++p; - } - if (c == '.') - { - c = *++p; - if (c >= '0' && c <= '9') - { - precision = abtol (&p, 10); - c = *p; - } - else if (c == '*') - { - precision = va_arg (ap, int); - c = *++p; - } - } - if (c == 'l') - c = *++p; - if (c == 'l') - { - eputs ("vfprintf: skipping second: l\n"); - c = *++p; - } - switch (c) - { - case '%': - { - fputc (*p, f); - count++; - break; - } - case 'c': - { - char _c; - _c = va_arg (ap, long); - fputc (_c, f); - break; - } - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - { - long d = va_arg (ap, long); - int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 10; - char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X'); - if (c == 'X') - strupr (s); - int length = strlen (s); - if (precision == -1) - precision = length; - if (!left_p) - { - while (width-- > precision) - { - fputc (pad, f); - count++; - } - while (precision > length) - { - fputc ('0', f); - precision--; - width--; - count++; - } - } - while (*s) - { - if (precision-- <= 0) - break; - width--; - fputc (*s++, f); - count++; - } - while (width > 0) - { - width--; - fputc (pad, f); - count++; - } - break; - } - case 's': - { - char *s = va_arg (ap, char *); - int length = strlen (s); - if (precision == -1) - precision = length; - if (!left_p) - { - while (width-- > precision) - { - fputc (pad, f); - count++; - } - while (precision > length) - { - fputc (' ', f); - precision--; - width--; - count++; - } - } - while (*s) - { - if (precision-- <= 0) - break; - width--; - fputc (*s++, f); - count++; - } - while (width > 0) - { - width--; - fputc (pad, f); - count++; - } - break; - } - case 'f': - case 'e': - case 'E': - case 'g': - case 'G': - { - double d = va_arg8 (ap, double); - char *s = dtoab (d, 10, 1); - if (c == 'E' || c == 'G') - strupr (s); - int length = strlen (s); - if (precision == -1) - precision = length; - if (!left_p) - { - while (width-- > precision) - { - fputc (pad, f); - count++; - } - while (precision > length) - { - fputc (' ', f); - precision--; - width--; - count++; - } - } - while (*s) - { - if (precision-- <= 0) - break; - width--; - fputc (*s++, f); - count++; - } - while (width > 0) - { - width--; - fputc (pad, f); - count++; - } - break; - } - case 'n': - { - int *n = va_arg (ap, int *); - *n = count; - break; - } - default: - { - eputs ("vfprintf: not supported: %:"); - eputc (c); - eputs ("\n"); - p++; - } - } - p++; - } - va_end (ap); - return 0; -} diff --git a/vendor/mes-libc/stdio/vprintf.c b/vendor/mes-libc/stdio/vprintf.c @@ -1,29 +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/>. - */ - -#include <mes/lib.h> -#include <stdarg.h> -#include <stdio.h> - -int -vprintf (char const *format, va_list ap) -{ - return vfprintf (stdout, format, ap); -} diff --git a/vendor/mes-libc/stdio/vsnprintf.c b/vendor/mes-libc/stdio/vsnprintf.c @@ -1,275 +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/>. - */ - -#include <mes/lib.h> -#include <ctype.h> -#include <stdarg.h> -#include <string.h> - -int -vsnprintf (char *str, size_t size, char const *format, va_list ap) -{ - char const *p = format; - int count = 0; - char c; - while (*p) - if (*p != '%') - { - c = *p++; - if (count < size) - *str++ = c; - count++; - } - else - { - p++; - c = *p; - int left_p = 0; - int precision = -1; - int width = -1; - if (c == '-') - { - left_p = 1; - c = *++p; - } - char pad = ' '; - if (c == ' ') - { - pad = c; - c = *p++; - } - if (c == '0') - { - pad = c; - c = *p++; - } - if (c >= '0' && c <= '9') - { - width = abtol (&p, 10); - c = *p; - } - else if (c == '*') - { - width = va_arg (ap, long); - c = *++p; - } - if (c == '.') - { - c = *++p; - if (c >= '0' && c <= '9') - { - precision = abtol (&p, 10); - c = *p; - } - else if (c == '*') - { - precision = va_arg (ap, long); - c = *++p; - } - } - if (c == 'l') - c = *++p; - if (c == 'l') - c = *++p; - if (c == 'l') - { - eputs ("vsnprintf: skipping second: l\n"); - c = *++p; - } - switch (c) - { - case '%': - { - if (count < size) - *str++ = *p; - count++; - break; - } - case 'c': - { - c = va_arg (ap, long); - if (count < size) - *str++ = c; - count++; - break; - } - case 'd': - case 'i': - case 'o': - case 'u': - case 'x': - case 'X': - { - long d = va_arg (ap, long); - int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 10; - char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X'); - if (c == 'X') - strupr (s); - int length = strlen (s); - if (precision == -1) - precision = length; - if (!left_p) - { - while (width-- > precision) - { - if (count < size) - *str++ = pad; - count++; - } - while (precision > length) - { - if (count < size) - *str++ = '0'; - precision--; - width--; - count++; - } - } - while (*s) - { - if (precision-- <= 0) - break; - width--; - c = *s++; - if (count < size) - *str++ = c; - count++; - } - while (width > 0) - { - width--; - if (count < size) - *str++ = pad; - count++; - } - break; - } - case 's': - { - char *s = va_arg (ap, char *); - int length = s ? strlen (s) : 0; - if (precision == -1) - precision = length; - if (!left_p) - { - while (width-- > precision) - { - if (count < size) - *str++ = pad; - count++; - } - while (width > length) - { - if (count < size) - *str++ = ' '; - precision--; - width--; - count++; - } - } - while (s && *s) - { - if (precision-- <= 0) - break; - width--; - c = *s++; - if (count < size) - *str++ = c; - count++; - } - while (width > 0) - { - width--; - if (count < size) - *str++ = pad; - count++; - } - break; - } - case 'f': - case 'e': - case 'E': - case 'g': - case 'G': - { - double d = va_arg8 (ap, double); - char *s = dtoab (d, 10, 1); - if (c == 'E' || c == 'G') - strupr (s); - int length = strlen (s); - if (precision == -1) - precision = length; - if (!left_p) - { - while (width-- > precision) - { - if (count < size) - *str++ = pad; - count++; - } - while (precision > length) - { - if (count < size) - *str++ = ' '; - precision--; - width--; - count++; - } - } - while (*s) - { - if (precision-- <= 0) - break; - width--; - c = *s++; - if (count < size) - *str++ = c; - count++; - } - while (width > 0) - { - width--; - if (count < size) - *str++ = pad; - count++; - } - break; - } - case 'n': - { - int *n = va_arg (ap, int *); - *n = count; - break; - } - default: - { - eputs ("vsnprintf: not supported: %:"); - eputc (c); - eputs ("\n"); - p++; - } - } - p++; - } - va_end (ap); - if (count < size) - *str = 0; - return count; -} diff --git a/vendor/mes-libc/stdio/vsprintf.c b/vendor/mes-libc/stdio/vsprintf.c @@ -1,28 +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/>. - */ - -#include <limits.h> -#include <stdarg.h> - -int -vsprintf (char *str, char const *format, va_list ap) -{ - return vsnprintf (str, LONG_MAX, format, ap); -} diff --git a/vendor/mes-libc/stdlib/__exit.c b/vendor/mes-libc/stdlib/__exit.c @@ -1,27 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <stdlib.h> - -int -__exit (int status) -{ - exit (status); -} diff --git a/vendor/mes-libc/stdlib/abort.c b/vendor/mes-libc/stdlib/abort.c @@ -1,32 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <signal.h> - -void -abort (void) -{ - if (raise (SIGABRT) < 0) /* could not raise SIGABRT */ - { - /* Fail in any way possible */ - unsigned char* x = (unsigned char*) 0; - *x = 2; - } -} diff --git a/vendor/mes-libc/stdlib/atoi.c b/vendor/mes-libc/stdlib/atoi.c @@ -1,28 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -int -atoi (char const *string) -{ - char const *p = string; - return abtol (&p, 0); -} diff --git a/vendor/mes-libc/stdlib/atol.c b/vendor/mes-libc/stdlib/atol.c @@ -1,27 +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/>. - */ - -#include <stdlib.h> - -int -atol (char const *s) -{ - return atoi (s); -} diff --git a/vendor/mes-libc/stdlib/calloc.c b/vendor/mes-libc/stdlib/calloc.c @@ -1,31 +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/>. - */ - -#include <stdlib.h> -#include <string.h> - -void * -calloc (size_t nmemb, size_t size) -{ - size_t count = nmemb * size; - void *p = malloc (count); - memset (p, 0, count); - return p; -} diff --git a/vendor/mes-libc/stdlib/exit.c b/vendor/mes-libc/stdlib/exit.c @@ -1,35 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,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/>. - */ - -#include <mes/lib.h> - -#if !__M2__ -void (*__call_at_exit) (void); -#endif - -void -exit (int code) -{ -#if !__M2__ - if (__call_at_exit) - (*__call_at_exit) (); -#endif - _exit (code); -} diff --git a/vendor/mes-libc/stdlib/free.c b/vendor/mes-libc/stdlib/free.c @@ -1,26 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <stdlib.h> - -void -free (void *ptr) -{ -} diff --git a/vendor/mes-libc/stdlib/puts.c b/vendor/mes-libc/stdlib/puts.c @@ -1,28 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -int -puts (char const *s) -{ - oputs (s); - return oputs ("\n"); -} diff --git a/vendor/mes-libc/stdlib/qsort.c b/vendor/mes-libc/stdlib/qsort.c @@ -1,80 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright © 2021 Paul Dersey <pdersey@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/>. - */ - -#include <stdlib.h> -#include <string.h> - -void -qswap (void *a, void *b, size_t size) -{ - char *pa = a; - char *pb = b; - do - { - char tmp = *pa; - *pa++ = *pb; - *pb++ = tmp; - } while (--size > 0); -} - -size_t -qpart (void *base, size_t count, size_t size, int (*compare) (void const *, void const *)) -{ - void *p = base + count * size; - size_t i = 0; - for (size_t j = 0; j < count; j++) - { - int c = compare (base + j * size, p); - if (c < 0) - { -#if 1 //__x86_64__ - qswap (base + i * size, base + j * size, size); -#else - int p1 = base + i * size; - int p2 = base + j * size; - qswap (p1, p2, size); -#endif - i++; - } - else if (c == 0) - i++; - } - if (compare (base + count * size, base + i * size) < 0) - qswap (base + i * size, base + count * size, size); - return i; -} - -void -qsort (void *base, size_t count, size_t size, int (*compare) (void const *, void const *)) -{ - if (count > 1) - { - int p = qpart (base, count - 1, size, compare); - qsort (base, p, size, compare); -#if 1 //__x86_64__ - qsort (base + p * size, count - p, size, compare); -#else - int p1 = base + p * size; - int p2 = count - p; - qsort (p1, p2, size, compare); -#endif - } -} diff --git a/vendor/mes-libc/stdlib/realloc.c b/vendor/mes-libc/stdlib/realloc.c @@ -1,34 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <stdlib.h> -#include <string.h> - -void * -realloc (void *ptr, size_t size) -{ - void *new = malloc (size); - if (ptr != 0 && new != 0) - { - memcpy (new, ptr, size); - free (ptr); - } - return new; -} diff --git a/vendor/mes-libc/stdlib/strtof.c b/vendor/mes-libc/stdlib/strtof.c @@ -1,27 +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/>. - */ - -#include <stdlib.h> - -float -strtof (char const *string, char **tailptr) -{ - return strtod (string, tailptr); -} diff --git a/vendor/mes-libc/stdlib/strtol.c b/vendor/mes-libc/stdlib/strtol.c @@ -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/>. - */ - -#include <mes/lib.h> -#include <stdlib.h> -#include <string.h> - -long -strtol (char const *string, char **tailptr, int base) -{ - if (!strncmp (string, "0x", 2)) - { - string += 2; - base = 16; - } - if (tailptr) - { - *tailptr = (char *) string; - return abtol ((char const **) tailptr, base); - } - char **p = (char **) &string; - return abtol ((char const **) p, base); -} diff --git a/vendor/mes-libc/stdlib/strtoll.c b/vendor/mes-libc/stdlib/strtoll.c @@ -1,27 +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/>. - */ - -#include <stdlib.h> - -long long int -strtoll (char const *string, char **tailptr, int base) -{ - return strtol (string, tailptr, base); -} diff --git a/vendor/mes-libc/stdlib/strtoul.c b/vendor/mes-libc/stdlib/strtoul.c @@ -1,27 +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/>. - */ - -#include <stdlib.h> - -unsigned long -strtoul (char const *string, char **tailptr, int base) -{ - return strtol (string, tailptr, base); -} diff --git a/vendor/mes-libc/stdlib/strtoull.c b/vendor/mes-libc/stdlib/strtoull.c @@ -1,27 +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/>. - */ - -#include <stdlib.h> - -unsigned long long -strtoull (char const *string, char **tailptr, int base) -{ - return strtol (string, tailptr, base); -} diff --git a/vendor/mes-libc/string/memchr.c b/vendor/mes-libc/string/memchr.c @@ -1,37 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,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/>. - */ - -#include <string.h> - -void * -memchr (void const *block, int c, size_t size) -{ - char const *p = block; - - while (size != 0) - { - size = size - 1; - if (c == p[0]) - return (void*) p; - p = p + 1; - } - - return 0; -} diff --git a/vendor/mes-libc/string/memcmp.c b/vendor/mes-libc/string/memcmp.c @@ -1,40 +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/>. - */ - -#include <string.h> - -int -memcmp (void const *s1, void const *s2, size_t size) -{ - if (size == 0) - return 0; - - char const *a = s1; - char const *b = s2; - - while (a[0] == b[0] && size > 1) - { - size = size - 1; - a = a + 1; - b = b + 1; - } - - return a[0] - b[0]; -} diff --git a/vendor/mes-libc/string/memcpy.c b/vendor/mes-libc/string/memcpy.c @@ -1,44 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> -#include <string.h> - -char * -_memcpy (char *dest, char const *src, size_t n) -{ - char *p = dest; - - while (n != 0) - { - n = n - 1; - dest[0] = src[0]; - dest = dest + 1; - src = src + 1; - } - - return p; -} - -void * -memcpy (void *dest, void const *src, size_t n) -{ - return _memcpy (dest, src, n); -} diff --git a/vendor/mes-libc/string/memmem.c b/vendor/mes-libc/string/memmem.c @@ -1,60 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 1997--2015,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> - * Copyright (C) 1997--2015,2018 Han-Wen Nienhuys <hanwen@xs4all.nl> - * - * 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/>. - */ - -#include <string.h> - -/** locate a substring. #memmem# finds the first occurrence of - #needle# in #haystack#. This is not ANSI-C. - - The prototype is not in accordance with the Linux Programmer's - Manual v1.15, but it is with /usr/include/string.h */ - -unsigned char * -_memmem (unsigned char const *haystack, int haystack_len, unsigned char const *needle, int needle_len) -{ - unsigned char const *end_haystack = haystack + haystack_len - needle_len + 1; - unsigned char const *end_needle = needle + needle_len; - - /* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation - is the spice of life */ - while (haystack < end_haystack) - { - unsigned char const *subneedle = needle; - unsigned char const *subhaystack = haystack; - while (subneedle < end_needle) - if (*subneedle++ != *subhaystack++) - goto next; - - /* Completed the needle. Gotcha. */ - return (unsigned char *) haystack; - next: - haystack++; - } - return 0; -} - -void * -memmem (void const *haystack, int haystack_len, void const *needle, int needle_len) -{ - unsigned char const *haystack_byte_c = (unsigned char const *) haystack; - unsigned char const *needle_byte_c = (unsigned char const *) needle; - return _memmem (haystack_byte_c, haystack_len, needle_byte_c, needle_len); -} diff --git a/vendor/mes-libc/string/memmove.c b/vendor/mes-libc/string/memmove.c @@ -1,33 +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/>. - */ - -#include <string.h> - -void * -memmove (void *dest, void const *src, size_t n) -{ - if (dest < src) - return memcpy (dest, src, n); - char *p = dest + n; - char const *q = src + n; - while (n--) - *--p = *--q; - return dest; -} diff --git a/vendor/mes-libc/string/memset.c b/vendor/mes-libc/string/memset.c @@ -1,40 +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/>. - */ - -#include <string.h> - -char * -_memset (char *s, int c, size_t n) -{ - char *p = s; - while (n != 0) - { - n = n - 1; - s[0] = c; - s = s + 1; - } - return p; -} - -void * -memset (void *s, int c, size_t n) -{ - return _memset (s, c, n); -} diff --git a/vendor/mes-libc/string/strcat.c b/vendor/mes-libc/string/strcat.c @@ -1,31 +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/>. - */ - -#include <string.h> - -char * -strcat (char *to, char const *from) -{ - char *p = strchr (to, '\0'); - while (*from) - *p++ = *from++; - *p = 0; - return to; -} diff --git a/vendor/mes-libc/string/strchr.c b/vendor/mes-libc/string/strchr.c @@ -1,34 +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/>. - */ - -#include <string.h> - -char * -strchr (char const *s, int c) -{ - char const *p = s; - while (*p || !c) - { - if (c == *p) - return (char *) p; - p++; - } - return 0; -} diff --git a/vendor/mes-libc/string/strcmp.c b/vendor/mes-libc/string/strcmp.c @@ -1,33 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <string.h> - -int -strcmp (char const *a, char const *b) -{ - while (a[0] != 0 && b[0] != 0 && a[0] == b[0]) - { - a = a + 1; - b = b + 1; - } - - return a[0] - b[0]; -} diff --git a/vendor/mes-libc/string/strcpy.c b/vendor/mes-libc/string/strcpy.c @@ -1,37 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <string.h> - -char * -strcpy (char *dest, char const *src) -{ - char *p = dest; - - while (src[0] != 0) - { - p[0] = src[0]; - p = p + 1; - src = src + 1; - } - p[0] = 0; - - return dest; -} diff --git a/vendor/mes-libc/string/strcspn.c b/vendor/mes-libc/string/strcspn.c @@ -1,33 +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/>. - */ - -#include <string.h> - -size_t -strcspn (char const *string, char const *stopset) -{ - char *p = (char *) string; - while (*p) - if (strchr (stopset, *p)) - break; - else - p++; - return p - string; -} diff --git a/vendor/mes-libc/string/strdup.c b/vendor/mes-libc/string/strdup.c @@ -1,32 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <stdlib.h> -#include <string.h> - -char * -strdup (char const *s) -{ - size_t length = strlen (s) + 1; - char *p = (char *) malloc (length); - if (p) - return memcpy (p, s, length); - return 0; -} diff --git a/vendor/mes-libc/string/strerror.c b/vendor/mes-libc/string/strerror.c @@ -1,81 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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/>. - */ - -#include <mes/lib.h> -#include <string.h> - -char *sys_errlist[] = { - "error 00", - "error 01", - "error 02", - "error 03", - "error 04", - "error 05", - "error 06", - "error 07", - "error 08", - "error 09", - "error 10", - "error 11", - "error 12", - "error 13", - "error 14", - "error 15", - "error 16", - "error 17", - "error 18", - "error 19", - "error 20", - "error 21", - "error 22", - "error 23", - "error 24", - "error 25", - "error 26", - "error 27", - "error 28", - "error 29", - "error 30", - "error 31", - "error 32", - "error 33", - "error 34", - "error 35", - "error 36", - "error 37", - "error 38", - "error 39", -}; - -int sys_nerr = 39; - -char * -strerror (int errnum) -{ - if (__mes_debug ()) - { - eputs ("strerror errnum="); - eputs (itoa (errnum)); - eputs ("\n"); - } - if (errnum > 0 && errnum <= sys_nerr) - return sys_errlist[errnum]; - return "sterror: unknown error"; -} diff --git a/vendor/mes-libc/string/strlen.c b/vendor/mes-libc/string/strlen.c @@ -1,32 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <mes/lib.h> - -size_t -strlen (char const *s) -{ - int i = 0; - - while (s[i] != 0) - i = i + 1; - - return i; -} diff --git a/vendor/mes-libc/string/strncat.c b/vendor/mes-libc/string/strncat.c @@ -1,33 +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/>. - */ - -#include <string.h> - -char * -strncat (char *to, char const *from, size_t size) -{ - if (size == 0) - return to; - char *p = strchr (to, '\0'); - while (*from && size-- > 0) - *p++ = *from++; - *p = 0; - return to; -} diff --git a/vendor/mes-libc/string/strncmp.c b/vendor/mes-libc/string/strncmp.c @@ -1,37 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,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/>. - */ - -#include <string.h> - -int -strncmp (char const *a, char const *b, size_t size) -{ - if (size == 0) - return 0; - - while (a[0] != 0 && b[0] != 0 && a[0] == b[0] && size > 1) - { - size = size - 1; - a = a + 1; - b = b + 1; - } - - return a[0] - b[0]; -} diff --git a/vendor/mes-libc/string/strncpy.c b/vendor/mes-libc/string/strncpy.c @@ -1,36 +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/>. - */ - -#include <string.h> - -char * -strncpy (char *to, char const *from, size_t size) -{ - if (size == 0) - return to; - char *p = to; - while (*from && size--) - *p++ = *from++; - if (*from) - size++; - while (size--) - *p++ = 0; - return to; -} diff --git a/vendor/mes-libc/string/strpbrk.c b/vendor/mes-libc/string/strpbrk.c @@ -1,33 +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/>. - */ - -#include <string.h> - -char * -strpbrk (char const *string, char const *stopset) -{ - char *p = (char *) string; - while (*p) - if (strchr (stopset, *p)) - break; - else - p++; - return p; -} diff --git a/vendor/mes-libc/string/strrchr.c b/vendor/mes-libc/string/strrchr.c @@ -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/>. - */ - -#include <string.h> - -char * -strrchr (char const *s, int c) -{ - int n = strlen (s); - if (!n) - return 0; - char const *p = s + n; - if (!*p && !c) - return (char *) p; - p--; - while (n-- && (*p || !c)) - { - if (c == *p) - return (char *) p; - p--; - } - return 0; -} diff --git a/vendor/mes-libc/string/strspn.c b/vendor/mes-libc/string/strspn.c @@ -1,33 +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/>. - */ - -#include <string.h> - -size_t -strspn (char const *string, char const *skipset) -{ - char *p = (char *) string; - while (*p) - if (!strchr (skipset, *p)) - break; - else - p++; - return p - string; -} diff --git a/vendor/mes-libc/string/strstr.c b/vendor/mes-libc/string/strstr.c @@ -1,29 +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/>. - */ - -#include <stdlib.h> -#include <string.h> -#include <sys/mman.h> - -char * -strstr (char const *haystack, char const *needle) -{ - return memmem (haystack, strlen (haystack), needle, strlen (needle)); -} diff --git a/vendor/mes-libc/string/strupr.c b/vendor/mes-libc/string/strupr.c @@ -1,34 +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/>. - */ - -#include <ctype.h> -#include <string.h> - -char * -strupr (char *string) -{ - char *p = string; - while (*p) - { - *p = toupper (*p); - p++; - } - return string; -} diff --git a/vendor/mes-libc/unified-libc.c b/vendor/mes-libc/unified-libc.c @@ -1,150 +0,0 @@ -/* unified-libc.c — single translation unit gathering every vendored - * mes-libc .c plus boot2-syscall.c. The host preprocessor flattens - * the whole thing to libc.flat.c, which cc.scm compiles to libc.P1pp. - * - * Order matters in a few specific places: - * 1. boot2-syscall.c declares the extern sys_* P1pp labels and - * defines _read / _write / _open3 / close / lseek / brk / unlink / - * _exit. It comes early so later layers see the prototypes. - * 2. mes/globals.c defines errno / __stdin etc. as tentative - * definitions; mes/mes_open.c later assigns them initial values. - * Tentative-then-initialized is a standard C resolution; cc.scm - * follows the C linkage rule (commit 6488cca). - * 3. linux/malloc.c provides the allocator and the __brk pointer - * that posix/sbrk.c re-exports. - * - * Everything else is order-independent — each mes .c is a self-contained - * function or two with its own header includes. - */ - -#include <mes/lib.h> - -/* ---- low-level: P1pp syscall wrappers + thin posix glue --------- */ -#include "boot2-syscall.c" - -/* ---- ctype ------------------------------------------------------ */ -#include "ctype/isalnum.c" -#include "ctype/isalpha.c" -#include "ctype/isascii.c" -#include "ctype/iscntrl.c" -#include "ctype/isdigit.c" -#include "ctype/isgraph.c" -#include "ctype/islower.c" -#include "ctype/isnumber.c" -#include "ctype/isprint.c" -#include "ctype/ispunct.c" -#include "ctype/isspace.c" -#include "ctype/isupper.c" -#include "ctype/isxdigit.c" -#include "ctype/tolower.c" -#include "ctype/toupper.c" - -/* ---- string ----------------------------------------------------- */ -/* memcpy/memmove/memset/memcmp are compiler-builtin runtime supplied - by libp1pp (see P1/P1pp.P1pp). Omit mes-libc's copies so the - symbols are not duplicated at hex2++ link time. */ -#include "string/memchr.c" -#include "string/memmem.c" -#include "string/strcat.c" -#include "string/strchr.c" -#include "string/strcmp.c" -#include "string/strcpy.c" -#include "string/strcspn.c" -#include "string/strdup.c" -#include "string/strerror.c" -#include "string/strlen.c" -#include "string/strncat.c" -#include "string/strncmp.c" -#include "string/strncpy.c" -#include "string/strpbrk.c" -#include "string/strrchr.c" -#include "string/strspn.c" -#include "string/strstr.c" -#include "string/strupr.c" - -/* ---- mes runtime ------------------------------------------------ */ -#include "mes/globals.c" -#include "mes/cast.c" -#include "mes/__assert_fail.c" -#include "mes/abtol.c" -#include "mes/dtoab.c" -#include "mes/eputc.c" -#include "mes/eputs.c" -#include "mes/fdgetc.c" -#include "mes/fdgets.c" -#include "mes/fdputc.c" -#include "mes/fdputs.c" -#include "mes/fdungetc.c" -#include "mes/__buffered_read.c" -#include "mes/__init_io.c" -#include "mes/__mes_debug.c" -#include "mes/itoa.c" -#include "mes/ltoa.c" -#include "mes/ltoab.c" -#include "mes/mes_open.c" -#include "mes/ntoab.c" -#include "mes/oputc.c" -#include "mes/oputs.c" -#include "mes/search-path.c" -#include "mes/ultoa.c" -#include "mes/utoa.c" - -/* ---- stdlib ----------------------------------------------------- */ -#include "stdlib/__exit.c" -#include "stdlib/abort.c" -#include "stdlib/atoi.c" -#include "stdlib/atol.c" -#include "stdlib/calloc.c" -#include "stdlib/exit.c" -#include "stdlib/free.c" -#include "stdlib/puts.c" -#include "stdlib/qsort.c" -#include "stdlib/realloc.c" -#include "stdlib/strtof.c" -#include "stdlib/strtol.c" -#include "stdlib/strtoll.c" -#include "stdlib/strtoul.c" -#include "stdlib/strtoull.c" - -/* ---- linux (allocator only; the rest replaced by boot2-syscall.c) */ -#include "linux/malloc.c" - -/* ---- posix ------------------------------------------------------ */ -#include "posix/buffered-read.c" -#include "posix/execvp.c" -#include "posix/getcwd.c" -#include "posix/getenv.c" -#include "posix/open.c" -#include "posix/sbrk.c" -#include "posix/write.c" - -/* ---- stdio ------------------------------------------------------ */ -#include "stdio/clearerr.c" -#include "stdio/fclose.c" -#include "stdio/fdopen.c" -#include "stdio/feof.c" -#include "stdio/ferror.c" -#include "stdio/fflush.c" -#include "stdio/fgetc.c" -#include "stdio/fgets.c" -#include "stdio/fileno.c" -#include "stdio/fopen.c" -#include "stdio/fprintf.c" -#include "stdio/fputc.c" -#include "stdio/fputs.c" -#include "stdio/fread.c" -#include "stdio/fseek.c" -#include "stdio/ftell.c" -#include "stdio/fwrite.c" -#include "stdio/getc.c" -#include "stdio/perror.c" -#include "stdio/printf.c" -#include "stdio/putc.c" -#include "stdio/remove.c" -#include "stdio/snprintf.c" -#include "stdio/sprintf.c" -#include "stdio/ungetc.c" -#include "stdio/vfprintf.c" -#include "stdio/vprintf.c" -#include "stdio/vsnprintf.c" -#include "stdio/vsprintf.c"