Compare commits
25 Commits
wip-gcc4.2
...
master
Author | SHA1 | Date |
---|---|---|
Jan (janneke) Nieuwenhuizen | 1608f9f38a | |
Jan (janneke) Nieuwenhuizen | 7562330ec7 | |
Jan (janneke) Nieuwenhuizen | f0182ecf97 | |
Jan (janneke) Nieuwenhuizen | 56fed8d65e | |
Jan (janneke) Nieuwenhuizen | c824c62f85 | |
Jan (janneke) Nieuwenhuizen | 029a891d4e | |
Jan (janneke) Nieuwenhuizen | 43fe67e2f9 | |
R. Masters | b28f42de07 | |
Jan (janneke) Nieuwenhuizen | 1e14c26305 | |
Jan (janneke) Nieuwenhuizen | c1f93c1d71 | |
Jan (janneke) Nieuwenhuizen | dbb446d906 | |
Jan (janneke) Nieuwenhuizen | cfb620567a | |
Jan (janneke) Nieuwenhuizen | bc1fa57851 | |
Jan (janneke) Nieuwenhuizen | 25e0c4d119 | |
Jan (janneke) Nieuwenhuizen | 84fd995f43 | |
Jan (janneke) Nieuwenhuizen | 77602c2cde | |
Jan (janneke) Nieuwenhuizen | fc6e88ab89 | |
Jan (janneke) Nieuwenhuizen | 5f73e64480 | |
Gabriel Wicki | 580782bb72 | |
Jan (janneke) Nieuwenhuizen | ec12220737 | |
Ekaitz | f89fed3c3b | |
Ekaitz | 761420ac31 | |
Jan (janneke) Nieuwenhuizen | 5fc5983e50 | |
Jan (janneke) Nieuwenhuizen | 358ae145ab | |
Jan (janneke) Nieuwenhuizen | 2a1976b6de |
8
COPYING
8
COPYING
|
@ -1,7 +1,7 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
|
@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
|
|||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
|
|
32
HACKING
32
HACKING
|
@ -130,30 +130,30 @@ x/s *((char **)($rsp+8))
|
|||
|
||||
** C parser/compiler
|
||||
*** [[https://savannah.gnu.org/projects/nyacc][nyacc]]
|
||||
*** PEG: [[http://piumarta.com/software/peg/][parse C using PEG]]
|
||||
*** PEG: [[https://piumarta.com/software/peg/][parse C using PEG]]
|
||||
*** [[https://en.wikipedia.org/wiki/Tiny_C_Compiler][Tiny C Compiler]]
|
||||
*** [[http://www.t3x.org/subc/index.html][Sub C]]
|
||||
*** [[https://www.t3x.org/subc/index.html][Sub C]]
|
||||
*** [[https://groups.google.com/forum/#!topic/comp.lang.lisp/VPuX0VsjTTE][C intepreter in LISP/Scheme/Python]]
|
||||
|
||||
** C assembler/linker
|
||||
*** [[http://www.tldp.org/HOWTO/Assembly-HOWTO/linux.html][Assembly HOWTO]]
|
||||
*** [[https://www.tldp.org/HOWTO/Assembly-HOWTO/linux.html][Assembly HOWTO]]
|
||||
*** ELF
|
||||
7f 45 4c 46
|
||||
*** [[http://www.muppetlabs.com/~breadbox/software/tiny/][Small ELF programs]]
|
||||
*** [[http://www.cirosantilli.com/elf-hello-world/][Elf hello world]]
|
||||
*** [[https://www.muppetlabs.com/~breadbox/software/tiny/][Small ELF programs]]
|
||||
*** [[https://www.cirosantilli.com/elf-hello-world/][Elf hello world]]
|
||||
** SC - c as s-expressions
|
||||
sc: http://sph.mn/content/3d3
|
||||
sc: https://sph.mn/content/3d3
|
||||
** RNRS
|
||||
*** [[http://www.scheme-reports.org/][Scheme Reports]]
|
||||
*** [[https://www.scheme-reports.org/][Scheme Reports]]
|
||||
*** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-349.pdf][Scheme - Report on Scheme]]
|
||||
*** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-452.pdf][RRS - Revised Report on Scheme]]
|
||||
|
||||
** tiny schemes
|
||||
http://forum.osdev.org/viewtopic.php?f=15&t=19937
|
||||
https://forum.osdev.org/viewtopic.php?f=15&t=19937
|
||||
|
||||
http://www.stripedgazelle.org/joey/dreamos.html
|
||||
http://armpit.sourceforge.net/
|
||||
http://common-lisp.net/project/movitz/movitz.html
|
||||
https://www.stripedgazelle.org/joey/dreamos.html
|
||||
https://armpit.sourceforge.net/
|
||||
https://common-lisp.net/project/movitz/movitz.html
|
||||
|
||||
<civodul> janneke: https://github.com/namin/inc looks interesting [15:18]
|
||||
** Orians Jeremiah
|
||||
|
@ -170,13 +170,13 @@ http://common-lisp.net/project/movitz/movitz.html
|
|||
<janneke> OriansJ: i looked a few times and saw 'LISP empty', so thanks for
|
||||
the pointer! [00:24]
|
||||
<civodul> OriansJ, janneke: from that page, there's also:
|
||||
https://web.archive.org/web/20160604035203fw_/http://homepage.ntlworld.com/edmund.grimley-evans/bcompiler.html
|
||||
https://web.archive.org/web/20160604035203fw_/https://homepage.ntlworld.com/edmund.grimley-evans/bcompiler.html
|
||||
|
||||
** C4/C500
|
||||
https://web.archive.org/web/20160604041431/http://homepage.ntlworld.com/edmund.grimley-evans/cc500/cc500.c
|
||||
https://web.archive.org/web/20160604041431/https://homepage.ntlworld.com/edmund.grimley-evans/cc500/cc500.c
|
||||
https://github.com/rswier/c4/blob/master/c4.c
|
||||
** Compilers for free
|
||||
http://codon.com/compilers-for-free
|
||||
https://codon.com/compilers-for-free
|
||||
** Small lisps
|
||||
*** [[https://www.mirrorservice.org/sites/www.bitsavers.org/bits/TI/Explorer/zeta-c/][ZETA-C]]
|
||||
** Small C compilers
|
||||
|
@ -188,10 +188,10 @@ simple as possible.
|
|||
*** pcc
|
||||
*** early GCC?
|
||||
https://miyuki.github.io/2017/10/04/gcc-archaeology-1.html
|
||||
*** [[http://tack.sourceforge.net/][ack]]
|
||||
*** [[https://tack.sourceforge.net/][ack]]
|
||||
<rain1> it may be possible to compile like this: mes |> ack |> pcc |> tcc |>
|
||||
gcc 4.7.4 |> gcc later version... up to modern
|
||||
*** [[https://web.archive.org/web/20160402225843/http://homepage.ntlworld.com/edmund.grimley-evans/cc500/][cc500]]
|
||||
*** [[https://web.archive.org/web/20160402225843/https://homepage.ntlworld.com/edmund.grimley-evans/cc500/][cc500]]
|
||||
** rain1's Bootstrapping Wiki: https://bootstrapping.miraheze.org/wiki/Main_Page
|
||||
** rain1's hex86
|
||||
https://notabug.org/rain1/hex86/src/master/tests/hex0b3.hex86
|
||||
|
|
18
NEWS
18
NEWS
|
@ -2,7 +2,7 @@
|
|||
#+TITLE: GNU Mes NEWS – history of user-visible changes
|
||||
#+STARTUP: content hidestars
|
||||
|
||||
Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
Copyright © 2016,2017,2018,2019,2021,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
|
@ -10,6 +10,22 @@ Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@
|
|||
|
||||
Please send Mes bug reports to bug-mes@gnu.org.
|
||||
|
||||
* Changes in 0.24.2 since 0.24.1
|
||||
** Build
|
||||
*** A number of compile warnings have been fixed.
|
||||
*** The `simple.make' and `simple.sh' builds have been resurrected.
|
||||
** MesCC
|
||||
*** Some assembly defines were added for building TinyCC for x86_64.
|
||||
*** `__assert_fail' has been updated to use the standard signature.
|
||||
** Noteworthy bug fixes
|
||||
*** A bootstrap build without M2-Planet is now supported again.
|
||||
*** `gettimeofday' no longer segfaults in the M2-Planet build.
|
||||
*** `stat64' and friends are now used on 32bit platforms.
|
||||
This fixes https://debbugs.gnu.org/41264, and should also fix
|
||||
https://debbugs.gnu.org/49985,
|
||||
https://debbugs.gnu.org/53415,
|
||||
https://debbugs.gnu.org/53416.
|
||||
*** The Mes C Library now supports uppercase hex conversions.
|
||||
* Changes in 0.24.1 since 0.24
|
||||
** Build
|
||||
*** Support M2-Planet bootstrap for ARM.
|
||||
|
|
6
README
6
README
|
@ -7,7 +7,7 @@
|
|||
System. Since version 0.22 it has again helped to halve the size of
|
||||
opaque, uninspectable binary seeds that are currently being used in the
|
||||
[[https://guix.gnu.org/blog/2020/guix-further-reduces-bootstrap-seed-to-25][Further Reduced Binary Seed bootstrap]] of [[https://www.gnu.org/software/guix][GNU Guix]]. The final goal is to
|
||||
help create a full-source bootstrap as part of the [[http://bootstrappable.org][bootstrappable builds]]
|
||||
help create a full-source bootstrap as part of the [[https://bootstrappable.org][bootstrappable builds]]
|
||||
effort for UNIX-like operating systems.
|
||||
|
||||
The Scheme interpreter is written in ~5,000 LOC of simple C, and the C
|
||||
|
@ -25,7 +25,7 @@ Reduced Binary Seed bootstrap for the gnutools triplet: glibc-2.2.5,
|
|||
binutils-2.20.1, gcc-2.95.3. This is enough to bootstrap Guix for
|
||||
i686-linux, x86_64-linux, armhf-linux and aarch64-linux.
|
||||
|
||||
Mes is inspired by The Maxwell Equations of Software: [[http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf][LISP-1.5]] -- John
|
||||
Mes is inspired by The Maxwell Equations of Software: [[https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf][LISP-1.5]] -- John
|
||||
McCarthy page 13, GNU Guix's source/binary packaging transparency and
|
||||
Jeremiah Orians's [[https://github.com/oriansj/stage0][stage0]] ~500 byte self-hosting hex assembler.
|
||||
|
||||
|
@ -76,7 +76,7 @@ General Public Licence version 3 or later. See the file [[file:COPYING][COPYING
|
|||
[7] https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html
|
||||
[8] https://www.nongnu.org/nyacc
|
||||
[9] https://gitlab.com/janneke/tinycc
|
||||
[10] [[http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf]]
|
||||
[10] [[https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf]]
|
||||
[11] https://savannah.nongnu.org/projects/stage0
|
||||
[12] https://nlnet.nl/project/GNUMes
|
||||
[13] https://nlnet.nl/project/GNUMes-arm
|
||||
|
|
5
ROADMAP
5
ROADMAP
|
@ -1,7 +1,7 @@
|
|||
-*- org -*-
|
||||
#+TITLE: Tentative GNU Mes Road Map
|
||||
|
||||
Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
Copyright © 2016,2017,2018,2019,2020,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
|
@ -23,6 +23,9 @@ on Libera Chat!
|
|||
|
||||
* TODO
|
||||
** release 0.x, unsorted
|
||||
- Full Guile module support.
|
||||
- Run Gash and Gash-Utils on Mes.
|
||||
- Remove Guile as a dependency for the Guix Full Source Bootstrap.
|
||||
- Integrate Full Source bootstrap for ARM on GNU Guix;
|
||||
see branch wip-aarch64-bootstrap.
|
||||
- Integrate Reduced Binary Seed bootstrap for ARM on GNU Guix;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2018,2019,2021,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -85,17 +85,26 @@ PHONY_TARGETS:=\
|
|||
|
||||
.PHONY: $(PHONY_TARGETS)
|
||||
|
||||
X86_ARCH_HEADERS = $(wildcard $(scrdest)include/linux/x86/*.h)
|
||||
ARCH_HEADERS = $(X86_ARCH_HEADERS:$(srcdest)include/linux/x86/%=include/arch/%)
|
||||
|
||||
default: all
|
||||
|
||||
all: doc
|
||||
|
||||
doc: build
|
||||
|
||||
build:
|
||||
build: | $(ARCH_HEADERS)
|
||||
$(SHELL) build.sh
|
||||
|
||||
src/${program_prefix}mes: build
|
||||
|
||||
include/arch/%.h: $(srcdest)include/$(mes_kernel)/$(mes_cpu)/%.h | arch-dir
|
||||
cp -f $< $@
|
||||
|
||||
arch-dir:
|
||||
mkdir -p include/arch
|
||||
|
||||
clean:
|
||||
rm -f *.o *.s bin/mes bin/mes-gcc bin/mes-mescc
|
||||
rm -f mes.{aux,cp,cps,fn,info,log,tmp,toc,vr,vrs}
|
||||
|
@ -348,6 +357,7 @@ tag:
|
|||
# 1. Tag for release
|
||||
# make tag VERSION=0.23
|
||||
# 2. Create signed tarball
|
||||
# ./configure
|
||||
# make sign-dist
|
||||
# 3. Update Guix package description
|
||||
# make release
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! @SHELL@
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -54,18 +54,16 @@ AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ../include -I include"
|
|||
AM_CFLAGS="-L ${srcdest}lib"
|
||||
|
||||
mkdir -p $mes_cpu-mes
|
||||
cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c .
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS crt1.c
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c
|
||||
cp crt1.o $mes_cpu-mes
|
||||
cp crt1.s $mes_cpu-mes
|
||||
|
||||
objects=
|
||||
for c in $libc_mini_SOURCES; do
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
o=$b.o
|
||||
o=$(basename $c .c).o
|
||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
fi
|
||||
objects="$objects $o"
|
||||
done
|
||||
|
@ -74,11 +72,10 @@ $AR crD $mes_cpu-mes/libc-mini.a $objects
|
|||
|
||||
objects=
|
||||
for c in $libmescc_SOURCES; do
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
o=$b.o
|
||||
o=$(basename $c .c).o
|
||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
fi
|
||||
objects="$objects $o"
|
||||
done
|
||||
|
@ -87,11 +84,10 @@ $AR crD $mes_cpu-mes/libmescc.a $objects
|
|||
|
||||
objects=
|
||||
for c in $libc_SOURCES; do
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
o=$b.o
|
||||
o=$(basename $c .c).o
|
||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
fi
|
||||
objects="$objects $o"
|
||||
done
|
||||
|
@ -100,11 +96,10 @@ $AR crD $mes_cpu-mes/libc.a $objects
|
|||
|
||||
objects=
|
||||
for c in $libc_tcc_SOURCES; do
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
o=$b.o
|
||||
o=$(basename $c .c).o
|
||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
fi
|
||||
objects="$objects $o"
|
||||
done
|
||||
|
@ -118,11 +113,10 @@ AM_CFLAGS="-L ${srcdest}lib"
|
|||
|
||||
objects=
|
||||
for c in $mes_SOURCES; do
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
o=$b.o
|
||||
o=$(basename $c .c).o
|
||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
fi
|
||||
objects="$objects $o"
|
||||
done
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -26,8 +26,7 @@
|
|||
trap 'test -f .log && cat .log' EXIT
|
||||
|
||||
mkdir -p $mes_cpu-mes
|
||||
cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c .
|
||||
compile crt1.c
|
||||
compile lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c
|
||||
cp crt1.o $mes_cpu-mes
|
||||
if test -e crt1.s; then
|
||||
cp crt1.s $mes_cpu-mes
|
||||
|
|
|
@ -150,6 +150,7 @@ fi
|
|||
${SHELL} ${srcdest}build-aux/build-lib.sh
|
||||
${SHELL} ${srcdest}build-aux/build-source-lib.sh
|
||||
if $bootstrap; then
|
||||
rm -f globals.* # FIXME: avoid name clash with globals from lib
|
||||
${SHELL} ${srcdest}build-aux/build-mes.sh
|
||||
cp -f bin/mes-mescc ../bin
|
||||
cp -f bin/mes ../bin
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -18,12 +18,8 @@
|
|||
|
||||
objects=
|
||||
compile () {
|
||||
if test $(dirname $1) = "."; then
|
||||
c=$1
|
||||
else
|
||||
c=${srcdest}$1
|
||||
fi
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
c=${srcdest}$1
|
||||
b=$(basename $c .c)
|
||||
o=$b.o
|
||||
objects="$objects $o"
|
||||
if test ! -e $o -o $c -nt $o; then
|
||||
|
@ -38,7 +34,7 @@ archive () {
|
|||
sources="$@"
|
||||
objects=
|
||||
for c in $sources; do
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
b=$(basename $c .c)
|
||||
o=$b.o
|
||||
compile $c
|
||||
done
|
||||
|
|
|
@ -201,7 +201,6 @@ lib/tests/setjmp/80-setjmp.c
|
|||
lib/tests/stdio/80-sscanf.c
|
||||
lib/tests/stdlib/80-qsort.c
|
||||
lib/tests/stdlib/80-qsort-dupes.c
|
||||
lib/tests/stdlib/80-qsort-stress.c
|
||||
lib/tests/string/80-strncpy.c
|
||||
lib/tests/string/80-strrchr.c
|
||||
lib/tests/scaffold/82-define.c
|
||||
|
@ -216,7 +215,6 @@ lib/tests/io/90-stat.c
|
|||
lib/tests/mes/90-abtod.c
|
||||
lib/tests/mes/90-dtoab.c
|
||||
lib/tests/posix/90-execlp.c
|
||||
lib/tests/posix/90-mmap.c
|
||||
lib/tests/posix/90-unsetenv.c
|
||||
lib/tests/signal/90-signal.c
|
||||
lib/tests/stdio/90-fopen.c
|
||||
|
@ -224,7 +222,6 @@ lib/tests/stdio/90-fopen-append.c
|
|||
lib/tests/stdio/90-fread-fwrite.c
|
||||
lib/tests/stdio/90-fseek.c
|
||||
lib/tests/stdio/90-sprintf.c
|
||||
lib/tests/stdio/90-sscanf.c
|
||||
lib/tests/stdlib/90-strtol.c
|
||||
lib/tests/string/90-snprintf.c
|
||||
lib/tests/string/90-strpbrk.c
|
||||
|
@ -293,7 +290,6 @@ lib/tests/scaffold/70-extern.c
|
|||
lib/tests/stdio/80-sscanf.c
|
||||
lib/tests/posix/90-execlp.c
|
||||
lib/tests/string/90-snprintf.c
|
||||
lib/tests/stdio/90-sscanf.c
|
||||
"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -74,7 +74,7 @@ libc_mini_SOURCES="$libc_mini_shared_SOURCES"
|
|||
|
||||
if test $mes_libc = mes; then
|
||||
libc_mini_SOURCES="$libc_mini_SOURCES
|
||||
lib/mes/write.c
|
||||
lib/mes/mini-write.c
|
||||
"
|
||||
fi
|
||||
|
||||
|
@ -215,7 +215,6 @@ lib/linux/malloc.c
|
|||
lib/linux/_read.c
|
||||
lib/linux/time.c
|
||||
lib/linux/unlink.c
|
||||
lib/linux/wait4.c
|
||||
lib/linux/waitpid.c
|
||||
lib/linux/$mes_cpu-mes-$compiler/syscall.c
|
||||
lib/linux/getpid.c
|
||||
|
@ -250,7 +249,6 @@ lib/stdio/fclose.c
|
|||
lib/stdio/fdopen.c
|
||||
lib/stdio/ferror.c
|
||||
lib/stdio/fflush.c
|
||||
lib/stdio/fileno.c
|
||||
lib/stdio/fopen.c
|
||||
lib/stdio/fprintf.c
|
||||
lib/stdio/fread.c
|
||||
|
@ -321,11 +319,9 @@ lib/dirent/__getdirentries.c
|
|||
lib/dirent/closedir.c
|
||||
lib/dirent/opendir.c
|
||||
lib/dirent/readdir.c
|
||||
lib/locale/localeconv.c
|
||||
lib/math/ceil.c
|
||||
lib/math/fabs.c
|
||||
lib/math/floor.c
|
||||
lib/math/labs.c
|
||||
lib/mes/fdgets.c
|
||||
lib/posix/alarm.c
|
||||
lib/posix/execl.c
|
||||
|
@ -337,10 +333,10 @@ lib/posix/unsetenv.c
|
|||
lib/stdio/clearerr.c
|
||||
lib/stdio/feof.c
|
||||
lib/stdio/fgets.c
|
||||
lib/stdio/fileno.c
|
||||
lib/stdio/freopen.c
|
||||
lib/stdio/fscanf.c
|
||||
lib/stdio/perror.c
|
||||
lib/stdio/rewind.c
|
||||
lib/stdio/vfscanf.c
|
||||
lib/stdlib/__exit.c
|
||||
lib/stdlib/abort.c
|
||||
|
@ -361,9 +357,7 @@ lib/string/strerror.c
|
|||
lib/string/strncat.c
|
||||
lib/string/strpbrk.c
|
||||
lib/string/strspn.c
|
||||
lib/string/strtok.c
|
||||
lib/stub/__cleanup.c
|
||||
lib/stub/asctime.c
|
||||
lib/stub/atan2.c
|
||||
lib/stub/bsearch.c
|
||||
lib/stub/chown.c
|
||||
|
@ -376,7 +370,6 @@ lib/stub/frexp.c
|
|||
lib/stub/getgrgid.c
|
||||
lib/stub/getgrnam.c
|
||||
lib/stub/getlogin.c
|
||||
lib/stub/getpagesize.c
|
||||
lib/stub/getpgid.c
|
||||
lib/stub/getpgrp.c
|
||||
lib/stub/getpwnam.c
|
||||
|
@ -389,6 +382,7 @@ lib/stub/pclose.c
|
|||
lib/stub/popen.c
|
||||
lib/stub/pow.c
|
||||
lib/stub/rand.c
|
||||
lib/stub/rewind.c
|
||||
lib/stub/setbuf.c
|
||||
lib/stub/setgrent.c
|
||||
lib/stub/setlocale.c
|
||||
|
@ -400,9 +394,7 @@ lib/stub/sigsetmask.c
|
|||
lib/stub/sin.c
|
||||
lib/stub/sqrt.c
|
||||
lib/stub/strftime.c
|
||||
lib/stub/strsignal.c
|
||||
lib/stub/sys_siglist.c
|
||||
lib/stub/sysconf.c
|
||||
lib/stub/system.c
|
||||
lib/stub/times.c
|
||||
lib/stub/ttyname.c
|
||||
|
@ -427,14 +419,12 @@ lib/linux/link.c
|
|||
lib/linux/lstat.c
|
||||
lib/linux/mkdir.c
|
||||
lib/linux/mknod.c
|
||||
lib/linux/mmap.c
|
||||
lib/linux/munmap.c
|
||||
lib/linux/nanosleep.c
|
||||
lib/linux/pipe.c
|
||||
lib/linux/readlink.c
|
||||
lib/linux/rename.c
|
||||
lib/linux/setgid.c
|
||||
lib/linux/setitimer.c
|
||||
lib/linux/settimer.c
|
||||
lib/linux/setuid.c
|
||||
lib/linux/signal.c
|
||||
lib/linux/sigprogmask.c
|
||||
|
|
|
@ -48,6 +48,7 @@ sed -ri \
|
|||
include/mes/mes.h \
|
||||
include/mes/symbols.h \
|
||||
include/mes/builtins.h \
|
||||
include/m2/lib.h \
|
||||
src/builtins.c \
|
||||
src/cc.c \
|
||||
src/core.c \
|
||||
|
|
|
@ -4,7 +4,7 @@ MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)'
|
|||
!#
|
||||
|
||||
;;; GNU Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2017,2018,2019,2020,2021,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2020 Vagrant Cascadian <vagrant@reproducible-builds.org>
|
||||
;;;
|
||||
;;; configure: This file is part of GNU Mes.
|
||||
|
@ -37,7 +37,7 @@ MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)'
|
|||
(define PACKAGE "mes")
|
||||
(define PACKAGE-NAME "GNU Mes")
|
||||
(define PACKAGE-BUGREPORT "bug-mes@gnu.org")
|
||||
(define VERSION "0.24.1")
|
||||
(define VERSION "0.24.2")
|
||||
|
||||
(cond-expand
|
||||
(guile)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2018,2019,2021,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
set -e
|
||||
|
||||
VERSION=0.24.1
|
||||
VERSION=0.24.2
|
||||
srcdir=${srcdir-$(dirname $0)}
|
||||
srcdest=
|
||||
if test "$srcdir" != "."; then
|
||||
|
|
|
@ -0,0 +1,117 @@
|
|||
|
||||
Subject: GNU Mes 0.24.2 released
|
||||
|
||||
<#secure method=pgpmime mode=sign>
|
||||
|
||||
We are happy to announce the release of GNU Mes 0.24.2, representing 25
|
||||
commits over nine months by four people.
|
||||
|
||||
This release should fix the long standing `stat64' bug #41264[0].
|
||||
|
||||
We are very grateful that the NLnet Foundation[1] is sponsoring this
|
||||
work!
|
||||
|
||||
What's next?
|
||||
|
||||
Work to prototype this so-called "Full Source Bootstrap" for ARM on
|
||||
Aarch64 is happening on the wip-aarch64-bootstrap[2] branch. Also, full
|
||||
Guile compatible module support, and RISC-V support.
|
||||
|
||||
Enjoy!
|
||||
|
||||
* About
|
||||
|
||||
GNU Mes[3] is a Scheme interpreter and C compiler for bootstrapping
|
||||
the GNU System. Since version 0.22 it has again helped to halve the
|
||||
size of opaque, uninspectable binary seeds that are currently being
|
||||
used in the Reduced Binary Seed bootstrap[4] of GNU Guix[5]. The
|
||||
final goal is to help create a full source bootstrap as part of the
|
||||
bootstrappable builds[6] effort for UNIX-like operating systems.
|
||||
|
||||
The Scheme interpreter is written in ~5,000 LOC of simple C, and the C
|
||||
compiler written in Scheme and these are mutual self-hosting. Mes can
|
||||
now be bootstrapped from M2-Planet[7] and Mescc-Tools[8].
|
||||
|
||||
Mes has a Garbage Collector, a library of loadable Scheme modules--
|
||||
notably Dominique Boucher's LALR[9], Pre-R6RS portable
|
||||
syntax-case[10] with R7RS ellipsis, Matt Wette's Nyacc[11] --and test
|
||||
suite, just enough to support a REPL and a C99 compiler: mescc.
|
||||
|
||||
Mes + MesCC + Mes C Library can build a bootstrappable TinyCC[12] that
|
||||
is self-hosting. Using this tcc and the Mes C library we now have a
|
||||
Reduced Binary Seed bootstrap for the gnutools triplet: glibc-2.2.5,
|
||||
binutils-2.20.1, gcc-2.95.3. This is enough to bootstrap Guix for
|
||||
i686-linux, x86_64-linux, armhf-linux and aarch64-linux.
|
||||
|
||||
Mes is inspired by The Maxwell Equations of Software: LISP-1.5[13] --
|
||||
John McCarthy page 13, GNU Guix's source/binary packaging transparency
|
||||
and Jeremiah Orians's stage0[14] 357-byte self-hosting hex assembler.
|
||||
|
||||
* Download
|
||||
|
||||
git clone git://git.savannah.gnu.org/mes.git
|
||||
|
||||
Here are the compressed sources and a GPG detached signature[*]:
|
||||
https://ftp.gnu.org/gnu/mes/mes-0.24.2.tar.gz
|
||||
https://ftp.gnu.org/gnu/mes/mes-0.24.2.tar.gz.sig
|
||||
|
||||
Use a mirror for higher download bandwidth:
|
||||
https://ftpmirror.gnu.org/mes/mes-0.24.2.tar.gz
|
||||
https://ftpmirror.gnu.org/mes/mes-0.24.2.tar.gz.sig
|
||||
|
||||
Here are the SHA1 and SHA256 checksums:
|
||||
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.24.2.tar.gz
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.24.2.tar.gz
|
||||
|
||||
[*] Use a .sig file to verify that the corresponding file (without the
|
||||
.sig suffix) is intact. First, be sure to download both the .sig file
|
||||
and the corresponding tarball. Then, run a command like this:
|
||||
|
||||
gpg --verify mes-0.24.2.tar.gz.sig
|
||||
|
||||
If that command fails because you don't have the required public key,
|
||||
or that public key has expired, try the following commands to update
|
||||
or refresh it, and then rerun the 'gpg --verify' command.
|
||||
|
||||
gpg --recv-keys 1A858392E331EAFDB8C27FFBF3C1A0D9C1D65273
|
||||
|
||||
* Get informed, get involved
|
||||
|
||||
See https://bootstrappable.org
|
||||
Join #bootstrappable on irc.libera.chat
|
||||
|
||||
* NEWS
|
||||
* Changes in 0.24.2 since 0.24.1
|
||||
** Build
|
||||
*** A number of compile warnings have been fixed.
|
||||
*** The `simple.make' and `simple.sh' builds have been resurrected.
|
||||
** MesCC
|
||||
*** Some assembly defines were added for building TinyCC for x86_64.
|
||||
*** `__assert_fail' has been updated to use the standard signature.
|
||||
** Noteworthy bug fixes
|
||||
*** A bootstrap build without M2-Planet is now supported again.
|
||||
*** `gettimeofday' no longer segfaults in the M2-Planet build.
|
||||
*** `stat64' and friends are now used on 32bit platforms.
|
||||
This fixes https://debbugs.gnu.org/41264, and should also fix
|
||||
https://debbugs.gnu.org/49985,
|
||||
https://debbugs.gnu.org/53415,
|
||||
https://debbugs.gnu.org/53416.
|
||||
*** The Mes C Library now supports uppercase hex conversions.
|
||||
|
||||
* Links
|
||||
[0] https://debbugs.gnu.org/41264
|
||||
[1] https://nlnet.nl/project/GNUMes-ARM_RISC-V
|
||||
[2] https://git.savannah.gnu.org/cgit/guix.git/log/?h=wip-aarch64-bootstrap
|
||||
[3] https://www.gnu.org/software/mes
|
||||
[4] https://guix.gnu.org/blog/2020/guix-further-reduces-bootstrap-seed-to-25
|
||||
[5] https://www.gnu.org/software/guix
|
||||
[6] https://bootstrappable.org
|
||||
[7] https://github.com/oriansj/m2-planet
|
||||
[8] https://savannah.nongnu.org/projects/mescc-tools
|
||||
[9] https://github.com/schemeway/lalr-scm
|
||||
[10] https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html
|
||||
[11] https://www.nongnu.org/nyacc
|
||||
[12] https://gitlab.com/janneke/tinycc
|
||||
[13] http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf
|
||||
[14] https://github.com/oriansj/stage0-posix
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
@display
|
||||
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
|
||||
@uref{http://fsf.org/}
|
||||
@uref{https://fsf.org/}
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
@ -414,7 +414,7 @@ The Free Software Foundation may publish new, revised versions
|
|||
of the GNU Free Documentation License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns. See
|
||||
@uref{http://www.gnu.org/copyleft/}.
|
||||
@uref{https://www.gnu.org/copyleft/}.
|
||||
|
||||
Each version of the License is given a distinguishing version number.
|
||||
If the Document specifies that a particular numbered version of this
|
||||
|
|
20
doc/mes.texi
20
doc/mes.texi
|
@ -204,7 +204,7 @@ Freedom 1.
|
|||
@section Reproducible Builds
|
||||
|
||||
The current Reproducible Builds effort incubated in the Debian
|
||||
project@footnote{@url{http://debian.org, The Debian Project}} and was
|
||||
project@footnote{@url{https://debian.org, The Debian Project}} and was
|
||||
organized by Lunar. Quoting the Reproducible Builds
|
||||
website@footnote{@url{https://reproducible-builds.org/,Reproducible
|
||||
Builds}}
|
||||
|
@ -365,7 +365,7 @@ Most computers work pretty well so apparently there is not a pressing
|
|||
need to inspect and study all of these codes. At the same time it is
|
||||
tricky to fully trust@footnote{ Ken Thompson's 1984 Turing award
|
||||
acceptance speech
|
||||
@url{http://www.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf,
|
||||
@url{https://www.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf,
|
||||
Reflections on Trusting Tust}.} a computer that was bootstrapped in this
|
||||
way.
|
||||
|
||||
|
@ -461,7 +461,7 @@ and mescc-tools can be removed.
|
|||
As fate would have it, I stumbled upon this
|
||||
@url{https://queue.acm.org/detail.cfm?id=1039523, interview with Alan
|
||||
Kay}, where he shares a revelation he had when reading John McCarthy's
|
||||
@url{http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf,
|
||||
@url{https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf,
|
||||
LISP-1.5} manual:
|
||||
|
||||
@quotation
|
||||
|
@ -553,11 +553,11 @@ in the Mes source tree for additional details.
|
|||
GNU Mes depends on the following packages:
|
||||
|
||||
@itemize
|
||||
@item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.13 or
|
||||
@item @url{https://gnu.org/software/guile/, GNU Guile}, version 2.0.13 or
|
||||
later, including 2.2.x and 3.0.x,
|
||||
@item @url{http://www.gnu.org/software/make/, GNU Make}.
|
||||
@item @url{https://www.gnu.org/software/make/, GNU Make}.
|
||||
@item @url{https://savannah.gnu.org/projects/nyacc/, NYACC}, version 1.00.2,
|
||||
@item @url{http://gcc.gnu.org, GCC's gcc}, version 2.95.3 or later, including 10.2.0,
|
||||
@item @url{https://gcc.gnu.org, GCC's gcc}, version 2.95.3 or later, including 10.2.0,
|
||||
@item @url{https://savannah.gnu.org/projects/mescc-tools/, mescc-tools}, version 1.4.0,
|
||||
@end itemize
|
||||
|
||||
|
@ -693,7 +693,7 @@ responsibility.
|
|||
The Reduced Binary Seed bootstrap currently adopted by Guix@footnote{See
|
||||
@file{gnu/packages/commencement.scm} in the @var{master} branch in Guix
|
||||
git
|
||||
@url{http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/commencement.scm}}.
|
||||
@url{https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/commencement.scm}}.
|
||||
In its intiial form it is only available for x86-linux and armhf-linux.
|
||||
|
||||
Currently, it goes like this:
|
||||
|
@ -1155,8 +1155,8 @@ Porting MesCC:
|
|||
The Perfect Setup to hack on Mes is basically the perfect setup used
|
||||
for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
|
||||
Manual}). First, you need more than an editor, you need
|
||||
@url{http://www.gnu.org/software/emacs, Emacs}, empowered by the
|
||||
wonderful @url{http://nongnu.org/geiser/, Geiser}.
|
||||
@url{https://www.gnu.org/software/emacs, Emacs}, empowered by the
|
||||
wonderful @url{https://nongnu.org/geiser/, Geiser}.
|
||||
|
||||
Geiser allows for interactive and incremental development from within
|
||||
Emacs: code compilation and evaluation from within buffers, access to
|
||||
|
@ -1181,7 +1181,7 @@ Scheme code in Mes is written in a purely functional style.
|
|||
@cindex coding style
|
||||
When writing Scheme code, we follow common wisdom among Scheme
|
||||
programmers. In general, we follow the
|
||||
@url{http://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
|
||||
@url{https://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
|
||||
Style Rules}. This document happens to describe the conventions mostly
|
||||
used in Guile’s code too. It is very thoughtful and well written, so
|
||||
please do read it.
|
||||
|
|
|
@ -87,7 +87,7 @@ get_machine.")
|
|||
(define-public m2-planet
|
||||
(package
|
||||
(name "m2-planet")
|
||||
(version "1.10.0")
|
||||
(version "1.9.0")
|
||||
(source (origin
|
||||
(method git-fetch)
|
||||
(uri (git-reference
|
||||
|
@ -97,7 +97,7 @@ get_machine.")
|
|||
(file-name (git-file-name name version))
|
||||
(sha256
|
||||
(base32
|
||||
"03ixvfdzhyy1d94iqpwl0p924pdvdp7yq4ggm05w3c013kzy2y12"))))
|
||||
"0cgvvq91cbxxm93k8ayyvhpaf3c2lv10qw4wyqwn3hc1qb1cfyvr"))))
|
||||
(native-inputs (list mescc-tools))
|
||||
(build-system gnu-build-system)
|
||||
(arguments
|
||||
|
@ -183,13 +183,13 @@ extensive examples, including parsers for the Javascript and C99 languages.")
|
|||
(define-public mes
|
||||
(package
|
||||
(name "mes")
|
||||
(version #!mes!# "0.24.1")
|
||||
(version #!mes!# "0.24.2")
|
||||
(source (origin
|
||||
(method url-fetch)
|
||||
(uri (string-append
|
||||
"https://ftp.gnu.org/pub/gnu/mes/mes-" version ".tar.gz"))
|
||||
(sha256
|
||||
(base32 #!mes!# "0246sy5zm49zw4zs87hrq1j1x74mchijh4rlj2mzlwjccha5cybs"))))
|
||||
(base32 #!mes!# "0vp8v88zszh1imm3dvdfi3m8cywshdj7xcrsq4cgmss69s2y1nkx"))))
|
||||
(build-system gnu-build-system)
|
||||
(supported-systems '("aarch64-linux" "armhf-linux" "i686-linux" "x86_64-linux"))
|
||||
(propagated-inputs (list mescc-tools nyacc))
|
||||
|
@ -238,7 +238,7 @@ Guile.")
|
|||
(license gpl3+)))
|
||||
|
||||
(define-public mes.git
|
||||
(let ((version #!mes!# "0.24.1")
|
||||
(let ((version #!mes!# "0.24.2")
|
||||
(revision "0")
|
||||
(commit (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ))))
|
||||
(package
|
||||
|
|
|
@ -69,11 +69,8 @@
|
|||
#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode)
|
||||
int dup (int old);
|
||||
int dup2 (int old, int new);
|
||||
|
||||
#if !__M2__
|
||||
int fcntl (int filedes, int command, ...);
|
||||
int open (char const *s, int flags, ...);
|
||||
#endif
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
|
|
|
@ -29,19 +29,6 @@
|
|||
#define DBL_MIN_EXP -1021
|
||||
#define LDBL_MIN_EXP -1021
|
||||
|
||||
// gcc-4.6
|
||||
#define DBL_EPSILON 1
|
||||
#define DBL_MANT_DIG 1
|
||||
#define DBL_MAX INT_MAX
|
||||
#define DBL_MIN INT_MIN
|
||||
|
||||
#define FLT_RADIX 10
|
||||
|
||||
#define LDBL_EPSILON 1
|
||||
#define LDBL_MANT_DIG 1
|
||||
#define LDBL_MAX INT_MAX
|
||||
#define LDBL_MIN INT_MIN
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
#endif // __MES_FLOAT_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -17,17 +17,9 @@
|
|||
* 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 <mes/lib.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <arch/syscall.h>
|
||||
|
||||
void
|
||||
__buffered_read_init (int filedes)
|
||||
{
|
||||
}
|
||||
|
||||
size_t
|
||||
__buffered_read_clear (int filedes)
|
||||
{
|
||||
}
|
||||
#endif // __MES_GNU_X86_KERNEL_STAT_H
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -33,7 +33,6 @@
|
|||
|
||||
#define MB_CUR_MAX 1
|
||||
#define NAME_MAX 255
|
||||
#define PAGE_SIZE 4096
|
||||
#define PATH_MAX 512
|
||||
#define _POSIX_OPEN_MAX 16
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include <arch/syscall.h>
|
||||
|
||||
#if __SIZEOF_LONG_LONG__ != 8
|
||||
|
||||
// *INDENT-OFF*
|
||||
struct stat
|
||||
{
|
||||
|
@ -46,8 +48,10 @@ struct stat
|
|||
unsigned long __pad0;
|
||||
unsigned long __pad1;
|
||||
};
|
||||
#if __SIZEOF_LONG_LONG__ == 8
|
||||
struct stat64
|
||||
|
||||
#else // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
struct stat
|
||||
{
|
||||
unsigned long long st_dev;
|
||||
unsigned char __pad0[4];
|
||||
|
@ -70,14 +74,6 @@ struct stat64
|
|||
unsigned long long st_ino;
|
||||
};
|
||||
|
||||
#define stat stat64
|
||||
#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 // HAVE_LONG_LONG
|
||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
#endif // __MES_LINUX_ARM_KERNEL_STAT_H
|
||||
|
|
|
@ -25,29 +25,47 @@
|
|||
|
||||
/* libc-mini */
|
||||
#ifndef SYS_exit
|
||||
// CONSTANT SYS_exit 0x01
|
||||
#define SYS_exit 0x01
|
||||
#endif
|
||||
#ifndef SYS_write
|
||||
// CONSTANT SYS_write 0x04
|
||||
#define SYS_write 0x04
|
||||
#endif
|
||||
|
||||
/* libc */
|
||||
// CONSTANT SYS_fork 0x02
|
||||
#define SYS_fork 0x02
|
||||
// CONSTANT SYS_read 0x03
|
||||
#define SYS_read 0x03
|
||||
// CONSTANT SYS_open 0x05
|
||||
#define SYS_open 0x05
|
||||
//#define SYS_waitpid
|
||||
// CONSTANT SYS_wait4 0x72
|
||||
#define SYS_wait4 0x72
|
||||
// CONSTANT SYS_execve 0x0b
|
||||
#define SYS_execve 0x0b
|
||||
// CONSTANT SYS_chmod 0x0f
|
||||
#define SYS_chmod 0x0f
|
||||
// CONSTANT SYS_access 0x21
|
||||
#define SYS_access 0x21
|
||||
// CONSTANT SYS_brk 0x2d
|
||||
#define SYS_brk 0x2d
|
||||
// CONSTANT SYS_ioctl 0x36
|
||||
#define SYS_ioctl 0x36
|
||||
// CONSTANT SYS_fsync 0x76
|
||||
#define SYS_fsync 0x76
|
||||
// CONSTANT SYS_getcwd 0xb7
|
||||
#define SYS_getcwd 0xb7
|
||||
// CONSTANT SYS_dup 0x29
|
||||
#define SYS_dup 0x29
|
||||
// CONSTANT SYS_dup2 0x3f
|
||||
#define SYS_dup2 0x3f
|
||||
// CONSTANT SYS_unlink 0x0a
|
||||
#define SYS_unlink 0x0a
|
||||
// CONSTANT SYS_gettimeofday 0x4e
|
||||
#define SYS_gettimeofday 0x4e
|
||||
// CONSTANT SYS_clock_gettime 0x107
|
||||
#define SYS_clock_gettime 0x107
|
||||
|
||||
/* libc+tcc */
|
||||
|
@ -55,7 +73,6 @@
|
|||
#define SYS_lseek 0x13
|
||||
#define SYS_rmdir 0x28
|
||||
#define SYS_stat 0x6a
|
||||
#define SYS_stat64 0xc3
|
||||
|
||||
/* libc+gnu */
|
||||
#define SYS_chdir 0x0c
|
||||
|
@ -72,10 +89,8 @@
|
|||
#define SYS_fcntl 0x37
|
||||
#define SYS_getrusage 0x4d
|
||||
#define SYS_lstat 0x6b
|
||||
#define SYS_lstat64 0xc4
|
||||
#define SYS_setitimer 0x68
|
||||
#define SYS_fstat 0x6c
|
||||
#define SYS_fstat64 0xc5
|
||||
#define SYS_nanosleep 0xa2
|
||||
#define SYS_getdents 0x8d
|
||||
|
||||
|
@ -94,8 +109,23 @@
|
|||
#define SYS_readlink 0x55
|
||||
#define SYS_mknod 0x0e
|
||||
|
||||
// gcc-4.6.4
|
||||
#define SYS_mmap 0x5a
|
||||
#define SYS_munmap 0x5b
|
||||
#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 */
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
#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
|
||||
/* https://github.com/torvalds/linux/blob/master/arch/x86/include/uapi/asm/stat.h */
|
||||
|
||||
// *INDENT-OFF*
|
||||
/* *INDENT-OFF* */
|
||||
struct stat
|
||||
{
|
||||
unsigned st_dev;
|
||||
|
@ -44,4 +44,4 @@ struct stat
|
|||
unsigned __pad0;
|
||||
unsigned __pad1;
|
||||
};
|
||||
#endif // __LINUX_M2_KERNEL_STAT_H
|
||||
#endif /* __LINUX_M2_KERNEL_STAT_H */
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include <arch/syscall.h>
|
||||
|
||||
#if __SIZEOF_LONG_LONG__ != 8
|
||||
|
||||
// *INDENT-OFF*
|
||||
struct stat
|
||||
{
|
||||
|
@ -46,8 +48,10 @@ struct stat
|
|||
unsigned long __pad0;
|
||||
unsigned long __pad1;
|
||||
};
|
||||
#if __SIZEOF_LONG_LONG__ == 8
|
||||
struct stat64
|
||||
|
||||
#else // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
struct stat
|
||||
{
|
||||
unsigned long long st_dev;
|
||||
unsigned char __pad0[4];
|
||||
|
@ -70,14 +74,6 @@ struct stat64
|
|||
unsigned long long st_ino;
|
||||
};
|
||||
|
||||
#define stat stat64
|
||||
#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 // HAVE_LONG_LONG
|
||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
#endif // __MES_LINUX_X86_KERNEL_STAT_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -22,30 +22,50 @@
|
|||
|
||||
/* libc-mini */
|
||||
#ifndef SYS_exit
|
||||
// CONSTANT SYS_exit 0x01
|
||||
#define SYS_exit 0x01
|
||||
#endif
|
||||
#ifndef SYS_write
|
||||
// CONSTANT SYS_write 0x04
|
||||
#define SYS_write 0x04
|
||||
#endif
|
||||
|
||||
/* libc */
|
||||
// CONSTANT SYS_fork 0x02
|
||||
#define SYS_fork 0x02
|
||||
// CONSTANT SYS_read 0x03
|
||||
#define SYS_read 0x03
|
||||
// CONSTANT SYS_open 0x05
|
||||
#define SYS_open 0x05
|
||||
// CONSTANT SYS_waitpid 0x07
|
||||
#define SYS_waitpid 0x07
|
||||
// CONSTANT SYS_wait4 0x72
|
||||
#define SYS_wait4 0x72
|
||||
// CONSTANT SYS_execve 0x0b
|
||||
#define SYS_execve 0x0b
|
||||
// CONSTANT SYS_chmod 0x0f
|
||||
#define SYS_chmod 0x0f
|
||||
// CONSTANT SYS_access 0x21
|
||||
#define SYS_access 0x21
|
||||
// CONSTANT SYS_brk 0x2d
|
||||
#define SYS_brk 0x2d
|
||||
// CONSTANT SYS_ioctl 0x36
|
||||
#define SYS_ioctl 0x36
|
||||
// CONSTANT SYS_fsync 0x76
|
||||
#define SYS_fsync 0x76
|
||||
// CONSTANT SYS_getcwd 0xb7
|
||||
#define SYS_getcwd 0xb7
|
||||
// CONSTANT SYS_dup 0x29
|
||||
#define SYS_dup 0x29
|
||||
// CONSTANT SYS_dup2 0x3f
|
||||
#define SYS_dup2 0x3f
|
||||
// CONSTANT SYS_unlink 0x0a
|
||||
#define SYS_unlink 0x0a
|
||||
// CONSTANT SYS_gettimeofday 0x4e
|
||||
#define SYS_gettimeofday 0x4e
|
||||
// CONSTANT SYS_clock_gettime 0x109
|
||||
#define SYS_clock_gettime 0x109
|
||||
// CONSTANT SYS_time 0x0d
|
||||
#define SYS_time 0x0d
|
||||
|
||||
/* libc+tcc */
|
||||
|
@ -53,7 +73,6 @@
|
|||
#define SYS_lseek 0x13
|
||||
#define SYS_rmdir 0x28
|
||||
#define SYS_stat 0x6a
|
||||
#define SYS_stat64 0xc3
|
||||
|
||||
/* libc+gnu */
|
||||
#define SYS_chdir 0x0c
|
||||
|
@ -72,10 +91,8 @@
|
|||
#define SYS_fcntl 0x37
|
||||
#define SYS_getrusage 0x4d
|
||||
#define SYS_lstat 0x6b
|
||||
#define SYS_lstat64 0xc4
|
||||
#define SYS_setitimer 0x68
|
||||
#define SYS_fstat 0x6c
|
||||
#define SYS_fstat64 0xc5
|
||||
#define SYS_nanosleep 0xa2
|
||||
#define SYS_getdents 0x8d
|
||||
|
||||
|
@ -94,8 +111,23 @@
|
|||
#define SYS_readlink 0x55
|
||||
#define SYS_mknod 0x0e
|
||||
|
||||
// gcc-4.6.4
|
||||
#define SYS_mmap 0x5a
|
||||
#define SYS_munmap 0x5b
|
||||
#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 */
|
||||
|
|
|
@ -85,8 +85,4 @@
|
|||
#define SYS_readlink 0x59
|
||||
#define SYS_mknod 0x85
|
||||
|
||||
// gcc-4.6.4
|
||||
#define SYS_mmap 0x09
|
||||
#define SYS_munmap 0x0b
|
||||
|
||||
#endif // __MES_LINUX_X86_64_SYSCALL_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -38,30 +38,6 @@
|
|||
#endif
|
||||
// *INDENT-ON*
|
||||
|
||||
struct lconv
|
||||
{
|
||||
char *decimal_point;
|
||||
char *thousands_sep;
|
||||
char *grouping;
|
||||
|
||||
char *int_curr_symbol;
|
||||
char *currency_symbol;
|
||||
char *mon_decimal_point;
|
||||
char *mon_thousands_sep;
|
||||
char *mon_grouping;
|
||||
char *positive_sign;
|
||||
char *negative_sign;
|
||||
char int_frac_digits;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_cs_precedes;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
};
|
||||
|
||||
struct lconv * localeconv (void);
|
||||
char *setlocale (int category, char const *locale);
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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 __M2_LIB_H
|
||||
#define __M2_LIB_H
|
||||
|
||||
char **environ;
|
||||
int __stdin;
|
||||
int __stdout;
|
||||
int __stderr;
|
||||
int errno;
|
||||
|
||||
// CONSTANT EOF 0xffffffff
|
||||
// CONSTANT __FILEDES_MAX 512
|
||||
|
||||
char* cast_intp_to_charp (int *i);
|
||||
char* cast_long_to_charp (long i);
|
||||
long cast_charp_to_long (char const *);
|
||||
long cast_int_to_long (int i);
|
||||
long cast_voidp_to_long (void const *);
|
||||
|
||||
char *itoa (int number);
|
||||
char *ltoa (long number);
|
||||
int __ungetc_p (int filedes);
|
||||
int eputs (char *s);
|
||||
int oputs (char *s);
|
||||
int puts (char *s);
|
||||
size_t strlen (char *s);
|
||||
ssize_t _write ();
|
||||
ssize_t write (int filedes, void *buffer, size_t size);
|
||||
void __ungetc_clear (int filedes);
|
||||
void __ungetc_init ();
|
||||
void __ungetc_set (int filedes, int c);
|
||||
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
struct timespec
|
||||
{
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
struct timeval
|
||||
{
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
|
||||
#endif /* __M2_LIB_H */
|
|
@ -0,0 +1,138 @@
|
|||
/* -*-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
|
||||
|
||||
/*
|
||||
#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
|
|
@ -31,7 +31,6 @@ double cos (double x);
|
|||
double exp (double x);
|
||||
double fabs (double number);
|
||||
double floor (double x);
|
||||
long int labs (long int number);
|
||||
double ldexp (double value, int exponent);
|
||||
double log (double x);
|
||||
double modf (double value, double *integer_part);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -23,32 +23,76 @@
|
|||
|
||||
/* Cell types */
|
||||
|
||||
// CONSTANT TCHAR 0
|
||||
#define TCHAR 0
|
||||
|
||||
// CONSTANT TBYTES 1
|
||||
#define TBYTES 1
|
||||
// CONSTANT TCLOSURE 2
|
||||
#define TCLOSURE 2
|
||||
// CONSTANT TCONTINUATION 3
|
||||
#define TCONTINUATION 3
|
||||
// CONSTANT TKEYWORD 4
|
||||
#define TKEYWORD 4
|
||||
// CONSTANT TMACRO 5
|
||||
#define TMACRO 5
|
||||
// CONSTANT TNUMBER 6
|
||||
#define TNUMBER 6
|
||||
// CONSTANT TPAIR 7
|
||||
#define TPAIR 7
|
||||
// CONSTANT TPORT 8
|
||||
#define TPORT 8
|
||||
// CONSTANT TREF 9
|
||||
#define TREF 9
|
||||
// CONSTANT TSPECIAL 10
|
||||
#define TSPECIAL 10
|
||||
// CONSTANT TSTRING 11
|
||||
#define TSTRING 11
|
||||
// CONSTANT TSTRUCT 12
|
||||
#define TSTRUCT 12
|
||||
// CONSTANT TSYMBOL 13
|
||||
#define TSYMBOL 13
|
||||
// CONSTANT TVALUES 14
|
||||
#define TVALUES 14
|
||||
// CONSTANT TVARIABLE 15
|
||||
#define TVARIABLE 15
|
||||
// CONSTANT TVECTOR 16
|
||||
#define TVECTOR 16
|
||||
// CONSTANT TBROKEN_HEART 17
|
||||
#define TBROKEN_HEART 17
|
||||
|
||||
/* Struct types */
|
||||
|
||||
// CONSTANT STRUCT_TYPE 0
|
||||
#define STRUCT_TYPE 0
|
||||
// CONSTANT STRUCT_PRINTER 1
|
||||
#define STRUCT_PRINTER 1
|
||||
|
||||
// CONSTANT GC_FRAME_SIZE 5
|
||||
#define GC_FRAME_SIZE 5
|
||||
// CONSTANT GC_FRAME_PROCEDURE 4
|
||||
#define GC_FRAME_PROCEDURE 4
|
||||
|
||||
// CONSTANT STDIN 0
|
||||
// CONSTANT STDOUT 1
|
||||
// CONSTANT STDERR 2
|
||||
|
||||
/* Unknown type 1
|
||||
// CONSTANT EOF -1
|
||||
*/
|
||||
|
||||
// CONSTANT O_RDONLY 0
|
||||
// CONSTANT O_WRONLY 1
|
||||
// CONSTANT O_CREAT 0x40
|
||||
// CONSTANT O_TRUNC 0x200
|
||||
|
||||
// CONSTANT PATH_MAX 1024
|
||||
// CONSTANT __FILEDES_MAX 512
|
||||
|
||||
// CONSTANT S_IRUSR 00400
|
||||
// CONSTANT S_IWUSR 00200
|
||||
|
||||
// CONSTANT CLOCK_PROCESS_CPUTIME_ID 2
|
||||
|
||||
|
||||
#endif /* __MES_CONSTANTS_H */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -25,27 +25,21 @@
|
|||
#include <mes/config.h>
|
||||
#endif
|
||||
|
||||
// CONSTANT STDIN 0
|
||||
#ifndef STDIN
|
||||
#define STDIN 0
|
||||
#endif
|
||||
|
||||
// CONSTANT STDOUT 1
|
||||
#ifndef STDOUT
|
||||
#define STDOUT 1
|
||||
#endif
|
||||
|
||||
// CONSTANT STDERR 2
|
||||
#ifndef STDERR
|
||||
#define STDERR 2
|
||||
#endif
|
||||
|
||||
/* M2-Planet does not support pointer arithmetic. Explicitly compensate
|
||||
for that by multiplying with M2_PTR_SIZE when using (char)
|
||||
pointers. */
|
||||
#if __M2__
|
||||
#define M2_PTR_SIZE 4
|
||||
#else
|
||||
#define M2_PTR_SIZE 1
|
||||
#endif
|
||||
|
||||
extern char **environ;
|
||||
extern int __stdin;
|
||||
extern int __stdout;
|
||||
|
@ -69,14 +63,10 @@ int oputs (char const *s);
|
|||
#ifndef __MES_SIZE_T
|
||||
#define __MES_SIZE_T
|
||||
#undef size_t
|
||||
#if __M2__
|
||||
typedef unsigned size_t;
|
||||
#else
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -23,9 +23,6 @@
|
|||
|
||||
#include <mes/lib-mini.h>
|
||||
|
||||
#define __FILEDES_MAX 512
|
||||
extern char *__brk;
|
||||
|
||||
char *cast_intp_to_charp (int const *i);
|
||||
char *cast_long_to_charp (long i);
|
||||
long cast_charp_to_long (char const *);
|
||||
|
@ -37,11 +34,14 @@ void __ungetc_init ();
|
|||
void __ungetc_clear (int filedes);
|
||||
void __ungetc_set (int filedes, int c);
|
||||
int __ungetc_p (int filedes);
|
||||
double abtod (char const **p, int base);
|
||||
long abtol (char const **p, int base);
|
||||
char *dtoab (double number, int base, int signed_p);
|
||||
char *itoa (int number);
|
||||
char *ltoa (long number);
|
||||
char *ltoab (long x, int base);
|
||||
char *ntoab (long number, unsigned base, int signed_p);
|
||||
char *ultoa (unsigned long number);
|
||||
char *utoa (unsigned number);
|
||||
int eputc (int c);
|
||||
int fdgetc (int fd);
|
||||
|
@ -61,12 +61,10 @@ char *search_path (char const *file_name);
|
|||
ssize_t _read (int fd, void *buffer, size_t size);
|
||||
void assert_msg (int check, char *msg);
|
||||
|
||||
long __mesabi_imod (long a, long b);
|
||||
long __mesabi_idiv (long a, long b);
|
||||
void *__memcpy (void *dest, void const *src, size_t n);
|
||||
void *__memmove (void *dest, void const *src, size_t n);
|
||||
void *__memset (void *s, int c, size_t n);
|
||||
int __raise (int signal);
|
||||
extern char *__brk;
|
||||
extern void (*__call_at_exit) (void);
|
||||
|
||||
#define __FILEDES_MAX 512
|
||||
|
||||
#if !SYSTEM_LIBC
|
||||
void __assert_fail (char const *s, char const *file, unsigned line,
|
||||
|
@ -77,15 +75,16 @@ void _exit (int code);
|
|||
long brk (void *addr);
|
||||
#endif // !SYSTEM_LIBC
|
||||
|
||||
#if !__M2__
|
||||
extern void (*__call_at_exit) (void);
|
||||
double abtod (char const **p, int base);
|
||||
char *dtoab (double number, int base, int signed_p);
|
||||
char *ultoa (unsigned long number);
|
||||
long __mesabi_imod (long a, long b);
|
||||
long __mesabi_idiv (long a, long b);
|
||||
unsigned long __mesabi_umod (unsigned long a, unsigned long b);
|
||||
unsigned long __mesabi_udiv (unsigned long a, unsigned long b);
|
||||
unsigned long __mesabi_uldiv (unsigned long a, unsigned long b,
|
||||
unsigned long *remainder);
|
||||
#endif
|
||||
|
||||
void *__memcpy (void *dest, void const *src, size_t n);
|
||||
void *__memmove (void *dest, void const *src, size_t n);
|
||||
void *__memset (void *s, int c, size_t n);
|
||||
int __raise (int signal);
|
||||
|
||||
#endif //__MES_LIB_H
|
||||
|
|
|
@ -53,15 +53,6 @@ struct scm
|
|||
};
|
||||
};
|
||||
|
||||
/* 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 12
|
||||
#else
|
||||
#define M2_CELL_SIZE 1
|
||||
#endif
|
||||
|
||||
/* mes */
|
||||
extern char *g_datadir;
|
||||
extern int g_debug;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -137,8 +137,14 @@ extern struct scm *cell_type_broken_heart;
|
|||
extern struct scm *cell_symbol_program;
|
||||
extern struct scm *cell_symbol_test;
|
||||
|
||||
// CONSTANT SYMBOL_MAX 114
|
||||
#define SYMBOL_MAX 114
|
||||
|
||||
// CONSTANT CELL_UNSPECIFIED 7
|
||||
#define CELL_UNSPECIFIED 7
|
||||
|
||||
// CONSTANT CELL_SYMBOL_RECORD_TYPE 82
|
||||
#define CELL_SYMBOL_RECORD_TYPE 82
|
||||
|
||||
|
||||
#endif /* __MES_SYMBOLS_H */
|
||||
|
|
|
@ -29,12 +29,9 @@
|
|||
|
||||
#define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long)))
|
||||
|
||||
#if !__M2__
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
unsigned long items[_SIGSET_NITEMS];
|
||||
} sigset_t;
|
||||
#endif
|
||||
typedef long stack_t;
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -94,7 +91,6 @@ typedef long stack_t;
|
|||
#define SA_NOMASK SA_NODEFER
|
||||
#define SA_ONESHOT SA_RESETHAND
|
||||
|
||||
#if !__M2__ // lacks short, casts
|
||||
typedef struct siginfo_t
|
||||
{
|
||||
int si_signo;
|
||||
|
@ -124,7 +120,7 @@ typedef struct siginfo_t
|
|||
} siginfo_t;
|
||||
// *INDENT-ON*
|
||||
|
||||
#if __M2__ || __MESC__
|
||||
#if __MESC__
|
||||
typedef long sighandler_t;
|
||||
#else
|
||||
typedef void (*sighandler_t) (int);
|
||||
|
@ -259,7 +255,6 @@ int sigemptyset (sigset_t * set);
|
|||
#endif
|
||||
int sigprocmask (int how, sigset_t const *set, sigset_t * oldset);
|
||||
|
||||
#endif // !__M2__
|
||||
#endif //! SYSTEM_LIBC
|
||||
|
||||
#endif // __MES_SIGNAL_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018 Peter De Wachter <pdewacht@gmail.com>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
|
@ -55,8 +55,10 @@ typedef unsigned short uint16_t;
|
|||
typedef short int16_t;
|
||||
typedef unsigned uint32_t;
|
||||
typedef int int32_t;
|
||||
#if __SIZEOF_LONG_LONG__ == 8
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef long long int64_t;
|
||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
typedef int intmax_t;
|
||||
typedef unsigned uintmax_t;
|
||||
|
@ -85,12 +87,6 @@ typedef unsigned uintmax_t;
|
|||
|
||||
#define INT_MIN -2147483648
|
||||
#define INT_MAX 2147483647
|
||||
|
||||
#define SHRT_MAX INT16_MAX
|
||||
#define SHRT_MIN INT16_MIN
|
||||
#define USHRT_MAX UINT16_MAX
|
||||
#define USHRT_MIN UINT16_MIN
|
||||
|
||||
#if __i386__ || __arm__
|
||||
#define LONG_MIN INT_MIN
|
||||
#define LONG_MAX INT_MAX
|
||||
|
@ -109,8 +105,6 @@ typedef unsigned uintmax_t;
|
|||
#define SIZE_MAX UINT64_MAX
|
||||
#endif
|
||||
|
||||
#define SSIZE_MAX LONG_MAX
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
#endif // __MES_STDINT_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -65,35 +65,30 @@ int ferror (FILE * stream);
|
|||
int fflush (FILE * stream);
|
||||
int fgetc (FILE * stream);
|
||||
char *fgets (char *s, int size, FILE * stream);
|
||||
int fileno (FILE *);
|
||||
int fprintf (FILE * stream, char const *format, ...);
|
||||
int fpurge (FILE * stream);
|
||||
int fputc (int c, FILE * stream);
|
||||
int fputs (char const *s, FILE * stream);
|
||||
int fscanf (FILE * stream, char const *template, ...);
|
||||
int fseek (FILE * stream, long offset, int whence);
|
||||
int getc (FILE * stream);
|
||||
int getchar (void);
|
||||
char *getlogin (void);
|
||||
int printf (char const *format, ...);
|
||||
int putc (int c, FILE * stream);
|
||||
int putchar (int c);
|
||||
int puts (char const *s);
|
||||
int remove (char const *file_name);
|
||||
void rewind (FILE * stream);
|
||||
int setvbuf (FILE * stream, char *buf, int mode, size_t size);
|
||||
int snprintf (char *str, size_t size, char const *format, ...);
|
||||
int sprintf (char *str, char const *format, ...);
|
||||
int sscanf (char const *str, char const *format, ...);
|
||||
int ungetc (int c, FILE * stream);
|
||||
long ftell (FILE * stream);
|
||||
size_t fread (void *ptr, size_t size, size_t count, FILE * stream);
|
||||
size_t freadahead (FILE * fp);
|
||||
size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream);
|
||||
|
||||
#if !__M2__
|
||||
int fprintf (FILE * stream, char const *format, ...);
|
||||
int fscanf (FILE * stream, char const *template, ...);
|
||||
int printf (char const *format, ...);
|
||||
int snprintf (char *str, size_t size, char const *format, ...);
|
||||
int sprintf (char *str, char const *format, ...);
|
||||
int sscanf (char const *str, char const *format, ...);
|
||||
#endif // !__M2__
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
#endif // __MES_STDIO_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -47,9 +47,7 @@ size_t strlen (char const *);
|
|||
char *strncpy (char *to, char const *from, size_t size);
|
||||
int strncmp (char const *, char const *, size_t);
|
||||
char *strrchr (char const *s, int c);
|
||||
char *strsignal (int signum);
|
||||
char *strstr (char const *haystack, char const *needle);
|
||||
char *strtok (char *new_string, char const *delimiters);
|
||||
char *strlwr (char *string);
|
||||
char *strupr (char *string);
|
||||
|
||||
|
|
|
@ -28,13 +28,8 @@
|
|||
|
||||
#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
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -25,25 +25,19 @@
|
|||
#include_next <sys/mman.h>
|
||||
#else // ! SYSTEM_LIBC
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MAP_SHARED 0x01
|
||||
#define MAP_PRIVATE 0x02
|
||||
#define MAP_ANONYMOUS 0x20
|
||||
#define MAP_POPULATE 0x08000
|
||||
|
||||
#define MAP_ANON MAP_ANONYMOUS
|
||||
#define MAP_FAILED ((void*)-1)
|
||||
#ifndef __MES_SIZE_T
|
||||
#define __MES_SIZE_T
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
|
||||
#define PROT_NONE 0
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define PROT_EXEC 4
|
||||
|
||||
void *mmap (void *address, size_t length, int protect, int flags, int filedes, off_t offset);
|
||||
int mprotect (void *addr, size_t len, int prot);
|
||||
int munmap (void *addr, size_t length);
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
#endif // __MES_SYS_MMAN_H
|
||||
|
||||
|
|
|
@ -32,20 +32,20 @@ struct rusage
|
|||
{
|
||||
struct timeval ru_utime;
|
||||
struct timeval ru_stime;
|
||||
long ru_maxrss;
|
||||
long ru_ixrss;
|
||||
long ru_idrss;
|
||||
long ru_isrss;
|
||||
long ru_minflt;
|
||||
long ru_majflt;
|
||||
long ru_nswap;
|
||||
long ru_inblock;
|
||||
long ru_oublock;
|
||||
long ru_msgsnd;
|
||||
long ru_msgrcv;
|
||||
long ru_nsignals;
|
||||
long ru_nvcsw;
|
||||
long ru_nivcsw;
|
||||
long int ru_maxrss;
|
||||
long int ru_ixrss;
|
||||
long int ru_idrss;
|
||||
long int ru_isrss;
|
||||
long int ru_minflt;
|
||||
long int ru_majflt;
|
||||
long int ru_nswap;
|
||||
long int ru_inblock;
|
||||
long int ru_oublock;
|
||||
long int ru_msgsnd;
|
||||
long int ru_msgrcv;
|
||||
long int ru_nsignals;
|
||||
long int ru_nvcsw;
|
||||
long int ru_nivcsw;
|
||||
};
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -32,12 +32,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef EOF
|
||||
// FIXME M2_Planet chokes on -1, even inside #if ! __M2__
|
||||
#if __arm__ || __i386__
|
||||
#define EOF 0xffffffff
|
||||
#else
|
||||
#define EOF 0xffffffffffffffff
|
||||
#endif
|
||||
#define EOF -1
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
|
@ -71,23 +66,15 @@ typedef unsigned gid_t;
|
|||
#ifndef __MES_INO_T
|
||||
#define __MES_INO_T
|
||||
#undef ino_t
|
||||
#if __M2__
|
||||
typedef unsigned ino_t;
|
||||
#else
|
||||
typedef unsigned long ino_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __SIZEOF_LONG_LONG__ == 8
|
||||
#ifndef __MES_INO64_T
|
||||
#define __MES_INO64_T
|
||||
#undef ino64_t
|
||||
#if __M2__
|
||||
typedef unsigned ino64_t;
|
||||
#else
|
||||
typedef unsigned long long ino64_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
#if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined)
|
||||
|
@ -96,12 +83,8 @@ typedef unsigned long long ino64_t;
|
|||
#undef intptr_t
|
||||
typedef long intptr_t;
|
||||
#undef uintptr_t
|
||||
#if __M2__
|
||||
typedef unsigned uintptr_t;
|
||||
#else
|
||||
typedef unsigned long uintptr_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __MES_OFF_T
|
||||
#define __MES_OFF_T
|
||||
|
@ -113,12 +96,8 @@ typedef long off_t;
|
|||
#ifndef __MES_OFF64_T
|
||||
#define __MES_OFF64_T
|
||||
#undef off64_t
|
||||
#if __M2__
|
||||
typedef unsigned off64_t;
|
||||
#else
|
||||
typedef unsigned long long off64_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
#ifndef __MES_PID_T
|
||||
|
@ -147,13 +126,9 @@ typedef long sigval_t;
|
|||
#ifndef __MES_SIZE_T
|
||||
#define __MES_SIZE_T
|
||||
#undef size_t
|
||||
#if __M2__
|
||||
typedef unsigned size_t;
|
||||
#else
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __MES_SSIZE_T
|
||||
#define __MES_SSIZE_T
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -20,8 +20,6 @@
|
|||
#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>
|
||||
|
@ -37,8 +35,6 @@ typedef int pid_t;
|
|||
|
||||
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
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -27,8 +27,8 @@
|
|||
|
||||
#ifndef __MES_TIME_T
|
||||
#define __MES_TIME_T 1
|
||||
typedef long clockid_t;
|
||||
typedef long time_t;
|
||||
typedef long int clockid_t;
|
||||
typedef long int time_t;
|
||||
#endif
|
||||
|
||||
struct tm
|
||||
|
@ -56,7 +56,6 @@ struct timespec
|
|||
#endif // __MES_STRUCT_TIMESPEC
|
||||
|
||||
#define CLOCK_PROCESS_CPUTIME_ID 2
|
||||
char *asctime (struct tm const *broken_time);
|
||||
int clock_gettime (clockid_t clk_id, struct timespec *tp);
|
||||
struct tm *localtime (time_t const *timep);
|
||||
struct tm *gmtime (time_t const *time);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -74,7 +74,6 @@ int setgid (gid_t newgid);
|
|||
int setuid (uid_t newuid);
|
||||
uid_t geteuid (void);
|
||||
gid_t getegid (void);
|
||||
int getpagesize (void);
|
||||
pid_t getpgrp (void);
|
||||
pid_t getpid (void);
|
||||
pid_t getppid (void);
|
||||
|
@ -91,7 +90,6 @@ char *sbrk (ptrdiff_t delta);
|
|||
void *sbrk (intptr_t delta);
|
||||
#endif
|
||||
int symlink (char const *old_name, char const *new_name);
|
||||
long sysconf (int name);
|
||||
int unlink (char const *file_name);
|
||||
ssize_t write (int filedes, void const *buffer, size_t size);
|
||||
|
||||
|
|
24
kaem.arm
24
kaem.arm
|
@ -1,24 +0,0 @@
|
|||
#! /bin/sh
|
||||
# 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/>.
|
||||
|
||||
# Usage:
|
||||
# kaem --verbose --strict
|
||||
|
||||
mes_cpu=arm
|
||||
stage0_cpu=armv7l
|
||||
kaem --verbose --strict
|
38
kaem.run
38
kaem.run
|
@ -25,41 +25,35 @@ stage0_cpu=${stage0_cpu:-x86}
|
|||
mkdir -p m2
|
||||
|
||||
M2-Planet \
|
||||
--bootstrap-mode \
|
||||
--debug \
|
||||
--architecture ${stage0_cpu} \
|
||||
-D __linux__=1 \
|
||||
-f include/mes/config.h \
|
||||
-f include/mes/lib-mini.h \
|
||||
-f include/mes/lib.h \
|
||||
-f include/m2/lib.h \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||
-f lib/mes/globals.c \
|
||||
-f lib/m2/cast.c \
|
||||
-f lib/stdlib/exit.c \
|
||||
-f lib/mes/write.c \
|
||||
-f include/linux/${mes_cpu}/syscall.h \
|
||||
-f lib/m2/exit.c \
|
||||
-f lib/mes/mini-write.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
||||
-f include/linux/${mes_cpu}/syscall.h \
|
||||
-f lib/stub/__raise.c \
|
||||
-f lib/linux/brk.c \
|
||||
-f lib/linux/malloc.c \
|
||||
-f lib/m2/malloc.c \
|
||||
-f lib/string/memset.c \
|
||||
-f lib/linux/read.c \
|
||||
-f lib/m2/read.c \
|
||||
-f lib/mes/fdgetc.c \
|
||||
-f lib/stdio/getchar.c \
|
||||
-f lib/stdio/putchar.c \
|
||||
-f lib/stub/__buffered_read.c \
|
||||
-f lib/linux/_open3.c \
|
||||
-f lib/linux/open.c \
|
||||
-f lib/mes/mes_open.c \
|
||||
-f lib/m2/open.c \
|
||||
-f lib/m2/mes_open.c \
|
||||
-f lib/string/strlen.c \
|
||||
-f lib/mes/eputs.c \
|
||||
-f lib/mes/fdputc.c \
|
||||
-f lib/mes/eputc.c \
|
||||
\
|
||||
-f include/time.h \
|
||||
-f include/sys/time.h \
|
||||
-f include/sys/types.h \
|
||||
-f include/m2/types.h \
|
||||
-f include/mes/mes.h \
|
||||
-f include/mes/builtins.h \
|
||||
-f include/mes/constants.h \
|
||||
|
@ -90,21 +84,17 @@ M2-Planet \
|
|||
-f lib/linux/access.c \
|
||||
-f include/linux/m2/kernel-stat.h \
|
||||
-f include/sys/stat.h \
|
||||
-f lib/linux/chmod.c \
|
||||
-f lib/m2/chmod.c \
|
||||
-f lib/linux/ioctl3.c \
|
||||
-f include/sys/ioctl.h \
|
||||
-f lib/m2/isatty.c \
|
||||
-f lib/linux/fork.c \
|
||||
-f lib/m2/execve.c \
|
||||
-f lib/m2/execv.c \
|
||||
-f include/sys/resource.h \
|
||||
-f lib/linux/wait4.c \
|
||||
-f lib/linux/waitpid.c \
|
||||
-f lib/m2/waitpid.c \
|
||||
-f lib/linux/gettimeofday.c \
|
||||
-f lib/linux/clock_gettime.c \
|
||||
-f lib/m2/clock_gettime.c \
|
||||
-f lib/m2/time.c \
|
||||
-f lib/linux/_getcwd.c \
|
||||
-f include/limits.h \
|
||||
-f lib/m2/getcwd.c \
|
||||
-f lib/linux/dup.c \
|
||||
-f lib/linux/dup2.c \
|
||||
|
@ -115,7 +105,6 @@ M2-Planet \
|
|||
-f src/core.c \
|
||||
-f src/display.c \
|
||||
-f src/eval-apply.c \
|
||||
-f include/fcntl.h \
|
||||
-f src/gc.c \
|
||||
-f src/hash.c \
|
||||
-f src/lib.c \
|
||||
|
@ -123,7 +112,6 @@ M2-Planet \
|
|||
-f src/math.c \
|
||||
-f src/mes.c \
|
||||
-f src/module.c \
|
||||
-f include/signal.h \
|
||||
-f src/posix.c \
|
||||
-f src/reader.c \
|
||||
-f src/stack.c \
|
||||
|
|
24
kaem.x86
24
kaem.x86
|
@ -1,24 +0,0 @@
|
|||
#! /bin/sh
|
||||
# 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/>.
|
||||
|
||||
# Usage:
|
||||
# kaem --verbose --strict
|
||||
|
||||
mes_cpu=x86
|
||||
stage0_cpu=x86
|
||||
kaem --verbose --strict
|
|
@ -1,6 +1,7 @@
|
|||
/* -*-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.
|
||||
*
|
||||
|
|
|
@ -24,5 +24,5 @@
|
|||
int
|
||||
isxdigit (int c)
|
||||
{
|
||||
return isdigit (c) || (c >= 'a' && c <= 'f');
|
||||
return isdigit (c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ struct dirent *
|
|||
readdir (DIR * dirp)
|
||||
{
|
||||
struct dirent *dp;
|
||||
int save_errno = errno;
|
||||
int saved_errno = errno;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ readdir (DIR * dirp)
|
|||
{
|
||||
/* Don't modifiy errno when reaching EOF. */
|
||||
if (bytes == 0)
|
||||
errno = save_errno;
|
||||
errno = saved_errno;
|
||||
dp = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -26,9 +26,7 @@
|
|||
int
|
||||
_open3 (char const *file_name, int flags, int mask)
|
||||
{
|
||||
long long_file_name = cast_voidp_to_long (file_name);
|
||||
int r = _sys_call3 (SYS_open, long_file_name, flags, mask);
|
||||
__ungetc_init ();
|
||||
int r = _sys_call3 (SYS_open, (long) file_name, (int) flags, (int) mask);
|
||||
if (r > 2)
|
||||
{
|
||||
__ungetc_clear (r);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/arm/syscall.h>
|
||||
#include <linux/x86/syscall.h>
|
||||
|
||||
#if !__TINYC__
|
||||
// *INDENT-OFF*
|
||||
|
@ -187,6 +187,7 @@ __sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
}
|
||||
#endif //__TINYC__
|
||||
|
||||
#if 0
|
||||
long
|
||||
__sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||
{
|
||||
|
@ -207,6 +208,7 @@ __sys_call6 (long sys_call, long one, long two, long three, long four, long five
|
|||
);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
// *INDENT-ON*
|
||||
|
||||
|
@ -280,6 +282,7 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
return r;
|
||||
}
|
||||
|
||||
#if 0
|
||||
long
|
||||
_sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||
{
|
||||
|
@ -293,3 +296,4 @@ _sys_call6 (long sys_call, long one, long two, long three, long four, long five,
|
|||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -24,23 +24,23 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
|
||||
off_t
|
||||
_lseek (int filedes, off_t offset, int whence)
|
||||
{
|
||||
long long_offset = offset;
|
||||
return _sys_call3 (SYS_lseek, filedes, long_offset, whence);
|
||||
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
|
||||
}
|
||||
#endif
|
||||
|
||||
off_t
|
||||
lseek (int filedes, off_t offset, int whence)
|
||||
{
|
||||
#if !__MESC__ && !__M2__
|
||||
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
|
||||
if (_lseek (filedes, 0, SEEK_CUR) == -1)
|
||||
return -1;
|
||||
#endif
|
||||
size_t skip = __buffered_read_clear (filedes);
|
||||
if (whence == SEEK_CUR)
|
||||
offset -= skip;
|
||||
long long_offset = offset;
|
||||
return _sys_call3 (SYS_lseek, filedes, long_offset, whence);
|
||||
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2021 Danny Milosavljevic <dannym@scratchpost.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
|
@ -31,11 +31,9 @@ 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;
|
||||
|
|
|
@ -1,49 +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 <linux/syscall.h>
|
||||
#include <arch/syscall.h>
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if __M2__
|
||||
int
|
||||
open (char *file_name, int flags, int mask)
|
||||
{
|
||||
int r = _sys_call3 (SYS_open, file_name, flags, mask);
|
||||
if (r > 2)
|
||||
__ungetc_clear (r);
|
||||
return r;
|
||||
}
|
||||
#else // !__M2__
|
||||
int
|
||||
open (char const *file_name, int flags, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, flags);
|
||||
int mask = va_arg (ap, int);
|
||||
int r = _sys_call3 (SYS_open, (long) file_name, flags, mask);
|
||||
va_end (ap);
|
||||
if (r > 2)
|
||||
__ungetc_clear (r);
|
||||
return r;
|
||||
}
|
||||
#endif // !__M2__
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,18 +18,16 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <arch/syscall.h>
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
ssize_t
|
||||
read (int filedes, void *buffer, size_t size)
|
||||
{
|
||||
long long_filedes = filedes;
|
||||
long long_buffer = cast_voidp_to_long (buffer);
|
||||
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, long_buffer, size);
|
||||
#if !__M2__
|
||||
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, (long) buffer, (long) size);
|
||||
if (__mes_debug () > 4)
|
||||
{
|
||||
if (bytes == 1)
|
||||
|
@ -50,6 +48,5 @@ read (int filedes, void *buffer, size_t size)
|
|||
eputs ("\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return bytes;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2019,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -36,7 +36,7 @@ sighandler_t
|
|||
signal (int signum, sighandler_t action)
|
||||
{
|
||||
#if __i386__
|
||||
return _sys_call2 (SYS_signal, signum, action);
|
||||
return (sighandler_t) _sys_call2 (SYS_signal, signum, (long) action);
|
||||
#else
|
||||
static struct sigaction setup_action = { 0 };
|
||||
static struct sigaction old = { 0 };
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,7 +18,6 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <arch/syscall.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -26,12 +25,11 @@
|
|||
pid_t
|
||||
waitpid (pid_t pid, int *status_ptr, int options)
|
||||
{
|
||||
long long_pid = pid;
|
||||
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
||||
long long_options = options;
|
||||
#if SYS_waitpid
|
||||
return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
|
||||
#elif SYS_wait4
|
||||
return wait4 (pid, status_ptr, options, 0);
|
||||
#if __i386__
|
||||
return _sys_call3 (SYS_waitpid, (long) pid, (long) status_ptr, (int) options);
|
||||
#elif __x86_64__ || __arm__
|
||||
return _sys_call4 (SYS_wait4, (long) pid, (long) status_ptr, (int) options, 0);
|
||||
#else
|
||||
#error arch not supported
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -177,20 +177,3 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %1,%%eax\n\t"
|
||||
"mov %%ebp,%%ebx\n\t"
|
||||
"add $0x0c,%%ebx\n\t"
|
||||
"int $0x80\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call)
|
||||
: "eax", "ebx"
|
||||
);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -66,15 +66,6 @@ __sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
long
|
||||
__sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !0x08");
|
||||
asm ("mov____%ebp,%ebx");
|
||||
asm ("add____$i8,%ebx !0x0c");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call (long sys_call)
|
||||
{
|
||||
|
@ -144,9 +135,3 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call6 (int sys_call, int one, int two, int three, int four, int five, int six)
|
||||
{
|
||||
return __sys_call6 (sys_call, one, two, three, four, five, six);
|
||||
}
|
||||
|
|
|
@ -179,26 +179,3 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %2,%%rdi\n\t"
|
||||
"mov %3,%%rsi\n\t"
|
||||
"mov %4,%%rdx\n\t"
|
||||
"mov %5,%%r10\n\t"
|
||||
"mov %6,%%r8\n\t"
|
||||
"mov %7,%%r9\n\t"
|
||||
"mov %1,%%rax\n\t"
|
||||
// );
|
||||
// asm (
|
||||
"syscall \n\t"
|
||||
"mov %%rax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three), "rm" (four), "rm" (five), "rm" (six)
|
||||
: "rax", "rdi", "rsi", "rdx", "r10", "r8", "r9"
|
||||
);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -96,8 +96,6 @@ __sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
asm ("mov____0x8(%rbp),%rsi !0x20");
|
||||
asm ("mov____0x8(%rbp),%rdx !0x28");
|
||||
asm ("mov____0x8(%rbp),%r10 !0x30");
|
||||
asm ("mov____0x8(%rbp),%r8 !0x38");
|
||||
asm ("mov____0x8(%rbp),%r9 !0x40");
|
||||
#endif
|
||||
|
||||
asm ("syscall");
|
||||
|
@ -172,12 +170,3 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
|||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||
{
|
||||
// long rax = sys_call;
|
||||
// long r = __sys_call6 (one, two, three, four, five, six);
|
||||
long r = __sys_call (sys_call, one, two, three, four, five, six);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -1,51 +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/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <locale.h>
|
||||
#include <limits.h>
|
||||
|
||||
static struct lconv posix_lconv =
|
||||
{
|
||||
".",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
CHAR_MAX,
|
||||
};
|
||||
|
||||
struct lconv *
|
||||
localeconv (void)
|
||||
{
|
||||
return (void *)&posix_lconv;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/* -*-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 <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
chmod (char const *file_name, int mask)
|
||||
{
|
||||
long long_file_name = file_name;
|
||||
long long_mask = mask;
|
||||
return _sys_call2 (SYS_chmod, long_file_name, long_mask);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -19,11 +19,12 @@
|
|||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <arch/syscall.h>
|
||||
#include <sys/mman.h>
|
||||
#include <syscall.h>
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
munmap (void *addr, size_t length)
|
||||
clock_gettime (long clk_id, struct timespec *tp)
|
||||
{
|
||||
return _sys_call2 (SYS_munmap, (long) addr, (long) length);
|
||||
long long_tp = tp;
|
||||
return _sys_call2 (SYS_clock_gettime, clk_id, tp);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,12 +18,12 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <mes/lib.h>
|
||||
|
||||
long int
|
||||
labs (long int number)
|
||||
void _exit (int code);
|
||||
|
||||
void
|
||||
exit (int code)
|
||||
{
|
||||
if (number < 0)
|
||||
return -number;
|
||||
return number;
|
||||
_exit (code);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -24,6 +24,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// CONSTANT PATH_MAX 1024
|
||||
|
||||
char *__getcwd_buf;
|
||||
|
||||
char *
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@
|
|||
#include <string.h>
|
||||
#include <termio.h>
|
||||
|
||||
// CONSTANT TCGETS 0x5401
|
||||
#define TCGETS 0x5401
|
||||
|
||||
struct ktermios
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -21,14 +21,16 @@
|
|||
#include <mes/lib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
strsignal (int signum)
|
||||
char *__brk = 0;
|
||||
|
||||
void *
|
||||
malloc (size_t size)
|
||||
{
|
||||
static int stub = 0;
|
||||
if (__mes_debug () && !stub)
|
||||
eputs ("strsignal stub\n");
|
||||
stub = 1;
|
||||
static char buf[30] = "Unknown signal: ";
|
||||
strcat (buf, itoa (signum));
|
||||
return buf;
|
||||
if (!__brk)
|
||||
__brk = cast_long_to_charp (brk (0));
|
||||
if (brk (__brk + size) == -1)
|
||||
return 0;
|
||||
char *p = __brk;
|
||||
__brk = __brk + size;
|
||||
return p;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,15 +18,11 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <limits.h>
|
||||
|
||||
int
|
||||
getpagesize (void)
|
||||
mes_open (char *file_name, int flags, int mask)
|
||||
{
|
||||
static int stub = 0;
|
||||
if (__mes_debug () && !stub)
|
||||
eputs ("getpagesize stub\n");
|
||||
stub = 1;
|
||||
return PAGE_SIZE;
|
||||
int filedes = open (file_name, flags, mask);
|
||||
if (filedes > 2)
|
||||
__ungetc_clear (filedes);
|
||||
return filedes;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -20,10 +20,15 @@
|
|||
|
||||
#include <linux/syscall.h>
|
||||
#include <arch/syscall.h>
|
||||
#include <sys/mman.h>
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void *
|
||||
mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
int
|
||||
open (char *file_name, int flags, int mask)
|
||||
{
|
||||
return (void *)_sys_call6 (SYS_mmap, (long) addr, (long) len, (int) prot, (int) flags, (int) fd, (long) offset);
|
||||
int r = _sys_call3 (SYS_open, file_name, flags, mask);
|
||||
if (r > 2)
|
||||
__ungetc_clear (r);
|
||||
return r;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,15 +18,14 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <mes/lib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
long
|
||||
sysconf (int name)
|
||||
read (int filedes, void *buffer, long size)
|
||||
{
|
||||
static int stub = 0;
|
||||
if (__mes_debug () && !stub)
|
||||
eputs ("sysconf stub\n");
|
||||
stub = 1;
|
||||
return -1;
|
||||
long bytes = _sys_call3 (SYS_read, filedes, buffer, size);
|
||||
return bytes;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2019,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -22,13 +22,16 @@
|
|||
#include <arch/syscall.h>
|
||||
#include <time.h>
|
||||
|
||||
char *__tv;
|
||||
|
||||
long
|
||||
time (long* result)
|
||||
{
|
||||
int r;
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
r = _sys_call2 (SYS_gettimeofday, tv, tz);
|
||||
if (__tv == 0)
|
||||
__tv = malloc (sizeof (struct timeval));
|
||||
struct timeval *tv = __tv;
|
||||
r = _sys_call2 (SYS_gettimeofday, tv, 0);
|
||||
if (r != 0)
|
||||
return -1;
|
||||
if (result != 0)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -22,15 +22,18 @@
|
|||
#include <linux/syscall.h>
|
||||
#include <arch/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
pid_t
|
||||
wait4 (pid_t pid, int *status_ptr, int options, struct rusage *rusage)
|
||||
int
|
||||
waitpid (int pid, int *status_ptr, int options)
|
||||
{
|
||||
long long_pid = pid;
|
||||
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
||||
long long_options = options;
|
||||
long long_rusage = cast_voidp_to_long (rusage);
|
||||
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options,
|
||||
long_rusage);
|
||||
//##if __i386__
|
||||
//# return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
|
||||
//##elif __x86_64__ || __arm__
|
||||
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options, 0);
|
||||
//##else
|
||||
//##error arch not supported
|
||||
//##endif
|
||||
}
|
|
@ -25,7 +25,7 @@ void
|
|||
__assert_fail (char const *msg, char const *file, unsigned line,
|
||||
char const *function)
|
||||
{
|
||||
if (file && *file)
|
||||
if (file && file[0])
|
||||
{
|
||||
eputs (file);
|
||||
eputs (":");
|
||||
|
@ -35,7 +35,7 @@ __assert_fail (char const *msg, char const *file, unsigned line,
|
|||
eputs (itoa (line));
|
||||
eputs (":");
|
||||
}
|
||||
if (function && *function)
|
||||
if (function && function[0])
|
||||
{
|
||||
eputs (function);
|
||||
eputs (":");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2022 Rick Masters <grick23@gmail.com>
|
||||
* Copyright © 2022,2023 Rick Masters <grick23@gmail.com>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -43,10 +43,15 @@ abtol (char const **p, int base)
|
|||
while (isnumber (s[0], base) != 0)
|
||||
{
|
||||
i = i * base;
|
||||
if (s[0] > '9')
|
||||
if (s[0] >= 'a')
|
||||
m = 'a' - 10;
|
||||
else
|
||||
m = '0';
|
||||
{
|
||||
if (s[0] >= 'A')
|
||||
m = 'A' - 10;
|
||||
else
|
||||
m = '0';
|
||||
}
|
||||
i = i + s[0] - m;
|
||||
s = s + 1;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
|
|
|
@ -23,19 +23,7 @@
|
|||
#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
|
||||
#if __M2_PLANET__ || (!(__MESC__ && __arm__) && !(__TINYC__ && __arm__ && BOOTSTRAP))
|
||||
size_t
|
||||
__mesabi_uldiv (size_t a, size_t b, size_t *remainder)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-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 © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -23,6 +23,8 @@
|
|||
#include <sys/types.h>
|
||||
#include <mes/lib.h>
|
||||
|
||||
char *__getcwd_buf;
|
||||
|
||||
char *
|
||||
getcwd (char *buffer, size_t size)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -22,6 +22,9 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// CONSTANT M2_PTR_SIZE 4
|
||||
#define M2_PTR_SIZE 1
|
||||
|
||||
char *
|
||||
getenv (char const *s)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -29,13 +29,6 @@ _open2 (char const *file_name, int flags)
|
|||
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, ...)
|
||||
{
|
||||
|
@ -51,4 +44,3 @@ open (char const *file_name, int flags, ...)
|
|||
else
|
||||
return _open2 (file_name, flags);
|
||||
}
|
||||
#endif // !__M2__
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -22,6 +22,9 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// CONSTANT M2_PTR_SIZE 4
|
||||
#define M2_PTR_SIZE 1
|
||||
|
||||
int
|
||||
setenv (char const *s, char const *v, int overwrite_p)
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
int
|
||||
vfprintf (FILE * f, char const *format, va_list ap)
|
||||
{
|
||||
int fd = fileno (f);
|
||||
int fd = (long) f;
|
||||
char const *p = format;
|
||||
int count = 0;
|
||||
while (*p)
|
||||
|
@ -41,7 +41,6 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
char c = *p;
|
||||
int left_p = 0;
|
||||
int precision = -1;
|
||||
int prefix_p = 0;
|
||||
int width = -1;
|
||||
if (c == '-')
|
||||
{
|
||||
|
@ -52,17 +51,12 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
if (c == ' ')
|
||||
{
|
||||
pad = c;
|
||||
c = *++p;
|
||||
}
|
||||
if (c == '#')
|
||||
{
|
||||
prefix_p = 1;
|
||||
c = *++p;
|
||||
c = *p++;
|
||||
}
|
||||
if (c == '0')
|
||||
{
|
||||
pad = c;
|
||||
c = *++p;
|
||||
c = *p++;
|
||||
}
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
|
@ -140,18 +134,6 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
count++;
|
||||
}
|
||||
}
|
||||
if (prefix_p && *s && c == 'o')
|
||||
{
|
||||
fputc ('0', f);
|
||||
width--;
|
||||
}
|
||||
if (prefix_p && *s && (c == 'x' || c == 'X'))
|
||||
{
|
||||
fputc ('0', f);
|
||||
width--;
|
||||
fputc ('x', f);
|
||||
width--;
|
||||
}
|
||||
while (*s)
|
||||
{
|
||||
if (precision-- <= 0)
|
||||
|
@ -212,9 +194,6 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
case 'G':
|
||||
{
|
||||
double d = va_arg8 (ap, double);
|
||||
#if 1
|
||||
fputs ("0.0", f);
|
||||
#else
|
||||
char *s = dtoab (d, 10, 1);
|
||||
if (c == 'E' || c == 'G')
|
||||
strupr (s);
|
||||
|
@ -250,7 +229,6 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
fputc (pad, f);
|
||||
count++;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
|
@ -263,8 +241,6 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
{
|
||||
eputs ("vfprintf: not supported: %:");
|
||||
eputc (c);
|
||||
eputs (", in format: ");
|
||||
eputs (format);
|
||||
eputs ("\n");
|
||||
p++;
|
||||
}
|
||||
|
@ -272,5 +248,5 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
p++;
|
||||
}
|
||||
va_end (ap);
|
||||
return count;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
|
||||
* Copyright © 2017,2018,2019,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -24,81 +23,62 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int
|
||||
vfscanf (FILE * stream, char const *template, va_list ap)
|
||||
{
|
||||
char r = fgetc (stream);
|
||||
char p = fgetc (stream);
|
||||
char const *t = template;
|
||||
int count = 0;
|
||||
while (*t && r != EOF)
|
||||
while (*t && p != EOF)
|
||||
if (*t != '%')
|
||||
{
|
||||
t++;
|
||||
r = fgetc (stream);
|
||||
p = fgetc (stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
t++;
|
||||
char c = *t;
|
||||
int skip_p = 0;
|
||||
int length = -1;
|
||||
if (c == '*')
|
||||
skip_p = 1;
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
length = abtol (&t, 10);
|
||||
c = *t;
|
||||
}
|
||||
if (c == 'l')
|
||||
c = *++t;
|
||||
switch (c)
|
||||
{
|
||||
case '%':
|
||||
{
|
||||
r = fgetc (stream);
|
||||
p = fgetc (stream);
|
||||
break;
|
||||
}
|
||||
case 'c':
|
||||
{
|
||||
r = fgetc (stream);
|
||||
if (!skip_p)
|
||||
{
|
||||
char *c = va_arg (ap, char *);
|
||||
*c = r;
|
||||
count++;
|
||||
}
|
||||
char *c = va_arg (ap, char *);
|
||||
*c = p;
|
||||
p = fgetc (stream);
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'u':
|
||||
{
|
||||
int *d = skip_p ? 0 : va_arg (ap, int *);
|
||||
int *d = va_arg (ap, int *);
|
||||
char buf[20];
|
||||
char *q = buf;
|
||||
if (r == '+' || r == '-')
|
||||
if (p == '+' || p == '-')
|
||||
{
|
||||
*q++ = r;
|
||||
r = fgetc (stream);
|
||||
*q++ = p;
|
||||
p = fgetc (stream);
|
||||
}
|
||||
while (isdigit (r))
|
||||
while (isdigit (p))
|
||||
{
|
||||
*q++ = r;
|
||||
r = fgetc (stream);
|
||||
*q++ = p;
|
||||
p = fgetc (stream);
|
||||
}
|
||||
ungetc (r, stream);
|
||||
ungetc (p, stream);
|
||||
*q = 0;
|
||||
q = buf;
|
||||
if (skip_p)
|
||||
abtol ((char const **) &q, 10);
|
||||
else
|
||||
{
|
||||
*d = abtol ((char const **) &q, 10);
|
||||
count++;
|
||||
}
|
||||
*d = abtol ((char const**)&q, 10);
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
case 'e':
|
||||
|
@ -107,100 +87,33 @@ vfscanf (FILE * stream, char const *template, va_list ap)
|
|||
case 'E':
|
||||
case 'G':
|
||||
{
|
||||
float *f = skip_p ? 0 : va_arg (ap, float *);
|
||||
float *f = va_arg (ap, float *);
|
||||
char buf[20];
|
||||
char *q = buf;
|
||||
if (r == '+' || r == '-')
|
||||
if (p == '+' || p == '-')
|
||||
{
|
||||
*q++ = r;
|
||||
r = fgetc (stream);
|
||||
*q++ = p;
|
||||
p = fgetc (stream);
|
||||
}
|
||||
while (isdigit (r))
|
||||
while (isdigit (p))
|
||||
{
|
||||
*q++ = r;
|
||||
r = fgetc (stream);
|
||||
*q++ = p;
|
||||
p = fgetc (stream);
|
||||
}
|
||||
ungetc (r, stream);
|
||||
ungetc (p, stream);
|
||||
*q = 0;
|
||||
q = buf;
|
||||
if (skip_p)
|
||||
strtod (q, &q);
|
||||
else
|
||||
{
|
||||
*f = strtod (q, &q);
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
{
|
||||
char *s = skip_p ? 0 : va_arg (ap, char *);
|
||||
while (r && !isspace (r) && (length == -1 || length--))
|
||||
{
|
||||
if (!skip_p)
|
||||
*s++ = r;
|
||||
r = fgetc (stream);
|
||||
}
|
||||
if (!skip_p)
|
||||
{
|
||||
count++;
|
||||
*s = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '[':
|
||||
{
|
||||
char *s = skip_p ? 0 : va_arg (ap, char *);
|
||||
char set[1024];
|
||||
int i = 0;
|
||||
int not_in_set_p = 0;
|
||||
t++;
|
||||
if (*t == '^')
|
||||
{
|
||||
not_in_set_p = 1;
|
||||
t++;
|
||||
}
|
||||
if (*t == ']' || *t == '-')
|
||||
set[i++] = *t++;
|
||||
while (*t && *t != ']')
|
||||
{
|
||||
if (*t == '-')
|
||||
{
|
||||
char end = *t++;
|
||||
for (char x = set[i - 1] + 1; x < end; x++)
|
||||
set[i++] = x;
|
||||
}
|
||||
else
|
||||
set[i++] = *t++;
|
||||
}
|
||||
set[i] = 0;
|
||||
while (r && (length == -1 || length--))
|
||||
{
|
||||
int match = (int) (long) strchr (set, r);
|
||||
if (not_in_set_p)
|
||||
match = !match;
|
||||
if (!match)
|
||||
break;
|
||||
if (!skip_p)
|
||||
*s++ = r;
|
||||
r = fgetc (stream);
|
||||
}
|
||||
if (!skip_p)
|
||||
{
|
||||
count++;
|
||||
*s = 0;
|
||||
}
|
||||
*f = strtod (q, &q);
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
eputs ("vsscanf: not supported: %:");
|
||||
eputc (c);
|
||||
eputs (", in template: ");
|
||||
eputs (template);
|
||||
eputs ("\n");
|
||||
t++;
|
||||
r = fgetc (stream);
|
||||
p = fgetc (stream);
|
||||
}
|
||||
}
|
||||
t++;
|
||||
|
|
|
@ -43,7 +43,6 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
|||
c = *p;
|
||||
int left_p = 0;
|
||||
int precision = -1;
|
||||
int prefix_p = 0;
|
||||
int width = -1;
|
||||
if (c == '-')
|
||||
{
|
||||
|
@ -54,17 +53,12 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
|||
if (c == ' ')
|
||||
{
|
||||
pad = c;
|
||||
c = *++p;
|
||||
}
|
||||
if (c == '#')
|
||||
{
|
||||
prefix_p = 1;
|
||||
c = *++p;
|
||||
c = *p++;
|
||||
}
|
||||
if (c == '0')
|
||||
{
|
||||
pad = c;
|
||||
c = *++p;
|
||||
c = *p++;
|
||||
}
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
|
@ -148,18 +142,6 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
|||
count++;
|
||||
}
|
||||
}
|
||||
if (prefix_p && *s && c == 'o')
|
||||
{
|
||||
*s++ = '0';
|
||||
width--;
|
||||
}
|
||||
if (prefix_p && *s && (c == 'x' || c == 'X'))
|
||||
{
|
||||
*s++ = '0';
|
||||
width--;
|
||||
*s++ = 'x';
|
||||
width--;
|
||||
}
|
||||
while (*s)
|
||||
{
|
||||
if (precision-- <= 0)
|
||||
|
@ -228,11 +210,6 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
|||
case 'G':
|
||||
{
|
||||
double d = va_arg8 (ap, double);
|
||||
#if 1
|
||||
*str++ = '0';
|
||||
*str++ = '.';
|
||||
*str++ = '0';
|
||||
#else
|
||||
char *s = dtoab (d, 10, 1);
|
||||
if (c == 'E' || c == 'G')
|
||||
strupr (s);
|
||||
|
@ -273,7 +250,6 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
|||
*str++ = pad;
|
||||
count++;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
|
@ -286,8 +262,6 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
|||
{
|
||||
eputs ("vsnprintf: not supported: %:");
|
||||
eputc (c);
|
||||
eputs (", in format: ");
|
||||
eputs (format);
|
||||
eputs ("\n");
|
||||
p++;
|
||||
}
|
||||
|
|
|
@ -41,15 +41,6 @@ vsscanf (char const *s, char const *template, va_list ap)
|
|||
{
|
||||
t++;
|
||||
char c = *t;
|
||||
int skip_p = 0;
|
||||
int length = -1;
|
||||
if (c == '*')
|
||||
skip_p = 1;
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
length = abtol (&t, 10);
|
||||
c = *t;
|
||||
}
|
||||
if (c == 'l')
|
||||
c = *++t;
|
||||
switch (c)
|
||||
|
@ -61,27 +52,18 @@ vsscanf (char const *s, char const *template, va_list ap)
|
|||
}
|
||||
case 'c':
|
||||
{
|
||||
char r = *p++;
|
||||
if (!skip_p)
|
||||
{
|
||||
char *c = va_arg (ap, char *);
|
||||
*c = r;
|
||||
count++;
|
||||
}
|
||||
char *c = va_arg (ap, char *);
|
||||
*c = *p++;
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
case 'i':
|
||||
case 'u':
|
||||
{
|
||||
if (skip_p)
|
||||
abtol ((char const **) &p, 10);
|
||||
else
|
||||
{
|
||||
int *d = va_arg (ap, int *);
|
||||
*d = abtol ((char const **) &p, 10);
|
||||
count++;
|
||||
}
|
||||
int *d = va_arg (ap, int *);
|
||||
*d = abtol ((char const **)&p, 10);
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
case 'e':
|
||||
|
@ -90,84 +72,15 @@ vsscanf (char const *s, char const *template, va_list ap)
|
|||
case 'E':
|
||||
case 'G':
|
||||
{
|
||||
if (skip_p)
|
||||
strtod (p, &p);
|
||||
else
|
||||
{
|
||||
float *f = va_arg (ap, float *);
|
||||
*f = strtod (p, &p);
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
{
|
||||
char *s = skip_p ? 0 : va_arg (ap, char *);
|
||||
char r = *p;
|
||||
while (r && !isspace (r) && (length == -1 || length--))
|
||||
{
|
||||
if (!skip_p)
|
||||
*s++ = r;
|
||||
r = *++p;
|
||||
}
|
||||
if (!skip_p)
|
||||
{
|
||||
count++;
|
||||
*s = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '[':
|
||||
{
|
||||
char *s = skip_p ? 0 : va_arg (ap, char *);
|
||||
char set[1024];
|
||||
int i = 0;
|
||||
int not_in_set_p = 0;
|
||||
t++;
|
||||
if (*t == '^')
|
||||
{
|
||||
not_in_set_p = 1;
|
||||
t++;
|
||||
}
|
||||
if (*t == ']' || *t == '-')
|
||||
set[i++] = *t++;
|
||||
while (*t && *t != ']')
|
||||
{
|
||||
if (*t == '-')
|
||||
{
|
||||
char end = *t++;
|
||||
for (char x = set[i - 1] + 1; x < end; x++)
|
||||
set[i++] = x;
|
||||
}
|
||||
else
|
||||
set[i++] = *t++;
|
||||
}
|
||||
set[i] = 0;
|
||||
char r = *p;
|
||||
while (r && (length == -1 || length--))
|
||||
{
|
||||
int match = (int) (long) strchr (set, r);
|
||||
if (not_in_set_p)
|
||||
match = !match;
|
||||
if (!match)
|
||||
break;
|
||||
if (!skip_p)
|
||||
*s++ = r;
|
||||
r = *++p;
|
||||
}
|
||||
if (!skip_p)
|
||||
{
|
||||
count++;
|
||||
*s = 0;
|
||||
}
|
||||
float *f = va_arg (ap, float *);
|
||||
*f = strtod (p, &p);
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
eputs ("vsscanf: not supported: %:");
|
||||
eputc (c);
|
||||
eputs (", in template: ");
|
||||
eputs (template);
|
||||
eputs ("\n");
|
||||
t++;
|
||||
p++;
|
||||
|
|
|
@ -25,5 +25,4 @@ int
|
|||
atexit (void (*function) (void))
|
||||
{
|
||||
__call_at_exit = function;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -20,16 +20,12 @@
|
|||
|
||||
#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);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -30,6 +30,6 @@ mbstowcs (wchar_t * wstring, char const *string, size_t size)
|
|||
if (__mes_debug () && !stub)
|
||||
eputs ("mbstowcs stub\n");
|
||||
stub = 1;
|
||||
strcpy (wstring, string);
|
||||
strcpy ((char*)wstring, string);
|
||||
return strlen (string);
|
||||
}
|
||||
|
|
|
@ -19,62 +19,62 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* See: https://en.wikipedia.org/wiki/Quicksort */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static void
|
||||
qswap (char *a, char *b, size_t size)
|
||||
void
|
||||
qswap (void *a, void *b, size_t size)
|
||||
{
|
||||
while (size-- > 0)
|
||||
{
|
||||
char tmp = *a;
|
||||
*a++ = *b;
|
||||
*b++ = tmp;
|
||||
}
|
||||
char *pa = a;
|
||||
char *pb = b;
|
||||
do
|
||||
{
|
||||
char tmp = *pa;
|
||||
*pa++ = *pb;
|
||||
*pb++ = tmp;
|
||||
} while (--size > 0);
|
||||
}
|
||||
|
||||
static size_t
|
||||
qpart (char *base, size_t lo, size_t hi, size_t size,
|
||||
int (*compare) (void const *, void const *))
|
||||
size_t
|
||||
qpart (void *base, size_t count, size_t size, int (*compare) (void const *, void const *))
|
||||
{
|
||||
char *pivot = base + hi * size;
|
||||
size_t i = lo;
|
||||
|
||||
for (size_t j = lo; j < hi; j++)
|
||||
void *p = base + count * size;
|
||||
size_t i = 0;
|
||||
for (size_t j = 0; j < count; j++)
|
||||
{
|
||||
char *pj = base + j * size;
|
||||
if (pj != pivot && compare (pj, pivot) < 0)
|
||||
int c = compare (base + j * size, p);
|
||||
if (c < 0)
|
||||
{
|
||||
void *pi = base + i * size;
|
||||
qswap (pi, pj, size);
|
||||
#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++;
|
||||
}
|
||||
|
||||
char *pi = base + i * size;
|
||||
qswap (pi, pivot, size);
|
||||
|
||||
if (compare (base + count * size, base + i * size) < 0)
|
||||
qswap (base + i * size, base + count * size, size);
|
||||
return i;
|
||||
}
|
||||
|
||||
static void
|
||||
_qsort (void *base, size_t lo, size_t hi, size_t size,
|
||||
int (*compare) (void const *, void const *))
|
||||
{
|
||||
if (lo >= hi)
|
||||
return;
|
||||
size_t pi = qpart (base, lo, hi, size, compare);
|
||||
if (pi > 0)
|
||||
_qsort (base, lo, pi - 1, size, compare);
|
||||
_qsort (base, pi + 1, hi, size, compare);
|
||||
}
|
||||
|
||||
void
|
||||
qsort (void *base, size_t count, size_t size,
|
||||
int (*compare) (void const *, void const *))
|
||||
qsort (void *base, size_t count, size_t size, int (*compare) (void const *, void const *))
|
||||
{
|
||||
if (count <= 1)
|
||||
return;
|
||||
_qsort (base, 0, count - 1, size, compare);
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -77,7 +77,5 @@ strerror (int errnum)
|
|||
}
|
||||
if (errnum > 0 && errnum <= sys_nerr)
|
||||
return sys_errlist[errnum];
|
||||
static char buf[40] = "strerror: unknown error: ";
|
||||
strcat (buf, itoa (errnum));
|
||||
return buf;
|
||||
return "sterror: unknown error";
|
||||
}
|
||||
|
|
|
@ -1,42 +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 <string.h>
|
||||
|
||||
char *
|
||||
strtok (char *new_string, char const *delimiters)
|
||||
{
|
||||
static char *mark;
|
||||
if (new_string)
|
||||
mark = new_string;
|
||||
if (!*mark)
|
||||
return 0;
|
||||
while (strchr (delimiters, *mark))
|
||||
mark++;
|
||||
char *point = mark;
|
||||
while (*mark && !strchr (delimiters, *mark))
|
||||
mark++;
|
||||
if (*mark)
|
||||
{
|
||||
*mark = 0;
|
||||
mark++;
|
||||
}
|
||||
return point;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,6 +18,8 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// CONSTANT SIGABRT 0
|
||||
|
||||
int
|
||||
__raise (int signum)
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue