Compare commits
269 Commits
master
...
wip-module
Author | SHA1 | Date |
---|---|---|
Jan (janneke) Nieuwenhuizen | aaa26001f3 | |
Jan (janneke) Nieuwenhuizen | 3ad33b85e0 | |
Jan (janneke) Nieuwenhuizen | 7c1ef45e1b | |
Jan (janneke) Nieuwenhuizen | 2032b3bd02 | |
Jan (janneke) Nieuwenhuizen | 5effea9a61 | |
Jan (janneke) Nieuwenhuizen | 80b51c18e7 | |
Jan Nieuwenhuizen | 31cd2723ae | |
Jan Nieuwenhuizen | b5e1d6b403 | |
Jan Nieuwenhuizen | 7a6b4cd91c | |
Jan Nieuwenhuizen | 3c93215c18 | |
Jan Nieuwenhuizen | c1a172b222 | |
Jan Nieuwenhuizen | 112a12e0b9 | |
Jan Nieuwenhuizen | a0f580c522 | |
Jan Nieuwenhuizen | 33e3867b7f | |
Jan Nieuwenhuizen | 1a922d3e5b | |
Jan Nieuwenhuizen | 3060bee531 | |
Jan Nieuwenhuizen | 65f400a4c9 | |
Jan Nieuwenhuizen | 58392ab4a9 | |
Jan Nieuwenhuizen | 353171c5c7 | |
Jan Nieuwenhuizen | 633bd3a1b6 | |
Jan Nieuwenhuizen | bb1aff9991 | |
Jan Nieuwenhuizen | accae96fa6 | |
Jan Nieuwenhuizen | 2377552677 | |
Jan Nieuwenhuizen | 2f1c84688f | |
Jan Nieuwenhuizen | 5256a336c9 | |
Jan Nieuwenhuizen | 26f73a46f8 | |
Jan Nieuwenhuizen | 03502d7844 | |
Jan Nieuwenhuizen | a285782399 | |
Jan Nieuwenhuizen | a66a5392a6 | |
Jan Nieuwenhuizen | 063f3cd6e3 | |
Jan Nieuwenhuizen | 2deb3d6a35 | |
Jan Nieuwenhuizen | 63e0996aaa | |
Jan Nieuwenhuizen | 5ee49f2887 | |
Jan Nieuwenhuizen | 256d7397b3 | |
Jan Nieuwenhuizen | f61490b930 | |
Jan Nieuwenhuizen | 3cdd216714 | |
Jan Nieuwenhuizen | 91b35f6ceb | |
Jan Nieuwenhuizen | 3b9281194f | |
Jan Nieuwenhuizen | 0a1a53be8b | |
Jan Nieuwenhuizen | 5ed16be84d | |
Jan Nieuwenhuizen | ebce9ddc3d | |
Jan Nieuwenhuizen | e7c6bad7ee | |
Jan Nieuwenhuizen | ebccc7cc39 | |
Jan Nieuwenhuizen | 7d4432a350 | |
Jan Nieuwenhuizen | c94ccbd345 | |
Jan Nieuwenhuizen | 6c079a8fb0 | |
Jan Nieuwenhuizen | c98651ab4e | |
Jan Nieuwenhuizen | ca2db881e2 | |
Jan Nieuwenhuizen | 23af952ad0 | |
Jan Nieuwenhuizen | cbc0c80568 | |
Jan Nieuwenhuizen | 778be3d15d | |
Jan Nieuwenhuizen | 81972a9b2e | |
Jan Nieuwenhuizen | beb982b3a0 | |
Jan Nieuwenhuizen | 530746caaa | |
Jan Nieuwenhuizen | 4af868525f | |
Jan Nieuwenhuizen | fb816fb7ed | |
Jan Nieuwenhuizen | 925eb14f87 | |
Jan Nieuwenhuizen | bb514fa55a | |
Jan Nieuwenhuizen | 3fd4ac1efa | |
Jan Nieuwenhuizen | f60adb3e20 | |
Jan Nieuwenhuizen | 524d6fd5ed | |
Jan Nieuwenhuizen | 0f4b0ae04f | |
Jan Nieuwenhuizen | e56a7fadf7 | |
Jan Nieuwenhuizen | fb4bc4fd0d | |
Jan Nieuwenhuizen | ef90589b1f | |
Jan Nieuwenhuizen | 1031d1e5a9 | |
Jan Nieuwenhuizen | bab229adef | |
Jan Nieuwenhuizen | 536ed43b12 | |
Jan Nieuwenhuizen | 52733ced9a | |
Jan Nieuwenhuizen | 166c93c458 | |
Jan Nieuwenhuizen | 197416e285 | |
Jan Nieuwenhuizen | 91dba33bf3 | |
Jan Nieuwenhuizen | 649b662308 | |
Jan Nieuwenhuizen | 2663098e24 | |
Jan Nieuwenhuizen | cff843a18f | |
Jan Nieuwenhuizen | 8d13441dfb | |
Jan Nieuwenhuizen | 28eebd5d2c | |
Jan Nieuwenhuizen | b2098b3a76 | |
Jan Nieuwenhuizen | f200bfe054 | |
Jan Nieuwenhuizen | 9532829d89 | |
Jan Nieuwenhuizen | cfceb07027 | |
Jan Nieuwenhuizen | 997acf5ce2 | |
Jan Nieuwenhuizen | 70e3c62637 | |
Jan Nieuwenhuizen | 25e159d622 | |
Jan Nieuwenhuizen | 630dd9a3d9 | |
Jan Nieuwenhuizen | 9f876a9fcc | |
Jan Nieuwenhuizen | 522135342d | |
Jan Nieuwenhuizen | 60d65653b2 | |
Jan Nieuwenhuizen | 02da290b21 | |
Jan Nieuwenhuizen | fddbe47e08 | |
Jan Nieuwenhuizen | 6c03bfe5a3 | |
Jan Nieuwenhuizen | b798746104 | |
Jan Nieuwenhuizen | 4dfbb1f867 | |
Jan Nieuwenhuizen | 8e6c41f4e4 | |
Jan Nieuwenhuizen | 6f4d948cc4 | |
Jan Nieuwenhuizen | bae6557dab | |
Jan Nieuwenhuizen | b6ed1bc9ed | |
Jan Nieuwenhuizen | 888fe1ac6c | |
Jan Nieuwenhuizen | e350187cd3 | |
Jan Nieuwenhuizen | c6d55bffeb | |
Jan Nieuwenhuizen | dd7573529d | |
Jan Nieuwenhuizen | 9ea3f4ec61 | |
Jan Nieuwenhuizen | 2ea505a931 | |
Jan Nieuwenhuizen | f1430fc845 | |
Jan Nieuwenhuizen | a950e6b948 | |
Jan Nieuwenhuizen | 5678640e04 | |
Jan Nieuwenhuizen | 84bd81f155 | |
Jan Nieuwenhuizen | 9f66f648b7 | |
Jan Nieuwenhuizen | b6bc836f5a | |
Jan Nieuwenhuizen | 6d30f93dfd | |
Jan Nieuwenhuizen | 266d3b890c | |
Jan Nieuwenhuizen | 859325eedd | |
Jan Nieuwenhuizen | edd07bfecf | |
Jan Nieuwenhuizen | b4bab89d0a | |
Jan Nieuwenhuizen | 7c8e423eae | |
Jan Nieuwenhuizen | 3660297ef8 | |
Jan Nieuwenhuizen | 2202ab2599 | |
Jan Nieuwenhuizen | 3c3bb89c94 | |
Jan Nieuwenhuizen | 4355559473 | |
Jan Nieuwenhuizen | 05d5d6d1ee | |
Jan Nieuwenhuizen | 05618820da | |
Jan Nieuwenhuizen | dda4ebcd21 | |
Jan Nieuwenhuizen | 81579b6066 | |
Jan Nieuwenhuizen | 065b90c82e | |
Jan Nieuwenhuizen | 6950fc0e04 | |
Jan Nieuwenhuizen | bad6ebeeaf | |
Jan Nieuwenhuizen | 0115c9acbe | |
Jan Nieuwenhuizen | a31d9207e5 | |
Jan Nieuwenhuizen | 85322abc07 | |
Jan Nieuwenhuizen | 847d1ef665 | |
Jan Nieuwenhuizen | c13d50f867 | |
Jan Nieuwenhuizen | ed49f0d376 | |
Jan Nieuwenhuizen | 71f57d9f36 | |
Jan Nieuwenhuizen | ec4abcb3cf | |
Jan Nieuwenhuizen | 60c70cf262 | |
Jan Nieuwenhuizen | ccfdbc0a91 | |
Jan Nieuwenhuizen | d9e338e2a5 | |
Jan Nieuwenhuizen | 348e2c678a | |
Jan Nieuwenhuizen | 6c897f5e63 | |
Jan Nieuwenhuizen | 3427368d31 | |
Jan Nieuwenhuizen | 54c18f998a | |
Jan Nieuwenhuizen | b9630faf05 | |
Jan Nieuwenhuizen | 56ee7781a5 | |
Jan Nieuwenhuizen | 69cff15c1b | |
Jan Nieuwenhuizen | 04126ad14a | |
Jan Nieuwenhuizen | f3efd4e689 | |
Jan Nieuwenhuizen | 60fb2e2d46 | |
Jan Nieuwenhuizen | d2f1f75703 | |
Jan Nieuwenhuizen | 813a92855f | |
Jan Nieuwenhuizen | ca5140c714 | |
Jan Nieuwenhuizen | 058dfc74ea | |
Jan Nieuwenhuizen | 1ac06460a6 | |
Jan Nieuwenhuizen | ec490ef2fd | |
Jan Nieuwenhuizen | eb48442b50 | |
Jan Nieuwenhuizen | 5a2f0c19b9 | |
Jan Nieuwenhuizen | f0cb62063a | |
Jan Nieuwenhuizen | df019a63d4 | |
Jan Nieuwenhuizen | cc3aa2b306 | |
Jan Nieuwenhuizen | 0e4830a035 | |
Jan Nieuwenhuizen | 158761a486 | |
Jan Nieuwenhuizen | 89e3418a57 | |
Jan Nieuwenhuizen | a85fdebe4f | |
Jan Nieuwenhuizen | 2b0c2b821c | |
Jan Nieuwenhuizen | eb87158f8c | |
Jan Nieuwenhuizen | 6afd8e7a3c | |
Jan Nieuwenhuizen | 2b7d8ba6fa | |
Jan Nieuwenhuizen | 18d91a9c59 | |
Jan Nieuwenhuizen | b79374e7ae | |
Jan Nieuwenhuizen | b2f571c800 | |
Jan Nieuwenhuizen | 417a6b9df7 | |
Jan Nieuwenhuizen | 2675807d12 | |
Jan Nieuwenhuizen | 0d08d198a3 | |
Jan Nieuwenhuizen | 56ecae96d0 | |
Jan Nieuwenhuizen | f59f2d9ec3 | |
Jan Nieuwenhuizen | 2cbb3e1860 | |
Jan Nieuwenhuizen | 381bb3f62a | |
Jan Nieuwenhuizen | 8db2b44d8e | |
Jan Nieuwenhuizen | c01ea57e69 | |
Jan Nieuwenhuizen | 52b06bff98 | |
Jan Nieuwenhuizen | 8eca568745 | |
Jan Nieuwenhuizen | 1d1387f069 | |
Jan Nieuwenhuizen | 9f956d9206 | |
Jan Nieuwenhuizen | 7c0cb60709 | |
Jan Nieuwenhuizen | f4cbbf620c | |
Jan Nieuwenhuizen | d9fccb532a | |
Jan Nieuwenhuizen | 5f5066aaea | |
Jan Nieuwenhuizen | fe4a19c10f | |
Jan Nieuwenhuizen | 693921e059 | |
Jan Nieuwenhuizen | 50156e6c07 | |
Jan Nieuwenhuizen | 43197fff3c | |
Jan Nieuwenhuizen | d454fe905d | |
Jan Nieuwenhuizen | 75895950fb | |
Jan Nieuwenhuizen | ed29b83575 | |
Jan Nieuwenhuizen | cdc4256758 | |
Jan Nieuwenhuizen | 790d2ebb91 | |
Jan Nieuwenhuizen | 3209febc2e | |
Jan Nieuwenhuizen | 3f5f12201e | |
Jan Nieuwenhuizen | b08281d75e | |
Jan Nieuwenhuizen | ce11c855ff | |
Jan Nieuwenhuizen | 8ba3abe0c4 | |
Jan Nieuwenhuizen | c536ffb3bf | |
Jan Nieuwenhuizen | a5ba54c31f | |
Jan Nieuwenhuizen | 6f3c78314d | |
Jan Nieuwenhuizen | da85d20500 | |
Jan Nieuwenhuizen | c3a7033886 | |
Jan Nieuwenhuizen | 2b8bb1abd2 | |
Jan Nieuwenhuizen | 2d82d58e82 | |
Jan Nieuwenhuizen | 6f5d815e7d | |
Jan Nieuwenhuizen | e315162c57 | |
Jan Nieuwenhuizen | 330e9ba037 | |
Jan Nieuwenhuizen | a70e82e1d6 | |
Jan Nieuwenhuizen | de1725aebd | |
Jan Nieuwenhuizen | 42c3c28509 | |
Jan Nieuwenhuizen | c8fe8f3de5 | |
Jan Nieuwenhuizen | eb2136b4b2 | |
Jan Nieuwenhuizen | 930519b142 | |
Jan Nieuwenhuizen | 7225bef283 | |
Jan Nieuwenhuizen | e51b2339c5 | |
Jan Nieuwenhuizen | 1aa12c225b | |
Jan Nieuwenhuizen | aea32924b7 | |
Jan Nieuwenhuizen | 2471c1f362 | |
Jan Nieuwenhuizen | cf10d97045 | |
Jan Nieuwenhuizen | c5f9c3d4b6 | |
Jan Nieuwenhuizen | 3c71aee7dc | |
Jan Nieuwenhuizen | 504616b68a | |
Jan Nieuwenhuizen | 06a2527cc9 | |
Danny Milosavljevic | 6a31571d5a | |
Jan Nieuwenhuizen | e0926c6e12 | |
Jan Nieuwenhuizen | 4884ba4ad0 | |
Jan Nieuwenhuizen | b03be4a465 | |
Jan Nieuwenhuizen | 265d1c6a64 | |
Jan Nieuwenhuizen | 530dea3405 | |
Jan Nieuwenhuizen | 25082ea4bc | |
Jan Nieuwenhuizen | 5ece64edd4 | |
Danny Milosavljevic | 35e84ff8aa | |
Danny Milosavljevic | 58f9e644f4 | |
Danny Milosavljevic | 4455f45496 | |
Danny Milosavljevic | 0ea76f2f61 | |
Danny Milosavljevic | 809aa3f03a | |
Jan Nieuwenhuizen | 4d55c843dc | |
Jan Nieuwenhuizen | 0857d59c24 | |
Jan Nieuwenhuizen | c7ff4cf2e2 | |
Jan Nieuwenhuizen | 11ef8a5f85 | |
Jan Nieuwenhuizen | 082ca6a786 | |
Jan Nieuwenhuizen | ce5b77062f | |
Jan Nieuwenhuizen | cea8ff7b13 | |
Jan Nieuwenhuizen | 9c734094ba | |
Jan Nieuwenhuizen | 6e59b834ef | |
Jan Nieuwenhuizen | a65d759903 | |
Jan Nieuwenhuizen | d30aa7cb04 | |
Jan Nieuwenhuizen | f7bad50ac8 | |
Jan Nieuwenhuizen | bea67d7683 | |
Jan Nieuwenhuizen | d5a542215a | |
Jan Nieuwenhuizen | c63067c0c9 | |
Jan Nieuwenhuizen | 37e82074f0 | |
Jan Nieuwenhuizen | efd813d404 | |
Jan Nieuwenhuizen | e040e55f8e | |
Jan Nieuwenhuizen | bcb8a071ee | |
Jan Nieuwenhuizen | d12afa089e | |
Jan Nieuwenhuizen | 8f223bf978 | |
Jan Nieuwenhuizen | b14eebb6d1 | |
Jan Nieuwenhuizen | 165b6f24b5 | |
Jan Nieuwenhuizen | 51e8791ab4 | |
Jan Nieuwenhuizen | 6f50a38ac5 | |
Jan Nieuwenhuizen | 94e06a52ed | |
Jan Nieuwenhuizen | 20999775b5 | |
Jan Nieuwenhuizen | caf44f85b2 | |
Jan Nieuwenhuizen | 8e25ec2e5d | |
Jan Nieuwenhuizen | 2d7c2f9791 |
|
@ -33,32 +33,15 @@
|
|||
*.mini-hex2
|
||||
*.a
|
||||
*.o
|
||||
*.h.m2
|
||||
*.c.m2
|
||||
*.seed-out
|
||||
*.stderr
|
||||
*.stdout
|
||||
|
||||
*.x86-out
|
||||
|
||||
*.x86-mes-E
|
||||
*.x86-mes-S
|
||||
*.x86-mes-gcc-a
|
||||
*.x86-mes-gcc-o
|
||||
*.x86-mes-gcc-out
|
||||
*.x86-mes-gcc-stdout
|
||||
*.x86-mes-o
|
||||
*.x86-mes-out
|
||||
*.x86-mes-stdout
|
||||
|
||||
*.x86_64-mes-E
|
||||
*.x86_64-mes-S
|
||||
*.x86_64-mes-gcc-a
|
||||
*.x86_64-mes-gcc-o
|
||||
*.x86_64-mes-gcc-out
|
||||
*.x86_64-mes-gcc-stdout
|
||||
*.x86_64-mes-o
|
||||
*.x86_64-mes-out
|
||||
*.x86_64-mes-stdout
|
||||
*.x86_64-out
|
||||
/TAGS
|
||||
|
||||
/lib/x86-mes/0exit-42
|
||||
/lib/x86-mes/exit-42
|
||||
|
@ -69,58 +52,28 @@
|
|||
!/lib/tests/*/*.exit
|
||||
!/lib/tests/*/*.stdout
|
||||
|
||||
/scaffold/*.M1
|
||||
/scaffold/*.m2
|
||||
/scaffold/*.hex2
|
||||
/scaffold/argv
|
||||
/scaffold/hello
|
||||
/scaffold/main
|
||||
/scaffold/micro-mes
|
||||
/scaffold/read
|
||||
/scaffold/tiny-mes
|
||||
|
||||
/scaffold/x86-mes-*
|
||||
/scaffold/x86_64-mes-*
|
||||
|
||||
/scaffold/tests/x86-mes-*
|
||||
/scaffold/tests/[0-9a][0-9a-z]-*
|
||||
/scaffold/tests/t.*
|
||||
!/scaffold/tests/*.c
|
||||
!/scaffold/tests/*.exit
|
||||
!/scaffold/tests/*.stdout
|
||||
|
||||
/src/mes.mes.symbols.h
|
||||
/src/gc.mes.h
|
||||
/src/hash.mes.h
|
||||
/src/lib.mes.h
|
||||
/src/math.mes.h
|
||||
/src/mes.mes.h
|
||||
/src/module.mes.h
|
||||
/src/posix.mes.h
|
||||
/src/reader.mes.h
|
||||
/src/strings.mes.h
|
||||
/src/struct.mes.h
|
||||
/src/vector.mes.h
|
||||
/src/gc.mes.i
|
||||
/src/hash.mes.i
|
||||
/src/lib.mes.i
|
||||
/src/math.mes.i
|
||||
/src/mes.mes.i
|
||||
/src/module.mes.i
|
||||
/src/posix.mes.i
|
||||
/src/reader.mes.i
|
||||
/src/strings.mes.i
|
||||
/src/struct.mes.i
|
||||
/src/vector.mes.i
|
||||
|
||||
/src/mes
|
||||
/src/x86-mes-mes
|
||||
/src/x86_64-mes-mes
|
||||
/scaffold/argv-m2
|
||||
/scaffold/hello-m2
|
||||
/scaffold/main-m2
|
||||
/scaffold/micro-mes-m2
|
||||
/scaffold/read-m2
|
||||
/scaffold/tiny-mes-m2
|
||||
|
||||
/.config
|
||||
/.config.make
|
||||
/.store
|
||||
/.tarball-version
|
||||
|
||||
#keep this: bootstrap
|
||||
#/mes.mes
|
||||
|
||||
/out
|
||||
?
|
||||
?.mes
|
||||
\#*#
|
||||
|
@ -147,6 +100,7 @@
|
|||
/install.sh
|
||||
/uninstall.sh
|
||||
/mes/module/mes/boot-0.scm
|
||||
/scripts/m2-merge.scm
|
||||
/scripts/mesar
|
||||
/scripts/mescc.scm
|
||||
/scripts/mescc
|
||||
|
|
17
README
17
README
|
@ -11,13 +11,12 @@ interested UNIX-like operating system.
|
|||
|
||||
Mes consists of a mutual self-hosting Scheme interpreter written in
|
||||
~5,000 LOC of simple C and a Nyacc-based C compiler written in Scheme.
|
||||
This mes.c is [[https://github.com/oriansj/mes-m2][being simplified]] to be transpiled by [[https://github.com/oriansj/m2-planet][M2-Planet]].
|
||||
Mes can now be bootstrapped by [[https://github.com/oriansj/m2-planet][M2-Planet]] and [[https://savannah.nongnu.org/projects/mescc-tools][Mescc-Tools]].
|
||||
|
||||
The Scheme interpreter (mes.c) has a Garbage Collector, a library of
|
||||
loadable Scheme modules-- notably Dominique Boucher's [[https://github.com/schemeway/lalr-scm][LALR]], Pre-R6RS
|
||||
[[https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html][portable syntax-case]] with R7RS ellipsis, Matt Wette's [[https://www.nongnu.org/nyacc][Nyacc]] --and test
|
||||
suite just barely enough to support a simple REPL and simple
|
||||
C-compiler: MesCC.
|
||||
The Scheme interpreter has a Garbage Collector, a library of loadable
|
||||
Scheme modules-- notably Dominique Boucher's [[https://github.com/schemeway/lalr-scm][LALR]], Pre-R6RS [[https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html][portable
|
||||
syntax-case]] with R7RS ellipsis, Matt Wette's [[https://www.nongnu.org/nyacc][Nyacc]] --and test suite just
|
||||
enough to support a REPL and a C99 compiler: MesCC.
|
||||
|
||||
Mes+MesCC can compile an only [[http://gitlab.com/janneke/tinycc][lightly patched TinyCC]] that is
|
||||
self-hosting. Using this tcc and the Mes C library we now have a
|
||||
|
@ -66,14 +65,14 @@ General Public Licence version 3 or later. See the file [[file:COPYING][COPYING
|
|||
[0] https://www.gnu.org/software/mes
|
||||
[1] https://www.gnu.org/software/guix
|
||||
[2] http://bootstrappable.org
|
||||
[3] https://github.com/oriansj/mes-m2
|
||||
[4] https://github.com/oriansj/m2-planet
|
||||
[3] https://github.com/oriansj/m2-planet
|
||||
[4] https://savannah.nongnu.org/projects/mescc-tools
|
||||
[5] https://github.com/schemeway/lalr-scm
|
||||
[6] https://www.cs.indiana.edu/chezscheme/syntax-case/old-psyntax.html
|
||||
[7] https://www.nongnu.org/nyacc
|
||||
[8] http://gitlab.com/janneke/tinycc
|
||||
[9] [[http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf]]
|
||||
[10] https://github.com/oriansj/stage0
|
||||
[10] https://savannah.nongnu.org/projects/stage0
|
||||
|
||||
* Legalese
|
||||
Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]>
|
||||
|
|
|
@ -120,7 +120,7 @@ maintainer-clean:
|
|||
git clean -dfx
|
||||
|
||||
TAGS:
|
||||
etags ${srcdest}lib/*.c ${srcdest}lib/*/*.c ${srcdest}src/*.c ${srcdest}include/*.h ${srcdest}include/sys/*.h
|
||||
etags ${srcdest}lib/*.c ${srcdest}lib/*/*.c ${srcdest}src/*.c ${srcdest}include/*.h ${srcdest}include/*/*.h ${srcdest}include/sys/*.h
|
||||
|
||||
all-go:
|
||||
${srcdest}build-aux/build-guile.sh
|
||||
|
@ -242,6 +242,10 @@ COMMIT=$(shell test -e ${srcdest}.git && (cd ${srcdir} && git describe --dirty 2
|
|||
TARBALL_VERSION=$(COMMIT:v%=%)
|
||||
TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION)
|
||||
TARBALL:=$(TARBALL_DIR).tar.gz
|
||||
# Be friendly to Debian; avoid using EPOCH
|
||||
MTIME=$(shell git show HEAD --format=%ct --no-patch 2>/dev/null)
|
||||
# Reproducible tarball
|
||||
TAR_FLAGS=--sort=name --mtime=@$(MTIME) --owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s
|
||||
|
||||
.tarball-version:
|
||||
echo $(COMMIT) > $@
|
||||
|
@ -251,6 +255,7 @@ GIT_LS_FILES:=git ls-files
|
|||
ifeq ($(wildcard .git),)
|
||||
GIT_ARCHIVE_HEAD:=tar -cf-
|
||||
GIT_LS_FILES:=find
|
||||
MTIME:=0
|
||||
endif
|
||||
|
||||
dist: $(TARBALL)
|
||||
|
@ -270,11 +275,12 @@ generate-ChangeLog:
|
|||
mv generate-ChangeLog ChangeLog
|
||||
|
||||
$(TARBALL): .tarball-version | generate-ChangeLog
|
||||
($(GIT_LS_FILES)\
|
||||
--exclude=$(TARBALL_DIR);\
|
||||
echo $^ | tr ' ' '\n')\
|
||||
| GZIP=-n tar --sort=name --mtime=@0 --owner=0 --group=0 --numeric-owner\
|
||||
--transform=s,^,$(TARBALL_DIR)/,S -T- -czf $@
|
||||
($(GIT_LS_FILES) \
|
||||
--exclude=$(TARBALL_DIR); \
|
||||
echo $^ | tr ' ' '\n') \
|
||||
| tar $(TAR_FLAGS) \
|
||||
--transform=s,^,$(TARBALL_DIR)/,S -T- -cf- \
|
||||
| gzip -c --no-name > $@
|
||||
git checkout ChangeLog
|
||||
|
||||
ifdef GUIX
|
||||
|
|
|
@ -19,9 +19,18 @@
|
|||
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
LANG=
|
||||
MES_ARENA=${MES_ARENA-100000000}
|
||||
MES_MAX_ARENA=${MES_MAX_ARENA-100000000}
|
||||
MES_STACK=${MES_STACK-500000}
|
||||
MES_ARENA=${MES_ARENA-20000000}
|
||||
export MES_ARENA
|
||||
MES_MAX_ARENA=${MES_MAX_ARENA-${MES_ARENA}}
|
||||
export MES_MAX_ARENA
|
||||
MES_STACK=${MES_STACK-5000000}
|
||||
export MES_STACK
|
||||
MES_PREFIX=${MES_PREFIX-$PWD}
|
||||
|
||||
if test -n "@M2_PLANET@"; then
|
||||
echo " KAEM kaem.run"
|
||||
kaem --strict --verbose
|
||||
fi
|
||||
|
||||
. build-aux/configure-lib.sh
|
||||
|
||||
|
@ -33,39 +42,39 @@ cd mescc-lib
|
|||
srcdest=../
|
||||
CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_kernel/$mes_cpu"
|
||||
|
||||
mkdir $mes_cpu-mes
|
||||
mkdir -p $mes_cpu-mes
|
||||
$CC -c $CPPFLAGS $CFLAGS ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c
|
||||
cp crt1.o $mes_cpu-mes
|
||||
cp crt1.s $mes_cpu-mes
|
||||
|
||||
objects=
|
||||
for c in $libc_mini_SOURCES; do
|
||||
echo "CC $c"
|
||||
echo " CC $c"
|
||||
$CC -c $CPPFLAGS $CFLAGS ${srcdest}$c
|
||||
o=$(basename $c .c).o
|
||||
objects="$objects $o"
|
||||
done
|
||||
echo "AR $mes_cpu-mes/libc-mini.a"
|
||||
echo " AR $mes_cpu-mes/libc-mini.a"
|
||||
$AR crD $mes_cpu-mes/libc-mini.a $objects
|
||||
|
||||
objects=
|
||||
for c in $libc_SOURCES; do
|
||||
echo "CC $c"
|
||||
echo " CC $c"
|
||||
$CC -c $CPPFLAGS $CFLAGS ${srcdest}$c
|
||||
o=$(basename $c .c).o
|
||||
objects="$objects $o"
|
||||
done
|
||||
echo "AR $mes_cpu-mes/libc.a"
|
||||
echo " AR $mes_cpu-mes/libc.a"
|
||||
$AR crD $mes_cpu-mes/libc.a $objects
|
||||
|
||||
objects=
|
||||
for c in $libc_tcc_SOURCES; do
|
||||
echo "CC $c"
|
||||
echo " CC $c"
|
||||
$CC -c $CPPFLAGS $CFLAGS ${srcdest}$c
|
||||
o=$(basename $c .c).o
|
||||
objects="$objects $o"
|
||||
done
|
||||
echo "AR $mes_cpu-mes/libc+tcc.a"
|
||||
echo " AR $mes_cpu-mes/libc+tcc.a"
|
||||
$AR crD $mes_cpu-mes/libc+tcc.a $objects
|
||||
|
||||
cd ..
|
||||
|
@ -74,10 +83,23 @@ CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ${srcdest}include/$mes_kern
|
|||
|
||||
objects=
|
||||
for c in $mes_SOURCES; do
|
||||
echo "CC $c"
|
||||
echo " CC $c"
|
||||
$CC -c $CPPFLAGS $CFLAGS ${srcdest}$c
|
||||
o=$(basename $c .c).o
|
||||
objects="$objects $o"
|
||||
done
|
||||
echo "CCLD src/mes"
|
||||
$CC -nostdlib -o src/mes -L mescc-lib mescc-lib/crt1.o $objects -lc
|
||||
echo " CCLD bin/mes-mescc"
|
||||
$CC -nostdlib -o bin/mes-mescc -L mescc-lib mescc-lib/crt1.o $objects -lc
|
||||
cp bin/mes-mescc bin/mes
|
||||
|
||||
(
|
||||
mkdir -p gcc-lib
|
||||
cp config.sh gcc-lib
|
||||
cd gcc-lib
|
||||
compiler=gcc
|
||||
if test -z "$srcdest"; then
|
||||
srcdest=../
|
||||
srcdir=../
|
||||
fi
|
||||
@SHELL@ ${srcdest}build-aux/build-source-lib.sh
|
||||
)
|
||||
|
|
|
@ -79,26 +79,3 @@ cp libgetopt.a $mes_cpu-mes
|
|||
if test -e libgetopt.s; then
|
||||
cp libgetopt.s $mes_cpu-mes
|
||||
fi
|
||||
|
||||
cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt*.c $mes_cpu-mes
|
||||
|
||||
rm -f libc+gnu.c
|
||||
cat > libc+gnu.c <<EOF
|
||||
// Generated from Mes -- do not edit
|
||||
// compiler: $compiler
|
||||
// cpu: $mes_cpu
|
||||
// bits: $mes_bits
|
||||
// libc: $mes_libc
|
||||
// kernel: $mes_kernel
|
||||
// system: $mes_system
|
||||
|
||||
EOF
|
||||
for c in $libc_gnu_SOURCES; do
|
||||
echo "// $c" >> libc+gnu.c
|
||||
cat ${srcdest}$c >> libc+gnu.c
|
||||
echo >> libc+gnu.c
|
||||
done
|
||||
cp libc+gnu.c $mes_cpu-mes
|
||||
|
||||
cp ${srcdest}lib/libtcc1.c $mes_cpu-mes
|
||||
cp ${srcdest}lib/posix/getopt.c $mes_cpu-mes/libgetopt.c
|
||||
|
|
|
@ -30,28 +30,15 @@ fi
|
|||
. ./config.sh
|
||||
. ${srcdest}build-aux/trace.sh
|
||||
. ${srcdest}build-aux/cc.sh
|
||||
. ${srcdest}build-aux/configure-lib.sh
|
||||
|
||||
trap 'test -f .log && cat .log' EXIT
|
||||
|
||||
srcdest=${srcdest-}
|
||||
mes_sources="
|
||||
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/string.c
|
||||
src/struct.c
|
||||
src/vector.c
|
||||
"
|
||||
|
||||
for c in $mes_sources; do
|
||||
for c in $mes_SOURCES; do
|
||||
compile $c
|
||||
done
|
||||
if test $mes_libc = system; then
|
||||
LIBS=-lmes
|
||||
fi
|
||||
link src/mes
|
||||
link bin/mes-$compiler
|
||||
cp bin/mes-$compiler bin/mes
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
#! /bin/sh
|
||||
|
||||
# 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/>.
|
||||
|
||||
set -e
|
||||
|
||||
if test "$V" = 2; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
set -u
|
||||
srcdest=${srcdest-}
|
||||
. ${srcdest}build-aux/configure-lib.sh
|
||||
|
||||
mkdir -p $mes_cpu-mes
|
||||
cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt*.c $mes_cpu-mes
|
||||
|
||||
rm -f libc+gnu.c
|
||||
cat > libc+gnu.c <<EOF
|
||||
// Generated from Mes -- do not edit
|
||||
// compiler: $compiler
|
||||
// cpu: $mes_cpu
|
||||
// bits: $mes_bits
|
||||
// libc: $mes_libc
|
||||
// kernel: $mes_kernel
|
||||
// system: $mes_system
|
||||
|
||||
EOF
|
||||
for c in $libc_gnu_SOURCES; do
|
||||
echo "// $c" >> libc+gnu.c
|
||||
cat ${srcdest}$c >> libc+gnu.c
|
||||
echo >> libc+gnu.c
|
||||
done
|
||||
cp libc+gnu.c $mes_cpu-mes
|
||||
|
||||
cp ${srcdest}lib/libtcc1.c $mes_cpu-mes
|
||||
cp ${srcdest}lib/posix/getopt.c $mes_cpu-mes/libgetopt.c
|
|
@ -42,7 +42,9 @@ if $courageous; then
|
|||
set +e
|
||||
fi
|
||||
|
||||
${SHELL} ${srcdest}build-aux/build-scaffold.sh
|
||||
if test "$compiler" != bootstrap; then
|
||||
${SHELL} ${srcdest}build-aux/build-scaffold.sh
|
||||
fi
|
||||
|
||||
if test -n "$GUILE" -a "$GUILE" != true; then
|
||||
${SHELL} ${srcdest}build-aux/build-guile.sh
|
||||
|
@ -87,15 +89,15 @@ export CPPFLAGS
|
|||
export LDFLAGS
|
||||
export LIBS
|
||||
|
||||
if test $compiler = gcc; then
|
||||
(
|
||||
mkdir -p gcc-lib
|
||||
cp config.sh gcc-lib
|
||||
cd gcc-lib
|
||||
if test -z "$srcdest"; then
|
||||
srcdest=../
|
||||
srcdir=../
|
||||
fi
|
||||
(
|
||||
mkdir -p gcc-lib
|
||||
cp config.sh gcc-lib
|
||||
cd gcc-lib
|
||||
if test -z "$srcdest"; then
|
||||
srcdest=../
|
||||
srcdir=../
|
||||
fi
|
||||
if test $compiler = gcc; then
|
||||
CPPFLAGS="
|
||||
-D HAVE_CONFIG_H=1
|
||||
-I include
|
||||
|
@ -104,8 +106,10 @@ if test $compiler = gcc; then
|
|||
"
|
||||
${SHELL} ${srcdest}build-aux/build-lib.sh
|
||||
cp crt1.o ..
|
||||
)
|
||||
fi
|
||||
fi
|
||||
compiler=gcc ${SHELL} ${srcdest}build-aux/build-source-lib.sh
|
||||
)
|
||||
|
||||
|
||||
(
|
||||
if test $compiler = gcc; then
|
||||
|
@ -120,9 +124,27 @@ fi
|
|||
-I ${srcdest}include
|
||||
-I ${srcdest}include/$mes_kernel/$mes_cpu
|
||||
"
|
||||
${SHELL} ${srcdest}build-aux/build-mes.sh
|
||||
if test "$compiler" != bootstrap; then
|
||||
${SHELL} ${srcdest}build-aux/build-mes.sh
|
||||
fi
|
||||
)
|
||||
|
||||
if test -n "$M2_PLANET"; then
|
||||
(
|
||||
. ${srcdest}build-aux/trace.sh
|
||||
if [ -z "$V" -o "$V" = 0 ]; then
|
||||
__verbose=
|
||||
else
|
||||
__verbose=--verbose
|
||||
fi
|
||||
trace "KAEM scaffold/main.kaem" kaem --strict $__verbose -f scaffold/main.kaem
|
||||
trace "KAEM scaffold/hello.kaem" kaem --strict $__verbose -f scaffold/hello.kaem
|
||||
trace "KAEM scaffold/argv.kaem" kaem --strict $__verbose -f scaffold/argv.kaem
|
||||
trace "KAEM scaffold/read.kaem" kaem --strict $__verbose -f scaffold/read.kaem
|
||||
trace "KAEM kaem.run" kaem --strict $__verbose
|
||||
)
|
||||
fi
|
||||
|
||||
(
|
||||
mkdir -p mescc-lib
|
||||
cp config.sh mescc-lib
|
||||
|
@ -145,4 +167,5 @@ fi
|
|||
AR="${srcdest}pre-inst-env mesar"
|
||||
CC="${srcdest}pre-inst-env mescc -m $mes_bits"
|
||||
${SHELL} ${srcdest}build-aux/build-lib.sh
|
||||
${SHELL} ${srcdest}build-aux/build-source-lib.sh
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/bash
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -22,7 +22,7 @@ set -e
|
|||
. ./config.sh
|
||||
set -u
|
||||
|
||||
TESTS="
|
||||
boot_tests="
|
||||
|
||||
scaffold/boot/00-zero.scm
|
||||
scaffold/boot/01-true.scm
|
||||
|
@ -77,7 +77,6 @@ scaffold/boot/2g-vector.scm
|
|||
scaffold/boot/30-capture.scm
|
||||
scaffold/boot/31-capture-define.scm
|
||||
scaffold/boot/32-capture-modify-close.scm
|
||||
scaffold/boot/32-capture-modify-close.scm
|
||||
scaffold/boot/33-procedure-override-close.scm
|
||||
scaffold/boot/34-cdr-override-close.scm
|
||||
scaffold/boot/35-closure-modify.scm
|
||||
|
@ -111,11 +110,14 @@ scaffold/boot/50-primitive-load.scm
|
|||
scaffold/boot/53-closure-display.scm
|
||||
scaffold/boot/60-let-syntax.scm
|
||||
scaffold/boot/call-cc.scm
|
||||
scaffold/boot/gc.scm
|
||||
scaffold/boot/memory.scm
|
||||
scaffold/boot/numbers.scm
|
||||
"
|
||||
|
||||
XFAIL_TESTS=
|
||||
recheck=true
|
||||
TESTS=${TESTS-$boot_tests}
|
||||
XFAIL_TESTS=${XFAIL_TESTS-}
|
||||
|
||||
test_ext=.scm
|
||||
log_compiler="${SHELL} ${srcdest}build-aux/test-boot.sh"
|
||||
|
|
|
@ -27,6 +27,7 @@ tests/boot.test
|
|||
tests/read.test
|
||||
tests/srfi-0.test
|
||||
tests/macro.test
|
||||
tests/gc.test
|
||||
tests/perform.test
|
||||
tests/base.test
|
||||
tests/quasiquote.test
|
||||
|
@ -37,16 +38,17 @@ tests/display.test
|
|||
tests/cwv.test
|
||||
tests/math.test
|
||||
tests/vector.test
|
||||
tests/fluids.test
|
||||
tests/guile.test
|
||||
tests/module.test
|
||||
tests/srfi-1.test
|
||||
tests/srfi-9.test
|
||||
tests/srfi-13.test
|
||||
tests/srfi-14.test
|
||||
tests/srfi-43.test
|
||||
tests/optargs.test
|
||||
tests/fluids.test
|
||||
tests/catch.test
|
||||
tests/getopt-long.test
|
||||
tests/guile.test
|
||||
tests/syntax.test
|
||||
tests/let-syntax.test
|
||||
tests/pmatch.test
|
||||
|
|
|
@ -102,6 +102,7 @@ lib/tests/assert/50-assert.c
|
|||
lib/tests/mes/50-itoa.c
|
||||
lib/tests/posix/50-getenv.c
|
||||
lib/tests/stdlib/50-malloc.c
|
||||
lib/tests/string/50-memcmp.c
|
||||
lib/tests/string/50-strcmp.c
|
||||
lib/tests/string/50-strcpy.c
|
||||
lib/tests/string/50-strncmp.c
|
||||
|
@ -200,12 +201,16 @@ if test -z "$bootstrap"; then
|
|||
TESTS="$TESTS
|
||||
lib/tests/dirent/90-readdir.c
|
||||
lib/tests/io/90-stat.c
|
||||
lib/tests/mes/90-abtod.c
|
||||
lib/tests/mes/90-dtoab.c
|
||||
lib/tests/posix/90-execlp.c
|
||||
lib/tests/posix/90-unsetenv.c
|
||||
lib/tests/signal/90-signal.c
|
||||
lib/tests/stdio/90-fopen.c
|
||||
lib/tests/stdio/90-fopen-append.c
|
||||
lib/tests/stdio/90-fread-fwrite.c
|
||||
lib/tests/stdio/90-fseek.c
|
||||
lib/tests/stdio/90-sprintf.c
|
||||
lib/tests/stdlib/90-strtol.c
|
||||
lib/tests/string/90-snprintf.c
|
||||
lib/tests/string/90-strpbrk.c
|
||||
|
@ -222,7 +227,7 @@ lib/tests/scaffold/a1-global-no-clobber.c
|
|||
fi
|
||||
|
||||
XFAIL_TESTS="
|
||||
lib/tests/stdio/90-sprintf.c
|
||||
lib/tests/mes/90-abtod.c
|
||||
lib/tests/stdio/90-sprintf.c
|
||||
"
|
||||
|
||||
|
@ -232,6 +237,7 @@ lib/tests/scaffold/17-compare-unsigned-char-le.c
|
|||
lib/tests/scaffold/17-compare-unsigned-short-le.c
|
||||
lib/tests/scaffold/66-local-char-array.c
|
||||
lib/tests/scaffold/72-typedef-struct-def-local.c
|
||||
lib/tests/mes/90-dtoab.c
|
||||
lib/tests/scaffold/90-goto-var.c
|
||||
lib/tests/scaffold/91-goto-array.c
|
||||
"
|
||||
|
@ -248,11 +254,6 @@ lib/tests/scaffold/a0-call-trunc-int.c
|
|||
fi
|
||||
fi
|
||||
|
||||
if test $mes_cpu = x86; then
|
||||
XFAIL_TESTS="$XFAIL_TESTS
|
||||
"
|
||||
fi
|
||||
|
||||
if test $mes_cpu = x86_64; then
|
||||
XFAIL_TESTS="$XFAIL_TESTS
|
||||
lib/tests/stdio/70-printf-stdarg.c
|
||||
|
@ -261,10 +262,13 @@ fi
|
|||
|
||||
if test $compiler = gcc; then
|
||||
XFAIL_TESTS="$XFAIL_TESTS
|
||||
lib/tests/mes/90-abtod.c
|
||||
lib/tests/mes/90-dtoab.c
|
||||
"
|
||||
|
||||
if test $mes_cpu = x86; then
|
||||
XFAIL_TESTS="$XFAIL_TESTS
|
||||
lib/tests/mes/90-dtoab.c
|
||||
"
|
||||
fi
|
||||
|
||||
|
|
|
@ -20,6 +20,13 @@
|
|||
|
||||
set -e
|
||||
|
||||
MES_ARENA=${MES_ARENA-20000000}
|
||||
export MES_ARENA
|
||||
MES_MAX_ARENA=${MES_MAX_ARENA-${MES_ARENA}}
|
||||
export MES_MAX_ARENA
|
||||
MES_STACK=${MES_STACK-5000000}
|
||||
export MES_STACK
|
||||
|
||||
. ./config.sh
|
||||
|
||||
if $courageous; then
|
||||
|
|
|
@ -30,8 +30,10 @@ GUILE_EFFECTIVE_VERSION="@GUILE_EFFECTIVE_VERSION@"
|
|||
GUIX="@GUIX@"
|
||||
HELP2MAN="@HELP2MAN@"
|
||||
HEX2="@HEX2@"
|
||||
KAEM="@KAEM@"
|
||||
MAKEINFO="@MAKEINFO@"
|
||||
M1="@M1@"
|
||||
M2_PLANET="@M2_PLANET@"
|
||||
MES_FOR_BUILD="@MES_FOR_BUILD@"
|
||||
MES_SEED="@MES_SEED@"
|
||||
NYACC="@NYACC@"
|
||||
|
@ -52,7 +54,7 @@ arch="@arch@"
|
|||
build="@build@"
|
||||
host="@host@"
|
||||
|
||||
bootstrap=${bootstrap-}
|
||||
bootstrap=${bootstrap-@bootstrap@}
|
||||
compiler=${compiler-@compiler@}
|
||||
courageous=${courageous-@courageous@}
|
||||
mes_system=@mes_system@
|
||||
|
@ -81,6 +83,8 @@ srcdir=${srcdir-"@srcdir@"}
|
|||
sysconfdir="@sysconfdir@"
|
||||
top_builddir="@top_builddir@"
|
||||
|
||||
MES_PREFIX=${MES_PREFIX-$abs_top_srcdir}
|
||||
|
||||
export PACKAGE
|
||||
export PACKAGE_NAME
|
||||
export PACKAGE_BUGREPORT
|
||||
|
@ -95,3 +99,4 @@ export courageous
|
|||
export srcdest
|
||||
export srcdir
|
||||
export GUILE_AUTO_COMPILE
|
||||
export MES_PREFIX
|
||||
|
|
|
@ -55,6 +55,7 @@ libmes_SOURCES="
|
|||
$libc_mini_shared_SOURCES
|
||||
lib/ctype/isnumber.c
|
||||
lib/mes/abtol.c
|
||||
lib/mes/cast.c
|
||||
lib/mes/div.c
|
||||
lib/mes/eputc.c
|
||||
lib/mes/fdgetc.c
|
||||
|
@ -76,7 +77,9 @@ if test $mes_libc = mes; then
|
|||
lib/ctype/isdigit.c
|
||||
lib/ctype/isspace.c
|
||||
lib/ctype/isxdigit.c
|
||||
lib/mes/assert_msg.c
|
||||
lib/posix/write.c
|
||||
lib/stdlib/abort.c
|
||||
lib/stdlib/atoi.c
|
||||
"
|
||||
if test $mes_kernel = linux; then
|
||||
|
@ -86,6 +89,8 @@ lib/linux/lseek.c
|
|||
fi
|
||||
else
|
||||
libmes_SOURCES="$libmes_SOURCES
|
||||
lib/mes/abtod.c
|
||||
lib/mes/dtoab.c
|
||||
"
|
||||
fi
|
||||
|
||||
|
@ -156,6 +161,8 @@ lib/ctype/islower.c
|
|||
lib/ctype/isupper.c
|
||||
lib/ctype/tolower.c
|
||||
lib/ctype/toupper.c
|
||||
lib/mes/abtod.c
|
||||
lib/mes/dtoab.c
|
||||
lib/mes/search-path.c
|
||||
lib/posix/execvp.c
|
||||
lib/stdio/fclose.c
|
||||
|
@ -180,6 +187,7 @@ lib/stdio/vsprintf.c
|
|||
lib/stdio/vsscanf.c
|
||||
lib/stdlib/calloc.c
|
||||
lib/stdlib/qsort.c
|
||||
lib/stdlib/strtod.c
|
||||
lib/stdlib/strtof.c
|
||||
lib/stdlib/strtol.c
|
||||
lib/stdlib/strtold.c
|
||||
|
@ -199,7 +207,6 @@ lib/stub/ldexp.c
|
|||
lib/stub/mprotect.c
|
||||
lib/stub/localtime.c
|
||||
lib/stub/sigemptyset.c
|
||||
lib/stub/strtod.c
|
||||
lib/$mes_cpu-mes-$compiler/setjmp.c
|
||||
"
|
||||
|
||||
|
@ -217,6 +224,7 @@ lib/ctype/isalnum.c
|
|||
lib/ctype/isalpha.c
|
||||
lib/ctype/isascii.c
|
||||
lib/ctype/iscntrl.c
|
||||
lib/ctype/isgraph.c
|
||||
lib/ctype/isprint.c
|
||||
lib/ctype/ispunct.c
|
||||
lib/dirent/__getdirentries.c
|
||||
|
@ -227,6 +235,7 @@ lib/math/fabs.c
|
|||
lib/mes/fdgets.c
|
||||
lib/posix/alarm.c
|
||||
lib/posix/execl.c
|
||||
lib/posix/execlp.c
|
||||
lib/posix/mktemp.c
|
||||
lib/posix/raise.c
|
||||
lib/posix/sbrk.c
|
||||
|
@ -239,10 +248,10 @@ lib/stdio/fileno.c
|
|||
lib/stdio/freopen.c
|
||||
lib/stdio/perror.c
|
||||
lib/stdlib/__exit.c
|
||||
lib/stdlib/abort.c
|
||||
lib/stdlib/abs.c
|
||||
lib/stdlib/alloca.c
|
||||
lib/stdlib/atexit.c
|
||||
lib/stdlib/atof.c
|
||||
lib/stdlib/atol.c
|
||||
lib/stdlib/mbstowcs.c
|
||||
lib/string/bcmp.c
|
||||
|
@ -263,14 +272,22 @@ lib/stub/ctime.c
|
|||
lib/stub/fpurge.c
|
||||
lib/stub/freadahead.c
|
||||
lib/stub/frexp.c
|
||||
lib/stub/fscanf.c
|
||||
lib/stub/getgrgid.c
|
||||
lib/stub/getgrnam.c
|
||||
lib/stub/getlogin.c
|
||||
lib/stub/getpgid.c
|
||||
lib/stub/getpgrp.c
|
||||
lib/stub/getpwnam.c
|
||||
lib/stub/getpwuid.c
|
||||
lib/stub/gmtime.c
|
||||
lib/stub/mktime.c
|
||||
lib/stub/pclose.c
|
||||
lib/stub/popen.c
|
||||
lib/stub/rand.c
|
||||
lib/stub/rewind.c
|
||||
lib/stub/setbuf.c
|
||||
lib/stub/setgrent.c
|
||||
lib/stub/setlocale.c
|
||||
lib/stub/setvbuf.c
|
||||
lib/stub/sigaddset.c
|
||||
|
@ -303,18 +320,26 @@ lib/linux/kill.c
|
|||
lib/linux/link.c
|
||||
lib/linux/lstat.c
|
||||
lib/linux/mkdir.c
|
||||
lib/linux/mknod.c
|
||||
lib/linux/nanosleep.c
|
||||
lib/linux/pipe.c
|
||||
lib/linux/readlink.c
|
||||
lib/linux/rename.c
|
||||
lib/linux/setgid.c
|
||||
lib/linux/settimer.c
|
||||
lib/linux/setuid.c
|
||||
lib/linux/signal.c
|
||||
lib/linux/sigprogmask.c
|
||||
lib/linux/symlink.c
|
||||
"
|
||||
fi
|
||||
|
||||
mes_SOURCES="
|
||||
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
|
||||
|
@ -323,7 +348,10 @@ 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/variable.c
|
||||
src/vector.c
|
||||
"
|
||||
|
|
|
@ -19,3 +19,4 @@
|
|||
# along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
for i in $(find . -name '*.c' -o -name '*.h' -o -name '*.i'); do indent $i --no-tabs --line-length 110 --honour-newlines; done
|
||||
rm -f $(find . -name '*~')
|
||||
|
|
|
@ -27,9 +27,11 @@ _v=
|
|||
if test "$V" = 2; then
|
||||
set -x
|
||||
fi
|
||||
if test "$V" -gt 0; then
|
||||
v=v
|
||||
_v=-v
|
||||
if test -n "$V"; then
|
||||
if test "$V" -gt 0; then
|
||||
v=v
|
||||
_v=-v
|
||||
fi
|
||||
fi
|
||||
|
||||
set -u
|
||||
|
@ -41,7 +43,16 @@ fi
|
|||
|
||||
DESTDIR=${DESTDIR-}
|
||||
mkdir -p ${DESTDIR}${bindir}
|
||||
cp $_v src/mes ${DESTDIR}${bindir}/mes
|
||||
cp $_v bin/mes ${DESTDIR}${bindir}/mes
|
||||
if test -f bin/mes-gcc; then
|
||||
cp $_v bin/mes-gcc ${DESTDIR}${bindir}/mes-gcc
|
||||
fi
|
||||
if test -f bin/mes-m2; then
|
||||
cp $_v bin/mes-m2 ${DESTDIR}${bindir}/mes-m2
|
||||
fi
|
||||
if test -f bin/mes-mescc; then
|
||||
cp $_v bin/mes-mescc ${DESTDIR}${bindir}/mes-mescc2
|
||||
fi
|
||||
cp $_v scripts/mesar ${DESTDIR}${bindir}/mesar
|
||||
cp $_v scripts/mescc.scm ${DESTDIR}${bindir}/mescc.scm
|
||||
cp $_v scripts/mescc ${DESTDIR}${bindir}/mescc
|
||||
|
@ -77,13 +88,20 @@ else
|
|||
cp $_v ChangeLog ${DESTDIR}${docdir}
|
||||
fi
|
||||
|
||||
__exclude_go=
|
||||
__exclude_scm=
|
||||
if test -f module/mescc.go; then
|
||||
__exclude_go=--exclude='*.go'
|
||||
__exclude_scm=--exclude='*.scm'
|
||||
fi
|
||||
|
||||
mkdir -p $DESTDIR$includedir
|
||||
mkdir -p $DESTDIR$libdir
|
||||
mkdir -p $DESTDIR$pkgdatadir
|
||||
# rm -f $(find lib -type f -a -executable)
|
||||
# rm -f $(find scaffold -type f -a -executable)
|
||||
tar -cf- -C ${srcdir} include lib/$mes_cpu-mes | tar -${v}xf- -C $DESTDIR$prefix
|
||||
tar -cf- -C ${srcdir}/include . | tar -${v}xf- -C $DESTDIR$includedir
|
||||
tar -cf- -C ${srcdir}/lib $mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir
|
||||
if test -z "$srcdest"; then
|
||||
tar -cf- --exclude='*.go' module | tar -${v}xf- -C $DESTDIR$pkgdatadir
|
||||
tar -cf- $__exclude_go module | tar -${v}xf- -C $DESTDIR$pkgdatadir
|
||||
else
|
||||
tar -cf- -C ${srcdest} module | tar -${v}xf- -C $DESTDIR$pkgdatadir
|
||||
fi
|
||||
|
@ -97,8 +115,8 @@ fi
|
|||
|
||||
mkdir -p ${DESTDIR}${guile_site_dir}
|
||||
mkdir -p ${DESTDIR}${guile_site_ccache_dir}
|
||||
tar -cf- -C ${srcdest}module --exclude='*.go' . | tar -${v}xf- -C ${DESTDIR}${guile_site_dir}
|
||||
tar -cf- -C module --exclude='*.scm' . | tar -${v}xf- -C ${DESTDIR}${guile_site_ccache_dir}
|
||||
tar -cf- -C ${srcdest}module $__exclude_go . | tar -${v}xf- -C ${DESTDIR}${guile_site_dir}
|
||||
tar -cf- -C module $__exclude_scm . | tar -${v}xf- -C ${DESTDIR}${guile_site_ccache_dir}
|
||||
|
||||
if test -f doc/mes.info; then
|
||||
mkdir -p ${DESTDIR}${infodir}
|
||||
|
|
|
@ -4,7 +4,7 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes
|
|||
!#
|
||||
|
||||
;;; GNU Mes --- Maxwell Equations of Software
|
||||
;;; Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
;;; Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
;;;
|
||||
;;; mes-snarf.scm: This file is part of GNU Mes.
|
||||
;;;
|
||||
|
@ -85,8 +85,7 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes
|
|||
(cut string-replace-string <> "_to_" "->")
|
||||
(cut string-replace-suffix <> "_x" "!")
|
||||
(cut string-replace-suffix <> "_x_" "!-")
|
||||
(cut string-replace-suffix <> "_p" "?")
|
||||
)
|
||||
(cut string-replace-suffix <> "_p" "?"))
|
||||
(function.name f))))
|
||||
(if (not (string-suffix? "-" name)) name
|
||||
(string-append "core:" (string-drop-right name 1))))))
|
||||
|
@ -105,19 +104,26 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes
|
|||
(format #f "// CONSTANT ~a ~a\n" s i)
|
||||
(format #f "#define ~a ~a\n" s i)))
|
||||
|
||||
(define (symbol->header s i)
|
||||
(let ((c (string-upcase s)))
|
||||
(string-append
|
||||
(format #f "\n// CONSTANT ~a ~a\n" c i)
|
||||
(format #f "#define ~a ~a\n" c i)
|
||||
(format #f "struct scm *~a; /* ~a */\n" s i))))
|
||||
|
||||
(define (function->header f i)
|
||||
(let* ((arity (or (assoc-ref (function.annotation f) 'arity)
|
||||
(if (string-null? (function.formals f)) 0
|
||||
(length (string-split (function.formals f) #\,)))))
|
||||
(n (if (eq? arity 'n) -1 arity)))
|
||||
(format #f "SCM ~a (~a);\n" (function.name f) (function.formals f))))
|
||||
(format #f "struct scm *~a (~a);\n" (function.name f) (function.formals f))))
|
||||
|
||||
(define (function->source f i)
|
||||
(let* ((arity (or (assoc-ref (function.annotation f) 'arity)
|
||||
(if (string-null? (function.formals f)) 0
|
||||
(length (string-split (function.formals f) #\,)))))
|
||||
(n (if (eq? arity 'n) -1 arity)))
|
||||
(format #f " a = init_builtin (builtin_type, ~s, ~a, &~a, a);\n" (function.name f) n (function.name f))))
|
||||
(format #f " a = init_builtin (builtin_type, ~s, ~a, &~a, a);\n" (function-scm-name f) n (function.name f))))
|
||||
|
||||
(define (disjoin . predicates)
|
||||
(lambda (. arguments)
|
||||
|
@ -125,11 +131,11 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes
|
|||
|
||||
(define (snarf-symbols string)
|
||||
(let* ((lines (string-split string #\newline))
|
||||
(symbols (filter (cut string-prefix? " init_symbol (" <>) lines)))
|
||||
(symbols (filter (cut string-contains <> " = init_symbol (") lines)))
|
||||
(define (line->symbol line)
|
||||
((compose
|
||||
(lambda (s) (string-take s (string-index s #\,)))
|
||||
(cut string-drop <> (string-length " init_symbol (")))
|
||||
string-trim-both
|
||||
(lambda (s) (string-take s (string-index s #\=))))
|
||||
line))
|
||||
(map line->symbol symbols)))
|
||||
|
||||
|
@ -144,20 +150,28 @@ exec ${GUILE-guile} --no-auto-compile -L $(dirname $0) -C $(dirname $0) -e '(mes
|
|||
(receive (function rest)
|
||||
(apply values (string-split-string line " "))
|
||||
(and function
|
||||
(equal? (string-trim previous) "SCM")
|
||||
(or (equal? (string-trim previous) "struct scm*")
|
||||
(equal? (string-trim previous) "struct scm *"))
|
||||
(not (string-null? function))
|
||||
(not (string-prefix? "#" function))
|
||||
(not (string-prefix? "/" function))
|
||||
rest
|
||||
(receive (parameter-list annotation)
|
||||
(apply values (string-split-string rest " ///"))
|
||||
(let* ((parameters (string-drop parameter-list 1))
|
||||
(apply values (string-split-string rest " /*:"))
|
||||
(let* ((parameters (string-trim-both parameter-list))
|
||||
(parameters (string-drop parameters 1))
|
||||
(parameters (string-drop-right parameters 1))
|
||||
(annotation (if (string? annotation) (string-trim-both annotation)
|
||||
annotation))
|
||||
(annotation (if (and (string? annotation)
|
||||
(string-suffix? "*/" annotation))
|
||||
(string-drop-right annotation 2)
|
||||
annotation))
|
||||
(formals (if (string-null? parameters) '()
|
||||
(string-split parameters #\,)))
|
||||
(formals (map string-trim formals)))
|
||||
(and parameters
|
||||
(let* ((non-SCM (filter (negate (cut string-prefix? "SCM" <>)) formals)))
|
||||
(let* ((non-SCM (filter (negate (cut string-prefix? "struct scm" <>)) formals)))
|
||||
(and (null? non-SCM)
|
||||
(let ((annotation (and annotation (with-input-from-string annotation read))))
|
||||
(make-function function parameters annotation))))))))))
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
#! /bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
ptr_once='s,([^N])(MACRO|NAME|VALUE) \(([^()]*)\),\1\3->\L\2,'
|
||||
ptr_once='s,([^N])(BYTES|CAR|CDR|CLOSURE|CONTINUATION|LENGTH|MACRO|NAME|PORT|REF|STRING|STRUCT|TYPE|VALUE|VARIABLE|VECTOR) \(([^()]*)\),\1\3->\L\2,'
|
||||
n_once='s,N(TYPE|CAR|CDR|LENGTH|VALUE|VECTOR) \(([^()]*)\),\2->\L\1,'
|
||||
ncbytes='s,NC(BYTES) \(([^()]*)\),news_\L\1 (\2),'
|
||||
cbytes='s,([^N])C(BYTES) \(([^()]*)\),\1cell_\L\2 (\3),'
|
||||
cstring='s,C(STRING) \(([^()]*)\),cell_bytes (STRING (\2)),'
|
||||
struct='s,SCM,struct scm *,g'
|
||||
struct_scm_p='s,struct scm\* ?,struct scm *,g'
|
||||
|
||||
sed -ri \
|
||||
-e 's,POINTER_CELLS=0,POINTER_CELLS=1', \
|
||||
-e 's,#define POINTER_CELLS 0,#define POINTER_CELLS 1', \
|
||||
-e "$ncbytes" \
|
||||
-e "$cbytes" \
|
||||
-e "$cstring" \
|
||||
\
|
||||
-e "$ncbytes" \
|
||||
-e "$cbytes" \
|
||||
-e "$cstring" \
|
||||
\
|
||||
-e "$ptr_once" \
|
||||
-e "$ptr_once" \
|
||||
-e "$ptr_once" \
|
||||
-e 's,->\<struct\>,->structure,g' \
|
||||
-e "$struct" \
|
||||
-e "$struct_scm_p" \
|
||||
\
|
||||
-e "$n_once" \
|
||||
-e "$n_once" \
|
||||
\
|
||||
-e 's,CAR \(([^()]*)\),\1->cdr,' \
|
||||
-e 's,CAAR \(([^()]*)\),\1->car->car,' \
|
||||
-e 's,CADR \(([^()]*)\),\1->cdr->car,' \
|
||||
-e 's,CDAR \(([^()]*)\),\1->car->cdr,' \
|
||||
-e 's,CDDR \(([^()]*)\),\1->cdr->cdr,' \
|
||||
-e 's,CADAR \(([^()]*)\),\1->car->cdr->car,' \
|
||||
-e 's,CADDR \(([^()]*)\),\1->cdr->cdr->car,' \
|
||||
-e 's,CDADR \(([^()]*)\),\1->cdr->car->cdr,' \
|
||||
-e 's,CDDDR \(([^()]*)\),\1->cdr->cdr->cdr,' \
|
||||
-e 's,CDDAR \(([^()]*)\),\1->car->cdr->cdr,' \
|
||||
-e 's,CDADAR \(([^()]*)\),\1->cdr->car->cdr->car,' \
|
||||
\
|
||||
include/mes/builtins.h \
|
||||
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 \
|
||||
src/display.c \
|
||||
src/eval-apply.c \
|
||||
src/gc.c \
|
||||
src/hash.c \
|
||||
src/lib.c \
|
||||
src/m2.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 \
|
||||
src/test/gc.c \
|
||||
simple.make \
|
|
@ -36,10 +36,10 @@ if [ -n "$srcdest" ]; then
|
|||
fi
|
||||
export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
|
||||
|
||||
PATH="$abs_top_builddir/scripts:$abs_top_builddir/scripts:$abs_top_builddir/src:$abs_top_builddir/build-aux:$PATH"
|
||||
PATH="$abs_top_builddir/scripts:$abs_top_builddir/scripts:$abs_top_builddir/bin:$abs_top_builddir/build-aux:$PATH"
|
||||
export PATH
|
||||
|
||||
MES=${MES-${abs_top_builddir}/src/${program_prefix}mes}
|
||||
MES=${MES-${abs_top_builddir}/bin/${program_prefix}mes}
|
||||
export MES
|
||||
|
||||
bindir=${abs_top_builddir}/scripts
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/sh
|
||||
|
||||
# GNU Mes --- Maxwell Equations of Software
|
||||
# Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
#
|
||||
# This file is part of GNU Mes.
|
||||
#
|
||||
|
@ -20,17 +20,44 @@
|
|||
|
||||
set -e
|
||||
|
||||
. ${srcdest}build-aux/config.sh
|
||||
srcdest=${srcdest-./}
|
||||
. ${srcdest}config.sh
|
||||
. ${srcdest}build-aux/trace.sh
|
||||
|
||||
trace "SNARF$snarf gc.c" ${srcdest}build-aux/mes-snarf.scm src/gc.c
|
||||
trace "SNARF$snarf hash.c" ${srcdest}build-aux/mes-snarf.scm src/hash.c
|
||||
trace "SNARF$snarf lib.c" ${srcdest}build-aux/mes-snarf.scm src/lib.c
|
||||
trace "SNARF$snarf math.c" ${srcdest}build-aux/mes-snarf.scm src/math.c
|
||||
trace "SNARF$snarf mes.c" ${srcdest}build-aux/mes-snarf.scm src/mes.c
|
||||
trace "SNARF$snarf module.c" ${srcdest}build-aux/mes-snarf.scm src/module.c
|
||||
trace "SNARF$snarf posix.c" ${srcdest}build-aux/mes-snarf.scm src/posix.c
|
||||
trace "SNARF$snarf reader.c" ${srcdest}build-aux/mes-snarf.scm src/reader.c
|
||||
trace "SNARF$snarf strings.c" ${srcdest}build-aux/mes-snarf.scm src/string.c
|
||||
trace "SNARF$snarf struct.c" ${srcdest}build-aux/mes-snarf.scm src/struct.c
|
||||
trace "SNARF$snarf vector.c" ${srcdest}build-aux/mes-snarf.scm src/vector.c
|
||||
trace "SNARF$snarf builtins.c" ${srcdest}build-aux/mes-snarf.scm src/builtins.c
|
||||
trace "SNARF$snarf core.c" ${srcdest}build-aux/mes-snarf.scm src/core.c
|
||||
trace "SNARF$snarf display.c" ${srcdest}build-aux/mes-snarf.scm src/display.c
|
||||
trace "SNARF$snarf eval-apply.c" ${srcdest}build-aux/mes-snarf.scm src/eval-apply.c
|
||||
trace "SNARF$snarf gc.c" ${srcdest}build-aux/mes-snarf.scm src/gc.c
|
||||
trace "SNARF$snarf hash.c" ${srcdest}build-aux/mes-snarf.scm src/hash.c
|
||||
trace "SNARF$snarf lib.c" ${srcdest}build-aux/mes-snarf.scm src/lib.c
|
||||
trace "SNARF$snarf math.c" ${srcdest}build-aux/mes-snarf.scm src/math.c
|
||||
trace "SNARF$snarf mes.c" ${srcdest}build-aux/mes-snarf.scm src/mes.c
|
||||
trace "SNARF$snarf module.c" ${srcdest}build-aux/mes-snarf.scm src/module.c
|
||||
trace "SNARF$snarf posix.c" ${srcdest}build-aux/mes-snarf.scm src/posix.c
|
||||
trace "SNARF$snarf reader.c" ${srcdest}build-aux/mes-snarf.scm src/reader.c
|
||||
trace "SNARF$snarf stack.c" ${srcdest}build-aux/mes-snarf.scm src/stack.c
|
||||
trace "SNARF$snarf strings.c" ${srcdest}build-aux/mes-snarf.scm src/string.c
|
||||
trace "SNARF$snarf struct.c" ${srcdest}build-aux/mes-snarf.scm src/struct.c
|
||||
trace "SNARF$snarf symbol.c" ${srcdest}build-aux/mes-snarf.scm src/symbol.c
|
||||
trace "SNARF$snarf variable.c" ${srcdest}build-aux/mes-snarf.scm src/variable.c
|
||||
trace "SNARF$snarf vector.c" ${srcdest}build-aux/mes-snarf.scm src/vector.c
|
||||
|
||||
for i in src/*.symbols.h; do
|
||||
n=$(basename $i .symbols.h)
|
||||
echo "/* src/$n.c */"
|
||||
cat $i
|
||||
mv $i $(basename $i .symbols.h).s
|
||||
done > s
|
||||
|
||||
for i in src/*.h; do
|
||||
n=$(basename $i .h)
|
||||
echo "/* src/$n.c */"
|
||||
cat $i
|
||||
done > h
|
||||
|
||||
for i in src/*.i; do
|
||||
n=$(basename $i .i)
|
||||
echo " /* src/$n.c */"
|
||||
cat $i
|
||||
done > c
|
||||
|
|
|
@ -364,7 +364,6 @@ Some influential environment variables:
|
|||
GUILE guile command
|
||||
GUILD guild command
|
||||
MES_FOR_BUILD build system MES [can be mes or guile]
|
||||
MES_SEED location of mes-seed
|
||||
" PACKAGE VERSION (getenv "prefix")))
|
||||
|
||||
(define (main args)
|
||||
|
@ -383,7 +382,7 @@ Some influential environment variables:
|
|||
(bindir (option-ref options 'bindir "${prefix}/bin"))
|
||||
(datadir (option-ref options 'datadir "${prefix}/share"))
|
||||
(docdir (option-ref options 'docdir "${datadir}/doc/mes-${VERSION}"))
|
||||
(includedir (option-ref options 'libdir "${prefix}/include"))
|
||||
(includedir (option-ref options 'includedir "${prefix}/include"))
|
||||
(libdir (option-ref options 'libdir "${prefix}/lib"))
|
||||
(pkgdatadir (string-append datadir "/mes"))
|
||||
(guile-effective-version (effective-version))
|
||||
|
@ -417,12 +416,7 @@ Some influential environment variables:
|
|||
(when %verbose?
|
||||
(stderr "configure args=~s\n" args))
|
||||
(for-each (lambda (v) (apply setenv (string-split v #\=))) vars)
|
||||
(let* ((mes-seed (or (getenv "MES_SEED")
|
||||
(string-append srcdest "../mes-seed")))
|
||||
(mes-seed (and mes-seed
|
||||
(file-exists? (string-append mes-seed "/x86-mes/mes.S"))
|
||||
mes-seed))
|
||||
(tinycc-prefix (or (getenv "TINYCC_PREFIX")
|
||||
(let* ((tinycc-prefix (or (getenv "TINYCC_PREFIX")
|
||||
(string-append srcdest "../tinycc-prefix")))
|
||||
(gcc (or (getenv "CC") "gcc"))
|
||||
(tcc (or (getenv "TCC") "tcc"))
|
||||
|
@ -430,7 +424,9 @@ Some influential environment variables:
|
|||
(deps (fold (lambda (program results)
|
||||
(cons (check-program-version program) results))
|
||||
'()
|
||||
(list (make-dep "hex2" #:version '(0 6))
|
||||
(list (make-dep "kaem" #:version '(0 6) #:optional? #t)
|
||||
(make-dep "M2-Planet" #:version '(0 1 3) #:optional? #t)
|
||||
(make-dep "hex2" #:version '(0 6))
|
||||
(make-dep "M1" #:version '(0 6))
|
||||
(make-dep "blood-elf" #:version '(0 6))
|
||||
(make-dep "diff" #:optional? #t)
|
||||
|
@ -479,7 +475,7 @@ Some influential environment variables:
|
|||
"))
|
||||
deps)
|
||||
deps))
|
||||
(mesc? (file-name "cc is Mes C" deps))
|
||||
(mescc? (file-name "cc is Mes C" deps))
|
||||
(deps (if cc
|
||||
(cons (check-compile-c cc (make-dep "cc is Tiny CC" #:data "#if !defined (__TINYCC__)
|
||||
#error no tinycc
|
||||
|
@ -508,7 +504,11 @@ Some influential environment variables:
|
|||
(equal? "linux" (car kernel-list))) "linux")
|
||||
((equal? '( "gnu") kernel-list) "gnu")
|
||||
(else "unknown")))
|
||||
(compiler (if gcc? "gcc" "mescc"))
|
||||
(m2-planet (file-name "M2-Planet" deps))
|
||||
(compiler (or (and gcc? "gcc")
|
||||
(and tcc? "tcc")
|
||||
(and mescc? "mescc")
|
||||
"bootstrap"))
|
||||
(mes-system (string-join (list mes-cpu mes-kernel "mes") "-")))
|
||||
|
||||
(define* (substitute file-name pairs
|
||||
|
@ -594,10 +594,11 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
|
|||
("@GUILE@" . ,guile)
|
||||
("@GUIX@" . ,(or (file-name "guix" deps) ""))
|
||||
("@HELP2MAN@" . ,(or (file-name "help2man" deps) ""))
|
||||
("@KAEM@" . ,(or (file-name "kaem" deps) ""))
|
||||
("@M2_PLANET@" . ,(or (file-name "M2-Planet" deps) ""))
|
||||
("@MAKEINFO@" . ,(or (file-name "makeinfo" deps) ""))
|
||||
("@MES_FOR_BUILD@" . ,(or (file-name "mes" deps)
|
||||
guile))
|
||||
("@MES_SEED@" . ,(or mes-seed ""))
|
||||
("@PERL@" . ,(or (file-name "perl" deps) ""))
|
||||
("#SCHEME=\"@SCHEME@\"" . ,(if with-cheating? (string-append "\nSCHEME=\"" guile "\"") ""))
|
||||
("@SCHEME@" . ,(if with-cheating? guile ""))
|
||||
|
@ -615,8 +616,8 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
|
|||
deps))))
|
||||
|
||||
(when (and (not cc)
|
||||
(not mes-seed))
|
||||
(format (current-error-port) "must supply C compiler or MES_SEED/x86-mes/mes.S\n")
|
||||
(not m2-planet))
|
||||
(format (current-error-port) "must supply C compiler or M2-Planet\n")
|
||||
(exit 2))
|
||||
(for-each (lambda (o)
|
||||
(let* ((src (string-append srcdest o))
|
||||
|
@ -632,11 +633,13 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system)
|
|||
"build-aux/install.sh.in"
|
||||
"build-aux/pre-inst-env.in"
|
||||
"build-aux/uninstall.sh.in"
|
||||
"scripts/m2-merge.scm.in"
|
||||
"scripts/mesar.in"
|
||||
"scripts/mescc.scm.in"
|
||||
"scripts/mescc.in"
|
||||
))
|
||||
(chmod "pre-inst-env" #o755)
|
||||
(chmod "scripts/m2-merge.scm" #o755)
|
||||
(chmod "scripts/mesar" #o755)
|
||||
(chmod "scripts/mescc" #o755)
|
||||
(chmod "scripts/mescc.scm" #o755)
|
||||
|
|
93
configure.sh
93
configure.sh
|
@ -24,65 +24,35 @@ VERSION=0.20
|
|||
srcdir=${srcdir-$(dirname $0)}
|
||||
. ${srcdest}build-aux/trace.sh
|
||||
|
||||
# parse --with-system-libc
|
||||
cmdline=$(echo " $@")
|
||||
p=${cmdline/ --with-system-libc/}
|
||||
if test "$p" != "$cmdline"; then
|
||||
mes_libc=${mes_libc-system}
|
||||
else
|
||||
mes_libc=mes
|
||||
fi
|
||||
# parse arguments
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
(--with-courage)
|
||||
courageous=true
|
||||
;;
|
||||
(--with-system-libc)
|
||||
mes_libc=system
|
||||
;;
|
||||
(--build=*)
|
||||
build=${1#--build=}
|
||||
;;
|
||||
(--host=*)
|
||||
host=${1#--host=}
|
||||
;;
|
||||
(--prefix=*)
|
||||
prefix=${1#--prefix=}
|
||||
;;
|
||||
(--program-prefix=*)
|
||||
program_prefix=${1#--program-prefix=}
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# parse --with-courage
|
||||
cmdline=$(echo " $@")
|
||||
p=${cmdline/ --with-courage/}
|
||||
if test "$p" != "$cmdline"; then
|
||||
courageous=true
|
||||
else
|
||||
courageous=false
|
||||
fi
|
||||
|
||||
# parse --prefix=PREFIX
|
||||
p=${cmdline/ --prefix=/ -prefix=}
|
||||
if test "$p" != "$cmdline"; then
|
||||
p=${p##* -prefix=}
|
||||
p=${p% *}
|
||||
p=${p% -*}
|
||||
prefix=${p-/usr/local}
|
||||
else
|
||||
prefix=${prefix-/usr/local}
|
||||
fi
|
||||
|
||||
# parse --build=BUILD
|
||||
p=${cmdline/ --build=/ -build=}
|
||||
if [ "$p" != "$cmdline" ]; then
|
||||
p=${p##* -build=}
|
||||
p=${p% *}
|
||||
p=${p% -*}
|
||||
build=${p-$build}
|
||||
else
|
||||
build=$build
|
||||
fi
|
||||
|
||||
# parse --host=HOST
|
||||
p=${cmdline/ --host=/ -host=}
|
||||
if [ "$p" != "$cmdline" ]; then
|
||||
p=${p##* -host=}
|
||||
p=${p% *}
|
||||
p=${p% -*}
|
||||
host=${p-$build}
|
||||
elif test -n "$build"; then
|
||||
host=${host-$build}
|
||||
fi
|
||||
|
||||
# parse --program-prefix=
|
||||
p=${cmdline/ --program-prefix=/ -program-prefix=}
|
||||
if test "$p" != "$cmdline"; then
|
||||
p=${p##* -program-prefix=}
|
||||
p=${p% *}
|
||||
p=${p% -*}
|
||||
program_prefix=$p
|
||||
fi
|
||||
prefix=${prefix-/usr/local}
|
||||
mes_libc=${mes_libc-mes}
|
||||
courageous=${courageous-false}
|
||||
host=${host-$build}
|
||||
|
||||
AR=${AR-$(command -v ar)} || true
|
||||
BASH=${BASH-$(command -v bash)}
|
||||
|
@ -101,6 +71,8 @@ fi
|
|||
GUILE=${GUILE-$(command -v guile)} || true
|
||||
HEX2=${HEX2-$(command -v hex2)}
|
||||
M1=${M1-$(command -v M1)}
|
||||
M2_PLANET=${M1-$(command -v M2-Planet)}
|
||||
KAEM=${KAEM-$(command -v kaem)}
|
||||
MES_FOR_BUILD=${MES_FOR_BUILD-$(command -v mes || command -v guile || echo mes)}
|
||||
GIT=${GIT-$(command -v git)} || true
|
||||
PERL=${PERL-$(command -v perl)} || true
|
||||
|
@ -126,7 +98,7 @@ bindir=$(eval echo ${bindir-$prefix/bin})
|
|||
datadir=$(eval echo ${datadir-$prefix/share})
|
||||
docdir=$(eval echo ${docdir-$datadir/doc/mes-$VERSION})
|
||||
infodir=$(eval echo ${infodir-$datadir/info})
|
||||
includedir=$(eval echo ${libdir-$prefix/include})
|
||||
includedir=$(eval echo ${includedir-$prefix/include})
|
||||
libdir=$(eval echo ${libdir-$prefix/lib})
|
||||
pkgdatadir=$(eval echo ${pkgdatadir-$datadir/mes})
|
||||
mandir=$(eval echo ${mandir-$datadir/man})
|
||||
|
@ -140,6 +112,7 @@ subst () {
|
|||
-e s,"@PACKAGE_NAME@,$PACKAGE_NAME,"\
|
||||
-e s,"@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,"\
|
||||
-e s,"@VERSION@,$VERSION,"\
|
||||
-e s,"@bootstrap@,yes,"\
|
||||
-e s,"@build@,$build,"\
|
||||
-e s,"@host@,$host,"\
|
||||
-e s,"@compiler@,$compiler,"\
|
||||
|
@ -183,6 +156,8 @@ subst () {
|
|||
-e s,"@HEX2FLAGS@,$HEX2FLAGS,"\
|
||||
-e s,"@M1@,$M1,"\
|
||||
-e s,"@M1FLAGS@,$M1FLAGS,"\
|
||||
-e s,"@M2_PLANET@,$M2_PLANET,"\
|
||||
-e s,"@KAEM@,$KAEM,"\
|
||||
-e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\
|
||||
-e s,"@MES_SEED@,$MES_SEED,"\
|
||||
-e s,"@MES_SEED@,$MES_SEED,"\
|
||||
|
|
|
@ -7,7 +7,9 @@ We are pleased to announce the release of GNU Mes 0.20, representing
|
|||
147 commits over 38 weeks.
|
||||
|
||||
Mes has now brought the Reduced Binary Seed bootstrap to Guix (bootstrap
|
||||
a GNU/Linux system without binary GNU toolchain or equivalent).
|
||||
a GNU/Linux system without binary GNU toolchain or equivalent). It
|
||||
should land in Guix master any day now: a big thank you to everyone who
|
||||
helped, notably Ludovic and Mark.
|
||||
|
||||
This release is a step towards the upcoming Scheme-only bootstrap and
|
||||
bringing Mes into NixOS and Debian. This effort is now sponsored by
|
||||
|
@ -67,8 +69,8 @@ Packages are available in Guix master.
|
|||
|
||||
Here are the MD5 and SHA1 checksums:
|
||||
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.20.tar.gz
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.20.tar.gz
|
||||
df839a83e4a2ad6c2a4accc5bf17b1a7 mes-0.20.tar.gz
|
||||
38d4cb3fa28fa1f5fc57fea9e046d4d8052bbb8c mes-0.20.tar.gz
|
||||
|
||||
[*] Use a .sig file to verify that the corresponding file (without the
|
||||
.sig suffix) is intact. First, be sure to download both the .sig file
|
||||
|
@ -83,6 +85,11 @@ Packages are available in Guix master.
|
|||
|
||||
and rerun the 'gpg --verify' command.
|
||||
|
||||
* Get informed, get involved
|
||||
|
||||
See https://bootstrappable.org
|
||||
Join #bootstrappable on irc.freenode.net.
|
||||
|
||||
* Changes in 0.20 since 0.19
|
||||
** Core
|
||||
*** The build system has been simplified, again.
|
||||
|
@ -108,6 +115,9 @@ Packages are available in Guix master.
|
|||
*** string->number now support #x hex-prefix.
|
||||
*** ungetc now has a buffer per file handle.
|
||||
|
||||
Greetings,
|
||||
janneke and Danny.
|
||||
|
||||
[0] https://www.gnu.org/software/mes
|
||||
[1] http://joyofsource.com/reduced-binary-seed-bootstrap.html
|
||||
[2] https://www.gnu.org/software/guix
|
||||
|
@ -119,5 +129,5 @@ Packages are available in Guix master.
|
|||
[8] https://www.nongnu.org/nyacc
|
||||
[9] https://gitlab.com/janneke/tinycc
|
||||
[10] http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf
|
||||
[11] https://github.com/oriansj/stage0
|
||||
[11] https://savannah.nongnu.org/projects/stage0
|
||||
[12] https://nlnet.nl/project/GNUMes
|
||||
|
|
|
@ -520,7 +520,7 @@ build-aux/check-boot.sh
|
|||
Run a single Mes boot test
|
||||
|
||||
@example
|
||||
MES_BOOT=scaffold/boot/00-zero.scm src/mes
|
||||
MES_BOOT=scaffold/boot/00-zero.scm bin/mes
|
||||
@end example
|
||||
|
||||
Run a single Mes Scheme test
|
||||
|
|
|
@ -81,6 +81,38 @@ get_machine.")
|
|||
(home-page "https://savannah.nongnu.org/projects/mescc-tools")
|
||||
(license gpl3+)))
|
||||
|
||||
(define-public m2-planet
|
||||
(let ((commit "1fc2aeab483208bd2ba117b21df3894c182470ec")
|
||||
(revision "0"))
|
||||
(package
|
||||
(name "m2-planet")
|
||||
(version (string-append "1.4.0-" revision "." (string-take commit 7)))
|
||||
(source (origin
|
||||
(method git-fetch)
|
||||
(uri (git-reference
|
||||
(url "https://github.com/oriansj/m2-planet.git")
|
||||
(commit commit)))
|
||||
(file-name (git-file-name name version))
|
||||
(sha256
|
||||
(base32
|
||||
"1fj3xiqcibdfi78b43nn6w8hs3vkz32yb06n8r5mna8pnjdmn00l"))))
|
||||
(native-inputs
|
||||
`(("mescc-tools" ,mescc-tools)))
|
||||
(build-system gnu-build-system)
|
||||
(arguments
|
||||
`(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")))
|
||||
#:tests? #f
|
||||
#:phases (modify-phases %standard-phases
|
||||
(delete 'bootstrap)
|
||||
(delete 'configure))))
|
||||
(synopsis "The PLAtform NEutral Transpiler")
|
||||
(description
|
||||
"M2-Planet, The PLAtform NEutral Transpiler, when combined with
|
||||
mescc-tools compiles a subset of the C language into working binaries
|
||||
with introspective steps inbetween.")
|
||||
(home-page "https://savannah.nongnu.org/projects/mescc-tools")
|
||||
(license gpl3+))))
|
||||
|
||||
(define-public nyacc
|
||||
(package
|
||||
(name "nyacc")
|
||||
|
@ -131,7 +163,7 @@ extensive examples, including parsers for the Javascript and C99 languages.")
|
|||
(uri (string-append
|
||||
"https://ftp.gnu.org/pub/gnu/mes/mes-" version ".tar.gz"))
|
||||
(sha256
|
||||
(base32 #!mes!# "06qkwkahcpzk5v4qydpvcvzm7lx8g8pflc48f9l7bpjz6hl5lk4s"))))
|
||||
(base32 #!mes!# "04pajp8v31na34ls4730ig5f6miiplhdvkmsb9ls1b8bbmw2vb4n"))))
|
||||
(build-system gnu-build-system)
|
||||
(supported-systems '("i686-linux" "x86_64-linux"))
|
||||
(propagated-inputs
|
||||
|
@ -149,7 +181,9 @@ extensive examples, including parsers for the Javascript and C99 languages.")
|
|||
'())
|
||||
("graphviz" ,graphviz)
|
||||
("help2man" ,help2man)
|
||||
("perl" ,perl) ; build-aux/gitlog-to-changelog
|
||||
("m2-planet" ,m2-planet)
|
||||
("mescc-tools" ,mescc-tools)
|
||||
("perl" ,perl) ; build-aux/gitlog-to-changelog
|
||||
("texinfo" ,texinfo)))
|
||||
(arguments
|
||||
`(#:strip-binaries? #f)) ; binutil's strip b0rkes MesCC/M1/hex2 binaries
|
||||
|
|
|
@ -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,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -35,6 +35,7 @@ int isalpha (int c);
|
|||
int isascii (int c);
|
||||
int iscntrl (int c);
|
||||
int isdigit (int c);
|
||||
int isgraph (int c);
|
||||
int islower (int c);
|
||||
int isnumber (int c, int base);
|
||||
int isprint (int c);
|
||||
|
|
|
@ -38,14 +38,16 @@ int errno;
|
|||
#define ENOENT 2
|
||||
#define EINTR 4
|
||||
#define EIO 5
|
||||
#define ENXIO 6
|
||||
#define E2BIG 7
|
||||
#define ENOEXEC 8
|
||||
#define ENOEXEC 8
|
||||
#define EBADF 9
|
||||
#define ECHILD 10
|
||||
#define EAGAIN 11
|
||||
#define ENOMEM 12
|
||||
#define EACCES 13
|
||||
#define EEXIST 17
|
||||
#define EXDEV 18
|
||||
#define ENOTDIR 20
|
||||
#define EISDIR 21
|
||||
#define EINVAL 22
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#define F_GETFL 3
|
||||
#define F_SETFL 4
|
||||
|
||||
#define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode)
|
||||
int dup (int old);
|
||||
int dup2 (int old, int new);
|
||||
int fcntl (int filedes, int command, ...);
|
||||
|
|
|
@ -20,34 +20,61 @@
|
|||
#ifndef __MES_LINUX_X86_SYSCALL_H
|
||||
#define __MES_LINUX_X86_SYSCALL_H 1
|
||||
|
||||
// libc-mini
|
||||
// #define SYS_exit 0x01
|
||||
// #define SYS_write 0x04
|
||||
/* 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
|
||||
/* 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
|
||||
|
||||
// libc+tcc
|
||||
#define SYS_close 0x06
|
||||
#define SYS_time 0x0d
|
||||
#define SYS_lseek 0x13
|
||||
#define SYS_unlink 0x0a
|
||||
#define SYS_rmdir 0x28
|
||||
#define SYS_gettimeofday 0x4e
|
||||
#define SYS_stat 0x6a
|
||||
// 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+gnu
|
||||
/* libc+tcc */
|
||||
#define SYS_close 0x06
|
||||
#define SYS_lseek 0x13
|
||||
#define SYS_rmdir 0x28
|
||||
#define SYS_stat 0x6a
|
||||
|
||||
/* libc+gnu */
|
||||
|
||||
#define SYS_chdir 0x0c
|
||||
#define SYS_link 0x09
|
||||
|
@ -56,7 +83,6 @@
|
|||
#define SYS_kill 0x25
|
||||
#define SYS_rename 0x26
|
||||
#define SYS_mkdir 0x27
|
||||
#define SYS_dup 0x29
|
||||
#define SYS_pipe 0x2a
|
||||
#define SYS_getgid 0x2f
|
||||
#define SYS_signal 0x30
|
||||
|
@ -64,23 +90,26 @@
|
|||
#define SYS_rt_sigaction 0xae
|
||||
#define SYS_signal 0x30
|
||||
#define SYS_fcntl 0x37
|
||||
#define SYS_dup2 0x3f
|
||||
#define SYS_getrusage 0x4d
|
||||
#define SYS_lstat 0x6b
|
||||
#define SYS_setitimer 0x68
|
||||
#define SYS_fstat 0x6c
|
||||
#define SYS_nanosleep 0xa2
|
||||
#define SYS_getdents 0x8d
|
||||
#define SYS_clock_gettime 0x109
|
||||
|
||||
// bash
|
||||
/* bash */
|
||||
#define SYS_setuid 0x17
|
||||
#define SYS_geteuid 0x31
|
||||
#define SYS_getegid 0x32
|
||||
#define SYS_setgid 0x3e
|
||||
#define SYS_getppid 0x40
|
||||
|
||||
// make+POSIX
|
||||
/* make+POSIX */
|
||||
#define SYS_sigprocmask 0x7e
|
||||
|
||||
#endif // __MES_LINUX_X86_SYSCALL_H
|
||||
/* tar */
|
||||
#define SYS_symlink 0x53
|
||||
#define SYS_readlink 0x55
|
||||
#define SYS_mknod 0x0e
|
||||
|
||||
#endif /* __MES_LINUX_X86_SYSCALL_H */
|
||||
|
|
|
@ -80,4 +80,9 @@
|
|||
// make+SYSTEM_LIBC
|
||||
#define SYS_rt_sigprocmask 0x0e
|
||||
|
||||
// tar
|
||||
#define SYS_symlink 0x58
|
||||
#define SYS_readlink 0x59
|
||||
#define SYS_mknod 0x85
|
||||
|
||||
#endif // __MES_LINUX_X86_64_SYSCALL_H
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __M2_LIB_H
|
||||
#define __M2_LIB_H
|
||||
|
||||
char **environ;
|
||||
int __stdin;
|
||||
int __stdout;
|
||||
int __stderr;
|
||||
int errno;
|
||||
|
||||
// CONSTANT EOF 0xffffffff
|
||||
// CONSTANT __FILEDES_MAX 512
|
||||
|
||||
char* cast_intp_to_charp (int *i);
|
||||
char* cast_long_to_charp (long i);
|
||||
long cast_charp_to_long (char const *);
|
||||
long cast_int_to_long (int i);
|
||||
long cast_voidp_to_long (void const *);
|
||||
|
||||
char *itoa (int number);
|
||||
char *ltoa (long number);
|
||||
int __ungetc_p (int filedes);
|
||||
int eputs (char *s);
|
||||
int oputs (char *s);
|
||||
int puts (char *s);
|
||||
size_t strlen (char *s);
|
||||
ssize_t _write ();
|
||||
ssize_t write (int filedes, void *buffer, size_t size);
|
||||
void __ungetc_clear (int filedes);
|
||||
void __ungetc_init ();
|
||||
void __ungetc_set (int filedes, int c);
|
||||
|
||||
struct timezone
|
||||
{
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
struct timespec
|
||||
{
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
struct timeval
|
||||
{
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
|
||||
#endif /* __M2_LIB_H */
|
|
@ -21,396 +21,168 @@
|
|||
#ifndef __MES_BUILTINS_H
|
||||
#define __MES_BUILTINS_H
|
||||
|
||||
// src/gc.mes
|
||||
SCM gc_check ();
|
||||
SCM gc ();
|
||||
// src/hash.mes
|
||||
SCM hashq (SCM x, SCM size);
|
||||
SCM hash (SCM x, SCM size);
|
||||
SCM hashq_get_handle (SCM table, SCM key, SCM dflt);
|
||||
SCM hashq_ref (SCM table, SCM key, SCM dflt);
|
||||
SCM hash_ref (SCM table, SCM key, SCM dflt);
|
||||
SCM hashq_set_x (SCM table, SCM key, SCM value);
|
||||
SCM hash_set_x (SCM table, SCM key, SCM value);
|
||||
SCM hash_table_printer (SCM table);
|
||||
SCM make_hash_table (SCM x);
|
||||
// src/lib.mes
|
||||
SCM procedure_name_ (SCM x);
|
||||
SCM display_ (SCM x);
|
||||
SCM display_error_ (SCM x);
|
||||
SCM display_port_ (SCM x, SCM p);
|
||||
SCM write_ (SCM x);
|
||||
SCM write_error_ (SCM x);
|
||||
SCM write_port_ (SCM x, SCM p);
|
||||
SCM exit_ (SCM x);
|
||||
SCM frame_printer (SCM frame);
|
||||
SCM make_stack (SCM stack);
|
||||
SCM stack_length (SCM stack);
|
||||
SCM stack_ref (SCM stack, SCM index);
|
||||
SCM xassq (SCM x, SCM a);
|
||||
SCM memq (SCM x, SCM a);
|
||||
SCM equal2_p (SCM a, SCM b);
|
||||
SCM last_pair (SCM x);
|
||||
SCM pair_p (SCM x);
|
||||
// src/math.mes
|
||||
SCM greater_p (SCM x);
|
||||
SCM less_p (SCM x);
|
||||
SCM is_p (SCM x);
|
||||
SCM minus (SCM x);
|
||||
SCM plus (SCM x);
|
||||
SCM divide (SCM x);
|
||||
SCM modulo (SCM a, SCM b);
|
||||
SCM multiply (SCM x);
|
||||
SCM logand (SCM x);
|
||||
SCM logior (SCM x);
|
||||
SCM lognot (SCM x);
|
||||
SCM logxor (SCM x);
|
||||
SCM ash (SCM n, SCM count);
|
||||
// src/mes.mes
|
||||
SCM make_cell_ (SCM type, SCM car, SCM cdr);
|
||||
SCM type_ (SCM x);
|
||||
SCM car_ (SCM x);
|
||||
SCM cdr_ (SCM x);
|
||||
SCM arity_ (SCM x);
|
||||
SCM cons (SCM x, SCM y);
|
||||
SCM car (SCM x);
|
||||
SCM cdr (SCM x);
|
||||
SCM list (SCM x);
|
||||
SCM null_p (SCM x);
|
||||
SCM eq_p (SCM x, SCM y);
|
||||
SCM values (SCM x);
|
||||
SCM acons (SCM key, SCM value, SCM alist);
|
||||
SCM length (SCM x);
|
||||
SCM error (SCM key, SCM x);
|
||||
SCM append2 (SCM x, SCM y);
|
||||
SCM append_reverse (SCM x, SCM y);
|
||||
SCM reverse_x_ (SCM x, SCM t);
|
||||
SCM pairlis (SCM x, SCM y, SCM a);
|
||||
SCM call (SCM fn, SCM x);
|
||||
SCM assq (SCM x, SCM a);
|
||||
SCM assoc (SCM x, SCM a);
|
||||
SCM set_car_x (SCM x, SCM e);
|
||||
SCM set_cdr_x (SCM x, SCM e);
|
||||
SCM set_env_x (SCM x, SCM e, SCM a);
|
||||
SCM macro_get_handle (SCM name);
|
||||
SCM add_formals (SCM formals, SCM x);
|
||||
SCM eval_apply ();
|
||||
SCM make_builtin_type ();
|
||||
SCM make_builtin (SCM builtin_type, SCM name, SCM arity, SCM function);
|
||||
SCM builtin_arity (SCM builtin);
|
||||
SCM builtin_p (SCM x);
|
||||
SCM builtin_printer (SCM builtin);
|
||||
// CONSTANT cell_nil 1
|
||||
#define cell_nil 1
|
||||
// CONSTANT cell_f 2
|
||||
#define cell_f 2
|
||||
// CONSTANT cell_t 3
|
||||
#define cell_t 3
|
||||
// CONSTANT cell_dot 4
|
||||
#define cell_dot 4
|
||||
// CONSTANT cell_arrow 5
|
||||
#define cell_arrow 5
|
||||
// CONSTANT cell_undefined 6
|
||||
#define cell_undefined 6
|
||||
// CONSTANT cell_unspecified 7
|
||||
#define cell_unspecified 7
|
||||
// CONSTANT cell_closure 8
|
||||
#define cell_closure 8
|
||||
// CONSTANT cell_circular 9
|
||||
#define cell_circular 9
|
||||
// CONSTANT cell_begin 10
|
||||
#define cell_begin 10
|
||||
// CONSTANT cell_call_with_current_continuation 11
|
||||
#define cell_call_with_current_continuation 11
|
||||
// CONSTANT cell_vm_apply 12
|
||||
#define cell_vm_apply 12
|
||||
// CONSTANT cell_vm_apply2 13
|
||||
#define cell_vm_apply2 13
|
||||
// CONSTANT cell_vm_begin 14
|
||||
#define cell_vm_begin 14
|
||||
// CONSTANT cell_vm_begin_eval 15
|
||||
#define cell_vm_begin_eval 15
|
||||
// CONSTANT cell_vm_begin_expand 16
|
||||
#define cell_vm_begin_expand 16
|
||||
// CONSTANT cell_vm_begin_expand_eval 17
|
||||
#define cell_vm_begin_expand_eval 17
|
||||
// CONSTANT cell_vm_begin_expand_macro 18
|
||||
#define cell_vm_begin_expand_macro 18
|
||||
// CONSTANT cell_vm_begin_expand_primitive_load 19
|
||||
#define cell_vm_begin_expand_primitive_load 19
|
||||
// CONSTANT cell_vm_begin_primitive_load 20
|
||||
#define cell_vm_begin_primitive_load 20
|
||||
// CONSTANT cell_vm_begin_read_input_file 21
|
||||
#define cell_vm_begin_read_input_file 21
|
||||
// CONSTANT cell_vm_call_with_current_continuation2 22
|
||||
#define cell_vm_call_with_current_continuation2 22
|
||||
// CONSTANT cell_vm_call_with_values2 23
|
||||
#define cell_vm_call_with_values2 23
|
||||
// CONSTANT cell_vm_eval 24
|
||||
#define cell_vm_eval 24
|
||||
// CONSTANT cell_vm_eval2 25
|
||||
#define cell_vm_eval2 25
|
||||
// CONSTANT cell_vm_eval_check_func 26
|
||||
#define cell_vm_eval_check_func 26
|
||||
// CONSTANT cell_vm_eval_define 27
|
||||
#define cell_vm_eval_define 27
|
||||
// CONSTANT cell_vm_eval_macro_expand_eval 28
|
||||
#define cell_vm_eval_macro_expand_eval 28
|
||||
// CONSTANT cell_vm_eval_macro_expand_expand 29
|
||||
#define cell_vm_eval_macro_expand_expand 29
|
||||
// CONSTANT cell_vm_eval_pmatch_car 30
|
||||
#define cell_vm_eval_pmatch_car 30
|
||||
// CONSTANT cell_vm_eval_pmatch_cdr 31
|
||||
#define cell_vm_eval_pmatch_cdr 31
|
||||
// CONSTANT cell_vm_eval_set_x 32
|
||||
#define cell_vm_eval_set_x 32
|
||||
// CONSTANT cell_vm_evlis 33
|
||||
#define cell_vm_evlis 33
|
||||
// CONSTANT cell_vm_evlis2 34
|
||||
#define cell_vm_evlis2 34
|
||||
// CONSTANT cell_vm_evlis3 35
|
||||
#define cell_vm_evlis3 35
|
||||
// CONSTANT cell_vm_if 36
|
||||
#define cell_vm_if 36
|
||||
// CONSTANT cell_vm_if_expr 37
|
||||
#define cell_vm_if_expr 37
|
||||
// CONSTANT cell_vm_macro_expand 38
|
||||
#define cell_vm_macro_expand 38
|
||||
// CONSTANT cell_vm_macro_expand_car 39
|
||||
#define cell_vm_macro_expand_car 39
|
||||
// CONSTANT cell_vm_macro_expand_cdr 40
|
||||
#define cell_vm_macro_expand_cdr 40
|
||||
// CONSTANT cell_vm_macro_expand_define 41
|
||||
#define cell_vm_macro_expand_define 41
|
||||
// CONSTANT cell_vm_macro_expand_define_macro 42
|
||||
#define cell_vm_macro_expand_define_macro 42
|
||||
// CONSTANT cell_vm_macro_expand_lambda 43
|
||||
#define cell_vm_macro_expand_lambda 43
|
||||
// CONSTANT cell_vm_macro_expand_set_x 44
|
||||
#define cell_vm_macro_expand_set_x 44
|
||||
// CONSTANT cell_vm_return 45
|
||||
#define cell_vm_return 45
|
||||
// CONSTANT cell_symbol_dot 46
|
||||
#define cell_symbol_dot 46
|
||||
// CONSTANT cell_symbol_lambda 47
|
||||
#define cell_symbol_lambda 47
|
||||
// CONSTANT cell_symbol_begin 48
|
||||
#define cell_symbol_begin 48
|
||||
// CONSTANT cell_symbol_if 49
|
||||
#define cell_symbol_if 49
|
||||
// CONSTANT cell_symbol_quote 50
|
||||
#define cell_symbol_quote 50
|
||||
// CONSTANT cell_symbol_define 51
|
||||
#define cell_symbol_define 51
|
||||
// CONSTANT cell_symbol_define_macro 52
|
||||
#define cell_symbol_define_macro 52
|
||||
// CONSTANT cell_symbol_quasiquote 53
|
||||
#define cell_symbol_quasiquote 53
|
||||
// CONSTANT cell_symbol_unquote 54
|
||||
#define cell_symbol_unquote 54
|
||||
// CONSTANT cell_symbol_unquote_splicing 55
|
||||
#define cell_symbol_unquote_splicing 55
|
||||
// CONSTANT cell_symbol_syntax 56
|
||||
#define cell_symbol_syntax 56
|
||||
// CONSTANT cell_symbol_quasisyntax 57
|
||||
#define cell_symbol_quasisyntax 57
|
||||
// CONSTANT cell_symbol_unsyntax 58
|
||||
#define cell_symbol_unsyntax 58
|
||||
// CONSTANT cell_symbol_unsyntax_splicing 59
|
||||
#define cell_symbol_unsyntax_splicing 59
|
||||
// CONSTANT cell_symbol_set_x 60
|
||||
#define cell_symbol_set_x 60
|
||||
// CONSTANT cell_symbol_sc_expand 61
|
||||
#define cell_symbol_sc_expand 61
|
||||
// CONSTANT cell_symbol_macro_expand 62
|
||||
#define cell_symbol_macro_expand 62
|
||||
// CONSTANT cell_symbol_portable_macro_expand 63
|
||||
#define cell_symbol_portable_macro_expand 63
|
||||
// CONSTANT cell_symbol_sc_expander_alist 64
|
||||
#define cell_symbol_sc_expander_alist 64
|
||||
// CONSTANT cell_symbol_call_with_values 65
|
||||
#define cell_symbol_call_with_values 65
|
||||
// CONSTANT cell_symbol_call_with_current_continuation 66
|
||||
#define cell_symbol_call_with_current_continuation 66
|
||||
// CONSTANT cell_symbol_boot_module 67
|
||||
#define cell_symbol_boot_module 67
|
||||
// CONSTANT cell_symbol_current_module 68
|
||||
#define cell_symbol_current_module 68
|
||||
// CONSTANT cell_symbol_primitive_load 69
|
||||
#define cell_symbol_primitive_load 69
|
||||
// CONSTANT cell_symbol_read_input_file 70
|
||||
#define cell_symbol_read_input_file 70
|
||||
// CONSTANT cell_symbol_write 71
|
||||
#define cell_symbol_write 71
|
||||
// CONSTANT cell_symbol_display 72
|
||||
#define cell_symbol_display 72
|
||||
// CONSTANT cell_symbol_car 73
|
||||
#define cell_symbol_car 73
|
||||
// CONSTANT cell_symbol_cdr 74
|
||||
#define cell_symbol_cdr 74
|
||||
// CONSTANT cell_symbol_not_a_number 75
|
||||
#define cell_symbol_not_a_number 75
|
||||
// CONSTANT cell_symbol_not_a_pair 76
|
||||
#define cell_symbol_not_a_pair 76
|
||||
// CONSTANT cell_symbol_system_error 77
|
||||
#define cell_symbol_system_error 77
|
||||
// CONSTANT cell_symbol_throw 78
|
||||
#define cell_symbol_throw 78
|
||||
// CONSTANT cell_symbol_unbound_variable 79
|
||||
#define cell_symbol_unbound_variable 79
|
||||
// CONSTANT cell_symbol_wrong_number_of_args 80
|
||||
#define cell_symbol_wrong_number_of_args 80
|
||||
// CONSTANT cell_symbol_wrong_type_arg 81
|
||||
#define cell_symbol_wrong_type_arg 81
|
||||
// CONSTANT cell_symbol_buckets 82
|
||||
#define cell_symbol_buckets 82
|
||||
// CONSTANT cell_symbol_builtin 83
|
||||
#define cell_symbol_builtin 83
|
||||
// CONSTANT cell_symbol_frame 84
|
||||
#define cell_symbol_frame 84
|
||||
// CONSTANT cell_symbol_hashq_table 85
|
||||
#define cell_symbol_hashq_table 85
|
||||
// CONSTANT cell_symbol_module 86
|
||||
#define cell_symbol_module 86
|
||||
// CONSTANT cell_symbol_procedure 87
|
||||
#define cell_symbol_procedure 87
|
||||
// CONSTANT cell_symbol_record_type 88
|
||||
#define cell_symbol_record_type 88
|
||||
// CONSTANT cell_symbol_size 89
|
||||
#define cell_symbol_size 89
|
||||
// CONSTANT cell_symbol_stack 90
|
||||
#define cell_symbol_stack 90
|
||||
// CONSTANT cell_symbol_argv 91
|
||||
#define cell_symbol_argv 91
|
||||
// CONSTANT cell_symbol_mes_prefix 92
|
||||
#define cell_symbol_mes_prefix 92
|
||||
// CONSTANT cell_symbol_mes_version 93
|
||||
#define cell_symbol_mes_version 93
|
||||
// CONSTANT cell_symbol_internal_time_units_per_second 94
|
||||
#define cell_symbol_internal_time_units_per_second 94
|
||||
// CONSTANT cell_symbol_compiler 95
|
||||
#define cell_symbol_compiler 95
|
||||
// CONSTANT cell_symbol_arch 96
|
||||
#define cell_symbol_arch 96
|
||||
// CONSTANT cell_symbol_pmatch_car 97
|
||||
#define cell_symbol_pmatch_car 97
|
||||
// CONSTANT cell_symbol_pmatch_cdr 98
|
||||
#define cell_symbol_pmatch_cdr 98
|
||||
// CONSTANT cell_type_bytes 99
|
||||
#define cell_type_bytes 99
|
||||
// CONSTANT cell_type_char 100
|
||||
#define cell_type_char 100
|
||||
// CONSTANT cell_type_closure 101
|
||||
#define cell_type_closure 101
|
||||
// CONSTANT cell_type_continuation 102
|
||||
#define cell_type_continuation 102
|
||||
// CONSTANT cell_type_function 103
|
||||
#define cell_type_function 103
|
||||
// CONSTANT cell_type_keyword 104
|
||||
#define cell_type_keyword 104
|
||||
// CONSTANT cell_type_macro 105
|
||||
#define cell_type_macro 105
|
||||
// CONSTANT cell_type_number 106
|
||||
#define cell_type_number 106
|
||||
// CONSTANT cell_type_pair 107
|
||||
#define cell_type_pair 107
|
||||
// CONSTANT cell_type_port 108
|
||||
#define cell_type_port 108
|
||||
// CONSTANT cell_type_ref 109
|
||||
#define cell_type_ref 109
|
||||
// CONSTANT cell_type_special 110
|
||||
#define cell_type_special 110
|
||||
// CONSTANT cell_type_string 111
|
||||
#define cell_type_string 111
|
||||
// CONSTANT cell_type_struct 112
|
||||
#define cell_type_struct 112
|
||||
// CONSTANT cell_type_symbol 113
|
||||
#define cell_type_symbol 113
|
||||
// CONSTANT cell_type_values 114
|
||||
#define cell_type_values 114
|
||||
// CONSTANT cell_type_variable 115
|
||||
#define cell_type_variable 115
|
||||
// CONSTANT cell_type_vector 116
|
||||
#define cell_type_vector 116
|
||||
// CONSTANT cell_type_broken_heart 117
|
||||
#define cell_type_broken_heart 117
|
||||
// CONSTANT cell_symbol_test 118
|
||||
#define cell_symbol_test 118
|
||||
// src/module.mes
|
||||
SCM make_module_type ();
|
||||
SCM module_printer (SCM module);
|
||||
SCM module_variable (SCM module, SCM name);
|
||||
SCM module_ref (SCM module, SCM name);
|
||||
SCM module_define_x (SCM module, SCM name, SCM value);
|
||||
// src/posix.mes
|
||||
SCM peek_byte ();
|
||||
SCM read_byte ();
|
||||
SCM unread_byte (SCM i);
|
||||
SCM peek_char ();
|
||||
SCM read_char (SCM port);
|
||||
SCM unread_char (SCM i);
|
||||
SCM write_char (SCM i);
|
||||
SCM write_byte (SCM x);
|
||||
SCM getenv_ (SCM s);
|
||||
SCM setenv_ (SCM s, SCM v);
|
||||
SCM access_p (SCM file_name, SCM mode);
|
||||
SCM current_input_port ();
|
||||
SCM open_input_file (SCM file_name);
|
||||
SCM open_input_string (SCM string);
|
||||
SCM set_current_input_port (SCM port);
|
||||
SCM current_output_port ();
|
||||
SCM current_error_port ();
|
||||
SCM open_output_file (SCM x);
|
||||
SCM set_current_output_port (SCM port);
|
||||
SCM set_current_error_port (SCM port);
|
||||
SCM force_output (SCM p);
|
||||
SCM chmod_ (SCM file_name, SCM mode);
|
||||
SCM isatty_p (SCM port);
|
||||
SCM primitive_fork ();
|
||||
SCM execl_ (SCM file_name, SCM args);
|
||||
SCM waitpid_ (SCM pid, SCM options);
|
||||
SCM current_time ();
|
||||
SCM gettimeofday_ ();
|
||||
SCM get_internal_run_time ();
|
||||
SCM getcwd_ ();
|
||||
SCM dup_ (SCM port);
|
||||
SCM dup2_ (SCM old, SCM new);
|
||||
SCM delete_file (SCM file_name);
|
||||
// src/reader.mes
|
||||
SCM read_input_file_env_ (SCM e, SCM a);
|
||||
SCM read_input_file_env (SCM a);
|
||||
SCM read_env (SCM a);
|
||||
SCM reader_read_sexp (SCM c, SCM s, SCM a);
|
||||
SCM reader_read_character ();
|
||||
SCM reader_read_binary ();
|
||||
SCM reader_read_octal ();
|
||||
SCM reader_read_hex ();
|
||||
SCM reader_read_string ();
|
||||
// src/strings.mes
|
||||
SCM string_equal_p (SCM a, SCM b);
|
||||
SCM symbol_to_string (SCM symbol);
|
||||
SCM symbol_to_keyword (SCM symbol);
|
||||
SCM keyword_to_string (SCM keyword);
|
||||
SCM string_to_symbol (SCM string);
|
||||
SCM make_symbol (SCM string);
|
||||
SCM string_to_list (SCM string);
|
||||
SCM list_to_string (SCM list);
|
||||
SCM read_string (SCM port);
|
||||
SCM string_append (SCM x);
|
||||
SCM string_length (SCM string);
|
||||
SCM string_ref (SCM str, SCM k);
|
||||
// src/struct.mes
|
||||
SCM make_struct (SCM type, SCM fields, SCM printer);
|
||||
SCM struct_length (SCM x);
|
||||
SCM struct_ref (SCM x, SCM i);
|
||||
SCM struct_set_x (SCM x, SCM i, SCM e);
|
||||
// src/vector.mes
|
||||
SCM make_vector_ (SCM n);
|
||||
SCM vector_length (SCM x);
|
||||
SCM vector_ref (SCM x, SCM i);
|
||||
SCM vector_entry (SCM x);
|
||||
SCM vector_set_x (SCM x, SCM i, SCM e);
|
||||
SCM list_to_vector (SCM x);
|
||||
SCM vector_to_list (SCM v);
|
||||
/* src/builtins.c */
|
||||
struct scm *make_builtin (struct scm *builtin_type, struct scm *name, struct scm *arity, struct scm *function);
|
||||
struct scm *builtin_name (struct scm *builtin);
|
||||
struct scm *builtin_arity (struct scm *builtin);
|
||||
struct scm *builtin_p (struct scm *x);
|
||||
struct scm *builtin_printer (struct scm *builtin);
|
||||
/* src/core.c */
|
||||
struct scm *car (struct scm *x);
|
||||
struct scm *cdr (struct scm *x);
|
||||
struct scm *list (struct scm *x);
|
||||
struct scm *null_p (struct scm *x);
|
||||
struct scm *eq_p (struct scm *x, struct scm *y);
|
||||
struct scm *values (struct scm *x);
|
||||
struct scm *acons (struct scm *key, struct scm *value, struct scm *alist);
|
||||
struct scm *length (struct scm *x);
|
||||
struct scm *error (struct scm *key, struct scm *x);
|
||||
struct scm *append2 (struct scm *x, struct scm *y);
|
||||
struct scm *append_reverse (struct scm *x, struct scm *y);
|
||||
struct scm *reverse_x_ (struct scm *x, struct scm *t);
|
||||
struct scm *assq (struct scm *x, struct scm *a);
|
||||
struct scm *assoc (struct scm *x, struct scm *a);
|
||||
/* src/display.c */
|
||||
struct scm *display_ (struct scm *x);
|
||||
struct scm *display_error_ (struct scm *x);
|
||||
struct scm *display_port_ (struct scm *x, struct scm *p);
|
||||
struct scm *write_ (struct scm *x);
|
||||
struct scm *write_error_ (struct scm *x);
|
||||
struct scm *write_port_ (struct scm *x, struct scm *p);
|
||||
/* src/eval-apply.c */
|
||||
struct scm *pairlis (struct scm *x, struct scm *y, struct scm *a);
|
||||
struct scm *set_car_x (struct scm *x, struct scm *e);
|
||||
struct scm *set_cdr_x (struct scm *x, struct scm *e);
|
||||
struct scm *add_formals (struct scm *formals, struct scm *x);
|
||||
struct scm *eval_apply ();
|
||||
/* src/gc.c */
|
||||
struct scm *cons (struct scm *x, struct scm *y);
|
||||
struct scm *make_variable (struct scm *var);
|
||||
struct scm *gc_check ();
|
||||
struct scm *gc ();
|
||||
/* src/hash.c */
|
||||
struct scm *hashq (struct scm *x, struct scm *size);
|
||||
struct scm *hash (struct scm *x, struct scm *size);
|
||||
struct scm *hashq_get_handle_ (struct scm *table, struct scm *key);
|
||||
struct scm *hashq_ref_ (struct scm *table, struct scm *key, struct scm *dflt);
|
||||
struct scm *hash_ref_ (struct scm *table, struct scm *key, struct scm *dflt);
|
||||
struct scm *hashq_set_handle_x (struct scm *table, struct scm *key, struct scm *value);
|
||||
struct scm *hashq_set_x (struct scm *table, struct scm *key, struct scm *value);
|
||||
struct scm *hash_set_x (struct scm *table, struct scm *key, struct scm *value);
|
||||
struct scm *hash_table_printer (struct scm *table);
|
||||
struct scm *make_hash_table (struct scm *x);
|
||||
struct scm *hash_table_p (struct scm *x);
|
||||
struct scm *hash_map_to_list (struct scm *proc, struct scm *table);
|
||||
struct scm *hash_clear_x (struct scm *table);
|
||||
/* src/lib.c */
|
||||
struct scm *type_ (struct scm *x);
|
||||
struct scm *car_ (struct scm *x);
|
||||
struct scm *cdr_ (struct scm *x);
|
||||
struct scm *xassq (struct scm *x, struct scm *a);
|
||||
struct scm *memq (struct scm *x, struct scm *a);
|
||||
struct scm *equal2_p (struct scm *a, struct scm *b);
|
||||
struct scm *last_pair (struct scm *x);
|
||||
struct scm *pair_p (struct scm *x);
|
||||
struct scm *char_to_integer (struct scm *x);
|
||||
struct scm *integer_to_char (struct scm *x);
|
||||
/* src/math.c */
|
||||
struct scm *greater_p (struct scm *x);
|
||||
struct scm *less_p (struct scm *x);
|
||||
struct scm *is_p (struct scm *x);
|
||||
struct scm *minus (struct scm *x);
|
||||
struct scm *plus (struct scm *x);
|
||||
struct scm *divide (struct scm *x);
|
||||
struct scm *modulo (struct scm *a, struct scm *b);
|
||||
struct scm *multiply (struct scm *x);
|
||||
struct scm *logand (struct scm *x);
|
||||
struct scm *logior (struct scm *x);
|
||||
struct scm *lognot (struct scm *x);
|
||||
struct scm *logxor (struct scm *x);
|
||||
struct scm *ash (struct scm *n, struct scm *count);
|
||||
/* src/module.c */
|
||||
struct scm *module_define_x (struct scm *module, struct scm *name, struct scm *value);
|
||||
struct scm *initial_module ();
|
||||
/* src/posix.c */
|
||||
struct scm *abort_ ();
|
||||
struct scm *exit_ (struct scm *x);
|
||||
struct scm *peek_byte ();
|
||||
struct scm *read_byte ();
|
||||
struct scm *unread_byte (struct scm *i);
|
||||
struct scm *peek_char ();
|
||||
struct scm *read_char (struct scm *port);
|
||||
struct scm *unread_char (struct scm *i);
|
||||
struct scm *write_char (struct scm *i);
|
||||
struct scm *write_byte (struct scm *x);
|
||||
struct scm *getenv_ (struct scm *s);
|
||||
struct scm *setenv_ (struct scm *s, struct scm *v);
|
||||
struct scm *access_p (struct scm *file_name, struct scm *mode);
|
||||
struct scm *current_input_port ();
|
||||
struct scm *open_input_file (struct scm *file_name);
|
||||
struct scm *open_input_string (struct scm *string);
|
||||
struct scm *set_current_input_port (struct scm *port);
|
||||
struct scm *current_output_port ();
|
||||
struct scm *current_error_port ();
|
||||
struct scm *open_output_file (struct scm *x);
|
||||
struct scm *set_current_output_port (struct scm *port);
|
||||
struct scm *set_current_error_port (struct scm *port);
|
||||
struct scm *chmod_ (struct scm *file_name, struct scm *mode);
|
||||
struct scm *isatty_p (struct scm *port);
|
||||
struct scm *primitive_fork ();
|
||||
struct scm *execl_ (struct scm *file_name, struct scm *args);
|
||||
struct scm *waitpid_ (struct scm *pid, struct scm *options);
|
||||
struct scm *current_time ();
|
||||
struct scm *gettimeofday_ ();
|
||||
struct scm *get_internal_run_time ();
|
||||
struct scm *getcwd_ ();
|
||||
struct scm *dup_ (struct scm *port);
|
||||
struct scm *dup2_ (struct scm *old, struct scm *new);
|
||||
struct scm *delete_file (struct scm *file_name);
|
||||
/* src/reader.c */
|
||||
struct scm *read_input_file_env_ (struct scm *e, struct scm *a);
|
||||
struct scm *read_input_file_env (struct scm *a);
|
||||
struct scm *read_env (struct scm *a);
|
||||
struct scm *reader_read_sexp (struct scm *c, struct scm *s, struct scm *a);
|
||||
struct scm *reader_read_character ();
|
||||
struct scm *reader_read_binary ();
|
||||
struct scm *reader_read_octal ();
|
||||
struct scm *reader_read_hex ();
|
||||
struct scm *reader_read_string ();
|
||||
/* src/stack.c */
|
||||
struct scm *frame_printer (struct scm *frame);
|
||||
struct scm *make_stack (struct scm *stack);
|
||||
struct scm *stack_length (struct scm *stack);
|
||||
struct scm *stack_ref (struct scm *stack, struct scm *index);
|
||||
/* src/string.c */
|
||||
struct scm *string_equal_p (struct scm *a, struct scm *b);
|
||||
struct scm *symbol_to_string (struct scm *symbol);
|
||||
struct scm *symbol_to_keyword (struct scm *symbol);
|
||||
struct scm *keyword_to_string (struct scm *keyword);
|
||||
struct scm *string_to_symbol (struct scm *string);
|
||||
struct scm *make_symbol (struct scm *string);
|
||||
struct scm *string_to_list (struct scm *string);
|
||||
struct scm *list_to_string (struct scm *list);
|
||||
struct scm *read_string (struct scm *port);
|
||||
struct scm *string_append (struct scm *x);
|
||||
struct scm *string_length (struct scm *string);
|
||||
struct scm *string_ref (struct scm *str, struct scm *k);
|
||||
/* src/struct.c */
|
||||
struct scm *make_struct (struct scm *type, struct scm *fields, struct scm *printer);
|
||||
struct scm *struct_length (struct scm *x);
|
||||
struct scm *struct_ref (struct scm *x, struct scm *i);
|
||||
struct scm *struct_set_x (struct scm *x, struct scm *i, struct scm *e);
|
||||
/* src/variable.c */
|
||||
struct scm *variable_ref (struct scm *var);
|
||||
struct scm *variable_set_x (struct scm *var, struct scm *value);
|
||||
struct scm *variable_bound_p (struct scm *var);
|
||||
struct scm *lookup_handle (struct scm *name, struct scm* define_p);
|
||||
struct scm *lookup_ref (struct scm *name, struct scm* bound_p);
|
||||
/* src/vector.c */
|
||||
struct scm *make_vector (struct scm *x);
|
||||
struct scm *vector_length (struct scm *x);
|
||||
struct scm *vector_ref (struct scm *x, struct scm *i);
|
||||
struct scm *vector_entry (struct scm *x);
|
||||
struct scm *vector_set_x (struct scm *x, struct scm *i, struct scm *e);
|
||||
struct scm *list_to_vector (struct scm *x);
|
||||
struct scm *vector_to_list (struct scm *v);
|
||||
|
||||
#endif //__MES_BUILTINS_H
|
||||
#endif /* __MES_BUILTINS_H */
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MES_CC_H
|
||||
#define __MES_CC_H
|
||||
|
||||
typedef struct scm* SCM;
|
||||
|
||||
#if __MESC__
|
||||
typedef long FUNCTION;
|
||||
typedef long function0_t;
|
||||
typedef long function1_t;
|
||||
typedef long function2_t;
|
||||
typedef long function3_t;
|
||||
typedef long functionn_t;
|
||||
#else // !__MESC__
|
||||
typedef SCM (*FUNCTION) (void);
|
||||
typedef SCM (*function0_t) (void);
|
||||
typedef SCM (*function1_t) (SCM);
|
||||
typedef SCM (*function2_t) (SCM, SCM);
|
||||
typedef SCM (*function3_t) (SCM, SCM, SCM);
|
||||
typedef SCM (*functionn_t) (SCM);
|
||||
#endif // !__MESC__
|
||||
|
||||
#endif //__MES_CC_H
|
|
@ -21,263 +21,13 @@
|
|||
#ifndef __MES_CONSTANTS_H
|
||||
#define __MES_CONSTANTS_H
|
||||
|
||||
/* Symbols */
|
||||
|
||||
// CONSTANT cell_nil 1
|
||||
#define cell_nil 1
|
||||
// CONSTANT cell_f 2
|
||||
#define cell_f 2
|
||||
// CONSTANT cell_t 3
|
||||
#define cell_t 3
|
||||
// CONSTANT cell_dot 4
|
||||
#define cell_dot 4
|
||||
// CONSTANT cell_arrow 5
|
||||
#define cell_arrow 5
|
||||
// CONSTANT cell_undefined 6
|
||||
#define cell_undefined 6
|
||||
// CONSTANT cell_unspecified 7
|
||||
#define cell_unspecified 7
|
||||
// CONSTANT cell_closure 8
|
||||
#define cell_closure 8
|
||||
// CONSTANT cell_circular 9
|
||||
#define cell_circular 9
|
||||
// CONSTANT cell_begin 10
|
||||
#define cell_begin 10
|
||||
// CONSTANT cell_call_with_current_continuation 11
|
||||
#define cell_call_with_current_continuation 11
|
||||
|
||||
// CONSTANT cell_vm_apply 12
|
||||
#define cell_vm_apply 12
|
||||
// CONSTANT cell_vm_apply2 13
|
||||
#define cell_vm_apply2 13
|
||||
// CONSTANT cell_vm_begin 14
|
||||
#define cell_vm_begin 14
|
||||
// CONSTANT cell_vm_begin_eval 15
|
||||
#define cell_vm_begin_eval 15
|
||||
// CONSTANT cell_vm_begin_expand 16
|
||||
#define cell_vm_begin_expand 16
|
||||
// CONSTANT cell_vm_begin_expand_eval 17
|
||||
#define cell_vm_begin_expand_eval 17
|
||||
// CONSTANT cell_vm_begin_expand_macro 18
|
||||
#define cell_vm_begin_expand_macro 18
|
||||
// CONSTANT cell_vm_begin_expand_primitive_load 19
|
||||
#define cell_vm_begin_expand_primitive_load 19
|
||||
// CONSTANT cell_vm_begin_primitive_load 20
|
||||
#define cell_vm_begin_primitive_load 20
|
||||
// CONSTANT cell_vm_begin_read_input_file 21
|
||||
#define cell_vm_begin_read_input_file 21
|
||||
// CONSTANT cell_vm_call_with_current_continuation2 22
|
||||
#define cell_vm_call_with_current_continuation2 22
|
||||
// CONSTANT cell_vm_call_with_values2 23
|
||||
#define cell_vm_call_with_values2 23
|
||||
// CONSTANT cell_vm_eval 24
|
||||
#define cell_vm_eval 24
|
||||
// CONSTANT cell_vm_eval2 25
|
||||
#define cell_vm_eval2 25
|
||||
// CONSTANT cell_vm_eval_check_func 26
|
||||
#define cell_vm_eval_check_func 26
|
||||
// CONSTANT cell_vm_eval_define 27
|
||||
#define cell_vm_eval_define 27
|
||||
// CONSTANT cell_vm_eval_macro_expand_eval 28
|
||||
#define cell_vm_eval_macro_expand_eval 28
|
||||
// CONSTANT cell_vm_eval_macro_expand_expand 29
|
||||
#define cell_vm_eval_macro_expand_expand 29
|
||||
// CONSTANT cell_vm_eval_pmatch_car 30
|
||||
#define cell_vm_eval_pmatch_car 30
|
||||
// CONSTANT cell_vm_eval_pmatch_cdr 31
|
||||
#define cell_vm_eval_pmatch_cdr 31
|
||||
// CONSTANT cell_vm_eval_set_x 32
|
||||
#define cell_vm_eval_set_x 32
|
||||
// CONSTANT cell_vm_evlis 33
|
||||
#define cell_vm_evlis 33
|
||||
// CONSTANT cell_vm_evlis2 34
|
||||
#define cell_vm_evlis2 34
|
||||
// CONSTANT cell_vm_evlis3 35
|
||||
#define cell_vm_evlis3 35
|
||||
// CONSTANT cell_vm_if 36
|
||||
#define cell_vm_if 36
|
||||
// CONSTANT cell_vm_if_expr 37
|
||||
#define cell_vm_if_expr 37
|
||||
// CONSTANT cell_vm_macro_expand 38
|
||||
#define cell_vm_macro_expand 38
|
||||
// CONSTANT cell_vm_macro_expand_car 39
|
||||
#define cell_vm_macro_expand_car 39
|
||||
// CONSTANT cell_vm_macro_expand_cdr 40
|
||||
#define cell_vm_macro_expand_cdr 40
|
||||
// CONSTANT cell_vm_macro_expand_define 41
|
||||
#define cell_vm_macro_expand_define 41
|
||||
// CONSTANT cell_vm_macro_expand_define_macro 42
|
||||
#define cell_vm_macro_expand_define_macro 42
|
||||
// CONSTANT cell_vm_macro_expand_lambda 43
|
||||
#define cell_vm_macro_expand_lambda 43
|
||||
// CONSTANT cell_vm_macro_expand_set_x 44
|
||||
#define cell_vm_macro_expand_set_x 44
|
||||
// CONSTANT cell_vm_return 45
|
||||
#define cell_vm_return 45
|
||||
|
||||
// CONSTANT cell_symbol_dot 46
|
||||
#define cell_symbol_dot 46
|
||||
// CONSTANT cell_symbol_lambda 47
|
||||
#define cell_symbol_lambda 47
|
||||
// CONSTANT cell_symbol_begin 48
|
||||
#define cell_symbol_begin 48
|
||||
// CONSTANT cell_symbol_if 49
|
||||
#define cell_symbol_if 49
|
||||
// CONSTANT cell_symbol_quote 50
|
||||
#define cell_symbol_quote 50
|
||||
// CONSTANT cell_symbol_define 51
|
||||
#define cell_symbol_define 51
|
||||
// CONSTANT cell_symbol_define_macro 52
|
||||
#define cell_symbol_define_macro 52
|
||||
|
||||
// CONSTANT cell_symbol_quasiquote 53
|
||||
#define cell_symbol_quasiquote 53
|
||||
// CONSTANT cell_symbol_unquote 54
|
||||
#define cell_symbol_unquote 54
|
||||
// CONSTANT cell_symbol_unquote_splicing 55
|
||||
#define cell_symbol_unquote_splicing 55
|
||||
// CONSTANT cell_symbol_syntax 56
|
||||
#define cell_symbol_syntax 56
|
||||
// CONSTANT cell_symbol_quasisyntax 57
|
||||
#define cell_symbol_quasisyntax 57
|
||||
// CONSTANT cell_symbol_unsyntax 58
|
||||
#define cell_symbol_unsyntax 58
|
||||
// CONSTANT cell_symbol_unsyntax_splicing 59
|
||||
#define cell_symbol_unsyntax_splicing 59
|
||||
|
||||
// CONSTANT cell_symbol_set_x 60
|
||||
#define cell_symbol_set_x 60
|
||||
|
||||
// CONSTANT cell_symbol_sc_expand 61
|
||||
#define cell_symbol_sc_expand 61
|
||||
// CONSTANT cell_symbol_macro_expand 62
|
||||
#define cell_symbol_macro_expand 62
|
||||
// CONSTANT cell_symbol_portable_macro_expand 63
|
||||
#define cell_symbol_portable_macro_expand 63
|
||||
// CONSTANT cell_symbol_sc_expander_alist 64
|
||||
#define cell_symbol_sc_expander_alist 64
|
||||
|
||||
// CONSTANT cell_symbol_call_with_values 65
|
||||
#define cell_symbol_call_with_values 65
|
||||
// CONSTANT cell_symbol_call_with_current_continuation 66
|
||||
#define cell_symbol_call_with_current_continuation 66
|
||||
// CONSTANT cell_symbol_boot_module 67
|
||||
#define cell_symbol_boot_module 67
|
||||
// CONSTANT cell_symbol_current_module 68
|
||||
#define cell_symbol_current_module 68
|
||||
// CONSTANT cell_symbol_primitive_load 69
|
||||
#define cell_symbol_primitive_load 69
|
||||
// CONSTANT cell_symbol_read_input_file 70
|
||||
#define cell_symbol_read_input_file 70
|
||||
// CONSTANT cell_symbol_write 71
|
||||
#define cell_symbol_write 71
|
||||
// CONSTANT cell_symbol_display 72
|
||||
#define cell_symbol_display 72
|
||||
|
||||
// CONSTANT cell_symbol_car 73
|
||||
#define cell_symbol_car 73
|
||||
// CONSTANT cell_symbol_cdr 74
|
||||
#define cell_symbol_cdr 74
|
||||
// CONSTANT cell_symbol_not_a_number 75
|
||||
#define cell_symbol_not_a_number 75
|
||||
// CONSTANT cell_symbol_not_a_pair 76
|
||||
#define cell_symbol_not_a_pair 76
|
||||
// CONSTANT cell_symbol_system_error 77
|
||||
#define cell_symbol_system_error 77
|
||||
// CONSTANT cell_symbol_throw 78
|
||||
#define cell_symbol_throw 78
|
||||
// CONSTANT cell_symbol_unbound_variable 79
|
||||
#define cell_symbol_unbound_variable 79
|
||||
// CONSTANT cell_symbol_wrong_number_of_args 80
|
||||
#define cell_symbol_wrong_number_of_args 80
|
||||
// CONSTANT cell_symbol_wrong_type_arg 81
|
||||
#define cell_symbol_wrong_type_arg 81
|
||||
|
||||
// CONSTANT cell_symbol_buckets 82
|
||||
#define cell_symbol_buckets 82
|
||||
// CONSTANT cell_symbol_builtin 83
|
||||
#define cell_symbol_builtin 83
|
||||
// CONSTANT cell_symbol_frame 84
|
||||
#define cell_symbol_frame 84
|
||||
// CONSTANT cell_symbol_hashq_table 85
|
||||
#define cell_symbol_hashq_table 85
|
||||
// CONSTANT cell_symbol_module 86
|
||||
#define cell_symbol_module 86
|
||||
// CONSTANT cell_symbol_procedure 87
|
||||
#define cell_symbol_procedure 87
|
||||
// CONSTANT cell_symbol_record_type 88
|
||||
#define cell_symbol_record_type 88
|
||||
// CONSTANT cell_symbol_size 89
|
||||
#define cell_symbol_size 89
|
||||
// CONSTANT cell_symbol_stack 90
|
||||
#define cell_symbol_stack 90
|
||||
|
||||
// CONSTANT cell_symbol_argv 91
|
||||
#define cell_symbol_argv 91
|
||||
// CONSTANT cell_symbol_mes_datadir 92
|
||||
#define cell_symbol_mes_datadir 92
|
||||
// CONSTANT cell_symbol_mes_version 93
|
||||
#define cell_symbol_mes_version 93
|
||||
|
||||
// CONSTANT cell_symbol_internal_time_units_per_second 94
|
||||
#define cell_symbol_internal_time_units_per_second 94
|
||||
// CONSTANT cell_symbol_compiler 95
|
||||
#define cell_symbol_compiler 95
|
||||
// CONSTANT cell_symbol_arch 96
|
||||
#define cell_symbol_arch 96
|
||||
// CONSTANT cell_symbol_pmatch_car 97
|
||||
#define cell_symbol_pmatch_car 97
|
||||
// CONSTANT cell_symbol_pmatch_cdr 98
|
||||
#define cell_symbol_pmatch_cdr 98
|
||||
|
||||
// CONSTANT cell_type_bytes 99
|
||||
#define cell_type_bytes 99
|
||||
// CONSTANT cell_type_char 100
|
||||
#define cell_type_char 100
|
||||
// CONSTANT cell_type_closure 101
|
||||
#define cell_type_closure 101
|
||||
// CONSTANT cell_type_continuation 102
|
||||
#define cell_type_continuation 102
|
||||
// CONSTANT cell_type_function 103
|
||||
#define cell_type_function 103
|
||||
// CONSTANT cell_type_keyword 104
|
||||
#define cell_type_keyword 104
|
||||
// CONSTANT cell_type_macro 105
|
||||
#define cell_type_macro 105
|
||||
// CONSTANT cell_type_number 106
|
||||
#define cell_type_number 106
|
||||
// CONSTANT cell_type_pair 107
|
||||
#define cell_type_pair 107
|
||||
// CONSTANT cell_type_port 108
|
||||
#define cell_type_port 108
|
||||
// CONSTANT cell_type_ref 109
|
||||
#define cell_type_ref 109
|
||||
// CONSTANT cell_type_special 110
|
||||
#define cell_type_special 110
|
||||
// CONSTANT cell_type_string 111
|
||||
#define cell_type_string 111
|
||||
// CONSTANT cell_type_struct 112
|
||||
#define cell_type_struct 112
|
||||
// CONSTANT cell_type_symbol 113
|
||||
#define cell_type_symbol 113
|
||||
// CONSTANT cell_type_values 114
|
||||
#define cell_type_values 114
|
||||
// CONSTANT cell_type_variable 115
|
||||
#define cell_type_variable 115
|
||||
// CONSTANT cell_type_vector 116
|
||||
#define cell_type_vector 116
|
||||
// CONSTANT cell_type_broken_heart 117
|
||||
#define cell_type_broken_heart 117
|
||||
|
||||
// CONSTANT cell_test 118
|
||||
#define cell_test 118
|
||||
|
||||
/* Cell types */
|
||||
|
||||
// CONSTANT TBYTES 0
|
||||
#define TBYTES 0
|
||||
// CONSTANT TCHAR 1
|
||||
#define TCHAR 1
|
||||
// CONSTANT TCHAR 0
|
||||
#define TCHAR 0
|
||||
|
||||
// CONSTANT TBYTES 1
|
||||
#define TBYTES 1
|
||||
// CONSTANT TCLOSURE 2
|
||||
#define TCLOSURE 2
|
||||
// CONSTANT TCONTINUATION 3
|
||||
|
@ -318,7 +68,37 @@
|
|||
// CONSTANT STRUCT_PRINTER 1
|
||||
#define STRUCT_PRINTER 1
|
||||
|
||||
// CONSTANT FRAME_SIZE 5
|
||||
#define FRAME_SIZE 5
|
||||
// CONSTANT FRAME_PROCEDURE 4
|
||||
#define FRAME_PROCEDURE 4
|
||||
|
||||
#endif //__MES_CONSTANTS_H
|
||||
// CONSTANT MODULE_DEFINES 3
|
||||
#define MODULE_DEFINES 3
|
||||
|
||||
// CONSTANT MODULE_USES 4
|
||||
#define MODULE_USES 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 */
|
||||
|
|
|
@ -23,12 +23,26 @@
|
|||
|
||||
#include <mes/lib-mini.h>
|
||||
|
||||
char* cast_intp_to_charp (int const *i);
|
||||
char* cast_long_to_charp (long i);
|
||||
long cast_charp_to_long (char const *);
|
||||
long cast_int_to_long (int i);
|
||||
long cast_voidp_to_long (void const *);
|
||||
|
||||
// #define cast_intp_to_charp(x) ((char*) x)
|
||||
// #define cast_long_to_charp(x) ((char*) x)
|
||||
// #define cast_charp_to_long(x) ((long) x)
|
||||
// #define cast_int_to_long(x) ((long) x)
|
||||
// #define cast_voidp_to_long(x) ((long) x)
|
||||
|
||||
int __mes_debug ();
|
||||
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);
|
||||
|
@ -50,6 +64,7 @@ int oputc (int c);
|
|||
int oputs (char const *s);
|
||||
char *search_path (char const *file_name);
|
||||
ssize_t _read (int fd, void *buffer, size_t size);
|
||||
void assert_msg (int check, char *msg);
|
||||
|
||||
extern char *__brk;
|
||||
extern void (*__call_at_exit) (void);
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MES_MACROS_H
|
||||
#define __MES_MACROS_H
|
||||
|
||||
#define TYPE(x) g_cells[x].type
|
||||
#define CAR(x) g_cells[x].car
|
||||
#define CDR(x) g_cells[x].cdr
|
||||
|
||||
#define NTYPE(x) g_news[x].type
|
||||
#define NCAR(x) g_news[x].car
|
||||
#define NCDR(x) g_news[x].cdr
|
||||
|
||||
#define BYTES(x) g_cells[x].car
|
||||
#define LENGTH(x) g_cells[x].car
|
||||
#define REF(x) g_cells[x].car
|
||||
#define START(x) (g_cells[x].car >> 16)
|
||||
#define LEN(x) (g_cells[x].car & 0xffff)
|
||||
#define VARIABLE(x) g_cells[x].car
|
||||
|
||||
#define CLOSURE(x) g_cells[x].cdr
|
||||
#define CONTINUATION(x) g_cells[x].cdr
|
||||
|
||||
#define CBYTES(x) (char*)&g_cells[x].cdr
|
||||
#define CSTRING_STRUCT(x) (char*)&g_cells[x.cdr].cdr
|
||||
|
||||
#define MACRO(x) g_cells[x].car
|
||||
#define NAME(x) g_cells[x].cdr
|
||||
#define PORT(x) g_cells[x].car
|
||||
#define STRING(x) g_cells[x].cdr
|
||||
#define STRUCT(x) g_cells[x].cdr
|
||||
#define VALUE(x) g_cells[x].cdr
|
||||
#define VECTOR(x) g_cells[x].cdr
|
||||
|
||||
#define NLENGTH(x) g_news[x].car
|
||||
#define NCBYTES(x) (char*)&g_news[x].cdr
|
||||
#define NVALUE(x) g_news[x].cdr
|
||||
#define NSTRING(x) g_news[x].cdr
|
||||
#define NVECTOR(x) g_news[x].cdr
|
||||
|
||||
#define CSTRING(x) CBYTES (STRING (x))
|
||||
|
||||
#define MAKE_BYTES0(x) make_bytes (x, strlen (x))
|
||||
#define NAME_SYMBOL(symbol,name) {size_t s = strlen (name); CAR (symbol) = s; CDR (symbol) = make_bytes (name, s);}
|
||||
|
||||
#define MAKE_CHAR(n) make_cell__ (TCHAR, 0, n)
|
||||
#define MAKE_CONTINUATION(n) make_cell__ (TCONTINUATION, n, g_stack)
|
||||
#define MAKE_NUMBER(n) make_cell__ (TNUMBER, 0, (long)n)
|
||||
#define MAKE_REF(n) make_cell__ (TREF, n, 0)
|
||||
#define MAKE_STRING0(x) make_string (x, strlen (x))
|
||||
#define MAKE_STRING_PORT(x) make_cell__ (TPORT, -length__ (g_ports) - 2, x)
|
||||
#define MAKE_MACRO(name, x) make_cell__ (TMACRO, x, STRING (name))
|
||||
|
||||
#define CAAR(x) CAR (CAR (x))
|
||||
#define CADR(x) CAR (CDR (x))
|
||||
#define CDAR(x) CDR (CAR (x))
|
||||
#define CDDR(x) CDR (CDR (x))
|
||||
#define CADAR(x) CAR (CDR (CAR (x)))
|
||||
#define CADDR(x) CAR (CDR (CDR (x)))
|
||||
#define CDADAR(x) CAR (CDR (CAR (CDR (x))))
|
||||
|
||||
#endif //__MES_MACROS_H
|
|
@ -22,85 +22,174 @@
|
|||
#define __MES_MES_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef long SCM;
|
||||
#include "mes/cc.h"
|
||||
|
||||
struct scm
|
||||
{
|
||||
long type;
|
||||
SCM car;
|
||||
SCM cdr;
|
||||
union
|
||||
{
|
||||
struct scm *car;
|
||||
long car_value;
|
||||
char *bytes;
|
||||
long length;
|
||||
struct scm *ref;
|
||||
struct scm *variable;
|
||||
struct scm *macro;
|
||||
long port;
|
||||
};
|
||||
union
|
||||
{
|
||||
struct scm *cdr;
|
||||
long cdr_value;
|
||||
struct scm *closure;
|
||||
struct scm *continuation;
|
||||
char *name;
|
||||
struct scm *string;
|
||||
struct scm *structure;
|
||||
long value;
|
||||
FUNCTION function;
|
||||
struct scm *vector;
|
||||
};
|
||||
};
|
||||
|
||||
// mes
|
||||
extern int g_debug;
|
||||
extern char *g_buf;
|
||||
extern SCM g_continuations;
|
||||
extern SCM g_symbols;
|
||||
extern SCM g_symbol_max;
|
||||
/* mes */
|
||||
char *g_datadir;
|
||||
int g_debug;
|
||||
char *g_buf;
|
||||
int g_continuations;
|
||||
struct scm *g_symbols;
|
||||
struct scm *g_symbol_max;
|
||||
int g_mini;
|
||||
|
||||
// a/env
|
||||
extern SCM r0;
|
||||
// param 1
|
||||
extern SCM r1;
|
||||
// save 2
|
||||
extern SCM r2;
|
||||
// continuation
|
||||
extern SCM r3;
|
||||
// current-module
|
||||
extern SCM m0;
|
||||
// macro
|
||||
extern SCM g_macros;
|
||||
extern SCM g_ports;
|
||||
/* a/env */
|
||||
struct scm *R0;
|
||||
/* param 1 */
|
||||
struct scm *R1;
|
||||
/* save 2 */
|
||||
struct scm *R2;
|
||||
/* continuation */
|
||||
struct scm *R3;
|
||||
/* initial module */
|
||||
struct scm *M0;
|
||||
/* macro */
|
||||
struct scm *g_macros;
|
||||
struct scm *g_ports;
|
||||
|
||||
// gc
|
||||
extern long ARENA_SIZE;
|
||||
extern long MAX_ARENA_SIZE;
|
||||
extern long STACK_SIZE;
|
||||
extern long JAM_SIZE;
|
||||
extern long GC_SAFETY;
|
||||
extern long MAX_STRING;
|
||||
extern char *g_arena;
|
||||
extern long g_free;
|
||||
extern SCM g_stack;
|
||||
extern SCM *g_stack_array;
|
||||
extern struct scm *g_cells;
|
||||
extern struct scm *g_news;
|
||||
/* gc */
|
||||
long ARENA_SIZE;
|
||||
long MAX_ARENA_SIZE;
|
||||
long STACK_SIZE;
|
||||
long JAM_SIZE;
|
||||
long GC_SAFETY;
|
||||
long MAX_STRING;
|
||||
char *g_arena;
|
||||
struct scm *cell_arena;
|
||||
struct scm *cell_zero;
|
||||
|
||||
SCM alloc (long n);
|
||||
SCM apply (SCM f, SCM x, SCM a);
|
||||
SCM apply_builtin (SCM fn, SCM x);
|
||||
SCM cstring_to_list (char const *s);
|
||||
SCM cstring_to_symbol (char const *s);
|
||||
SCM display_ (SCM x);
|
||||
SCM fdisplay_ (SCM, int, int);
|
||||
SCM gc_init ();
|
||||
SCM gc_peek_frame ();
|
||||
SCM gc_pop_frame ();
|
||||
SCM gc_push_frame ();
|
||||
SCM init_time (SCM a);
|
||||
SCM make_bytes (char const *s, size_t length);
|
||||
SCM make_cell__ (long type, SCM car, SCM cdr);
|
||||
SCM make_hash_table_ (long size);
|
||||
SCM make_hashq_type ();
|
||||
SCM make_initial_module (SCM a);
|
||||
SCM make_string (char const *s, size_t length);
|
||||
SCM make_vector__ (long k);
|
||||
SCM read_input_file_env (SCM);
|
||||
SCM string_equal_p (SCM a, SCM b);
|
||||
SCM struct_ref_ (SCM x, long i);
|
||||
SCM struct_set_x_ (SCM x, long i, SCM e);
|
||||
SCM vector_ref_ (SCM x, long i);
|
||||
SCM vector_set_x_ (SCM x, long i, SCM e);
|
||||
struct scm *g_free;
|
||||
struct scm *g_symbol;
|
||||
|
||||
struct scm **g_stack_array;
|
||||
struct scm *g_cells;
|
||||
struct scm *g_news;
|
||||
long g_stack;
|
||||
|
||||
char **__execl_c_argv;
|
||||
char *__getcwd_buf;
|
||||
char *__open_boot_buf;
|
||||
char *__open_boot_file_name;
|
||||
char *__setenv_buf;
|
||||
char *__reader_read_char_buf;
|
||||
struct timespec *g_start_time;
|
||||
struct timeval *__gettimeofday_time;
|
||||
struct timespec *__get_internal_run_time_ts;
|
||||
|
||||
struct scm *scm_hash_table_type;
|
||||
|
||||
struct scm *cast_charp_to_scmp (char const *i);
|
||||
struct scm ** cast_charp_to_scmpp (char const *i);
|
||||
char* cast_voidp_to_charp (void const *i);
|
||||
long cast_scmp_to_long (struct scm *i);
|
||||
char* cast_scmp_to_charp (struct scm *i);
|
||||
|
||||
// #define cast_voidp_to_charp(x) ((char*) x)
|
||||
// #define cast_charp_to_scmp(x) ((struct scm *) x)
|
||||
// #define cast_charp_to_scmpp(x) ((struct scm **) x)
|
||||
// #define cast_scmp_to_long(x) ((long) x)
|
||||
// #define cast_scmp_to_charp(x) ((char*) x)
|
||||
|
||||
struct scm *alloc (long n);
|
||||
struct scm *apply (struct scm *f, struct scm *x, struct scm *a);
|
||||
struct scm *apply_builtin (struct scm *fn, struct scm *x);
|
||||
struct scm *apply_builtin0 (struct scm *fn);
|
||||
struct scm *apply_builtin1 (struct scm *fn, struct scm *x);
|
||||
struct scm *apply_builtin2 (struct scm *fn, struct scm *x, struct scm *y);
|
||||
struct scm *apply_builtin3 (struct scm *fn, struct scm *x, struct scm *y, struct scm *z);
|
||||
struct scm *builtin_name (struct scm *builtin);
|
||||
struct scm *cell_ref (struct scm *cell, long index);
|
||||
struct scm *cstring_to_list (char const *s);
|
||||
struct scm *cstring_to_symbol (char const *s);
|
||||
struct scm *current_module ();
|
||||
struct scm *deep_variable_ref (struct scm *var);
|
||||
struct scm *fdisplay_ (struct scm *, int, int);
|
||||
struct scm *handle_set_x (struct scm *name, struct scm *value);
|
||||
struct scm *init_symbols ();
|
||||
struct scm *init_time (struct scm *a);
|
||||
struct scm *lookup_handle (struct scm *name, struct scm *define_p);
|
||||
struct scm *lookup_ref_ (char const *name);
|
||||
struct scm *make_builtin_type ();
|
||||
struct scm *make_bytes (char const *s, size_t length);
|
||||
struct scm *make_cell (long type, struct scm *car, struct scm *cdr);
|
||||
struct scm *make_pointer_cell (long type, long car, void *cdr);
|
||||
struct scm *make_value_cell (long type, long car, long cdr);
|
||||
struct scm *make_char (int n);
|
||||
struct scm *make_continuation (long n);
|
||||
struct scm *make_hash_table_ (long size);
|
||||
struct scm *make_hash_table_type ();
|
||||
struct scm *make_initial_module (struct scm *a);
|
||||
struct scm *make_macro (struct scm *name, struct scm *x);
|
||||
struct scm *make_number (long n);
|
||||
struct scm *make_ref (struct scm *x);
|
||||
struct scm *make_string (char const *s, size_t length);
|
||||
struct scm *make_string0 (char const *s);
|
||||
struct scm *make_string_port (struct scm *x);
|
||||
struct scm *make_vector_ (long k, struct scm *e);
|
||||
struct scm *mes_builtins (struct scm *a);
|
||||
struct scm *module_defines (struct scm *module);
|
||||
struct scm *module_handle (struct scm *module, struct scm *name);
|
||||
struct scm *module_variable (struct scm *module, struct scm *name);
|
||||
struct scm *push_cc (struct scm *p1, struct scm *p2, struct scm *a, struct scm *c);
|
||||
struct scm *set_x (struct scm *x, struct scm *e);
|
||||
struct scm *struct_ref_ (struct scm *x, long i);
|
||||
struct scm *struct_set_x_ (struct scm *x, long i, struct scm *e);
|
||||
struct scm *vector_ref_ (struct scm *x, long i);
|
||||
struct scm *vector_set_x_ (struct scm *x, long i, struct scm *e);
|
||||
FUNCTION builtin_function (struct scm *builtin);
|
||||
char *cell_bytes (struct scm *x);
|
||||
char *news_bytes (struct scm *x);
|
||||
int peekchar ();
|
||||
int readchar ();
|
||||
int unreadchar ();
|
||||
long length__ (SCM x);
|
||||
long gc_free ();
|
||||
long length__ (struct scm *x);
|
||||
size_t bytes_cells (size_t length);
|
||||
void assert_max_string (size_t i, char const *msg, char *string);
|
||||
void assert_max_string (size_t i, char const *msg, char const *string);
|
||||
void assert_msg (int check, char *msg);
|
||||
void assert_number (char const *name, struct scm *x);
|
||||
void assert_variable (long pos, struct scm *x);
|
||||
void copy_cell (struct scm *to, struct scm *from);
|
||||
void gc_ ();
|
||||
void gc_dump_arena (struct scm *cells, long size);
|
||||
void gc_init ();
|
||||
void gc_peek_frame ();
|
||||
void gc_pop_frame ();
|
||||
void gc_push_frame ();
|
||||
void gc_stats_ (char const* where);
|
||||
void init_symbols_ ();
|
||||
|
||||
#include "mes/builtins.h"
|
||||
#include "mes/constants.h"
|
||||
#include "mes/macros.h"
|
||||
#include "mes/symbols.h"
|
||||
|
||||
#endif //__MES_MES_H
|
||||
#endif /* __MES_MES_H */
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MES_SYMBOLS_H
|
||||
#define __MES_SYMBOLS_H
|
||||
|
||||
struct scm *cell_nil;
|
||||
struct scm *cell_f;
|
||||
struct scm *cell_t;
|
||||
struct scm *cell_dot;
|
||||
struct scm *cell_arrow;
|
||||
struct scm *cell_undefined;
|
||||
struct scm *cell_unspecified;
|
||||
struct scm *cell_closure;
|
||||
struct scm *cell_circular;
|
||||
|
||||
struct scm *cell_vm_apply;
|
||||
struct scm *cell_vm_apply2;
|
||||
struct scm *cell_vm_begin;
|
||||
struct scm *cell_vm_begin_eval;
|
||||
struct scm *cell_vm_begin_expand;
|
||||
struct scm *cell_vm_begin_expand_eval;
|
||||
struct scm *cell_vm_begin_expand_macro;
|
||||
struct scm *cell_vm_begin_expand_primitive_load;
|
||||
struct scm *cell_vm_begin_primitive_load;
|
||||
struct scm *cell_vm_primitive_load_return;
|
||||
struct scm *cell_vm_begin_read_input_file;
|
||||
struct scm *cell_vm_call_with_current_continuation2;
|
||||
struct scm *cell_vm_call_with_values2;
|
||||
struct scm *cell_vm_eval;
|
||||
struct scm *cell_vm_eval2;
|
||||
struct scm *cell_vm_eval_check_func;
|
||||
struct scm *cell_vm_eval_define;
|
||||
struct scm *cell_vm_eval_macro_expand_eval;
|
||||
struct scm *cell_vm_eval_macro_expand_expand;
|
||||
struct scm *cell_vm_eval_pmatch_car;
|
||||
struct scm *cell_vm_eval_pmatch_cdr;
|
||||
struct scm *cell_vm_eval_set_x;
|
||||
struct scm *cell_vm_evlis;
|
||||
struct scm *cell_vm_evlis2;
|
||||
struct scm *cell_vm_evlis3;
|
||||
struct scm *cell_vm_if;
|
||||
struct scm *cell_vm_if_expr;
|
||||
struct scm *cell_vm_macro_expand;
|
||||
struct scm *cell_vm_macro_expand_car;
|
||||
struct scm *cell_vm_macro_expand_cdr;
|
||||
struct scm *cell_vm_macro_expand_define;
|
||||
struct scm *cell_vm_macro_expand_define_macro;
|
||||
struct scm *cell_vm_macro_expand_lambda;
|
||||
struct scm *cell_vm_macro_expand_set_x;
|
||||
struct scm *cell_vm_return;
|
||||
|
||||
struct scm *cell_symbol_lambda;
|
||||
struct scm *cell_symbol_begin;
|
||||
struct scm *cell_symbol_if;
|
||||
struct scm *cell_symbol_quote;
|
||||
struct scm *cell_symbol_define;
|
||||
struct scm *cell_symbol_define_macro;
|
||||
struct scm *cell_symbol_quasiquote;
|
||||
struct scm *cell_symbol_unquote;
|
||||
struct scm *cell_symbol_unquote_splicing;
|
||||
struct scm *cell_symbol_syntax;
|
||||
struct scm *cell_symbol_quasisyntax;
|
||||
struct scm *cell_symbol_unsyntax;
|
||||
struct scm *cell_symbol_unsyntax_splicing;
|
||||
struct scm *cell_symbol_set_x;
|
||||
struct scm *cell_symbol_sc_expand;
|
||||
struct scm *cell_symbol_macro_expand;
|
||||
struct scm *cell_symbol_portable_macro_expand;
|
||||
struct scm *cell_symbol_sc_expander_alist;
|
||||
struct scm *cell_symbol_call_with_values;
|
||||
struct scm *cell_symbol_call_with_current_continuation;
|
||||
struct scm *cell_symbol_current_module;
|
||||
struct scm *cell_symbol_primitive_load;
|
||||
struct scm *cell_symbol_car;
|
||||
struct scm *cell_symbol_cdr;
|
||||
struct scm *cell_symbol_not_a_number;
|
||||
struct scm *cell_symbol_not_a_pair;
|
||||
struct scm *cell_symbol_system_error;
|
||||
struct scm *cell_symbol_throw;
|
||||
struct scm *cell_symbol_unbound_variable;
|
||||
struct scm *cell_symbol_wrong_number_of_args;
|
||||
struct scm *cell_symbol_wrong_type_arg;
|
||||
struct scm *cell_symbol_buckets;
|
||||
struct scm *cell_symbol_builtin;
|
||||
struct scm *cell_symbol_frame;
|
||||
struct scm *cell_symbol_hashq_table;
|
||||
struct scm *cell_symbol_module;
|
||||
struct scm *cell_symbol_procedure;
|
||||
struct scm *cell_symbol_record_type;
|
||||
struct scm *cell_symbol_size;
|
||||
struct scm *cell_symbol_stack;
|
||||
struct scm *cell_symbol_argv;
|
||||
struct scm *cell_symbol_mes_datadir;
|
||||
struct scm *cell_symbol_mes_version;
|
||||
struct scm *cell_symbol_internal_time_units_per_second;
|
||||
struct scm *cell_symbol_compiler;
|
||||
struct scm *cell_symbol_arch;
|
||||
struct scm *cell_symbol_pmatch_car;
|
||||
struct scm *cell_symbol_pmatch_cdr;
|
||||
struct scm *cell_type_bytes;
|
||||
struct scm *cell_type_char;
|
||||
struct scm *cell_type_closure;
|
||||
struct scm *cell_type_continuation;
|
||||
struct scm *cell_type_function;
|
||||
struct scm *cell_type_keyword;
|
||||
struct scm *cell_type_macro;
|
||||
struct scm *cell_type_number;
|
||||
struct scm *cell_type_pair;
|
||||
struct scm *cell_type_port;
|
||||
struct scm *cell_type_ref;
|
||||
struct scm *cell_type_special;
|
||||
struct scm *cell_type_string;
|
||||
struct scm *cell_type_struct;
|
||||
struct scm *cell_type_symbol;
|
||||
struct scm *cell_type_values;
|
||||
struct scm *cell_type_variable;
|
||||
struct scm *cell_type_vector;
|
||||
struct scm *cell_type_broken_heart;
|
||||
struct scm *cell_symbol_program;
|
||||
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 81
|
||||
#define CELL_SYMBOL_RECORD_TYPE 81
|
||||
|
||||
|
||||
#endif /* __MES_SYMBOLS_H */
|
|
@ -34,6 +34,8 @@
|
|||
typedef char *va_list;
|
||||
#define va_start(ap, last) (void)((ap) = (char*)(&(last) + 1))
|
||||
#define va_arg(ap, type) (type)(((long*)((ap) = ((ap) + sizeof (void*))))[-1])
|
||||
#define va_align(ap, alignment) ((char*)((((unsigned long) (ap)) + (alignment) - 1) &~ ((alignment) - 1)))
|
||||
#define va_arg8(ap, type) (type)(((double*)((ap) = (va_align((ap), 8) + sizeof(double))))[-1])
|
||||
#define va_end(ap) (void)((ap) = 0)
|
||||
#define va_copy(dest, src) dest = src
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ typedef int (*comparison_fn_t) (void const *, void const *);
|
|||
#include <sys/types.h>
|
||||
#include <alloca.h>
|
||||
|
||||
void abort (void);
|
||||
double atof (char const *s);
|
||||
int atoi (char const *s);
|
||||
int atexit (void (*function) (void));
|
||||
|
|
|
@ -85,10 +85,12 @@ struct stat
|
|||
int chmod (char const *file_name, mode_t mode);
|
||||
int fstat (int filedes, struct stat *buf);
|
||||
int mkdir (char const *file_name, mode_t mode);
|
||||
int mknod (char const *file_name, mode_t mode, dev_t dev);
|
||||
int chown (char const *file_name, uid_t owner, gid_t group);
|
||||
int rmdir (char const *file_name);
|
||||
int stat (char const *file_name, struct stat *buf);
|
||||
|
||||
#define S_IFIFO 0010000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFBLK 0060000
|
||||
|
@ -96,6 +98,7 @@ int stat (char const *file_name, struct stat *buf);
|
|||
#define S_IFLNK 0120000
|
||||
#define S_IFMT 0170000
|
||||
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ typedef unsigned long uintptr_t;
|
|||
#ifndef __MES_OFF_T
|
||||
#define __MES_OFF_T
|
||||
#undef off_t
|
||||
typedef unsigned long off_t;
|
||||
typedef long off_t;
|
||||
#endif
|
||||
|
||||
#ifndef __MES_OFF64_T
|
||||
|
@ -138,6 +138,15 @@ typedef long ssize_t;
|
|||
typedef unsigned uid_t;
|
||||
#endif
|
||||
|
||||
#ifndef __WCHAR_T
|
||||
#define __WCHAR_T
|
||||
#ifndef __MES_WCHAR_T
|
||||
#define __MES_WCHAR_T
|
||||
#undef wchar_t
|
||||
typedef int wchar_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
#endif // __MES_SYS_TYPES_H
|
||||
|
|
|
@ -49,6 +49,14 @@
|
|||
#define CS8 0000060
|
||||
#define PARENB 0000400
|
||||
|
||||
struct winsize
|
||||
{
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
unsigned short ws_xpixel;
|
||||
unsigned short ws_ypixel;
|
||||
};
|
||||
|
||||
struct termio
|
||||
{
|
||||
unsigned short c_iflag;
|
||||
|
|
|
@ -59,6 +59,7 @@ struct timespec
|
|||
int clock_gettime (clockid_t clk_id, struct timespec *tp);
|
||||
struct tm *localtime (time_t const *timep);
|
||||
struct tm *gmtime (time_t const *time);
|
||||
time_t mktime (struct tm *broken_time);
|
||||
int nanosleep (struct timespec const *requested_time, struct timespec const *remaining);
|
||||
time_t time (time_t * tloc);
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ unsigned int alarm (unsigned int seconds);
|
|||
int close (int fd);
|
||||
int execv (char const *file_name, char *const argv[]);
|
||||
int execl (char const *file_name, char const *arg, ...);
|
||||
int execlp (char const *file_name, char const *arg, ...);
|
||||
int execve (char const *file, char *const argv[], char *const env[]);
|
||||
int execvp (char const *file, char *const argv[]);
|
||||
int fork (void);
|
||||
|
@ -73,21 +74,24 @@ int setgid (gid_t newgid);
|
|||
int setuid (uid_t newuid);
|
||||
uid_t geteuid (void);
|
||||
gid_t getegid (void);
|
||||
pid_t getpgrp (void);
|
||||
pid_t getpid (void);
|
||||
pid_t getppid (void);
|
||||
int getpgid (pid_t pid);
|
||||
int isatty (int fd);
|
||||
int link (char const *oldname, char const *newname);
|
||||
int link (char const *old_name, char const *new_name);
|
||||
off_t lseek (int fd, off_t offset, int whence);
|
||||
ssize_t read (int fd, void *buffer, size_t size);
|
||||
ssize_t readlink (char const *file_name, char *buffer, size_t size);
|
||||
#if __SBRK_CHAR_PTRDIFF
|
||||
/* xmalloc in binutils <= 2.10.1 uses this old prototype */
|
||||
char *sbrk (ptrdiff_t delta);
|
||||
#else
|
||||
void *sbrk (intptr_t delta);
|
||||
#endif
|
||||
int symlink (char const *old_name, char const *new_name);
|
||||
int unlink (char const *file_name);
|
||||
ssize_t write (int filedes, void const *buffer, size_t size);
|
||||
pid_t getpid (void);
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
#!/bin/bash
|
||||
# Copyright (C) 2019 Jeremiah Orians <jeremiah@pdp10.guru>
|
||||
# Copyright (C) 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/>.
|
||||
|
||||
# Usage:
|
||||
# kaem --verbose --strict
|
||||
|
||||
mkdir -p m2
|
||||
|
||||
M2-Planet \
|
||||
--debug \
|
||||
--architecture x86 \
|
||||
-f include/m2/lib.h \
|
||||
-f lib/linux/x86-mes-m2/crt1.c \
|
||||
-f lib/linux/x86-mes-m2/mini.c \
|
||||
-f lib/m2/cast.c \
|
||||
-f lib/m2/exit.c \
|
||||
-f lib/mes/write.c \
|
||||
-f lib/linux/x86-mes-m2/syscall.c \
|
||||
-f include/linux/x86/syscall.h \
|
||||
-f lib/linux/brk.c \
|
||||
-f lib/stdlib/malloc.c \
|
||||
-f lib/string/memset.c \
|
||||
-f lib/m2/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/string/strlen.c \
|
||||
-f lib/mes/eputs.c \
|
||||
-f lib/mes/fdputc.c \
|
||||
-f lib/mes/eputc.c \
|
||||
\
|
||||
-f include/mes/mes.h \
|
||||
-f include/mes/builtins.h \
|
||||
-f include/mes/constants.h \
|
||||
-f include/mes/symbols.h \
|
||||
\
|
||||
-f lib/mes/__assert_fail.c \
|
||||
-f lib/mes/assert_msg.c \
|
||||
\
|
||||
-f lib/mes/fdputc.c \
|
||||
-f lib/string/strncmp.c \
|
||||
-f lib/posix/getenv.c \
|
||||
-f lib/mes/fdputs.c \
|
||||
-f lib/m2/ntoab.c \
|
||||
-f lib/ctype/isdigit.c \
|
||||
-f lib/ctype/isxdigit.c \
|
||||
-f lib/ctype/isspace.c \
|
||||
-f lib/ctype/isnumber.c \
|
||||
-f lib/mes/abtol.c \
|
||||
-f lib/stdlib/atoi.c \
|
||||
-f lib/string/memcpy.c \
|
||||
-f lib/stdlib/free.c \
|
||||
-f lib/stdlib/realloc.c \
|
||||
-f lib/string/strcpy.c \
|
||||
-f lib/mes/itoa.c \
|
||||
-f lib/mes/ltoa.c \
|
||||
-f lib/mes/fdungetc.c \
|
||||
-f lib/posix/setenv.c \
|
||||
-f lib/linux/access.c \
|
||||
-f lib/m2/chmod.c \
|
||||
-f lib/m2/ioctl.c \
|
||||
-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 lib/linux/gettimeofday.c \
|
||||
-f lib/m2/clock_gettime.c \
|
||||
-f lib/m2/time.c \
|
||||
-f lib/linux/_getcwd.c \
|
||||
-f lib/m2/getcwd.c \
|
||||
-f lib/linux/dup.c \
|
||||
-f lib/linux/dup2.c \
|
||||
-f lib/string/strcmp.c \
|
||||
-f lib/string/memcmp.c \
|
||||
-f lib/linux/unlink.c \
|
||||
-f lib/stdlib/abort.c \
|
||||
-f src/builtins.c \
|
||||
-f src/core.c \
|
||||
-f src/display.c \
|
||||
-f src/eval-apply.c \
|
||||
-f src/gc.c \
|
||||
-f src/hash.c \
|
||||
-f src/lib.c \
|
||||
-f src/m2.c \
|
||||
-f src/math.c \
|
||||
-f src/mes.c \
|
||||
-f src/module.c \
|
||||
-f src/posix.c \
|
||||
-f src/reader.c \
|
||||
-f src/stack.c \
|
||||
-f src/string.c \
|
||||
-f src/struct.c \
|
||||
-f src/symbol.c \
|
||||
-f src/variable.c \
|
||||
-f src/vector.c \
|
||||
-o m2/mes.M1
|
||||
|
||||
blood-elf -f m2/mes.M1 -o m2/mes.blood-elf-M1
|
||||
|
||||
M1 \
|
||||
--LittleEndian \
|
||||
--architecture x86 \
|
||||
-f lib/m2/x86/x86_defs.M1 \
|
||||
-f lib/x86-mes/x86.M1 \
|
||||
-f lib/linux/x86-mes-m2/crt1.M1 \
|
||||
-f m2/mes.M1 \
|
||||
-f m2/mes.blood-elf-M1 \
|
||||
-o m2/mes.hex2
|
||||
|
||||
mkdir -p bin
|
||||
hex2 \
|
||||
--LittleEndian \
|
||||
--architecture x86 \
|
||||
--BaseAddress 0x1000000 \
|
||||
--exec_enable \
|
||||
-f lib/x86-mes/elf32-header.hex2 \
|
||||
-f m2/mes.hex2 \
|
||||
-o bin/mes-m2
|
||||
|
||||
echo Running mes-m2
|
||||
./bin/mes-m2 -c "(display 'Hello,M2-mes!) (newline)"
|
||||
cp bin/mes-m2 bin/mes
|
|
@ -0,0 +1,27 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
int
|
||||
isgraph (int c)
|
||||
{
|
||||
return c > 32 && c < 127;
|
||||
}
|
|
@ -18,14 +18,15 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib-mini.h>
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
char *
|
||||
_getcwd (char *buffer, size_t size)
|
||||
{
|
||||
int r = _sys_call2 (SYS_getcwd, (long) buffer, (long) size);
|
||||
long long_buffer = cast_charp_to_long (buffer);
|
||||
int r = _sys_call2 (SYS_getcwd, long_buffer, size);
|
||||
if (r >= 0)
|
||||
return buffer;
|
||||
return 0;
|
||||
|
|
|
@ -27,7 +27,6 @@ int
|
|||
_open3 (char const *file_name, int flags, int mask)
|
||||
{
|
||||
int r = _sys_call3 (SYS_open, (long) file_name, (int) flags, (int) mask);
|
||||
__ungetc_init ();
|
||||
if (r > 2)
|
||||
{
|
||||
__ungetc_clear (r);
|
||||
|
|
|
@ -18,11 +18,14 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
access (char const *file_name, int how)
|
||||
{
|
||||
return _sys_call2 (SYS_access, (long) file_name, (int) how);
|
||||
long long_file_name = cast_charp_to_long (file_name);
|
||||
long long_how = cast_int_to_long (how);
|
||||
return _sys_call2 (SYS_access, long_file_name, long_how);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
long
|
||||
brk (void *addr)
|
||||
{
|
||||
return _sys_call1 (SYS_brk, (long) addr);
|
||||
long long_addr = cast_voidp_to_long (addr);
|
||||
return _sys_call1 (SYS_brk, long_addr);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -25,5 +26,7 @@
|
|||
int
|
||||
chmod (char const *file_name, mode_t mask)
|
||||
{
|
||||
return _sys_call2 (SYS_chmod, (long) file_name, (long) mask);
|
||||
long long_file_name = cast_charp_to_long (file_name);
|
||||
long long_mask = cast_int_to_long (mask);
|
||||
return _sys_call2 (SYS_chmod, long_file_name, long_mask);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <time.h>
|
||||
|
@ -25,5 +26,7 @@
|
|||
int
|
||||
clock_gettime (clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
return _sys_call2 (SYS_clock_gettime, (long) clk_id, (long) tp);
|
||||
long long_clk_id = cast_int_to_long (clk_id);
|
||||
long long_tp = cast_voidp_to_long (tp);
|
||||
return _sys_call2 (SYS_clock_gettime, long_clk_id, long_tp);
|
||||
}
|
||||
|
|
|
@ -24,5 +24,6 @@
|
|||
int
|
||||
dup (int old)
|
||||
{
|
||||
return _sys_call1 (SYS_dup, (int) old);
|
||||
long long_old = old;
|
||||
return _sys_call1 (SYS_dup, long_old);
|
||||
}
|
||||
|
|
|
@ -24,5 +24,7 @@
|
|||
int
|
||||
dup2 (int old, int new)
|
||||
{
|
||||
return _sys_call2 (SYS_dup2, (int) old, (int) new);
|
||||
long long_old = old;
|
||||
long long_new = new;
|
||||
return _sys_call2 (SYS_dup2, long_old, long_new);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -25,5 +26,7 @@
|
|||
int
|
||||
gettimeofday (struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
return _sys_call2 (SYS_gettimeofday, (long) tv, (long) tz);
|
||||
long long_tv = cast_voidp_to_long (tv);
|
||||
long long_tz = cast_voidp_to_long (tz);
|
||||
return _sys_call2 (SYS_gettimeofday, long_tv, long_tz);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-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 <sys/stat.h>
|
||||
|
||||
int
|
||||
mknod (char const *file_name, mode_t mode, dev_t dev)
|
||||
{
|
||||
return _sys_call3 (SYS_mknod, (long) file_name, (long) mode, (long) dev);
|
||||
}
|
|
@ -26,21 +26,23 @@
|
|||
ssize_t
|
||||
read (int filedes, void *buffer, size_t size)
|
||||
{
|
||||
ssize_t bytes = _sys_call3 (SYS_read, (int) filedes, (long) buffer, (long) size);
|
||||
long long_filedes = filedes;
|
||||
ssize_t bytes = _sys_call3 (SYS_read, long_filedes, buffer, size);
|
||||
if (__mes_debug () > 4)
|
||||
{
|
||||
if (bytes == 1)
|
||||
{
|
||||
eputs ("read fd=");
|
||||
eputs (itoa ((int) filedes));
|
||||
eputs (itoa (filedes));
|
||||
eputs (" c=");
|
||||
eputc (*(char *) buffer);
|
||||
char *s = buffer;
|
||||
eputc (s[0]);
|
||||
eputs ("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
eputs ("read fd=");
|
||||
eputs (itoa ((int) filedes));
|
||||
eputs (itoa (filedes));
|
||||
eputs (" bytes=");
|
||||
eputs (itoa (bytes));
|
||||
eputs ("\n");
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-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 <sys/stat.h>
|
||||
|
||||
ssize_t
|
||||
readlink (char const *file_name, char *buffer, size_t size)
|
||||
{
|
||||
return _sys_call3 (SYS_readlink, (long) file_name, (long) buffer, (long) size);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-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 <unistd.h>
|
||||
|
||||
int
|
||||
symlink (char const *old_name, char const *new_name)
|
||||
{
|
||||
return _sys_call2 (SYS_symlink, (long) old_name, (long) new_name);
|
||||
}
|
|
@ -18,11 +18,13 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
unlink (char const *file_name)
|
||||
{
|
||||
return _sys_call1 (SYS_unlink, (long) file_name);
|
||||
long long_file_name = cast_charp_to_long (file_name);
|
||||
return _sys_call1 (SYS_unlink, long_file_name);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
###
|
||||
### This file is part of GNU Mes.
|
||||
###
|
||||
### GNU Mes is free software; you can redistribute it and/or modify it
|
||||
### under the terms of the GNU General Public License as published by
|
||||
### the Free Software Foundation; either version 3 of the License, or (at
|
||||
### your option) any later version.
|
||||
###
|
||||
### GNU Mes is distributed in the hope that it will be useful, but
|
||||
### WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
### GNU General Public License for more details.
|
||||
###
|
||||
### You should have received a copy of the GNU General Public License
|
||||
### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
:_start
|
||||
push___%ebp
|
||||
mov____%esp,%ebp
|
||||
sub____$i32,%esp %0x1054
|
||||
mov____$i8,%eax !0
|
||||
mov____%eax,0x32 &GLOBAL___stdin
|
||||
mov____$i8,%eax !1
|
||||
mov____%eax,0x32 &GLOBAL___stdout
|
||||
mov____$i8,%eax !2
|
||||
mov____%eax,0x32 &GLOBAL___stderr
|
||||
mov____%ebp,%eax
|
||||
add____$i8,%eax !4
|
||||
movzbl_(%eax),%eax
|
||||
add____$i8,%eax !3
|
||||
shl____$i8,%eax !0x02
|
||||
add____%ebp,%eax
|
||||
mov____%eax,0x32 &GLOBAL_environ
|
||||
|
||||
mov____%esp,%edi ; M2-Planet calling convention pushes forward
|
||||
mov____%ebp,%eax ; argc
|
||||
add____$i8,%eax !4
|
||||
movzbl_(%eax),%eax
|
||||
push___%eax
|
||||
|
||||
mov____%ebp,%eax ; argv
|
||||
add____$i8,%eax !8
|
||||
push___%eax
|
||||
|
||||
mov____0x32,%eax &GLOBAL_environ
|
||||
push___%eax
|
||||
|
||||
mov____%edi,%ebp ; M2-Planet calling convention
|
||||
call32 %FUNCTION_main
|
||||
add____$i8,%esp !0x0
|
||||
test___%eax,%eax
|
||||
mov____%eax,%ebx
|
||||
mov____$i32,%eax %1
|
||||
int____$0x80
|
||||
hlt
|
||||
leave
|
||||
ret
|
|
@ -0,0 +1,68 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
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 ()
|
||||
{
|
||||
asm ("mov____$i8,%eax !0");
|
||||
asm ("mov____%eax,0x32 &GLOBAL___stdin");
|
||||
|
||||
asm ("mov____$i8,%eax !1");
|
||||
asm ("mov____%eax,0x32 &GLOBAL___stdout");
|
||||
|
||||
asm ("mov____$i8,%eax !2");
|
||||
asm ("mov____%eax,0x32 &GLOBAL___stderr");
|
||||
|
||||
asm ("mov____%ebp,%eax");
|
||||
asm ("add____$i8,%eax !4");
|
||||
|
||||
asm ("movzbl_(%eax),%eax");
|
||||
asm ("add____$i8,%eax !3");
|
||||
|
||||
asm ("shl____$i8,%eax !0x02");
|
||||
asm ("add____%ebp,%eax");
|
||||
asm ("mov____%eax,0x32 &GLOBAL_environ");
|
||||
asm ("push___%eax");
|
||||
|
||||
asm ("mov____%ebp,%eax");
|
||||
asm ("add____$i8,%eax !8");
|
||||
asm ("push___%eax");
|
||||
|
||||
asm ("mov____%ebp,%eax");
|
||||
asm ("add____$i8,%eax !4");
|
||||
asm ("movzbl_(%eax),%eax");
|
||||
asm ("push___%eax");
|
||||
main ();
|
||||
|
||||
asm ("mov____%eax,%ebx");
|
||||
asm ("mov____$i32,%eax %1");
|
||||
asm ("int____$0x80");
|
||||
asm ("hlt");
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,37 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,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/>.
|
||||
*/
|
||||
|
||||
void
|
||||
_exit ()
|
||||
{
|
||||
asm ("mov____$i32,%eax SYS_exit");
|
||||
asm ("mov____0x8(%ebp),%ebx !-4");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
void
|
||||
_write (int filedes, void *buffer, int size)
|
||||
{
|
||||
asm ("mov____$i32,%eax SYS_write");
|
||||
asm ("mov____0x8(%ebp),%ebx !-4");
|
||||
asm ("mov____0x8(%ebp),%ecx !-8");
|
||||
asm ("mov____0x8(%ebp),%edx !-12");
|
||||
asm ("int____$0x80");
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/x86/syscall.h>
|
||||
|
||||
int errno;
|
||||
|
||||
int
|
||||
__sys_call (int sys_call)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !-4");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
__sys_call1 (int sys_call, int one)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !-4");
|
||||
asm ("mov____0x8(%ebp),%ebx !-8");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
__sys_call2 (int sys_call, int one, int two)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !-4");
|
||||
asm ("mov____0x8(%ebp),%ebx !-8");
|
||||
asm ("mov____0x8(%ebp),%ecx !-12");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
__sys_call3 (int sys_call, int one, int two, int three)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !-4");
|
||||
asm ("mov____0x8(%ebp),%ebx !-8");
|
||||
asm ("mov____0x8(%ebp),%ecx !-12");
|
||||
asm ("mov____0x8(%ebp),%edx !-16");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
__sys_call4 (int sys_call, int one, int two, int three, int four)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !-4");
|
||||
asm ("mov____0x8(%ebp),%ebx !-8");
|
||||
asm ("mov____0x8(%ebp),%ecx !-12");
|
||||
asm ("mov____0x8(%ebp),%edx !-16");
|
||||
asm ("mov____0x8(%ebp),%esi !-24");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call (int sys_call)
|
||||
{
|
||||
int r = __sys_call (sys_call);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call1 (int sys_call, int one)
|
||||
{
|
||||
int r = __sys_call1 (sys_call, one);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call2 (int sys_call, int one, int two)
|
||||
{
|
||||
int r = __sys_call2 (sys_call, one, two);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call3 (int sys_call, int one, int two, int three)
|
||||
{
|
||||
int r = __sys_call3 (sys_call, one, two, three);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call4 (int sys_call, int one, int two, int three, int four)
|
||||
{
|
||||
int r = __sys_call4 (sys_call, one, two, three, four);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
|
||||
#undef cast_intp_to_charp
|
||||
#undef cast_long_to_charp
|
||||
#undef cast_charp_to_long
|
||||
#undef cast_int_to_long
|
||||
#undef cast_voidp_to_long
|
||||
|
||||
char*
|
||||
cast_intp_to_charp (int const *i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
char*
|
||||
cast_long_to_charp (long i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
long
|
||||
cast_charp_to_long (char const *i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
long
|
||||
cast_int_to_long (int i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
long
|
||||
cast_voidp_to_long (void const *i)
|
||||
{
|
||||
return i;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
chmod (char const *file_name, int mask)
|
||||
{
|
||||
long long_file_name = file_name;
|
||||
long long_mask = mask;
|
||||
return _sys_call2 (SYS_chmod, long_file_name, long_mask);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* -*-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);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
int
|
||||
execv (char *file_name, char **argv)
|
||||
{
|
||||
return execve (file_name, argv, environ);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
execve (char const *file_name, char **argv, char **env)
|
||||
{
|
||||
long long_file_name = file_name;
|
||||
long long_argv = argv;
|
||||
long long_env = env;
|
||||
return _sys_call3 (SYS_execve, file_name, argv, env);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
|
||||
void _exit (int code);
|
||||
|
||||
void
|
||||
exit (int code)
|
||||
{
|
||||
_exit (code);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <mes/lib.h>
|
||||
|
||||
// CONSTANT PATH_MAX 1024
|
||||
|
||||
char *
|
||||
getcwd (char *buffer, int size)
|
||||
{
|
||||
if (__getcwd_buf == 0)
|
||||
__getcwd_buf = malloc (PATH_MAX);
|
||||
char *buf = __itoa_buf;
|
||||
if (buffer != 0)
|
||||
return _getcwd (buffer, size);
|
||||
return _getcwd (buf, PATH_MAX);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/* -*-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 <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int
|
||||
ioctl (int filedes, long command, int data)
|
||||
{
|
||||
long long_filedes = filedes;
|
||||
long long_command = command;
|
||||
long long_data = data;
|
||||
int r = _sys_call3 (SYS_ioctl, long_filedes, long_command, long_data);
|
||||
return r;
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termio.h>
|
||||
|
||||
// CONSTANT TCGETS 0x5401
|
||||
#define TCGETS 0x5401
|
||||
|
||||
// CONSTANT NCCS 19
|
||||
#define NCCS 19
|
||||
|
||||
struct ktermios
|
||||
{
|
||||
unsigned c_iflag;
|
||||
unsigned c_oflag;
|
||||
unsigned c_cflag;
|
||||
unsigned c_lflag;
|
||||
char c_line;
|
||||
char c_cc[NCCS];
|
||||
unsigned c_ispeed;
|
||||
unsigned c_ospeed;
|
||||
};
|
||||
|
||||
struct ktermios *__isatty_kernel_termios;
|
||||
|
||||
int
|
||||
isatty (int filedes)
|
||||
{
|
||||
if (__isatty_kernel_termios == 0)
|
||||
__isatty_kernel_termios = malloc (sizeof (struct ktermios));
|
||||
int r = ioctl (filedes, TCGETS, __isatty_kernel_termios);
|
||||
return r == 0;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
int
|
||||
mes_open (char *file_name, int flags, int mask)
|
||||
{
|
||||
int filedes = open (file_name, flags, mask);
|
||||
if (filedes > 2)
|
||||
__ungetc_clear (filedes);
|
||||
return filedes;
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
char *__itoa_buf;
|
||||
|
||||
char *
|
||||
ntoab (long x, int base, int signed_p)
|
||||
{
|
||||
if (__itoa_buf == 0)
|
||||
__itoa_buf = malloc (20);
|
||||
|
||||
char *buf = __itoa_buf;
|
||||
char *p = buf + 11;
|
||||
p[0] = 0;
|
||||
p = p - 1;
|
||||
assert_msg (base > 0, "base > 0");
|
||||
|
||||
int sign_p = 0;
|
||||
unsigned u;
|
||||
if (signed_p != 0 && x < 0)
|
||||
{
|
||||
sign_p = 1;
|
||||
u = -x;
|
||||
}
|
||||
else
|
||||
u = x;
|
||||
|
||||
do
|
||||
{
|
||||
unsigned i;
|
||||
i = u % base;
|
||||
u = u / base;
|
||||
if (i > 9)
|
||||
p[0] = 'a' + i - 10;
|
||||
else
|
||||
p[0] = '0' + i;
|
||||
p = p - 1;
|
||||
}
|
||||
while (u != 0);
|
||||
|
||||
if (sign_p && p[1] != '0')
|
||||
{
|
||||
p[0] = '-';
|
||||
p = p - 1;
|
||||
}
|
||||
|
||||
return p + 1;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
open (char *file_name, int flags, int mask)
|
||||
{
|
||||
int r = _sys_call3 (SYS_open, file_name, flags, mask);
|
||||
if (r > 2)
|
||||
__ungetc_clear (r);
|
||||
return r;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* aSCM 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>
|
||||
|
||||
SCM
|
||||
read (int filedes, void *buffer, SCM size)
|
||||
{
|
||||
SCM bytes = _sys_call3 (SYS_read, filedes, buffer, size);
|
||||
return bytes;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-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>
|
||||
|
||||
long
|
||||
time (long *result)
|
||||
{
|
||||
return _sys_call1 (SYS_time, result);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/* -*-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/types.h>
|
||||
|
||||
int
|
||||
waitpid (int pid, int *status_ptr, int options)
|
||||
{
|
||||
long long_pid = pid;
|
||||
long long_status_ptr = status_ptr;
|
||||
long long_options = options;
|
||||
#if __i386__
|
||||
return _sys_call3 (SYS_waitpid, long_pid, long_status_ptr, long_options);
|
||||
#elif __x86_64__
|
||||
return _sys_call4 (SYS_wait4, long_pid, long_status_ptr, long_options, 0);
|
||||
#else
|
||||
#error arch not supported
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
## 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_eax 81C0
|
||||
DEFINE ADD_IMMEDIATE_to_ebp 81C5
|
||||
DEFINE ADD_eax_to_ebx 01C3
|
||||
DEFINE ADD_ebp_to_eax 01E8
|
||||
DEFINE ADD_ebx_to_eax 01D8
|
||||
DEFINE AND_eax_ebx 21D8
|
||||
DEFINE CALL_IMMEDIATE E8
|
||||
DEFINE CALL_eax FFD0
|
||||
DEFINE CMP 39C3
|
||||
DEFINE COPY_eax_to_ebx 89C3
|
||||
DEFINE COPY_eax_to_ecx 89C1
|
||||
DEFINE COPY_ebp_to_eax 89E8
|
||||
DEFINE COPY_ebx_to_eax 89D8
|
||||
DEFINE COPY_ebx_to_edx 89DA
|
||||
DEFINE COPY_ecx_to_ebp 89CD
|
||||
DEFINE COPY_edi_to_ebp 89fd
|
||||
DEFINE COPY_esp_to_ebp 89E5
|
||||
DEFINE COPY_esp_to_ecx 89E1
|
||||
DEFINE COPY_esp_to_edi 89E7
|
||||
DEFINE DIVIDE_eax_by_ebx_into_eax F7FB
|
||||
DEFINE DIVIDES_eax_by_ebx_into_eax F7F3
|
||||
DEFINE INT_80 CD80
|
||||
DEFINE JUMP E9
|
||||
DEFINE JUMP_EQ 0F84
|
||||
DEFINE JUMP_NE 0F85
|
||||
DEFINE JUMP_EQ8 74
|
||||
DEFINE JUMP_NE8 75
|
||||
DEFINE LOAD_BASE_ADDRESS_eax 8D85
|
||||
DEFINE LOAD_BYTE 0FBE00
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS 8D8424
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_ebx 8D9C24
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_ecx 8D8C24
|
||||
DEFINE LOAD_EFFECTIVE_ADDRESS_edx 8D9424
|
||||
DEFINE LOAD_ESP_IMMEDIATE_into_eax 8B8424
|
||||
DEFINE LOAD_IMMEDIATE_eax B8
|
||||
DEFINE LOAD_IMMEDIATE_ebx BB
|
||||
DEFINE LOAD_IMMEDIATE_edx BA
|
||||
DEFINE LOAD_INTEGER 8B00
|
||||
DEFINE LOAD_INTEGER_ebx 8B1B
|
||||
DEFINE LOAD_INTEGER_ecx 8B09
|
||||
DEFINE LOAD_INTEGER_edx 8B12
|
||||
DEFINE MODULUS_eax_from_ebx_into_ebx F7FB
|
||||
DEFINE MODULUSS_eax_from_ebx_into_ebx F7F3
|
||||
DEFINE MOVEZBL 0FB6C0
|
||||
DEFINE MOVE_ebx_to_eax 89D8
|
||||
DEFINE MOVE_ecx_to_eax 89C8
|
||||
DEFINE MOVE_edx_to_eax 89D0
|
||||
DEFINE MULTIPLY_eax_by_ebx_into_eax F7EB
|
||||
DEFINE MULTIPLYS_eax_by_ebx_into_eax F7E3
|
||||
DEFINE NOP 00000000
|
||||
DEFINE NOT_eax F7D0
|
||||
DEFINE OR_eax_ebx 09D8
|
||||
DEFINE POP_eax 58
|
||||
DEFINE POP_ebx 5B
|
||||
DEFINE POP_ebp 5D
|
||||
DEFINE POP_edi 5F
|
||||
DEFINE PUSH_eax 50
|
||||
DEFINE PUSH_ebx 53
|
||||
DEFINE PUSH_ebp 55
|
||||
DEFINE PUSH_edi 57
|
||||
DEFINE RETURN C3
|
||||
DEFINE SAL_eax_Immediate8 C1E0
|
||||
DEFINE SAL_eax_cl D3E0
|
||||
DEFINE SAR_eax_cl D3F8
|
||||
DEFINE SETE 0F94C0
|
||||
DEFINE SETLE 0F9EC0
|
||||
DEFINE SETL 0F9CC0
|
||||
DEFINE SETGE 0F9DC0
|
||||
DEFINE SETG 0F9FC0
|
||||
DEFINE SETNE 0F95C0
|
||||
DEFINE STORE_CHAR 8803
|
||||
DEFINE STORE_INTEGER 8903
|
||||
DEFINE SUBTRACT_eax_from_ebx_into_ebx 29C3
|
||||
DEFINE TEST 85C0
|
||||
DEFINE XCHG_eax_ebx 93
|
||||
DEFINE XOR_ebx_eax_into_eax 31D8
|
|
@ -28,5 +28,5 @@ __assert_fail (char *s)
|
|||
eputs ("\n");
|
||||
char *fail = s;
|
||||
fail = 0;
|
||||
*fail = 0;
|
||||
fail[0] = 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
|
||||
double
|
||||
abtod (char const **p, int base)
|
||||
{
|
||||
char const *s = *p;
|
||||
double d = 0;
|
||||
int sign_p = 0;
|
||||
if (!base)
|
||||
base = 10;
|
||||
double dbase = base;
|
||||
long i = abtol (&s, base);
|
||||
long f = 0;
|
||||
long e = 0;
|
||||
if (*s == '.')
|
||||
{
|
||||
s++;
|
||||
f = abtol (&s, base);
|
||||
}
|
||||
if (*s == 'e')
|
||||
{
|
||||
s++;
|
||||
e = abtol (&s, base);
|
||||
}
|
||||
d = i + f / dbase;
|
||||
if (e < 0)
|
||||
while (e++)
|
||||
d = d / dbase;
|
||||
while (e--)
|
||||
d = d * dbase;
|
||||
*p = s;
|
||||
return sign_p ? -d : d;
|
||||
}
|
|
@ -24,23 +24,32 @@
|
|||
long
|
||||
abtol (char const **p, int base)
|
||||
{
|
||||
char const *s = *p;
|
||||
char const *s = p[0];
|
||||
int i = 0;
|
||||
int sign = 1;
|
||||
if (!base)
|
||||
int sign_p = 0;
|
||||
if (base == 0)
|
||||
base = 10;
|
||||
if (*s && *s == '-')
|
||||
while (isspace (s[0]) != 0)
|
||||
s = s + 1;
|
||||
if (s[0] != 0 && s[0] == '+')
|
||||
s = s + 1;
|
||||
if (s[0] != 0 && s[0] == '-')
|
||||
{
|
||||
sign = -1;
|
||||
s++;
|
||||
sign_p = 1;
|
||||
s = s + 1;
|
||||
}
|
||||
while (isnumber (*s, base))
|
||||
while (isnumber (s[0], base) != 0)
|
||||
{
|
||||
i *= base;
|
||||
int m = *s > '9' ? 'a' - 10 : '0';
|
||||
i += *s - m;
|
||||
s++;
|
||||
i = i * base;
|
||||
int m = '0';
|
||||
if (s[0] > '9')
|
||||
m = 'a' - 10;
|
||||
i = i + s[0] - m;
|
||||
s = s + 1;
|
||||
}
|
||||
*p = s;
|
||||
return i * sign;
|
||||
p[0] = s;
|
||||
if (sign_p != 0)
|
||||
return -i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jeremiah Orians <jeremiah@pdp10.guru>
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
assert_msg (int bool, char *msg)
|
||||
{
|
||||
if (bool == 0)
|
||||
__assert_fail (msg);
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
|
||||
#undef cast_intp_to_charp
|
||||
#undef cast_long_to_charp
|
||||
#undef cast_charp_to_long
|
||||
#undef cast_int_to_long
|
||||
#undef cast_voidp_to_long
|
||||
|
||||
char*
|
||||
cast_intp_to_charp (int const *i)
|
||||
{
|
||||
return (char*)i;
|
||||
}
|
||||
|
||||
char*
|
||||
cast_long_to_charp (long i)
|
||||
{
|
||||
return (char*)i;
|
||||
}
|
||||
|
||||
long
|
||||
cast_charp_to_long (char const *i)
|
||||
{
|
||||
return (long)i;
|
||||
}
|
||||
|
||||
long
|
||||
cast_int_to_long (int i)
|
||||
{
|
||||
return (long)i;
|
||||
}
|
||||
|
||||
long
|
||||
cast_voidp_to_long (void const *i)
|
||||
{
|
||||
return (long)i;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
dtoab (double d, int base, int signed_p)
|
||||
{
|
||||
static char dtoa_buf[40];
|
||||
long i = (long) d;
|
||||
char *p = ntoab (i, base, signed_p);
|
||||
strcpy (dtoa_buf, p);
|
||||
long f = (d - (double) i) * (double) 100000000;
|
||||
if (f)
|
||||
{
|
||||
if (f < 0)
|
||||
f = -f;
|
||||
strcat (dtoa_buf, ".");
|
||||
p = ntoab (f, base, 1);
|
||||
strcat (dtoa_buf, p);
|
||||
p = strchr (dtoa_buf, 0);
|
||||
p--;
|
||||
while (*p && *p == '0')
|
||||
*p-- = 0;
|
||||
}
|
||||
return dtoa_buf;
|
||||
}
|
|
@ -19,42 +19,57 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int __ungetc_buf[__FILEDES_MAX + 1] = { 0 };
|
||||
int errno;
|
||||
int *__ungetc_buf;
|
||||
|
||||
int
|
||||
__ungetc_p (int filedes)
|
||||
{
|
||||
if (__ungetc_buf == 0)
|
||||
__ungetc_init ();
|
||||
return __ungetc_buf[filedes] >= 0;
|
||||
}
|
||||
|
||||
void
|
||||
__ungetc_init ()
|
||||
{
|
||||
if (__ungetc_buf[__FILEDES_MAX] == 0)
|
||||
memset (__ungetc_buf, -1, (__FILEDES_MAX + 1) * sizeof (int));
|
||||
if (__ungetc_buf == 0)
|
||||
{
|
||||
int save_errno = errno;
|
||||
__ungetc_buf = malloc ((__FILEDES_MAX + 1) * sizeof (int));
|
||||
errno = save_errno;
|
||||
memset (__ungetc_buf, -1, (__FILEDES_MAX + 1) * sizeof (int));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
__ungetc_clear (int filedes)
|
||||
{
|
||||
if (__ungetc_buf == 0)
|
||||
__ungetc_init ();
|
||||
__ungetc_buf[filedes] = -1;
|
||||
}
|
||||
|
||||
void
|
||||
__ungetc_set (int filedes, int c)
|
||||
{
|
||||
if (__ungetc_buf == 0)
|
||||
__ungetc_init ();
|
||||
__ungetc_buf[filedes] = c;
|
||||
}
|
||||
|
||||
int
|
||||
fdgetc (int fd)
|
||||
{
|
||||
__ungetc_init ();
|
||||
if (__ungetc_buf == 0)
|
||||
__ungetc_init ();
|
||||
|
||||
char c;
|
||||
int i = __ungetc_buf[fd];
|
||||
|
@ -65,10 +80,10 @@ fdgetc (int fd)
|
|||
int r = read (fd, &c, 1);
|
||||
if (r < 1)
|
||||
return -1;
|
||||
i = (int) c;
|
||||
i = c;
|
||||
}
|
||||
if (i < 0)
|
||||
i += 256;
|
||||
i = i + 256;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
int
|
||||
fdputc (int c, int fd)
|
||||
{
|
||||
write (fd, (char *) &c, 1);
|
||||
char *p = cast_intp_to_charp (&c);
|
||||
write (fd, p, 1);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,10 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <assert.h>
|
||||
|
||||
int
|
||||
fdungetc (int c, int fd)
|
||||
{
|
||||
__ungetc_init ();
|
||||
if (c == -1)
|
||||
return c;
|
||||
else if (__ungetc_p (fd))
|
||||
|
@ -32,7 +30,7 @@ fdungetc (int c, int fd)
|
|||
eputs (" ***MES C LIB*** fdungetc ungetc buffer overflow fd=");
|
||||
eputs (itoa (fd));
|
||||
eputs ("\n");
|
||||
assert (0);
|
||||
assert_msg (0, "0");
|
||||
}
|
||||
__ungetc_set (fd, c);
|
||||
return c;
|
||||
|
|
|
@ -32,7 +32,6 @@ int __stderr = STDERR;
|
|||
int
|
||||
mes_open (char const *file_name, int flags, int mask)
|
||||
{
|
||||
__ungetc_init ();
|
||||
int filedes = open (file_name, flags, mask);
|
||||
if (filedes > 2)
|
||||
__ungetc_clear (filedes);
|
||||
|
|
|
@ -18,20 +18,32 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <mes/lib.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *__itoa_buf;
|
||||
|
||||
char *
|
||||
ntoab (long x, int base, int signed_p)
|
||||
{
|
||||
static char itoa_buf[20];
|
||||
char *p = itoa_buf + 11;
|
||||
*p-- = 0;
|
||||
assert(base > 0);
|
||||
#if 0
|
||||
if (! __itoa_buf)
|
||||
__itoa_buf = malloc (20);
|
||||
p = __itoa_buf + 11;
|
||||
#else
|
||||
static char buf[20];
|
||||
char *p = buf + 19;
|
||||
#endif
|
||||
|
||||
p[0] = 0;
|
||||
p = p - 1;
|
||||
assert_msg (base > 0, "base > 0");
|
||||
|
||||
int sign_p = 0;
|
||||
unsigned long u;
|
||||
if (signed_p && x < 0)
|
||||
if (signed_p != 0 && x < 0)
|
||||
{
|
||||
sign_p = 1;
|
||||
u = -x;
|
||||
|
@ -48,12 +60,19 @@ ntoab (long x, int base, int signed_p)
|
|||
i = u % base;
|
||||
u = u / base;
|
||||
#endif
|
||||
*p-- = i > 9 ? 'a' + i - 10 : '0' + i;
|
||||
if (i > 9)
|
||||
p[0] = 'a' + i - 10;
|
||||
else
|
||||
p[0] = '0' + i;
|
||||
p = p - 1;
|
||||
}
|
||||
while (u);
|
||||
while (u != 0);
|
||||
|
||||
if (sign_p && *(p + 1) != '0')
|
||||
*p-- = '-';
|
||||
if (sign_p && p[1] != '0')
|
||||
{
|
||||
p[0] = '-';
|
||||
p = p - 1;
|
||||
}
|
||||
|
||||
return p + 1;
|
||||
}
|
||||
|
|
|
@ -23,22 +23,13 @@
|
|||
#include <unistd.h>
|
||||
|
||||
int
|
||||
execl (char const *file_name, char const *arg, ...)
|
||||
vexec (char const *file_name, va_list ap)
|
||||
{
|
||||
if (__mes_debug () > 2)
|
||||
{
|
||||
eputs ("execl ");
|
||||
eputs (file_name);
|
||||
eputs ("\n");
|
||||
}
|
||||
char *arg = va_arg (ap, char *);
|
||||
char *argv[1000]; // POSIX minimum 4096
|
||||
int i = 0;
|
||||
|
||||
va_list ap;
|
||||
va_start (ap, arg);
|
||||
|
||||
argv[i++] = (char *)file_name;
|
||||
arg = va_arg (ap, char const *);
|
||||
argv[i++] = (char *) file_name;
|
||||
while (arg)
|
||||
{
|
||||
argv[i++] = arg;
|
||||
|
@ -57,3 +48,20 @@ execl (char const *file_name, char const *arg, ...)
|
|||
va_end (ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
execl (char const *file_name, char const *arg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int r;
|
||||
va_start (ap, arg);
|
||||
if (__mes_debug () > 2)
|
||||
{
|
||||
eputs ("execl ");
|
||||
eputs (file_name);
|
||||
eputs ("\n");
|
||||
}
|
||||
r = vexec (file_name, ap);
|
||||
va_end (ap);
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
* GNU Mes is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* GNU Mes is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
execlp (char const *file_name, char const *arg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int r;
|
||||
va_start (ap, arg);
|
||||
if (file_name[0] != '/')
|
||||
file_name = search_path (file_name);
|
||||
if (__mes_debug () > 2)
|
||||
{
|
||||
eputs ("execlp ");
|
||||
eputs (file_name ? file_name : "0");
|
||||
eputs ("\n");
|
||||
}
|
||||
if (!file_name)
|
||||
{
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
r = vexec (file_name, ap);
|
||||
va_end (ap);
|
||||
return r;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
/*
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
|
@ -22,16 +22,30 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// CONSTANT M2_PTR_SIZE 4
|
||||
#define M2_PTR_SIZE 1
|
||||
|
||||
char *
|
||||
getenv (char const *s)
|
||||
{
|
||||
/* eputs ("\ngetenv s="); eputs (s); eputs ("\n"); */
|
||||
char **p = environ;
|
||||
int length = strlen (s);
|
||||
while (*p)
|
||||
|
||||
while (p[0] != 0)
|
||||
{
|
||||
if (!strncmp (s, *p, length) && *(*p + length) == '=')
|
||||
return (*p + length + 1);
|
||||
p++;
|
||||
/* eputs ("getenv p[0]="); eputs (p[0]); eputs ("\n"); */
|
||||
if (strncmp (s, p[0], length) == 0)
|
||||
{
|
||||
/* eputs ("found!\n"); */
|
||||
char *q = p[0] + length;
|
||||
if (q[0] == '=')
|
||||
return q + 1;
|
||||
}
|
||||
/* else */
|
||||
/* eputs ("not found!\n"); */
|
||||
p = p + M2_PTR_SIZE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -22,25 +22,34 @@
|
|||
#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)
|
||||
{
|
||||
char **p = environ;
|
||||
int length = strlen (s);
|
||||
while (*p)
|
||||
|
||||
while (p[0] != 0)
|
||||
{
|
||||
if (!strncmp (s, *p, length) && *(*p + length) == '=')
|
||||
break;
|
||||
p++;
|
||||
if (strncmp (s, p[0], length) == 0)
|
||||
{
|
||||
char *q = p[0] + length;
|
||||
if (q[0] == '=')
|
||||
break;
|
||||
}
|
||||
p = p + M2_PTR_SIZE;
|
||||
}
|
||||
char *entry = malloc (length + strlen (v) + 2);
|
||||
int end_p = *p == 0;
|
||||
*p = entry;
|
||||
int end_p = p[0] == 0;
|
||||
p[0] = entry;
|
||||
strcpy (entry, s);
|
||||
strcpy (entry + length, "=");
|
||||
strcpy (entry + length + 1, v);
|
||||
*(entry + length + strlen (v) + 2) = 0;
|
||||
if (end_p)
|
||||
*++p = 0;
|
||||
entry[length + strlen (v) + 2] = 0;
|
||||
if (end_p != 0)
|
||||
p[1] = 0;
|
||||
|
||||
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,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -25,5 +25,8 @@
|
|||
int
|
||||
fflush (FILE * stream)
|
||||
{
|
||||
fsync ((long) stream);
|
||||
int filedes = (long) stream;
|
||||
if (filedes < 3)
|
||||
return 0;
|
||||
return fsync (filedes);
|
||||
}
|
||||
|
|
|
@ -18,11 +18,13 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
putchar (int c)
|
||||
{
|
||||
write (STDOUT, (char *) &c, 1);
|
||||
char *p = cast_intp_to_charp (&c);
|
||||
write (__stdout, p, 1);
|
||||
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,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -33,7 +33,7 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
if (*p != '%')
|
||||
{
|
||||
count++;
|
||||
fputc (*p++, fd);
|
||||
fputc (*p++, f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -88,7 +88,7 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
{
|
||||
case '%':
|
||||
{
|
||||
fputc (*p, fd);
|
||||
fputc (*p, f);
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
{
|
||||
char _c;
|
||||
_c = va_arg (ap, long);
|
||||
fputc (_c, fd);
|
||||
fputc (_c, f);
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
|
@ -108,7 +108,7 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
{
|
||||
long d = va_arg (ap, long);
|
||||
int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 10;
|
||||
char const *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X');
|
||||
char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X');
|
||||
if (c == 'X')
|
||||
strupr (s);
|
||||
int length = strlen (s);
|
||||
|
@ -182,6 +182,50 @@ vfprintf (FILE * f, char const *format, va_list ap)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
{
|
||||
double d = va_arg8 (ap, double);
|
||||
char *s = dtoab (d, 10, 1);
|
||||
if (c == 'E' || c == 'G')
|
||||
strupr (s);
|
||||
int length = strlen (s);
|
||||
if (precision == -1)
|
||||
precision = length;
|
||||
if (!left_p)
|
||||
{
|
||||
while (width-- > precision)
|
||||
{
|
||||
fputc (pad, f);
|
||||
count++;
|
||||
}
|
||||
while (precision > length)
|
||||
{
|
||||
fputc (' ', f);
|
||||
precision--;
|
||||
width--;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
while (*s)
|
||||
{
|
||||
if (precision-- <= 0)
|
||||
break;
|
||||
width--;
|
||||
fputc (*s++, f);
|
||||
count++;
|
||||
}
|
||||
while (width > 0)
|
||||
{
|
||||
width--;
|
||||
fputc (pad, f);
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
{
|
||||
int *n = va_arg (ap, int *);
|
||||
|
|
|
@ -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,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -114,7 +114,7 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
|||
{
|
||||
long d = va_arg (ap, long);
|
||||
int base = c == 'o' ? 8 : c == 'x' || c == 'X' ? 16 : 10;
|
||||
char const *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X');
|
||||
char *s = ntoab (d, base, c != 'u' && c != 'x' && c != 'X');
|
||||
if (c == 'X')
|
||||
strupr (s);
|
||||
int length = strlen (s);
|
||||
|
@ -198,6 +198,55 @@ vsnprintf (char *str, size_t size, char const *format, va_list ap)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
{
|
||||
double d = va_arg8 (ap, double);
|
||||
char *s = dtoab (d, 10, 1);
|
||||
if (c == 'E' || c == 'G')
|
||||
strupr (s);
|
||||
int length = strlen (s);
|
||||
if (precision == -1)
|
||||
precision = length;
|
||||
if (!left_p)
|
||||
{
|
||||
while (width-- > precision)
|
||||
{
|
||||
if (count < size)
|
||||
*str++ = pad;
|
||||
count++;
|
||||
}
|
||||
while (precision > length)
|
||||
{
|
||||
if (count < size)
|
||||
*str++ = ' ';
|
||||
precision--;
|
||||
width--;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
while (*s)
|
||||
{
|
||||
if (precision-- <= 0)
|
||||
break;
|
||||
width--;
|
||||
c = *s++;
|
||||
if (count < size)
|
||||
*str++ = c;
|
||||
count++;
|
||||
}
|
||||
while (width > 0)
|
||||
{
|
||||
width--;
|
||||
if (count < size)
|
||||
*str++ = pad;
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
{
|
||||
int *n = va_arg (ap, int *);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue