Compare commits
36 Commits
master
...
wip-x86_64
Author | SHA1 | Date |
---|---|---|
Jan (janneke) Nieuwenhuizen | ee352a7b5c | |
Jan (janneke) Nieuwenhuizen | e465eb8eb9 | |
Jan (janneke) Nieuwenhuizen | 932ea587df | |
Jan (janneke) Nieuwenhuizen | 08f0adcdfa | |
Meghan Denny | 3d1dcc3971 | |
Jan (janneke) Nieuwenhuizen | f92727fba9 | |
Jan (janneke) Nieuwenhuizen | c4e58b5a18 | |
Jan (janneke) Nieuwenhuizen | 571f40c408 | |
Jan (janneke) Nieuwenhuizen | 8e46da9c7e | |
Jan (janneke) Nieuwenhuizen | 2c739adb26 | |
Jan (janneke) Nieuwenhuizen | a382f6291e | |
Jan (janneke) Nieuwenhuizen | 5db2d16f74 | |
Jan (janneke) Nieuwenhuizen | 4207656c48 | |
Jan (janneke) Nieuwenhuizen | 2ed1f5a34b | |
Jan (janneke) Nieuwenhuizen | cda70de448 | |
Jan (janneke) Nieuwenhuizen | dab5a9d5c7 | |
Jan (janneke) Nieuwenhuizen | 3905ef3613 | |
Jan (janneke) Nieuwenhuizen | 76967b6494 | |
Jan (janneke) Nieuwenhuizen | 9b0c397cb0 | |
Jan (janneke) Nieuwenhuizen | 0305f345fe | |
Jan (janneke) Nieuwenhuizen | 5c436dae9f | |
Jan (janneke) Nieuwenhuizen | 6a031319e4 | |
Jan (janneke) Nieuwenhuizen | d88da02892 | |
Jan (janneke) Nieuwenhuizen | a6ecd2c344 | |
Jan (janneke) Nieuwenhuizen | 2edf1c997d | |
Jan (janneke) Nieuwenhuizen | bbb9b2546e | |
Jan (janneke) Nieuwenhuizen | 3d3efa06dd | |
Gabriel Wicki | 2b3e6fa7a0 | |
Jan (janneke) Nieuwenhuizen | 1c220d9c3a | |
Jan (janneke) Nieuwenhuizen | 31e5f2e476 | |
Jan (janneke) Nieuwenhuizen | 496fd10680 | |
Jan (janneke) Nieuwenhuizen | cc796a5d61 | |
Jan (janneke) Nieuwenhuizen | f9232e804f | |
Jan (janneke) Nieuwenhuizen | 015e68a28a | |
Jan (janneke) Nieuwenhuizen | a64e292ce2 | |
Jan (janneke) Nieuwenhuizen | 688b4ffbb6 |
2
PORTING
2
PORTING
|
@ -22,7 +22,7 @@ to your config.scm and run guix system reconfigure.
|
|||
|
||||
For example (note: ARM is no longer a 'port', see HACKING)
|
||||
#+BEGIN_SRC bash
|
||||
guix shell --system=armhf-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain@7 grep git guile@2.2 gzip help2man make mescc-tools nyacc openssh-sans-x pkg-config sed tar texinfo
|
||||
guix shell --system=armhf-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git guile gzip help2man make mescc-tools nyacc openssh-sans-x pkg-config sed tar texinfo
|
||||
#+END_SRC
|
||||
|
||||
** Try it
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! @SHELL@
|
||||
|
||||
# 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.
|
||||
#
|
||||
|
@ -54,13 +54,15 @@ AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_k
|
|||
AM_CFLAGS="-L ${srcdest}lib"
|
||||
|
||||
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.s $mes_cpu-mes
|
||||
|
||||
objects=
|
||||
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
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
|
@ -72,7 +74,8 @@ $AR crD $mes_cpu-mes/libc-mini.a $objects
|
|||
|
||||
objects=
|
||||
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
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
|
@ -84,7 +87,8 @@ $AR crD $mes_cpu-mes/libmescc.a $objects
|
|||
|
||||
objects=
|
||||
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
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
|
@ -96,7 +100,8 @@ $AR crD $mes_cpu-mes/libc.a $objects
|
|||
|
||||
objects=
|
||||
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
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
|
@ -113,7 +118,8 @@ AM_CFLAGS="-L ${srcdest}lib"
|
|||
|
||||
objects=
|
||||
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
|
||||
echo " CC $c"
|
||||
$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# 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.
|
||||
#
|
||||
|
@ -26,7 +26,8 @@
|
|||
trap 'test -f .log && cat .log' EXIT
|
||||
|
||||
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
|
||||
if test -e crt1.s; then
|
||||
cp crt1.s $mes_cpu-mes
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# 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.
|
||||
#
|
||||
|
@ -29,6 +29,7 @@ fi
|
|||
|
||||
. ./config.sh
|
||||
. ${srcdest}build-aux/trace.sh
|
||||
. ${srcdest}build-aux/cflags.sh
|
||||
|
||||
if $courageous; then
|
||||
set +e
|
||||
|
@ -42,25 +43,6 @@ else
|
|||
}
|
||||
fi
|
||||
|
||||
case "$mes_cpu" in
|
||||
arm)
|
||||
stage0_arch=40
|
||||
stage0_cpu=armv7l
|
||||
;;
|
||||
x86_64)
|
||||
stage0_arch=2
|
||||
stage0_cpu=amd64
|
||||
;;
|
||||
x86)
|
||||
stage0_arch=1
|
||||
stage0_cpu=x86
|
||||
;;
|
||||
*)
|
||||
stage0_arch=1
|
||||
stage0_cpu=$mes_cpu
|
||||
;;
|
||||
esac
|
||||
|
||||
trace "CCLD ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/exit-42.S" $CC\
|
||||
-nostdlib\
|
||||
-g\
|
||||
|
|
|
@ -38,25 +38,6 @@ set -u
|
|||
. ./config.sh
|
||||
. ${srcdest}build-aux/cflags.sh
|
||||
|
||||
case "$mes_cpu" in
|
||||
arm)
|
||||
stage0_arch=40
|
||||
stage0_cpu=armv7l
|
||||
;;
|
||||
x86_64)
|
||||
stage0_arch=2
|
||||
stage0_cpu=amd64
|
||||
;;
|
||||
x86)
|
||||
stage0_arch=1
|
||||
stage0_cpu=x86
|
||||
;;
|
||||
*)
|
||||
stage0_arch=1
|
||||
stage0_cpu=$mes_cpu
|
||||
;;
|
||||
esac
|
||||
|
||||
if $courageous; then
|
||||
echo "Applying courage"
|
||||
set +e
|
||||
|
@ -122,7 +103,8 @@ fi
|
|||
)
|
||||
|
||||
if test -n "$M2_PLANET" && (test "$mes_cpu" == "x86" \
|
||||
|| test "$mes_cpu" == "arm"); then
|
||||
|| test "$mes_cpu" == "x86_64" \
|
||||
|| test "$mes_cpu" == "arm" ); then
|
||||
(
|
||||
. ${srcdest}build-aux/trace.sh
|
||||
if [ -z "$V" -o "$V" = 0 ]; then
|
||||
|
@ -170,7 +152,6 @@ fi
|
|||
${SHELL} ${srcdest}build-aux/build-lib.sh
|
||||
${SHELL} ${srcdest}build-aux/build-source-lib.sh
|
||||
if $bootstrap; then
|
||||
rm -f globals.* # FIXME: avoid name clash with globals from lib
|
||||
${SHELL} ${srcdest}build-aux/build-mes.sh
|
||||
cp -f bin/mes-mescc ../bin
|
||||
cp -f bin/mes ../bin
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -18,8 +18,12 @@
|
|||
|
||||
objects=
|
||||
compile () {
|
||||
c=${srcdest}$1
|
||||
b=$(basename $c .c)
|
||||
if test $(dirname $1) = "."; then
|
||||
c=$1
|
||||
else
|
||||
c=${srcdest}$1
|
||||
fi
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
o=$b.o
|
||||
objects="$objects $o"
|
||||
if test ! -e $o -o $c -nt $o; then
|
||||
|
@ -34,7 +38,7 @@ archive () {
|
|||
sources="$@"
|
||||
objects=
|
||||
for c in $sources; do
|
||||
b=$(basename $c .c)
|
||||
b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,)
|
||||
o=$b.o
|
||||
compile $c
|
||||
done
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -16,6 +16,25 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
case "$mes_cpu" in
|
||||
arm)
|
||||
stage0_arch=40
|
||||
stage0_cpu=armv7l
|
||||
;;
|
||||
x86_64)
|
||||
stage0_arch=2
|
||||
stage0_cpu=amd64
|
||||
;;
|
||||
x86)
|
||||
stage0_arch=1
|
||||
stage0_cpu=x86
|
||||
;;
|
||||
*)
|
||||
stage0_arch=1
|
||||
stage0_cpu=$mes_cpu
|
||||
;;
|
||||
esac
|
||||
|
||||
AM_CPPFLAGS="
|
||||
-D HAVE_CONFIG_H=1
|
||||
-I ${srcdest}include
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -117,6 +117,7 @@ lib/tests/scaffold/54-argv.c
|
|||
lib/tests/scaffold/55-char-array.c
|
||||
lib/tests/scaffold/60-math.c
|
||||
lib/tests/scaffold/60-math-itoa.c
|
||||
lib/tests/scaffold/60-math-modulo.c
|
||||
lib/tests/scaffold/61-array.c
|
||||
lib/tests/scaffold/62-array.c
|
||||
lib/tests/scaffold/63-struct.c
|
||||
|
|
|
@ -74,7 +74,7 @@ libc_mini_SOURCES="$libc_mini_shared_SOURCES"
|
|||
|
||||
if test $mes_libc = mes; then
|
||||
libc_mini_SOURCES="$libc_mini_SOURCES
|
||||
lib/mes/mini-write.c
|
||||
lib/mes/write.c
|
||||
"
|
||||
fi
|
||||
|
||||
|
@ -215,6 +215,7 @@ lib/linux/malloc.c
|
|||
lib/linux/_read.c
|
||||
lib/linux/time.c
|
||||
lib/linux/unlink.c
|
||||
lib/linux/wait4.c
|
||||
lib/linux/waitpid.c
|
||||
lib/linux/$mes_cpu-mes-$compiler/syscall.c
|
||||
lib/linux/getpid.c
|
||||
|
|
|
@ -48,7 +48,6 @@ sed -ri \
|
|||
include/mes/mes.h \
|
||||
include/mes/symbols.h \
|
||||
include/mes/builtins.h \
|
||||
include/m2/lib.h \
|
||||
src/builtins.c \
|
||||
src/cc.c \
|
||||
src/core.c \
|
||||
|
|
|
@ -87,7 +87,7 @@ get_machine.")
|
|||
(define-public m2-planet
|
||||
(package
|
||||
(name "m2-planet")
|
||||
(version "1.9.0")
|
||||
(version "1.10.0")
|
||||
(source (origin
|
||||
(method git-fetch)
|
||||
(uri (git-reference
|
||||
|
@ -97,7 +97,7 @@ get_machine.")
|
|||
(file-name (git-file-name name version))
|
||||
(sha256
|
||||
(base32
|
||||
"0cgvvq91cbxxm93k8ayyvhpaf3c2lv10qw4wyqwn3hc1qb1cfyvr"))))
|
||||
"03ixvfdzhyy1d94iqpwl0p924pdvdp7yq4ggm05w3c013kzy2y12"))))
|
||||
(native-inputs (list mescc-tools))
|
||||
(build-system gnu-build-system)
|
||||
(arguments
|
||||
|
|
|
@ -69,8 +69,11 @@
|
|||
#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode)
|
||||
int dup (int old);
|
||||
int dup2 (int old, int new);
|
||||
|
||||
#if !__M2__
|
||||
int fcntl (int filedes, int command, ...);
|
||||
int open (char const *s, int flags, ...);
|
||||
#endif
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
|
|
|
@ -25,47 +25,29 @@
|
|||
|
||||
/* libc-mini */
|
||||
#ifndef SYS_exit
|
||||
// CONSTANT SYS_exit 0x01
|
||||
#define SYS_exit 0x01
|
||||
#endif
|
||||
#ifndef SYS_write
|
||||
// CONSTANT SYS_write 0x04
|
||||
#define SYS_write 0x04
|
||||
#endif
|
||||
|
||||
/* libc */
|
||||
// CONSTANT SYS_fork 0x02
|
||||
#define SYS_fork 0x02
|
||||
// CONSTANT SYS_read 0x03
|
||||
#define SYS_read 0x03
|
||||
// CONSTANT SYS_open 0x05
|
||||
#define SYS_open 0x05
|
||||
//#define SYS_waitpid
|
||||
// CONSTANT SYS_wait4 0x72
|
||||
#define SYS_wait4 0x72
|
||||
// CONSTANT SYS_execve 0x0b
|
||||
#define SYS_execve 0x0b
|
||||
// CONSTANT SYS_chmod 0x0f
|
||||
#define SYS_chmod 0x0f
|
||||
// CONSTANT SYS_access 0x21
|
||||
#define SYS_access 0x21
|
||||
// CONSTANT SYS_brk 0x2d
|
||||
#define SYS_brk 0x2d
|
||||
// CONSTANT SYS_ioctl 0x36
|
||||
#define SYS_ioctl 0x36
|
||||
// CONSTANT SYS_fsync 0x76
|
||||
#define SYS_fsync 0x76
|
||||
// CONSTANT SYS_getcwd 0xb7
|
||||
#define SYS_getcwd 0xb7
|
||||
// CONSTANT SYS_dup 0x29
|
||||
#define SYS_dup 0x29
|
||||
// CONSTANT SYS_dup2 0x3f
|
||||
#define SYS_dup2 0x3f
|
||||
// CONSTANT SYS_unlink 0x0a
|
||||
#define SYS_unlink 0x0a
|
||||
// CONSTANT SYS_gettimeofday 0x4e
|
||||
#define SYS_gettimeofday 0x4e
|
||||
// CONSTANT SYS_clock_gettime 0x107
|
||||
#define SYS_clock_gettime 0x107
|
||||
|
||||
/* libc+tcc */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -22,50 +22,30 @@
|
|||
|
||||
/* libc-mini */
|
||||
#ifndef SYS_exit
|
||||
// CONSTANT SYS_exit 0x01
|
||||
#define SYS_exit 0x01
|
||||
#endif
|
||||
#ifndef SYS_write
|
||||
// CONSTANT SYS_write 0x04
|
||||
#define SYS_write 0x04
|
||||
#endif
|
||||
|
||||
/* libc */
|
||||
// CONSTANT SYS_fork 0x02
|
||||
#define SYS_fork 0x02
|
||||
// CONSTANT SYS_read 0x03
|
||||
#define SYS_read 0x03
|
||||
// CONSTANT SYS_open 0x05
|
||||
#define SYS_open 0x05
|
||||
// CONSTANT SYS_waitpid 0x07
|
||||
#define SYS_waitpid 0x07
|
||||
// CONSTANT SYS_wait4 0x72
|
||||
#define SYS_wait4 0x72
|
||||
// CONSTANT SYS_execve 0x0b
|
||||
#define SYS_execve 0x0b
|
||||
// CONSTANT SYS_chmod 0x0f
|
||||
#define SYS_chmod 0x0f
|
||||
// CONSTANT SYS_access 0x21
|
||||
#define SYS_access 0x21
|
||||
// CONSTANT SYS_brk 0x2d
|
||||
#define SYS_brk 0x2d
|
||||
// CONSTANT SYS_ioctl 0x36
|
||||
#define SYS_ioctl 0x36
|
||||
// CONSTANT SYS_fsync 0x76
|
||||
#define SYS_fsync 0x76
|
||||
// CONSTANT SYS_getcwd 0xb7
|
||||
#define SYS_getcwd 0xb7
|
||||
// CONSTANT SYS_dup 0x29
|
||||
#define SYS_dup 0x29
|
||||
// CONSTANT SYS_dup2 0x3f
|
||||
#define SYS_dup2 0x3f
|
||||
// CONSTANT SYS_unlink 0x0a
|
||||
#define SYS_unlink 0x0a
|
||||
// CONSTANT SYS_gettimeofday 0x4e
|
||||
#define SYS_gettimeofday 0x4e
|
||||
// CONSTANT SYS_clock_gettime 0x109
|
||||
#define SYS_clock_gettime 0x109
|
||||
// CONSTANT SYS_time 0x0d
|
||||
#define SYS_time 0x0d
|
||||
|
||||
/* libc+tcc */
|
||||
|
|
|
@ -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 */
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -23,76 +23,32 @@
|
|||
|
||||
/* Cell types */
|
||||
|
||||
// CONSTANT TCHAR 0
|
||||
#define TCHAR 0
|
||||
|
||||
// CONSTANT TBYTES 1
|
||||
#define TBYTES 1
|
||||
// CONSTANT TCLOSURE 2
|
||||
#define TCLOSURE 2
|
||||
// CONSTANT TCONTINUATION 3
|
||||
#define TCONTINUATION 3
|
||||
// CONSTANT TKEYWORD 4
|
||||
#define TKEYWORD 4
|
||||
// CONSTANT TMACRO 5
|
||||
#define TMACRO 5
|
||||
// CONSTANT TNUMBER 6
|
||||
#define TNUMBER 6
|
||||
// CONSTANT TPAIR 7
|
||||
#define TPAIR 7
|
||||
// CONSTANT TPORT 8
|
||||
#define TPORT 8
|
||||
// CONSTANT TREF 9
|
||||
#define TREF 9
|
||||
// CONSTANT TSPECIAL 10
|
||||
#define TSPECIAL 10
|
||||
// CONSTANT TSTRING 11
|
||||
#define TSTRING 11
|
||||
// CONSTANT TSTRUCT 12
|
||||
#define TSTRUCT 12
|
||||
// CONSTANT TSYMBOL 13
|
||||
#define TSYMBOL 13
|
||||
// CONSTANT TVALUES 14
|
||||
#define TVALUES 14
|
||||
// CONSTANT TVARIABLE 15
|
||||
#define TVARIABLE 15
|
||||
// CONSTANT TVECTOR 16
|
||||
#define TVECTOR 16
|
||||
// CONSTANT TBROKEN_HEART 17
|
||||
#define TBROKEN_HEART 17
|
||||
|
||||
/* Struct types */
|
||||
|
||||
// CONSTANT STRUCT_TYPE 0
|
||||
#define STRUCT_TYPE 0
|
||||
// CONSTANT STRUCT_PRINTER 1
|
||||
#define STRUCT_PRINTER 1
|
||||
|
||||
// CONSTANT GC_FRAME_SIZE 5
|
||||
#define GC_FRAME_SIZE 5
|
||||
// CONSTANT GC_FRAME_PROCEDURE 4
|
||||
#define GC_FRAME_PROCEDURE 4
|
||||
|
||||
// CONSTANT STDIN 0
|
||||
// CONSTANT STDOUT 1
|
||||
// CONSTANT STDERR 2
|
||||
|
||||
/* Unknown type 1
|
||||
// CONSTANT EOF -1
|
||||
*/
|
||||
|
||||
// CONSTANT O_RDONLY 0
|
||||
// CONSTANT O_WRONLY 1
|
||||
// CONSTANT O_CREAT 0x40
|
||||
// CONSTANT O_TRUNC 0x200
|
||||
|
||||
// CONSTANT PATH_MAX 1024
|
||||
// CONSTANT __FILEDES_MAX 512
|
||||
|
||||
// CONSTANT S_IRUSR 00400
|
||||
// CONSTANT S_IWUSR 00200
|
||||
|
||||
// CONSTANT CLOCK_PROCESS_CPUTIME_ID 2
|
||||
|
||||
|
||||
#endif /* __MES_CONSTANTS_H */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2020 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.
|
||||
*
|
||||
|
@ -25,21 +25,27 @@
|
|||
#include <mes/config.h>
|
||||
#endif
|
||||
|
||||
// CONSTANT STDIN 0
|
||||
#ifndef STDIN
|
||||
#define STDIN 0
|
||||
#endif
|
||||
|
||||
// CONSTANT STDOUT 1
|
||||
#ifndef STDOUT
|
||||
#define STDOUT 1
|
||||
#endif
|
||||
|
||||
// CONSTANT STDERR 2
|
||||
#ifndef STDERR
|
||||
#define STDERR 2
|
||||
#endif
|
||||
|
||||
/* M2-Planet does not support pointer arithmetic. Explicitly compensate
|
||||
for that by multiplying with M2_PTR_SIZE when using (char)
|
||||
pointers. */
|
||||
#if __M2__
|
||||
#define M2_PTR_SIZE sizeof (void*)
|
||||
#else
|
||||
#define M2_PTR_SIZE 1
|
||||
#endif
|
||||
|
||||
extern char **environ;
|
||||
extern int __stdin;
|
||||
extern int __stdout;
|
||||
|
@ -63,10 +69,14 @@ int oputs (char const *s);
|
|||
#ifndef __MES_SIZE_T
|
||||
#define __MES_SIZE_T
|
||||
#undef size_t
|
||||
#if __M2__
|
||||
typedef unsigned size_t;
|
||||
#else
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _SSIZE_T
|
||||
#define _SSIZE_T
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
||||
*
|
||||
|
@ -23,6 +23,9 @@
|
|||
|
||||
#include <mes/lib-mini.h>
|
||||
|
||||
#define __FILEDES_MAX 512
|
||||
extern char *__brk;
|
||||
|
||||
char *cast_intp_to_charp (int const *i);
|
||||
char *cast_long_to_charp (long i);
|
||||
long cast_charp_to_long (char const *);
|
||||
|
@ -34,14 +37,11 @@ void __ungetc_init ();
|
|||
void __ungetc_clear (int filedes);
|
||||
void __ungetc_set (int filedes, int c);
|
||||
int __ungetc_p (int filedes);
|
||||
double abtod (char const **p, int base);
|
||||
long abtol (char const **p, int base);
|
||||
char *dtoab (double number, int base, int signed_p);
|
||||
char *itoa (int number);
|
||||
char *ltoa (long number);
|
||||
char *ltoab (long x, int base);
|
||||
char *ntoab (long number, unsigned base, int signed_p);
|
||||
char *ultoa (unsigned long number);
|
||||
char *utoa (unsigned number);
|
||||
int eputc (int c);
|
||||
int fdgetc (int fd);
|
||||
|
@ -61,10 +61,12 @@ char *search_path (char const *file_name);
|
|||
ssize_t _read (int fd, void *buffer, size_t size);
|
||||
void assert_msg (int check, char *msg);
|
||||
|
||||
extern char *__brk;
|
||||
extern void (*__call_at_exit) (void);
|
||||
|
||||
#define __FILEDES_MAX 512
|
||||
long __mesabi_imod (long a, long b);
|
||||
long __mesabi_idiv (long a, long b);
|
||||
void *__memcpy (void *dest, void const *src, size_t n);
|
||||
void *__memmove (void *dest, void const *src, size_t n);
|
||||
void *__memset (void *s, int c, size_t n);
|
||||
int __raise (int signal);
|
||||
|
||||
#if !SYSTEM_LIBC
|
||||
void __assert_fail (char *s);
|
||||
|
@ -74,16 +76,15 @@ void _exit (int code);
|
|||
long brk (void *addr);
|
||||
#endif // !SYSTEM_LIBC
|
||||
|
||||
long __mesabi_imod (long a, long b);
|
||||
long __mesabi_idiv (long a, long b);
|
||||
#if !__M2__
|
||||
extern void (*__call_at_exit) (void);
|
||||
double abtod (char const **p, int base);
|
||||
char *dtoab (double number, int base, int signed_p);
|
||||
char *ultoa (unsigned long number);
|
||||
unsigned long __mesabi_umod (unsigned long a, unsigned long b);
|
||||
unsigned long __mesabi_udiv (unsigned long a, unsigned long b);
|
||||
unsigned long __mesabi_uldiv (unsigned long a, unsigned long b,
|
||||
unsigned long *remainder);
|
||||
|
||||
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
|
||||
|
||||
#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 sizeof (struct scm)
|
||||
#else
|
||||
#define M2_CELL_SIZE 1
|
||||
#endif
|
||||
|
||||
/* mes */
|
||||
extern char *g_datadir;
|
||||
extern int g_debug;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2021 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.
|
||||
*
|
||||
|
@ -137,14 +137,8 @@ extern struct scm *cell_type_broken_heart;
|
|||
extern struct scm *cell_symbol_program;
|
||||
extern struct scm *cell_symbol_test;
|
||||
|
||||
// CONSTANT SYMBOL_MAX 114
|
||||
#define SYMBOL_MAX 114
|
||||
|
||||
// CONSTANT CELL_UNSPECIFIED 7
|
||||
#define CELL_UNSPECIFIED 7
|
||||
|
||||
// CONSTANT CELL_SYMBOL_RECORD_TYPE 82
|
||||
#define CELL_SYMBOL_RECORD_TYPE 82
|
||||
|
||||
|
||||
#endif /* __MES_SYMBOLS_H */
|
||||
|
|
|
@ -29,9 +29,12 @@
|
|||
|
||||
#define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long)))
|
||||
|
||||
typedef struct {
|
||||
#if !__M2__
|
||||
typedef struct
|
||||
{
|
||||
unsigned long items[_SIGSET_NITEMS];
|
||||
} sigset_t;
|
||||
#endif
|
||||
typedef long stack_t;
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -91,6 +94,7 @@ typedef long stack_t;
|
|||
#define SA_NOMASK SA_NODEFER
|
||||
#define SA_ONESHOT SA_RESETHAND
|
||||
|
||||
#if !__M2__ // lacks short, casts
|
||||
typedef struct siginfo_t
|
||||
{
|
||||
int si_signo;
|
||||
|
@ -120,7 +124,7 @@ typedef struct siginfo_t
|
|||
} siginfo_t;
|
||||
// *INDENT-ON*
|
||||
|
||||
#if __MESC__
|
||||
#if __M2__ || __MESC__
|
||||
typedef long sighandler_t;
|
||||
#else
|
||||
typedef void (*sighandler_t) (int);
|
||||
|
@ -255,6 +259,7 @@ int sigemptyset (sigset_t * set);
|
|||
#endif
|
||||
int sigprocmask (int how, sigset_t const *set, sigset_t * oldset);
|
||||
|
||||
#endif // !__M2__
|
||||
#endif //! SYSTEM_LIBC
|
||||
|
||||
#endif // __MES_SIGNAL_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 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.
|
||||
*
|
||||
|
@ -65,30 +65,33 @@ int ferror (FILE * stream);
|
|||
int fflush (FILE * stream);
|
||||
int fgetc (FILE * stream);
|
||||
char *fgets (char *s, int size, FILE * stream);
|
||||
int fprintf (FILE * stream, char const *format, ...);
|
||||
int fpurge (FILE * stream);
|
||||
int fputc (int c, FILE * stream);
|
||||
int fputs (char const *s, FILE * stream);
|
||||
int fscanf (FILE * stream, char const *template, ...);
|
||||
int fseek (FILE * stream, long offset, int whence);
|
||||
int getc (FILE * stream);
|
||||
int getchar (void);
|
||||
char *getlogin (void);
|
||||
int printf (char const *format, ...);
|
||||
int putc (int c, FILE * stream);
|
||||
int putchar (int c);
|
||||
int puts (char const *s);
|
||||
int remove (char const *file_name);
|
||||
int setvbuf (FILE * stream, char *buf, int mode, size_t size);
|
||||
int snprintf (char *str, size_t size, char const *format, ...);
|
||||
int sprintf (char *str, char const *format, ...);
|
||||
int sscanf (char const *str, char const *format, ...);
|
||||
int ungetc (int c, FILE * stream);
|
||||
long ftell (FILE * stream);
|
||||
size_t fread (void *ptr, size_t size, size_t count, FILE * stream);
|
||||
size_t freadahead (FILE * fp);
|
||||
size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream);
|
||||
|
||||
#if !__M2__
|
||||
int fprintf (FILE * stream, char const *format, ...);
|
||||
int fscanf (FILE * stream, char const *template, ...);
|
||||
int printf (char const *format, ...);
|
||||
int snprintf (char *str, size_t size, char const *format, ...);
|
||||
int sprintf (char *str, char const *format, ...);
|
||||
int sscanf (char const *str, char const *format, ...);
|
||||
#endif // !__M2__
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
#endif // __MES_STDIO_H
|
||||
|
|
|
@ -28,8 +28,13 @@
|
|||
|
||||
#define TCGETS 0x5401
|
||||
#define TCGETA 0x5405
|
||||
#if __M2__
|
||||
int ioctl (int fd, unsigned request, long data);
|
||||
int ioctl3 (int fd, unsigned request, long data);
|
||||
#else
|
||||
int ioctl (int fd, unsigned long request, ...);
|
||||
int ioctl3 (int fd, unsigned long request, long data);
|
||||
#endif
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
|
|
|
@ -32,20 +32,20 @@ struct rusage
|
|||
{
|
||||
struct timeval ru_utime;
|
||||
struct timeval ru_stime;
|
||||
long int ru_maxrss;
|
||||
long int ru_ixrss;
|
||||
long int ru_idrss;
|
||||
long int ru_isrss;
|
||||
long int ru_minflt;
|
||||
long int ru_majflt;
|
||||
long int ru_nswap;
|
||||
long int ru_inblock;
|
||||
long int ru_oublock;
|
||||
long int ru_msgsnd;
|
||||
long int ru_msgrcv;
|
||||
long int ru_nsignals;
|
||||
long int ru_nvcsw;
|
||||
long int ru_nivcsw;
|
||||
long ru_maxrss;
|
||||
long ru_ixrss;
|
||||
long ru_idrss;
|
||||
long ru_isrss;
|
||||
long ru_minflt;
|
||||
long ru_majflt;
|
||||
long ru_nswap;
|
||||
long ru_inblock;
|
||||
long ru_oublock;
|
||||
long ru_msgsnd;
|
||||
long ru_msgrcv;
|
||||
long ru_nsignals;
|
||||
long ru_nvcsw;
|
||||
long ru_nivcsw;
|
||||
};
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
|
|
|
@ -36,7 +36,29 @@ typedef int mode_t;
|
|||
#endif
|
||||
|
||||
// *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
|
||||
{
|
||||
unsigned long st_dev;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -66,15 +66,23 @@ typedef unsigned gid_t;
|
|||
#ifndef __MES_INO_T
|
||||
#define __MES_INO_T
|
||||
#undef ino_t
|
||||
#if __M2__
|
||||
typedef unsigned ino_t;
|
||||
#else
|
||||
typedef unsigned long ino_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __SIZEOF_LONG_LONG__ == 8
|
||||
#ifndef __MES_INO64_T
|
||||
#define __MES_INO64_T
|
||||
#undef ino64_t
|
||||
#if __M2__
|
||||
typedef unsigned ino64_t;
|
||||
#else
|
||||
typedef unsigned long long ino64_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
#if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined)
|
||||
|
@ -83,8 +91,12 @@ typedef unsigned long long ino64_t;
|
|||
#undef intptr_t
|
||||
typedef long intptr_t;
|
||||
#undef uintptr_t
|
||||
#if __M2__
|
||||
typedef unsigned uintptr_t;
|
||||
#else
|
||||
typedef unsigned long uintptr_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __MES_OFF_T
|
||||
#define __MES_OFF_T
|
||||
|
@ -96,8 +108,12 @@ typedef long off_t;
|
|||
#ifndef __MES_OFF64_T
|
||||
#define __MES_OFF64_T
|
||||
#undef off64_t
|
||||
#if __M2__
|
||||
typedef unsigned off64_t;
|
||||
#else
|
||||
typedef unsigned long long off64_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif // __SIZEOF_LONG_LONG__ == 8
|
||||
|
||||
#ifndef __MES_PID_T
|
||||
|
@ -126,9 +142,13 @@ typedef long sigval_t;
|
|||
#ifndef __MES_SIZE_T
|
||||
#define __MES_SIZE_T
|
||||
#undef size_t
|
||||
#if __M2__
|
||||
typedef unsigned size_t;
|
||||
#else
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __MES_SSIZE_T
|
||||
#define __MES_SSIZE_T
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -20,6 +20,8 @@
|
|||
#ifndef __MES_SYS_WAIT_H
|
||||
#define __MES_SYS_WAIT_H 1
|
||||
|
||||
#include <sys/resource.h>
|
||||
|
||||
#if SYSTEM_LIBC
|
||||
#undef __MES_SYS_WAIT_H
|
||||
#include_next <sys/wait.h>
|
||||
|
@ -35,6 +37,8 @@ typedef int pid_t;
|
|||
|
||||
pid_t waitpid (pid_t pid, int *status_ptr, int options);
|
||||
pid_t wait (int *status_ptr);
|
||||
pid_t wait4 (pid_t pid, int *wstatus, int options,
|
||||
struct rusage *rusage);
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -27,8 +27,8 @@
|
|||
|
||||
#ifndef __MES_TIME_T
|
||||
#define __MES_TIME_T 1
|
||||
typedef long int clockid_t;
|
||||
typedef long int time_t;
|
||||
typedef long clockid_t;
|
||||
typedef long time_t;
|
||||
#endif
|
||||
|
||||
struct tm
|
||||
|
|
|
@ -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
|
39
kaem.run
39
kaem.run
|
@ -25,34 +25,42 @@ stage0_cpu=${stage0_cpu:-x86}
|
|||
mkdir -p m2
|
||||
|
||||
M2-Planet \
|
||||
--bootstrap-mode \
|
||||
--debug \
|
||||
--architecture ${stage0_cpu} \
|
||||
-f include/m2/lib.h \
|
||||
-D __${mes_cpu}__=1 \
|
||||
-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/_exit.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||
-f lib/mes/globals.c \
|
||||
-f lib/m2/cast.c \
|
||||
-f lib/m2/exit.c \
|
||||
-f lib/mes/mini-write.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
||||
-f lib/stdlib/exit.c \
|
||||
-f lib/mes/write.c \
|
||||
-f include/linux/${mes_cpu}/syscall.h \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
||||
-f lib/stub/__raise.c \
|
||||
-f lib/linux/brk.c \
|
||||
-f lib/m2/malloc.c \
|
||||
-f lib/linux/malloc.c \
|
||||
-f lib/string/memset.c \
|
||||
-f lib/m2/read.c \
|
||||
-f lib/linux/read.c \
|
||||
-f lib/mes/fdgetc.c \
|
||||
-f lib/stdio/getchar.c \
|
||||
-f lib/stdio/putchar.c \
|
||||
-f lib/m2/open.c \
|
||||
-f lib/m2/mes_open.c \
|
||||
-f lib/stub/__buffered_read.c \
|
||||
-f lib/linux/_open3.c \
|
||||
-f lib/linux/open.c \
|
||||
-f lib/mes/mes_open.c \
|
||||
-f lib/string/strlen.c \
|
||||
-f lib/mes/eputs.c \
|
||||
-f lib/mes/fdputc.c \
|
||||
-f lib/mes/eputc.c \
|
||||
\
|
||||
-f include/time.h \
|
||||
-f include/sys/time.h \
|
||||
-f include/sys/types.h \
|
||||
-f include/mes/mes.h \
|
||||
-f include/mes/builtins.h \
|
||||
-f include/mes/constants.h \
|
||||
|
@ -81,17 +89,22 @@ M2-Planet \
|
|||
-f lib/mes/fdungetc.c \
|
||||
-f lib/posix/setenv.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 include/sys/ioctl.h \
|
||||
-f lib/m2/isatty.c \
|
||||
-f lib/linux/fork.c \
|
||||
-f lib/m2/execve.c \
|
||||
-f lib/m2/execv.c \
|
||||
-f 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/m2/clock_gettime.c \
|
||||
-f lib/linux/clock_gettime.c \
|
||||
-f lib/m2/time.c \
|
||||
-f lib/linux/_getcwd.c \
|
||||
-f include/limits.h \
|
||||
-f lib/m2/getcwd.c \
|
||||
-f lib/linux/dup.c \
|
||||
-f lib/linux/dup2.c \
|
||||
|
@ -102,6 +115,7 @@ M2-Planet \
|
|||
-f src/core.c \
|
||||
-f src/display.c \
|
||||
-f src/eval-apply.c \
|
||||
-f include/fcntl.h \
|
||||
-f src/gc.c \
|
||||
-f src/hash.c \
|
||||
-f src/lib.c \
|
||||
|
@ -109,6 +123,7 @@ M2-Planet \
|
|||
-f src/math.c \
|
||||
-f src/mes.c \
|
||||
-f src/module.c \
|
||||
-f include/signal.h \
|
||||
-f src/posix.c \
|
||||
-f src/reader.c \
|
||||
-f src/stack.c \
|
||||
|
|
|
@ -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
|
|
@ -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_64
|
||||
stage0_cpu=amd64
|
||||
kaem --verbose --strict
|
|
@ -1,5 +1,5 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2018,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
### Copyright © 2017,2018,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
### Copyright © 2019,2020 Danny Milosavljevic <dannym@scratchpost.org>
|
||||
###
|
||||
### This file is part of GNU Mes.
|
||||
|
@ -91,6 +91,7 @@ DEFINE mov____%r0,(%r1) 000081e5
|
|||
DEFINE mov____%r1,%r0 0100a0e1
|
||||
DEFINE mov____%r1,%r2 0120a0e1
|
||||
DEFINE mov____%esp,%r0 0d00a0e1
|
||||
DEFINE mov____%esp,%r3 0d30a0e1
|
||||
|
||||
# e59f9004 ldr r9, [pc, #4] ; <L1>
|
||||
# e5890000 str r0, [r9]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -26,7 +26,9 @@
|
|||
int
|
||||
_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_int_to_long (file_name);
|
||||
int r = _sys_call3 (SYS_open, long_file_name, flags, mask);
|
||||
__ungetc_init ();
|
||||
if (r > 2)
|
||||
{
|
||||
__ungetc_clear (r);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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.
|
||||
*
|
||||
|
@ -24,23 +24,13 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
|
||||
off_t
|
||||
_lseek (int filedes, off_t offset, int whence)
|
||||
{
|
||||
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
|
||||
}
|
||||
#endif
|
||||
|
||||
off_t
|
||||
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 (_lseek (filedes, 0, SEEK_CUR) == -1)
|
||||
return -1;
|
||||
#endif
|
||||
long long_filedes = filedes;
|
||||
long long_offset = offset;
|
||||
size_t skip = __buffered_read_clear (filedes);
|
||||
if (whence == SEEK_CUR)
|
||||
offset -= skip;
|
||||
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
|
||||
return _sys_call3 (SYS_lseek, long_filedes, long_offset, whence);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
|
@ -31,9 +31,11 @@ malloc (size_t size)
|
|||
{
|
||||
if (!__brk)
|
||||
__brk = cast_long_to_charp (brk (0));
|
||||
#if !__M2__
|
||||
/* align what we give back. */
|
||||
__brk = (char*) (((uintptr_t) __brk
|
||||
+ sizeof (max_align_t) - 1) & -sizeof (max_align_t));
|
||||
#endif
|
||||
if (brk (__brk + size) == -1)
|
||||
return 0;
|
||||
char *p = __brk;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -22,6 +22,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#if __M2__
|
||||
int
|
||||
open (char *file_name, int flags, int mask)
|
||||
{
|
||||
|
@ -30,3 +31,17 @@ open (char *file_name, int flags, int mask)
|
|||
__ungetc_clear (r);
|
||||
return r;
|
||||
}
|
||||
#else // !__M2__
|
||||
int
|
||||
open (char const *file_name, int flags, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, flags);
|
||||
int mask = va_arg (ap, int);
|
||||
int r = _sys_call3 (SYS_open, (long) file_name, flags, mask);
|
||||
va_end (ap);
|
||||
if (r > 2)
|
||||
__ungetc_clear (r);
|
||||
return r;
|
||||
}
|
||||
#endif // __M2__
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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.
|
||||
*
|
||||
|
@ -18,16 +18,18 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
ssize_t
|
||||
read (int filedes, void *buffer, size_t size)
|
||||
{
|
||||
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 (bytes == 1)
|
||||
|
@ -48,5 +50,6 @@ read (int filedes, void *buffer, size_t size)
|
|||
eputs ("\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return bytes;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -21,14 +21,8 @@
|
|||
#include <linux/syscall.h>
|
||||
#include <syscall.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 <stdlib.h>
|
||||
|
||||
time_t
|
||||
time (time_t * result)
|
||||
|
@ -41,31 +35,3 @@ time (time_t * result)
|
|||
*result = 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:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -22,18 +22,15 @@
|
|||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
int
|
||||
waitpid (int pid, int *status_ptr, int options)
|
||||
pid_t
|
||||
wait4 (pid_t pid, int *status_ptr, int options, struct rusage *rusage)
|
||||
{
|
||||
long long_pid = pid;
|
||||
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
||||
long long_options = options;
|
||||
//##if __i386__
|
||||
//# return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
|
||||
//##elif __x86_64__ || __arm__
|
||||
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options, 0);
|
||||
//##else
|
||||
//##error arch not supported
|
||||
//##endif
|
||||
long long_rusage = cast_voidp_to_long (rusage);
|
||||
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options,
|
||||
long_rusage);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -25,11 +25,12 @@
|
|||
pid_t
|
||||
waitpid (pid_t pid, int *status_ptr, int options)
|
||||
{
|
||||
#if __i386__
|
||||
return _sys_call3 (SYS_waitpid, (long) pid, (long) status_ptr, (int) options);
|
||||
#elif __x86_64__ || __arm__
|
||||
return _sys_call4 (SYS_wait4, (long) pid, (long) status_ptr, (int) options, 0);
|
||||
#else
|
||||
#error arch not supported
|
||||
long long_pid = pid;
|
||||
long long_status_ptr = cast_voidp_to_long (status_ptr);
|
||||
long long_options = options;
|
||||
#if SYS_waitpid
|
||||
return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
|
||||
#elif SYS_wait4
|
||||
return wait4 (pid, status_ptr, options, 0);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,11 +18,12 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
int
|
||||
mes_open (char *file_name, int flags, int mask)
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
void
|
||||
_exit (int status)
|
||||
{
|
||||
int filedes = open (file_name, flags, mask);
|
||||
if (filedes > 2)
|
||||
__ungetc_clear (filedes);
|
||||
return filedes;
|
||||
asm ("mov____$i32,%rax SYS_exit");
|
||||
asm ("mov____0x8(%rbp),%rdi !-8");
|
||||
asm ("syscall");
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,19 +18,14 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <string.h>
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
char *__brk = 0;
|
||||
|
||||
void *
|
||||
malloc (size_t size)
|
||||
void
|
||||
_write (int filedes, void const *buffer, size_t size)
|
||||
{
|
||||
if (!__brk)
|
||||
__brk = cast_long_to_charp (brk (0));
|
||||
if (brk (__brk + size) == -1)
|
||||
return 0;
|
||||
char *p = __brk;
|
||||
__brk = __brk + size;
|
||||
return p;
|
||||
asm ("mov____$i32,%rax SYS_write");
|
||||
asm ("mov____0x8(%rbp),%rdi !-8");
|
||||
asm ("mov____0x8(%rbp),%rsi !-16");
|
||||
asm ("mov____0x8(%rbp),%rdx !-24");
|
||||
asm ("syscall");
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
###
|
||||
### This file is part of GNU Mes.
|
||||
###
|
||||
### GNU Mes is free software; you can redistribute it and/or modify it
|
||||
### under the terms of the GNU General Public License as published by
|
||||
### the Free Software Foundation; either version 3 of the License, or (at
|
||||
### your option) any later version.
|
||||
###
|
||||
### GNU Mes is distributed in the hope that it will be useful, but
|
||||
### WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
### GNU General Public License for more details.
|
||||
###
|
||||
### You should have received a copy of the GNU General Public License
|
||||
### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
:UNUSED_start
|
||||
push___%rbp
|
||||
mov____%rsp,%rbp
|
||||
sub____$i32,%rsp %0x10a4
|
||||
mov____$i8,%rax !0
|
||||
movl___%eax,0x32 &GLOBAL___stdin
|
||||
mov____$i8,%rax !1
|
||||
movl___%eax,0x32 &GLOBAL___stdout
|
||||
mov____$i8,%rax !2
|
||||
movl___%eax,0x32 &GLOBAL___stderr
|
||||
|
||||
mov____%rbp,%rax
|
||||
add____$i8,%rax !8
|
||||
mov____(%rax),%rax
|
||||
add____$i8,%rax !0x03
|
||||
shl____$i8,%rax !0x03
|
||||
add____%rbp,%rax
|
||||
mov____%rax,0x32 &GLOBAL_environ
|
||||
;; push___%rax ;M2-Planet pushes forward
|
||||
|
||||
mov____%rbp,%rax ;argc
|
||||
add____$i8,%rax !8
|
||||
mov____(%rax),%rax
|
||||
push___%rax
|
||||
|
||||
mov____%rbp,%rax ;argv
|
||||
add____$i8,%rax !16
|
||||
push___%rax
|
||||
|
||||
mov____0x32,%rax &GLOBAL_environ
|
||||
push___%rax ;env
|
||||
|
||||
mov____%rdi,%rbp ;M2-Planet calling convention
|
||||
add____$i8,%rbp !8
|
||||
|
||||
call32 %FUNCTION_main
|
||||
add____$i8,%rsp !0x0
|
||||
test___%rax,%rax
|
||||
mov____%rax,%rdi
|
||||
mov____$i32,%rax %0x3c
|
||||
syscall
|
||||
hlt
|
||||
mov____%rbp,%rsp
|
||||
pop____%rbp
|
||||
ret
|
||||
|
||||
:_start
|
||||
|
||||
COPY_rsp_to_rbp ; Protect rsp
|
||||
|
||||
;; Prepare argv
|
||||
LOAD_BASE_ADDRESS_rax %8 ; ARGV_address = RBP + 8
|
||||
PUSH_RAX ; Put argv on the stack
|
||||
|
||||
;; Prepare envp
|
||||
COPY_rbp_to_rax ; Address we need to load from
|
||||
LOAD_INTEGER ; Get ARGC
|
||||
ADD_IMMEDIATE_to_rax %2 ; OFFSET = ARGC + 2
|
||||
SAL_rax_Immediate8 !3 ; OFFSET = OFFSET * WORDSIZE
|
||||
ADD_rbp_to_rax ; ENVP_address = RSP + OFFSET
|
||||
PUSH_RAX ; Put envp on the stack
|
||||
|
||||
;; mes c lib environ
|
||||
mov____%rax,0x32 &GLOBAL_environ
|
||||
;; mes c lib io
|
||||
mov____$i8,%rax !0
|
||||
movl___%eax,0x32 &GLOBAL___stdin
|
||||
mov____$i8,%rax !1
|
||||
movl___%eax,0x32 &GLOBAL___stdout
|
||||
mov____$i8,%rax !2
|
||||
movl___%eax,0x32 &GLOBAL___stderr
|
||||
|
||||
LOAD_IMMEDIATE_rax &GLOBAL___stdin
|
||||
PUSH_RAX #_common_recursion
|
||||
LOAD_IMMEDIATE_rax %0
|
||||
POP_RBX # _common_recursion
|
||||
STORE_INTEGER
|
||||
|
||||
LOAD_IMMEDIATE_rax &GLOBAL___stdout
|
||||
PUSH_RAX #_common_recursion
|
||||
LOAD_IMMEDIATE_rax %1
|
||||
POP_RBX # _common_recursion
|
||||
STORE_INTEGER
|
||||
|
||||
LOAD_IMMEDIATE_rax &GLOBAL___stderr
|
||||
PUSH_RAX #_common_recursion
|
||||
LOAD_IMMEDIATE_rax %2
|
||||
POP_RBX # _common_recursion
|
||||
STORE_INTEGER
|
||||
|
||||
;; Stack offset
|
||||
ADD_IMMEDIATE_to_rbp %8 ; Fix rbp
|
||||
|
||||
;; Perform the main loop
|
||||
CALL_IMMEDIATE %FUNCTION_main
|
||||
|
||||
mov____%rax,%rdi
|
||||
mov____$i32,%rax SYS_exit
|
||||
syscall
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,14 +18,17 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
long
|
||||
read (int filedes, void *buffer, long size)
|
||||
{
|
||||
long bytes = _sys_call3 (SYS_read, filedes, buffer, size);
|
||||
return bytes;
|
||||
}
|
||||
int __stdin;
|
||||
int __stdout;
|
||||
int __stderr;
|
||||
char **environ;
|
||||
int main (int argc, char **argv, char **envp);
|
||||
|
||||
/* FIXME: this is going to be called `FUNCTION__start' */
|
||||
//#int
|
||||
//#_start ()
|
||||
//#{
|
||||
//# ..
|
||||
//#}
|
|
@ -0,0 +1,137 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/x86_64/syscall.h>
|
||||
|
||||
long
|
||||
__sys_call (long sys_call)
|
||||
{
|
||||
asm ("mov____0x8(%rbp),%rax !-8");
|
||||
asm ("syscall");
|
||||
}
|
||||
|
||||
long
|
||||
__sys_call1 (long sys_call, long one)
|
||||
{
|
||||
asm ("mov____0x8(%rbp),%rax !-8");
|
||||
asm ("mov____0x8(%rbp),%rdi !-16");
|
||||
asm ("syscall");
|
||||
}
|
||||
|
||||
long
|
||||
__sys_call2 (long sys_call, long one, long two)
|
||||
{
|
||||
asm ("mov____0x8(%rbp),%rax !-8");
|
||||
asm ("mov____0x8(%rbp),%rdi !-16");
|
||||
asm ("mov____0x8(%rbp),%rsi !-24");
|
||||
asm ("syscall");
|
||||
}
|
||||
|
||||
long
|
||||
__sys_call3 (long sys_call, long one, long two, long three)
|
||||
{
|
||||
asm ("mov____0x8(%rbp),%rax !-8");
|
||||
asm ("mov____0x8(%rbp),%rdi !-16");
|
||||
asm ("mov____0x8(%rbp),%rsi !-24");
|
||||
asm ("mov____0x8(%rbp),%rdx !-32");
|
||||
asm ("syscall");
|
||||
}
|
||||
|
||||
long
|
||||
__sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||
{
|
||||
asm ("mov____0x8(%rbp),%rax !-8");
|
||||
asm ("mov____0x8(%rbp),%rdi !-16");
|
||||
asm ("mov____0x8(%rbp),%rsi !-24");
|
||||
asm ("mov____0x8(%rbp),%rdx !-32");
|
||||
asm ("mov____0x8(%rbp),%r10 !-40");
|
||||
asm ("syscall");
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call (long sys_call)
|
||||
{
|
||||
long r = __sys_call (sys_call);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call1 (long sys_call, long one)
|
||||
{
|
||||
long r = __sys_call1 (sys_call, one);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call2 (long sys_call, long one, long two)
|
||||
{
|
||||
long r = __sys_call2 (sys_call, one, two);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call3 (long sys_call, long one, long two, long three)
|
||||
{
|
||||
long r = __sys_call3 (sys_call, one, two, three);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||
{
|
||||
long r = __sys_call4 (sys_call, one, two, three, four);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
chmod (char const *file_name, int mask)
|
||||
{
|
||||
long long_file_name = file_name;
|
||||
long long_mask = mask;
|
||||
return _sys_call2 (SYS_chmod, long_file_name, long_mask);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
clock_gettime (long clk_id, struct timespec *tp)
|
||||
{
|
||||
long long_tp = tp;
|
||||
return _sys_call2 (SYS_clock_gettime, clk_id, tp);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 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.
|
||||
*
|
||||
|
@ -24,8 +24,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// CONSTANT PATH_MAX 1024
|
||||
|
||||
char *__getcwd_buf;
|
||||
|
||||
char *
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 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.
|
||||
*
|
||||
|
@ -24,7 +24,6 @@
|
|||
#include <string.h>
|
||||
#include <termio.h>
|
||||
|
||||
// CONSTANT TCGETS 0x5401
|
||||
#define TCGETS 0x5401
|
||||
|
||||
struct ktermios
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2019,2022,2023 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -22,13 +22,16 @@
|
|||
#include <syscall.h>
|
||||
#include <time.h>
|
||||
|
||||
char *__tv;
|
||||
|
||||
long
|
||||
time (long* result)
|
||||
{
|
||||
int r;
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
r = _sys_call2 (SYS_gettimeofday, tv, tz);
|
||||
if (__tv == 0)
|
||||
__tv = malloc (sizeof (struct timeval));
|
||||
struct timeval *tv = __tv;
|
||||
r = _sys_call2 (SYS_gettimeofday, tv, 0);
|
||||
if (r != 0)
|
||||
return -1;
|
||||
if (result != 0)
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||
### This file is part of M2-Planet.
|
||||
###
|
||||
### M2-Planet 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.
|
||||
###
|
||||
### M2-Planet 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 M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
### stage0's hex2 format
|
||||
### !<label> 1 byte relative
|
||||
### $<label> 2 byte address
|
||||
### @<label> 2 byte relative
|
||||
### &<label> 4 byte address
|
||||
### %<label> 4 byte relative
|
||||
|
||||
### if you wish to use this header, you need to add :ELF_end to the end of your
|
||||
### M1 or hex2 files.
|
||||
|
||||
## ELF Header
|
||||
|
||||
:ELF_base
|
||||
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||
|
||||
02 # e_ident[EI_CLASS] Indicating 64 bit
|
||||
01 # e_ident[EI_DATA] Indicating little endianness
|
||||
01 # e_ident[EI_VERSION] Indicating original elf
|
||||
|
||||
03 # e_ident[EI_OSABI] Set at 3 because FreeBSD is strict
|
||||
00 # e_ident[EI_ABIVERSION] See above
|
||||
|
||||
00 00 00 00 00 00 00 # e_ident[EI_PAD]
|
||||
|
||||
02 00 # e_type Indicating Executable
|
||||
3E 00 # e_machine Indicating AMD64
|
||||
01 00 00 00 # e_version Indicating original elf
|
||||
|
||||
&_start 00 00 00 00 # e_entry Address of the entry point
|
||||
%ELF_program_headers>ELF_base 00 00 00 00 # e_phoff Address of program header table
|
||||
00 00 00 00 00 00 00 00 # e_shoff Address of section header table
|
||||
|
||||
00 00 00 00 # e_flags
|
||||
|
||||
40 00 # e_ehsize Indicating our 64 Byte header
|
||||
|
||||
38 00 # e_phentsize size of a program header table
|
||||
01 00 # e_phnum number of entries in program table
|
||||
|
||||
00 00 # e_shentsize size of a section header table
|
||||
00 00 # e_shnum number of entries in section table
|
||||
|
||||
00 00 # e_shstrndx index of the section names
|
||||
|
||||
|
||||
:ELF_program_headers
|
||||
:ELF_program_header__text
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
00 00 00 00 00 00 00 00 # ph_offset
|
||||
&ELF_base 00 00 00 00 # ph_vaddr
|
||||
&ELF_base 00 00 00 00 # ph_physaddr
|
||||
%ELF_end>ELF_base 00 00 00 00 # ph_filesz
|
||||
%ELF_end>ELF_base 00 00 00 00 # ph_memsz
|
||||
01 00 00 00 00 00 00 00 # ph_align
|
||||
|
||||
:ELF_text
|
|
@ -0,0 +1,101 @@
|
|||
## Copyright (C) 2017 Jeremiah Orians
|
||||
## This file is part of M2-Planet.
|
||||
##
|
||||
## M2-Planet 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.
|
||||
##
|
||||
## M2-Planet 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 M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
DEFINE ADD_IMMEDIATE_to_rax 4805
|
||||
DEFINE ADD_IMMEDIATE_to_rbp 4881C5
|
||||
DEFINE ADD_rax_to_rbx 4801C3
|
||||
DEFINE ADD_rbp_to_rax 4801E8
|
||||
DEFINE ADD_rbx_to_rax 4801D8
|
||||
DEFINE AND_rax_rbx 4821D8
|
||||
DEFINE CALL_IMMEDIATE E8
|
||||
DEFINE CALL_rax FFD0
|
||||
DEFINE CMP 4839C3
|
||||
DEFINE COPY_rax_to_rcx 4889C1
|
||||
DEFINE COPY_rax_to_rdi 4889C7
|
||||
DEFINE COPY_rbx_to_rax 4889D8
|
||||
DEFINE COPY_rbp_to_rax 4889E8
|
||||
DEFINE COPY_rbx_to_rdi 4889DF
|
||||
DEFINE COPY_rdi_to_rbp 4889FD
|
||||
DEFINE COPY_rsp_to_rbp 4889E5
|
||||
DEFINE COPY_RSP_to_RDI 4889E7
|
||||
DEFINE CQTO 4899
|
||||
DEFINE DIVIDE_rax_by_rbx_into_rax 48F7F3
|
||||
DEFINE DIVIDES_rax_by_rbx_into_rax 48F7FB
|
||||
DEFINE JUMP E9
|
||||
DEFINE JUMP_EQ 0F84
|
||||
DEFINE JUMP_NE 0F85
|
||||
DEFINE LOAD_BASE_ADDRESS_rax 488D85
|
||||
DEFINE LOAD_BYTE 480FBE00
|
||||
DEFINE LOAD_BYTE_rbx 480FBE1B
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_rax 488D8424
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_rdi 488DBC24
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_rdx 488D9424
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_rsi 488DB424
|
||||
DEFINE LOAD_IMMEDIATE_r10 48C7C2
|
||||
DEFINE LOAD_IMMEDIATE_rax 48C7C0
|
||||
DEFINE LOAD_IMMEDIATE_rbx 48C7C3
|
||||
DEFINE LOAD_IMMEDIATE_rdi 48C7C7
|
||||
DEFINE LOAD_IMMEDIATE_rdx 48C7C2
|
||||
DEFINE LOAD_IMMEDIATE_rsi 48C7C6
|
||||
DEFINE LOAD_INTEGER 488B00
|
||||
DEFINE LOAD_INTEGER_rbx 488B1B
|
||||
DEFINE LOAD_INTEGER_rdi 488B3F
|
||||
DEFINE LOAD_INTEGER_rdx 488B12
|
||||
DEFINE LOAD_INTEGER_rsi 488B36
|
||||
DEFINE LOAD_RSP_IMMEDIATE_into_rax 488B8424
|
||||
DEFINE MODULUS_rax_from_rbx_into_rbx 48F7F3
|
||||
DEFINE MODULUSS_rax_from_rbx_into_rbx 48F7FB
|
||||
DEFINE MOVE_rbx_to_rax 4889D8
|
||||
DEFINE MOVE_rdx_to_rax 4889D0
|
||||
DEFINE MOVEZX 480FB6C0
|
||||
DEFINE MOVESX 4863C0
|
||||
DEFINE MULTIPLY_rax_by_rbx_into_rax 48F7EB
|
||||
DEFINE MULTIPLYS_rax_by_rbx_into_rax 48F7E3
|
||||
DEFINE NULL 0000000000000000
|
||||
DEFINE NOT_rax 48F7D0
|
||||
DEFINE OR_rax_rbx 4809D8
|
||||
DEFINE POP_RAX 58
|
||||
DEFINE POP_RBP 5D
|
||||
DEFINE POP_RBX 5B
|
||||
DEFINE POP_RDI 5F
|
||||
DEFINE PUSH_RAX 50
|
||||
DEFINE PUSH_RBP 55
|
||||
DEFINE PUSH_RBX 53
|
||||
DEFINE PUSH_RDI 57
|
||||
DEFINE RETURN C3
|
||||
DEFINE SAL_rax_Immediate8 48C1E0
|
||||
DEFINE SHL_rax_cl 48D3E0
|
||||
DEFINE SAL_rax_cl 48D3F0
|
||||
DEFINE SHR_rax_cl 48D3E8
|
||||
DEFINE SAR_rax_cl 48D3F8
|
||||
DEFINE SETA 0F97C0
|
||||
DEFINE SETAE 0F93C0
|
||||
DEFINE SETB 0F92C0
|
||||
DEFINE SETBE 0F96C0
|
||||
DEFINE SETE 0F94C0
|
||||
DEFINE SETG 0F9FC0
|
||||
DEFINE SETGE 0F9DC0
|
||||
DEFINE SETL 0F9CC0
|
||||
DEFINE SETLE 0F9EC0
|
||||
DEFINE SETNE 0F95C0
|
||||
DEFINE STORE_CHAR 8803
|
||||
DEFINE STORE_INTEGER 488903
|
||||
DEFINE SUBTRACT_rax_from_rbx_into_rbx 4829C3
|
||||
DEFINE SYSCALL 0F05
|
||||
DEFINE TEST 4885C0
|
||||
DEFINE XCHG_rax_rbx 4893
|
||||
DEFINE XOR_rbx_rax_into_rax 4831D8
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -23,7 +23,19 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if __M2_PLANET__ || !(__MESC__ && __arm__)
|
||||
#if __MESC__ && __arm__
|
||||
#define __MESC__and__arm__
|
||||
#endif
|
||||
|
||||
#if __TINYC__ && __arm__ && BOOTSTRAP
|
||||
#define __TINYC__and__arm__and__BOOTSTRAP
|
||||
#endif
|
||||
|
||||
#define __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP !defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP)
|
||||
|
||||
// FIXME: M2-Planet 1.10.0 crashes on this...
|
||||
// #if __M2__ || (!defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP))
|
||||
#if __M2__ || __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP
|
||||
size_t
|
||||
__mesabi_uldiv (size_t a, size_t b, size_t *remainder)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -23,8 +23,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <mes/lib.h>
|
||||
|
||||
char *__getcwd_buf;
|
||||
|
||||
char *
|
||||
getcwd (char *buffer, size_t size)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -22,9 +22,6 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// CONSTANT M2_PTR_SIZE 4
|
||||
#define M2_PTR_SIZE 1
|
||||
|
||||
char *
|
||||
getenv (char const *s)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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.
|
||||
*
|
||||
|
@ -29,6 +29,13 @@ _open2 (char const *file_name, int flags)
|
|||
return _open3 (file_name, flags, mask);
|
||||
}
|
||||
|
||||
#if __M2__
|
||||
int
|
||||
open (char const *file_name, int flags, int mask)
|
||||
{
|
||||
return _open3 (file_name, flags, mask);
|
||||
}
|
||||
#else // !__M2__
|
||||
int
|
||||
open (char const *file_name, int flags, ...)
|
||||
{
|
||||
|
@ -44,3 +51,4 @@ open (char const *file_name, int flags, ...)
|
|||
else
|
||||
return _open2 (file_name, flags);
|
||||
}
|
||||
#endif // !__M2__
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -22,9 +22,6 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// CONSTANT M2_PTR_SIZE 4
|
||||
#define M2_PTR_SIZE 1
|
||||
|
||||
int
|
||||
setenv (char const *s, char const *v, int overwrite_p)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -20,12 +20,16 @@
|
|||
|
||||
#include <mes/lib.h>
|
||||
|
||||
#if !__M2__
|
||||
void (*__call_at_exit) (void);
|
||||
#endif
|
||||
|
||||
void
|
||||
exit (int code)
|
||||
{
|
||||
#if !__M2__
|
||||
if (__call_at_exit)
|
||||
(*__call_at_exit) ();
|
||||
#endif
|
||||
_exit (code);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -19,11 +19,15 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
|
||||
void _exit (int code);
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
exit (int code)
|
||||
__buffered_read_init (int filedes)
|
||||
{
|
||||
}
|
||||
|
||||
size_t
|
||||
__buffered_read_clear (int filedes)
|
||||
{
|
||||
_exit (code);
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -18,8 +18,6 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// CONSTANT SIGABRT 0
|
||||
|
||||
int
|
||||
__raise (int signum)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -29,7 +29,12 @@ int
|
|||
main (int argc, char const *argv[])
|
||||
{
|
||||
eputs ("test:getenv\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 = ".";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -18,39 +18,62 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if SYSTEM_LIBC
|
||||
#error "SYSTEM_LIBC not supported"
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
main ()
|
||||
{
|
||||
int size = 5000;
|
||||
puts ("m!\n");
|
||||
//int *p = 0;
|
||||
char *p = 0;
|
||||
p = malloc (size);
|
||||
size = 5000;
|
||||
puts ("p=");
|
||||
puts (itoa (p));
|
||||
puts ("\n");
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
puts ("set ");
|
||||
puts (itoa (i));
|
||||
puts ("\n");
|
||||
p[i] = i;
|
||||
}
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
puts (itoa (i));
|
||||
puts (": ");
|
||||
puts (itoa (p[i]));
|
||||
puts ("\n");
|
||||
}
|
||||
int i;
|
||||
|
||||
oputs ("\n");
|
||||
|
||||
oputs ("t: 1 % 2\n");
|
||||
i = 1 % 2;
|
||||
if (i != 1)
|
||||
return 1;
|
||||
|
||||
oputs ("t: 2 % 4\n");
|
||||
i = 2 % 4;
|
||||
if (i != 2)
|
||||
return 2;
|
||||
|
||||
oputs ("t: 3 % 4\n");
|
||||
i = 3 % 4;
|
||||
if (i != 3)
|
||||
return 3;
|
||||
|
||||
oputs ("t: 1 % 256\n");
|
||||
i = 1 % 256;
|
||||
if (i != 1)
|
||||
return 4;
|
||||
|
||||
unsigned u;
|
||||
|
||||
oputs ("\n");
|
||||
|
||||
oputs ("t: 1U % 2\n");
|
||||
u = 1 % 2;
|
||||
if (u != 1)
|
||||
return 5;
|
||||
|
||||
oputs ("t: 2U % 4\n");
|
||||
u = 2 % 4;
|
||||
if (u != 2)
|
||||
return 6;
|
||||
|
||||
oputs ("t: 3U % 4\n");
|
||||
u = 3 % 4;
|
||||
if (u != 3)
|
||||
return 7;
|
||||
|
||||
oputs ("t: 1U % 256\n");
|
||||
u = 1 % 256;
|
||||
if (u != 1)
|
||||
return 8;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -48,7 +48,12 @@ struct anon
|
|||
int
|
||||
main ()
|
||||
{
|
||||
struct foo f = { 0, 1, 2 };
|
||||
#if __GNUC__ > 11
|
||||
struct foo f = { 0, 1, 2, 0, 0 };
|
||||
#else
|
||||
// FIXME: gcc-12.2.0 segfaults on this
|
||||
struct foo f = { 0, 1, 2, 0 };
|
||||
#endif
|
||||
f.s.baz = 2;
|
||||
oputs ("f.s.bar=");
|
||||
oputs (itoa (f.s.bar));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -214,7 +214,12 @@ main (int argc, char *argv[])
|
|||
//i = (*fun2)(argc, argv);
|
||||
|
||||
i = 1;
|
||||
#if __GNUC__ > 11
|
||||
int lst[6] = { -1, 1 - 1, i, 2, 3, 0 };
|
||||
#else
|
||||
// FIXME: gcc-12.2.0 segfaults on this
|
||||
int lst[6] = { -1, 1 - 1, i, 2, 3 };
|
||||
#endif
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
eputs ("i: ");
|
||||
|
|
|
@ -27,6 +27,7 @@ DEFINE add____$i32,%rdi 4881c7
|
|||
DEFINE add____$i32,(%rax) 8100
|
||||
DEFINE add____$i32,0x32(%rbp) 8185
|
||||
DEFINE add____$i8,%rax 4883c0
|
||||
DEFINE add____$i8,%rbp 4883c5
|
||||
DEFINE add____$i8,%rdi 4883c7
|
||||
DEFINE add____$i8,%rsp 4883c4
|
||||
DEFINE add____$i8,(%rax) 8300
|
||||
|
@ -114,6 +115,7 @@ DEFINE mov____%rbp,%rsp 4889ec
|
|||
DEFINE mov____%rbp,0x8(%rbp) 48896d
|
||||
DEFINE mov____%rdi,%r8 4989f8
|
||||
DEFINE mov____%rdi,%rax 4889f8
|
||||
DEFINE mov____%rdi,%rbp 4889fd
|
||||
DEFINE mov____%rdi,%rcx 4889f9
|
||||
DEFINE mov____%rdi,%rdi 4889ff
|
||||
DEFINE mov____%rdi,0x32 48893c25
|
||||
|
|
|
@ -369,10 +369,13 @@
|
|||
`(,(string-append "push___%" r0))
|
||||
(armv4:call-label #f "__mesabi_idiv" 2))
|
||||
;; __mesabi_uldiv(a, b, remainderp)
|
||||
(cons* `(,(string-append "push___0"))
|
||||
`(,(string-append "push___%" r1))
|
||||
`(,(string-append "push___%" r0))
|
||||
(armv4:call-label #f "__mesabi_uldiv" 3)))))
|
||||
(append `(("push___%r3") ; slot for remainder
|
||||
("mov____%esp,%r3")
|
||||
("push___%r3") ; pointer to remainder
|
||||
(,(string-append "push___%" r1))
|
||||
(,(string-append "push___%" r0)))
|
||||
(armv4:call-label #f "__mesabi_uldiv" 3)
|
||||
`(("pop____%r3"))))))
|
||||
|
||||
(define (armv4:r0%r1 info signed?)
|
||||
(let ((r0 (get-r0 info))
|
||||
|
@ -383,9 +386,9 @@
|
|||
`(,(string-append "push___%" r0))
|
||||
(armv4:call-label #f "__mesabi_imod" 2))
|
||||
;; __mesabi_uldiv(a, b, remainderp)
|
||||
(append `(("push___%r0") ; slot for remainder
|
||||
("mov____%esp,%r0")
|
||||
("push___%r0") ; pointer to remainder
|
||||
(append `(("push___%r3") ; slot for remainder
|
||||
("mov____%esp,%r3")
|
||||
("push___%r3") ; pointer to remainder
|
||||
(,(string-append "push___%" r1))
|
||||
(,(string-append "push___%" r0)))
|
||||
(armv4:call-label #f "__mesabi_uldiv" 3)
|
||||
|
|
|
@ -24,15 +24,14 @@ mes_cpu=${mes_cpu:-x86}
|
|||
stage0_cpu=${stage0_cpu:-x86}
|
||||
|
||||
M2-Planet \
|
||||
--bootstrap-mode \
|
||||
--debug \
|
||||
--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/_exit.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||
-f lib/string/strlen.c \
|
||||
-f lib/mes/mini-write.c \
|
||||
-f lib/mes/write.c \
|
||||
-f lib/mes/eputs.c \
|
||||
-f lib/string/strcmp.c \
|
||||
-f scaffold/argv.c \
|
||||
|
|
|
@ -30,7 +30,7 @@ M2-Planet \
|
|||
-f lib/mes/globals.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.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/strcpy.c \
|
||||
-f lib/mes/eputs.c \
|
||||
|
|
|
@ -24,15 +24,14 @@ mes_cpu=${mes_cpu:-x86}
|
|||
stage0_cpu=${stage0_cpu:-x86}
|
||||
|
||||
M2-Planet \
|
||||
--bootstrap-mode \
|
||||
--debug \
|
||||
--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/_exit.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_write.c \
|
||||
-f lib/string/strlen.c \
|
||||
-f lib/mes/mini-write.c \
|
||||
-f lib/mes/write.c \
|
||||
-f lib/mes/eputs.c \
|
||||
-f scaffold/hello.c \
|
||||
-o scaffold/hello.M1
|
||||
|
|
|
@ -30,7 +30,7 @@ M2-Planet \
|
|||
-f lib/mes/globals.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.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/strcpy.c \
|
||||
-f lib/mes/eputs.c \
|
||||
|
|
|
@ -30,7 +30,7 @@ M2-Planet \
|
|||
-f lib/mes/globals.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.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/strcpy.c \
|
||||
-f lib/mes/eputs.c \
|
||||
|
|
|
@ -24,7 +24,6 @@ mes_cpu=${mes_cpu:-x86}
|
|||
stage0_cpu=${stage0_cpu:-x86}
|
||||
|
||||
M2-Planet \
|
||||
--bootstrap-mode \
|
||||
--debug \
|
||||
--architecture ${stage0_cpu} \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/crt1.c \
|
||||
|
|
|
@ -24,28 +24,29 @@ mes_cpu=${mes_cpu:-x86}
|
|||
stage0_cpu=${stage0_cpu:-x86}
|
||||
|
||||
M2-Planet \
|
||||
--bootstrap-mode \
|
||||
--debug \
|
||||
--architecture ${stage0_cpu} \
|
||||
-f include/m2/lib.h \
|
||||
-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/syscall.c \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/_exit.c \
|
||||
-f include/linux/${mes_cpu}/syscall.h \
|
||||
-f lib/linux/${mes_cpu}-mes-m2/syscall.c \
|
||||
-f lib/m2/cast.c \
|
||||
-f include/mes/lib.h \
|
||||
-f lib/string/strlen.c \
|
||||
-f lib/mes/mini-write.c \
|
||||
-f lib/mes/write.c \
|
||||
-f lib/mes/eputs.c \
|
||||
-f lib/linux/brk.c \
|
||||
-f lib/m2/malloc.c \
|
||||
-f lib/linux/malloc.c \
|
||||
-f lib/string/memset.c \
|
||||
-f lib/m2/read.c \
|
||||
-f lib/linux/read.c \
|
||||
-f lib/mes/fdgetc.c \
|
||||
-f lib/stdio/getchar.c \
|
||||
-f lib/stdio/putchar.c \
|
||||
-f lib/m2/open.c \
|
||||
-f lib/m2/mes_open.c \
|
||||
-f lib/linux/open.c \
|
||||
-f include/sys/types.h \
|
||||
-f include/stdio.h \
|
||||
-f scaffold/read.c \
|
||||
-o scaffold/read.M1
|
||||
|
||||
|
|
60
simple.make
60
simple.make
|
@ -1,6 +1,6 @@
|
|||
# GNU Mes --- Maxwell Equations of Software
|
||||
# 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.
|
||||
#
|
||||
|
@ -76,20 +76,26 @@ M2_SOURCES = \
|
|||
lib/linux/x86-mes-m2/crt1.c \
|
||||
lib/linux/x86-mes-m2/_exit.c \
|
||||
lib/linux/x86-mes-m2/_write.c \
|
||||
lib/mes/globals.c \
|
||||
lib/m2/cast.c \
|
||||
lib/m2/exit.c \
|
||||
lib/mes/write.c \
|
||||
lib/stdlib/exit.c \
|
||||
lib/stub/__buffered_read.c \
|
||||
lib/linux/x86-mes-m2/syscall.c \
|
||||
lib/stub/__raise.c \
|
||||
lib/linux/brk.c \
|
||||
lib/stdlib/malloc.c \
|
||||
lib/linux/malloc.c \
|
||||
lib/string/memset.c \
|
||||
\
|
||||
lib/m2/read.c \
|
||||
lib/linux/read.c \
|
||||
lib/mes/fdgetc.c \
|
||||
lib/linux/lseek.c \
|
||||
lib/posix/write.c \
|
||||
\
|
||||
lib/stdio/getchar.c \
|
||||
lib/stdio/putchar.c \
|
||||
lib/m2/open.c \
|
||||
lib/m2/mes_open.c \
|
||||
lib/stub/__buffered_read.c \
|
||||
lib/linux/_open3.c \
|
||||
lib/linux/open.c \
|
||||
lib/mes/mes_open.c \
|
||||
lib/string/strlen.c \
|
||||
lib/mes/eputs.c \
|
||||
lib/mes/fdputc.c \
|
||||
|
@ -118,15 +124,16 @@ M2_SOURCES = \
|
|||
lib/mes/fdungetc.c \
|
||||
lib/posix/setenv.c \
|
||||
lib/linux/access.c \
|
||||
lib/m2/chmod.c \
|
||||
lib/linux/chmod.c \
|
||||
lib/linux/ioctl3.c \
|
||||
lib/m2/isatty.c \
|
||||
lib/linux/fork.c \
|
||||
lib/m2/execve.c \
|
||||
lib/m2/execv.c \
|
||||
lib/m2/waitpid.c \
|
||||
lib/linux/wait4.c \
|
||||
lib/linux/waitpid.c \
|
||||
lib/linux/gettimeofday.c \
|
||||
lib/m2/clock_gettime.c \
|
||||
lib/linux/clock_gettime.c \
|
||||
lib/m2/time.c \
|
||||
lib/linux/_getcwd.c \
|
||||
lib/m2/getcwd.c \
|
||||
|
@ -137,12 +144,6 @@ M2_SOURCES = \
|
|||
lib/linux/unlink.c \
|
||||
src/m2.c
|
||||
|
||||
M2_TODO = \
|
||||
lib/m2/file_print.c \
|
||||
lib/mes/ntoab.c \
|
||||
lib/mes/fdgetc.c \
|
||||
lib/mes/fdungetc.c
|
||||
|
||||
INCLUDES = \
|
||||
include/mes/builtins.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 $@
|
||||
|
||||
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/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/builtins.h \
|
||||
include/mes/constants.h \
|
||||
|
@ -216,12 +228,12 @@ m2/mes-m2.hex2: m2/mes-m2.blood-elf.M1
|
|||
-o $@
|
||||
|
||||
bin/mes-m2: m2/mes-m2.hex2
|
||||
hex2 \
|
||||
--architecture $(M2_PLANET_ARCH) \
|
||||
--little-endian \
|
||||
--base-address 0x1000000 \
|
||||
-f lib/x86-mes/elf32-header.hex2 \
|
||||
-f m2/mes-m2.hex2 \
|
||||
hex2 \
|
||||
--architecture $(M2_PLANET_ARCH) \
|
||||
--little-endian \
|
||||
--base-address 0x1000000 \
|
||||
-f lib/linux/x86-mes/elf32-header.hex2 \
|
||||
-f m2/mes-m2.hex2 \
|
||||
-o $@
|
||||
cp -f $@ bin/mes
|
||||
|
||||
|
|
315
simple.sh
315
simple.sh
|
@ -36,47 +36,48 @@ cat > include/mes/config.h <<EOF
|
|||
EOF
|
||||
|
||||
## Build ##
|
||||
gcc -g -D HAVE_CONFIG_H=1 -I include\
|
||||
-o out-system-libc/mes\
|
||||
\
|
||||
lib/mes/eputs.c\
|
||||
lib/mes/oputs.c\
|
||||
\
|
||||
lib/mes/cast.c\
|
||||
lib/mes/itoa.c\
|
||||
lib/mes/ltoa.c\
|
||||
lib/mes/ltoab.c\
|
||||
lib/mes/ultoa.c\
|
||||
lib/mes/utoa.c\
|
||||
lib/mes/eputc.c\
|
||||
lib/mes/fdgetc.c\
|
||||
lib/mes/fdputc.c\
|
||||
lib/mes/fdputs.c\
|
||||
lib/mes/fdungetc.c\
|
||||
lib/mes/mes_open.c\
|
||||
lib/mes/ntoab.c\
|
||||
lib/mes/oputc.c\
|
||||
\
|
||||
lib/mes/__assert_fail.c\
|
||||
lib/mes/assert_msg.c\
|
||||
\
|
||||
src/builtins.c\
|
||||
src/cc.c\
|
||||
src/core.c\
|
||||
src/display.c\
|
||||
src/eval-apply.c\
|
||||
src/gc.c\
|
||||
src/hash.c\
|
||||
src/lib.c\
|
||||
src/math.c\
|
||||
src/mes.c\
|
||||
src/module.c\
|
||||
src/posix.c\
|
||||
src/reader.c\
|
||||
src/stack.c\
|
||||
src/string.c\
|
||||
src/struct.c\
|
||||
src/symbol.c\
|
||||
gcc -g -D HAVE_CONFIG_H=1 -I include \
|
||||
-o out-system-libc/mes \
|
||||
\
|
||||
lib/mes/eputs.c \
|
||||
lib/mes/oputs.c \
|
||||
\
|
||||
lib/mes/cast.c \
|
||||
lib/mes/itoa.c \
|
||||
lib/mes/ltoa.c \
|
||||
lib/mes/ltoab.c \
|
||||
lib/mes/ultoa.c \
|
||||
lib/mes/utoa.c \
|
||||
lib/mes/eputc.c \
|
||||
lib/mes/fdgetc.c \
|
||||
lib/mes/fdputc.c \
|
||||
lib/mes/fdputs.c \
|
||||
lib/mes/fdungetc.c \
|
||||
lib/mes/mes_open.c \
|
||||
lib/mes/ntoab.c \
|
||||
lib/mes/oputc.c \
|
||||
\
|
||||
lib/mes/__assert_fail.c \
|
||||
lib/mes/assert_msg.c \
|
||||
\
|
||||
src/builtins.c \
|
||||
src/cc.c \
|
||||
src/core.c \
|
||||
src/display.c \
|
||||
src/eval-apply.c \
|
||||
src/gc.c \
|
||||
src/globals.c \
|
||||
src/hash.c \
|
||||
src/lib.c \
|
||||
src/math.c \
|
||||
src/mes.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
|
||||
|
||||
## 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/mes/globals.c\
|
||||
# lib/mes/mini-write.c\
|
||||
# lib/mes/write.c\
|
||||
# lib/string/strlen.c\
|
||||
# \
|
||||
# scaffold/hello.c
|
||||
|
@ -120,7 +121,7 @@ cat \
|
|||
lib/linux/$mes_cpu-mes-mescc/_write.c \
|
||||
\
|
||||
lib/mes/globals.c \
|
||||
lib/mes/mini-write.c \
|
||||
lib/mes/write.c \
|
||||
lib/string/strlen.c \
|
||||
\
|
||||
scaffold/hello.c \
|
||||
|
@ -164,115 +165,121 @@ EOF
|
|||
|
||||
## Build ##
|
||||
compiler=gcc # not configurable
|
||||
$CC -g -D HAVE_CONFIG_H=1 -I include -I include/$mes_kernel/$mes_cpu\
|
||||
-nostdinc -nostdlib -fno-builtin -fno-stack-protector\
|
||||
-o out-mes/mes\
|
||||
\
|
||||
lib/linux/$mes_cpu-mes-gcc/crt1.c\
|
||||
\
|
||||
lib/mes/globals.c\
|
||||
lib/mes/eputs.c\
|
||||
lib/mes/oputs.c\
|
||||
\
|
||||
lib/posix/write.c\
|
||||
lib/string/strlen.c\
|
||||
lib/stdlib/puts.c\
|
||||
lib/stdlib/exit.c\
|
||||
lib/$mes_kernel/$mes_cpu-mes-$compiler/_exit.c\
|
||||
lib/$mes_kernel/$mes_cpu-mes-$compiler/_write.c\
|
||||
\
|
||||
lib/mes/cast.c\
|
||||
lib/mes/itoa.c\
|
||||
lib/mes/ltoa.c\
|
||||
lib/mes/ltoab.c\
|
||||
lib/mes/ultoa.c\
|
||||
lib/mes/utoa.c\
|
||||
lib/mes/eputc.c\
|
||||
lib/mes/fdgetc.c\
|
||||
lib/mes/fdputc.c\
|
||||
lib/mes/fdputs.c\
|
||||
lib/mes/fdungetc.c\
|
||||
lib/mes/mes_open.c\
|
||||
lib/mes/ntoab.c\
|
||||
lib/mes/oputc.c\
|
||||
\
|
||||
lib/stdlib/atoi.c\
|
||||
lib/mes/abtol.c\
|
||||
lib/ctype/isdigit.c\
|
||||
lib/ctype/isnumber.c\
|
||||
lib/ctype/isspace.c\
|
||||
lib/ctype/isxdigit.c\
|
||||
\
|
||||
lib/mes/__assert_fail.c\
|
||||
lib/mes/assert_msg.c\
|
||||
lib/mes/__buffered_read.c\
|
||||
lib/mes/__mes_debug.c\
|
||||
lib/posix/execv.c\
|
||||
lib/posix/getcwd.c\
|
||||
lib/posix/getenv.c\
|
||||
lib/posix/isatty.c\
|
||||
lib/posix/open.c\
|
||||
lib/posix/setenv.c\
|
||||
lib/posix/wait.c\
|
||||
lib/stdio/fgetc.c\
|
||||
lib/stdio/fputc.c\
|
||||
lib/stdio/fputs.c\
|
||||
lib/stdio/getc.c\
|
||||
lib/stdio/getchar.c\
|
||||
lib/stdio/putc.c\
|
||||
lib/stdio/putchar.c\
|
||||
lib/stdio/ungetc.c\
|
||||
lib/stdlib/free.c\
|
||||
lib/stdlib/malloc.c\
|
||||
lib/stdlib/realloc.c\
|
||||
lib/string/memchr.c\
|
||||
lib/string/memcmp.c\
|
||||
lib/string/memcpy.c\
|
||||
lib/string/memmove.c\
|
||||
lib/string/memset.c\
|
||||
lib/string/strcmp.c\
|
||||
lib/string/strcpy.c\
|
||||
lib/string/strncmp.c\
|
||||
\
|
||||
lib/linux/lseek.c\
|
||||
\
|
||||
lib/linux/access.c\
|
||||
lib/linux/brk.c\
|
||||
lib/linux/chmod.c\
|
||||
lib/linux/clock_gettime.c\
|
||||
lib/linux/dup.c\
|
||||
lib/linux/dup2.c\
|
||||
lib/linux/execve.c\
|
||||
lib/linux/fork.c\
|
||||
lib/linux/fsync.c\
|
||||
lib/linux/_getcwd.c\
|
||||
lib/linux/gettimeofday.c\
|
||||
lib/linux/ioctl3.c\
|
||||
lib/linux/_open3.c\
|
||||
lib/linux/read.c\
|
||||
lib/linux/_read.c\
|
||||
lib/linux/time.c\
|
||||
lib/linux/unlink.c\
|
||||
lib/linux/waitpid.c\
|
||||
lib/linux/$mes_cpu-mes-$compiler/syscall.c\
|
||||
\
|
||||
src/builtins.c\
|
||||
src/cc.c\
|
||||
src/core.c\
|
||||
src/display.c\
|
||||
src/eval-apply.c\
|
||||
src/gc.c\
|
||||
src/hash.c\
|
||||
src/lib.c\
|
||||
src/math.c\
|
||||
src/mes.c\
|
||||
src/module.c\
|
||||
src/posix.c\
|
||||
src/reader.c\
|
||||
src/stack.c\
|
||||
src/string.c\
|
||||
src/struct.c\
|
||||
src/symbol.c\
|
||||
$CC -g -D HAVE_CONFIG_H=1 \
|
||||
-I include -I include/$mes_kernel/$mes_cpu \
|
||||
-nostdinc -nostdlib \
|
||||
-fno-builtin -fno-stack-protector \
|
||||
-o out-mes/mes \
|
||||
\
|
||||
lib/linux/$mes_cpu-mes-gcc/crt1.c \
|
||||
\
|
||||
lib/mes/globals.c \
|
||||
lib/mes/eputs.c \
|
||||
lib/mes/oputs.c \
|
||||
\
|
||||
lib/posix/write.c \
|
||||
lib/string/strlen.c \
|
||||
lib/stdlib/puts.c \
|
||||
lib/stdlib/exit.c \
|
||||
lib/$mes_kernel/$mes_cpu-mes-$compiler/_exit.c \
|
||||
lib/$mes_kernel/$mes_cpu-mes-$compiler/_write.c \
|
||||
\
|
||||
lib/mes/cast.c \
|
||||
lib/mes/itoa.c \
|
||||
lib/mes/ltoa.c \
|
||||
lib/mes/ltoab.c \
|
||||
lib/mes/ultoa.c \
|
||||
lib/mes/utoa.c \
|
||||
lib/mes/eputc.c \
|
||||
lib/mes/fdgetc.c \
|
||||
lib/mes/fdputc.c \
|
||||
lib/mes/fdputs.c \
|
||||
lib/mes/fdungetc.c \
|
||||
lib/mes/mes_open.c \
|
||||
lib/mes/ntoab.c \
|
||||
lib/mes/oputc.c \
|
||||
\
|
||||
lib/stdlib/atoi.c \
|
||||
lib/mes/abtol.c \
|
||||
lib/ctype/isdigit.c \
|
||||
lib/ctype/isnumber.c \
|
||||
lib/ctype/isspace.c \
|
||||
lib/ctype/isxdigit.c \
|
||||
\
|
||||
lib/stub/__raise.c \
|
||||
lib/mes/__assert_fail.c \
|
||||
lib/mes/assert_msg.c \
|
||||
lib/mes/__buffered_read.c \
|
||||
lib/mes/__mes_debug.c \
|
||||
lib/posix/execv.c \
|
||||
lib/posix/getcwd.c \
|
||||
lib/posix/getenv.c \
|
||||
lib/posix/isatty.c \
|
||||
lib/posix/open.c \
|
||||
lib/posix/setenv.c \
|
||||
lib/posix/wait.c \
|
||||
lib/stdio/fgetc.c \
|
||||
lib/stdio/fputc.c \
|
||||
lib/stdio/fputs.c \
|
||||
lib/stdio/getc.c \
|
||||
lib/stdio/getchar.c \
|
||||
lib/stdio/putc.c \
|
||||
lib/stdio/putchar.c \
|
||||
lib/stdio/ungetc.c \
|
||||
lib/stdlib/free.c \
|
||||
lib/linux/malloc.c \
|
||||
lib/stdlib/realloc.c \
|
||||
lib/string/memchr.c \
|
||||
lib/string/memcmp.c \
|
||||
lib/string/memcpy.c \
|
||||
lib/string/memmove.c \
|
||||
lib/string/memset.c \
|
||||
lib/string/strcmp.c \
|
||||
lib/string/strcpy.c \
|
||||
lib/string/strncmp.c \
|
||||
\
|
||||
lib/linux/lseek.c \
|
||||
\
|
||||
lib/linux/access.c \
|
||||
lib/linux/brk.c \
|
||||
lib/linux/chmod.c \
|
||||
lib/linux/clock_gettime.c \
|
||||
lib/linux/dup.c \
|
||||
lib/linux/dup2.c \
|
||||
lib/linux/execve.c \
|
||||
lib/linux/fork.c \
|
||||
lib/linux/fsync.c \
|
||||
lib/linux/_getcwd.c \
|
||||
lib/linux/gettimeofday.c \
|
||||
lib/linux/ioctl3.c \
|
||||
lib/linux/_open3.c \
|
||||
lib/linux/read.c \
|
||||
lib/linux/_read.c \
|
||||
lib/linux/time.c \
|
||||
lib/linux/unlink.c \
|
||||
include/sys/resource.h \
|
||||
lib/linux/wait4.c \
|
||||
lib/linux/waitpid.c \
|
||||
lib/linux/$mes_cpu-mes-$compiler/syscall.c \
|
||||
\
|
||||
src/builtins.c \
|
||||
src/cc.c \
|
||||
src/core.c \
|
||||
src/display.c \
|
||||
src/eval-apply.c \
|
||||
src/gc.c \
|
||||
src/globals.c \
|
||||
src/hash.c \
|
||||
src/lib.c \
|
||||
src/math.c \
|
||||
src/mes.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
|
||||
|
||||
## 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/mes/globals.c\
|
||||
# lib/mes/mini-write.c\
|
||||
# lib/mes/write.c\
|
||||
# lib/string/strlen.c\
|
||||
# \
|
||||
# scaffold/hello.c
|
||||
|
@ -316,7 +323,7 @@ cat \
|
|||
lib/linux/$mes_cpu-mes-mescc/_write.c \
|
||||
\
|
||||
lib/mes/globals.c \
|
||||
lib/mes/mini-write.c \
|
||||
lib/mes/write.c \
|
||||
lib/string/strlen.c \
|
||||
\
|
||||
scaffold/hello.c \
|
||||
|
|
|
@ -148,7 +148,7 @@ length (struct scm *x)
|
|||
struct scm *
|
||||
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);
|
||||
if (throw != cell_undefined)
|
||||
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:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -30,9 +31,6 @@
|
|||
|
||||
int g_dump_filedes;
|
||||
|
||||
#define M2_CELL_SIZE 1U
|
||||
// CONSTANT M2_CELL_SIZE 12
|
||||
|
||||
char *
|
||||
cell_bytes (struct scm *x)
|
||||
{
|
||||
|
@ -40,16 +38,20 @@ cell_bytes (struct scm *x)
|
|||
return p + (2 * sizeof (long));
|
||||
}
|
||||
|
||||
#if __M2__
|
||||
#define U10 10
|
||||
#define U100 100
|
||||
#else
|
||||
#define U10 10U
|
||||
// CONSTANT U10 10
|
||||
#define U100 100U
|
||||
// CONSTANT U100 100
|
||||
#endif
|
||||
|
||||
void
|
||||
gc_init ()
|
||||
{
|
||||
#if SYSTEM_LIBC
|
||||
ARENA_SIZE = 100000000; /* 2.3GiB */
|
||||
#elif ! __M2_PLANET__
|
||||
#elif ! __M2__
|
||||
ARENA_SIZE = 300000; /* 32b: 3MiB, 64b: 6 MiB */
|
||||
#else
|
||||
ARENA_SIZE = 20000000;
|
||||
|
@ -326,11 +328,11 @@ void
|
|||
gc_up_arena ()
|
||||
{
|
||||
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;
|
||||
JAM_SIZE = JAM_SIZE << 1;
|
||||
GC_SAFETY = GC_SAFETY << 1;
|
||||
ARENA_SIZE = ARENA_SIZE * 2;
|
||||
JAM_SIZE = JAM_SIZE * 2;
|
||||
GC_SAFETY = GC_SAFETY * 2;
|
||||
}
|
||||
else
|
||||
ARENA_SIZE = MAX_ARENA_SIZE - JAM_SIZE;
|
||||
|
@ -448,7 +450,7 @@ void
|
|||
gc_flip ()
|
||||
{
|
||||
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. */
|
||||
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>
|
||||
|
||||
#if SYSTEM_LIBC
|
||||
#define __raise(x) -1
|
||||
//#define __raise(x) -1
|
||||
#endif
|
||||
|
||||
struct scm *
|
||||
|
@ -377,13 +377,14 @@ waitpid_ (struct scm *pid, struct scm *options)
|
|||
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. */
|
||||
// CONSTANT TIME_UNITS_PER_SECOND 1000000000
|
||||
#define TIME_UNITS_PER_SECOND 1000000000U
|
||||
#else
|
||||
/* Milliseconds for everyone else. */
|
||||
// CONSTANT TIME_UNITS_PER_SECOND 1000
|
||||
#define TIME_UNITS_PER_SECOND 1000U
|
||||
#endif
|
||||
|
||||
|
@ -408,8 +409,12 @@ gettimeofday_ () /*:((name . "gettimeofday")) */
|
|||
return cons (make_number (time->tv_sec), make_number (time->tv_usec));
|
||||
}
|
||||
|
||||
#if __M2__
|
||||
#define UL1000000000 1000000000
|
||||
#else
|
||||
#define UL1000000000 1000000000UL
|
||||
// CONSTANT UL1000000000 1000000000
|
||||
#endif
|
||||
|
||||
long
|
||||
seconds_and_nanoseconds_to_long (long s, long ns)
|
||||
{
|
||||
|
|
12
src/symbol.c
12
src/symbol.c
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -23,16 +23,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
// char const *MES_VERSION = "0.23";
|
||||
|
||||
#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 *
|
||||
init_symbol (struct scm *x, long type, char const *name)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -24,9 +24,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define M2_CELL_SIZE 1
|
||||
// CONSTANT M2_CELL_SIZE 12
|
||||
|
||||
int g_debug;
|
||||
|
||||
void
|
||||
|
|
10
src/vector.c
10
src/vector.c
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* 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.
|
||||
*
|
||||
|
@ -21,14 +21,6 @@
|
|||
#include "mes/lib.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 *
|
||||
make_vector_ (long k, struct scm *e)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue