Compare commits
44 Commits
Author | SHA1 | Date |
---|---|---|
Jan (janneke) Nieuwenhuizen | 03019f6ddd | |
Jan (janneke) Nieuwenhuizen | c3ec4e5414 | |
Danny Milosavljevic | ad038b356d | |
Jan Nieuwenhuizen | feafc49ad6 | |
Jan Nieuwenhuizen | 10e65e2ad0 | |
Jan Nieuwenhuizen | 9fe7e05ffd | |
Jan Nieuwenhuizen | 48b12cbd52 | |
Jan (janneke) Nieuwenhuizen | b80f0d82c2 | |
Jan Nieuwenhuizen | 550a1e595b | |
Jan Nieuwenhuizen | 948590425b | |
Jan Nieuwenhuizen | 23abd8e2b7 | |
Jan Nieuwenhuizen | 2395703971 | |
Jan Nieuwenhuizen | 95ba472302 | |
Jan Nieuwenhuizen | 6f71f2da02 | |
Jan Nieuwenhuizen | c669116a7b | |
Jan Nieuwenhuizen | a05c4f8748 | |
Jan Nieuwenhuizen | 2f23211660 | |
Jan Nieuwenhuizen | 379c96c90c | |
Jan (janneke) Nieuwenhuizen | ba92886a4e | |
Jan (janneke) Nieuwenhuizen | 17a19c985d | |
Jan (janneke) Nieuwenhuizen | 602f14e560 | |
Jan (janneke) Nieuwenhuizen | fbb82dc65d | |
Jan (janneke) Nieuwenhuizen | cade49c699 | |
Jan (janneke) Nieuwenhuizen | 46b1158ee4 | |
Jan (janneke) Nieuwenhuizen | 2777d67e35 | |
Jan (janneke) Nieuwenhuizen | e3489c6abc | |
Jan (janneke) Nieuwenhuizen | 1ba7a0dc80 | |
Jan (janneke) Nieuwenhuizen | 95c80acffc | |
Jan (janneke) Nieuwenhuizen | f3d0d229f4 | |
Jan (janneke) Nieuwenhuizen | 2b62ad7931 | |
Jan (janneke) Nieuwenhuizen | 03df5c6361 | |
Jan (janneke) Nieuwenhuizen | 404b23b2bb | |
Jan (janneke) Nieuwenhuizen | dcf334a136 | |
Jan (janneke) Nieuwenhuizen | a07a3bd48a | |
Jan (janneke) Nieuwenhuizen | 038baa117e | |
Jan (janneke) Nieuwenhuizen | 15e0f82f20 | |
Jan (janneke) Nieuwenhuizen | 56ad9187a4 | |
Jan (janneke) Nieuwenhuizen | c618713d8f | |
Gabriel Wicki | 87b684ec75 | |
Ekaitz | a31a35369f | |
Ekaitz | aa6d6e07de | |
Jan (janneke) Nieuwenhuizen | 3c9ec14c6e | |
Jan (janneke) Nieuwenhuizen | cc8b9ff537 | |
Jan (janneke) Nieuwenhuizen | cada47f2ab |
8
COPYING
8
COPYING
|
@ -1,7 +1,7 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
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
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
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.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
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.
|
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,
|
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.
|
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
|
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
|
The GNU General Public License does not permit incorporating your program
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
may consider it more useful to permit linking proprietary applications with
|
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
|
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
|
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>.
|
||||||
|
|
35
HACKING
35
HACKING
|
@ -5,7 +5,8 @@
|
||||||
guix shell #64 bit + 32bit
|
guix shell #64 bit + 32bit
|
||||||
|
|
||||||
CC=i686-unknown-linux-gnu-gcc ./configure
|
CC=i686-unknown-linux-gnu-gcc ./configure
|
||||||
CC=arm-unknown-linux-gnu-gcc ./configure
|
CC=arm-unknown-linux-gnueabihf-gcc ./configure
|
||||||
|
|
||||||
or
|
or
|
||||||
./configure
|
./configure
|
||||||
|
|
||||||
|
@ -129,30 +130,30 @@ x/s *((char **)($rsp+8))
|
||||||
|
|
||||||
** C parser/compiler
|
** C parser/compiler
|
||||||
*** [[https://savannah.gnu.org/projects/nyacc][nyacc]]
|
*** [[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]]
|
*** [[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]]
|
*** [[https://groups.google.com/forum/#!topic/comp.lang.lisp/VPuX0VsjTTE][C intepreter in LISP/Scheme/Python]]
|
||||||
|
|
||||||
** C assembler/linker
|
** 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
|
*** ELF
|
||||||
7f 45 4c 46
|
7f 45 4c 46
|
||||||
*** [[http://www.muppetlabs.com/~breadbox/software/tiny/][Small ELF programs]]
|
*** [[https://www.muppetlabs.com/~breadbox/software/tiny/][Small ELF programs]]
|
||||||
*** [[http://www.cirosantilli.com/elf-hello-world/][Elf hello world]]
|
*** [[https://www.cirosantilli.com/elf-hello-world/][Elf hello world]]
|
||||||
** SC - c as s-expressions
|
** SC - c as s-expressions
|
||||||
sc: http://sph.mn/content/3d3
|
sc: https://sph.mn/content/3d3
|
||||||
** RNRS
|
** 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-349.pdf][Scheme - Report on Scheme]]
|
||||||
*** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-452.pdf][RRS - Revised Report on Scheme]]
|
*** [[ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-452.pdf][RRS - Revised Report on Scheme]]
|
||||||
|
|
||||||
** tiny schemes
|
** 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
|
https://www.stripedgazelle.org/joey/dreamos.html
|
||||||
http://armpit.sourceforge.net/
|
https://armpit.sourceforge.net/
|
||||||
http://common-lisp.net/project/movitz/movitz.html
|
https://common-lisp.net/project/movitz/movitz.html
|
||||||
|
|
||||||
<civodul> janneke: https://github.com/namin/inc looks interesting [15:18]
|
<civodul> janneke: https://github.com/namin/inc looks interesting [15:18]
|
||||||
** Orians Jeremiah
|
** Orians Jeremiah
|
||||||
|
@ -169,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
|
<janneke> OriansJ: i looked a few times and saw 'LISP empty', so thanks for
|
||||||
the pointer! [00:24]
|
the pointer! [00:24]
|
||||||
<civodul> OriansJ, janneke: from that page, there's also:
|
<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
|
** 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
|
https://github.com/rswier/c4/blob/master/c4.c
|
||||||
** Compilers for free
|
** Compilers for free
|
||||||
http://codon.com/compilers-for-free
|
https://codon.com/compilers-for-free
|
||||||
** Small lisps
|
** Small lisps
|
||||||
*** [[https://www.mirrorservice.org/sites/www.bitsavers.org/bits/TI/Explorer/zeta-c/][ZETA-C]]
|
*** [[https://www.mirrorservice.org/sites/www.bitsavers.org/bits/TI/Explorer/zeta-c/][ZETA-C]]
|
||||||
** Small C compilers
|
** Small C compilers
|
||||||
|
@ -187,10 +188,10 @@ simple as possible.
|
||||||
*** pcc
|
*** pcc
|
||||||
*** early GCC?
|
*** early GCC?
|
||||||
https://miyuki.github.io/2017/10/04/gcc-archaeology-1.html
|
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 |>
|
<rain1> it may be possible to compile like this: mes |> ack |> pcc |> tcc |>
|
||||||
gcc 4.7.4 |> gcc later version... up to modern
|
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 Bootstrapping Wiki: https://bootstrapping.miraheze.org/wiki/Main_Page
|
||||||
** rain1's hex86
|
** rain1's hex86
|
||||||
https://notabug.org/rain1/hex86/src/master/tests/hex0b3.hex86
|
https://notabug.org/rain1/hex86/src/master/tests/hex0b3.hex86
|
||||||
|
|
6
README
6
README
|
@ -7,7 +7,7 @@
|
||||||
System. Since version 0.22 it has again helped to halve the size of
|
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
|
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
|
[[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.
|
effort for UNIX-like operating systems.
|
||||||
|
|
||||||
The Scheme interpreter is written in ~5,000 LOC of simple C, and the C
|
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
|
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.
|
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
|
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.
|
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
|
[7] https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html
|
||||||
[8] https://www.nongnu.org/nyacc
|
[8] https://www.nongnu.org/nyacc
|
||||||
[9] https://gitlab.com/janneke/tinycc
|
[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
|
[11] https://savannah.nongnu.org/projects/stage0
|
||||||
[12] https://nlnet.nl/project/GNUMes
|
[12] https://nlnet.nl/project/GNUMes
|
||||||
[13] https://nlnet.nl/project/GNUMes-arm
|
[13] https://nlnet.nl/project/GNUMes-arm
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#! @SHELL@
|
#! @SHELL@
|
||||||
|
|
||||||
# GNU Mes --- Maxwell Equations of Software
|
# GNU Mes --- Maxwell Equations of Software
|
||||||
# Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
# Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
#
|
#
|
||||||
# This file is part of GNU Mes.
|
# This file is part of GNU Mes.
|
||||||
#
|
#
|
||||||
|
@ -54,16 +54,18 @@ AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_k
|
||||||
AM_CFLAGS="-L ${srcdest}lib"
|
AM_CFLAGS="-L ${srcdest}lib"
|
||||||
|
|
||||||
mkdir -p $mes_cpu-mes
|
mkdir -p $mes_cpu-mes
|
||||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c
|
cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c .
|
||||||
|
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS crt1.c
|
||||||
cp crt1.o $mes_cpu-mes
|
cp crt1.o $mes_cpu-mes
|
||||||
cp crt1.s $mes_cpu-mes
|
cp crt1.s $mes_cpu-mes
|
||||||
|
|
||||||
objects=
|
objects=
|
||||||
for c in $libc_mini_SOURCES; do
|
for c in $libc_mini_SOURCES; do
|
||||||
o=$(basename $c .c).o
|
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||||
|
o=$b.o
|
||||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||||
echo " CC $c"
|
echo " CC $c"
|
||||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||||
fi
|
fi
|
||||||
objects="$objects $o"
|
objects="$objects $o"
|
||||||
done
|
done
|
||||||
|
@ -72,10 +74,11 @@ $AR crD $mes_cpu-mes/libc-mini.a $objects
|
||||||
|
|
||||||
objects=
|
objects=
|
||||||
for c in $libmescc_SOURCES; do
|
for c in $libmescc_SOURCES; do
|
||||||
o=$(basename $c .c).o
|
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||||
|
o=$b.o
|
||||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||||
echo " CC $c"
|
echo " CC $c"
|
||||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||||
fi
|
fi
|
||||||
objects="$objects $o"
|
objects="$objects $o"
|
||||||
done
|
done
|
||||||
|
@ -84,10 +87,11 @@ $AR crD $mes_cpu-mes/libmescc.a $objects
|
||||||
|
|
||||||
objects=
|
objects=
|
||||||
for c in $libc_SOURCES; do
|
for c in $libc_SOURCES; do
|
||||||
o=$(basename $c .c).o
|
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||||
|
o=$b.o
|
||||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||||
echo " CC $c"
|
echo " CC $c"
|
||||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||||
fi
|
fi
|
||||||
objects="$objects $o"
|
objects="$objects $o"
|
||||||
done
|
done
|
||||||
|
@ -96,10 +100,11 @@ $AR crD $mes_cpu-mes/libc.a $objects
|
||||||
|
|
||||||
objects=
|
objects=
|
||||||
for c in $libc_tcc_SOURCES; do
|
for c in $libc_tcc_SOURCES; do
|
||||||
o=$(basename $c .c).o
|
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||||
|
o=$b.o
|
||||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||||
echo " CC $c"
|
echo " CC $c"
|
||||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||||
fi
|
fi
|
||||||
objects="$objects $o"
|
objects="$objects $o"
|
||||||
done
|
done
|
||||||
|
@ -113,10 +118,11 @@ AM_CFLAGS="-L ${srcdest}lib"
|
||||||
|
|
||||||
objects=
|
objects=
|
||||||
for c in $mes_SOURCES; do
|
for c in $mes_SOURCES; do
|
||||||
o=$(basename $c .c).o
|
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||||
|
o=$b.o
|
||||||
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
if test ! -e $o -o ${srcdest}$c -nt $o; then
|
||||||
echo " CC $c"
|
echo " CC $c"
|
||||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c
|
||||||
fi
|
fi
|
||||||
objects="$objects $o"
|
objects="$objects $o"
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
# GNU Mes --- Maxwell Equations of Software
|
# GNU Mes --- Maxwell Equations of Software
|
||||||
# Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
# Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
#
|
#
|
||||||
# This file is part of GNU Mes.
|
# This file is part of GNU Mes.
|
||||||
#
|
#
|
||||||
|
@ -26,7 +26,8 @@
|
||||||
trap 'test -f .log && cat .log' EXIT
|
trap 'test -f .log && cat .log' EXIT
|
||||||
|
|
||||||
mkdir -p $mes_cpu-mes
|
mkdir -p $mes_cpu-mes
|
||||||
compile lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c
|
cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c .
|
||||||
|
compile crt1.c
|
||||||
cp crt1.o $mes_cpu-mes
|
cp crt1.o $mes_cpu-mes
|
||||||
if test -e crt1.s; then
|
if test -e crt1.s; then
|
||||||
cp crt1.s $mes_cpu-mes
|
cp crt1.s $mes_cpu-mes
|
||||||
|
@ -64,16 +65,6 @@ if test -e libc+tcc.s; then
|
||||||
cp libc+tcc.s $mes_cpu-mes
|
cp libc+tcc.s $mes_cpu-mes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $courageous; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
archive libc+gnu.a $libc_gnu_SOURCES
|
|
||||||
cp libc+gnu.a $mes_cpu-mes
|
|
||||||
if test -e libc+gnu.s; then
|
|
||||||
cp libc+gnu.s $mes_cpu-mes
|
|
||||||
fi
|
|
||||||
|
|
||||||
archive libtcc1.a $libtcc1_SOURCES
|
archive libtcc1.a $libtcc1_SOURCES
|
||||||
cp libtcc1.a $mes_cpu-mes
|
cp libtcc1.a $mes_cpu-mes
|
||||||
if test -e libtcc1.s; then
|
if test -e libtcc1.s; then
|
||||||
|
@ -85,3 +76,13 @@ cp libgetopt.a $mes_cpu-mes
|
||||||
if test -e libgetopt.s; then
|
if test -e libgetopt.s; then
|
||||||
cp libgetopt.s $mes_cpu-mes
|
cp libgetopt.s $mes_cpu-mes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $courageous; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
archive libc+gnu.a $libc_gnu_SOURCES
|
||||||
|
cp libc+gnu.a $mes_cpu-mes
|
||||||
|
if test -e libc+gnu.s; then
|
||||||
|
cp libc+gnu.s $mes_cpu-mes
|
||||||
|
fi
|
||||||
|
|
|
@ -151,7 +151,6 @@ fi
|
||||||
${SHELL} ${srcdest}build-aux/build-lib.sh
|
${SHELL} ${srcdest}build-aux/build-lib.sh
|
||||||
${SHELL} ${srcdest}build-aux/build-source-lib.sh
|
${SHELL} ${srcdest}build-aux/build-source-lib.sh
|
||||||
if $bootstrap; then
|
if $bootstrap; then
|
||||||
rm -f globals.* # FIXME: avoid name clash with globals from lib
|
|
||||||
${SHELL} ${srcdest}build-aux/build-mes.sh
|
${SHELL} ${srcdest}build-aux/build-mes.sh
|
||||||
cp -f bin/mes-mescc ../bin
|
cp -f bin/mes-mescc ../bin
|
||||||
cp -f bin/mes ../bin
|
cp -f bin/mes ../bin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# GNU Mes --- Maxwell Equations of Software
|
# GNU Mes --- Maxwell Equations of Software
|
||||||
# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
#
|
#
|
||||||
# This file is part of GNU Mes.
|
# This file is part of GNU Mes.
|
||||||
#
|
#
|
||||||
|
@ -18,8 +18,12 @@
|
||||||
|
|
||||||
objects=
|
objects=
|
||||||
compile () {
|
compile () {
|
||||||
c=${srcdest}$1
|
if test $(dirname $1) = "."; then
|
||||||
b=$(basename $c .c)
|
c=$1
|
||||||
|
else
|
||||||
|
c=${srcdest}$1
|
||||||
|
fi
|
||||||
|
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||||
o=$b.o
|
o=$b.o
|
||||||
objects="$objects $o"
|
objects="$objects $o"
|
||||||
if test ! -e $o -o $c -nt $o; then
|
if test ! -e $o -o $c -nt $o; then
|
||||||
|
@ -34,7 +38,7 @@ archive () {
|
||||||
sources="$@"
|
sources="$@"
|
||||||
objects=
|
objects=
|
||||||
for c in $sources; do
|
for c in $sources; do
|
||||||
b=$(basename $c .c)
|
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||||
o=$b.o
|
o=$b.o
|
||||||
compile $c
|
compile $c
|
||||||
done
|
done
|
||||||
|
|
|
@ -215,6 +215,7 @@ lib/tests/io/90-stat.c
|
||||||
lib/tests/mes/90-abtod.c
|
lib/tests/mes/90-abtod.c
|
||||||
lib/tests/mes/90-dtoab.c
|
lib/tests/mes/90-dtoab.c
|
||||||
lib/tests/posix/90-execlp.c
|
lib/tests/posix/90-execlp.c
|
||||||
|
lib/tests/posix/90-mmap.c
|
||||||
lib/tests/posix/90-unsetenv.c
|
lib/tests/posix/90-unsetenv.c
|
||||||
lib/tests/signal/90-signal.c
|
lib/tests/signal/90-signal.c
|
||||||
lib/tests/stdio/90-fopen.c
|
lib/tests/stdio/90-fopen.c
|
||||||
|
@ -222,6 +223,7 @@ lib/tests/stdio/90-fopen-append.c
|
||||||
lib/tests/stdio/90-fread-fwrite.c
|
lib/tests/stdio/90-fread-fwrite.c
|
||||||
lib/tests/stdio/90-fseek.c
|
lib/tests/stdio/90-fseek.c
|
||||||
lib/tests/stdio/90-sprintf.c
|
lib/tests/stdio/90-sprintf.c
|
||||||
|
lib/tests/stdio/90-sscanf.c
|
||||||
lib/tests/stdlib/90-strtol.c
|
lib/tests/stdlib/90-strtol.c
|
||||||
lib/tests/string/90-snprintf.c
|
lib/tests/string/90-snprintf.c
|
||||||
lib/tests/string/90-strpbrk.c
|
lib/tests/string/90-strpbrk.c
|
||||||
|
@ -290,6 +292,7 @@ lib/tests/scaffold/70-extern.c
|
||||||
lib/tests/stdio/80-sscanf.c
|
lib/tests/stdio/80-sscanf.c
|
||||||
lib/tests/posix/90-execlp.c
|
lib/tests/posix/90-execlp.c
|
||||||
lib/tests/string/90-snprintf.c
|
lib/tests/string/90-snprintf.c
|
||||||
|
lib/tests/stdio/90-sscanf.c
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -74,7 +74,7 @@ libc_mini_SOURCES="$libc_mini_shared_SOURCES"
|
||||||
|
|
||||||
if test $mes_libc = mes; then
|
if test $mes_libc = mes; then
|
||||||
libc_mini_SOURCES="$libc_mini_SOURCES
|
libc_mini_SOURCES="$libc_mini_SOURCES
|
||||||
lib/mes/mini-write.c
|
lib/mes/write.c
|
||||||
"
|
"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -215,6 +215,7 @@ lib/linux/malloc.c
|
||||||
lib/linux/_read.c
|
lib/linux/_read.c
|
||||||
lib/linux/time.c
|
lib/linux/time.c
|
||||||
lib/linux/unlink.c
|
lib/linux/unlink.c
|
||||||
|
lib/linux/wait4.c
|
||||||
lib/linux/waitpid.c
|
lib/linux/waitpid.c
|
||||||
lib/linux/$mes_cpu-mes-$compiler/syscall.c
|
lib/linux/$mes_cpu-mes-$compiler/syscall.c
|
||||||
lib/linux/getpid.c
|
lib/linux/getpid.c
|
||||||
|
@ -322,6 +323,7 @@ lib/dirent/readdir.c
|
||||||
lib/math/ceil.c
|
lib/math/ceil.c
|
||||||
lib/math/fabs.c
|
lib/math/fabs.c
|
||||||
lib/math/floor.c
|
lib/math/floor.c
|
||||||
|
lib/math/labs.c
|
||||||
lib/mes/fdgets.c
|
lib/mes/fdgets.c
|
||||||
lib/posix/alarm.c
|
lib/posix/alarm.c
|
||||||
lib/posix/execl.c
|
lib/posix/execl.c
|
||||||
|
@ -337,6 +339,7 @@ lib/stdio/fileno.c
|
||||||
lib/stdio/freopen.c
|
lib/stdio/freopen.c
|
||||||
lib/stdio/fscanf.c
|
lib/stdio/fscanf.c
|
||||||
lib/stdio/perror.c
|
lib/stdio/perror.c
|
||||||
|
lib/stdio/rewind.c
|
||||||
lib/stdio/vfscanf.c
|
lib/stdio/vfscanf.c
|
||||||
lib/stdlib/__exit.c
|
lib/stdlib/__exit.c
|
||||||
lib/stdlib/abort.c
|
lib/stdlib/abort.c
|
||||||
|
@ -357,7 +360,9 @@ lib/string/strerror.c
|
||||||
lib/string/strncat.c
|
lib/string/strncat.c
|
||||||
lib/string/strpbrk.c
|
lib/string/strpbrk.c
|
||||||
lib/string/strspn.c
|
lib/string/strspn.c
|
||||||
|
lib/string/strtok.c
|
||||||
lib/stub/__cleanup.c
|
lib/stub/__cleanup.c
|
||||||
|
lib/stub/asctime.c
|
||||||
lib/stub/atan2.c
|
lib/stub/atan2.c
|
||||||
lib/stub/bsearch.c
|
lib/stub/bsearch.c
|
||||||
lib/stub/chown.c
|
lib/stub/chown.c
|
||||||
|
@ -382,7 +387,6 @@ lib/stub/pclose.c
|
||||||
lib/stub/popen.c
|
lib/stub/popen.c
|
||||||
lib/stub/pow.c
|
lib/stub/pow.c
|
||||||
lib/stub/rand.c
|
lib/stub/rand.c
|
||||||
lib/stub/rewind.c
|
|
||||||
lib/stub/setbuf.c
|
lib/stub/setbuf.c
|
||||||
lib/stub/setgrent.c
|
lib/stub/setgrent.c
|
||||||
lib/stub/setlocale.c
|
lib/stub/setlocale.c
|
||||||
|
@ -419,6 +423,8 @@ lib/linux/link.c
|
||||||
lib/linux/lstat.c
|
lib/linux/lstat.c
|
||||||
lib/linux/mkdir.c
|
lib/linux/mkdir.c
|
||||||
lib/linux/mknod.c
|
lib/linux/mknod.c
|
||||||
|
lib/linux/mmap.c
|
||||||
|
lib/linux/munmap.c
|
||||||
lib/linux/nanosleep.c
|
lib/linux/nanosleep.c
|
||||||
lib/linux/pipe.c
|
lib/linux/pipe.c
|
||||||
lib/linux/readlink.c
|
lib/linux/readlink.c
|
||||||
|
|
|
@ -48,7 +48,6 @@ sed -ri \
|
||||||
include/mes/mes.h \
|
include/mes/mes.h \
|
||||||
include/mes/symbols.h \
|
include/mes/symbols.h \
|
||||||
include/mes/builtins.h \
|
include/mes/builtins.h \
|
||||||
include/m2/lib.h \
|
|
||||||
src/builtins.c \
|
src/builtins.c \
|
||||||
src/cc.c \
|
src/cc.c \
|
||||||
src/core.c \
|
src/core.c \
|
||||||
|
|
|
@ -77,8 +77,8 @@ GUILE=${GUILE-$(command -v guile)} || true
|
||||||
HEX2=${HEX2-$(command -v hex2)}
|
HEX2=${HEX2-$(command -v hex2)}
|
||||||
LDPFLAGS=${LDFLAGS-}
|
LDPFLAGS=${LDFLAGS-}
|
||||||
M1=${M1-$(command -v M1)}
|
M1=${M1-$(command -v M1)}
|
||||||
M2_PLANET=${M1-$(command -v M2-Planet)}
|
M2_PLANET=${M2_PLANET-$(command -v M2-Planet)} || true
|
||||||
KAEM=${KAEM-$(command -v kaem)}
|
KAEM=${KAEM-$(command -v kaem)} || true
|
||||||
MES_FOR_BUILD=${MES_FOR_BUILD-$(command -v mes || command -v guile || echo mes)}
|
MES_FOR_BUILD=${MES_FOR_BUILD-$(command -v mes || command -v guile || echo mes)}
|
||||||
GIT=${GIT-$(command -v git)} || true
|
GIT=${GIT-$(command -v git)} || true
|
||||||
PERL=${PERL-$(command -v perl)} || true
|
PERL=${PERL-$(command -v perl)} || true
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
@display
|
@display
|
||||||
Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
|
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
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
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
|
of the GNU Free Documentation License from time to time. Such new
|
||||||
versions will be similar in spirit to the present version, but may
|
versions will be similar in spirit to the present version, but may
|
||||||
differ in detail to address new problems or concerns. See
|
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.
|
Each version of the License is given a distinguishing version number.
|
||||||
If the Document specifies that a particular numbered version of this
|
If the Document specifies that a particular numbered version of this
|
||||||
|
|
22
doc/mes.texi
22
doc/mes.texi
|
@ -204,7 +204,7 @@ Freedom 1.
|
||||||
@section Reproducible Builds
|
@section Reproducible Builds
|
||||||
|
|
||||||
The current Reproducible Builds effort incubated in the Debian
|
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
|
organized by Lunar. Quoting the Reproducible Builds
|
||||||
website@footnote{@url{https://reproducible-builds.org/,Reproducible
|
website@footnote{@url{https://reproducible-builds.org/,Reproducible
|
||||||
Builds}}
|
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
|
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
|
tricky to fully trust@footnote{ Ken Thompson's 1984 Turing award
|
||||||
acceptance speech
|
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
|
Reflections on Trusting Tust}.} a computer that was bootstrapped in this
|
||||||
way.
|
way.
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ and mescc-tools can be removed.
|
||||||
As fate would have it, I stumbled upon this
|
As fate would have it, I stumbled upon this
|
||||||
@url{https://queue.acm.org/detail.cfm?id=1039523, interview with Alan
|
@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
|
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:
|
LISP-1.5} manual:
|
||||||
|
|
||||||
@quotation
|
@quotation
|
||||||
|
@ -553,11 +553,11 @@ in the Mes source tree for additional details.
|
||||||
GNU Mes depends on the following packages:
|
GNU Mes depends on the following packages:
|
||||||
|
|
||||||
@itemize
|
@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,
|
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{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,
|
@item @url{https://savannah.gnu.org/projects/mescc-tools/, mescc-tools}, version 1.4.0,
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ responsibility.
|
||||||
The Reduced Binary Seed bootstrap currently adopted by Guix@footnote{See
|
The Reduced Binary Seed bootstrap currently adopted by Guix@footnote{See
|
||||||
@file{gnu/packages/commencement.scm} in the @var{master} branch in Guix
|
@file{gnu/packages/commencement.scm} in the @var{master} branch in Guix
|
||||||
git
|
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.
|
In its intiial form it is only available for x86-linux and armhf-linux.
|
||||||
|
|
||||||
Currently, it goes like this:
|
Currently, it goes like this:
|
||||||
|
@ -935,7 +935,7 @@ The @var{option}s can be among the following:
|
||||||
align @var{symbol}, the default is @code{functions}; other valid values
|
align @var{symbol}, the default is @code{functions}; other valid values
|
||||||
are: @code{globals}.
|
are: @code{globals}.
|
||||||
|
|
||||||
@item --base-address=ADRRESS
|
@item --base-address=ADDRESS
|
||||||
use BaseAddress ADDRESS [0x1000000]
|
use BaseAddress ADDRESS [0x1000000]
|
||||||
|
|
||||||
@item -c
|
@item -c
|
||||||
|
@ -1155,8 +1155,8 @@ Porting MesCC:
|
||||||
The Perfect Setup to hack on Mes is basically the perfect setup used
|
The Perfect Setup to hack on Mes is basically the perfect setup used
|
||||||
for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
|
for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
|
||||||
Manual}). First, you need more than an editor, you need
|
Manual}). First, you need more than an editor, you need
|
||||||
@url{http://www.gnu.org/software/emacs, Emacs}, empowered by the
|
@url{https://www.gnu.org/software/emacs, Emacs}, empowered by the
|
||||||
wonderful @url{http://nongnu.org/geiser/, Geiser}.
|
wonderful @url{https://nongnu.org/geiser/, Geiser}.
|
||||||
|
|
||||||
Geiser allows for interactive and incremental development from within
|
Geiser allows for interactive and incremental development from within
|
||||||
Emacs: code compilation and evaluation from within buffers, access to
|
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
|
@cindex coding style
|
||||||
When writing Scheme code, we follow common wisdom among Scheme
|
When writing Scheme code, we follow common wisdom among Scheme
|
||||||
programmers. In general, we follow the
|
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
|
Style Rules}. This document happens to describe the conventions mostly
|
||||||
used in Guile’s code too. It is very thoughtful and well written, so
|
used in Guile’s code too. It is very thoughtful and well written, so
|
||||||
please do read it.
|
please do read it.
|
||||||
|
|
|
@ -87,7 +87,7 @@ get_machine.")
|
||||||
(define-public m2-planet
|
(define-public m2-planet
|
||||||
(package
|
(package
|
||||||
(name "m2-planet")
|
(name "m2-planet")
|
||||||
(version "1.9.0")
|
(version "1.10.0")
|
||||||
(source (origin
|
(source (origin
|
||||||
(method git-fetch)
|
(method git-fetch)
|
||||||
(uri (git-reference
|
(uri (git-reference
|
||||||
|
@ -97,7 +97,7 @@ get_machine.")
|
||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"0cgvvq91cbxxm93k8ayyvhpaf3c2lv10qw4wyqwn3hc1qb1cfyvr"))))
|
"03ixvfdzhyy1d94iqpwl0p924pdvdp7yq4ggm05w3c013kzy2y12"))))
|
||||||
(native-inputs (list mescc-tools))
|
(native-inputs (list mescc-tools))
|
||||||
(build-system gnu-build-system)
|
(build-system gnu-build-system)
|
||||||
(arguments
|
(arguments
|
||||||
|
@ -189,7 +189,7 @@ extensive examples, including parsers for the Javascript and C99 languages.")
|
||||||
(uri (string-append
|
(uri (string-append
|
||||||
"https://ftp.gnu.org/pub/gnu/mes/mes-" version ".tar.gz"))
|
"https://ftp.gnu.org/pub/gnu/mes/mes-" version ".tar.gz"))
|
||||||
(sha256
|
(sha256
|
||||||
(base32 #!mes!# "0d855agwawjjzwbjmvb5xlbwg77zdpwbjm9kjxc2wqvn0vmhq4im"))))
|
(base32 #!mes!# "0246sy5zm49zw4zs87hrq1j1x74mchijh4rlj2mzlwjccha5cybs"))))
|
||||||
(build-system gnu-build-system)
|
(build-system gnu-build-system)
|
||||||
(supported-systems '("aarch64-linux" "armhf-linux" "i686-linux" "x86_64-linux"))
|
(supported-systems '("aarch64-linux" "armhf-linux" "i686-linux" "x86_64-linux"))
|
||||||
(propagated-inputs (list mescc-tools nyacc))
|
(propagated-inputs (list mescc-tools nyacc))
|
||||||
|
|
|
@ -69,8 +69,11 @@
|
||||||
#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode)
|
#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode)
|
||||||
int dup (int old);
|
int dup (int old);
|
||||||
int dup2 (int old, int new);
|
int dup2 (int old, int new);
|
||||||
|
|
||||||
|
#if !__M2__
|
||||||
int fcntl (int filedes, int command, ...);
|
int fcntl (int filedes, int command, ...);
|
||||||
int open (char const *s, int flags, ...);
|
int open (char const *s, int flags, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // ! SYSTEM_LIBC
|
#endif // ! SYSTEM_LIBC
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,19 @@
|
||||||
#define DBL_MIN_EXP -1021
|
#define DBL_MIN_EXP -1021
|
||||||
#define LDBL_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 // ! SYSTEM_LIBC
|
||||||
|
|
||||||
#endif // __MES_FLOAT_H
|
#endif // __MES_FLOAT_H
|
||||||
|
|
|
@ -25,47 +25,29 @@
|
||||||
|
|
||||||
/* libc-mini */
|
/* libc-mini */
|
||||||
#ifndef SYS_exit
|
#ifndef SYS_exit
|
||||||
// CONSTANT SYS_exit 0x01
|
|
||||||
#define SYS_exit 0x01
|
#define SYS_exit 0x01
|
||||||
#endif
|
#endif
|
||||||
#ifndef SYS_write
|
#ifndef SYS_write
|
||||||
// CONSTANT SYS_write 0x04
|
|
||||||
#define SYS_write 0x04
|
#define SYS_write 0x04
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* libc */
|
/* libc */
|
||||||
// CONSTANT SYS_fork 0x02
|
|
||||||
#define SYS_fork 0x02
|
#define SYS_fork 0x02
|
||||||
// CONSTANT SYS_read 0x03
|
|
||||||
#define SYS_read 0x03
|
#define SYS_read 0x03
|
||||||
// CONSTANT SYS_open 0x05
|
|
||||||
#define SYS_open 0x05
|
#define SYS_open 0x05
|
||||||
//#define SYS_waitpid
|
//#define SYS_waitpid
|
||||||
// CONSTANT SYS_wait4 0x72
|
|
||||||
#define SYS_wait4 0x72
|
#define SYS_wait4 0x72
|
||||||
// CONSTANT SYS_execve 0x0b
|
|
||||||
#define SYS_execve 0x0b
|
#define SYS_execve 0x0b
|
||||||
// CONSTANT SYS_chmod 0x0f
|
|
||||||
#define SYS_chmod 0x0f
|
#define SYS_chmod 0x0f
|
||||||
// CONSTANT SYS_access 0x21
|
|
||||||
#define SYS_access 0x21
|
#define SYS_access 0x21
|
||||||
// CONSTANT SYS_brk 0x2d
|
|
||||||
#define SYS_brk 0x2d
|
#define SYS_brk 0x2d
|
||||||
// CONSTANT SYS_ioctl 0x36
|
|
||||||
#define SYS_ioctl 0x36
|
#define SYS_ioctl 0x36
|
||||||
// CONSTANT SYS_fsync 0x76
|
|
||||||
#define SYS_fsync 0x76
|
#define SYS_fsync 0x76
|
||||||
// CONSTANT SYS_getcwd 0xb7
|
|
||||||
#define SYS_getcwd 0xb7
|
#define SYS_getcwd 0xb7
|
||||||
// CONSTANT SYS_dup 0x29
|
|
||||||
#define SYS_dup 0x29
|
#define SYS_dup 0x29
|
||||||
// CONSTANT SYS_dup2 0x3f
|
|
||||||
#define SYS_dup2 0x3f
|
#define SYS_dup2 0x3f
|
||||||
// CONSTANT SYS_unlink 0x0a
|
|
||||||
#define SYS_unlink 0x0a
|
#define SYS_unlink 0x0a
|
||||||
// CONSTANT SYS_gettimeofday 0x4e
|
|
||||||
#define SYS_gettimeofday 0x4e
|
#define SYS_gettimeofday 0x4e
|
||||||
// CONSTANT SYS_clock_gettime 0x107
|
|
||||||
#define SYS_clock_gettime 0x107
|
#define SYS_clock_gettime 0x107
|
||||||
|
|
||||||
/* libc+tcc */
|
/* libc+tcc */
|
||||||
|
@ -109,4 +91,8 @@
|
||||||
#define SYS_readlink 0x55
|
#define SYS_readlink 0x55
|
||||||
#define SYS_mknod 0x0e
|
#define SYS_mknod 0x0e
|
||||||
|
|
||||||
|
// gcc-4.6.4
|
||||||
|
#define SYS_mmap 0x5a
|
||||||
|
#define SYS_munmap 0x5b
|
||||||
|
|
||||||
#endif /* __MES_LINUX_ARM_SYSCALL_H */
|
#endif /* __MES_LINUX_ARM_SYSCALL_H */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -22,50 +22,30 @@
|
||||||
|
|
||||||
/* libc-mini */
|
/* libc-mini */
|
||||||
#ifndef SYS_exit
|
#ifndef SYS_exit
|
||||||
// CONSTANT SYS_exit 0x01
|
|
||||||
#define SYS_exit 0x01
|
#define SYS_exit 0x01
|
||||||
#endif
|
#endif
|
||||||
#ifndef SYS_write
|
#ifndef SYS_write
|
||||||
// CONSTANT SYS_write 0x04
|
|
||||||
#define SYS_write 0x04
|
#define SYS_write 0x04
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* libc */
|
/* libc */
|
||||||
// CONSTANT SYS_fork 0x02
|
|
||||||
#define SYS_fork 0x02
|
#define SYS_fork 0x02
|
||||||
// CONSTANT SYS_read 0x03
|
|
||||||
#define SYS_read 0x03
|
#define SYS_read 0x03
|
||||||
// CONSTANT SYS_open 0x05
|
|
||||||
#define SYS_open 0x05
|
#define SYS_open 0x05
|
||||||
// CONSTANT SYS_waitpid 0x07
|
|
||||||
#define SYS_waitpid 0x07
|
#define SYS_waitpid 0x07
|
||||||
// CONSTANT SYS_wait4 0x72
|
|
||||||
#define SYS_wait4 0x72
|
#define SYS_wait4 0x72
|
||||||
// CONSTANT SYS_execve 0x0b
|
|
||||||
#define SYS_execve 0x0b
|
#define SYS_execve 0x0b
|
||||||
// CONSTANT SYS_chmod 0x0f
|
|
||||||
#define SYS_chmod 0x0f
|
#define SYS_chmod 0x0f
|
||||||
// CONSTANT SYS_access 0x21
|
|
||||||
#define SYS_access 0x21
|
#define SYS_access 0x21
|
||||||
// CONSTANT SYS_brk 0x2d
|
|
||||||
#define SYS_brk 0x2d
|
#define SYS_brk 0x2d
|
||||||
// CONSTANT SYS_ioctl 0x36
|
|
||||||
#define SYS_ioctl 0x36
|
#define SYS_ioctl 0x36
|
||||||
// CONSTANT SYS_fsync 0x76
|
|
||||||
#define SYS_fsync 0x76
|
#define SYS_fsync 0x76
|
||||||
// CONSTANT SYS_getcwd 0xb7
|
|
||||||
#define SYS_getcwd 0xb7
|
#define SYS_getcwd 0xb7
|
||||||
// CONSTANT SYS_dup 0x29
|
|
||||||
#define SYS_dup 0x29
|
#define SYS_dup 0x29
|
||||||
// CONSTANT SYS_dup2 0x3f
|
|
||||||
#define SYS_dup2 0x3f
|
#define SYS_dup2 0x3f
|
||||||
// CONSTANT SYS_unlink 0x0a
|
|
||||||
#define SYS_unlink 0x0a
|
#define SYS_unlink 0x0a
|
||||||
// CONSTANT SYS_gettimeofday 0x4e
|
|
||||||
#define SYS_gettimeofday 0x4e
|
#define SYS_gettimeofday 0x4e
|
||||||
// CONSTANT SYS_clock_gettime 0x109
|
|
||||||
#define SYS_clock_gettime 0x109
|
#define SYS_clock_gettime 0x109
|
||||||
// CONSTANT SYS_time 0x0d
|
|
||||||
#define SYS_time 0x0d
|
#define SYS_time 0x0d
|
||||||
|
|
||||||
/* libc+tcc */
|
/* libc+tcc */
|
||||||
|
@ -112,4 +92,8 @@
|
||||||
#define SYS_readlink 0x55
|
#define SYS_readlink 0x55
|
||||||
#define SYS_mknod 0x0e
|
#define SYS_mknod 0x0e
|
||||||
|
|
||||||
|
// gcc-4.6.4
|
||||||
|
#define SYS_mmap 0x5a
|
||||||
|
#define SYS_munmap 0x5b
|
||||||
|
|
||||||
#endif /* __MES_LINUX_X86_SYSCALL_H */
|
#endif /* __MES_LINUX_X86_SYSCALL_H */
|
||||||
|
|
|
@ -85,4 +85,8 @@
|
||||||
#define SYS_readlink 0x59
|
#define SYS_readlink 0x59
|
||||||
#define SYS_mknod 0x85
|
#define SYS_mknod 0x85
|
||||||
|
|
||||||
|
// gcc-4.6.4
|
||||||
|
#define SYS_mmap 0x09
|
||||||
|
#define SYS_munmap 0x0b
|
||||||
|
|
||||||
#endif // __MES_LINUX_X86_64_SYSCALL_H
|
#endif // __MES_LINUX_X86_64_SYSCALL_H
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 */
|
|
|
@ -31,6 +31,7 @@ double cos (double x);
|
||||||
double exp (double x);
|
double exp (double x);
|
||||||
double fabs (double number);
|
double fabs (double number);
|
||||||
double floor (double x);
|
double floor (double x);
|
||||||
|
long int labs (long int number);
|
||||||
double ldexp (double value, int exponent);
|
double ldexp (double value, int exponent);
|
||||||
double log (double x);
|
double log (double x);
|
||||||
double modf (double value, double *integer_part);
|
double modf (double value, double *integer_part);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -23,76 +23,32 @@
|
||||||
|
|
||||||
/* Cell types */
|
/* Cell types */
|
||||||
|
|
||||||
// CONSTANT TCHAR 0
|
|
||||||
#define TCHAR 0
|
#define TCHAR 0
|
||||||
|
|
||||||
// CONSTANT TBYTES 1
|
|
||||||
#define TBYTES 1
|
#define TBYTES 1
|
||||||
// CONSTANT TCLOSURE 2
|
|
||||||
#define TCLOSURE 2
|
#define TCLOSURE 2
|
||||||
// CONSTANT TCONTINUATION 3
|
|
||||||
#define TCONTINUATION 3
|
#define TCONTINUATION 3
|
||||||
// CONSTANT TKEYWORD 4
|
|
||||||
#define TKEYWORD 4
|
#define TKEYWORD 4
|
||||||
// CONSTANT TMACRO 5
|
|
||||||
#define TMACRO 5
|
#define TMACRO 5
|
||||||
// CONSTANT TNUMBER 6
|
|
||||||
#define TNUMBER 6
|
#define TNUMBER 6
|
||||||
// CONSTANT TPAIR 7
|
|
||||||
#define TPAIR 7
|
#define TPAIR 7
|
||||||
// CONSTANT TPORT 8
|
|
||||||
#define TPORT 8
|
#define TPORT 8
|
||||||
// CONSTANT TREF 9
|
|
||||||
#define TREF 9
|
#define TREF 9
|
||||||
// CONSTANT TSPECIAL 10
|
|
||||||
#define TSPECIAL 10
|
#define TSPECIAL 10
|
||||||
// CONSTANT TSTRING 11
|
|
||||||
#define TSTRING 11
|
#define TSTRING 11
|
||||||
// CONSTANT TSTRUCT 12
|
|
||||||
#define TSTRUCT 12
|
#define TSTRUCT 12
|
||||||
// CONSTANT TSYMBOL 13
|
|
||||||
#define TSYMBOL 13
|
#define TSYMBOL 13
|
||||||
// CONSTANT TVALUES 14
|
|
||||||
#define TVALUES 14
|
#define TVALUES 14
|
||||||
// CONSTANT TVARIABLE 15
|
|
||||||
#define TVARIABLE 15
|
#define TVARIABLE 15
|
||||||
// CONSTANT TVECTOR 16
|
|
||||||
#define TVECTOR 16
|
#define TVECTOR 16
|
||||||
// CONSTANT TBROKEN_HEART 17
|
|
||||||
#define TBROKEN_HEART 17
|
#define TBROKEN_HEART 17
|
||||||
|
|
||||||
/* Struct types */
|
/* Struct types */
|
||||||
|
|
||||||
// CONSTANT STRUCT_TYPE 0
|
|
||||||
#define STRUCT_TYPE 0
|
#define STRUCT_TYPE 0
|
||||||
// CONSTANT STRUCT_PRINTER 1
|
|
||||||
#define STRUCT_PRINTER 1
|
#define STRUCT_PRINTER 1
|
||||||
|
|
||||||
// CONSTANT GC_FRAME_SIZE 5
|
|
||||||
#define GC_FRAME_SIZE 5
|
#define GC_FRAME_SIZE 5
|
||||||
// CONSTANT GC_FRAME_PROCEDURE 4
|
|
||||||
#define 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 */
|
#endif /* __MES_CONSTANTS_H */
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -25,21 +25,27 @@
|
||||||
#include <mes/config.h>
|
#include <mes/config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CONSTANT STDIN 0
|
|
||||||
#ifndef STDIN
|
#ifndef STDIN
|
||||||
#define STDIN 0
|
#define STDIN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CONSTANT STDOUT 1
|
|
||||||
#ifndef STDOUT
|
#ifndef STDOUT
|
||||||
#define STDOUT 1
|
#define STDOUT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CONSTANT STDERR 2
|
|
||||||
#ifndef STDERR
|
#ifndef STDERR
|
||||||
#define STDERR 2
|
#define STDERR 2
|
||||||
#endif
|
#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 char **environ;
|
||||||
extern int __stdin;
|
extern int __stdin;
|
||||||
extern int __stdout;
|
extern int __stdout;
|
||||||
|
@ -63,10 +69,14 @@ int oputs (char const *s);
|
||||||
#ifndef __MES_SIZE_T
|
#ifndef __MES_SIZE_T
|
||||||
#define __MES_SIZE_T
|
#define __MES_SIZE_T
|
||||||
#undef size_t
|
#undef size_t
|
||||||
|
#if __M2__
|
||||||
|
typedef unsigned size_t;
|
||||||
|
#else
|
||||||
typedef unsigned long size_t;
|
typedef unsigned long size_t;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef _SSIZE_T
|
#ifndef _SSIZE_T
|
||||||
#define _SSIZE_T
|
#define _SSIZE_T
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -23,6 +23,9 @@
|
||||||
|
|
||||||
#include <mes/lib-mini.h>
|
#include <mes/lib-mini.h>
|
||||||
|
|
||||||
|
#define __FILEDES_MAX 512
|
||||||
|
extern char *__brk;
|
||||||
|
|
||||||
char *cast_intp_to_charp (int const *i);
|
char *cast_intp_to_charp (int const *i);
|
||||||
char *cast_long_to_charp (long i);
|
char *cast_long_to_charp (long i);
|
||||||
long cast_charp_to_long (char const *);
|
long cast_charp_to_long (char const *);
|
||||||
|
@ -34,14 +37,11 @@ void __ungetc_init ();
|
||||||
void __ungetc_clear (int filedes);
|
void __ungetc_clear (int filedes);
|
||||||
void __ungetc_set (int filedes, int c);
|
void __ungetc_set (int filedes, int c);
|
||||||
int __ungetc_p (int filedes);
|
int __ungetc_p (int filedes);
|
||||||
double abtod (char const **p, int base);
|
|
||||||
long abtol (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 *itoa (int number);
|
||||||
char *ltoa (long number);
|
char *ltoa (long number);
|
||||||
char *ltoab (long x, int base);
|
char *ltoab (long x, int base);
|
||||||
char *ntoab (long number, unsigned base, int signed_p);
|
char *ntoab (long number, unsigned base, int signed_p);
|
||||||
char *ultoa (unsigned long number);
|
|
||||||
char *utoa (unsigned number);
|
char *utoa (unsigned number);
|
||||||
int eputc (int c);
|
int eputc (int c);
|
||||||
int fdgetc (int fd);
|
int fdgetc (int fd);
|
||||||
|
@ -61,10 +61,12 @@ char *search_path (char const *file_name);
|
||||||
ssize_t _read (int fd, void *buffer, size_t size);
|
ssize_t _read (int fd, void *buffer, size_t size);
|
||||||
void assert_msg (int check, char *msg);
|
void assert_msg (int check, char *msg);
|
||||||
|
|
||||||
extern char *__brk;
|
long __mesabi_imod (long a, long b);
|
||||||
extern void (*__call_at_exit) (void);
|
long __mesabi_idiv (long a, long b);
|
||||||
|
void *__memcpy (void *dest, void const *src, size_t n);
|
||||||
#define __FILEDES_MAX 512
|
void *__memmove (void *dest, void const *src, size_t n);
|
||||||
|
void *__memset (void *s, int c, size_t n);
|
||||||
|
int __raise (int signal);
|
||||||
|
|
||||||
#if !SYSTEM_LIBC
|
#if !SYSTEM_LIBC
|
||||||
void __assert_fail (char *s);
|
void __assert_fail (char *s);
|
||||||
|
@ -74,16 +76,15 @@ void _exit (int code);
|
||||||
long brk (void *addr);
|
long brk (void *addr);
|
||||||
#endif // !SYSTEM_LIBC
|
#endif // !SYSTEM_LIBC
|
||||||
|
|
||||||
long __mesabi_imod (long a, long b);
|
#if !__M2__
|
||||||
long __mesabi_idiv (long a, long b);
|
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);
|
||||||
unsigned long __mesabi_umod (unsigned long a, unsigned 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_udiv (unsigned long a, unsigned long b);
|
||||||
unsigned long __mesabi_uldiv (unsigned long a, unsigned long b,
|
unsigned long __mesabi_uldiv (unsigned long a, unsigned long b,
|
||||||
unsigned long *remainder);
|
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
|
#endif //__MES_LIB_H
|
||||||
|
|
|
@ -53,6 +53,15 @@ 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 */
|
/* mes */
|
||||||
extern char *g_datadir;
|
extern char *g_datadir;
|
||||||
extern int g_debug;
|
extern int g_debug;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -137,14 +137,8 @@ extern struct scm *cell_type_broken_heart;
|
||||||
extern struct scm *cell_symbol_program;
|
extern struct scm *cell_symbol_program;
|
||||||
extern struct scm *cell_symbol_test;
|
extern struct scm *cell_symbol_test;
|
||||||
|
|
||||||
// CONSTANT SYMBOL_MAX 114
|
|
||||||
#define SYMBOL_MAX 114
|
#define SYMBOL_MAX 114
|
||||||
|
|
||||||
// CONSTANT CELL_UNSPECIFIED 7
|
|
||||||
#define CELL_UNSPECIFIED 7
|
#define CELL_UNSPECIFIED 7
|
||||||
|
|
||||||
// CONSTANT CELL_SYMBOL_RECORD_TYPE 82
|
|
||||||
#define CELL_SYMBOL_RECORD_TYPE 82
|
#define CELL_SYMBOL_RECORD_TYPE 82
|
||||||
|
|
||||||
|
|
||||||
#endif /* __MES_SYMBOLS_H */
|
#endif /* __MES_SYMBOLS_H */
|
||||||
|
|
|
@ -29,9 +29,12 @@
|
||||||
|
|
||||||
#define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long)))
|
#define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long)))
|
||||||
|
|
||||||
typedef struct {
|
#if !__M2__
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
unsigned long items[_SIGSET_NITEMS];
|
unsigned long items[_SIGSET_NITEMS];
|
||||||
} sigset_t;
|
} sigset_t;
|
||||||
|
#endif
|
||||||
typedef long stack_t;
|
typedef long stack_t;
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -91,6 +94,7 @@ typedef long stack_t;
|
||||||
#define SA_NOMASK SA_NODEFER
|
#define SA_NOMASK SA_NODEFER
|
||||||
#define SA_ONESHOT SA_RESETHAND
|
#define SA_ONESHOT SA_RESETHAND
|
||||||
|
|
||||||
|
#if !__M2__ // lacks short, casts
|
||||||
typedef struct siginfo_t
|
typedef struct siginfo_t
|
||||||
{
|
{
|
||||||
int si_signo;
|
int si_signo;
|
||||||
|
@ -120,7 +124,7 @@ typedef struct siginfo_t
|
||||||
} siginfo_t;
|
} siginfo_t;
|
||||||
// *INDENT-ON*
|
// *INDENT-ON*
|
||||||
|
|
||||||
#if __MESC__
|
#if __M2__ || __MESC__
|
||||||
typedef long sighandler_t;
|
typedef long sighandler_t;
|
||||||
#else
|
#else
|
||||||
typedef void (*sighandler_t) (int);
|
typedef void (*sighandler_t) (int);
|
||||||
|
@ -255,6 +259,7 @@ int sigemptyset (sigset_t * set);
|
||||||
#endif
|
#endif
|
||||||
int sigprocmask (int how, sigset_t const *set, sigset_t * oldset);
|
int sigprocmask (int how, sigset_t const *set, sigset_t * oldset);
|
||||||
|
|
||||||
|
#endif // !__M2__
|
||||||
#endif //! SYSTEM_LIBC
|
#endif //! SYSTEM_LIBC
|
||||||
|
|
||||||
#endif // __MES_SIGNAL_H
|
#endif // __MES_SIGNAL_H
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2017,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
* Copyright © 2018 Peter De Wachter <pdewacht@gmail.com>
|
* Copyright © 2018 Peter De Wachter <pdewacht@gmail.com>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
|
@ -87,6 +87,12 @@ typedef unsigned uintmax_t;
|
||||||
|
|
||||||
#define INT_MIN -2147483648
|
#define INT_MIN -2147483648
|
||||||
#define INT_MAX 2147483647
|
#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__
|
#if __i386__ || __arm__
|
||||||
#define LONG_MIN INT_MIN
|
#define LONG_MIN INT_MIN
|
||||||
#define LONG_MAX INT_MAX
|
#define LONG_MAX INT_MAX
|
||||||
|
@ -105,6 +111,8 @@ typedef unsigned uintmax_t;
|
||||||
#define SIZE_MAX UINT64_MAX
|
#define SIZE_MAX UINT64_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SSIZE_MAX LONG_MAX
|
||||||
|
|
||||||
#endif // ! SYSTEM_LIBC
|
#endif // ! SYSTEM_LIBC
|
||||||
|
|
||||||
#endif // __MES_STDINT_H
|
#endif // __MES_STDINT_H
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -65,30 +65,34 @@ int ferror (FILE * stream);
|
||||||
int fflush (FILE * stream);
|
int fflush (FILE * stream);
|
||||||
int fgetc (FILE * stream);
|
int fgetc (FILE * stream);
|
||||||
char *fgets (char *s, int size, FILE * stream);
|
char *fgets (char *s, int size, FILE * stream);
|
||||||
int fprintf (FILE * stream, char const *format, ...);
|
|
||||||
int fpurge (FILE * stream);
|
int fpurge (FILE * stream);
|
||||||
int fputc (int c, FILE * stream);
|
int fputc (int c, FILE * stream);
|
||||||
int fputs (char const *s, 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 fseek (FILE * stream, long offset, int whence);
|
||||||
int getc (FILE * stream);
|
int getc (FILE * stream);
|
||||||
int getchar (void);
|
int getchar (void);
|
||||||
char *getlogin (void);
|
char *getlogin (void);
|
||||||
int printf (char const *format, ...);
|
|
||||||
int putc (int c, FILE * stream);
|
int putc (int c, FILE * stream);
|
||||||
int putchar (int c);
|
int putchar (int c);
|
||||||
int puts (char const *s);
|
int puts (char const *s);
|
||||||
int remove (char const *file_name);
|
int remove (char const *file_name);
|
||||||
|
void rewind (FILE * stream);
|
||||||
int setvbuf (FILE * stream, char *buf, int mode, size_t size);
|
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);
|
int ungetc (int c, FILE * stream);
|
||||||
long ftell (FILE * stream);
|
long ftell (FILE * stream);
|
||||||
size_t fread (void *ptr, size_t size, size_t count, FILE * stream);
|
size_t fread (void *ptr, size_t size, size_t count, FILE * stream);
|
||||||
size_t freadahead (FILE * fp);
|
size_t freadahead (FILE * fp);
|
||||||
size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream);
|
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 // ! SYSTEM_LIBC
|
||||||
|
|
||||||
#endif // __MES_STDIO_H
|
#endif // __MES_STDIO_H
|
||||||
|
|
|
@ -48,6 +48,7 @@ char *strncpy (char *to, char const *from, size_t size);
|
||||||
int strncmp (char const *, char const *, size_t);
|
int strncmp (char const *, char const *, size_t);
|
||||||
char *strrchr (char const *s, int c);
|
char *strrchr (char const *s, int c);
|
||||||
char *strstr (char const *haystack, char const *needle);
|
char *strstr (char const *haystack, char const *needle);
|
||||||
|
char *strtok (char *new_string, char const *delimiters);
|
||||||
char *strlwr (char *string);
|
char *strlwr (char *string);
|
||||||
char *strupr (char *string);
|
char *strupr (char *string);
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,13 @@
|
||||||
|
|
||||||
#define TCGETS 0x5401
|
#define TCGETS 0x5401
|
||||||
#define TCGETA 0x5405
|
#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 ioctl (int fd, unsigned long request, ...);
|
||||||
int ioctl3 (int fd, unsigned long request, long data);
|
int ioctl3 (int fd, unsigned long request, long data);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // ! SYSTEM_LIBC
|
#endif // ! SYSTEM_LIBC
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -25,19 +25,25 @@
|
||||||
#include_next <sys/mman.h>
|
#include_next <sys/mman.h>
|
||||||
#else // ! SYSTEM_LIBC
|
#else // ! SYSTEM_LIBC
|
||||||
|
|
||||||
#ifndef __MES_SIZE_T
|
#include <sys/types.h>
|
||||||
#define __MES_SIZE_T
|
|
||||||
typedef unsigned long size_t;
|
#define MAP_SHARED 0x01
|
||||||
#endif
|
#define MAP_PRIVATE 0x02
|
||||||
|
#define MAP_ANONYMOUS 0x20
|
||||||
|
#define MAP_POPULATE 0x08000
|
||||||
|
|
||||||
|
#define MAP_ANON MAP_ANONYMOUS
|
||||||
|
#define MAP_FAILED ((void*)-1)
|
||||||
|
|
||||||
#define PROT_NONE 0
|
#define PROT_NONE 0
|
||||||
#define PROT_READ 1
|
#define PROT_READ 1
|
||||||
#define PROT_WRITE 2
|
#define PROT_WRITE 2
|
||||||
#define PROT_EXEC 4
|
#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 mprotect (void *addr, size_t len, int prot);
|
||||||
|
int munmap (void *addr, size_t length);
|
||||||
|
|
||||||
#endif // ! SYSTEM_LIBC
|
#endif // ! SYSTEM_LIBC
|
||||||
|
|
||||||
#endif // __MES_SYS_MMAN_H
|
#endif // __MES_SYS_MMAN_H
|
||||||
|
|
||||||
|
|
|
@ -32,20 +32,20 @@ struct rusage
|
||||||
{
|
{
|
||||||
struct timeval ru_utime;
|
struct timeval ru_utime;
|
||||||
struct timeval ru_stime;
|
struct timeval ru_stime;
|
||||||
long int ru_maxrss;
|
long ru_maxrss;
|
||||||
long int ru_ixrss;
|
long ru_ixrss;
|
||||||
long int ru_idrss;
|
long ru_idrss;
|
||||||
long int ru_isrss;
|
long ru_isrss;
|
||||||
long int ru_minflt;
|
long ru_minflt;
|
||||||
long int ru_majflt;
|
long ru_majflt;
|
||||||
long int ru_nswap;
|
long ru_nswap;
|
||||||
long int ru_inblock;
|
long ru_inblock;
|
||||||
long int ru_oublock;
|
long ru_oublock;
|
||||||
long int ru_msgsnd;
|
long ru_msgsnd;
|
||||||
long int ru_msgrcv;
|
long ru_msgrcv;
|
||||||
long int ru_nsignals;
|
long ru_nsignals;
|
||||||
long int ru_nvcsw;
|
long ru_nvcsw;
|
||||||
long int ru_nivcsw;
|
long ru_nivcsw;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RUSAGE_SELF 0
|
#define RUSAGE_SELF 0
|
||||||
|
|
|
@ -36,7 +36,29 @@ typedef int mode_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// *INDENT-OFF*
|
// *INDENT-OFF*
|
||||||
#if __i386__ || __arm__
|
#if __M2__
|
||||||
|
struct stat
|
||||||
|
{
|
||||||
|
unsigned st_dev;
|
||||||
|
unsigned st_ino;
|
||||||
|
char st_mode[2];
|
||||||
|
char st_nlink[2];
|
||||||
|
char st_uid[2];
|
||||||
|
char st_gid[2];
|
||||||
|
unsigned st_rdev;
|
||||||
|
long st_size; /* Linux: unsigned long; glibc: off_t (i.e. signed) */
|
||||||
|
unsigned st_blksize;
|
||||||
|
unsigned st_blocks;
|
||||||
|
time_t st_atime; /* Linux: unsigned long; glibc: time_t */
|
||||||
|
unsigned st_atime_usec;
|
||||||
|
time_t st_mtime; /* Linux: unsigned long; glibc: time_t */
|
||||||
|
unsigned st_mtime_usec;
|
||||||
|
time_t st_ctime; /* Linux: unsigned long; glibc: time_t */
|
||||||
|
unsigned st_ctime_usec;
|
||||||
|
unsigned __foo0;
|
||||||
|
unsigned __foo1;
|
||||||
|
};
|
||||||
|
#elif __i386__ || __arm__
|
||||||
struct stat
|
struct stat
|
||||||
{
|
{
|
||||||
unsigned long st_dev;
|
unsigned long st_dev;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -32,7 +32,12 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef EOF
|
#ifndef EOF
|
||||||
#define EOF -1
|
// FIXME M2_Planet chokes on -1, even inside #if ! __M2__
|
||||||
|
#if __arm__ || __i386__
|
||||||
|
#define EOF 0xffffffff
|
||||||
|
#else
|
||||||
|
#define EOF 0xffffffffffffffff
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NULL
|
#ifndef NULL
|
||||||
|
@ -66,15 +71,23 @@ typedef unsigned gid_t;
|
||||||
#ifndef __MES_INO_T
|
#ifndef __MES_INO_T
|
||||||
#define __MES_INO_T
|
#define __MES_INO_T
|
||||||
#undef ino_t
|
#undef ino_t
|
||||||
|
#if __M2__
|
||||||
|
typedef unsigned ino_t;
|
||||||
|
#else
|
||||||
typedef unsigned long ino_t;
|
typedef unsigned long ino_t;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if __SIZEOF_LONG_LONG__ == 8
|
#if __SIZEOF_LONG_LONG__ == 8
|
||||||
#ifndef __MES_INO64_T
|
#ifndef __MES_INO64_T
|
||||||
#define __MES_INO64_T
|
#define __MES_INO64_T
|
||||||
#undef ino64_t
|
#undef ino64_t
|
||||||
|
#if __M2__
|
||||||
|
typedef unsigned ino64_t;
|
||||||
|
#else
|
||||||
typedef unsigned long long ino64_t;
|
typedef unsigned long long ino64_t;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||||
|
|
||||||
#if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined)
|
#if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined)
|
||||||
|
@ -83,8 +96,12 @@ typedef unsigned long long ino64_t;
|
||||||
#undef intptr_t
|
#undef intptr_t
|
||||||
typedef long intptr_t;
|
typedef long intptr_t;
|
||||||
#undef uintptr_t
|
#undef uintptr_t
|
||||||
|
#if __M2__
|
||||||
|
typedef unsigned uintptr_t;
|
||||||
|
#else
|
||||||
typedef unsigned long uintptr_t;
|
typedef unsigned long uintptr_t;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __MES_OFF_T
|
#ifndef __MES_OFF_T
|
||||||
#define __MES_OFF_T
|
#define __MES_OFF_T
|
||||||
|
@ -96,8 +113,12 @@ typedef long off_t;
|
||||||
#ifndef __MES_OFF64_T
|
#ifndef __MES_OFF64_T
|
||||||
#define __MES_OFF64_T
|
#define __MES_OFF64_T
|
||||||
#undef off64_t
|
#undef off64_t
|
||||||
|
#if __M2__
|
||||||
|
typedef unsigned off64_t;
|
||||||
|
#else
|
||||||
typedef unsigned long long off64_t;
|
typedef unsigned long long off64_t;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||||
|
|
||||||
#ifndef __MES_PID_T
|
#ifndef __MES_PID_T
|
||||||
|
@ -126,9 +147,13 @@ typedef long sigval_t;
|
||||||
#ifndef __MES_SIZE_T
|
#ifndef __MES_SIZE_T
|
||||||
#define __MES_SIZE_T
|
#define __MES_SIZE_T
|
||||||
#undef size_t
|
#undef size_t
|
||||||
|
#if __M2__
|
||||||
|
typedef unsigned size_t;
|
||||||
|
#else
|
||||||
typedef unsigned long size_t;
|
typedef unsigned long size_t;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __MES_SSIZE_T
|
#ifndef __MES_SSIZE_T
|
||||||
#define __MES_SSIZE_T
|
#define __MES_SSIZE_T
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -20,6 +20,8 @@
|
||||||
#ifndef __MES_SYS_WAIT_H
|
#ifndef __MES_SYS_WAIT_H
|
||||||
#define __MES_SYS_WAIT_H 1
|
#define __MES_SYS_WAIT_H 1
|
||||||
|
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
#if SYSTEM_LIBC
|
#if SYSTEM_LIBC
|
||||||
#undef __MES_SYS_WAIT_H
|
#undef __MES_SYS_WAIT_H
|
||||||
#include_next <sys/wait.h>
|
#include_next <sys/wait.h>
|
||||||
|
@ -35,6 +37,8 @@ typedef int pid_t;
|
||||||
|
|
||||||
pid_t waitpid (pid_t pid, int *status_ptr, int options);
|
pid_t waitpid (pid_t pid, int *status_ptr, int options);
|
||||||
pid_t wait (int *status_ptr);
|
pid_t wait (int *status_ptr);
|
||||||
|
pid_t wait4 (pid_t pid, int *wstatus, int options,
|
||||||
|
struct rusage *rusage);
|
||||||
|
|
||||||
#endif // ! SYSTEM_LIBC
|
#endif // ! SYSTEM_LIBC
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
#ifndef __MES_TIME_T
|
#ifndef __MES_TIME_T
|
||||||
#define __MES_TIME_T 1
|
#define __MES_TIME_T 1
|
||||||
typedef long int clockid_t;
|
typedef long clockid_t;
|
||||||
typedef long int time_t;
|
typedef long time_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct tm
|
struct tm
|
||||||
|
@ -56,6 +56,7 @@ struct timespec
|
||||||
#endif // __MES_STRUCT_TIMESPEC
|
#endif // __MES_STRUCT_TIMESPEC
|
||||||
|
|
||||||
#define CLOCK_PROCESS_CPUTIME_ID 2
|
#define CLOCK_PROCESS_CPUTIME_ID 2
|
||||||
|
char *asctime (struct tm const *broken_time);
|
||||||
int clock_gettime (clockid_t clk_id, struct timespec *tp);
|
int clock_gettime (clockid_t clk_id, struct timespec *tp);
|
||||||
struct tm *localtime (time_t const *timep);
|
struct tm *localtime (time_t const *timep);
|
||||||
struct tm *gmtime (time_t const *time);
|
struct tm *gmtime (time_t const *time);
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#! /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,34 +25,41 @@ stage0_cpu=${stage0_cpu:-x86}
|
||||||
mkdir -p m2
|
mkdir -p m2
|
||||||
|
|
||||||
M2-Planet \
|
M2-Planet \
|
||||||
--bootstrap-mode \
|
|
||||||
--debug \
|
--debug \
|
||||||
--architecture ${stage0_cpu} \
|
--architecture ${stage0_cpu} \
|
||||||
-f include/m2/lib.h \
|
-D __linux__=1 \
|
||||||
|
-f include/mes/config.h \
|
||||||
|
-f include/mes/lib-mini.h \
|
||||||
|
-f include/mes/lib.h \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
-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/_exit.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||||
-f lib/mes/globals.c \
|
-f lib/mes/globals.c \
|
||||||
-f lib/m2/cast.c \
|
-f lib/m2/cast.c \
|
||||||
-f lib/m2/exit.c \
|
-f lib/stdlib/exit.c \
|
||||||
-f lib/mes/mini-write.c \
|
-f lib/mes/write.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
|
||||||
-f include/linux/${mes_cpu}/syscall.h \
|
-f include/linux/${mes_cpu}/syscall.h \
|
||||||
|
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
||||||
-f lib/stub/__raise.c \
|
-f lib/stub/__raise.c \
|
||||||
-f lib/linux/brk.c \
|
-f lib/linux/brk.c \
|
||||||
-f lib/m2/malloc.c \
|
-f lib/linux/malloc.c \
|
||||||
-f lib/string/memset.c \
|
-f lib/string/memset.c \
|
||||||
-f lib/m2/read.c \
|
-f lib/linux/read.c \
|
||||||
-f lib/mes/fdgetc.c \
|
-f lib/mes/fdgetc.c \
|
||||||
-f lib/stdio/getchar.c \
|
-f lib/stdio/getchar.c \
|
||||||
-f lib/stdio/putchar.c \
|
-f lib/stdio/putchar.c \
|
||||||
-f lib/m2/open.c \
|
-f lib/stub/__buffered_read.c \
|
||||||
-f lib/m2/mes_open.c \
|
-f lib/linux/_open3.c \
|
||||||
|
-f lib/linux/open.c \
|
||||||
|
-f lib/mes/mes_open.c \
|
||||||
-f lib/string/strlen.c \
|
-f lib/string/strlen.c \
|
||||||
-f lib/mes/eputs.c \
|
-f lib/mes/eputs.c \
|
||||||
-f lib/mes/fdputc.c \
|
-f lib/mes/fdputc.c \
|
||||||
-f lib/mes/eputc.c \
|
-f lib/mes/eputc.c \
|
||||||
\
|
\
|
||||||
|
-f include/time.h \
|
||||||
|
-f include/sys/time.h \
|
||||||
|
-f include/sys/types.h \
|
||||||
-f include/mes/mes.h \
|
-f include/mes/mes.h \
|
||||||
-f include/mes/builtins.h \
|
-f include/mes/builtins.h \
|
||||||
-f include/mes/constants.h \
|
-f include/mes/constants.h \
|
||||||
|
@ -81,17 +88,22 @@ M2-Planet \
|
||||||
-f lib/mes/fdungetc.c \
|
-f lib/mes/fdungetc.c \
|
||||||
-f lib/posix/setenv.c \
|
-f lib/posix/setenv.c \
|
||||||
-f lib/linux/access.c \
|
-f lib/linux/access.c \
|
||||||
-f lib/m2/chmod.c \
|
-f include/sys/stat.h \
|
||||||
|
-f lib/linux/chmod.c \
|
||||||
-f lib/linux/ioctl3.c \
|
-f lib/linux/ioctl3.c \
|
||||||
|
-f include/sys/ioctl.h \
|
||||||
-f lib/m2/isatty.c \
|
-f lib/m2/isatty.c \
|
||||||
-f lib/linux/fork.c \
|
-f lib/linux/fork.c \
|
||||||
-f lib/m2/execve.c \
|
-f lib/m2/execve.c \
|
||||||
-f lib/m2/execv.c \
|
-f lib/m2/execv.c \
|
||||||
-f lib/m2/waitpid.c \
|
-f include/sys/resource.h \
|
||||||
|
-f lib/linux/wait4.c \
|
||||||
|
-f lib/linux/waitpid.c \
|
||||||
-f lib/linux/gettimeofday.c \
|
-f lib/linux/gettimeofday.c \
|
||||||
-f lib/m2/clock_gettime.c \
|
-f lib/linux/clock_gettime.c \
|
||||||
-f lib/m2/time.c \
|
-f lib/m2/time.c \
|
||||||
-f lib/linux/_getcwd.c \
|
-f lib/linux/_getcwd.c \
|
||||||
|
-f include/limits.h \
|
||||||
-f lib/m2/getcwd.c \
|
-f lib/m2/getcwd.c \
|
||||||
-f lib/linux/dup.c \
|
-f lib/linux/dup.c \
|
||||||
-f lib/linux/dup2.c \
|
-f lib/linux/dup2.c \
|
||||||
|
@ -102,6 +114,7 @@ M2-Planet \
|
||||||
-f src/core.c \
|
-f src/core.c \
|
||||||
-f src/display.c \
|
-f src/display.c \
|
||||||
-f src/eval-apply.c \
|
-f src/eval-apply.c \
|
||||||
|
-f include/fcntl.h \
|
||||||
-f src/gc.c \
|
-f src/gc.c \
|
||||||
-f src/hash.c \
|
-f src/hash.c \
|
||||||
-f src/lib.c \
|
-f src/lib.c \
|
||||||
|
@ -109,6 +122,7 @@ M2-Planet \
|
||||||
-f src/math.c \
|
-f src/math.c \
|
||||||
-f src/mes.c \
|
-f src/mes.c \
|
||||||
-f src/module.c \
|
-f src/module.c \
|
||||||
|
-f include/signal.h \
|
||||||
-f src/posix.c \
|
-f src/posix.c \
|
||||||
-f src/reader.c \
|
-f src/reader.c \
|
||||||
-f src/stack.c \
|
-f src/stack.c \
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#! /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,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -26,7 +26,9 @@
|
||||||
int
|
int
|
||||||
_open3 (char const *file_name, int flags, int mask)
|
_open3 (char const *file_name, int flags, int mask)
|
||||||
{
|
{
|
||||||
int r = _sys_call3 (SYS_open, (long) 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 ();
|
||||||
if (r > 2)
|
if (r > 2)
|
||||||
{
|
{
|
||||||
__ungetc_clear (r);
|
__ungetc_clear (r);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <linux/x86/syscall.h>
|
#include <linux/arm/syscall.h>
|
||||||
|
|
||||||
#if !__TINYC__
|
#if !__TINYC__
|
||||||
// *INDENT-OFF*
|
// *INDENT-OFF*
|
||||||
|
@ -187,7 +187,6 @@ __sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
}
|
}
|
||||||
#endif //__TINYC__
|
#endif //__TINYC__
|
||||||
|
|
||||||
#if 0
|
|
||||||
long
|
long
|
||||||
__sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
__sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||||
{
|
{
|
||||||
|
@ -208,7 +207,6 @@ __sys_call6 (long sys_call, long one, long two, long three, long four, long five
|
||||||
);
|
);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// *INDENT-ON*
|
// *INDENT-ON*
|
||||||
|
|
||||||
|
@ -282,7 +280,6 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
long
|
long
|
||||||
_sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
_sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six)
|
||||||
{
|
{
|
||||||
|
@ -296,4 +293,3 @@ _sys_call6 (long sys_call, long one, long two, long three, long four, long five,
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -24,23 +24,23 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
|
|
||||||
off_t
|
off_t
|
||||||
_lseek (int filedes, off_t offset, int whence)
|
_lseek (int filedes, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
|
long long_offset = offset;
|
||||||
|
return _sys_call3 (SYS_lseek, filedes, long_offset, whence);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
lseek (int filedes, off_t offset, int whence)
|
lseek (int filedes, off_t offset, int whence)
|
||||||
{
|
{
|
||||||
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
|
#if !__MESC__ && !__M2__
|
||||||
if (_lseek (filedes, 0, SEEK_CUR) == -1)
|
if (_lseek (filedes, 0, SEEK_CUR) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
size_t skip = __buffered_read_clear (filedes);
|
size_t skip = __buffered_read_clear (filedes);
|
||||||
if (whence == SEEK_CUR)
|
if (whence == SEEK_CUR)
|
||||||
offset -= skip;
|
offset -= skip;
|
||||||
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
|
long long_offset = offset;
|
||||||
|
return _sys_call3 (SYS_lseek, filedes, long_offset, whence);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
* Copyright © 2021 Danny Milosavljevic <dannym@scratchpost.org>
|
* Copyright © 2021 Danny Milosavljevic <dannym@scratchpost.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
|
@ -31,9 +31,11 @@ malloc (size_t size)
|
||||||
{
|
{
|
||||||
if (!__brk)
|
if (!__brk)
|
||||||
__brk = cast_long_to_charp (brk (0));
|
__brk = cast_long_to_charp (brk (0));
|
||||||
|
#if !__M2__
|
||||||
/* align what we give back. */
|
/* align what we give back. */
|
||||||
__brk = (char*) (((uintptr_t) __brk
|
__brk = (char*) (((uintptr_t) __brk
|
||||||
+ sizeof (max_align_t) - 1) & -sizeof (max_align_t));
|
+ sizeof (max_align_t) - 1) & -sizeof (max_align_t));
|
||||||
|
#endif
|
||||||
if (brk (__brk + size) == -1)
|
if (brk (__brk + size) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
char *p = __brk;
|
char *p = __brk;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -20,12 +20,10 @@
|
||||||
|
|
||||||
#include <linux/syscall.h>
|
#include <linux/syscall.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
int
|
void *
|
||||||
chmod (char const *file_name, int mask)
|
mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||||
{
|
{
|
||||||
long long_file_name = file_name;
|
return (void *)_sys_call6 (SYS_mmap, (long) addr, (long) len, (int) prot, (int) flags, (int) fd, (long) offset);
|
||||||
long long_mask = mask;
|
|
||||||
return _sys_call2 (SYS_chmod, long_file_name, long_mask);
|
|
||||||
}
|
}
|
|
@ -20,11 +20,10 @@
|
||||||
|
|
||||||
#include <linux/syscall.h>
|
#include <linux/syscall.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <time.h>
|
#include <sys/mman.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
clock_gettime (long clk_id, struct timespec *tp)
|
munmap (void *addr, size_t length)
|
||||||
{
|
{
|
||||||
long long_tp = tp;
|
return _sys_call2 (SYS_munmap, (long) addr, (long) length);
|
||||||
return _sys_call2 (SYS_clock_gettime, clk_id, tp);
|
|
||||||
}
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
*
|
||||||
|
* This file is part of GNU Mes.
|
||||||
|
*
|
||||||
|
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* GNU Mes is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <mes/lib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#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:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,16 +18,18 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <mes/lib.h>
|
||||||
#include <linux/syscall.h>
|
#include <linux/syscall.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <mes/lib.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
read (int filedes, void *buffer, size_t size)
|
read (int filedes, void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
long long_filedes = filedes;
|
long long_filedes = filedes;
|
||||||
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, buffer, size);
|
long long_buffer = cast_voidp_to_long (buffer);
|
||||||
|
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, long_buffer, size);
|
||||||
|
#if !__M2__
|
||||||
if (__mes_debug () > 4)
|
if (__mes_debug () > 4)
|
||||||
{
|
{
|
||||||
if (bytes == 1)
|
if (bytes == 1)
|
||||||
|
@ -48,5 +50,6 @@ read (int filedes, void *buffer, size_t size)
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -21,14 +21,8 @@
|
||||||
#include <linux/syscall.h>
|
#include <linux/syscall.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/* Linux' SYS_time syscall is a compatibility shim for SYS_gettimeofday.
|
|
||||||
Therefore, prefer SYS_gettimeofday. */
|
|
||||||
|
|
||||||
#if defined (SYS_gettimeofday)
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
time (time_t * result)
|
time (time_t * result)
|
||||||
|
@ -41,31 +35,3 @@ time (time_t * result)
|
||||||
*result = tv.tv_sec;
|
*result = tv.tv_sec;
|
||||||
return tv.tv_sec;
|
return tv.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined (SYS_time)
|
|
||||||
|
|
||||||
time_t
|
|
||||||
time (time_t * result)
|
|
||||||
{
|
|
||||||
return _sys_call1 (SYS_time, (long) result);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#warning there is no time
|
|
||||||
|
|
||||||
#include <mes/lib.h>
|
|
||||||
|
|
||||||
time_t
|
|
||||||
time (time_t * result)
|
|
||||||
{
|
|
||||||
static int stub = 0;
|
|
||||||
if (__mes_debug () && !stub)
|
|
||||||
eputs ("time stub\n");
|
|
||||||
stub = 1;
|
|
||||||
if (result)
|
|
||||||
*result = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -22,18 +22,15 @@
|
||||||
#include <linux/syscall.h>
|
#include <linux/syscall.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
int
|
pid_t
|
||||||
waitpid (int pid, int *status_ptr, int options)
|
wait4 (pid_t pid, int *status_ptr, int options, struct rusage *rusage)
|
||||||
{
|
{
|
||||||
long long_pid = pid;
|
long long_pid = pid;
|
||||||
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
||||||
long long_options = options;
|
long long_options = options;
|
||||||
//##if __i386__
|
long long_rusage = cast_voidp_to_long (rusage);
|
||||||
//# return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
|
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options,
|
||||||
//##elif __x86_64__ || __arm__
|
long_rusage);
|
||||||
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options, 0);
|
|
||||||
//##else
|
|
||||||
//##error arch not supported
|
|
||||||
//##endif
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <mes/lib.h>
|
||||||
#include <linux/syscall.h>
|
#include <linux/syscall.h>
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -25,11 +26,12 @@
|
||||||
pid_t
|
pid_t
|
||||||
waitpid (pid_t pid, int *status_ptr, int options)
|
waitpid (pid_t pid, int *status_ptr, int options)
|
||||||
{
|
{
|
||||||
#if __i386__
|
long long_pid = pid;
|
||||||
return _sys_call3 (SYS_waitpid, (long) pid, (long) status_ptr, (int) options);
|
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
||||||
#elif __x86_64__ || __arm__
|
long long_options = options;
|
||||||
return _sys_call4 (SYS_wait4, (long) pid, (long) status_ptr, (int) options, 0);
|
#if SYS_waitpid
|
||||||
#else
|
return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
|
||||||
#error arch not supported
|
#elif SYS_wait4
|
||||||
|
return wait4 (pid, status_ptr, options, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,3 +177,20 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return r;
|
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,6 +66,15 @@ __sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
asm ("int____$0x80");
|
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
|
long
|
||||||
_sys_call (long sys_call)
|
_sys_call (long sys_call)
|
||||||
{
|
{
|
||||||
|
@ -135,3 +144,9 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return r;
|
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,3 +179,26 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return r;
|
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,6 +96,8 @@ __sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
asm ("mov____0x8(%rbp),%rsi !0x20");
|
asm ("mov____0x8(%rbp),%rsi !0x20");
|
||||||
asm ("mov____0x8(%rbp),%rdx !0x28");
|
asm ("mov____0x8(%rbp),%rdx !0x28");
|
||||||
asm ("mov____0x8(%rbp),%r10 !0x30");
|
asm ("mov____0x8(%rbp),%r10 !0x30");
|
||||||
|
asm ("mov____0x8(%rbp),%r8 !0x38");
|
||||||
|
asm ("mov____0x8(%rbp),%r9 !0x40");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
asm ("syscall");
|
asm ("syscall");
|
||||||
|
@ -170,3 +172,12 @@ _sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return r;
|
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,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -24,8 +24,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
// CONSTANT PATH_MAX 1024
|
|
||||||
|
|
||||||
char *__getcwd_buf;
|
char *__getcwd_buf;
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -24,7 +24,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termio.h>
|
#include <termio.h>
|
||||||
|
|
||||||
// CONSTANT TCGETS 0x5401
|
|
||||||
#define TCGETS 0x5401
|
#define TCGETS 0x5401
|
||||||
|
|
||||||
struct ktermios
|
struct ktermios
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
|
||||||
*
|
|
||||||
* This file is part of GNU Mes.
|
|
||||||
*
|
|
||||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or (at
|
|
||||||
* your option) any later version.
|
|
||||||
*
|
|
||||||
* GNU Mes is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
mes_open (char *file_name, int flags, int mask)
|
|
||||||
{
|
|
||||||
int filedes = open (file_name, flags, mask);
|
|
||||||
if (filedes > 2)
|
|
||||||
__ungetc_clear (filedes);
|
|
||||||
return filedes;
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,12 +18,12 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mes/lib.h>
|
#include <math.h>
|
||||||
|
|
||||||
void _exit (int code);
|
long int
|
||||||
|
labs (long int number)
|
||||||
void
|
|
||||||
exit (int code)
|
|
||||||
{
|
{
|
||||||
_exit (code);
|
if (number < 0)
|
||||||
|
return -number;
|
||||||
|
return number;
|
||||||
}
|
}
|
|
@ -23,7 +23,19 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if __M2_PLANET__ || (!(__MESC__ && __arm__) && !(__TINYC__ && __arm__ && BOOTSTRAP))
|
#if __MESC__ && __arm__
|
||||||
|
#define __MESC__and__arm__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __TINYC__ && __arm__ && BOOTSTRAP
|
||||||
|
#define __TINYC__and__arm__and__BOOTSTRAP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP !defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP)
|
||||||
|
|
||||||
|
// FIXME: M2-Planet 1.10.0 crashes on this...
|
||||||
|
// #if __M2__ || (!defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP))
|
||||||
|
#if __M2__ || __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP
|
||||||
size_t
|
size_t
|
||||||
__mesabi_uldiv (size_t a, size_t b, size_t *remainder)
|
__mesabi_uldiv (size_t a, size_t b, size_t *remainder)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -23,8 +23,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <mes/lib.h>
|
#include <mes/lib.h>
|
||||||
|
|
||||||
char *__getcwd_buf;
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
getcwd (char *buffer, size_t size)
|
getcwd (char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -22,9 +22,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// CONSTANT M2_PTR_SIZE 4
|
|
||||||
#define M2_PTR_SIZE 1
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
getenv (char const *s)
|
getenv (char const *s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,13 @@ _open2 (char const *file_name, int flags)
|
||||||
return _open3 (file_name, flags, mask);
|
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
|
int
|
||||||
open (char const *file_name, int flags, ...)
|
open (char const *file_name, int flags, ...)
|
||||||
{
|
{
|
||||||
|
@ -44,3 +51,4 @@ open (char const *file_name, int flags, ...)
|
||||||
else
|
else
|
||||||
return _open2 (file_name, flags);
|
return _open2 (file_name, flags);
|
||||||
}
|
}
|
||||||
|
#endif // !__M2__
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -22,9 +22,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// CONSTANT M2_PTR_SIZE 4
|
|
||||||
#define M2_PTR_SIZE 1
|
|
||||||
|
|
||||||
int
|
int
|
||||||
setenv (char const *s, char const *v, int overwrite_p)
|
setenv (char const *s, char const *v, int overwrite_p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,16 +18,10 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mes/lib.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
int
|
void
|
||||||
rewind (int x)
|
rewind (FILE * stream)
|
||||||
{
|
{
|
||||||
static int stub = 0;
|
fseek (stream, 0, SEEK_SET);
|
||||||
if (__mes_debug () && !stub)
|
|
||||||
eputs ("rewind stub\n");
|
|
||||||
stub = 1;
|
|
||||||
errno = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
|
@ -41,6 +41,7 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
||||||
char c = *p;
|
char c = *p;
|
||||||
int left_p = 0;
|
int left_p = 0;
|
||||||
int precision = -1;
|
int precision = -1;
|
||||||
|
int prefix_p = 0;
|
||||||
int width = -1;
|
int width = -1;
|
||||||
if (c == '-')
|
if (c == '-')
|
||||||
{
|
{
|
||||||
|
@ -51,12 +52,17 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
||||||
if (c == ' ')
|
if (c == ' ')
|
||||||
{
|
{
|
||||||
pad = c;
|
pad = c;
|
||||||
c = *p++;
|
c = *++p;
|
||||||
|
}
|
||||||
|
if (c == '#')
|
||||||
|
{
|
||||||
|
prefix_p = 1;
|
||||||
|
c = *++p;
|
||||||
}
|
}
|
||||||
if (c == '0')
|
if (c == '0')
|
||||||
{
|
{
|
||||||
pad = c;
|
pad = c;
|
||||||
c = *p++;
|
c = *++p;
|
||||||
}
|
}
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
{
|
{
|
||||||
|
@ -134,6 +140,18 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
||||||
count++;
|
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)
|
while (*s)
|
||||||
{
|
{
|
||||||
if (precision-- <= 0)
|
if (precision-- <= 0)
|
||||||
|
@ -241,6 +259,8 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
||||||
{
|
{
|
||||||
eputs ("vfprintf: not supported: %:");
|
eputs ("vfprintf: not supported: %:");
|
||||||
eputc (c);
|
eputc (c);
|
||||||
|
eputs (", in format: ");
|
||||||
|
eputs (format);
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
* Copyright © 2019 Danny Milosavljevic <dannym@scratchpost.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -22,62 +23,82 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
vfscanf (FILE * stream, char const *template, va_list ap)
|
vfscanf (FILE * stream, char const *template, va_list ap)
|
||||||
{
|
{
|
||||||
char p = fgetc (stream);
|
char r = fgetc (stream);
|
||||||
char const *t = template;
|
char const *t = template;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (*t && p != EOF)
|
while (*t && r != EOF)
|
||||||
if (*t != '%')
|
if (*t != '%')
|
||||||
{
|
{
|
||||||
t++;
|
t++;
|
||||||
p = fgetc (stream);
|
r = fgetc (stream);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t++;
|
t++;
|
||||||
char c = *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')
|
if (c == 'l')
|
||||||
c = *++t;
|
c = *++t;
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '%':
|
case '%':
|
||||||
{
|
{
|
||||||
p = fgetc (stream);
|
r = fgetc (stream);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
char *c = va_arg (ap, char *);
|
r = fgetc (stream);
|
||||||
*c = p;
|
if (!skip_p)
|
||||||
p = fgetc (stream);
|
{
|
||||||
count++;
|
char *c = va_arg (ap, char *);
|
||||||
|
*c = r;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
int *d = va_arg (ap, int *);
|
int *d = skip_p ? 0 : va_arg (ap, int *);
|
||||||
char buf[20];
|
char buf[20];
|
||||||
char *q = buf;
|
char *q = buf;
|
||||||
if (p == '+' || p == '-')
|
if (r == '+' || r == '-')
|
||||||
{
|
{
|
||||||
*q++ = p;
|
*q++ = r;
|
||||||
p = fgetc (stream);
|
r = fgetc (stream);
|
||||||
}
|
}
|
||||||
while (isdigit (p))
|
while (isdigit (r))
|
||||||
{
|
{
|
||||||
*q++ = p;
|
*q++ = r;
|
||||||
p = fgetc (stream);
|
r = fgetc (stream);
|
||||||
}
|
}
|
||||||
ungetc (p, stream);
|
ungetc (r, stream);
|
||||||
*q = 0;
|
*q = 0;
|
||||||
q = buf;
|
q = buf;
|
||||||
*d = abtol (&q, 10);
|
if (skip_p)
|
||||||
count++;
|
abtol ((char const **) &q, 10);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*d = abtol ((char const **) &q, 10);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'e':
|
case 'e':
|
||||||
|
@ -86,33 +107,100 @@ vfscanf (FILE * stream, char const *template, va_list ap)
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'G':
|
case 'G':
|
||||||
{
|
{
|
||||||
float *f = va_arg (ap, float *);
|
float *f = skip_p ? 0 : va_arg (ap, float *);
|
||||||
char buf[20];
|
char buf[20];
|
||||||
char *q = buf;
|
char *q = buf;
|
||||||
if (p == '+' || p == '-')
|
if (r == '+' || r == '-')
|
||||||
{
|
{
|
||||||
*q++ = p;
|
*q++ = r;
|
||||||
p = fgetc (stream);
|
r = fgetc (stream);
|
||||||
}
|
}
|
||||||
while (isdigit (p))
|
while (isdigit (r))
|
||||||
{
|
{
|
||||||
*q++ = p;
|
*q++ = r;
|
||||||
p = fgetc (stream);
|
r = fgetc (stream);
|
||||||
}
|
}
|
||||||
ungetc (p, stream);
|
ungetc (r, stream);
|
||||||
*q = 0;
|
*q = 0;
|
||||||
q = buf;
|
q = buf;
|
||||||
*f = strtod (q, &q);
|
if (skip_p)
|
||||||
count++;
|
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;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
eputs ("vsscanf: not supported: %:");
|
eputs ("vsscanf: not supported: %:");
|
||||||
eputc (c);
|
eputc (c);
|
||||||
|
eputs (", in template: ");
|
||||||
|
eputs (template);
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
t++;
|
t++;
|
||||||
p = fgetc (stream);
|
r = fgetc (stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t++;
|
t++;
|
||||||
|
|
|
@ -43,6 +43,7 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
||||||
c = *p;
|
c = *p;
|
||||||
int left_p = 0;
|
int left_p = 0;
|
||||||
int precision = -1;
|
int precision = -1;
|
||||||
|
int prefix_p = 0;
|
||||||
int width = -1;
|
int width = -1;
|
||||||
if (c == '-')
|
if (c == '-')
|
||||||
{
|
{
|
||||||
|
@ -53,12 +54,17 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
||||||
if (c == ' ')
|
if (c == ' ')
|
||||||
{
|
{
|
||||||
pad = c;
|
pad = c;
|
||||||
c = *p++;
|
c = *++p;
|
||||||
|
}
|
||||||
|
if (c == '#')
|
||||||
|
{
|
||||||
|
prefix_p = 1;
|
||||||
|
c = *++p;
|
||||||
}
|
}
|
||||||
if (c == '0')
|
if (c == '0')
|
||||||
{
|
{
|
||||||
pad = c;
|
pad = c;
|
||||||
c = *p++;
|
c = *++p;
|
||||||
}
|
}
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
{
|
{
|
||||||
|
@ -142,6 +148,18 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
||||||
count++;
|
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)
|
while (*s)
|
||||||
{
|
{
|
||||||
if (precision-- <= 0)
|
if (precision-- <= 0)
|
||||||
|
@ -262,6 +280,8 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
||||||
{
|
{
|
||||||
eputs ("vsnprintf: not supported: %:");
|
eputs ("vsnprintf: not supported: %:");
|
||||||
eputc (c);
|
eputc (c);
|
||||||
|
eputs (", in format: ");
|
||||||
|
eputs (format);
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,15 @@ vsscanf (char const *s, char const *template, va_list ap)
|
||||||
{
|
{
|
||||||
t++;
|
t++;
|
||||||
char c = *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')
|
if (c == 'l')
|
||||||
c = *++t;
|
c = *++t;
|
||||||
switch (c)
|
switch (c)
|
||||||
|
@ -52,18 +61,27 @@ vsscanf (char const *s, char const *template, va_list ap)
|
||||||
}
|
}
|
||||||
case 'c':
|
case 'c':
|
||||||
{
|
{
|
||||||
char *c = va_arg (ap, char *);
|
char r = *p++;
|
||||||
*c = *p++;
|
if (!skip_p)
|
||||||
count++;
|
{
|
||||||
|
char *c = va_arg (ap, char *);
|
||||||
|
*c = r;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
int *d = va_arg (ap, int *);
|
if (skip_p)
|
||||||
*d = abtol ((char const **)&p, 10);
|
abtol ((char const **) &p, 10);
|
||||||
count++;
|
else
|
||||||
|
{
|
||||||
|
int *d = va_arg (ap, int *);
|
||||||
|
*d = abtol ((char const **) &p, 10);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'e':
|
case 'e':
|
||||||
|
@ -72,15 +90,84 @@ vsscanf (char const *s, char const *template, va_list ap)
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'G':
|
case 'G':
|
||||||
{
|
{
|
||||||
float *f = va_arg (ap, float *);
|
if (skip_p)
|
||||||
*f = strtod (p, &p);
|
strtod (p, &p);
|
||||||
count++;
|
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;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
eputs ("vsscanf: not supported: %:");
|
eputs ("vsscanf: not supported: %:");
|
||||||
eputc (c);
|
eputc (c);
|
||||||
|
eputs (", in template: ");
|
||||||
|
eputs (template);
|
||||||
eputs ("\n");
|
eputs ("\n");
|
||||||
t++;
|
t++;
|
||||||
p++;
|
p++;
|
||||||
|
|
|
@ -25,4 +25,5 @@ int
|
||||||
atexit (void (*function) (void))
|
atexit (void (*function) (void))
|
||||||
{
|
{
|
||||||
__call_at_exit = function;
|
__call_at_exit = function;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -20,12 +20,16 @@
|
||||||
|
|
||||||
#include <mes/lib.h>
|
#include <mes/lib.h>
|
||||||
|
|
||||||
|
#if !__M2__
|
||||||
void (*__call_at_exit) (void);
|
void (*__call_at_exit) (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
exit (int code)
|
exit (int code)
|
||||||
{
|
{
|
||||||
|
#if !__M2__
|
||||||
if (__call_at_exit)
|
if (__call_at_exit)
|
||||||
(*__call_at_exit) ();
|
(*__call_at_exit) ();
|
||||||
|
#endif
|
||||||
_exit (code);
|
_exit (code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,19 +18,25 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mes/lib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
char *__brk = 0;
|
char *
|
||||||
|
strtok (char *new_string, char const *delimiters)
|
||||||
void *
|
|
||||||
malloc (size_t size)
|
|
||||||
{
|
{
|
||||||
if (!__brk)
|
static char *mark;
|
||||||
__brk = cast_long_to_charp (brk (0));
|
if (new_string)
|
||||||
if (brk (__brk + size) == -1)
|
mark = new_string;
|
||||||
|
if (!*mark)
|
||||||
return 0;
|
return 0;
|
||||||
char *p = __brk;
|
while (strchr (delimiters, *mark))
|
||||||
__brk = __brk + size;
|
mark++;
|
||||||
return p;
|
char *point = mark;
|
||||||
|
while (*mark && !strchr (delimiters, *mark))
|
||||||
|
mark++;
|
||||||
|
if (*mark)
|
||||||
|
{
|
||||||
|
*mark = 0;
|
||||||
|
mark++;
|
||||||
|
}
|
||||||
|
return point;
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,14 +18,16 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/syscall.h>
|
|
||||||
#include <syscall.h>
|
|
||||||
#include <mes/lib.h>
|
#include <mes/lib.h>
|
||||||
#include <fcntl.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
long
|
void
|
||||||
read (int filedes, void *buffer, long size)
|
__buffered_read_init (int filedes)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
__buffered_read_clear (int filedes)
|
||||||
{
|
{
|
||||||
long bytes = _sys_call3 (SYS_read, filedes, buffer, size);
|
|
||||||
return bytes;
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,8 +18,6 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// CONSTANT SIGABRT 0
|
|
||||||
|
|
||||||
int
|
int
|
||||||
__raise (int signum)
|
__raise (int signum)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -19,14 +19,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <mes/lib.h>
|
#include <mes/lib.h>
|
||||||
#include <fcntl.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <time.h>
|
||||||
|
|
||||||
int
|
char *
|
||||||
open (char *file_name, int flags, int mask)
|
asctime (struct tm const *broken_time)
|
||||||
{
|
{
|
||||||
int r = _sys_call3 (SYS_open, file_name, flags, mask);
|
static int stub = 0;
|
||||||
if (r > 2)
|
if (__mes_debug () && !stub)
|
||||||
__ungetc_clear (r);
|
eputs ("asctime stub\n");
|
||||||
return r;
|
stub = 1;
|
||||||
|
errno = 0;
|
||||||
|
return "now";
|
||||||
}
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/* -*-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 <assert.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
size_t file_size (char const* file_name)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
stat (file_name, &st);
|
||||||
|
return st.st_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char const *argv[])
|
||||||
|
{
|
||||||
|
eputs ("test:mmap\n");
|
||||||
|
#if __GNUC__ > 11
|
||||||
|
char* file_name = malloc (PATH_MAX);
|
||||||
|
#else
|
||||||
|
// FIXME: gcc-12.2.0 fails open using this
|
||||||
|
char file_name[PATH_MAX];
|
||||||
|
#endif
|
||||||
|
char *srcdir = getenv ("abs_top_srcdir");
|
||||||
|
if (! srcdir) // for running by hand
|
||||||
|
srcdir = ".";
|
||||||
|
eputs ("srcdir=");
|
||||||
|
eputs (srcdir);
|
||||||
|
eputs ("\n");
|
||||||
|
strcpy (file_name, srcdir);
|
||||||
|
strcpy (file_name + strlen (srcdir), "/lib/tests/posix/data/open-read");
|
||||||
|
eputs ("test mmap:");
|
||||||
|
eputs (file_name);
|
||||||
|
eputs ("\n");
|
||||||
|
|
||||||
|
size_t size = file_size (file_name);
|
||||||
|
int fd = open (file_name, O_RDONLY, 0);
|
||||||
|
assert (fd != -1);
|
||||||
|
|
||||||
|
void* data = mmap (NULL, size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, fd, 0);
|
||||||
|
assert(data != MAP_FAILED);
|
||||||
|
write (1, data, size);
|
||||||
|
|
||||||
|
int rc = munmap (data, size);
|
||||||
|
assert (rc == 0);
|
||||||
|
close (fd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -18,39 +18,33 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if SYSTEM_LIBC
|
|
||||||
#error "SYSTEM_LIBC not supported"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <mes/lib.h>
|
#include <mes/lib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <string.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main ()
|
||||||
{
|
{
|
||||||
int size = 5000;
|
char buf_abc[20];
|
||||||
puts ("m!\n");
|
char buf_xxx[20];
|
||||||
//int *p = 0;
|
char buf_0_9[20];
|
||||||
char *p = 0;
|
int i = sscanf ("@abcxxx x0", "@%5[a-bc]%s%[^0-9]", &buf_abc, &buf_xxx, &buf_0_9);
|
||||||
p = malloc (size);
|
if (i != 3)
|
||||||
size = 5000;
|
return 1;
|
||||||
puts ("p=");
|
eputs ("buf_abc=");
|
||||||
puts (itoa (p));
|
eputs (buf_abc);
|
||||||
puts ("\n");
|
eputs ("\n");
|
||||||
for (int i = 0; i < size; i++)
|
eputs ("buf_xxx=");
|
||||||
{
|
eputs (buf_xxx);
|
||||||
puts ("set ");
|
eputs ("\n");
|
||||||
puts (itoa (i));
|
eputs ("buf_0_9=");
|
||||||
puts ("\n");
|
eputs (buf_0_9);
|
||||||
p[i] = i;
|
eputs ("\n");
|
||||||
}
|
if (strcmp (buf_abc, "abc"))
|
||||||
for (int i = 0; i < size; i++)
|
return 2;
|
||||||
{
|
if (strcmp (buf_xxx, "xxx"))
|
||||||
puts (itoa (i));
|
return 3;
|
||||||
puts (": ");
|
if (strcmp (buf_0_9, " x"))
|
||||||
puts (itoa (p[i]));
|
return 4;
|
||||||
puts ("\n");
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -85,6 +85,7 @@ DEFINE mov____$i32,0x8(%ebp) c745
|
||||||
DEFINE mov____$i8,%al b0
|
DEFINE mov____$i8,%al b0
|
||||||
DEFINE mov____$i8,%eax b0
|
DEFINE mov____$i8,%eax b0
|
||||||
DEFINE mov____%al,(%ebx) 8803
|
DEFINE mov____%al,(%ebx) 8803
|
||||||
|
DEFINE mov____%al,0x32(%ebp) 8885
|
||||||
DEFINE mov____%al,0x8(%ebp) 8845
|
DEFINE mov____%al,0x8(%ebp) 8845
|
||||||
DEFINE mov____%ax,(%ebx) 668903
|
DEFINE mov____%ax,(%ebx) 668903
|
||||||
DEFINE mov____%ax,0x8(%ebp) 668945
|
DEFINE mov____%ax,0x8(%ebp) 668945
|
||||||
|
@ -163,6 +164,7 @@ DEFINE not____%ebx f7d3
|
||||||
DEFINE or_____%ebx,%eax 09d8
|
DEFINE or_____%ebx,%eax 09d8
|
||||||
DEFINE pop____%eax 58
|
DEFINE pop____%eax 58
|
||||||
DEFINE pop____%ebx 5b
|
DEFINE pop____%ebx 5b
|
||||||
|
DEFINE pop____%ebp 5d
|
||||||
DEFINE pop____%edx 5a
|
DEFINE pop____%edx 5a
|
||||||
DEFINE push___$i32 68
|
DEFINE push___$i32 68
|
||||||
DEFINE push___%eax 50
|
DEFINE push___%eax 50
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
### GNU Mes --- Maxwell Equations of Software
|
### GNU Mes --- Maxwell Equations of Software
|
||||||
### Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
### Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
### Copyright © 2018 Peter De Wachter <pdewacht@gmail.com>
|
### Copyright © 2018 Peter De Wachter <pdewacht@gmail.com>
|
||||||
|
### Copyright © 2022 Ekaitz Zarraga <ekaitz@elenq.tech>
|
||||||
###
|
###
|
||||||
### This file is part of GNU Mes.
|
### This file is part of GNU Mes.
|
||||||
###
|
###
|
||||||
|
@ -123,10 +124,14 @@ DEFINE mov____%rdx,%rax 4889d0
|
||||||
DEFINE mov____%rdx,%rdi 4889d7
|
DEFINE mov____%rdx,%rdi 4889d7
|
||||||
DEFINE mov____%rsi,(%rdi) 488937
|
DEFINE mov____%rsi,(%rdi) 488937
|
||||||
DEFINE mov____%rsp,%rbp 4889e5
|
DEFINE mov____%rsp,%rbp 4889e5
|
||||||
|
DEFINE mov____%si,(%rdi) 668937
|
||||||
|
DEFINE mov____%sil,(%rdi) 448837
|
||||||
DEFINE mov____(%rax),%eax 8b00
|
DEFINE mov____(%rax),%eax 8b00
|
||||||
DEFINE mov____(%rax),%esi 8b30
|
DEFINE mov____(%rax),%esi 8b30
|
||||||
DEFINE mov____(%rax),%rax 488b00
|
DEFINE mov____(%rax),%rax 488b00
|
||||||
DEFINE mov____(%rax),%rsi 488b30
|
DEFINE mov____(%rax),%rsi 488b30
|
||||||
|
DEFINE mov____(%rax),%si 668b30
|
||||||
|
DEFINE mov____(%rax),%sil 408a30
|
||||||
DEFINE mov____(%rdi),%edi 8b3f
|
DEFINE mov____(%rdi),%edi 8b3f
|
||||||
DEFINE mov____(%rdi),%rdi 488b3f
|
DEFINE mov____(%rdi),%rdi 488b3f
|
||||||
DEFINE mov____0x32(%rbp),%rax 488b85
|
DEFINE mov____0x32(%rbp),%rax 488b85
|
||||||
|
@ -136,6 +141,7 @@ DEFINE mov____0x32,%rdi 488b3c25
|
||||||
DEFINE mov____0x8(%rbp),%eax 8b45
|
DEFINE mov____0x8(%rbp),%eax 8b45
|
||||||
DEFINE mov____0x8(%rbp),%r10 4c8b55
|
DEFINE mov____0x8(%rbp),%r10 4c8b55
|
||||||
DEFINE mov____0x8(%rbp),%r8 4c8b45
|
DEFINE mov____0x8(%rbp),%r8 4c8b45
|
||||||
|
DEFINE mov____0x8(%rbp),%r9 4c8b4d
|
||||||
DEFINE mov____0x8(%rbp),%rax 488b45
|
DEFINE mov____0x8(%rbp),%rax 488b45
|
||||||
DEFINE mov____0x8(%rbp),%rbp 488b6d
|
DEFINE mov____0x8(%rbp),%rbp 488b6d
|
||||||
DEFINE mov____0x8(%rbp),%rbx 488b5d
|
DEFINE mov____0x8(%rbp),%rbx 488b5d
|
||||||
|
|
|
@ -107,7 +107,7 @@ Options:
|
||||||
--arch=ARCH compile for ARCH [~a]
|
--arch=ARCH compile for ARCH [~a]
|
||||||
--kernel=ARCH compile for KERNEL [~a]
|
--kernel=ARCH compile for KERNEL [~a]
|
||||||
-dumpmachine display the compiler's target machine
|
-dumpmachine display the compiler's target machine
|
||||||
--base-address=ADRRESS
|
--base-address=ADDRESS
|
||||||
use BaseAddress ADDRESS [0x1000000]
|
use BaseAddress ADDRESS [0x1000000]
|
||||||
--numbered-arch mescc-tools use numbered arch
|
--numbered-arch mescc-tools use numbered arch
|
||||||
-D DEFINE[=VALUE] define DEFINE [VALUE=1]
|
-D DEFINE[=VALUE] define DEFINE [VALUE=1]
|
||||||
|
|
|
@ -24,15 +24,14 @@ mes_cpu=${mes_cpu:-x86}
|
||||||
stage0_cpu=${stage0_cpu:-x86}
|
stage0_cpu=${stage0_cpu:-x86}
|
||||||
|
|
||||||
M2-Planet \
|
M2-Planet \
|
||||||
--bootstrap-mode \
|
|
||||||
--debug \
|
--debug \
|
||||||
--architecture ${stage0_cpu} \
|
--architecture ${stage0_cpu} \
|
||||||
-f include/m2/lib.h \
|
-f include/mes/lib-mini.h \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
-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/_exit.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||||
-f lib/string/strlen.c \
|
-f lib/string/strlen.c \
|
||||||
-f lib/mes/mini-write.c \
|
-f lib/mes/write.c \
|
||||||
-f lib/mes/eputs.c \
|
-f lib/mes/eputs.c \
|
||||||
-f lib/string/strcmp.c \
|
-f lib/string/strcmp.c \
|
||||||
-f scaffold/argv.c \
|
-f scaffold/argv.c \
|
||||||
|
|
|
@ -30,7 +30,7 @@ M2-Planet \
|
||||||
-f lib/mes/globals.c \
|
-f lib/mes/globals.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||||
-f lib/mes/mini-write.c \
|
-f lib/mes/write.c \
|
||||||
-f lib/string/strlen.c \
|
-f lib/string/strlen.c \
|
||||||
-f lib/string/strcpy.c \
|
-f lib/string/strcpy.c \
|
||||||
-f lib/mes/eputs.c \
|
-f lib/mes/eputs.c \
|
||||||
|
|
|
@ -24,15 +24,14 @@ mes_cpu=${mes_cpu:-x86}
|
||||||
stage0_cpu=${stage0_cpu:-x86}
|
stage0_cpu=${stage0_cpu:-x86}
|
||||||
|
|
||||||
M2-Planet \
|
M2-Planet \
|
||||||
--bootstrap-mode \
|
|
||||||
--debug \
|
--debug \
|
||||||
--architecture ${stage0_cpu} \
|
--architecture ${stage0_cpu} \
|
||||||
-f include/m2/lib.h \
|
-f include/mes/lib-mini.h \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
-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/_exit.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||||
-f lib/string/strlen.c \
|
-f lib/string/strlen.c \
|
||||||
-f lib/mes/mini-write.c \
|
-f lib/mes/write.c \
|
||||||
-f lib/mes/eputs.c \
|
-f lib/mes/eputs.c \
|
||||||
-f scaffold/hello.c \
|
-f scaffold/hello.c \
|
||||||
-o scaffold/hello.M1
|
-o scaffold/hello.M1
|
||||||
|
|
|
@ -30,7 +30,7 @@ M2-Planet \
|
||||||
-f lib/mes/globals.c \
|
-f lib/mes/globals.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||||
-f lib/mes/mini-write.c \
|
-f lib/mes/write.c \
|
||||||
-f lib/string/strlen.c \
|
-f lib/string/strlen.c \
|
||||||
-f lib/string/strcpy.c \
|
-f lib/string/strcpy.c \
|
||||||
-f lib/mes/eputs.c \
|
-f lib/mes/eputs.c \
|
||||||
|
|
|
@ -30,7 +30,7 @@ M2-Planet \
|
||||||
-f lib/mes/globals.c \
|
-f lib/mes/globals.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||||
-f lib/mes/mini-write.c \
|
-f lib/mes/write.c \
|
||||||
-f lib/string/strlen.c \
|
-f lib/string/strlen.c \
|
||||||
-f lib/string/strcpy.c \
|
-f lib/string/strcpy.c \
|
||||||
-f lib/mes/eputs.c \
|
-f lib/mes/eputs.c \
|
||||||
|
|
|
@ -24,7 +24,6 @@ mes_cpu=${mes_cpu:-x86}
|
||||||
stage0_cpu=${stage0_cpu:-x86}
|
stage0_cpu=${stage0_cpu:-x86}
|
||||||
|
|
||||||
M2-Planet \
|
M2-Planet \
|
||||||
--bootstrap-mode \
|
|
||||||
--debug \
|
--debug \
|
||||||
--architecture ${stage0_cpu} \
|
--architecture ${stage0_cpu} \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
||||||
|
|
|
@ -24,28 +24,29 @@ mes_cpu=${mes_cpu:-x86}
|
||||||
stage0_cpu=${stage0_cpu:-x86}
|
stage0_cpu=${stage0_cpu:-x86}
|
||||||
|
|
||||||
M2-Planet \
|
M2-Planet \
|
||||||
--bootstrap-mode \
|
|
||||||
--debug \
|
--debug \
|
||||||
--architecture ${stage0_cpu} \
|
--architecture ${stage0_cpu} \
|
||||||
-f include/m2/lib.h \
|
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
-f include/mes/lib-mini.h \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||||
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
||||||
-f include/linux/${mes_cpu}/syscall.h \
|
-f include/linux/${mes_cpu}/syscall.h \
|
||||||
|
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
||||||
-f lib/m2/cast.c \
|
-f lib/m2/cast.c \
|
||||||
|
-f include/mes/lib.h \
|
||||||
-f lib/string/strlen.c \
|
-f lib/string/strlen.c \
|
||||||
-f lib/mes/mini-write.c \
|
-f lib/mes/write.c \
|
||||||
-f lib/mes/eputs.c \
|
-f lib/mes/eputs.c \
|
||||||
-f lib/linux/brk.c \
|
-f lib/linux/brk.c \
|
||||||
-f lib/m2/malloc.c \
|
-f lib/linux/malloc.c \
|
||||||
-f lib/string/memset.c \
|
-f lib/string/memset.c \
|
||||||
-f lib/m2/read.c \
|
-f lib/linux/read.c \
|
||||||
-f lib/mes/fdgetc.c \
|
-f lib/mes/fdgetc.c \
|
||||||
-f lib/stdio/getchar.c \
|
-f lib/stdio/getchar.c \
|
||||||
-f lib/stdio/putchar.c \
|
-f lib/stdio/putchar.c \
|
||||||
-f lib/m2/open.c \
|
-f lib/linux/open.c \
|
||||||
-f lib/m2/mes_open.c \
|
-f include/sys/types.h \
|
||||||
|
-f include/stdio.h \
|
||||||
-f scaffold/read.c \
|
-f scaffold/read.c \
|
||||||
-o scaffold/read.M1
|
-o scaffold/read.M1
|
||||||
|
|
||||||
|
|
60
simple.make
60
simple.make
|
@ -1,6 +1,6 @@
|
||||||
# GNU Mes --- Maxwell Equations of Software
|
# GNU Mes --- Maxwell Equations of Software
|
||||||
# Copyright © 2019 Jeremiah Orians <jeremiah@pdp10.guru>
|
# Copyright © 2019 Jeremiah Orians <jeremiah@pdp10.guru>
|
||||||
# Copyright © 2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
# Copyright © 2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
#
|
#
|
||||||
# This file is part of GNU Mes.
|
# This file is part of GNU Mes.
|
||||||
#
|
#
|
||||||
|
@ -76,20 +76,26 @@ M2_SOURCES = \
|
||||||
lib/linux/x86-mes-m2/crt1.c \
|
lib/linux/x86-mes-m2/crt1.c \
|
||||||
lib/linux/x86-mes-m2/_exit.c \
|
lib/linux/x86-mes-m2/_exit.c \
|
||||||
lib/linux/x86-mes-m2/_write.c \
|
lib/linux/x86-mes-m2/_write.c \
|
||||||
|
lib/mes/globals.c \
|
||||||
lib/m2/cast.c \
|
lib/m2/cast.c \
|
||||||
lib/m2/exit.c \
|
lib/stdlib/exit.c \
|
||||||
lib/mes/write.c \
|
lib/stub/__buffered_read.c \
|
||||||
lib/linux/x86-mes-m2/syscall.c \
|
lib/linux/x86-mes-m2/syscall.c \
|
||||||
|
lib/stub/__raise.c \
|
||||||
lib/linux/brk.c \
|
lib/linux/brk.c \
|
||||||
lib/stdlib/malloc.c \
|
lib/linux/malloc.c \
|
||||||
lib/string/memset.c \
|
lib/string/memset.c \
|
||||||
\
|
lib/linux/read.c \
|
||||||
lib/m2/read.c \
|
|
||||||
lib/mes/fdgetc.c \
|
lib/mes/fdgetc.c \
|
||||||
|
lib/linux/lseek.c \
|
||||||
|
lib/posix/write.c \
|
||||||
|
\
|
||||||
lib/stdio/getchar.c \
|
lib/stdio/getchar.c \
|
||||||
lib/stdio/putchar.c \
|
lib/stdio/putchar.c \
|
||||||
lib/m2/open.c \
|
lib/stub/__buffered_read.c \
|
||||||
lib/m2/mes_open.c \
|
lib/linux/_open3.c \
|
||||||
|
lib/linux/open.c \
|
||||||
|
lib/mes/mes_open.c \
|
||||||
lib/string/strlen.c \
|
lib/string/strlen.c \
|
||||||
lib/mes/eputs.c \
|
lib/mes/eputs.c \
|
||||||
lib/mes/fdputc.c \
|
lib/mes/fdputc.c \
|
||||||
|
@ -118,15 +124,16 @@ M2_SOURCES = \
|
||||||
lib/mes/fdungetc.c \
|
lib/mes/fdungetc.c \
|
||||||
lib/posix/setenv.c \
|
lib/posix/setenv.c \
|
||||||
lib/linux/access.c \
|
lib/linux/access.c \
|
||||||
lib/m2/chmod.c \
|
lib/linux/chmod.c \
|
||||||
lib/linux/ioctl3.c \
|
lib/linux/ioctl3.c \
|
||||||
lib/m2/isatty.c \
|
lib/m2/isatty.c \
|
||||||
lib/linux/fork.c \
|
lib/linux/fork.c \
|
||||||
lib/m2/execve.c \
|
lib/m2/execve.c \
|
||||||
lib/m2/execv.c \
|
lib/m2/execv.c \
|
||||||
lib/m2/waitpid.c \
|
lib/linux/wait4.c \
|
||||||
|
lib/linux/waitpid.c \
|
||||||
lib/linux/gettimeofday.c \
|
lib/linux/gettimeofday.c \
|
||||||
lib/m2/clock_gettime.c \
|
lib/linux/clock_gettime.c \
|
||||||
lib/m2/time.c \
|
lib/m2/time.c \
|
||||||
lib/linux/_getcwd.c \
|
lib/linux/_getcwd.c \
|
||||||
lib/m2/getcwd.c \
|
lib/m2/getcwd.c \
|
||||||
|
@ -137,12 +144,6 @@ M2_SOURCES = \
|
||||||
lib/linux/unlink.c \
|
lib/linux/unlink.c \
|
||||||
src/m2.c
|
src/m2.c
|
||||||
|
|
||||||
M2_TODO = \
|
|
||||||
lib/m2/file_print.c \
|
|
||||||
lib/mes/ntoab.c \
|
|
||||||
lib/mes/fdgetc.c \
|
|
||||||
lib/mes/fdungetc.c
|
|
||||||
|
|
||||||
INCLUDES = \
|
INCLUDES = \
|
||||||
include/mes/builtins.h \
|
include/mes/builtins.h \
|
||||||
include/mes/constants.h \
|
include/mes/constants.h \
|
||||||
|
@ -186,8 +187,19 @@ bin/gc-gcc: simple.make $(GCC_SOURCES) $(TEST_GC_SOURCES) $(INCLUDES) | bin
|
||||||
$(CC) $(CFLAGS) -D GC_TEST=1 $(GCC_SOURCES) $(TEST_GC_SOURCES) -o $@
|
$(CC) $(CFLAGS) -D GC_TEST=1 $(GCC_SOURCES) $(TEST_GC_SOURCES) -o $@
|
||||||
|
|
||||||
M2_PLANET_INCLUDES = \
|
M2_PLANET_INCLUDES = \
|
||||||
include/m2/lib.h \
|
include/mes/config.h \
|
||||||
|
include/mes/lib-mini.h \
|
||||||
|
include/mes/lib.h \
|
||||||
include/linux/x86/syscall.h \
|
include/linux/x86/syscall.h \
|
||||||
|
include/time.h \
|
||||||
|
include/sys/time.h \
|
||||||
|
include/sys/types.h \
|
||||||
|
include/stdio.h \
|
||||||
|
include/limits.h \
|
||||||
|
include/sys/resource.h \
|
||||||
|
include/sys/stat.h \
|
||||||
|
include/fcntl.h \
|
||||||
|
include/signal.h \
|
||||||
include/mes/mes.h \
|
include/mes/mes.h \
|
||||||
include/mes/builtins.h \
|
include/mes/builtins.h \
|
||||||
include/mes/constants.h \
|
include/mes/constants.h \
|
||||||
|
@ -216,12 +228,12 @@ m2/mes-m2.hex2: m2/mes-m2.blood-elf.M1
|
||||||
-o $@
|
-o $@
|
||||||
|
|
||||||
bin/mes-m2: m2/mes-m2.hex2
|
bin/mes-m2: m2/mes-m2.hex2
|
||||||
hex2 \
|
hex2 \
|
||||||
--architecture $(M2_PLANET_ARCH) \
|
--architecture $(M2_PLANET_ARCH) \
|
||||||
--little-endian \
|
--little-endian \
|
||||||
--base-address 0x1000000 \
|
--base-address 0x1000000 \
|
||||||
-f lib/x86-mes/elf32-header.hex2 \
|
-f lib/linux/x86-mes/elf32-header.hex2 \
|
||||||
-f m2/mes-m2.hex2 \
|
-f m2/mes-m2.hex2 \
|
||||||
-o $@
|
-o $@
|
||||||
cp -f $@ bin/mes
|
cp -f $@ bin/mes
|
||||||
|
|
||||||
|
|
315
simple.sh
315
simple.sh
|
@ -36,47 +36,48 @@ cat > include/mes/config.h <<EOF
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
## Build ##
|
## Build ##
|
||||||
gcc -g -D HAVE_CONFIG_H=1 -I include\
|
gcc -g -D HAVE_CONFIG_H=1 -I include \
|
||||||
-o out-system-libc/mes\
|
-o out-system-libc/mes \
|
||||||
\
|
\
|
||||||
lib/mes/eputs.c\
|
lib/mes/eputs.c \
|
||||||
lib/mes/oputs.c\
|
lib/mes/oputs.c \
|
||||||
\
|
\
|
||||||
lib/mes/cast.c\
|
lib/mes/cast.c \
|
||||||
lib/mes/itoa.c\
|
lib/mes/itoa.c \
|
||||||
lib/mes/ltoa.c\
|
lib/mes/ltoa.c \
|
||||||
lib/mes/ltoab.c\
|
lib/mes/ltoab.c \
|
||||||
lib/mes/ultoa.c\
|
lib/mes/ultoa.c \
|
||||||
lib/mes/utoa.c\
|
lib/mes/utoa.c \
|
||||||
lib/mes/eputc.c\
|
lib/mes/eputc.c \
|
||||||
lib/mes/fdgetc.c\
|
lib/mes/fdgetc.c \
|
||||||
lib/mes/fdputc.c\
|
lib/mes/fdputc.c \
|
||||||
lib/mes/fdputs.c\
|
lib/mes/fdputs.c \
|
||||||
lib/mes/fdungetc.c\
|
lib/mes/fdungetc.c \
|
||||||
lib/mes/mes_open.c\
|
lib/mes/mes_open.c \
|
||||||
lib/mes/ntoab.c\
|
lib/mes/ntoab.c \
|
||||||
lib/mes/oputc.c\
|
lib/mes/oputc.c \
|
||||||
\
|
\
|
||||||
lib/mes/__assert_fail.c\
|
lib/mes/__assert_fail.c \
|
||||||
lib/mes/assert_msg.c\
|
lib/mes/assert_msg.c \
|
||||||
\
|
\
|
||||||
src/builtins.c\
|
src/builtins.c \
|
||||||
src/cc.c\
|
src/cc.c \
|
||||||
src/core.c\
|
src/core.c \
|
||||||
src/display.c\
|
src/display.c \
|
||||||
src/eval-apply.c\
|
src/eval-apply.c \
|
||||||
src/gc.c\
|
src/gc.c \
|
||||||
src/hash.c\
|
src/globals.c \
|
||||||
src/lib.c\
|
src/hash.c \
|
||||||
src/math.c\
|
src/lib.c \
|
||||||
src/mes.c\
|
src/math.c \
|
||||||
src/module.c\
|
src/mes.c \
|
||||||
src/posix.c\
|
src/module.c \
|
||||||
src/reader.c\
|
src/posix.c \
|
||||||
src/stack.c\
|
src/reader.c \
|
||||||
src/string.c\
|
src/stack.c \
|
||||||
src/struct.c\
|
src/string.c \
|
||||||
src/symbol.c\
|
src/struct.c \
|
||||||
|
src/symbol.c \
|
||||||
src/vector.c
|
src/vector.c
|
||||||
|
|
||||||
## Check ##
|
## Check ##
|
||||||
|
@ -106,7 +107,7 @@ MES_DEBUG=3 MES_ARENA=10000 MES_MAX_ARENA=10000 MES_BOOT=tests/gc.test out-syste
|
||||||
# lib/linux/$mes_cpu-mes-mescc/_write.c\
|
# lib/linux/$mes_cpu-mes-mescc/_write.c\
|
||||||
# \
|
# \
|
||||||
# lib/mes/globals.c\
|
# lib/mes/globals.c\
|
||||||
# lib/mes/mini-write.c\
|
# lib/mes/write.c\
|
||||||
# lib/string/strlen.c\
|
# lib/string/strlen.c\
|
||||||
# \
|
# \
|
||||||
# scaffold/hello.c
|
# scaffold/hello.c
|
||||||
|
@ -120,7 +121,7 @@ cat \
|
||||||
lib/linux/$mes_cpu-mes-mescc/_write.c \
|
lib/linux/$mes_cpu-mes-mescc/_write.c \
|
||||||
\
|
\
|
||||||
lib/mes/globals.c \
|
lib/mes/globals.c \
|
||||||
lib/mes/mini-write.c \
|
lib/mes/write.c \
|
||||||
lib/string/strlen.c \
|
lib/string/strlen.c \
|
||||||
\
|
\
|
||||||
scaffold/hello.c \
|
scaffold/hello.c \
|
||||||
|
@ -164,115 +165,121 @@ EOF
|
||||||
|
|
||||||
## Build ##
|
## Build ##
|
||||||
compiler=gcc # not configurable
|
compiler=gcc # not configurable
|
||||||
$CC -g -D HAVE_CONFIG_H=1 -I include -I include/$mes_kernel/$mes_cpu\
|
$CC -g -D HAVE_CONFIG_H=1 \
|
||||||
-nostdinc -nostdlib -fno-builtin -fno-stack-protector\
|
-I include -I include/$mes_kernel/$mes_cpu \
|
||||||
-o out-mes/mes\
|
-nostdinc -nostdlib \
|
||||||
\
|
-fno-builtin -fno-stack-protector \
|
||||||
lib/linux/$mes_cpu-mes-gcc/crt1.c\
|
-o out-mes/mes \
|
||||||
\
|
\
|
||||||
lib/mes/globals.c\
|
lib/linux/$mes_cpu-mes-gcc/crt1.c \
|
||||||
lib/mes/eputs.c\
|
\
|
||||||
lib/mes/oputs.c\
|
lib/mes/globals.c \
|
||||||
\
|
lib/mes/eputs.c \
|
||||||
lib/posix/write.c\
|
lib/mes/oputs.c \
|
||||||
lib/string/strlen.c\
|
\
|
||||||
lib/stdlib/puts.c\
|
lib/posix/write.c \
|
||||||
lib/stdlib/exit.c\
|
lib/string/strlen.c \
|
||||||
lib/$mes_kernel/$mes_cpu-mes-$compiler/_exit.c\
|
lib/stdlib/puts.c \
|
||||||
lib/$mes_kernel/$mes_cpu-mes-$compiler/_write.c\
|
lib/stdlib/exit.c \
|
||||||
\
|
lib/$mes_kernel/$mes_cpu-mes-$compiler/_exit.c \
|
||||||
lib/mes/cast.c\
|
lib/$mes_kernel/$mes_cpu-mes-$compiler/_write.c \
|
||||||
lib/mes/itoa.c\
|
\
|
||||||
lib/mes/ltoa.c\
|
lib/mes/cast.c \
|
||||||
lib/mes/ltoab.c\
|
lib/mes/itoa.c \
|
||||||
lib/mes/ultoa.c\
|
lib/mes/ltoa.c \
|
||||||
lib/mes/utoa.c\
|
lib/mes/ltoab.c \
|
||||||
lib/mes/eputc.c\
|
lib/mes/ultoa.c \
|
||||||
lib/mes/fdgetc.c\
|
lib/mes/utoa.c \
|
||||||
lib/mes/fdputc.c\
|
lib/mes/eputc.c \
|
||||||
lib/mes/fdputs.c\
|
lib/mes/fdgetc.c \
|
||||||
lib/mes/fdungetc.c\
|
lib/mes/fdputc.c \
|
||||||
lib/mes/mes_open.c\
|
lib/mes/fdputs.c \
|
||||||
lib/mes/ntoab.c\
|
lib/mes/fdungetc.c \
|
||||||
lib/mes/oputc.c\
|
lib/mes/mes_open.c \
|
||||||
\
|
lib/mes/ntoab.c \
|
||||||
lib/stdlib/atoi.c\
|
lib/mes/oputc.c \
|
||||||
lib/mes/abtol.c\
|
\
|
||||||
lib/ctype/isdigit.c\
|
lib/stdlib/atoi.c \
|
||||||
lib/ctype/isnumber.c\
|
lib/mes/abtol.c \
|
||||||
lib/ctype/isspace.c\
|
lib/ctype/isdigit.c \
|
||||||
lib/ctype/isxdigit.c\
|
lib/ctype/isnumber.c \
|
||||||
\
|
lib/ctype/isspace.c \
|
||||||
lib/mes/__assert_fail.c\
|
lib/ctype/isxdigit.c \
|
||||||
lib/mes/assert_msg.c\
|
\
|
||||||
lib/mes/__buffered_read.c\
|
lib/stub/__raise.c \
|
||||||
lib/mes/__mes_debug.c\
|
lib/mes/__assert_fail.c \
|
||||||
lib/posix/execv.c\
|
lib/mes/assert_msg.c \
|
||||||
lib/posix/getcwd.c\
|
lib/mes/__buffered_read.c \
|
||||||
lib/posix/getenv.c\
|
lib/mes/__mes_debug.c \
|
||||||
lib/posix/isatty.c\
|
lib/posix/execv.c \
|
||||||
lib/posix/open.c\
|
lib/posix/getcwd.c \
|
||||||
lib/posix/setenv.c\
|
lib/posix/getenv.c \
|
||||||
lib/posix/wait.c\
|
lib/posix/isatty.c \
|
||||||
lib/stdio/fgetc.c\
|
lib/posix/open.c \
|
||||||
lib/stdio/fputc.c\
|
lib/posix/setenv.c \
|
||||||
lib/stdio/fputs.c\
|
lib/posix/wait.c \
|
||||||
lib/stdio/getc.c\
|
lib/stdio/fgetc.c \
|
||||||
lib/stdio/getchar.c\
|
lib/stdio/fputc.c \
|
||||||
lib/stdio/putc.c\
|
lib/stdio/fputs.c \
|
||||||
lib/stdio/putchar.c\
|
lib/stdio/getc.c \
|
||||||
lib/stdio/ungetc.c\
|
lib/stdio/getchar.c \
|
||||||
lib/stdlib/free.c\
|
lib/stdio/putc.c \
|
||||||
lib/stdlib/malloc.c\
|
lib/stdio/putchar.c \
|
||||||
lib/stdlib/realloc.c\
|
lib/stdio/ungetc.c \
|
||||||
lib/string/memchr.c\
|
lib/stdlib/free.c \
|
||||||
lib/string/memcmp.c\
|
lib/linux/malloc.c \
|
||||||
lib/string/memcpy.c\
|
lib/stdlib/realloc.c \
|
||||||
lib/string/memmove.c\
|
lib/string/memchr.c \
|
||||||
lib/string/memset.c\
|
lib/string/memcmp.c \
|
||||||
lib/string/strcmp.c\
|
lib/string/memcpy.c \
|
||||||
lib/string/strcpy.c\
|
lib/string/memmove.c \
|
||||||
lib/string/strncmp.c\
|
lib/string/memset.c \
|
||||||
\
|
lib/string/strcmp.c \
|
||||||
lib/linux/lseek.c\
|
lib/string/strcpy.c \
|
||||||
\
|
lib/string/strncmp.c \
|
||||||
lib/linux/access.c\
|
\
|
||||||
lib/linux/brk.c\
|
lib/linux/lseek.c \
|
||||||
lib/linux/chmod.c\
|
\
|
||||||
lib/linux/clock_gettime.c\
|
lib/linux/access.c \
|
||||||
lib/linux/dup.c\
|
lib/linux/brk.c \
|
||||||
lib/linux/dup2.c\
|
lib/linux/chmod.c \
|
||||||
lib/linux/execve.c\
|
lib/linux/clock_gettime.c \
|
||||||
lib/linux/fork.c\
|
lib/linux/dup.c \
|
||||||
lib/linux/fsync.c\
|
lib/linux/dup2.c \
|
||||||
lib/linux/_getcwd.c\
|
lib/linux/execve.c \
|
||||||
lib/linux/gettimeofday.c\
|
lib/linux/fork.c \
|
||||||
lib/linux/ioctl3.c\
|
lib/linux/fsync.c \
|
||||||
lib/linux/_open3.c\
|
lib/linux/_getcwd.c \
|
||||||
lib/linux/read.c\
|
lib/linux/gettimeofday.c \
|
||||||
lib/linux/_read.c\
|
lib/linux/ioctl3.c \
|
||||||
lib/linux/time.c\
|
lib/linux/_open3.c \
|
||||||
lib/linux/unlink.c\
|
lib/linux/read.c \
|
||||||
lib/linux/waitpid.c\
|
lib/linux/_read.c \
|
||||||
lib/linux/$mes_cpu-mes-$compiler/syscall.c\
|
lib/linux/time.c \
|
||||||
\
|
lib/linux/unlink.c \
|
||||||
src/builtins.c\
|
include/sys/resource.h \
|
||||||
src/cc.c\
|
lib/linux/wait4.c \
|
||||||
src/core.c\
|
lib/linux/waitpid.c \
|
||||||
src/display.c\
|
lib/linux/$mes_cpu-mes-$compiler/syscall.c \
|
||||||
src/eval-apply.c\
|
\
|
||||||
src/gc.c\
|
src/builtins.c \
|
||||||
src/hash.c\
|
src/cc.c \
|
||||||
src/lib.c\
|
src/core.c \
|
||||||
src/math.c\
|
src/display.c \
|
||||||
src/mes.c\
|
src/eval-apply.c \
|
||||||
src/module.c\
|
src/gc.c \
|
||||||
src/posix.c\
|
src/globals.c \
|
||||||
src/reader.c\
|
src/hash.c \
|
||||||
src/stack.c\
|
src/lib.c \
|
||||||
src/string.c\
|
src/math.c \
|
||||||
src/struct.c\
|
src/mes.c \
|
||||||
src/symbol.c\
|
src/module.c \
|
||||||
|
src/posix.c \
|
||||||
|
src/reader.c \
|
||||||
|
src/stack.c \
|
||||||
|
src/string.c \
|
||||||
|
src/struct.c \
|
||||||
|
src/symbol.c \
|
||||||
src/vector.c
|
src/vector.c
|
||||||
|
|
||||||
## Check ##
|
## Check ##
|
||||||
|
@ -302,7 +309,7 @@ MES_DEBUG=3 MES_ARENA=10000 MES_MAX_ARENA=10000 MES_BOOT=tests/gc.test out-mes/m
|
||||||
# lib/linux/$mes_cpu-mes-mescc/_write.c\
|
# lib/linux/$mes_cpu-mes-mescc/_write.c\
|
||||||
# \
|
# \
|
||||||
# lib/mes/globals.c\
|
# lib/mes/globals.c\
|
||||||
# lib/mes/mini-write.c\
|
# lib/mes/write.c\
|
||||||
# lib/string/strlen.c\
|
# lib/string/strlen.c\
|
||||||
# \
|
# \
|
||||||
# scaffold/hello.c
|
# scaffold/hello.c
|
||||||
|
@ -316,7 +323,7 @@ cat \
|
||||||
lib/linux/$mes_cpu-mes-mescc/_write.c \
|
lib/linux/$mes_cpu-mes-mescc/_write.c \
|
||||||
\
|
\
|
||||||
lib/mes/globals.c \
|
lib/mes/globals.c \
|
||||||
lib/mes/mini-write.c \
|
lib/mes/write.c \
|
||||||
lib/string/strlen.c \
|
lib/string/strlen.c \
|
||||||
\
|
\
|
||||||
scaffold/hello.c \
|
scaffold/hello.c \
|
||||||
|
|
|
@ -148,7 +148,7 @@ length (struct scm *x)
|
||||||
struct scm *
|
struct scm *
|
||||||
error (struct scm *key, struct scm *x)
|
error (struct scm *key, struct scm *x)
|
||||||
{
|
{
|
||||||
#if !__MESC_MES__ && !__M2_PLANET__
|
#if !__MESC_MES__ && !__M2__
|
||||||
struct scm *throw = module_ref (R0, cell_symbol_throw);
|
struct scm *throw = module_ref (R0, cell_symbol_throw);
|
||||||
if (throw != cell_undefined)
|
if (throw != cell_undefined)
|
||||||
return apply (throw, cons (key, cons (x, cell_nil)), R0);
|
return apply (throw, cons (key, cons (x, cell_nil)), R0);
|
||||||
|
|
26
src/gc.c
26
src/gc.c
|
@ -1,6 +1,7 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
* Copyright © 2022 Gabriel Wicki <gabriel@erlikon.ch>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -30,9 +31,6 @@
|
||||||
|
|
||||||
int g_dump_filedes;
|
int g_dump_filedes;
|
||||||
|
|
||||||
#define M2_CELL_SIZE 1U
|
|
||||||
// CONSTANT M2_CELL_SIZE 12
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
cell_bytes (struct scm *x)
|
cell_bytes (struct scm *x)
|
||||||
{
|
{
|
||||||
|
@ -40,16 +38,20 @@ cell_bytes (struct scm *x)
|
||||||
return p + (2 * sizeof (long));
|
return p + (2 * sizeof (long));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __M2__
|
||||||
|
#define U10 10
|
||||||
|
#define U100 100
|
||||||
|
#else
|
||||||
#define U10 10U
|
#define U10 10U
|
||||||
// CONSTANT U10 10
|
|
||||||
#define U100 100U
|
#define U100 100U
|
||||||
// CONSTANT U100 100
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
gc_init ()
|
gc_init ()
|
||||||
{
|
{
|
||||||
#if SYSTEM_LIBC
|
#if SYSTEM_LIBC
|
||||||
ARENA_SIZE = 100000000; /* 2.3GiB */
|
ARENA_SIZE = 100000000; /* 2.3GiB */
|
||||||
#elif ! __M2_PLANET__
|
#elif ! __M2__
|
||||||
ARENA_SIZE = 300000; /* 32b: 3MiB, 64b: 6 MiB */
|
ARENA_SIZE = 300000; /* 32b: 3MiB, 64b: 6 MiB */
|
||||||
#else
|
#else
|
||||||
ARENA_SIZE = 20000000;
|
ARENA_SIZE = 20000000;
|
||||||
|
@ -326,11 +328,11 @@ void
|
||||||
gc_up_arena ()
|
gc_up_arena ()
|
||||||
{
|
{
|
||||||
long old_arena_bytes = (ARENA_SIZE + JAM_SIZE) * sizeof (struct scm);
|
long old_arena_bytes = (ARENA_SIZE + JAM_SIZE) * sizeof (struct scm);
|
||||||
if (ARENA_SIZE >> 1 < MAX_ARENA_SIZE >> 2)
|
if (ARENA_SIZE / 2 < MAX_ARENA_SIZE / 4)
|
||||||
{
|
{
|
||||||
ARENA_SIZE = ARENA_SIZE << 1;
|
ARENA_SIZE = ARENA_SIZE * 2;
|
||||||
JAM_SIZE = JAM_SIZE << 1;
|
JAM_SIZE = JAM_SIZE * 2;
|
||||||
GC_SAFETY = GC_SAFETY << 1;
|
GC_SAFETY = GC_SAFETY * 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ARENA_SIZE = MAX_ARENA_SIZE - JAM_SIZE;
|
ARENA_SIZE = MAX_ARENA_SIZE - JAM_SIZE;
|
||||||
|
@ -448,7 +450,7 @@ void
|
||||||
gc_flip ()
|
gc_flip ()
|
||||||
{
|
{
|
||||||
if (g_free - g_news > JAM_SIZE)
|
if (g_free - g_news > JAM_SIZE)
|
||||||
JAM_SIZE = (g_free - g_news) + ((g_free - g_news) / 2);
|
JAM_SIZE = ((g_free - g_news) * 3) / 2;
|
||||||
|
|
||||||
cell_arena = g_cells - M2_CELL_SIZE; /* For debugging. */
|
cell_arena = g_cells - M2_CELL_SIZE; /* For debugging. */
|
||||||
gc_cellcpy (g_cells, g_news, (g_free - g_news) / M2_CELL_SIZE);
|
gc_cellcpy (g_cells, g_news, (g_free - g_news) / M2_CELL_SIZE);
|
||||||
|
|
15
src/posix.c
15
src/posix.c
|
@ -35,7 +35,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if SYSTEM_LIBC
|
#if SYSTEM_LIBC
|
||||||
#define __raise(x) -1
|
//#define __raise(x) -1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct scm *
|
struct scm *
|
||||||
|
@ -377,13 +377,14 @@ waitpid_ (struct scm *pid, struct scm *options)
|
||||||
return cons (make_number (child), make_number (status));
|
return cons (make_number (child), make_number (status));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __x86_64__
|
#if __M2__
|
||||||
|
/* Milliseconds for everyone else. */
|
||||||
|
#define TIME_UNITS_PER_SECOND 1000
|
||||||
|
#elif __x86_64__
|
||||||
/* Nanoseconds on 64-bit systems with POSIX timers. */
|
/* Nanoseconds on 64-bit systems with POSIX timers. */
|
||||||
// CONSTANT TIME_UNITS_PER_SECOND 1000000000
|
|
||||||
#define TIME_UNITS_PER_SECOND 1000000000U
|
#define TIME_UNITS_PER_SECOND 1000000000U
|
||||||
#else
|
#else
|
||||||
/* Milliseconds for everyone else. */
|
/* Milliseconds for everyone else. */
|
||||||
// CONSTANT TIME_UNITS_PER_SECOND 1000
|
|
||||||
#define TIME_UNITS_PER_SECOND 1000U
|
#define TIME_UNITS_PER_SECOND 1000U
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -408,8 +409,12 @@ gettimeofday_ () /*:((name . "gettimeofday")) */
|
||||||
return cons (make_number (time->tv_sec), make_number (time->tv_usec));
|
return cons (make_number (time->tv_sec), make_number (time->tv_usec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __M2__
|
||||||
|
#define UL1000000000 1000000000
|
||||||
|
#else
|
||||||
#define UL1000000000 1000000000UL
|
#define UL1000000000 1000000000UL
|
||||||
// CONSTANT UL1000000000 1000000000
|
#endif
|
||||||
|
|
||||||
long
|
long
|
||||||
seconds_and_nanoseconds_to_long (long s, long ns)
|
seconds_and_nanoseconds_to_long (long s, long ns)
|
||||||
{
|
{
|
||||||
|
|
10
src/symbol.c
10
src/symbol.c
|
@ -23,16 +23,6 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// char const *MES_VERSION = "0.24";
|
|
||||||
|
|
||||||
#if __M2_PLANET__
|
|
||||||
#define M2_CELL_SIZE 12
|
|
||||||
// CONSTANT M2_CELL_SIZE 12
|
|
||||||
#else
|
|
||||||
#define M2_CELL_SIZE 1
|
|
||||||
// CONSTANT M2_CELL_SIZE 12
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct scm *
|
struct scm *
|
||||||
init_symbol (struct scm *x, long type, char const *name)
|
init_symbol (struct scm *x, long type, char const *name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
* Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
*
|
*
|
||||||
* This file is part of GNU Mes.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -24,9 +24,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define M2_CELL_SIZE 1
|
|
||||||
// CONSTANT M2_CELL_SIZE 12
|
|
||||||
|
|
||||||
int g_debug;
|
int g_debug;
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
10
src/vector.c
10
src/vector.c
|
@ -1,6 +1,6 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
* GNU Mes --- Maxwell Equations of Software
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
* This file is part of GNU Mes.
|
||||||
*
|
*
|
||||||
|
@ -21,14 +21,6 @@
|
||||||
#include "mes/lib.h"
|
#include "mes/lib.h"
|
||||||
#include "mes/mes.h"
|
#include "mes/mes.h"
|
||||||
|
|
||||||
#if __M2_PLANET__
|
|
||||||
#define M2_CELL_SIZE 12
|
|
||||||
// CONSTANT M2_CELL_SIZE 12
|
|
||||||
#else
|
|
||||||
#define M2_CELL_SIZE 1
|
|
||||||
// CONSTANT M2_CELL_SIZE 12
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct scm *
|
struct scm *
|
||||||
make_vector_ (long k, struct scm *e)
|
make_vector_ (long k, struct scm *e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue