diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..d5e0c3a16 --- /dev/null +++ b/.clang-format @@ -0,0 +1,11 @@ +--- +BasedOnStyle: WebKit +AllowShortLoopsOnASingleLine: 'false' +AlwaysBreakAfterDefinitionReturnType: false +BreakBeforeBraces: Allman +IndentCaseLabels: 'true' +PointerAlignment: Left +TabWidth: '4' +UseTab: ForIndentation + +... diff --git a/.distr b/.distr index 971a46554..1009a685e 100644 --- a/.distr +++ b/.distr @@ -1,9 +1,7 @@ README CHANGES Copyright -pm -pmfile -config.pm +Makefile h modules/h @@ -13,7 +11,7 @@ util/data util/LLgen modules/src/alloc -modules/src/assert +#modules/src/assert modules/src/system modules/src/string modules/src/read_em @@ -31,7 +29,7 @@ util/ack lib/descr/fe util/arch #util/cpp -util/cgg +#util/cgg util/ncgg util/misc util/opt @@ -43,15 +41,22 @@ lang/cem lang/pc lang/m2 #lang/occam -#lang/basic +lang/basic mach/proto mach/i80 mach/i86 mach/i386 +mach/m68020 +mach/vc4 +plat plat/cpm plat/pc86 +plat/linux plat/linux386 +plat/linux68k +plat/rpi examples +man diff --git a/.hgignore b/.hgignore new file mode 100644 index 000000000..231210b94 --- /dev/null +++ b/.hgignore @@ -0,0 +1,3 @@ +.obj +.sass-cache +_site diff --git a/.hgtags b/.hgtags deleted file mode 100644 index 425e6c9c6..000000000 --- a/.hgtags +++ /dev/null @@ -1,9 +0,0 @@ -5a0daa6017c4aa5ae23b870e97eb7431021762bc distr2 -15b742c4c278c27029eca0e41f16463bc076de6e distr3 -a0686e2ca8d6780ce37b8267b865f60e9317a340 llgen-1-0 -d96cd06672c368e8aaa584fead379ce1d343acad oct-1 -bf69b3579e8545ecfc03f5e2550586e3c479270d release-6-0-pre-4 -e880082b57f12a7df1c33a2da2c7424d6368f185 dist2 -fe535e3e8bc859d4a4e4a186f42670f9e588a5aa release-5-6 -90102c21c4480102634c6a482d0dd55f2d9ca00f release-6-0-pre-3 -ddc0de0e5e7d91b1dcd7c05602c9c2a6adf8d312 release-6-0-pre-1 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..2852603af --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +before_install: + - sudo apt-get install ed lua5.1 liblua5.1-posix1 ninja-build +language: c +script: + - make PREFIX=/tmp/acki -j4 + diff --git a/CHANGES b/CHANGES index b7bd2edd1..ddc6bfc97 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ # $State$ # $Revision$ +6.1pre1 + + Threw away the make-based build system, because it just didn't work. Wrote + ackbuilder. Many, many little bugfixes and cleanups, too many to remember. + 6.0pre4 Fixed some minor bit-rotting issues that were preventing compilation on @@ -32,4 +37,4 @@ compilers, Pascal, Modula-2, Basic and Occam. Working backends: i86. Working platforms: pc86, the very noddy testbed setup that produces floppy disk images. - \ No newline at end of file + diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..af143bcfa --- /dev/null +++ b/Makefile @@ -0,0 +1,104 @@ +# ======================================================================= # +# ACK CONFIGURATION # +# (Edit this before building) # +# ======================================================================= # + +# What platform to build for by default? + +DEFAULT_PLATFORM = pc86 + +# Where should the ACK put its temporary files? + +ACK_TEMP_DIR = /tmp + +# Where is the ACK going to be installed, eventually? If you don't want to +# install it and just want to run the ACK from the build directory +# (/tmp/ack-build/staging, by default), leave this as $(INSDIR). + +#PREFIX = /usr/local +PREFIX = $(INSDIR) + +# Where do you want to put the object files used when building? + +BUILDDIR = $(ACK_TEMP_DIR)/ack-build + +# What build flags do you want to use? + +CFLAGS = -g +LDFLAGS = + +# Various commands. + +AR = ar +CC = gcc + +# Which build system to use; use 'ninja' or 'make' (in lower case). Leave +# blank to autodetect. + +BUILDSYSTEM = + +# Build flags for ninja. + +NINJAFLAGS = + +# Build flags for make. + +MAKEFLAGS = -r + +# ======================================================================= # +# END OF CONFIGURATION # +# ======================================================================= # + +# You shouldn't need to change anything below this point unless you are +# actually developing ACK. + +OBJDIR = $(abspath $(BUILDDIR)/obj) +BINDIR = $(abspath $(BUILDDIR)/bin) +LIBDIR = $(abspath $(BUILDDIR)/lib) +INCDIR = $(abspath $(BUILDDIR)/include) +INSDIR = $(abspath $(BUILDDIR)/staging) + +PLATIND = $(INSDIR)/share/ack +PLATDEP = $(INSDIR)/lib/ack + +MAKECMDGOALS ?= +ack +BUILD_FILES = $(shell find * -name '*.lua') + +ifneq ($(shell which ninja),) +BUILDSYSTEM = ninja +BUILDFLAGS = $(NINJAFLAGS) +else +BUILDSYSTEM = make +BUILDFLAGS = $(MAKEFLAGS) +endif + +ifneq ($(findstring +, $(MAKECMDGOALS)),) + +$(MAKECMDGOALS): $(BUILDDIR)/build.$(BUILDSYSTEM) + @$(BUILDSYSTEM) $(BUILDFLAGS) -f $^ $(MAKECMDGOALS) + +endif + +$(BUILDDIR)/build.$(BUILDSYSTEM): first/ackbuilder.lua Makefile $(BUILD_FILES) + @mkdir -p $(BUILDDIR) + @lua5.1 first/ackbuilder.lua \ + first/build.lua build.lua \ + --$(BUILDSYSTEM) \ + OBJDIR=$(OBJDIR) \ + BINDIR=$(BINDIR) \ + LIBDIR=$(LIBDIR) \ + INCDIR=$(INCDIR) \ + INSDIR=$(INSDIR) \ + PLATIND=$(PLATIND) \ + PLATDEP=$(PLATDEP) \ + AR=$(AR) \ + CC=$(CC) \ + > $(BUILDDIR)/build.$(BUILDSYSTEM) + +install: + mkdir -p $(PREFIX) + tar cf - -C $(INSDIR) . | tar xvf - -C $(PREFIX) + +clean: + @rm -rf $(BUILDDIR) + diff --git a/README b/README index 956623d1e..701581f17 100644 --- a/README +++ b/README @@ -1,8 +1,8 @@ - THE AMSTERDAM COMPILER KIT V6.0pre4 + THE AMSTERDAM COMPILER KIT V6.1pre1 =================================== © 1987-2005 Vrije Universiteit, Amsterdam - 2010-08-08 + 2016-08-02 INTRODUCTION @@ -13,10 +13,10 @@ front end compilers for a number of different languages, code generators, support libraries, and all the tools necessary to go from source code to executable on any of the platforms it supports. -This is an early prerelease of the apocryphal version 6.0 release. Not a +This is an early prerelease of the apocryphal version 6.1 release. Not a lot is supported, the build mechanism needs work, and a lot of things are probably broken. However, what's there should be sufficient to get things -done and to evaluate how the full 6.0 release should work. +done and to evaluate how the full 6.1 release should work. SUPPORT @@ -24,59 +24,68 @@ SUPPORT Languages: -ANSI C, Pascal, Modula 2. K&R is supported via the ANSI C compiler. +ANSI C, Pascal, Modula 2, Basic. K&R is supported via the ANSI C compiler. Platforms: pc86 produces bootable floppy disk images for 8086 PCs linux386 produces ELF executables for PC Linux systems +linux68k produces ELF executables for m68020 Linux systems cpm produces i80 CP/M .COM files +rpi produces Raspberry Pi GPU binaries INSTALLATION ============ -The version 6.0 build mechanism has been completely rewritten and is based -around the Prime Mover build tool (see http://primemover.sf.net for more -information). Installation ought to be fairly straightforward. +The version 5.0 build mechanism has been completely rewritten. Installation +ought to be fairly straightforward. Requirements: -- an ANSI C compiler. Currently, I'm afraid, it's hard-coded to use gcc. - To change, try changing the variable definitions in first/c.pm. This also - needs to be available as 'cc' from the shell. - -- about 20MB free in /tmp (or some other temporary directory). +- an ANSI C compiler. This defaults to gcc. You can change this by setting + the CC make variable. + +- flex and yacc. + +- GNU make. + +- Lua 5.1 and the luaposix library (used by the build system). + +- (optionally) ninja; if you've got this, this will be autodetected and give + you faster builds. + +- about 40MB free in /tmp (or some other temporary directory). - about 6MB in the target directory. Instructions: -- edit config.pm. There's a small section at the top containing some editable - variables. Probably the only one you may want to edit is PREFIX, which - changes where the ACK installs to. - +- edit the Makefile. There's a small section at the top where you can change + the configuration. Probably the only one you may want to edit is PREFIX, + which changes where the ACK installs to. + - Run: - ./pm configure - - ...from the command line. This will write out a configuration file. - + make + + ...from the command line. This will do the build. + + The make system is fully parallelisable. If you have a multicore system, + install ninja and it'll use all your cores. If you don't have ninja, you + can still use make for parallel builds with: + + make MAKEFLAGS='-r -j8' # or however many cores you have + + ...but frankly, I recommend ninja. + - Run: - ./pm - - ...from the command line. This will actually do the build. This takes - about two minutes on my 1.6GHz Athlon Linux machine and about 30 on my - 166MHz Pentium OpenBSD machine. - -- Run: + sudo make install + + ...from the command line. This will install the ACK in your PREFIX + directory (by default, /usr/local). - ./pm install - - ...from the command line (possibly with sudo). This will install the built - ACK into whatever directory you nominated in PREFIX. - The ACK should now be ready to use. @@ -94,8 +103,9 @@ Some useful options include: -o specifies the output file -c produce a .o file -c.s produce a .s assembly file - -O enable optimisation + -O enable optimisation (optimisation levels go up to 6) -ansi compile ANSI C (when using the C compiler) + -v be more verbose (repeatable) build file ack figures out which language to use from the file extension: @@ -107,6 +117,7 @@ ack figures out which language to use from the file extension: .p Pascal .o object files .s assembly files + .e ACK intermediate code assembly files For further information, see the man page (which actually does get installed, but is rather out of date). @@ -117,12 +128,13 @@ A sample command line is: ack -mlinux386 -O examples/paranoia.c + GOTCHAS ======= There are some things you should be aware of. -- Look at plat//README for information about the two supported +- Look at plat//README for information about the supported platforms. - The library support is fairly limited; for C, it's at roughly the ANSI C @@ -138,6 +150,10 @@ There are some things you should be aware of. - The ACK uses its own .o format. You won't be able to mix the ACK's object files and another compiler's. +- The distribution contains *everything*, including the weird, ancient, + archaic stuff that doesn't work any more and never will, such as the int EM + interpreter and the assembler-linkers. Only some of it builds. Look for + build.lua files. DISCLAIMER ========== @@ -163,8 +179,4 @@ Please enjoy. David Given (dtrg on Sourceforge) dg@cowlark.com -2010-08-08 - -# $Source$ -# $State$ -# $Revision$ +2016-08-02 diff --git a/bin/.distr b/bin/.distr deleted file mode 100644 index 96768b1ae..000000000 --- a/bin/.distr +++ /dev/null @@ -1,9 +0,0 @@ -cc-and-mkdep.ack -cc-and-mkdep.all -cc-and-mkdep.sun -do_deps -do_resolve -lint-lib.ack -lint-lib.unix -mk_manpage -rm_deps diff --git a/build.lua b/build.lua new file mode 100644 index 000000000..b5de879c8 --- /dev/null +++ b/build.lua @@ -0,0 +1,38 @@ +vars.cflags = { + "-g", "-O" +} +vars.ackcflags = { + "-O6" +} +vars.plats = { + "cpm", + "linux386", + "linux68k", + "pc86", + "rpi", +} + +local plat_packages = {} +for _, p in ipairs(vars.plats) do + plat_packages[#plat_packages+1] = "plat/"..p.."+pkg" +end + +installable { + name = "ack", + map = { + "lang/basic/src+pkg", + "lang/cem/cemcom.ansi+pkg", + "lang/m2/comp+pkg", + "lang/pc/comp+pkg", + "util/ack+pkg", + "util/amisc+pkg", + "util/arch+pkg", + "util/ego+pkg", + "util/led+pkg", + "util/misc+pkg", + "util/opt+pkg", + "examples+pkg", + plat_packages + } +} + diff --git a/config.pm b/config.pm index 1d59b7f0c..79dc7c55a 100644 --- a/config.pm +++ b/config.pm @@ -13,7 +13,7 @@ ACK_TEMP_DIR = "/tmp" -- Where is the ACK going to be installed, eventually? -PREFIX = "/usr/local" +PREFIX = "/tmp/ack-temp/staging" -- ======================================================================= -- -- BROKEN ACK CONFIGURATION -- diff --git a/distr/Exceptions b/distr/Exceptions deleted file mode 100644 index edd5a5724..000000000 --- a/distr/Exceptions +++ /dev/null @@ -1,15 +0,0 @@ -++ ./doc/install.pr made -++ ./doc/int/.distr made -++ ./etc/new_table_done made -++ ./lang/cem/cemcom.ansi/Version.c made -++ ./lang/cem/libcc.ansi/stdlib/malloc.c made -++ ./lang/cem/cemcom/Version.c made -++ ./lang/pc/comp/Version.c made -++ ./lang/m2/comp/Version.c made -++ ./lang/m2/m2mm/Version.c made -++ ./mach/sparc/ce/EM_table made -++ ./mach/sparc_solaris/libem/LIST made -++ ./util/LLgen/src/LLgen.c.dist made -++ ./util/cpp/Version.c made -++ ./util/ego/share/pop_push.h made -++ ./util/grind/ops.c made diff --git a/distr/How_To b/distr/How_To deleted file mode 100644 index 17ec1ad39..000000000 --- a/distr/How_To +++ /dev/null @@ -1,90 +0,0 @@ -How to make a distribution --------------------------- - -I have written a new tool to generate the distributions that does not rely on -having a local CVS server --- distr/mkdist. - -To use it, you need to specify your CVS work tree, the destination directory -that the distribution will be written to, plus flags. It should be self- -documenting; use: - - mkdist --help - -...to get documentation. - -It uses .distr files in exactly the same way as the previous mechanism. - -The documentation for the old distribution tools follows. - -David Given -dg@cowlark.com -2005-06-25 - ------------------------------------------------------------------------------ - -How to make a fresh distribution: -For a distribution you need ".distr" files and RCS files. -The EM home directory contains a file called ".distr". It contains -the names of all the files and directories you want to have in the distribution. -The directories should contain .distr files, the other files should -be placed under CVS. -There are files that derive from other files and yet should be placed -in the distribution. -These files should not be placed under RCS or CVS. -The file "Exceptions" in this directory contains the current list of -these files. - -When all this is correct, use the shell script mktree the extract -the distribution from the EM tree. - sh mktree destination_tree repository_tree 2>f.attf -Use the "cvs rtag" command to give the distribution a name first! -Make sure that the destination tree exists and is empty! -Failing to do that will almost certainly result in a welter of -error messages. -The file f.attf contains mktree error messages and should be compared -to Exceptions. -The actions of mktree are quite complicated. It starts in the current -directory creating a version in the destination directory. -Then it reads the .distr file. -For each file mentioned there it performes certain actions: -1- Directory Change to that directory and call yourself recursively. -2- File - a- Does a file LIST exist in this directory AND - is the first line of LIST equal to the name of the - destination file? If so, try to extract all the files - named in the rest of the LIST file and call the program - arch to create a library "arch cDr `cat LIST`". - In this manner libraries can be distributed whose members - have their own RCS file. - else - b- Try to run 'make distr' - else - c- Try to run 'make ' - else - d- give message that says "not present" (or some such). - -Now, the tree contains all the files in the distribution, but it also contains -files that should not be in the distribution, especially the files created -by CVS. -That is why we now give the command: - dtar cdf distr . -The file distr is the one you should put on tape! -But,.... before doing that: Try it out! -Repeat the process described in the installation manual. -Only if that succeeds you are sure that you included the files needed. - Good Luck, - Ed Keizer, 85/4/15. - -Updated for 3rd distribution by Ceriel Jacobs, 87/3/11. -And again, - Good Luck! - -Updated for 4th distribution by Ceriel Jacobs, 88/4/08. -And again, - Good Luck! -Updated for 5th distribution by Ceriel Jacobs, 91/19/12. -And again, - Good Luck! -Updated for 1st upgrade to 5th distribution by Ceriel Jacobs, 91/12/11. -And again, - Good Luck! diff --git a/distr/dwalk b/distr/dwalk deleted file mode 100755 index 1a869f105..000000000 --- a/distr/dwalk +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -: ${CDIR=.} -${DF-:} $CDIR .distr -if test ! -r $DESTDIR/$CDIR/.distr -then - echo ++ no .distr in $CDIR 1>&2 - exit 0 -fi -for i in `cat $DESTDIR/$CDIR/.distr` -do - if test -d $i - then - ( if cd $i - then - CDIR=$CDIR/$i - export CDIR - exec $DDIR/dwalk $* - else - echo ++ Could not access $CDIR/$i 1>&2 - fi - ) - else - ${DF-:} $CDIR $i - fi -done diff --git a/distr/echod b/distr/echod deleted file mode 100755 index 9fb9840d0..000000000 --- a/distr/echod +++ /dev/null @@ -1 +0,0 @@ -echo $1 diff --git a/distr/listall b/distr/listall deleted file mode 100755 index 0bacb4932..000000000 --- a/distr/listall +++ /dev/null @@ -1,10 +0,0 @@ -case $# in -0) DESTDIR=. ;; -1) DESTDIR=$1 ;; -*) echo $0 [directory] ; exit 1 ;; -esac -DD=`pwd`/listall.d -DW=`pwd`/dwalk -export DD DESTDIR -cd $DESTDIR -$DW diff --git a/distr/listall.d b/distr/listall.d deleted file mode 100755 index d66cf179c..000000000 --- a/distr/listall.d +++ /dev/null @@ -1,2 +0,0 @@ -echo "<$1>" -ls -bCdx `cat .distr` diff --git a/distr/listdirs b/distr/listdirs deleted file mode 100755 index 9d5d3c1f1..000000000 --- a/distr/listdirs +++ /dev/null @@ -1,10 +0,0 @@ -case $# in -0) DIR=. ;; -1) DIR=$1 ;; -*) echo $0 [directory] ; exit 1 ;; -esac -DD=`pwd`/echod -DW=`pwd`/dwalk -export DD -cd $DIR -$DW diff --git a/distr/mk_distr_syms b/distr/mk_distr_syms deleted file mode 100755 index 8263c1181..000000000 --- a/distr/mk_distr_syms +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -: Utility to make a tree of symbolic links to source tree. -: Mount the source tree read-only, use this script, and then try installation. -case $# in -2) ;; -*) echo "Usage: $0 " 1>&2 - exit 1 - ;; -esac -if [ -f $1/.distr ] -then - for i in `cat $1/.distr` - do - if [ -d $1/$i ] - then - if mkdir $2/$i && $0 $1/$i $2/$i - then - : - else - exit 2 - fi - else - if [ -f $1/$i ] - then - if ln -s $1/$i $2/$i - then - : - else - exit 3 - fi - else - echo "Missing file $1/$i" 1>&2 - exit 4 - fi - fi - done -else - echo "No .distr file in $1" 1>&2 - exit 5 -fi diff --git a/distr/mka b/distr/mka deleted file mode 100755 index 1581e662b..000000000 --- a/distr/mka +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -e -for i in `tail +2 $DESTDIR/$1/LIST` -do - ${DF-false} $1 $i -done -cd $DESTDIR/$1 -arch cDr `cat LIST` -: I do not remove the files constituating the library, because -: they might be present in .distr diff --git a/distr/mkdist b/distr/mkdist deleted file mode 100755 index 2e2653430..000000000 --- a/distr/mkdist +++ /dev/null @@ -1,177 +0,0 @@ -#!/bin/sh -# $Source$ -# $State$ - -# Set up default variables. - -destdir= -srcdir=`pwd` -arch=/usr/local/bin/arch -delete=no -copy="ln" - -# --- Options parsing ------------------------------------------------------- - -while [ "$1" != "" ]; do - case "$1" in - -s|--srcdir) - srcdir="$2" - shift - ;; - - -d|--destdir) - destdir="$2" - shift - ;; - - -x|--delete) - delete=yes - ;; - - -c|--copy) - copy="cp -Rp" - ;; - - -S|--symlink) - copy="ln -s" - ;; - - -a|--arch) - arch="$2" - shift - ;; - - -h|--help) - echo "mkdist [options]" - echo "Options are:" - echo " -s --srcdir The CVS tree to read from. (default: CWD)" - echo " -d --destdir The directory to create the distribution in." - echo " -x --delete Erase the destination directory first." - echo " -c --copy Make physical copies of the files. (default: hardlink)" - echo " -S --symlink Make symbolic links instead of copying or hardlinking." - echo " -a --arch Where the ACK 'arch' tool is." - echo " -h --help Display this message." - exit 0 - ;; - - *) - echo "Unrecognised option. Try --help for help." - exit 1 - esac - shift -done - -if [ "$destdir" = "" ]; then - echo "You must specify a destination directory. (Try --help for help.)" - exit 1 -fi - -# --- Main routines --------------------------------------------------------- - -# These two routines do the work of traversing the source tree and building -# the distribution tree. - -addfile() { - local f - f="${1##$srcdir/}" - mkdir -p $destdir/`dirname $f` - $copy "$1" "$destdir/$f" -} - -process_dir() { - local path - local archivename - - path=$1 - cd $path - echo $PWD - - # Look for a LIST file and cache the first line. - - archivename= - if [ -f LIST ]; then - archivename=`head -1 LIST` - fi - - for i in `cat $path/.distr`; do - case "$i" in - \#*) # Comment. Do nothing. - ;; - - *) - if [ -d $i ]; then - # This is a directory. Recurse into it. - - ( process_dir $path/$i ) - elif [ -f $i ]; then - # This is a file. - - addfile $path/$i - elif [ "$i" = "$archivename" ]; then - # Build the named archive. - - $arch cDr `cat LIST` - addfile $path/$archivename - else - echo "Don't know what to do with $i, listed in $PWD/.distr." - exit 1 - fi - ;; - esac - done -} - -# --- Main program ---------------------------------------------------------- - -# Test to make sure that $arch points to the right thing. - -if !(strings $arch | grep archiver > /dev/null); then - echo "$arch does not seem to point at the ACK archiver tool." - echo "(Don't confuse this with the Linux tool for displaying your" - echo "architecture.)" - echo "" - echo "Press RETURN to go ahead anyway, or CTRL+C to abort." - read ignored -fi - -# Actually do the work. - -echo "Creating distribution from CVS tree: $srcdir" -echo " into destination tree: $destdir" -echo "" - -if [ -e $destdir ]; then - if [ "$delete" = "yes" ]; then - echo "Press RETURN to erase $destdir and its contents, or CTRL+C to abort." - read - echo "Erasing..." - rm -rf "$destdir" - else - echo "$destdir exists. Aborting." - exit 1 - fi -fi - -echo "Working..." -mkdir -p $destdir -process_dir $srcdir -echo "Done." - -# Revision history -# $Log$ -# Revision 1.5 2007-04-24 19:48:41 dtrg -# Removed bashish. -# -# Revision 1.4 2007/02/25 20:56:41 dtrg -# Performed major renovations to make the script work on OpenBSD. -# -# Revision 1.3 2007/02/24 02:05:56 dtrg -# Removed some bashish; added comment support; removed the make -# distr functionality, as nothing was using it any more and it was -# causing problems. -# -# Revision 1.2 2005/06/24 23:19:23 dtrg -# Added new mkdist tool. -# -# Revision 1.1 2005/06/24 22:13:57 dtrg -# Created new tool to generate distributions. diff --git a/distr/mkf b/distr/mkf deleted file mode 100755 index c7f572f91..000000000 --- a/distr/mkf +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -if [ -f $DESTDIR/$1/$2 ] -then - : -elif grep LIST $DESTDIR/$1/.distr >/dev/null 2>&1 && - (test "$2" = "`head -1 $DESTDIR/$1/LIST`") >/dev/null 2>&1 && - ${DA-false} "$1" "$2" -then -: Fetched library contents one by one and put them together -elif ( cd $DESTDIR/$1 ; make distr ) > /dev/null 2>&1 -then - echo ++ $1/$2 made 1>&2 -elif ( cd $DESTDIR/$1 ; make $2 ) > /dev/null 2>&1 -then - echo ++ $1/$2 made 1>&2 -else - echo ++ $1/$2 not present 1>&2 -fi diff --git a/distr/mktree b/distr/mktree deleted file mode 100644 index 037fa4086..000000000 --- a/distr/mktree +++ /dev/null @@ -1,42 +0,0 @@ -case $# in -2|3) ;; -*) echo Usage: $0 directory repdir [ SVrecord ] 1>&2 ; exit 1 ;; -esac -case $0 in -/*) DDIR=`dirname $0` - ;; -*) DDIR=`pwd`/`dirname $0` - ;; -esac -case $1 in -/*) DESTDIR=$1 ;; -*) DESTDIR=`pwd`/$1 ;; -esac -case $2 in -/*) REPDIR=$2 ;; -*) REPDIR=`pwd`/$2 ;; -esac -# DD=$DDIR/mkd -# export DD -mkdir -p $DESTDIR -CVSROOT=/usr/proj/em/Repositories -export CVSROOT -cd $DESTDIR -case $# in -3) - cvs checkout world -r $3 - ;; -2) - cvs checkout world - ;; -esac -cd $REPDIR -DF=$DDIR/mkf -DA=$DDIR/mka -export DDIR DESTDIR DF DA REPDIR - -$DDIR/dwalk - -cd $DESTDIR -find . -type d -print | xargs chmod "uog+rx" -chmod -R "og-w,u+w,uog+r" . diff --git a/distr/todistr b/distr/todistr deleted file mode 100644 index 5b171453b..000000000 --- a/distr/todistr +++ /dev/null @@ -1,26 +0,0 @@ -REV= -FILE= -while : -do - case $# in - 0) break ;; - esac - ARG="$1" - shift - case "$ARG" in - -r*) REV=`echo "$ARG"| sed s/-r//` ;; - -*) FLAGS="$FLAGS $ARG" ;; - *) case x$FILE in - x) FILE="$ARG" ;; - *) echo todistr can only be done on one file at the time - exit 1 ;; - esac - esac -done -case x$REV in -x) REV=`rlog -h "$FILE"|sed -n -e '/head/s/^head:[ ]*//p'` ;; -esac -case x$REV in -x) exit 2 ;; -esac -rcs -ndistr4:$REV $FLAGS $FILE diff --git a/distr/ts b/distr/ts deleted file mode 100755 index 8350341b2..000000000 --- a/distr/ts +++ /dev/null @@ -1,2 +0,0 @@ -DD=`pwd`/ts -echo OK diff --git a/doc/.distr b/doc/.distr deleted file mode 100644 index ba9928276..000000000 --- a/doc/.distr +++ /dev/null @@ -1,32 +0,0 @@ -READ_ME -Makefile -proto.make -ack.doc -basic.doc -cg.doc -crefman.doc -ansi_C.doc -em -install.doc -install.pr -ncg.doc -pcref.doc -peep.doc -regadd.doc -toolkit.doc -v7bugs.doc -val.doc -6500.doc -i80.doc -z80.doc -m68020.doc -m2ref.doc -nopt.doc -top -ego -occam -int -ceg -sparc -lint -pascal diff --git a/doc/LLgen/.distr b/doc/LLgen/.distr deleted file mode 100644 index 5215a59c7..000000000 --- a/doc/LLgen/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LLgen.n -LLgen_NCER.n -LLgen.refs -proto.make diff --git a/doc/ceg/.distr b/doc/ceg/.distr deleted file mode 100644 index 92c3fa3af..000000000 --- a/doc/ceg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -ceg.ref -ceg.tr diff --git a/doc/ego/.distr b/doc/ego/.distr deleted file mode 100644 index 17d03f8d5..000000000 --- a/doc/ego/.distr +++ /dev/null @@ -1,18 +0,0 @@ -proto.make -bo -ca -cf -cj -cs -ic -il -intro -lv -ov -ra -refs.gen -refs.opt -refs.stat -sp -sr -ud diff --git a/doc/ego/bo/.distr b/doc/ego/bo/.distr deleted file mode 100644 index 8f41f100d..000000000 --- a/doc/ego/bo/.distr +++ /dev/null @@ -1 +0,0 @@ -bo1 diff --git a/doc/ego/ca/.distr b/doc/ego/ca/.distr deleted file mode 100644 index 4723880e2..000000000 --- a/doc/ego/ca/.distr +++ /dev/null @@ -1 +0,0 @@ -ca1 diff --git a/doc/ego/cf/.distr b/doc/ego/cf/.distr deleted file mode 100644 index 6aff9ca72..000000000 --- a/doc/ego/cf/.distr +++ /dev/null @@ -1,6 +0,0 @@ -cf1 -cf2 -cf3 -cf4 -cf5 -cf6 diff --git a/doc/ego/cj/.distr b/doc/ego/cj/.distr deleted file mode 100644 index a92acc3b1..000000000 --- a/doc/ego/cj/.distr +++ /dev/null @@ -1 +0,0 @@ -cj1 diff --git a/doc/ego/cs/.distr b/doc/ego/cs/.distr deleted file mode 100644 index 99b8c7793..000000000 --- a/doc/ego/cs/.distr +++ /dev/null @@ -1,5 +0,0 @@ -cs1 -cs2 -cs3 -cs4 -cs5 diff --git a/doc/ego/ic/.distr b/doc/ego/ic/.distr deleted file mode 100644 index eabb41472..000000000 --- a/doc/ego/ic/.distr +++ /dev/null @@ -1,5 +0,0 @@ -ic1 -ic2 -ic3 -ic4 -ic5 diff --git a/doc/ego/il/.distr b/doc/ego/il/.distr deleted file mode 100644 index 2aac56865..000000000 --- a/doc/ego/il/.distr +++ /dev/null @@ -1,6 +0,0 @@ -il1 -il2 -il3 -il4 -il5 -il6 diff --git a/doc/ego/intro/.distr b/doc/ego/intro/.distr deleted file mode 100644 index 45de40776..000000000 --- a/doc/ego/intro/.distr +++ /dev/null @@ -1,3 +0,0 @@ -head -intro1 -tail diff --git a/doc/ego/lv/.distr b/doc/ego/lv/.distr deleted file mode 100644 index b82f3da53..000000000 --- a/doc/ego/lv/.distr +++ /dev/null @@ -1 +0,0 @@ -lv1 diff --git a/doc/ego/ov/.distr b/doc/ego/ov/.distr deleted file mode 100644 index 9170d50dc..000000000 --- a/doc/ego/ov/.distr +++ /dev/null @@ -1 +0,0 @@ -ov1 diff --git a/doc/ego/ra/.distr b/doc/ego/ra/.distr deleted file mode 100644 index d9cbc6df4..000000000 --- a/doc/ego/ra/.distr +++ /dev/null @@ -1,4 +0,0 @@ -ra1 -ra2 -ra3 -ra4 diff --git a/doc/ego/sp/.distr b/doc/ego/sp/.distr deleted file mode 100644 index fb3527e1b..000000000 --- a/doc/ego/sp/.distr +++ /dev/null @@ -1 +0,0 @@ -sp1 diff --git a/doc/ego/sr/.distr b/doc/ego/sr/.distr deleted file mode 100644 index 6de854118..000000000 --- a/doc/ego/sr/.distr +++ /dev/null @@ -1,4 +0,0 @@ -sr1 -sr2 -sr3 -sr4 diff --git a/doc/ego/ud/.distr b/doc/ego/ud/.distr deleted file mode 100644 index f64dc1145..000000000 --- a/doc/ego/ud/.distr +++ /dev/null @@ -1,5 +0,0 @@ -ud1 -ud2 -ud3 -ud4 -ud5 diff --git a/doc/em/.distr b/doc/em/.distr deleted file mode 100644 index 76d9cae6b..000000000 --- a/doc/em/.distr +++ /dev/null @@ -1,28 +0,0 @@ -proto.make -READ_ME -app.codes.nr -app.exam.nr -assem.nr -cont.nr -descr.nr -dspace.nr -em.i -env.nr -even.c -exam.e -exam.p -int -intro.nr -ip.awk -ispace.nr -mach.nr -macr.nr -mapping.nr -mem.nr -title.nr -traps.nr -types.nr -mkdispatch.c -dispat1.sed -dispat2.sed -dispat3.sed diff --git a/doc/em/int/.distr b/doc/em/int/.distr deleted file mode 100644 index 8fb14befa..000000000 --- a/doc/em/int/.distr +++ /dev/null @@ -1,5 +0,0 @@ -proto.make -READ_ME -em.p -emdmp.c -mktables.c diff --git a/doc/lint/.distr b/doc/lint/.distr deleted file mode 100644 index 9c1cf0954..000000000 --- a/doc/lint/.distr +++ /dev/null @@ -1,15 +0,0 @@ -proto.make -abstract -appendix_A -appendix_B -chap1 -chap2 -chap3 -chap4 -chap5 -chap6 -chap7 -chap8 -chap9 -contents -frontpage diff --git a/doc/occam/.distr b/doc/occam/.distr deleted file mode 100644 index 08cf9cf3b..000000000 --- a/doc/occam/.distr +++ /dev/null @@ -1,12 +0,0 @@ -proto.make -ctot -p0 -p1 -p2 -p3 -p4 -p5 -p6 -p7 -p8 -p9 diff --git a/doc/pascal/.distr b/doc/pascal/.distr deleted file mode 100644 index 44bb76092..000000000 --- a/doc/pascal/.distr +++ /dev/null @@ -1,20 +0,0 @@ -ab+intro.doc -compar.doc -conf.doc -contents.doc -deviations.doc -example.doc -extensions.doc -hints.doc -his.doc -improv.doc -internal.doc -options.doc -proto.make -reference.doc -rtl.doc -syntax.doc -test.doc -titlepg.doc -transpem.doc -vrk.doc diff --git a/doc/sparc/.distr b/doc/sparc/.distr deleted file mode 100644 index bed3d274f..000000000 --- a/doc/sparc/.distr +++ /dev/null @@ -1,15 +0,0 @@ -1 -2 -3 -4 -5 -A -B -init -intro -note_on_reg_wins -refs -timing -title -proto.make -pics diff --git a/doc/sparc/pics/.distr b/doc/sparc/pics/.distr deleted file mode 100644 index 32d6efca8..000000000 --- a/doc/sparc/pics/.distr +++ /dev/null @@ -1,12 +0,0 @@ -EM_stack.orig -EM_stack.ours -compile_bars -mem_config -perf -perf.comp -perf.d -perf.dhry -reg_layout -run-time_bars -run-time_bars.bup -signal_stack diff --git a/doc/top/.distr b/doc/top/.distr deleted file mode 100644 index 32161cf4b..000000000 --- a/doc/top/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -refs.top -top.n diff --git a/emtest/.distr b/emtest/.distr deleted file mode 100644 index 3d60866ba..000000000 --- a/emtest/.distr +++ /dev/null @@ -1,6 +0,0 @@ -Makefile -READ_ME -ok -select.c -test.h -tests diff --git a/etc/.distr b/etc/.distr deleted file mode 100644 index b9c5d3c85..000000000 --- a/etc/.distr +++ /dev/null @@ -1,7 +0,0 @@ -proto.make -em_table -new_table -new_table_done -pop_push -traps -ip_spec.t diff --git a/examples/.distr b/examples/.distr deleted file mode 100644 index 3469c16ff..000000000 --- a/examples/.distr +++ /dev/null @@ -1,10 +0,0 @@ -hilo.b -hilo.c -hilo.mod -hilo.ocm -hilo.p -mandelbrot.c -paranoia.c -startrek.c -startrek.doc -README diff --git a/examples/build.lua b/examples/build.lua new file mode 100644 index 000000000..631752976 --- /dev/null +++ b/examples/build.lua @@ -0,0 +1,44 @@ +include("plat/build.lua") + +local conly = { + rpi = true +} + +local sourcefiles = filenamesof( + "./hilo.b", + "./hilo.c", + "./hilo.mod", + "./hilo.p", + "./mandelbrot.c", + "./paranoia.c", + "./startrek.c" +) + +local installmap = {} +for _, file in ipairs(sourcefiles) do + local b = basename(file) + local be = replace(b, "%.", "_") + local _, _, e = b:find("%.(%w*)$") + + for _, plat in ipairs(vars.plats) do + if (e == "c") or not conly[plat] then + local exe = ackprogram { + name = be.."_"..plat, + srcs = { file }, + vars = { + plat = plat, + lang = e, + } + } + + installmap["$(PLATIND)/examples/"..be.."."..plat] = exe + end + end + installmap["$(PLATIND)/examples/"..b] = file +end + +installable { + name = "pkg", + map = installmap +} + diff --git a/fast/.distr b/fast/.distr deleted file mode 100644 index 08ea893ed..000000000 --- a/fast/.distr +++ /dev/null @@ -1,6 +0,0 @@ -Action -driver -f_c.ansi -f_c -f_m2 -f_pc diff --git a/fast/driver/.distr b/fast/driver/.distr deleted file mode 100644 index 467369b36..000000000 --- a/fast/driver/.distr +++ /dev/null @@ -1,5 +0,0 @@ -afcc.1 -afm2.1 -afpc.1 -driver.c -proto.make diff --git a/fast/f_c.ansi/.distr b/fast/f_c.ansi/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/fast/f_c.ansi/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/fast/f_c/.distr b/fast/f_c/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/fast/f_c/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/fast/f_m2/.distr b/fast/f_m2/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/fast/f_m2/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/fast/f_pc/.distr b/fast/f_pc/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/fast/f_pc/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/fcc/.distr b/fcc/.distr deleted file mode 100644 index 04696d0c4..000000000 --- a/fcc/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -cemcom -driver diff --git a/fcc/cemcom/.distr b/fcc/cemcom/.distr deleted file mode 100644 index 7f00154bd..000000000 --- a/fcc/cemcom/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Parameters.sun3 -Parameters.vax4 -proto.main -proto.make diff --git a/fcc/driver/.distr b/fcc/driver/.distr deleted file mode 100644 index ebc669f71..000000000 --- a/fcc/driver/.distr +++ /dev/null @@ -1,3 +0,0 @@ -fcc.1 -fcc.c -proto.make diff --git a/first/.distr b/first/.distr deleted file mode 100644 index 8bff7f59c..000000000 --- a/first/.distr +++ /dev/null @@ -1,24 +0,0 @@ -ack.pm -ack-custom.pm -c.pm -llgen.pm -yacc.pm - -#create_dir -#cp_dir -#em_path.h.src -#first -#get_answer -#get_makepars -#get_sys -#get_sysvax -#install_tail -#limit_enquire -#limit_impl -#lint_params -#local.h.src -#mk_config -#mk_makefile -#mk_target -#target_comp -#util_comp diff --git a/first/ack-custom.pm b/first/ack-custom.pm deleted file mode 100644 index a6b000dc4..000000000 --- a/first/ack-custom.pm +++ /dev/null @@ -1,21 +0,0 @@ --- $Source$ --- $State$ - --- Custom rules used by the ACK build process. - -preprocess = simple { - class = "preprocess", - outputs = {"%U%-%I%"}, - command = { - "cpp -I%HEADERDIR% %in% > %out[1]%" - } -} - --- Revision history --- $Log$ --- Revision 1.2 2007-02-20 00:32:58 dtrg --- Changed the 'preprocess' rule to use the system C preprocessor. --- --- Revision 1.1 2006/07/22 00:49:48 dtrg --- First version in CVS. --- diff --git a/first/ack.pm b/first/ack.pm deleted file mode 100644 index 6f3ac56ab..000000000 --- a/first/ack.pm +++ /dev/null @@ -1,33 +0,0 @@ --- $Source$ --- $State$ - --- Provides rules for building things with the half-built ACK itself. - -ACKBUILDFLAGS = {"-m%PLATFORM%", "%OPTIMISATION%"} -ACKDEFINES = EMPTY -ACKINCLUDES = EMPTY - -ackfile = simple_with_clike_dependencies { - class = "ackfile", - CINCLUDES = {REDIRECT, "ACKINCLUDES"}, - command = { - "%BINDIR%bin/ack %ACKBUILDFLAGS% %ACKINCLUDES:cincludes% %ACKDEFINES:cdefines% -c -o %out% %in%" - }, - outputs = {"%U%-%I%.o"}, -} - -ackprogram = simple { - class = "ackprogram", - command = { - "%BINDIR%bin/ack %ACKBUILDFLAGS% -o %out% %in%" - }, - outputs = {"%U%-%I%"}, -} - -acklibrary = simple { - class = "acklibrary", - command = { - "%RM% %out% && %BINDIR%bin/aal cr %out% %in%" - }, - outputs = {"%U%-%I%.a"}, -} diff --git a/first/ackbuilder.lua b/first/ackbuilder.lua new file mode 100644 index 000000000..282e6f185 --- /dev/null +++ b/first/ackbuilder.lua @@ -0,0 +1,916 @@ +local posix = require("posix") + +-- Targets: +-- +-- { +-- fullname = full name of target +-- dir = target's build directory +-- outs = target's object files +-- is = { set of rule types which made the target } +-- } + +local emitter = {} +local rules = {} +local targets = {} +local buildfiles = {} +local globals +local cwd = "." +local vars = {} +local parente = {} +local loadingstack = {} + +-- Forward references +local loadtarget + +local function print(...) + local function print_no_nl(list) + for _, s in ipairs(list) do + if (type(s) == "table") then + io.stderr:write("{") + for k, v in pairs(s) do + print_no_nl({k}) + io.stderr:write("=") + print_no_nl({v}) + io.stderr:write(" ") + end + io.stderr:write("}") + else + io.stderr:write(tostring(s)) + end + end + end + + print_no_nl({...}) + io.stderr:write("\n") +end + +local function assertString(s, i) + if (type(s) ~= "string") then + error(string.format("parameter %d must be a string", i)) + end +end + +local function concat(...) + local r = {} + + local function process(list) + for _, t in ipairs(list) do + if (type(t) == "table") and not t.is then + process(t) + else + r[#r+1] = t + end + end + end + process({...}) + + return r +end + +-- Test table membership (crudely). +local function contains(needle, haystack) + for _, k in ipairs(haystack) do + if (k == needle) then + return true + end + end + return false +end + +local function inherit(high, low) + local o = {} + setmetatable(o, { + __index = function(self, k) + local x = high[k] + if x then + return x + end + return low[k] + end + }) + for k, v in pairs(high) do + local _, _, kk = k:find("^%+(.*)$") + if kk then + o[kk] = concat(low[kk], v) + end + end + return o +end + +local function asstring(o) + local t = type(o) + if (t == "nil") then + return "" + elseif (t == "string") then + return o + elseif (t == "number") then + return o + elseif (t == "table") then + if o.is then + return asstring(o.outs) + else + local s = {} + for _, v in pairs(o) do + s[#s+1] = asstring(v) + end + return table.concat(s, " ") + end + else + error(string.format("can't turn values of type '%s' into strings", t)) + end +end + +local function concatpath(...) + local p = table.concat({...}, "/") + return (p:gsub("/+", "/"):gsub("^%./", ""):gsub("/%./", "/")) +end + +-- Returns a list of the targets within the given collection; the keys of any +-- keyed items are lost. Lists and wildcards are expanded. +local function targetsof(...) + local o = {} + + local function process(items) + for _, item in pairs(items) do + if (type(item) == "table") then + if item.is then + -- This is a target. + o[#o+1] = item + else + -- This is a list. + process(item) + end + elseif (type(item) == "string") then + -- Filename! + if item:find("^%+") then + item = cwd..item + elseif item:find("^%./") then + item = concatpath(cwd, item) + end + o[#o+1] = loadtarget(item) + else + error(string.format("member of target list is not a string or a target")) + end + end + end + + process({...}) + return o +end + +local function filenamesof(...) + local targets = targetsof(...) + + local f = {} + for _, r in ipairs(targets) do + if (type(r) == "table") and r.is then + if r.outs then + for _, o in ipairs(r.outs) do + f[#f+1] = o + end + end + elseif (type(r) == "string") then + f[#f+1] = r + else + error(string.format("list of targets contains a %s which isn't a target", + type(r))) + end + end + return f +end + +local function targetnamesof(...) + local targets = targetsof(...) + + local f + for _, r in pairs(targets) do + if (type(r) == "table") and r.is then + f[#f+1] = r.fullname + elseif (type(r) == "string") then + f[#f+1] = r + else + error(string.format("list of targets contains a %s which isn't a target", + type(r))) + end + end + return f +end + +local function dotocollection(files, callback) + if (#files == 1) and (type(files[1]) == "string") then + return callback(files[1]) + end + + local o = {} + local function process(files) + for _, s in ipairs(files) do + if (type(s) == "table") then + if s.is then + error("passed target to a filename manipulation function") + else + process(s) + end + else + local b = callback(s) + if (b ~= "") then + o[#o+1] = b + end + end + end + end + process(files) + return o +end + + +local function abspath(...) + return dotocollection({...}, + function(filename) + assertString(filename, 1) + if not filename:find("^[/$]") then + filename = concatpath(posix.getcwd(), filename) + end + return filename + end + ) +end + + +local function basename(...) + return dotocollection({...}, + function(filename) + assertString(filename, 1) + local _, _, b = filename:find("^.*/([^/]*)$") + if not b then + return filename + end + return b + end + ) +end + + +local function dirname(...) + return dotocollection({...}, + function(filename) + assertString(filename, 1) + local _, _, b = filename:find("^(.*)/[^/]*$") + if not b then + return "" + end + return b + end + ) +end + +local function replace(files, pattern, repl) + return dotocollection({files}, + function(filename) + return filename:gsub(pattern, repl) + end + ) +end + +local function fpairs(...) + return ipairs(filenamesof(...)) +end + +local function matching(collection, pattern) + local o = {} + dotocollection(collection, + function(filename) + if filename:find(pattern) then + o[#o+1] = filename + end + end + ) + return o +end + +-- Selects all targets containing at least one output file that matches +-- the pattern (or all, if the pattern is nil). +local function selectof(targets, pattern) + local targets = targetsof(targets) + local o = {} + for k, v in pairs(targets) do + if v.is and v.outs then + local matches = false + for _, f in pairs(v.outs) do + if f:find(pattern) then + matches = true + break + end + end + if matches then + o[#o+1] = v + end + end + end + return o +end + +local function uniquify(...) + local s = {} + return dotocollection({...}, + function(filename) + if not s[filename] then + s[filename] = true + return filename + end + end + ) +end + +local function startswith(needle, haystack) + return haystack:sub(1, #needle) == needle +end + +local function emit(...) + local n = select("#", ...) + local args = {...} + + for i=1, n do + local s = asstring(args[i]) + io.stdout:write(s) + if not s:find("\n$") then + io.stdout:write(" ") + end + end +end + +local function templateexpand(list, vars) + vars = inherit(vars, globals) + + local o = {} + for _, s in ipairs(list) do + o[#o+1] = s:gsub("%%%b{}", + function(expr) + expr = expr:sub(3, -2) + local chunk, e = loadstring("return ("..expr..")", expr) + if e then + error(string.format("error evaluating expression: %s", e)) + end + setfenv(chunk, vars) + local value = chunk() + if (value == nil) then + error(string.format("template expression '%s' expands to nil (probably an undefined variable)", expr)) + end + return asstring(value) + end + ) + end + return o +end + +local function loadbuildfile(filename) + if contains(filename, loadingstack) then + error(string.format("build file cycle; '%s' refers to itself indirectly; stack is: %s %s", + filename, asstring(loadingstack), filename)) + end + + loadingstack[#loadingstack+1] = filename + if not buildfiles[filename] then + buildfiles[filename] = true + + local fp, data, chunk, e + io.stderr:write("loading ", filename, "\n") + fp, e = io.open(filename) + if not e then + data, e = fp:read("*a") + fp:close() + if not e then + local thisglobals = {} + thisglobals._G = thisglobals + setmetatable(thisglobals, {__index = globals}) + chunk, e = loadstring(data, "@"..filename) + if not e then + setfenv(chunk, thisglobals) + end + end + end + if e then + error(string.format("couldn't load '%s': %s", filename, e)) + end + + local oldcwd = cwd + cwd = dirname(filename) + chunk() + cwd = oldcwd + end + loadingstack[#loadingstack] = nil +end + +local function loadbuildfilefor(filepart, targetpart) + local normalname = concatpath(filepart, "/build.lua") + if posix.access(normalname, "r") then + loadbuildfile(normalname) + return + end + + local extendedname = concatpath(filepart, "/build-"..targetpart..".lua") + if posix.access(extendedname, "r") then + loadbuildfile(extendedname) + return + end + + error(string.format("could not access either '%s' or '%s'", normalname, extendedname)) +end + +loadtarget = function(targetname) + if targets[targetname] then + return targets[targetname] + end + + local target + if not targetname:find("%+") then + local files + if targetname:find("[?*]") then + files = posix.glob(targetname) + if not files then + files = {} + end + else + files = {targetname} + end + + target = { + outs = files, + is = { + __implicitfile = true + } + } + targets[targetname] = target + else + local _, _, filepart, targetpart = targetname:find("^([^+]*)%+([%w-_]+)$") + if not filepart or not targetpart then + error(string.format("malformed target name '%s'", targetname)) + end + if (filepart == "") then + filepart = cwd + end + loadbuildfilefor(filepart, targetpart) + + target = targets[targetname] + if not target then + error(string.format("build file '%s' contains no target '%s'", + filename, targetpart)) + end + end + + return target +end + +local typeconverters = { + targets = function(propname, i) + if (type(i) == "string") then + i = {i} + elseif (type(i) ~= "table") then + error(string.format("property '%s' must be a target list", propname)) + end + + local m = {} + for k, v in pairs(i) do + local ts = targetsof(v) + if (type(k) == "number") then + for _, t in ipairs(ts) do + m[#m+1] = t + end + else + if (#ts ~= 1) then + error(string.format("named target '%s' can only be assigned from a single target", k)) + else + m[k] = ts[1] + end + end + end + return m + end, + + strings = function(propname, i) + if (type(i) == "string") then + i = {i} + elseif (type(i) ~= "table") then + error(string.format("property '%s' must be a string list", propname)) + end + return concat(i) + end, + + boolean = function(propname, i) + if (type(i) ~= "boolean") then + error(string.format("property '%s' must be a boolean", propname)) + end + return i + end, + + string = function(propname, i) + if (type(i) ~= "string") then + error(string.format("property '%s' must be a string", propname)) + end + return i + end, + + table = function(propname, i) + if (type(i) ~= "table") then + error(string.format("property '%s' must be a table", propname)) + end + return i + end, + + object = function(propname, i) + return i + end, +} + +local function definerule(rulename, types, cb) + if rulename and rules[rulename] then + error(string.format("rule '%s' is already defined", rulename)) + end + + types.name = { type="string" } + types.cwd = { type="string", optional=true } + types.vars = { type="table", default={} } + + for propname, typespec in pairs(types) do + if not typeconverters[typespec.type] then + error(string.format("property '%s' has unrecognised type '%s'", + propname, typespec.type)) + end + end + + local rulecwd = cwd + local rule = function(e) + local definedprops = {} + for propname, _ in pairs(e) do + definedprops[propname] = true + end + + local args = {} + for propname, typespec in pairs(types) do + if not e[propname] then + if not typespec.optional and (typespec.default == nil) then + error(string.format("missing mandatory property '%s'", propname)) + end + + args[propname] = typespec.default + else + args[propname] = typeconverters[typespec.type](propname, e[propname]) + definedprops[propname] = nil + end + end + + local propname, _ = next(definedprops) + if propname then + error(string.format("don't know what to do with property '%s'", propname)) + end + + if not args.cwd then + args.cwd = cwd + end + args.fullname = args.cwd.."+"..args.name + + local oldparente = parente + parente = args + args.vars = inherit(args.vars, oldparente.vars) + local result = cb(args) or {} + parente = oldparente + + result.is = result.is or {} + if rulename then + result.is[rulename] = true + end + result.fullname = args.fullname + + if targets[arg.fullname] and (targets[arg.fullname] ~= result) then + error(string.format("target '%s' is already defined", args.fullname)) + end + targets[result.fullname] = result + return result + end + + if rulename then + if rules[rulename] then + error(string.format("rule '%s' is already defined", rulename)) + end + rules[rulename] = rule + end + return rule +end + +----------------------------------------------------------------------------- +-- DEFAULT RULES -- +----------------------------------------------------------------------------- + +local function install_make_emitter() + emit("hide = @\n") + + function emitter:var(name, value) + -- Don't let emit insert spaces. + emit(name.."="..value.."\n") + end + + function emitter:rule(name, ins, outs) + if (#outs == 0) then + local n = name.."-IMAGINARY-OUT" + emit(".INTERMEDIATE:", n, "\n") + outs = {n} + end + + local impl = name.."-IMPL" + emit(".INTERMEDIATE:", name, "\n") + emit(".INTERMEDIATE:", impl, "\n") + + for i = 1, #outs do + emit(name..":", outs[i], "\n") + end + for i = 1, #outs do + emit(outs[i]..":", impl, ";\n") + end + + for i = 1, #ins do + emit(impl..":", ins[i], "\n") + end + + emit(impl..":", "\n") + local dirs = uniquify(dirname(outs)) + if (#dirs > 0) then + emit("\t@mkdir -p", dirs, "\n") + end + end + + function emitter:phony(name, ins, outs) + emit(".PHONY:", name, "\n") + self:rule(name, ins, outs) + end + + function emitter:label(...) + local s = table.concat({...}, " ") + emit("\t@echo", s, "\n") + end + + function emitter:exec(commands) + for _, s in ipairs(commands) do + emit("\t$(hide)", s, "\n") + end + end + + function emitter:endrule() + emit("\n") + end +end + +local function install_ninja_emitter() + emit("rule build\n") + emit(" command = $command\n") + emit("\n") + + local function unmake(collection) + return dotocollection({collection}, + function(s) + return s:gsub("%$%b()", + function(expr) + return "${"..expr:sub(3, -2).."}" + end + ) + end + ) + end + + function emitter:var(name, value) + -- Don't let emit insert spaces. + emit(name.."="..unmake(value).."\n") + end + + function emitter:rule(name, ins, outs) + if (#outs == 0) then + emit("build", name, ": phony", unmake(ins), "\n") + else + emit("build", name, ": phony", unmake(outs), "\n") + emit("build", unmake(outs), ": build", unmake(ins), "\n") + end + end + + function emitter:label(...) + end + + function emitter:exec(commands) + emit(" command =", table.concat(unmake(commands), " && "), "\n") + end + + function emitter:endrule() + emit("\n") + end +end + +definerule("simplerule", + { + ins = { type="targets" }, + outs = { type="strings" }, + deps = { type="targets", default={} }, + label = { type="string", optional=true }, + commands = { type="strings" }, + vars = { type="table", default={} }, + }, + function (e) + emitter:rule(e.fullname, filenamesof(e.ins, e.deps), e.outs) + emitter:label(e.fullname, " ", e.label or "") + + local vars = inherit(e.vars, { + ins = filenamesof(e.ins), + outs = filenamesof(e.outs) + }) + + emitter:exec(templateexpand(e.commands, vars)) + emitter:endrule() + + return { + outs = e.outs + } + end +) + +definerule("installable", + { + map = { type="targets", default={} }, + }, + function (e) + local deps = {} + local commands = {} + local srcs = {} + local outs = {} + local dests = {} + for dest, src in pairs(e.map) do + if src.is.installable then + if (type(dest) ~= "number") then + error("can't specify a destination filename when installing an installable") + end + deps[#deps+1] = src.fullname + outs = concat(outs, filenamesof(src)) + elseif (type(dest) == "number") then + error("only references to other installables can be missing a destination") + else + local f = filenamesof(src) + if (#f ~= 1) then + error("installable can only cope with targets emitting single files") + end + + deps[#deps+1] = f + dests[#dests+1] = dest + outs[#outs+1] = dest + commands[#commands+1] = "cp "..f[1].." "..dest + end + end + + emitter:rule(e.fullname, deps, dests) + emitter:label(e.fullname, " ", e.label or "") + if (#commands > 0) then + emitter:exec(commands) + end + emitter:endrule() + + return { + outs = outs + } + end +) + +----------------------------------------------------------------------------- +-- MAIN PROGRAM -- +----------------------------------------------------------------------------- + +local function parse_arguments(argmap, arg) + local i = 1 + local files = {} + + local function unrecognisedarg(arg) + argmap[" unrecognised"](arg) + end + + while (i <= #arg) do + local o = arg[i] + local op + + if (o:byte(1) == 45) then + -- This is an option. + if (o:byte(2) == 45) then + -- ...with a -- prefix. + o = o:sub(3) + local fn = argmap[o] + if not fn then + unrecognisedarg("--"..o) + end + i = i + fn(arg[i+1], arg[i+2]) + else + -- ...without a -- prefix. + local od = o:sub(2, 2) + local fn = argmap[od] + if not fn then + unrecognisedarg("-"..od) + end + op = o:sub(3) + if (op == "") then + i = i + fn(arg[i+1], arg[i+2]) + else + fn(op) + end + end + else + files[#files+1] = o + end + i = i + 1 + end + + argmap[" files"](files) +end + +globals = { + posix = posix, + + abspath = abspath, + asstring = asstring, + basename = basename, + concat = concat, + concatpath = concatpath, + cwd = function() return cwd end, + definerule = definerule, + dirname = dirname, + emit = emit, + filenamesof = filenamesof, + fpairs = fpairs, + include = loadbuildfile, + inherit = inherit, + print = print, + replace = replace, + matching = matching, + selectof = selectof, + startswith = startswith, + uniquify = uniquify, + vars = vars, +} +setmetatable(globals, + { + __index = function(self, k) + local rule = rules[k] + if rule then + return rule + else + return _G[k] + end + end + } +) + +vars.cflags = {} +parente.vars = vars + +setmetatable(_G, + { + __index = function(self, k) + local value = rawget(_G, k) + if not value then + error(string.format("access of undefined variable '%s'", k)) + end + return value + end + } +) + +do + local emitter_type = install_make_emitter + parse_arguments( + { + ["make"] = function() + emitter_type = install_make_emitter + return 0 + end, + + ["ninja"] = function() + emitter_type = install_ninja_emitter + return 0 + end, + + + [" unrecognised"] = function(arg) + error(string.format("unrecognised argument '%s'", arg)) + end, + + [" files"] = function(files) + emitter_type() + + for _, f in ipairs(files) do + local _, _, name, value = f:find("^([%w_]+)=(.*)$") + if name then + emitter:var(name, value) + end + end + + for _, f in ipairs(files) do + if not f:find("=") then + loadbuildfile(f) + end + end + end + }, + {...} + ) +end + diff --git a/first/ackbuilder.md b/first/ackbuilder.md new file mode 100644 index 000000000..27ca6d70b --- /dev/null +++ b/first/ackbuilder.md @@ -0,0 +1,351 @@ +# ackbuilder + +## What is it? + +ackbuilder is a very small build tool inspired by [bazel](https://bazel.io/) +which uses either make or [ninja](https://ninja-build.org/) as a backend. + +It supports fully parallelisable builds (in both make and ninja), as well as +hopefully-robust support for rules which generate more than one output file, +which is something make is very, very bad at. + +It was written because the ACK is a really horribly complex thing to build and +there wasn't anything else. ackbuilder is pretty rough and ready but it does +sort of work. Be prepared for bugs. + +This document is a very rapid brain dump of how the build file works. It +doesn't cover actually running the tool (because that bit's pretty nasty) --- +go look at the top level Makefile to see that for now. + +## Basic concepts + +Complete example, using the built-in C rules. This should be saved in a file +called `build.lua`: + + cprogram { + name = 'prog', + srcs = { "./*.c" }, + } + +This defines a rule `prog` which, when built, compiles all the source files in +the same directory as the `build.lua` file into an executable. + +Slightly more complex example: + + clibrary { + name = "library", + srcs = { "./library.c" }, + hdrs = { "./library.h" }, + } + + cprogram { + name = 'prog2', + srcs = { "./prog2.c" }, + deps = { "+library" } + } + +If we move the library into another directory, we can invoke it like this: + + cprogram { + name = 'prog3', + srcs = { "./prog3.c" }, + deps = { "path/to/library+library" } + } + + * Targets starting with `./` are relative to **the current directory** (i.e. + the one the build file is in). + + * Targets starting with a path are relative to the top directory of the + project. + + * Targets containing a `+` refer to a named target in another build file. So, + on encountering the library in `prog3` above, ackbuilder will look for + `path/to/library/build.lua`, load it, and then try to find a target in it + called `library`. + +**Warning**: files are interpreted from top to bottom; every time a target +referring to another build file is seen for the first time, that file is +interpreted then and there. You can't have circular dependencies (these are +caught and an error is generated). You can't refer to a target defined below +you in the same source file (these are not caught, and just won't be found). + +Build files each get their own private global scope. If you randomly set a +variable, it won't be seen by other build files. (Use `vars` for that; see +below.) Build files are only loaded once. + +The `cprogram` and `clibrary` rules, by the way, are sophisticated enough to +automatically handle library and header paths. The exported headers by the +library are automatically imported into the program. + +## `simplerule` and `normalrule` + +These are the building blocks out of which all other rules are made. If you +want to run your own programs, you will be using these. + +`simplerule` is the simplest. You give it inputs, and outputs, and commands, +and it does it. + + simplerule { + name = 'sorted-input', + ins = { './input.txt' }, + outs = { './output.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } + +In a command block, `%{...}` will evaluate the Lua expression between the +braces; various useful things are in scope, including the list of inputs and +outputs. + +However, this ends up leaving the output file lying around in the project +directory, which we don't want, so we usually use `normalrule` instead. +(`normalrule` is not strictly part of the ackbuilder core; it's in the standard +library along with `cprogram` and `clibrary`.) + + normalrule { + name = 'sorted-input', + ins = { './input.txt' }, + outleaves = { 'output.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } + +Note `outleaves`; there is no `./`. This is a list of leaf filenames. The rule +will create a directory in the object tree and put the files specified in it, +somewhere; you don't care where. You can refer to the output file via the +target name, so: + + normalrule { + name = 'reversed', + ins = { '+sorted-input' }, + outleaves = { 'reversed.txt' }, + commands = { + "rev < %{ins} > %{outs}" + } + } + +One common use for this is to generate C header or source files. + + normalrule { + name = 'reversed_h', + ins = { '+reversed' }, + outleaves = { 'reversed.h' }, + commands = { + 'xxd -i %{ins} > %{outs}' + } + } + + cprogram { + name = 'prog', + srcs = { './*.c' }, + deps = { '+reversed_h' } + } + +Now you can refer to `reversed.h` in one of your C files and it'll just work +(`+reversed_h`'s output directory gets added to the include path +automatically). + +## Defining your own rules + +Like this: + + definerule("sort", + { + srcs = { type="targets" }, + }, + function(e) + return normalrule { + name = e.name, + ins = e.srcs, + outleaves = { 'sorted.txt' }, + commands = { + "sort < %{ins} > %{outs}" + } + } + } + ) + + sort { + name = 'sorted', + srcs = { './input.txt' } + } + +You give `definerule()` the name of the rule you want to define, a description +of the properties the rule will take, and a callback that does the work. + +You can do anything you like in the callback, including defining as many +targets as you like; but remember that all targets must have unique names, so +for any temporary files you probably want something like `name = +e.name.."/intermediate"` to ensure uniqueness. + +The callback should end by returning an invocation of another rule, with `name += e.name` as above. + +Rules are defined whenever a build file containing them is seen. Letting this +happen automatically doesn't always work so you probably want to explicitly +include it: + + include("foo/bar/baz/build.lua") + +Rule properties are typed and can be specified to be required or optional (or +have a default value). If you try to invoke a rule with a property which isn't +declared, or missing a property which should be declared, you'll get an error. + + definerule("sort", + { + srcs = { type="targets" }, + numeric = { type="boolean", optional=true, default=false } + } + ...omitted... + +(The `optional=true` part can be omitted if you specify a default which isn't +`nil`.) + +Types include: + + * `targets`: the most common one. When the rule is invoked, ackbuilder will + resolve these for you so that when your callback fires, the property is a + flattened list of target objects. + + * `strings`: a Lua table of strings. If the invoker supplies a single string + which isn't a table, it'll get wrapped in one. + + * `string`: a string. + + * `boolean`: a boolean (either `true` or `false`; nothing else is allowed). + + * `table`: a Lua table. + + * `object`: any Lua value. + +## Target objects + +When a rule callback is run, any targets it needs will be resolved into target +objects. These are Lua objects with assorted useful stuff in them. + + * `object.is`: contains a set telling you which rules made the object. e.g. + `object.is.cprogram` is true if `object` was built with `cprogram`. Bear in + mind that `object.is.normalrule` is _also_ going to be true. + + * `object.dir`: the object's build directory. Only exists if the object was + built with `normalrule`. + +There are other properties (`fullname` and `outs`). Please don't use these; use +`targetnamesof()` and `filenamesof()` as described below. + +## The standard library + +Your build files are supplied a pile of useful functions. + +### Manipulating target lists + +A target list is a possibly nested set of tables containing either target +objects or strings. All of these functions will implicitly flatten the list and +resolve any strings into target objects before doing anything else to them. +Most of these functions can be supplied with varargs parameters. + +e.g. `targetsof(a, b)` is equivalent to `targetsof({a, b})` is equivalent to +`targetsof({a, {b}})`. + + * `targetsof(...)`: just flattens the list and resolves any string target + names. + + * `filenamesof(...)`: returns a list of output files for all the supplied + targets. + + * `targetnamesof(...)`: returns a list of fully qualified target names for + all the supplied stargets. + + * `selectof(targets, pattern)`: returns only those targets whose outputs + contain at least one file matching the pattern. + +### Manipulating filename lists + +Like the target list functions, all of these implicitly flatten any nested +tables. They all return lists; however, as a special exception, if any of the +functions which take varargs parameters have a single parameter which is a +string, they return just a string. + +e.g. `abspath({f})` returns a table; `abspath(f)` returns a string. + + * `abspath(...)`: attempts to return the absolute path of its arguments. This + isn't always possible due to variable references. + + * `basename(...)`: returns the basenames of its arguments (the file part of + the path). + + * `dirname(...)`: returns the directory name of its arguments. + + * `matching(files, pattern)`: returns only those files which match a Lua + pattern. + + * `replace(files, pattern, repl)`: performs a Lua pattern replace on the list + of files. + + * `uniquify(...)`: removes duplicates. + +### Other things + + * `include(file)`: loads another build file, if it hasn't been loaded before. + +## Variables + +There are two types of variable, mostly for hysterical reasons. + +### Makefile variables + +(Despite the name, these work on ninja too.) + +Filenames can contain variable references of the form `$(FOO)`. These are +expanded at build time based on definitions supplied on the ackbuilder command +line. + +ackbuilder assumes that these are absolute paths and won't attempt to +manipulate them much. + +I want to get rid of these at some point. + +### ackbuilder variables + +These are expanded by ackbuilder itself. + +Every rule invocation contains a magic property, `vars`. When a rule's commands +are executed, the variables provided in the template expansion are calculated +by combining all `vars` settings in the call stack (including the top level +build file). + +Easiest to explain with an example: + + cprogram { + name = 'another_test', + srcs = { './*.c' }, + vars = { + cflags = { '-g', '-O3' } + } + } + +When `cprogram` builds each C file, the command will refer to `%{cflags}`. The +value above will be flattened into a space-separated string and substituted in. + +Setting a variable this way will _override_ any definition further up the call +stack. However, you can do this: + + vars.cflags = { '-g' } + + cprogram { + name = 'another_test', + srcs = { './*.c' }, + vars = { + ["+cflags"] = { '-O3' } + } + } + +Now `cflags` will default to `-g` everywhere, because it's set at the top +level; but when `another_test` is built, it'll be `-g -O3`. + +ackbuilder variables are only expanded in command templates, not in filenames. + + + diff --git a/first/build.lua b/first/build.lua new file mode 100644 index 000000000..3240f9f1a --- /dev/null +++ b/first/build.lua @@ -0,0 +1,257 @@ +local function objdir(e) + return concatpath("$(OBJDIR)", e.cwd, e.name) +end + +definerule("normalrule", + { + ins = { type="targets" }, + deps = { type="targets", default={} }, + outleaves = { type="strings" }, + label = { type="string", optional=true }, + objdir = { type="string", optional=true }, + commands = { type="strings" }, + }, + function (e) + local dir = e.objdir or objdir(e) + local realouts = {} + for _, v in pairs(e.outleaves) do + realouts[#realouts+1] = concatpath(dir, v) + end + + local vars = inherit(e.vars, { + dir = dir + }) + + local result = simplerule { + name = e.name, + ins = e.ins, + deps = e.deps, + outs = realouts, + label = e.label, + commands = e.commands, + vars = vars, + } + result.dir = dir + return result + end +) + +definerule("cfile", + { + srcs = { type="targets" }, + deps = { type="targets", default={} }, + commands = { + type="strings", + default={ + "$(CC) -c -o %{outs[1]} %{ins[1]} %{hdrpaths} %{cflags}" + }, + } + }, + function (e) + local hdrpaths = {} + for _, t in pairs(e.deps) do + if t.dir then + hdrpaths[#hdrpaths+1] = "-I"..t.dir + end + end + hdrpaths = uniquify(hdrpaths) + + local outleaf = basename(e.name)..".o" + + return normalrule { + name = e.name, + cwd = e.cwd, + ins = e.srcs, + deps = e.deps, + outleaves = {outleaf}, + label = e.label, + commands = e.commands, + vars = { + hdrpaths = hdrpaths, + } + } + end +) + +definerule("cppfile", + { + srcs = { type="targets" }, + deps = { type="targets", default={} }, + outleaf = { type="string" }, + commands = { + type="strings", + default={ + "$(CC) -E -P -o %{outs[1]} %{hdrpaths} %{cflags} -x c %{ins}" + } + }, + }, + function (e) + if (#e.srcs ~= 1) then + error("you must have exactly one input file") + end + + local hdrpaths = {} + for _, t in pairs(e.deps) do + hdrpaths[#hdrpaths+1] = "-I"..t.dir + end + hdrpaths = uniquify(hdrpaths) + + return normalrule { + name = e.name, + cwd = e.cwd, + ins = e.srcs, + deps = e.deps, + outleaves = {e.outleaf}, + label = e.label, + commands = e.commands, + vars = { + hdrpaths = hdrpaths, + } + } + end +) + +definerule("bundle", + { + srcs = { type="targets" }, + commands = { + type="strings", + default={ + "tar cf - %{ins} | (cd %{dir} && tar xf -)" + } + } + }, + function (e) + local outleaves = {} + local commands = {} + for _, f in fpairs(e.srcs) do + local localf = basename(f) + outleaves[#outleaves+1] = localf + commands[#commands+1] = "cp "..f.." %{dir}/"..localf + end + + return normalrule { + name = e.name, + cwd = e.cwd, + ins = e.srcs, + outleaves = outleaves, + label = e.label, + commands = commands + } + end +) + +definerule("clibrary", + { + srcs = { type="targets", default={} }, + hdrs = { type="targets", default={} }, + deps = { type="targets", default={} }, + _cfile = { type="object", default=cfile }, + commands = { + type="strings", + default={ + "rm -f %{outs[1]}", + "$(AR) cqs %{outs[1]} %{ins}", + }, + } + }, + function (e) + local ins = {} + for _, src in fpairs(e.srcs) do + local n = basename(src):gsub("%.%w*$", "") + ins[#ins+1] = e._cfile { + name = e.name.."/"..n, + cwd = e.cwd, + srcs = {src}, + deps = e.deps, + vars = { + ["+cflags"] = { "-I"..e.cwd, }, + }, + } + end + + local commands = {} + local outleaves = {} + if (#e.srcs > 0) then + for _, s in ipairs(e.commands) do + commands[#commands+1] = s + end + outleaves[#outleaves+1] = e.name..".a" + end + + local hdrsin = {} + for dest, src in pairs(e.hdrs) do + if (type(dest) == "number") then + for _, f in ipairs(filenamesof(src)) do + hdrsin[#hdrsin+1] = f + outleaves[#outleaves+1] = basename(f) + commands[#commands+1] = "cp "..asstring(f).." %{dir}" + end + else + local fs = filenamesof(src) + if (#fs ~= 1) then + error(string.format("keyed header '%s' can only be a single file", dest)) + end + local f = fs[1] + + hdrsin[#hdrsin+1] = f + outleaves[#outleaves+1] = dest + commands[#commands+1] = "cp "..asstring(f).." %{dir}/"..dest + end + end + + return normalrule { + name = e.name, + cwd = e.cwd, + ins = ins, + deps = {hdrsin, e.deps}, + outleaves = outleaves, + label = e.label, + commands = commands, + } + end +) + +definerule("cprogram", + { + srcs = { type="targets", default={} }, + deps = { type="targets", default={} }, + _clibrary = { type="object", default=clibrary }, + commands = { + type="strings", + default={ + "$(CC) -o %{outs[1]} -Wl,--start-group %{ins} -Wl,--end-group" + }, + } + }, + function (e) + local libs = matching(filenamesof(e.deps), "%.a$") + if (#e.srcs > 0) then + for _, f in pairs( + matching( + filenamesof( + e._clibrary { + name = e.name .. "/main", + cwd = e.cwd, + srcs = e.srcs, + deps = e.deps, + } + ), + "%.a$" + ) + ) do + libs[#libs+1] = f + end + end + + return normalrule { + name = e.name, + cwd = e.cwd, + deps = e.deps, + ins = libs, + outleaves = { e.name }, + commands = e.commands, + } + end +) + diff --git a/first/c.pm b/first/c.pm deleted file mode 100644 index 3fdd716bd..000000000 --- a/first/c.pm +++ /dev/null @@ -1,238 +0,0 @@ --- $Id$ --- $HeadURL: https://primemover.svn.sf.net/svnroot/primemover/pm/lib/c.pm $ --- $LastChangedDate: 2007-02-24 01:37:06 +0000 (Sat, 24 Feb 2007) $ - --- pm includefile to compile *host* C programs. - --- Standard Lua boilerplate. - -local io_open = io.open -local string_gsub = string.gsub -local string_gfind = string.gfind -local string_find = string.find -local table_insert = table.insert -local table_getn = table.getn -local filetime = pm.filetime - --- Define some variables. - -CCOMPILER = "gcc" -CXXCOMPILER = "g++" -CC = "%CCOMPILER% %CBUILDFLAGS% %CDYNINCLUDES:cincludes% %CINCLUDES:cincludes% %CDEFINES:cdefines% %CEXTRAFLAGS% -c -o %out% %in%" -CXX = "%CXXCOMPILER% %CBUILDFLAGS% %CDYNINCLUDES:cincludes% %CINCLUDES:cincludes% %CDEFINES:cdefines% %CEXTRAFLAGS% -c -o %out% %in%" -CPROGRAM = "%CCOMPILER% %CBUILDFLAGS% %CLINKFLAGS% %CEXTRAFLAGS% -o %out% %in% %CLIBRARIES:clibraries%" -CXXPROGRAM = "%CXXCOMPILER% %CBUILDFLAGS% %CLINKFLAGS% %CEXTRAFLAGS% -o %out% %in% %CLIBRARIES:clibraries%" - -CLIBRARY = "rm -f %out% && ar cr %out% %in% && ranlib %out%" - -CBUILDFLAGS = {"-g"} -CINCLUDES = EMPTY -CDEFINES = EMPTY -CEXTRAFLAGS = EMPTY -CLINKFLAGS = EMPTY -CDYNINCLUDES = EMPTY -CLIBRARIES = EMPTY - ---- Custom string modifiers ------------------------------------------------- - -local function prepend(rule, arg, prefix) - if (arg == EMPTY) then - return EMPTY - end - - local t = {} - for i, j in ipairs(arg) do - t[i] = prefix..j - end - return t -end - -function pm.stringmodifier.cincludes(rule, arg) - return prepend(rule, arg, "-I") -end - -function pm.stringmodifier.cdefines(rule, arg) - return prepend(rule, arg, "-D") -end - -function pm.stringmodifier.clibraries(rule, arg) - if (arg == EMPTY) then - return EMPTY - end - - local t = {} - for i, j in ipairs(arg) do - if string_find(j, "%.a$") then - t[i] = j - else - t[i] = "-l"..j - end - end - return t -end - ---- Manage C file dependencies ---------------------------------------------- - -local dependency_cache = {} -local function calculate_dependencies(filename, includes) - -- Cache values, so we don't recalculate dependencies needlessly. - - local o = dependency_cache[filename] - if o then - return o - end - - local deps = {} - deps[filename] = true - - local calcdeps = 0 - calcdeps = function(filename, file) - file = file or io_open(filename) - if not file then - return - end - - local localincludes = string_gsub(filename, "/[^/]*$", "") - if localincludes then - localincludes = {localincludes, unpack(includes)} - else - localincludes = includes - end - - for line in file:lines() do - local _, _, f = string_find(line, '^[ \t]*#[ \t]*include[ \t]*["<]([^"]+)[">]') - if f then - for _, path in ipairs(localincludes) do - local subfilename = path.."/"..f - local subfile = io_open(subfilename) - if subfile then - if not deps[subfilename] then - deps[subfilename] = true - calcdeps(subfilename, subfile) - end - break - end - end - end - end - - -- Explicit close to avoid having to wait for the garbage collector - -- to free up the underlying fd. - - file:close() - end - - calcdeps(filename) - o = {} - for i, _ in pairs(deps) do - table_insert(o, i) - end - - dependency_cache[filename] = o - return o -end - --- This clause specialises 'simple' to add support for smart dependencies of C --- files. - -simple_with_clike_dependencies = simple { - class = "simple_with_clike_dependencies", - makedepends = {"%CDEPENDS%"}, - - __init = function(self, p) - simple.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- If dynamicheaders is an object, turn it into a singleton list. - - if self.dynamicheaders then - if (type(self.dynamicheaders) ~= "table") then - self:__error("doesn't know what to do with dynamicheaders, which ", - "should be a list or an object but was a ", type(self.dynamicheaders)) - end - if self.dynamicheaders.class then - self.dynamicheaders = {self.dynamicheaders} - end - end - end, - - __dependencies = function(self, inputs, outputs) - local cincludes = self:__index("CINCLUDES") - if (type(cincludes) == "string") then - cincludes = {cincludes} - end - - local includes = {} - for _, i in ipairs(cincludes) do - table_insert(includes, self:__expand(i)) - end - - local input = self:__expand(inputs[1]) - local depends = calculate_dependencies(input, includes) - if not depends then - self:__error("could not determine the dependencies for ", - pm.rendertable({input})) - end - if pm.verbose then - pm.message('"', input, '" appears to depend on ', - pm.rendertable(depends)) - end - return depends - end, - - __buildadditionalchildren = function(self) - self.CDYNINCLUDES = {} - if self.dynamicheaders then - for _, i in ipairs(self.dynamicheaders) do - local o = i:__build() - if o[1] then - table_insert(self.CDYNINCLUDES, (string_gsub(o[1], "/[^/]*$", ""))) - end - end - end - -- If no paths on the list, replace the list with EMPTY so it doesn't - -- expand to anything. - if (table_getn(self.CDYNINCLUDES) == 0) then - self.CDYNINCLUDES = EMPTY - end - end -} - --- These are the publically useful clauses. - -cfile = simple_with_clike_dependencies { - class = "cfile", - command = {"%CC%"}, - outputs = {"%U%-%I%.o"}, -} - -cxxfile = simple_with_clike_dependencies { - class = "cxxfile", - command = {"%CXX%"}, - outputs = {"%U%-%I%.o"}, -} - -cprogram = simple { - class = "cprogram", - command = {"%CPROGRAM%"}, - outputs = {"%U%-%I%"}, -} - -cxxprogram = simple { - class = "cxxprogram", - command = {"%CXXPROGRAM%"}, - outputs = {"%U%-%I%"}, -} - -clibrary = simple { - class = "clibrary", - command = { - "%CLIBRARY%" - }, - outputs = {"%U%-%I%.a"}, -} diff --git a/first/cp_dir b/first/cp_dir deleted file mode 100755 index a5c66906f..000000000 --- a/first/cp_dir +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e -trap "rm -f /tmp/xx$$" 0 1 2 3 15 -case $2 in -/*) target_dir=$2 - ;; -*) target_dir=`pwd`/$2 - ;; -esac -cd $1 -tar cf /tmp/xx$$ . -if [ -d $target_dir ] -then : -else mkdir $target_dir -fi -cd $target_dir -tar xf /tmp/xx$$ diff --git a/first/create_dir b/first/create_dir deleted file mode 100755 index 4f60bfba0..000000000 --- a/first/create_dir +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -if ( cd $1 ) 2>/dev/null -then - : -elif mkdir $1 2>/dev/null -then - : -else - echo $0: could not create directory $1 1>&2 - exit 1 -fi -exit 0 diff --git a/first/em_path.h.src b/first/em_path.h.src deleted file mode 100644 index 3da9a8acc..000000000 --- a/first/em_path.h.src +++ /dev/null @@ -1,11 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* Intended as a common directory for ALL temporary files */ -#define TMP_DIR "/tmp" - -/* Access to the ACK tree and parts thereof */ -#define EM_DIR "/usr/em" /* The root directory for EM stuff */ -#define ACK_PATH "lib/descr" diff --git a/first/first b/first/first deleted file mode 100755 index 0d06efba0..000000000 --- a/first/first +++ /dev/null @@ -1,208 +0,0 @@ -#! /bin/sh - -case $0 in -*/first) - FDIR=`expr $0 : '\(.*\)/first'` - ;; -first) FDIR=. - ;; -esac - -if echo 'a\c' | grep 'c' >/dev/null ; then - : We have BSD-like echo command. - E_FLAG='-n' - E_SFX='' -else - : We have SystemV-like echo command. - E_FLAG='' - E_SFX='\c' -fi -export E_FLAG E_SFX - -echo check write-ability of /tmp ... -if ( >/tmp/aaax.$$ ) -then - rm /tmp/aaax.$$ -else - echo /tmp must exist and be writable. - exit 2 -fi -echo "/tmp ok" - -if [ -f macros ] -then - . macros -fi - -: "Now get system name and directories" -. $FDIR/get_sys - -: "Take action according to the system used" -BM=1 -OLDACM=$ACM -OLDSYS=$SYS -case $SYSNAME in -vax_bsd4_1a) ACM=vax4 ; SYS=BSD4_1 ; BYTE_ORDER=0123 ; MACH=vax4 ;; -vax_bsd4_2) ACM=vax4 ; SYS=BSD4_2 ; BYTE_ORDER=0123 ; MACH=vax4 ;; -vax_sysV_2) ACM=vax4 ; SYS=SYS_5 ; BYTE_ORDER=0123 ; MACH=vax4 ;; -i386) ACM=i386 ; SYS=SYS_5 ; BYTE_ORDER=0123 ; MACH=i386 ;; -sun3) ACM=sun3 ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=m68020 ;; -sun2) ACM=sun2 ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=m68k4 ;; -m68_unisoft|m68k2) ACM=m68k2 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;; -m68_sysV_0|mantra) ACM=mantra ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=m68k4 ;; -m68020) ACM=m68020 ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=m68020 ;; -sparc) ACM=sparc ; SYS=BSD4_2; BYTE_ORDER=3210 ; MACH=sparc ;; -sparc_solaris) ACM=sparc_solaris ; SYS=SYS_5; BYTE_ORDER=3210 ; MACH=sparc_solaris ;; -i86) ACM=i86 ; SYS=SYS_5; BYTE_ORDER=0123 ; MACH=i86 ;; -xenix3) ACM=xenix3 ; SYS=SYS_5; BYTE_ORDER=0123 ; MACH=i86 ;; -minix) ACM=minix ; SYS=V7; BYTE_ORDER=0123 ; MACH=i86 ;; -pmds) ACM=pmds ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;; -pmds4) ACM=pmds4 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k4 ;; -minixST) ACM=minixST ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k2 ;; -m68k4) ACM=m68k4 ; SYS=V7; BYTE_ORDER=3210 ; MACH=m68k4 ;; -*) ACM=XXX ; SYS=XXX ; BYTE_ORDER=XXX ; MACH=XXX ;; -esac - -: do not change the order in MACH_LIST. check limit_enquire first. -MACH_LIST="i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z80 z8000 arm" - -while : -do - for i in $MACH_LIST - do - if [ $i = "$ACM" ] - then break - fi - done - if [ $i = "$ACM" ] - then break - fi - echo "This installation script has no knowledge about $SYSNAME. -You will have to specify the default machine that you want ACK to -compile for. Choices:" - l= - x= - for i in $MACH_LIST - do - l="$l $i" - x=x$x - case $x in - xxxxxxxxxx) echo $l - x= - l= - ;; - esac - done - ACM=$OLDACM - echo $l - echo $E_FLAG "Your choice: [$OLDACM] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$ACM";; - esac - ACM="$ANS" -done -while : -do -case $SYS in -V7|BSD4_1|BSD4_2|SYS_5) - break - ;; -*) - SYS=$OLDSYS - echo 'What kind of Unix is the target system running? -Choices: - V7 for Unix V7, BSD 2.* - BSD4_1 for Berkeley 4.1 - BSD4_2 for Berkeley 4.2, 4.3, SunOs 3, SunOs 4 - SYS_5 for Xenix, System III, System V, SunOs 5' - echo $E_FLAG "Your choice (V7|BSD4_1|BSD4_2|SYS_5): [$OLDSYS] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$SYS";; - esac - SYS="$ANS" - ;; -esac -done -rm -f local.h -sed -e /ACKM/s/'".*"'/'"'$ACM'"'/ -e /BIGMACH/s/'[01]'/$BM/ -e /SYSTEM/s/'^#[ ]*define[ ]*[a-zA-Z_][a-zA-Z0-9_]*'/"# define $SYS"/ < $FDIR/local.h.src >local.h -case $BYTE_ORDER in -XXX) ;; -*) echo '/* Optional definition of BYTE_ORDER: */' >> local.h - echo "#define BYTE_ORDER 0x$BYTE_ORDER" >> local.h - ;; -esac - -echo "Your default machine to compile for is $ACM" - -echo "Installation of the complete ACK takes a long time. Limiting the -number of languages, runtime libraries, back-ends, and assemblers to be -installed may save a lot of time. If you want to install everything, -answer no to the next question. Otherwise, answer yes, and you will be -prompted for details" -while : -do - echo $E_FLAG "Do you want to limit the installation in any way? (y/n) [$LIMIT] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$LIMIT";; - esac - case X$ANS in - Xj*|Xy|X) - LIMIT=y - . $FDIR/limit_enquire - break - ;; - Xn*) . $FDIR/get_sysvax - LIMIT=n - DO_MACHINE_INDEP=y - DO_FAST=n - DISABLE_LANG= - DISABLE_SUP= - if [ $TARGET_HOME = $UTIL_HOME ] - then - case $ACM in - sun3|m68020|i386|vax*) - DO_FAST=y - ;; - esac - fi - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac -done - -. $FDIR/get_makepars - -echo "TARGET_HOME=\"$TARGET_HOME\"; export TARGET_HOME" > macros -echo "UTIL_HOME=\"$UTIL_HOME\"; export UTIL_HOME" >> macros -echo "SRC_HOME=\"$SRC_HOME\"; export SRC_HOME" >> macros -echo "SYSNAME=\"$SYSNAME\"; export SYSNAME" >> macros -echo "ACM=\"$ACM\"; export ACM" >> macros -echo "CURRENT=\"$CURRENT\"; export CURRENT" >> macros -echo "SYS=\"$SYS\"; export SYS" >> macros -echo "LIMIT=\"$LIMIT\"; export LIMIT" >> macros -echo "CONFIG=\"$CONFIG\"; export CONFIG" >> macros -echo "DISABLE_LANG=\"$DISABLE_LANG\"; export DISABLE_LANG" >> macros -echo "DISABLE_SUP=\"$DISABLE_SUP\"; export DISABLE_SUP" >> macros -echo "DO_MACHINE_INDEP=\"$DO_MACHINE_INDEP\"; export DO_MACHINE_INDEP" >> macros -echo "MACH_LIST=\"$MACH_LIST\"; export MACH_LIST" >> macros -echo "SYSVAX=\"$SYSVAX\"; export SYSVAX" >> macros -echo "MACH=\"$MACH\"; export MACH" >> macros -echo "WS=\"$WS\"; export WS" >> macros -echo "PS=\"$PS\"; export PS" >> macros -echo "DO_FAST=\"$DO_FAST\"; export DO_FAST" >> macros - -cat macros $FDIR/install_tail > INSTALL -chmod +x INSTALL - -echo " -A shell-script called 'INSTALL' has been created. Running it -installs ACK. Note that this may take a (very) long time, so run it -in the background, with its output redirected, f.i.: - sh INSTALL > INSTALL.out 2>&1 & -" -exit 0 diff --git a/first/get_answer b/first/get_answer deleted file mode 100755 index 672deccd2..000000000 --- a/first/get_answer +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -if read ANS -then echo -else echo "Sorry, got EOF when reading your answer" - exit 1 -fi diff --git a/first/get_makepars b/first/get_makepars deleted file mode 100755 index cadbf31c9..000000000 --- a/first/get_makepars +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh - -know_target=0 -case $SYSNAME in -vax*|i386|sun*|sparc*|m68_sysV_0|m68020|mantra|pmds4|m68k4) - WS=4 ; PS=4 - know_target=1 - ;; -m68_unisoft|m68k2|minixST|pmds) - WS=2 ; PS=4 - know_target=1 - ;; -i86|minix|xenix3) - WS=2 ; PS=2 - know_target=1 - ;; -*) trap "rm -f ws.c ws.o a.out t$$" 0 1 2 3 15 - cat > ws.c <<'EOF' -#include -main() -{ - printf("WS=%d ; PS=%d\n", sizeof(int), sizeof(char *)); - exit(0); -} -EOF - if [ $TARGET_HOME = $UTIL_HOME ] && cc ws.c 2>/dev/null - then - : We can find out ourselves what the word-size and - : the pointer-size of the target machine is. - cc ws.c 2>/dev/null - ./a.out > t$$ - . t$$ - rm -f t$$ a.out ws.[co] - else - : we will have to ask installer. - echo $E_FLAG "Please give the word-size of the target-machine (sizeof(int)) in bytes: [$WS] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$WS";; - esac - WS="$ANS" - echo $E_FLAG "Please give the pointer-size of the target-machine (sizeof(char *)) in bytes: [$PS] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$PS";; - esac - PS="$ANS" - fi - ;; -esac - -echo "# Paths: -SRC_HOME = $SRC_HOME -TARGET_HOME = $TARGET_HOME -UTIL_HOME = $UTIL_HOME - -# Machine independent part created? -DO_MACHINE_INDEP = $DO_MACHINE_INDEP - -# Target machine, only needed for fast compilers -MACH = $MACH -" > make_macros - -if [ $TARGET_HOME = $UTIL_HOME ] -then - if [ -f /bin/ranlib -o -f /usr/bin/ranlib -o -f /usr/ucb/ranlib ] - then - sed "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" < $FDIR/target_comp >> make_macros - else - sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros - fi - case $ACM in - sun3|sparc) - ed -s make_macros <<'EOF' -/cc-and-mkdep.sun/s/^..// -w -q -EOF - ;; - esac - cat $FDIR/util_comp >> make_macros -else - case $know_target in - 1) sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "/cc-and-mkdep.ack/s/^..//" -e "s/^CC=cc/CC=acc -m$ACM/" -e "s/^# AR=aal/AR=aal/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros - ;; - *) if [ -f /bin/ranlib -o -f /usr/bin/ranlib -o -f /usr/ucb/ranlib ] - then - sed "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" < $FDIR/target_comp >> make_macros - else - sed -e "s/^COPTIONS.*\$/COPTIONS=-O -D_EM_WSIZE=$WS -D_EM_PSIZE=$PS -D__${MACH}__/" -e "s/^# RANLIB=:/RANLIB=:/" < $FDIR/target_comp >> make_macros - fi - ;; - esac - sed "s/^#U/U/" < $FDIR/util_comp >> make_macros -fi - -cat $FDIR/lint_params >> make_macros - -echo "A file called 'make_macros' has been created. This file defines some -'make' variables that parameterize all Makefiles in ACK. You may want -to check it before attempting to actually install ACK." -case $know_target in -0) echo "In fact, this installation script does not know much about -your target machine, so expect some things to be wrong" - ;; -esac diff --git a/first/get_sys b/first/get_sys deleted file mode 100755 index c2358e4d2..000000000 --- a/first/get_sys +++ /dev/null @@ -1,157 +0,0 @@ -#!/bin/sh - -rm -f em_path.h -echo "You will now be asked for the root directory of the ACK sources. -This directory will not be changed by the installation process. -" -while : -do - echo $E_FLAG "Please give the root of the ACK source tree, -an absolute path: [$SRC_HOME] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$SRC_HOME" ;; - esac - SRC_HOME="$ANS" - case $SRC_HOME in - /*) break; - ;; - *) echo "$SRC_HOME is not an absolute path; try again" - ;; - esac -done -echo "You will now be asked for a configuration directory. This is -the directory in which the compilations will take place. The tree that -resides in it will have the same structure as the ACK source tree, but -the directories will usually only contain Makefiles and .o files. -" -while : -do - echo $E_FLAG "Please give the root of the configuration tree, -an absolute path: [$CONFIG] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$CONFIG";; - esac - CONFIG="$ANS" - case $CONFIG in - /*) break; - ;; - *) echo "$CONFIG is not an absolute path; try again" - ;; - esac -done -echo "You will now be asked for the root directory of the ACK binaries. After -installation, this directory will have subdirectories bin, lib, lib.bin, -man, h, config, include, modules, doc. -Four of these directories will contain stuff that depends on the machine -for which the ACK binaries are made: bin, modules, config, and lib.bin. The -other sub-directories (lib, man, h, include and doc) will contain -machine-independent stuff. -This information may be useful if you want to use ACK on different platforms -and you have a shared file system. See the installation manual. -" -while : -do - echo $E_FLAG "Please give the root of the ACK binaries, -an absolute path: [$TARGET_HOME] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$TARGET_HOME";; - esac - TARGET_HOME="$ANS" - case $TARGET_HOME in - /*) break; - ;; - *) echo "$TARGET_HOME is not an absolute path; try again" - ;; - esac -done -sed -e "/^#define[ ]*EM_DIR/s@\".*\"@\"$TARGET_HOME\"@" <$FDIR/em_path.h.src >em_path.h - -echo "You will now be asked for the type of the system that you want -ACK binaries produced for. This is not neccessarily the system you -run this program on. In this case, if you have not done so already, -you will have to install ACK on the current machine first. -" -echo "Give me the type of the system, the current choice is: -vax_bsd4_1a VAX11 with BSD4.1a -vax_bsd4_2 VAX11 with BSD4.2 -vax_sysV_2 VAX11 with System V.2 -i386 Intel 80386 system running Xenix System V -sun3 Sun 3 M68020 workstation -sun2 Sun 2 M68000 workstation -m68_sysV_0 Motorola 68000 with Uniplus System V.0 Unix -m68020 Motorola M68020 VME131 running Unix System V/68 R2V2.1 -sparc SUN SPARC workstation running SunOs 4 -sparc_solaris SUN SPARC workstation running solaris 2 -ANY Neither of the above -" -echo $E_FLAG "system type: [$SYSNAME] $E_SFX" -. $FDIR/get_answer -case $ANS in -'') ANS="$SYSNAME";; -esac -SYSNAME="$ANS" - -while : -do -echo $E_FLAG "Is this the system you are running on? (y/n) [$CURRENT] $E_SFX" -. $FDIR/get_answer -case $ANS in -'') ANS="$CURRENT";; -esac -case X$ANS in -Xj*|Xy*|X) UTIL_HOME=$TARGET_HOME - CURRENT=y - break - ;; -Xn*) CURRENT=n - echo "You will now be asked for the root directory of ACK on the current machine. -This tree will not be changed by the installation process. -" - while : - do - echo $E_FLAG "Please give the root of a runnable ACK tree, -an absolute path: [$UTIL_HOME] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$UTIL_HOME" ;; - esac - UTIL_HOME="$ANS" - case $UTIL_HOME in - /*) break; - ;; - *) echo "$UTIL_HOME is not an absolute path; try again" - ;; - esac - done - break - ;; -*) echo "I do not understand your answer ($ANS). Try again." - ;; -esac -done - -while : -do -echo "The system to install ACK for is $SYSNAME, -the root of the ACK source tree is $SRC_HOME, -the root of the configuration tree is $CONFIG, -the root of the ACK binary tree to be created is $TARGET_HOME, -and the root of a runnable ACK binary tree is $UTIL_HOME. -If the machine to compile ACK for is the current machine, the last two names -may be identical." -echo $E_FLAG "Are you satisfied with all this? (y/n) $E_SFX" -. $FDIR/get_answer -case X$ANS in -Xj*|Xy*|X) break - ;; -Xn*) echo Ok, I will give you another chance.... - . $0 - break - ;; -*) echo "I do not understand your answer ($ANS). Try again." - ;; -esac -done diff --git a/first/get_sysvax b/first/get_sysvax deleted file mode 100755 index ed92a123c..000000000 --- a/first/get_sysvax +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -while : -do - echo $E_FLAG "Which system-call library do you want to install for the VAX? -You can choose between - libbsd4_1a for Berkeley Unix 4.1 - libbsd4_2 for Berkeley Unix 4.2 or newer, or Ultrix - libsysV_2 for Unix System V -Your choice: [$SYSVAX] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$SYSVAX";; - esac - SYSVAX="$ANS" - case $SYSVAX in - libbsd4_1a|libbsd4_2|libsysV_2) - break - ;; - *) echo "I do not understand your answer ($SYSVAX). Try again" - ;; - esac -done diff --git a/first/install_tail b/first/install_tail deleted file mode 100644 index bcd6d3957..000000000 --- a/first/install_tail +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh - -set -e - -PATH=::$CONFIG/bin:$UTIL_HOME/bin:/usr/ccs/bin:/usr/ucb:$PATH -export PATH - -$SRC_HOME/first/create_dir $CONFIG -$SRC_HOME/first/create_dir $CONFIG/bin - -( - # Slight complication here to ensure that the #! magic at the - # beginning of TakeAction is preserved correctly. - - head -1 $SRC_HOME/TakeAction - echo "PATH=:$CONFIG/bin:$UTIL_HOME/bin:$PATH; export PATH" - tail +2 $SRC_HOME/TakeAction -) > $CONFIG/bin/TakeAction - -sed '/^#PARAMS/r make_macros' < $SRC_HOME/first/mk_makefile > $CONFIG/bin/mk_makefile -cp $SRC_HOME/first/create_dir $CONFIG/bin/create_dir -cp $SRC_HOME/first/cp_dir $CONFIG/bin/cp_dir -chmod +x $CONFIG/bin/* - -$SRC_HOME/first/mk_config - -$SRC_HOME/first/mk_target - -$SRC_HOME/first/limit_impl - -case $SYSNAME in -i386) - ed -s $TARGET_HOME/lib/descr/fe << 'ABC' -1,$s/-D{NAME}/-D{NAME} -DNO_PROTOTYPE/ -w -q -ABC - ;; -esac - -: find varargs include file -: if not present use our own - -if test -f /usr/include/varargs.h -then - : -else - cp $SRC_HOME/include/_tail_cc/varargs.h $TARGET_HOME/modules/h -fi - -case X$SYSVAX in -Xvax_sysV_2) - ed -s $TARGET_HOME/lib/vax4/descr << 'ABC' -/CPP_F/s/$/ -D__USG/ -w -q -ABC - ed -s $CONFIG/mach/vax4/Action << 'ABC' -/libbsd4_2/s/libbsd4_2/libsysV_2/ -w -q -ABC - ( cd $CONFIG/mach/vax4 - for i in libcc libcc.ansi - do - ed -s $i/Makefile << 'ABC' -/BFS/s/BFS/UFS/ -w -q -ABC - done - ) - ;; -Xvax_bsd4_2) - ed -s $TARGET_HOME/lib/vax4/descr << 'ABC' -/CPP_F/s/$/ -D__BSD4_2/ -w -q -ABC - ;; -Xvax_bsd4_1a) - ed -s $CONFIG/mach/vax4/Action << 'ABC' -/libbsd4_2/s/libbsd4_2/libbsd4_1a/ -w -q -ABC - ;; -esac - -: and finally installing ... -cd $CONFIG -set +e -exec TakeAction diff --git a/first/limit_enquire b/first/limit_enquire deleted file mode 100644 index e93e19db3..000000000 --- a/first/limit_enquire +++ /dev/null @@ -1,209 +0,0 @@ -#!/bin/sh - -while : -do - echo "The libraries will end up in the machine-independent part of the -ACK binary tree. You may already have them from a previous ACK installation -on a different machine, in particular if you have an NFS file system. -Therefore, it may not be neccessary to install them again. As this part -of the ACK installation takes the most time, you are given the opportunity -to disable installation of the machine-independent part" - echo $E_FLAG \ - "Do you want to install the machine-independent part? (y/n) [$DO_MACHINE_INDEP] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$DO_MACHINE_INDEP" ;; - esac - case X$ANS in - Xj*|Xy*|X) DO_MACHINE_INDEP=y - echo "machine-independent part will be installed" - echo - break - ;; - Xn*) DO_MACHINE_INDEP=n - echo "machine-independent part will not be installed" - echo - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac -done -OLD_DIS_LANG="$DISABLE_LANG" -DISABLE_LANG= -case X$OLD_DIS_LANG in -X) ;; -*) set $OLD_DIS_LANG - ;; -esac -for i in Modula-2 Pascal Occam Basic ANSI-C C Fortran -do - DEF=y - if [ $# != 0 -a X$i = X$1 ] - then - DEF=n - shift - fi - while : - do - echo $E_FLAG "Do you want to install $i? (y/n) [$DEF] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$DEF";; - esac - case X$ANS in - Xj*|Xy*) - echo "$i will be installed" - echo - break - ;; - Xn*) DISABLE_LANG=$DISABLE_LANG" $i" - echo "$i will not be installed" - echo - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac - done -done -OLD_DIS_SUP="$DISABLE_SUP" -DISABLE_SUP= -set $MACH_LIST -while test $# != 0 -do - DEF=y - for i in $OLD_DIS_SUP - do - if [ X$i = X$1 ] - then - DEF=n - break - fi - done - while : - do - case $1 in - i86) echo "not installing i86 will disable installation of xenix3 and minix." - ;; - m68k2) echo "not installing m68k2 will disable installation of pmds, minixST, -m68k4, pmds4, sun2, and mantra." - ;; - m68k4) echo "not installing m68k4 will disable installation of pmds4, sun2, and mantra." - ;; - m68020) echo "not installing m68020 will disable installation of sun3." - ;; - esac - echo $E_FLAG "Do you want to install the $1 support? (y/n) [$DEF] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$DEF";; - esac - case X$ANS in - Xj*|Xy*) - echo "The $1 support will be installed" - echo - case $1 in - vax4) case $SYSNAME in - vax_bsd4_1a) SYSVAX=libbsd4_1a - ;; - vax_bsd4_2) SYSVAX=libbsd4_2 - ;; - vax_sysV_2) SYSVAX=libsysV_2 - ;; - *) if [ $DO_MACHINE_INDEP = y ] - then - . $FDIR/get_sysvax - fi - ;; - esac - ;; - sparc) shift - ;; - esac - break - ;; - Xn*) DISABLE_SUP=$DISABLE_SUP" $1" - echo "The $1 support will not be installed" - echo - case $1 in - i86) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - m68k2) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - m68k4) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - sparc) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - m68020) - shift - DISABLE_SUP=$DISABLE_SUP" $1" - ;; - esac - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac - done - shift -done - -if [ $TARGET_HOME = $UTIL_HOME ] -then - case $ACM in - sun3|m68020|i386|vax*) - while : - do - echo $E_FLAG "Do you want to install the fast compilers? (y/n) [$DO_FAST] $E_SFX" - . $FDIR/get_answer - case $ANS in - '') ANS="$DO_FAST" ;; - esac - case X$ANS in - Xj*|Xy*) - DO_FAST=y - echo "The fast compilers will be installed" - break - ;; - Xn*) - DO_FAST=n - echo "The fast compilers will not be installed" - break - ;; - *) echo "I do not understand your answer ($ANS). Try again." - ;; - esac - done - ;; - *) - DO_FAST=n - ;; - esac -else - DO_FAST=n -fi diff --git a/first/limit_impl b/first/limit_impl deleted file mode 100755 index 284f2c15e..000000000 --- a/first/limit_impl +++ /dev/null @@ -1,208 +0,0 @@ -#!/bin/sh - -for i in $DISABLE_LANG -do - ed -s $CONFIG/Action <> Action <> Action < $CONFIG/bin/ack_sys -echo "echo $SYSNAME" >> $CONFIG/bin/ack_sys -chmod +x $CONFIG/bin/ack_sys - -cd $SRC_HOME -find . -type d -perm -555 -print > $CONFIG/dir_list - -cd $CONFIG -for i in mach/*/libsys -do - rm -rf $i -done - -for i in `cat dir_list` -do - create_dir $i - rm -f $i/No* - if [ -f $i/Makefile ] - then - ( cd $i ; if make clean ; then exit 0 ; else exit 0 ; fi ) > /dev/null 2>&1 - fi - if [ -f $SRC_HOME/$i/proto.make ] - then mk_makefile $SRC_HOME/$i/proto.make > $i/Makefile - fi - if [ -f $SRC_HOME/$i/Action ] - then - cd $SRC_HOME/$i - cp Action* $CONFIG/$i - chmod +w $CONFIG/$i/Action* - cd $CONFIG - fi -done - -cd $CONFIG - -for i in lang/cem/cemcom.ansi lang/cem/cemcom lang/m2/comp -do - cp $SRC_HOME/$i/BigPars $CONFIG/$i/Parameters - chmod +w $CONFIG/$i/Parameters -done -for i in lang/pc/comp lang/cem/cpp.ansi -do - cp $SRC_HOME/$i/Parameters $CONFIG/$i/Parameters - chmod +w $CONFIG/$i/Parameters -done - -cd $CONFIG/mach -for i in * -do - if [ -d $i ] - then - if [ -d $i/as ] - then - cd $i/as - mk_makefile $SRC_HOME/mach/proto/as/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile - cd ../.. - fi - if [ -d $i/top ] - then - cd $i/top - mk_makefile $SRC_HOME/mach/proto/top/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile - cd ../.. - fi - if [ -d $i/cg ] - then - cd $i/cg - mk_makefile $SRC_HOME/mach/proto/cg/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile - cd ../.. - fi - if [ -d $i/ncg ] - then - cd $i/ncg - mk_makefile $SRC_HOME/mach/proto/ncg/proto.make | sed -e "/#MACH_DEFINE/,/^MACH/s/=.*/= $i/" > Makefile - if [ -f $SRC_HOME/mach/$i/ncg/table_dir ] - then - ed -s Makefile < Makefile - cd ../.. - fi - done - for j in libbsd4_1a libbsd4_2 libsysV_2 - do - if [ -d $i/$j ] - then - cd $i/$j - mk_makefile $SRC_HOME/mach/proto/libg/proto.libsys | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" -e "s/libsys/$j/g" > Makefile - cd ../.. - fi - done - for j in libcc libcc.ansi libm2 libpc libbc liboc libf77 - do - create_dir $i/$j - rm -f $i/$j/No* - cd $i/$j - mk_makefile $SRC_HOME/mach/proto/libg/proto.$j | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" > Makefile - cd ../.. - done - if [ $i = vax4 ] - then : - elif [ -d $i/libsys ] - then : - else - create_dir $i/libsys - rm -f $i/libsys/No* - cd $i/libsys - mk_makefile $SRC_HOME/mach/proto/libg/proto.sysmon | sed -e "/#MACH_PARAMS/r $SRC_HOME/mach/$i/mach_params" > Makefile - cd ../.. - fi - fi -done diff --git a/first/mk_makefile b/first/mk_makefile deleted file mode 100755 index ae0946bf1..000000000 --- a/first/mk_makefile +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -: '$Id$' - -: This shell script inserts make macros after a line -: starting with #PARAMS in "make_proto", and produces the result on -: standard output. - -trap "rm -f /tmp/mk_mak$$" 0 1 2 3 15 -case $# in -1) ;; -*) echo "Usage: $0 " 1>&2 - exit 1 - ;; -esac - -cp $1 /tmp/mk_mak$$ - -ed -s /tmp/mk_mak$$ << 'EOF' -/^#PARAMS/c -#PARAMS do not remove this line! -. -w -q -EOF -case `ack_sys` in -sparc_solaris) - ed -s /tmp/mk_mak$$ << 'EOF' -g/^EXTRALIB/s/=/= -lelf/ -w -q -EOF - ;; -esac -cat /tmp/mk_mak$$ -exit 0 diff --git a/first/mk_target b/first/mk_target deleted file mode 100755 index 8ab62a4b6..000000000 --- a/first/mk_target +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -set -e - -: machine-dependant stuff - -create_dir $TARGET_HOME -create_dir $TARGET_HOME/config -create_dir $TARGET_HOME/lib.bin -create_dir $TARGET_HOME/modules -create_dir $TARGET_HOME/modules/h -create_dir $TARGET_HOME/bin - -cp local.h em_path.h $TARGET_HOME/config -cp_dir $SRC_HOME/bin $TARGET_HOME/bin -cp $CONFIG/bin/cp_dir $TARGET_HOME/bin/cp_dir -echo "echo $SYSNAME" > $TARGET_HOME/bin/ack_sys -chmod +x $TARGET_HOME/bin/ack_sys - -: machine-independant stuff - -if [ $DO_MACHINE_INDEP = n ] -then - exit 0 -fi - -create_dir $TARGET_HOME/lib -create_dir $TARGET_HOME/etc -create_dir $TARGET_HOME/h -create_dir $TARGET_HOME/include -create_dir $TARGET_HOME/doc - -cp $SRC_HOME/etc/ip_spec.t $TARGET_HOME/etc/ip_spec.t -cp_dir $SRC_HOME/lib $TARGET_HOME/lib -cp_dir $SRC_HOME/h $TARGET_HOME/h -cp_dir $SRC_HOME/include $TARGET_HOME/include - -cd $TARGET_HOME -find . -type f -exec chmod +w {} \; - -exit 0 diff --git a/first/target_comp b/first/target_comp deleted file mode 100644 index db980dcfc..000000000 --- a/first/target_comp +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# compiler set for target machine - -CC=cc# # compiler to be used for compiling ACK - -# always passed to $(CC) -c. -COPTIONS=-O -D_EM_WSIZE=4 -D_EM_PSIZE=4 - -# passed to $(CC) -c when compiling modules. -LIBOPTIONS=# -# LIBOPTIONS=-LIB -L # when $(CC) is ACK - -CC_AND_MKDEP=cc-and-mkdep.all# # when $(CC) is neither ACK or SUN, -# CC_AND_MKDEP=cc-and-mkdep.ack## when $(CC) is an ACK-derived C compiler, -# CC_AND_MKDEP=cc-and-mkdep.sun## when $(CC) is a SUN C compiler - -LDOPTIONS=# # always passed to $(CC) when linking - -SUF=o# # suffix of files produced with $(CC) -c - -AR=ar# # archiver for Unix format objects -# AR=aal# # archiver for ACK .o format objects -# AR=arch# # archiver for ACK .s format objects - -RANLIB=ranlib# # when ranlib required -# RANLIB=:# # when ranlib not required - -LIBSUF=a# # suffix of object libraries diff --git a/first/util_comp b/first/util_comp deleted file mode 100644 index 8f046f627..000000000 --- a/first/util_comp +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# compiler set for producing runnable binaries (possibly using $(UTIL_HOME)). -# This must describe the compiler with which $(UTIL_HOME) has been compiled. -# If $(TARGET_HOME) is identical to $(UTIL_HOME), which usually will be -# the case, this part does not have to be changed. Otherwise (when you are -# cross-compiling ACK), you will have to change this part. Probable -# replacements are given in comments. Maybe the installation script -# has already changed them, but they should be checked to be sure. - -UCC=$(CC) -#UCC=cc# # compiler to be used - -UCOPTIONS=$(COPTIONS) -#UCOPTIONS=-O# # always passed to $(UCC) -c. - -ULDOPTIONS=$(LDOPTIONS) -#ULDOPTIONS=# # always passed to $(UCC) when linking - -USUF=$(SUF) -#USUF=o# # suffix of files produced with $(UCC) -c - -ULIBSUF=$(LIBSUF) -#ULIBSUF=a# # suffix of object libraries for $(UCC) diff --git a/first/yacc.lua b/first/yacc.lua new file mode 100644 index 000000000..bffaeee4c --- /dev/null +++ b/first/yacc.lua @@ -0,0 +1,44 @@ +definerule("yacc", + { + srcs = { type="targets" }, + commands = { + type="strings", + default={ + "yacc -t -b %{dir}/y -d %{ins}" + } + }, + }, + function (e) + return normalrule { + name = e.name, + cwd = e.cwd, + ins = e.srcs, + outleaves = { "y.tab.c", "y.tab.h" }, + label = e.label, + commands = e.commands, + } + end +) + +definerule("flex", + { + srcs = { type="targets" }, + commands = { + type="strings", + default={ + "flex -s -t %{ins} > %{outs[1]}" + } + } + }, + function (e) + return normalrule { + name = e.name, + cwd = e.cwd, + ins = e.srcs, + outleaves = { "lex.yy.c" }, + label = e.label, + commands = e.commands + } + end +) + diff --git a/first/yacc.pm b/first/yacc.pm deleted file mode 100644 index 92bbe39dc..000000000 --- a/first/yacc.pm +++ /dev/null @@ -1,18 +0,0 @@ -yacc = simple { - class = "yacc", - outputs = {"%U%/%I%.c"}, - - command = { - "yacc -t -b %out[1]:dirname%/y -d %in%", - "mv %out[1]:dirname%/y.tab.c %out[1]%" - } -} - -flex = simple { - class = "flex", - outputs = {"%U%/%I%.c"}, - - command = { - "flex -s -t %in% > %out%" - } -} diff --git a/h/.distr b/h/.distr deleted file mode 100644 index 7ab9a7094..000000000 --- a/h/.distr +++ /dev/null @@ -1,29 +0,0 @@ -#Makefile -arch.h -bc_io.h -bc_string.h -#as_spec.h -cg_pattern.h -cgg_cg.h -em_abs.h -em_ego.h -em_flag.h -em_mes.h -#em_mnem.h -#em_pseu.h -em_ptyp.h -em_reg.h -#em_spec.h -out.h -stb.h -pc_err.h -pc_file.h -pc_math.h -ranlib.h -ocm_chan.h -ocm_parco.h -ocm_proc.h -m2_traps.h -#ip_spec.h -em_table -con_float diff --git a/h/build.lua b/h/build.lua new file mode 100644 index 000000000..4249c1e55 --- /dev/null +++ b/h/build.lua @@ -0,0 +1,33 @@ +normalrule { + name = "em_path", + ins = {}, + outleaves = { "em_path.h" }, + commands = { + "echo '#define TMP_DIR \"/tmp\"' > %{outs}", + "echo '#define EM_DIR \"$(PREFIX)\"' >> %{outs}", + "echo '#define ACK_PATH \"share/ack/descr\"' >> %{outs}", + } +} + +normalrule { + name = "local", + ins = {}, + outleaves = { "local.h" }, + commands = { + "echo '#define VERSION 3' > %{outs}", + "echo '#define ACKM \"$(DEFAULT_PLATFORM)\"' >> %{outs}", + "echo '#define BIGMACHINE 1' >> %{outs}", + "echo '#define SYS_5' >> %{outs}", + } +} + +clibrary { + name = "emheaders", + hdrs = { + "./*.h", + "./con_float", + "+em_path", + "+local", + } +} + diff --git a/h/out.h b/h/out.h index 122296f8e..30cb6ba69 100644 --- a/h/out.h +++ b/h/out.h @@ -6,22 +6,25 @@ #ifndef __OUT_H_INCLUDED #define __OUT_H_INCLUDED + +#include + /* * output format for ACK assemblers */ struct outhead { - unsigned short oh_magic; /* magic number */ - unsigned short oh_stamp; /* version stamp */ - unsigned short oh_flags; /* several format flags */ - unsigned short oh_nsect; /* number of outsect structures */ - unsigned short oh_nrelo; /* number of outrelo structures */ - unsigned short oh_nname; /* number of outname structures */ - long oh_nemit; /* sum of all os_flen */ - long oh_nchar; /* size of string area */ + uint16_t oh_magic; /* magic number */ + uint16_t oh_stamp; /* version stamp */ + uint16_t oh_flags; /* several format flags */ + uint16_t oh_nsect; /* number of outsect structures */ + uint16_t oh_nrelo; /* number of outrelo structures */ + uint16_t oh_nname; /* number of outname structures */ + uint32_t oh_nemit; /* sum of all os_flen */ + uint32_t oh_nchar; /* size of string area */ }; -#define O_MAGIC 0x0201 /* magic number of output file */ +#define O_MAGIC 0x0202 /* magic number of output file */ #define O_STAMP 0 /* version stamp */ #define MAXSECT 64 /* Maximum number of sections */ @@ -29,18 +32,18 @@ struct outhead { #define HF_8086 0x0008 /* os_base specially encoded */ struct outsect { - long os_base; /* startaddress in machine */ - long os_size; /* section size in machine */ - long os_foff; /* startaddress in file */ - long os_flen; /* section size in file */ - long os_lign; /* section alignment */ + uint32_t os_base; /* startaddress in machine */ + uint32_t os_size; /* section size in machine */ + uint32_t os_foff; /* startaddress in file */ + uint32_t os_flen; /* section size in file */ + uint32_t os_lign; /* section alignment */ }; struct outrelo { - char or_type; /* type of reference */ - char or_sect; /* referencing section */ - unsigned short or_nami; /* referenced symbol index */ - long or_addr; /* referencing address */ + uint16_t or_type; /* type of reference */ + uint16_t or_sect; /* referencing section */ + uint16_t or_nami; /* referenced symbol index */ + uint32_t or_addr; /* referencing address */ }; struct outname { @@ -50,24 +53,25 @@ struct outname { } on_u; #define on_mptr on_u.on_ptr #define on_foff on_u.on_off - unsigned short on_type; /* symbol type */ - unsigned short on_desc; /* debug info */ - long on_valu; /* symbol value */ + uint16_t on_type; /* symbol type */ + uint16_t on_desc; /* debug info */ + uint32_t on_valu; /* symbol value */ }; /* * relocation type bits */ -#define RELSZ 0x07 /* relocation length */ +#define RELSZ 0x0fff /* relocation length */ #define RELO1 1 /* 1 byte */ #define RELO2 2 /* 2 bytes */ #define RELO4 3 /* 4 bytes */ #define RELOPPC 4 /* PowerPC 26-bit address */ #define RELOH2 5 /* write top 2 bytes of 4 byte word */ +#define RELOVC4 6 /* VideoCore IV address in 32-bit instruction */ -#define RELPC 0x08 /* pc relative */ -#define RELBR 0x10 /* High order byte lowest address. */ -#define RELWR 0x20 /* High order word lowest address. */ +#define RELPC 0x2000 /* pc relative */ +#define RELBR 0x4000 /* High order byte lowest address. */ +#define RELWR 0x8000 /* High order word lowest address. */ /* * section type bits and fields @@ -98,19 +102,13 @@ struct outname { */ /* - * structure format strings - */ -#define SF_HEAD "22222244" -#define SF_SECT "44444" -#define SF_RELO "1124" -#define SF_NAME "4224" - -/* - * structure sizes (bytes in file; add digits in SF_*) + * structure sizes on disk (bytes in file; add digits in SF_*) + * Note! These are NOT the sizes in memory (64-bit architectures will have + * a different layout). */ #define SZ_HEAD 20 #define SZ_SECT 20 -#define SZ_RELO 8 +#define SZ_RELO 10 #define SZ_NAME 12 /* diff --git a/include/.distr b/include/.distr deleted file mode 100644 index b13b150f1..000000000 --- a/include/.distr +++ /dev/null @@ -1,3 +0,0 @@ -_tail_mon -_tail_cc -occam diff --git a/include/_tail_mon/.distr b/include/_tail_mon/.distr deleted file mode 100644 index 0411643ee..000000000 --- a/include/_tail_mon/.distr +++ /dev/null @@ -1,4 +0,0 @@ -errno.h -signal.h -sgtty.h -sys diff --git a/include/_tail_mon/sys/.distr b/include/_tail_mon/sys/.distr deleted file mode 100644 index 2d8e3de02..000000000 --- a/include/_tail_mon/sys/.distr +++ /dev/null @@ -1,2 +0,0 @@ -types.h -timeb.h diff --git a/lang/.distr b/lang/.distr deleted file mode 100644 index 3f75d8944..000000000 --- a/lang/.distr +++ /dev/null @@ -1,6 +0,0 @@ -basic -cem -occam -pc -m2 -fortran diff --git a/lang/a68s/.distr b/lang/a68s/.distr deleted file mode 100644 index 2e474efe9..000000000 --- a/lang/a68s/.distr +++ /dev/null @@ -1,8 +0,0 @@ -COPYRIGHT -README -a68s.1 -aem -cpem -liba68s -test -util diff --git a/lang/a68s/aem/.distr b/lang/a68s/aem/.distr deleted file mode 100644 index 6a1ee1489..000000000 --- a/lang/a68s/aem/.distr +++ /dev/null @@ -1,26 +0,0 @@ -Makefile -a68s1ce.p -a68s1cg.p -a68s1int.p -a68s1lx.p -a68s1md.p -a68s1pa.p -a68s1s1.p -a68s1s2.p -a68scod.p -a68sdec.p -a68sdum.p -a68sin.p -a68sint.p -a68spar.p -a68ssp.p -cmpdum.p -cybcod.p -dec_main.p -dec_main_s1.p -getaddr.e -make -pcalls.e -perqce.p -perqcod.p -syntax diff --git a/lang/a68s/cpem/.distr b/lang/a68s/cpem/.distr deleted file mode 100644 index 5106cc94c..000000000 --- a/lang/a68s/cpem/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -READ_ME -cpem.p diff --git a/lang/a68s/liba68s/.distr b/lang/a68s/liba68s/.distr deleted file mode 100644 index b05416159..000000000 --- a/lang/a68s/liba68s/.distr +++ /dev/null @@ -1,127 +0,0 @@ -LIST -Makefile -aclose.c -aopen.c -arctan.c -associate.p -bytespack.p -calls.e -catpl.p -cfstr.p -chains.e -cleanup.c -collp.p -colltm.p -collts.p -complex.p -cos.c -crmult.p -crrefn.p -dclpsn.p -div.e -drefm.p -drefs.p -dumbacch.p -duminch.p -dummy.p -dumoutch.p -e.h -ensure.p -entier.c -errorr.p -exit.c -exp.c -fixed.p -float.p -genrec.p -get.e -getaddr.e -getmult.p -getout.p -gett.p -global.p -globale.e -gtot.p -gtotref.p -gvasstx.p -gvscope.p -heapmul.p -heapstr.p -hoist.e -is.p -linit2.p -linit34.p -linitinc.p -ln.c -lpb.s -make -maxr.c -mod.c -mulis.p -nassp.p -nassts.p -newline.p -onend.p -openclose.p -pcollmul.p -pcollst.p -posenq.p -powi.c -powneg.p -powr.c -put.e -putt.p -random.p -rangent.p -rangext.p -reset.p -rnstart.p -routn.p -routnp.p -rowm.p -rownm.p -run68g.p -rundecs.p -safeaccess.p -scopext.p -selectr.p -selecttsn.p -setcc.p -sett.p -shl.c -shr.c -signi.c -signr.c -sin.c -skip.p -slice12.p -slicen.p -space.p -sqrt.c -standass.p -standback.e -standin.p -standout.p -stbacch.p -stinch.p -stopen.p -stoutch.p -strsubtrim.p -structscope.p -swap.e -tassp.p -tasstm.p -tassts.p -temp.c -time.c -timesten.c -trace.e -trig.p -trim.p -uplwb.p -uplwbm.p -uplwbmstr.p -whole.p -widchar.p -widen.p -wrs.e diff --git a/lang/a68s/util/.distr b/lang/a68s/util/.distr deleted file mode 100644 index e2e34cc5c..000000000 --- a/lang/a68s/util/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Makefile -checkseq.p -indent.p -reseq.p -tailor.p -xref.c -pascal.ign diff --git a/lang/basic/.distr b/lang/basic/.distr deleted file mode 100644 index 8b025617a..000000000 --- a/lang/basic/.distr +++ /dev/null @@ -1,3 +0,0 @@ -pmfile -src -lib diff --git a/lang/basic/lib/.distr b/lang/basic/lib/.distr deleted file mode 100644 index 4e51a9787..000000000 --- a/lang/basic/lib/.distr +++ /dev/null @@ -1,34 +0,0 @@ -pmfile -abs.c -asc.c -asrt.c -atn.c -chr.c -conversion.c -hlt.c -mki.c -oct.c -peek.c -power.c -exp.c -log.c -print.c -io.c -random.c -read.c -return.c -sgn.c -sin.c -fif.e -sqt.c -fef.e -stop.c -string.c -salloc.c -swap.c -trace.c -write.c -file.c -error.c -trap.c -setline.e diff --git a/lang/basic/lib/atn.c b/lang/basic/lib/atn.c index db53b81bd..18c4dc6ef 100644 --- a/lang/basic/lib/atn.c +++ b/lang/basic/lib/atn.c @@ -7,62 +7,7 @@ /* $Id$ */ -#define __NO_DEFS #include -double -_atn(x) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ +double _atn(double x) { return atan(x); } - static double p[] = { - -0.13688768894191926929e+2, - -0.20505855195861651981e+2, - -0.84946240351320683534e+1, - -0.83758299368150059274e+0 - }; - static double q[] = { - 0.41066306682575781263e+2, - 0.86157349597130242515e+2, - 0.59578436142597344465e+2, - 0.15024001160028576121e+2, - 1.0 - }; - static double a[] = { - 0.0, - 0.52359877559829887307710723554658381, /* pi/6 */ - M_PI_2, - 1.04719755119659774615421446109316763 /* pi/3 */ - }; - - int neg = x < 0; - int n; - double g; - - if (neg) { - x = -x; - } - if (x > 1.0) { - x = 1.0/x; - n = 2; - } - else n = 0; - - if (x > 0.26794919243112270647) { /* 2-sqtr(3) */ - n = n + 1; - x = (((0.73205080756887729353*x-0.5)-0.5)+x)/ - (1.73205080756887729353+x); - } - - /* ??? avoid underflow ??? */ - - g = x * x; - x += x * g * POLYNOM3(g, p) / POLYNOM4(g, q); - if (n > 1) x = -x; - x += a[n]; - return neg ? -x : x; -} diff --git a/lang/basic/lib/build.lua b/lang/basic/lib/build.lua new file mode 100644 index 000000000..71710a542 --- /dev/null +++ b/lang/basic/lib/build.lua @@ -0,0 +1,26 @@ +include("plat/build.lua") + +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./*.c", + "./*.e", + }, + hdrs = {}, -- must be empty + deps = { + "h+emheaders", + "lang/cem/libcc.ansi/headers+headers", + "plat/"..plat.."/include+headers", + }, + vars = { plat = plat } + } + + installable { + name = "pkg_"..plat, + map = { + ["$(PLATIND)/"..plat.."/libbasic.a"] = "+lib_"..plat, + } + } +end + diff --git a/lang/basic/lib/error.c b/lang/basic/lib/error.c index 6d8f9aa3c..b2d893adc 100644 --- a/lang/basic/lib/error.c +++ b/lang/basic/lib/error.c @@ -1,4 +1,5 @@ -/* $Id$ */ +#include +#include /* error takes an error value in the range of 0-255 */ /* and generates a trap */ diff --git a/lang/basic/lib/exp.c b/lang/basic/lib/exp.c index 32cb9eff9..c16344e56 100644 --- a/lang/basic/lib/exp.c +++ b/lang/basic/lib/exp.c @@ -10,88 +10,7 @@ #define __NO_DEFS #include -static double -ldexp(fl,exp) - double fl; - int exp; +double _exp(double x) { - extern double _fef(); - int sign = 1; - int currexp; - - if (fl<0) { - fl = -fl; - sign = -1; - } - fl = _fef(fl,&currexp); - exp += currexp; - if (exp > 0) { - while (exp>30) { - fl *= (double) (1L << 30); - exp -= 30; - } - fl *= (double) (1L << exp); - } - else { - while (exp<-30) { - fl /= (double) (1L << 30); - exp += 30; - } - fl /= (double) (1L << -exp); - } - return sign * fl; -} - -double -_exp(x) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ - - static double p[] = { - 0.25000000000000000000e+0, - 0.75753180159422776666e-2, - 0.31555192765684646356e-4 - }; - - static double q[] = { - 0.50000000000000000000e+0, - 0.56817302698551221787e-1, - 0.63121894374398503557e-3, - 0.75104028399870046114e-6 - }; - double xn, g; - int n; - int negative = x < 0; - - if (x <= M_LN_MIN_D) { - return M_MIN_D; - } - if (x >= M_LN_MAX_D) { - if (x > M_LN_MAX_D) error(3); - return M_MAX_D; - } - if (negative) x = -x; - - /* ??? avoid underflow ??? */ - - n = x * M_LOG2E + 0.5; /* 1/ln(2) = log2(e), 0.5 added for rounding */ - xn = n; - { - double x1 = (long) x; - double x2 = x - x1; - - g = ((x1-xn*0.693359375)+x2) - xn*(-2.1219444005469058277e-4); - } - if (negative) { - g = -g; - n = -n; - } - xn = g * g; - x = g * POLYNOM2(xn, p); - n += 1; - return (ldexp(0.5 + x/(POLYNOM3(xn, q) - x), n)); + return exp(x); } diff --git a/lang/basic/lib/hlt.c b/lang/basic/lib/hlt.c index 3ba8a681f..20f4d5276 100644 --- a/lang/basic/lib/hlt.c +++ b/lang/basic/lib/hlt.c @@ -1,4 +1,4 @@ -/* $Id$ */ +#include _hlt(nr) int nr; diff --git a/lang/basic/lib/io.c b/lang/basic/lib/io.c index b7343e278..e0d7581f0 100644 --- a/lang/basic/lib/io.c +++ b/lang/basic/lib/io.c @@ -1,9 +1,8 @@ #include "bc_io.h" -#include -/* $Id$ */ - -struct sgttyb _ttydef; +/* dtrg --- this originally used sgtty.h to do clever tty manipulation. + * Strictly this should be converted to use termios, but for simplicity + * we're going to stick with plain stdio for now. */ /* BASIC has some nasty io characteristics */ @@ -65,9 +64,6 @@ char *buf; if( _chann == -1) { pos= _pos; - gtty(0,_ttydef); - _ttydef.sg_flags &= ~ECHO; - stty(0,_ttydef); }else pos= _fdtable[_chann].pos; c= buf; while( (holder = fgetc(_chanrd)) != EOF && holder != '\n'){ @@ -79,8 +75,6 @@ char *buf; if( _chann== -1) { _pos=pos; - _ttydef.sg_flags |= ECHO; - stty(0,_ttydef); } else _fdtable[_chann].pos= pos; } _tab(x) diff --git a/lang/basic/lib/log.c b/lang/basic/lib/log.c index 06833cd0a..e194f51d7 100644 --- a/lang/basic/lib/log.c +++ b/lang/basic/lib/log.c @@ -10,48 +10,7 @@ #define __NO_DEFS #include -double -_log(x) - double x; +double _log(double x) { - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ - static double a[] = { - -0.64124943423745581147e2, - 0.16383943563021534222e2, - -0.78956112887491257267e0 - }; - static double b[] = { - -0.76949932108494879777e3, - 0.31203222091924532844e3, - -0.35667977739034646171e2, - 1.0 - }; - - extern double _fef(); - double znum, zden, z, w; - int exponent; - - if (x <= 0) { - error(3); - return -HUGE; - } - - x = _fef(x, &exponent); - if (x > M_1_SQRT2) { - znum = (x - 0.5) - 0.5; - zden = x * 0.5 + 0.5; - } - else { - znum = x - 0.5; - zden = znum * 0.5 + 0.5; - exponent--; - } - z = znum/zden; w = z * z; - x = z + z * w * (POLYNOM2(w,a)/POLYNOM3(w,b)); - z = exponent; - x += z * (-2.121944400546905827679e-4); - return x + z * 0.693359375; + return log(x); } diff --git a/lang/basic/lib/oct.c b/lang/basic/lib/oct.c index 29a9040c3..ea73bc11d 100644 --- a/lang/basic/lib/oct.c +++ b/lang/basic/lib/oct.c @@ -1,3 +1,5 @@ +#include +#include #include "bc_string.h" /* $Id$ */ diff --git a/lang/basic/lib/pmfile b/lang/basic/lib/pmfile deleted file mode 100644 index eb069d330..000000000 --- a/lang/basic/lib/pmfile +++ /dev/null @@ -1,45 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."lang/basic/lib/" - -lang_basic_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - ackfile (d.."fif.e"), - ackfile (d.."fef.e"), - ackfile (d.."setline.e"), - ackfile (d.."abs.c"), - ackfile (d.."asc.c"), - ackfile (d.."asrt.c"), - ackfile (d.."atn.c"), - ackfile (d.."chr.c"), - ackfile (d.."conversion.c"), - ackfile (d.."error.c"), - ackfile (d.."exp.c"), - ackfile (d.."file.c"), - ackfile (d.."hlt.c"), - ackfile (d.."io.c"), - ackfile (d.."log.c"), - ackfile (d.."mki.c"), - ackfile (d.."oct.c"), - ackfile (d.."peek.c"), - ackfile (d.."power.c"), - ackfile (d.."print.c"), - ackfile (d.."random.c"), - ackfile (d.."read.c"), - ackfile (d.."return.c"), - ackfile (d.."salloc.c"), - ackfile (d.."sgn.c"), - ackfile (d.."sin.c"), - ackfile (d.."sqt.c"), - ackfile (d.."stop.c"), - ackfile (d.."string.c"), - ackfile (d.."swap.c"), - ackfile (d.."trace.c"), - ackfile (d.."trap.c"), - ackfile (d.."write.c"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libbasic.a") -} diff --git a/lang/basic/lib/power.c b/lang/basic/lib/power.c index 517262342..4a33806cd 100644 --- a/lang/basic/lib/power.c +++ b/lang/basic/lib/power.c @@ -1,32 +1,4 @@ -/* $Id$ */ +#include -/* - computes a^b. - uses log and exp -*/ +double _power(double x, double y) { return pow(x, y); } -double _log(), _exp(); - -double -_power(base,pownr) -double pownr, base; -{ - double temp; - long l; - - if(pownr <= 0.0) { - if(pownr == 0.0) { - if(base <= 0.0) - error(3); - return(0.0); - } - l = base; - if(l != base) - error(3); - temp = _exp(base * _log(-pownr)); - if(l & 1) - temp = -temp; - return(temp); - } - return(_exp(base * _log(pownr))); -} diff --git a/lang/basic/lib/print.c b/lang/basic/lib/print.c index 4ed9806bf..a4bdebfc1 100644 --- a/lang/basic/lib/print.c +++ b/lang/basic/lib/print.c @@ -1,3 +1,5 @@ +#include +#include #include "bc_string.h" #include "bc_io.h" diff --git a/lang/basic/lib/random.c b/lang/basic/lib/random.c index 3707d1e70..17340eddb 100644 --- a/lang/basic/lib/random.c +++ b/lang/basic/lib/random.c @@ -1,4 +1,5 @@ -/* $Id$ */ +#include +#include #if !defined(EM_WSIZE) #define EM_WSIZE _EM_WSIZE diff --git a/lang/basic/lib/salloc.c b/lang/basic/lib/salloc.c index c8e36b372..ef221a273 100644 --- a/lang/basic/lib/salloc.c +++ b/lang/basic/lib/salloc.c @@ -1,6 +1,4 @@ -/* $Id$ */ - -extern char *malloc() ; +#include char * salloc(length) unsigned length; diff --git a/lang/basic/lib/sin.c b/lang/basic/lib/sin.c index b6c3daab6..6503d92e6 100644 --- a/lang/basic/lib/sin.c +++ b/lang/basic/lib/sin.c @@ -10,96 +10,7 @@ #define __NO_DEFS #include -static double -sinus(x, cos_flag) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ +double _sin(double x) { return sin(x); } +double _cos(double x) { return cos(x); } +double _tan(double x) { return tan(x); } - static double r[] = { - -0.16666666666666665052e+0, - 0.83333333333331650314e-2, - -0.19841269841201840457e-3, - 0.27557319210152756119e-5, - -0.25052106798274584544e-7, - 0.16058936490371589114e-9, - -0.76429178068910467734e-12, - 0.27204790957888846175e-14 - }; - - double xsqr; - double y; - int neg = 0; - - if (x < 0) { - x = -x; - neg = 1; - } - if (cos_flag) { - neg = 0; - y = M_PI_2 + x; - } - else y = x; - - /* ??? avoid loss of significance, if y is too large, error ??? */ - - y = y * M_1_PI + 0.5; - - /* Use extended precision to calculate reduced argument. - Here we used 12 bits of the mantissa for a1. - Also split x in integer part x1 and fraction part x2. - */ -#define A1 3.1416015625 -#define A2 -8.908910206761537356617e-6 - { - double x1, x2; - extern double _fif(); - - _fif(y, 1.0, &y); - if (_fif(y, 0.5, &x1)) neg = !neg; - if (cos_flag) y -= 0.5; - x2 = _fif(x, 1.0, &x1); - x = x1 - y * A1; - x += x2; - x -= y * A2; -#undef A1 -#undef A2 - } - - if (x < 0) { - neg = !neg; - x = -x; - } - - /* ??? avoid underflow ??? */ - - y = x * x; - x += x * y * POLYNOM7(y, r); - return neg ? -x : x; -} - -double -_sin(x) - double x; -{ - return sinus(x, 0); -} - -double -_cos(x) - double x; -{ - if (x < 0) x = -x; - return sinus(x, 1); -} - -/* EXTENSION */ -double -_tan(x) - double x; -{ - return _sin(x)/_cos(x); -} diff --git a/lang/basic/lib/sqt.c b/lang/basic/lib/sqt.c index dbc9fa7a3..b71483ef7 100644 --- a/lang/basic/lib/sqt.c +++ b/lang/basic/lib/sqt.c @@ -10,62 +10,5 @@ #define __NO_DEFS #include -#define NITER 5 +double _sqt(double x) { return sqrt(x); } -static double -ldexp(fl,exp) - double fl; - int exp; -{ - extern double _fef(); - int sign = 1; - int currexp; - - if (fl<0) { - fl = -fl; - sign = -1; - } - fl = _fef(fl,&currexp); - exp += currexp; - if (exp > 0) { - while (exp>30) { - fl *= (double) (1L << 30); - exp -= 30; - } - fl *= (double) (1L << exp); - } - else { - while (exp<-30) { - fl /= (double) (1L << 30); - exp += 30; - } - fl /= (double) (1L << -exp); - } - return sign * fl; -} - -double -_sqt(x) - double x; -{ - extern double _fef(); - int exponent; - double val; - - if (x <= 0) { - if (x < 0) error(3); - return 0; - } - - val = _fef(x, &exponent); - if (exponent & 1) { - exponent--; - val *= 2; - } - val = ldexp(val + 1.0, exponent/2 - 1); - /* was: val = (val + 1.0)/2.0; val = ldexp(val, exponent/2); */ - for (exponent = NITER - 1; exponent >= 0; exponent--) { - val = (val + x / val) / 2.0; - } - return val; -} diff --git a/lang/basic/lib/stop.c b/lang/basic/lib/stop.c index 571562a89..8ef27cabf 100644 --- a/lang/basic/lib/stop.c +++ b/lang/basic/lib/stop.c @@ -1,4 +1,5 @@ -/* $Id$ */ +#include +#include _stop() { diff --git a/lang/basic/lib/string.c b/lang/basic/lib/string.c index bc8485991..4ccc69191 100644 --- a/lang/basic/lib/string.c +++ b/lang/basic/lib/string.c @@ -1,3 +1,5 @@ +#include +#include #include "bc_string.h" /* $Id$ */ diff --git a/lang/basic/lib/trap.c b/lang/basic/lib/trap.c index 6079686d0..4bcf742ee 100644 --- a/lang/basic/lib/trap.c +++ b/lang/basic/lib/trap.c @@ -1,3 +1,5 @@ +#include +#include #include #include diff --git a/lang/basic/pmfile b/lang/basic/pmfile deleted file mode 100644 index 180d1a2ae..000000000 --- a/lang/basic/pmfile +++ /dev/null @@ -1,7 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/basic/" - -include (d.."src/pmfile") -include (d.."lib/pmfile") diff --git a/lang/basic/src/.distr b/lang/basic/src/.distr deleted file mode 100644 index 053feca94..000000000 --- a/lang/basic/src/.distr +++ /dev/null @@ -1,19 +0,0 @@ -pmfile -basic.g -basic.lex -bem.c -bem.h -compile.c -eval.c -func.c -gencode.c -graph.c -graph.h -initialize.c -llmess.c -maketokentab -parsepar.c -symbols.c -symbols.h -util.c -yylexp.c diff --git a/lang/basic/src/basic.g b/lang/basic/src/basic.g index 8f74a69f7..5c4f6978a 100644 --- a/lang/basic/src/basic.g +++ b/lang/basic/src/basic.g @@ -90,7 +90,7 @@ #include #include #include "bem.h" -#include "llmess.c" +#include "llmess.h" typedef union { int integer ; @@ -112,7 +112,7 @@ int in_data = 0; /* set if processing DATA statement */ char *formatstring; /* formatstring used for printing */ Symbol *s; /* Symbol dummy */ -#include "yylexp.c" +#include "yylexp.h" #include "basic.lex" } diff --git a/lang/basic/src/basic.lex b/lang/basic/src/basic.lex index 974768932..4eb9e1659 100644 --- a/lang/basic/src/basic.lex +++ b/lang/basic/src/basic.lex @@ -235,9 +235,7 @@ File *stream; } } -extern char *strchr(); - -getline() +getinputline() { /* get next input line */ diff --git a/lang/basic/src/build.lua b/lang/basic/src/build.lua new file mode 100644 index 000000000..f4d6b94a8 --- /dev/null +++ b/lang/basic/src/build.lua @@ -0,0 +1,47 @@ +include("util/LLgen/build.lua") + +llgen { + name = "llgen", + srcs = { "./*.g" } +} + +normalrule { + name = "tokentab_h", + ins = { + "./maketokentab", + matching(filenamesof("+llgen"), "/Lpars.h$"), + }, + outleaves = { "tokentab.h" }, + commands = { + "%{ins} %{outs}" + } +} + +cprogram { + name = "em_bem", + srcs = { + "./*.c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+llgen", + "+tokentab_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/em_data+lib", + "modules/src/em_mes+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_bem"] = "+em_bem" + } +} + diff --git a/lang/basic/src/compile.c b/lang/basic/src/compile.c index 7325cdf74..eee685910 100644 --- a/lang/basic/src/compile.c +++ b/lang/basic/src/compile.c @@ -23,7 +23,7 @@ compileprogram() prolog2(); /* Some statements are moved from prolog2 to epilogcode in the new version of the compiler */ - while( basicline = 0, getline()) + while( basicline = 0, getinputline()) (void) LLparse(); epilogcode(); sys_close(yyin); diff --git a/lang/basic/src/gencode.c b/lang/basic/src/gencode.c index 4facb3af9..8c7a50e95 100644 --- a/lang/basic/src/gencode.c +++ b/lang/basic/src/gencode.c @@ -644,7 +644,7 @@ prolog2() C_loi((arith) BEMPTRSIZE); C_exa_dnam("trpbuf"); C_lae_dnam("trpbuf",(arith)0); - C_cal("setjmp"); + C_cal("__setjmp"); C_df_ilb(l); C_asp((arith)(BEMPTRSIZE+BEMPTRSIZE)); C_lfr((arith)BEMINTSIZE); diff --git a/lang/basic/src/llmess.c b/lang/basic/src/llmess.h similarity index 100% rename from lang/basic/src/llmess.c rename to lang/basic/src/llmess.h diff --git a/lang/basic/src/maketokentab b/lang/basic/src/maketokentab index 6ceee720d..777eb1402 100755 --- a/lang/basic/src/maketokentab +++ b/lang/basic/src/maketokentab @@ -1,6 +1,6 @@ #!/bin/sh -ed -s "${1:-Lpars.h}" <<'+' +ed -s "${1:-Lpars.h}" > $2 <<'+' 1d 1,$s/# *define // 1,$s/ ...$// @@ -13,6 +13,6 @@ char *tokentab[] = { $a }; . -w tokentab.h +1,$p q + diff --git a/lang/basic/src/pmfile b/lang/basic/src/pmfile deleted file mode 100644 index 254f67707..000000000 --- a/lang/basic/src/pmfile +++ /dev/null @@ -1,64 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/basic/src/" - -local lpars = LLgen { - file (d.."basic.g"), -} - -local tokentab_h = simple { - outputs = {"%U%/token.h"}, - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."maketokentab"), - lpars -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - lpars, - tokentab_h - } -} - -lang_basic_compiler = cprogram { - cfile_with_headers (d.."bem.c"), - cfile_with_headers (d.."symbols.c"), - cfile_with_headers (d.."initialize.c"), - cfile_with_headers (d.."compile.c"), - cfile_with_headers (d.."parsepar.c"), - cfile_with_headers (d.."gencode.c"), - cfile_with_headers (d.."util.c"), - cfile_with_headers (d.."graph.c"), - cfile_with_headers (d.."eval.c"), - cfile_with_headers (d.."func.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_alloc, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_bem"}, - install = { - pm.install("%BINDIR%%PLATDEP%/em_bem"), - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-26 23:08:09 dtrg --- Added support for the Basic compiler. --- \ No newline at end of file diff --git a/lang/basic/src/yylexp.c b/lang/basic/src/yylexp.h similarity index 100% rename from lang/basic/src/yylexp.c rename to lang/basic/src/yylexp.h diff --git a/lang/basic/test/.distr b/lang/basic/test/.distr deleted file mode 100644 index 7d139dfa6..000000000 --- a/lang/basic/test/.distr +++ /dev/null @@ -1,100 +0,0 @@ -Makefile -Out.std -bull.b -bull.b.g -buzzword.b -buzzword.b.g -checker.b -checker.b.g -creator.b -grafiek.b -grafiek.b.g -gunner.b -gunner.b.g -learn.b -learn.b.g -opg1.b -opg1.b.g -opg2.b -opg2.b.g -opg3.b -opg3.b.g -opg4.b -opg4.b.g -opg5.b -opg5.b.g -opg6.b -opg6.b.g -runcmp -som4.b -som4.b.g -test01.b -test01.b.g -test02.b -test02.b.g -test03.b -test03.b.g -test04.b -test04.b.g -test05.b -test05.b.g -test06.b -test06.b.g -test07.b -test07.b.g -test08.b -test08.b.g -test09.b -test09.b.g -test10.b -test10.b.g -test11.b -test11.b.g -test12.b -test12.b.g -test13.b -test13.b.g -test14.b -test14.b.g -test15.b -test15.b.g -test16.b -test16.b.g -test17.b -test17.b.g -test18.b -test18.b.g -test19.b -test19.b.g -test20.b -test20.b.g -test21.b -test21.b.g -test22.b -test22.b.g -test23.b -test23.b.g -test24.b -test24.b.g -test25.b -test25.b.g -test26.b -test26.b.g -test27.b -test27.b.g -test28.b -test28.b.g -test29.b -test29.b.g -test30.b -test30.b.g -test31.b -test31.b.g -test32.b -test32.b.g -test33.b -test33.b.g -test34.b -test35.b -test35.b.g -tst diff --git a/lang/basic/test/tst/.distr b/lang/basic/test/tst/.distr deleted file mode 100644 index 43fe24f68..000000000 --- a/lang/basic/test/tst/.distr +++ /dev/null @@ -1,2 +0,0 @@ -data -data1 diff --git a/distr/mkd b/lang/build.lua old mode 100755 new mode 100644 similarity index 100% rename from distr/mkd rename to lang/build.lua diff --git a/lang/cem/.distr b/lang/cem/.distr deleted file mode 100644 index b4ca36155..000000000 --- a/lang/cem/.distr +++ /dev/null @@ -1,6 +0,0 @@ -pmfile -cemcom.ansi -cpp.ansi -libcc.ansi -#cemcom -#libcc diff --git a/lang/cem/cemcom.ansi/.distr b/lang/cem/cemcom.ansi/.distr deleted file mode 100644 index 2ea332861..000000000 --- a/lang/cem/cemcom.ansi/.distr +++ /dev/null @@ -1,99 +0,0 @@ -pmfile -LLlex.c -LLlex.h -LLmessage.c -SmallPars -BigPars -align.h -arith.c -arith.h -assert.h -atw.h -blocks.c -cemcom.ansi.1 -ch3.c -ch3bin.c -ch3mon.c -char.tab -class.h -code.c -code.str -conversion.c -cstoper.c -dataflow.c -declar.g -declar.str -declarator.c -decspecs.c -decspecs.h -def.str -domacro.c -dumpidf.c -error.c -estack.str -eval.c -expr.c -expr.str -expression.g -field.c -field.str -file_info.h -fltcstoper.c -idf.c -idf.str -init.c -input.c -input.h -interface.h -ival.g -l_brace.str -l_class.h -l_comment.h -l_comment.c -l_em.h -l_ev_ord.c -l_lint.c -l_lint.h -l_misc.c -l_outdef.c -l_outdef.str -l_state.str -l_states.c -label.c -label.h -level.h -macro.str -main.c -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -mes.h -options -options.c -pragma.c -program.g -proto.c -proto.str -replace.c -replace.str -sizes.h -skip.c -specials.h -stab.c -stack.c -stack.str -statement.g -stb.c -stmt.str -struct.c -struct.str -switch.c -switch.str -tokenname.c -tokenname.h -type.c -type.str -util.str -util.c diff --git a/lang/cem/cemcom.ansi/LLlex.c b/lang/cem/cemcom.ansi/LLlex.c index 9736b4420..07a79ad8e 100644 --- a/lang/cem/cemcom.ansi/LLlex.c +++ b/lang/cem/cemcom.ansi/LLlex.c @@ -5,13 +5,8 @@ /* $Id$ */ /* L E X I C A L A N A L Y Z E R */ -#include "debug.h" -#include "lint.h" #include -#include "idfsize.h" -#include "numsize.h" -#include "strsize.h" -#include "nopp.h" +#include "parameters.h" #include "input.h" #include "arith.h" #include "def.h" diff --git a/lang/cem/cemcom.ansi/LLlex.h b/lang/cem/cemcom.ansi/LLlex.h index 7fb88292d..90b003954 100644 --- a/lang/cem/cemcom.ansi/LLlex.h +++ b/lang/cem/cemcom.ansi/LLlex.h @@ -11,7 +11,6 @@ */ #include "file_info.h" -#include "nopp.h" /* the structure of a token: */ struct token { diff --git a/lang/cem/cemcom.ansi/align.h b/lang/cem/cemcom.ansi/align.h index 1e4ee3f94..79b9be97b 100644 --- a/lang/cem/cemcom.ansi/align.h +++ b/lang/cem/cemcom.ansi/align.h @@ -5,8 +5,7 @@ /* $Id$ */ /* A L I G N M E N T D E F I N I T I O N S */ -#include "nocross.h" -#include "trgt_sizes.h" +#include "parameters.h" #ifndef NOCROSS extern int diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index ed3dc5004..d5f3af3e7 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -11,11 +11,8 @@ semantics of C is a mess. */ +#include "parameters.h" #include -#include "debug.h" -#include "lint.h" -#include "nobitfield.h" -#include "idf.h" #include #include "arith.h" #include "sizes.h" diff --git a/lang/cem/cemcom.ansi/arith.h b/lang/cem/cemcom.ansi/arith.h index 399e2645a..4bb403458 100644 --- a/lang/cem/cemcom.ansi/arith.h +++ b/lang/cem/cemcom.ansi/arith.h @@ -13,7 +13,7 @@ be handy. */ -#include "spec_arith.h" +#include "parameters.h" #ifndef SPECIAL_ARITHMETICS diff --git a/lang/cem/cemcom.ansi/assert.h b/lang/cem/cemcom.ansi/assert.h index 2210f792a..da650dad3 100644 --- a/lang/cem/cemcom.ansi/assert.h +++ b/lang/cem/cemcom.ansi/assert.h @@ -1,5 +1,6 @@ /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ @@ -10,7 +11,8 @@ there is no reasonable method to prove that a program is 100% correct, these assertions are needed in some places. */ -#include "debug.h" /* UF */ + +#include "parameters.h" #ifdef DEBUG /* Note: this macro uses parameter substitution inside strings */ diff --git a/lang/cem/cemcom.ansi/blocks.c b/lang/cem/cemcom.ansi/blocks.c index 88c6a49e3..6d75a3670 100644 --- a/lang/cem/cemcom.ansi/blocks.c +++ b/lang/cem/cemcom.ansi/blocks.c @@ -5,7 +5,7 @@ /* $Id$ */ /* B L O C K S T O R I N G A N D L O A D I N G */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include diff --git a/lang/cem/cemcom.ansi/build.lua b/lang/cem/cemcom.ansi/build.lua new file mode 100644 index 000000000..670c73abf --- /dev/null +++ b/lang/cem/cemcom.ansi/build.lua @@ -0,0 +1,165 @@ +include("util/LLgen/build.lua") +include("util/cmisc/build.lua") + +normalrule { + name = "parameters", + ins = { "./BigPars" }, + outleaves = { "parameters.h" }, + commands = { + "echo '#ifndef PARAMETERS_H' > %{outs}", + "echo '#define PARAMETERS_H' >> %{outs}", + "grep -v '^!' < %{ins} >> %{outs}", + "echo '#endif' >> %{outs}" + } +} + +local str_files = basename(filenamesof("./*.str")) +local str_targets = {} + +for _, f in ipairs(str_files) do + local bf = f:gsub("%.str$", "") + str_targets[#str_targets+1] = normalrule { + name = "allocd_header/"..bf, + ins = { "./make.allocd", "./"..f }, + outleaves = { bf..".h" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +normalrule { + name = "next-c", + ins = { + "./make.next", + "./*.str", + }, + outleaves = { "next.c" }, + commands = { + "%{ins} > %{outs[1]}" + } +} + +clibrary { + name = "nextlib", + srcs = { "+next-c" }, + hdrs = str_targets, + deps = { + "+parameters", + str_targets + } +} + +normalrule { + name = "tokenfile-g", + ins = { + "./make.tokfile", + "./tokenname.c", + }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}", + } +} + +normalrule { + name = "symbol2str-c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}", + } +} + +llgen { + name = "llgen", + srcs = { + "+tokenfile-g", -- must be first + "./*.g", + }, +} + +tabgen { + name = "tabgen", + srcs = { "./char.tab" } +} + +cprogram { + name = "cemcom", + srcs = { + "./LLlex.c", + "./LLmessage.c", + "./arith.c", + "./blocks.c", + "./ch3.c", + "./ch3bin.c", + "./ch3mon.c", + "./code.c", + "./conversion.c", + "./cstoper.c", + "./dataflow.c", + "./declarator.c", + "./decspecs.c", + "./domacro.c", + "./dumpidf.c", + "./error.c", + "./eval.c", + "./expr.c", + "./field.c", + "./fltcstoper.c", + "./idf.c", + "./init.c", + "./input.c", + "./l_comment.c", + "./l_ev_ord.c", + "./l_lint.c", + "./l_misc.c", + "./l_outdef.c", + "./l_states.c", + "./label.c", + "./main.c", + "./options.c", + "./pragma.c", + "./proto.c", + "./replace.c", + "./skip.c", + "./stab.c", + "./stack.c", + "./struct.c", + "./switch.c", + "./tokenname.c", + "./type.c", + "./util.c", + "+symbol2str-c", + "+tabgen", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "./*.h", + "+llgen", + "+nextlib", + "+parameters", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/em_data+lib", + "modules/src/em_mes+lib", + "modules/src/flt_arith+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + }, +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_cemcom.ansi"] = "+cemcom" + } +} diff --git a/lang/cem/cemcom.ansi/ch3.c b/lang/cem/cemcom.ansi/ch3.c index 6270dfd4a..bebe77efa 100644 --- a/lang/cem/cemcom.ansi/ch3.c +++ b/lang/cem/cemcom.ansi/ch3.c @@ -5,12 +5,10 @@ /* $Id$ */ /* S E M A N T I C A N A L Y S I S -- C H A P T E R 3.3 */ -#include "debug.h" -#include "lint.h" -#include "nobitfield.h" -#include "idf.h" +#include "parameters.h" #include #include "arith.h" +#include "idf.h" #include "proto.h" #include "type.h" #include "struct.h" diff --git a/lang/cem/cemcom.ansi/ch3bin.c b/lang/cem/cemcom.ansi/ch3bin.c index cb30e1087..8145b933d 100644 --- a/lang/cem/cemcom.ansi/ch3bin.c +++ b/lang/cem/cemcom.ansi/ch3bin.c @@ -5,11 +5,8 @@ /* $Id$ */ /* SEMANTIC ANALYSIS (CHAPTER 3.3) -- BINARY OPERATORS */ -#include "botch_free.h" -#include "debug.h" +#include "parameters.h" #include -#include "lint.h" -#include "idf.h" #include #include "arith.h" #include "type.h" diff --git a/lang/cem/cemcom.ansi/ch3mon.c b/lang/cem/cemcom.ansi/ch3mon.c index 40cc44025..8cffc2c9d 100644 --- a/lang/cem/cemcom.ansi/ch3mon.c +++ b/lang/cem/cemcom.ansi/ch3mon.c @@ -5,17 +5,15 @@ /* $Id$ */ /* SEMANTIC ANALYSIS (CHAPTER 3.3) -- MONADIC OPERATORS */ -#include "botch_free.h" -#include "debug.h" +#include "parameters.h" #include -#include "nobitfield.h" #include "Lpars.h" #include +#include "idf.h" #include "arith.h" #include "type.h" #include "label.h" #include "expr.h" -#include "idf.h" #include "def.h" #include "sizes.h" diff --git a/lang/cem/cemcom.ansi/code.c b/lang/cem/cemcom.ansi/code.c index 6289529ae..1beeb12c4 100644 --- a/lang/cem/cemcom.ansi/code.c +++ b/lang/cem/cemcom.ansi/code.c @@ -7,23 +7,18 @@ #include #include -#include "lint.h" -#include "debug.h" -#include "dbsymtab.h" +#include "parameters.h" #ifndef LINT #include #else #include "l_em.h" #include "l_lint.h" #endif /* LINT */ -#include "botch_free.h" #include -#include "dataflow.h" -#include "use_tmp.h" #include +#include "idf.h" #include "arith.h" #include "type.h" -#include "idf.h" #include "label.h" #include "code.h" #include "stmt.h" diff --git a/lang/cem/cemcom.ansi/conversion.c b/lang/cem/cemcom.ansi/conversion.c index 6627a30e1..485d8b8bd 100644 --- a/lang/cem/cemcom.ansi/conversion.c +++ b/lang/cem/cemcom.ansi/conversion.c @@ -5,7 +5,7 @@ /* $Id$ */ /* C O N V E R S I O N - C O D E G E N E R A T O R */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include diff --git a/lang/cem/cemcom.ansi/cstoper.c b/lang/cem/cemcom.ansi/cstoper.c index c86f122be..ac11c2ca9 100644 --- a/lang/cem/cemcom.ansi/cstoper.c +++ b/lang/cem/cemcom.ansi/cstoper.c @@ -5,8 +5,7 @@ /* $Id$ */ /* C O N S T A N T E X P R E S S I O N H A N D L I N G */ -#include "trgt_sizes.h" -#include "idf.h" +#include "parameters.h" #include #include "arith.h" #include "type.h" diff --git a/lang/cem/cemcom.ansi/dataflow.c b/lang/cem/cemcom.ansi/dataflow.c index e6f00abac..6a3fbcf65 100644 --- a/lang/cem/cemcom.ansi/dataflow.c +++ b/lang/cem/cemcom.ansi/dataflow.c @@ -9,7 +9,7 @@ Use the compiler option --d. */ -#include "dataflow.h" /* UF */ +#include "parameters.h" /* UF */ #ifdef DATAFLOW char *CurrentFunction = 0; diff --git a/lang/cem/cemcom.ansi/declar.g b/lang/cem/cemcom.ansi/declar.g index 4322cbeb0..d6119f59d 100644 --- a/lang/cem/cemcom.ansi/declar.g +++ b/lang/cem/cemcom.ansi/declar.g @@ -6,17 +6,14 @@ /* DECLARATION SYNTAX PARSER */ { -#include "lint.h" -#include "dbsymtab.h" +#include "parameters.h" #include -#include "nobitfield.h" -#include "debug.h" #include +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "label.h" #include "code.h" -#include "idf.h" #include "type.h" #include "proto.h" #include "struct.h" diff --git a/lang/cem/cemcom.ansi/declarator.c b/lang/cem/cemcom.ansi/declarator.c index 3d33a83be..212b8aeb1 100644 --- a/lang/cem/cemcom.ansi/declarator.c +++ b/lang/cem/cemcom.ansi/declarator.c @@ -5,8 +5,7 @@ /* $Id$ */ /* D E C L A R A T O R M A N I P U L A T I O N */ -#include "debug.h" -#include "botch_free.h" +#include "parameters.h" #include #include #include "arith.h" @@ -15,7 +14,6 @@ #include "Lpars.h" #include "declar.h" #include "def.h" -#include "idf.h" #include "label.h" #include "expr.h" #include "sizes.h" diff --git a/lang/cem/cemcom.ansi/def.str b/lang/cem/cemcom.ansi/def.str index adee48607..0ad7af339 100644 --- a/lang/cem/cemcom.ansi/def.str +++ b/lang/cem/cemcom.ansi/def.str @@ -5,7 +5,7 @@ /* $Id$ */ /* IDENTIFIER DEFINITION DESCRIPTOR */ -#include "lint.h" +#include "parameters.h" struct def { /* for ordinary tags */ struct def *next; diff --git a/lang/cem/cemcom.ansi/domacro.c b/lang/cem/cemcom.ansi/domacro.c index f2ac213aa..4173a11b2 100644 --- a/lang/cem/cemcom.ansi/domacro.c +++ b/lang/cem/cemcom.ansi/domacro.c @@ -5,29 +5,20 @@ /* $Id$ */ /* PREPROCESSOR: CONTROLLINE INTERPRETER */ -#include "debug.h" +#include +#include "parameters.h" +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "Lpars.h" -#include "idf.h" #include "input.h" -#include "nopp.h" -#include "lint.h" +#include "replace.h" #ifndef NOPP -#include "ifdepth.h" -#include "botch_free.h" -#include "nparams.h" -#include "parbufsize.h" -#include "textsize.h" -#include "idfsize.h" #include "assert.h" #include #include "class.h" #include "macro.h" -#include "macbuf.h" -#include "replace.h" -#include "dbsymtab.h" #ifdef DBSYMTAB #include #include diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index 18f425f26..849354bd3 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -5,16 +5,13 @@ /* $Id$ */ /* DUMP ROUTINES */ -#include "debug.h" #ifdef DEBUG +#include "parameters.h" #include -#include "nopp.h" -#include "nobitfield.h" #include #include "arith.h" #include "stack.h" -#include "idf.h" #include "def.h" #include "type.h" #include "proto.h" diff --git a/lang/cem/cemcom.ansi/error.c b/lang/cem/cemcom.ansi/error.c index 4b92b3261..10b237db4 100644 --- a/lang/cem/cemcom.ansi/error.c +++ b/lang/cem/cemcom.ansi/error.c @@ -5,7 +5,7 @@ /* $Id$ */ /* E R R O R A N D D I A G N O S T I C R O U T I N E S */ -#include "lint.h" +#include "parameters.h" #if __STDC__ #include #else @@ -18,11 +18,6 @@ #include "l_em.h" #endif /* LINT */ -#include "debug.h" -#include "lint.h" -#include "nopp.h" -#include "errout.h" - #include "tokenname.h" #include #include "arith.h" diff --git a/lang/cem/cemcom.ansi/eval.c b/lang/cem/cemcom.ansi/eval.c index 78a283c62..16f19c0ad 100644 --- a/lang/cem/cemcom.ansi/eval.c +++ b/lang/cem/cemcom.ansi/eval.c @@ -5,19 +5,16 @@ /* $Id$ */ /* EXPRESSION-CODE GENERATOR */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include #include #include -#include "debug.h" -#include "nobitfield.h" -#include "dataflow.h" #include +#include "idf.h" #include "arith.h" #include "type.h" -#include "idf.h" #include "label.h" #include "code.h" #include "assert.h" @@ -41,7 +38,7 @@ arith NewLocal(); /* util.c */ extern int err_occurred; /* error.c */ /* EVAL() is the main expression-tree evaluator, which turns - any legal expression tree into EM code. Parameters: + any legal expression tree into EM code. parameters.h: struct expr *expr pointer to root of the expression tree to be evaluated diff --git a/lang/cem/cemcom.ansi/expr.c b/lang/cem/cemcom.ansi/expr.c index 6f0eb2c4f..6d8c1e23d 100644 --- a/lang/cem/cemcom.ansi/expr.c +++ b/lang/cem/cemcom.ansi/expr.c @@ -5,13 +5,12 @@ /* $Id$ */ /* EXPRESSION TREE HANDLING */ -#include "lint.h" -#include "debug.h" +#include +#include "parameters.h" #include "assert.h" -#include "botch_free.h" #include -#include "idf.h" #include +#include "idf.h" #include "arith.h" #include "def.h" #include "type.h" @@ -23,7 +22,6 @@ #include "declar.h" #include "sizes.h" #include "level.h" -#include "use_tmp.h" extern char *symbol2str(); extern char options[]; diff --git a/lang/cem/cemcom.ansi/expression.g b/lang/cem/cemcom.ansi/expression.g index e80281299..3a1284e69 100644 --- a/lang/cem/cemcom.ansi/expression.g +++ b/lang/cem/cemcom.ansi/expression.g @@ -7,13 +7,11 @@ { #include -#include "lint.h" -#include "debug.h" +#include "parameters.h" #include #include "arith.h" #include "LLlex.h" #include "type.h" -#include "idf.h" #include "label.h" #include "expr.h" #include "code.h" diff --git a/lang/cem/cemcom.ansi/field.c b/lang/cem/cemcom.ansi/field.c index 3f8c07a57..1514942e2 100644 --- a/lang/cem/cemcom.ansi/field.c +++ b/lang/cem/cemcom.ansi/field.c @@ -5,19 +5,16 @@ /* $Id$ */ /* BITFIELD EXPRESSION EVALUATOR */ -#include "lint.h" +#include "parameters.h" #ifndef LINT -#include "nobitfield.h" #ifndef NOBITFIELD #include #include -#include "debug.h" #include #include "arith.h" #include "type.h" -#include "idf.h" #include "label.h" #include "code.h" #include "assert.h" diff --git a/lang/cem/cemcom.ansi/fltcstoper.c b/lang/cem/cemcom.ansi/fltcstoper.c index 8ac330df7..de4d26e51 100644 --- a/lang/cem/cemcom.ansi/fltcstoper.c +++ b/lang/cem/cemcom.ansi/fltcstoper.c @@ -6,11 +6,9 @@ /* C O N S T A N T E X P R E S S I O N H A N D L I N G */ /* F O R F L O A T I N G P O I N T N U M B E R S */ -#include "debug.h" +#include "parameters.h" #include "assert.h" #include -#include "trgt_sizes.h" -#include "idf.h" #include #include "arith.h" #include "type.h" diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index 56db5c20e..eb43e34bb 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -7,20 +7,15 @@ #include #include -#include "lint.h" +#include "parameters.h" #include -#include "debug.h" -#include "idfsize.h" -#include "botch_free.h" -#include "nopp.h" -#include "nparams.h" #include +#include "idf.h" #include "arith.h" #include "align.h" #include "LLlex.h" #include "level.h" #include "stack.h" -#include "idf.h" #include "label.h" #include "def.h" #include "type.h" diff --git a/lang/cem/cemcom.ansi/idf.str b/lang/cem/cemcom.ansi/idf.str index c4d01ea4b..fab968321 100644 --- a/lang/cem/cemcom.ansi/idf.str +++ b/lang/cem/cemcom.ansi/idf.str @@ -5,7 +5,7 @@ /* $Id$ */ /* IDENTIFIER DESCRIPTOR */ -#include "nopp.h" +#include "parameters.h" struct id_u { #ifndef NOPP diff --git a/lang/cem/cemcom.ansi/init.c b/lang/cem/cemcom.ansi/init.c index d59b1de18..bb1fd5559 100644 --- a/lang/cem/cemcom.ansi/init.c +++ b/lang/cem/cemcom.ansi/init.c @@ -7,15 +7,15 @@ #include #include -#include "nopp.h" +#include "parameters.h" #ifndef NOPP #include #include #include +#include "idf.h" #include "class.h" #include "macro.h" -#include "idf.h" extern char *sprint(); diff --git a/lang/cem/cemcom.ansi/input.c b/lang/cem/cemcom.ansi/input.c index e10aacb5a..2b652b64f 100644 --- a/lang/cem/cemcom.ansi/input.c +++ b/lang/cem/cemcom.ansi/input.c @@ -4,10 +4,10 @@ */ /* $Id$ */ +#include "parameters.h" #include #include #include -#include "inputtype.h" #include "file_info.h" #include "input.h" @@ -15,12 +15,9 @@ #define INP_TYPE struct file_info #define INP_VAR finfo struct file_info finfo; -#include "nopp.h" #include #include -#include "dbsymtab.h" -#include "lint.h" #ifndef NOPP #ifdef DBSYMTAB #include @@ -85,10 +82,9 @@ AtEoIF() } IncludeLevel--; #endif - if (WorkingDir[0] != '\0') free(WorkingDir); + /* We don't free WorkingDir and FileName here because the rest of the + * compiler may be holding pointers to them for displaying error messages. + */ #endif /* NOPP */ -#ifndef LINT - if (FileName != source) free(FileName); -#endif return 0; } diff --git a/lang/cem/cemcom.ansi/ival.g b/lang/cem/cemcom.ansi/ival.g index 0304d75ef..b085ebc73 100644 --- a/lang/cem/cemcom.ansi/ival.g +++ b/lang/cem/cemcom.ansi/ival.g @@ -6,18 +6,18 @@ /* CODE FOR THE INITIALISATION OF GLOBAL VARIABLES */ { -#include "lint.h" +#include +#include "parameters.h" #ifndef LINT #include #else #include "l_em.h" #include "l_lint.h" #endif /* LINT */ -#include "debug.h" #include #include -#include "nobitfield.h" #include +#include "idf.h" #include "arith.h" #include "label.h" #include "expr.h" @@ -29,11 +29,11 @@ #include "Lpars.h" #include "sizes.h" #include "align.h" -#include "idf.h" #include "level.h" #include "def.h" #include "LLlex.h" #include "estack.h" +#include "stack.h" #define con_nullbyte() C_con_ucon("0", (arith)1) #define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT) diff --git a/lang/cem/cemcom.ansi/l_comment.c b/lang/cem/cemcom.ansi/l_comment.c index da9d2b776..2ab983a85 100644 --- a/lang/cem/cemcom.ansi/l_comment.c +++ b/lang/cem/cemcom.ansi/l_comment.c @@ -5,10 +5,9 @@ /* $Id$ */ /* Lint-specific comment handling */ +#include "parameters.h" #include -#include "lint.h" - #ifdef LINT #include diff --git a/lang/cem/cemcom.ansi/l_ev_ord.c b/lang/cem/cemcom.ansi/l_ev_ord.c index 56515ebb0..c5d7550a3 100644 --- a/lang/cem/cemcom.ansi/l_ev_ord.c +++ b/lang/cem/cemcom.ansi/l_ev_ord.c @@ -5,7 +5,7 @@ /* $Id$ */ /* Lint evaluation order checking */ -#include "lint.h" +#include "parameters.h" #ifdef LINT @@ -18,7 +18,6 @@ #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" -#include "idf.h" #include "def.h" #include "code.h" /* RVAL etc */ #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/l_lint.c b/lang/cem/cemcom.ansi/l_lint.c index 497d7bd64..5f95cb0fa 100644 --- a/lang/cem/cemcom.ansi/l_lint.c +++ b/lang/cem/cemcom.ansi/l_lint.c @@ -5,12 +5,11 @@ /* $Id$ */ /* Lint main routines */ -#include "lint.h" +#include "parameters.h" #ifdef LINT #include /* for st_free */ -#include "debug.h" #include "interface.h" #include "assert.h" #ifdef ANSI @@ -19,7 +18,6 @@ #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" -#include "idf.h" #include "def.h" #include "code.h" /* RVAL etc */ #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/l_misc.c b/lang/cem/cemcom.ansi/l_misc.c index 5e8cd080d..c09c84b8b 100644 --- a/lang/cem/cemcom.ansi/l_misc.c +++ b/lang/cem/cemcom.ansi/l_misc.c @@ -5,7 +5,7 @@ /* $Id$ */ /* Lint miscellaneous routines */ -#include "lint.h" +#include "parameters.h" #ifdef LINT @@ -17,7 +17,6 @@ #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" -#include "idf.h" #include "def.h" #include "code.h" /* RVAL etc */ #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/l_outdef.c b/lang/cem/cemcom.ansi/l_outdef.c index a88945f6e..32e2172b8 100644 --- a/lang/cem/cemcom.ansi/l_outdef.c +++ b/lang/cem/cemcom.ansi/l_outdef.c @@ -5,7 +5,7 @@ /* $Id$ */ /* Lint outdef construction */ -#include "lint.h" +#include "parameters.h" #ifdef LINT @@ -26,7 +26,6 @@ #include "def.h" #include "struct.h" #include "field.h" -#include "idf.h" #include "level.h" #include "label.h" #include "code.h" diff --git a/lang/cem/cemcom.ansi/l_states.c b/lang/cem/cemcom.ansi/l_states.c index 99e1a4971..74d31b359 100644 --- a/lang/cem/cemcom.ansi/l_states.c +++ b/lang/cem/cemcom.ansi/l_states.c @@ -5,21 +5,19 @@ /* $Id$ */ /* Lint status checking */ -#include "lint.h" +#include "parameters.h" #ifdef LINT #include /* for st_free */ #include "interface.h" #include "assert.h" -#include "debug.h" #ifdef ANSI #include #endif /* ANSI */ #include "arith.h" #include "label.h" #include "expr.h" -#include "idf.h" #include "def.h" #include "code.h" /* RVAL etc */ #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/label.c b/lang/cem/cemcom.ansi/label.c index 643000452..fb200956e 100644 --- a/lang/cem/cemcom.ansi/label.c +++ b/lang/cem/cemcom.ansi/label.c @@ -5,9 +5,10 @@ /* $Id$ */ /* L A B E L H A N D L I N G */ +#include "parameters.h" +#include "idf.h" #include "Lpars.h" #include "level.h" -#include "idf.h" #include "label.h" #include "arith.h" #include "def.h" diff --git a/lang/cem/cemcom.ansi/macro.str b/lang/cem/cemcom.ansi/macro.str index 1414741c4..f229cac9b 100644 --- a/lang/cem/cemcom.ansi/macro.str +++ b/lang/cem/cemcom.ansi/macro.str @@ -5,7 +5,7 @@ /* $Id$ */ /* PREPROCESSOR: DEFINITION OF MACRO DESCRIPTOR */ -#include "nopp.h" +#include "parameters.h" #ifndef NOPP /* The flags of the mc_flag field of the macro structure. Note that diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index 4f56feb1d..556e23495 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -5,16 +5,11 @@ /* $Id$ */ /* MAIN PROGRAM */ -#include "lint.h" +#include "parameters.h" #include -#include "debug.h" -#include "nopp.h" -#include "trgt_sizes.h" -#include "use_tmp.h" -#include "inputtype.h" +#include "idf.h" #include "input.h" #include "level.h" -#include "idf.h" #include "arith.h" #include "type.h" #include "proto.h" @@ -24,7 +19,6 @@ #include "LLlex.h" #include #include "specials.h" -#include "nocross.h" #include "sizes.h" #include "align.h" #include "macro.h" diff --git a/lang/cem/cemcom.ansi/make.next b/lang/cem/cemcom.ansi/make.next index 26c24d0ce..06d50f0e0 100755 --- a/lang/cem/cemcom.ansi/make.next +++ b/lang/cem/cemcom.ansi/make.next @@ -1,6 +1,6 @@ #!/bin/sh -echo '#include "debug.h"' +echo '#include "parameters.h"' sed -n ' s:^.*ALLOCDEF.*"\(.*\)".*$:struct \1 *h_\1 = 0;\ #ifdef DEBUG\ diff --git a/lang/cem/cemcom.ansi/options.c b/lang/cem/cemcom.ansi/options.c index 379c7c603..a23ff3405 100644 --- a/lang/cem/cemcom.ansi/options.c +++ b/lang/cem/cemcom.ansi/options.c @@ -5,23 +5,16 @@ /* $Id$ */ /* U S E R O P T I O N - H A N D L I N G */ +#include "parameters.h" #include #include -#include "lint.h" -#include "botch_free.h" #include -#include "nopp.h" -#include "idfsize.h" -#include "nobitfield.h" #include "class.h" #include "macro.h" #include "idf.h" #include "arith.h" #include "sizes.h" #include "align.h" -#include "use_tmp.h" -#include "dataflow.h" -#include "dbsymtab.h" #ifndef NOPP extern char **inctable; diff --git a/lang/cem/cemcom.ansi/pmfile b/lang/cem/cemcom.ansi/pmfile deleted file mode 100644 index c22795135..000000000 --- a/lang/cem/cemcom.ansi/pmfile +++ /dev/null @@ -1,210 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/cemcom.ansi/" - -local extract_parameters = simple { - outputs = { - "%U%/lint.h", - "%U%/pathlength.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/nparams.h", - "%U%/ifdepth.h", - "%U%/density.h", - "%U%/macbuf.h", - "%U%/strsize.h", - "%U%/trgt_sizes.h", - "%U%/botch_free.h", - "%U%/dataflow.h", - "%U%/debug.h", - "%U%/use_tmp.h", - "%U%/parbufsize.h", - "%U%/textsize.h", - "%U%/inputtype.h", - "%U%/nopp.h", - "%U%/nobitfield.h", - "%U%/spec_arith.h", - "%U%/static.h", - "%U%/nocross.h", - "%U%/regcount.h", - "%U%/dbsymtab.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."BigPars") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."program.g"), - file (d.."declar.g"), - file (d.."expression.g"), - file (d.."statement.g"), - file (d.."ival.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/code.h"}, (d.."code.str") }, - allocd_header { outputs = {"%U%/declar.h"}, (d.."declar.str") }, - allocd_header { outputs = {"%U%/def.h"}, (d.."def.str") }, - allocd_header { outputs = {"%U%/expr.h"}, (d.."expr.str") }, - allocd_header { outputs = {"%U%/field.h"}, (d.."field.str") }, - allocd_header { outputs = {"%U%/estack.h"}, (d.."estack.str") }, - allocd_header { outputs = {"%U%/util.h"}, (d.."util.str") }, - allocd_header { outputs = {"%U%/proto.h"}, (d.."proto.str") }, - allocd_header { outputs = {"%U%/replace.h"}, (d.."replace.str") }, - allocd_header { outputs = {"%U%/idf.h"}, (d.."idf.str") }, - allocd_header { outputs = {"%U%/macro.h"}, (d.."macro.str") }, - allocd_header { outputs = {"%U%/stack.h"}, (d.."stack.str") }, - allocd_header { outputs = {"%U%/stmt.h"}, (d.."stmt.str") }, - allocd_header { outputs = {"%U%/struct.h"}, (d.."struct.str") }, - allocd_header { outputs = {"%U%/switch.h"}, (d.."switch.str") }, - allocd_header { outputs = {"%U%/type.h"}, (d.."type.str") }, - allocd_header { outputs = {"%U%/l_brace.h"}, (d.."l_brace.str") }, - allocd_header { outputs = {"%U%/l_state.h"}, (d.."l_state.str") }, - allocd_header { outputs = {"%U%/l_outdef.h"}, (d.."l_outdef.str") }, - lpars - } -} - -lang_cem_ansi_compiler = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."arith.c"), - cfile_with_headers (d.."blocks.c"), - cfile_with_headers (d.."ch3.c"), - cfile_with_headers (d.."ch3bin.c"), - cfile_with_headers (d.."ch3mon.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."conversion.c"), - cfile_with_headers (d.."cstoper.c"), - cfile_with_headers (d.."dataflow.c"), - cfile_with_headers (d.."declarator.c"), - cfile_with_headers (d.."decspecs.c"), - cfile_with_headers (d.."domacro.c"), - cfile_with_headers (d.."dumpidf.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."eval.c"), - cfile_with_headers (d.."expr.c"), - cfile_with_headers (d.."field.c"), - cfile_with_headers (d.."fltcstoper.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."init.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."l_comment.c"), - cfile_with_headers (d.."l_ev_ord.c"), - cfile_with_headers (d.."l_lint.c"), - cfile_with_headers (d.."l_misc.c"), - cfile_with_headers (d.."l_outdef.c"), - cfile_with_headers (d.."l_states.c"), - cfile_with_headers (d.."label.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."pragma.c"), - cfile_with_headers (d.."proto.c"), - cfile_with_headers (d.."replace.c"), - cfile_with_headers (d.."skip.c"), - cfile_with_headers (d.."stab.c"), - cfile_with_headers (d.."stack.c"), - cfile_with_headers (d.."struct.c"), - cfile_with_headers (d.."switch.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."type.c"), - cfile_with_headers (d.."util.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."code.str"), - file (d.."declar.str"), - file (d.."def.str"), - file (d.."expr.str"), - file (d.."field.str"), - file (d.."estack.str"), - file (d.."util.str"), - file (d.."proto.str"), - file (d.."replace.str"), - file (d.."idf.str"), - file (d.."macro.str"), - file (d.."stack.str"), - file (d.."stmt.str"), - file (d.."struct.str"), - file (d.."switch.str"), - file (d.."type.str"), - file (d.."l_brace.str"), - file (d.."l_state.str"), - file (d.."l_outdef.str"), - } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_input, - lib_assert, - lib_alloc, - lib_flt_arith, - lib_print, - lib_system, - lib_string, - - outputs = {"%U%/em_cemcom.ansi"}, - install = { - pm.install( BINDIR..PLATDEP.."/em_cemcom.ansi"), - pm.install(d.."cemcom.ansi.1", BINDIR.."/man/man1/cemcom.ansi.1"), - } -} diff --git a/lang/cem/cemcom.ansi/pragma.c b/lang/cem/cemcom.ansi/pragma.c index 92739dd9a..b4198d92b 100644 --- a/lang/cem/cemcom.ansi/pragma.c +++ b/lang/cem/cemcom.ansi/pragma.c @@ -5,8 +5,7 @@ /* $Id$ */ /* PREPROCESSOR: PRAGMA INTERPRETER */ -#include "debug.h" -#include "idf.h" +#include "parameters.h" #define P_UNKNOWN 0 #define NR_PRAGMAS 0 diff --git a/lang/cem/cemcom.ansi/program.g b/lang/cem/cemcom.ansi/program.g index 937effab6..861c97b2e 100644 --- a/lang/cem/cemcom.ansi/program.g +++ b/lang/cem/cemcom.ansi/program.g @@ -45,13 +45,10 @@ %start If_expr, control_if_expression; { -#include "lint.h" -#include "nopp.h" -#include "debug.h" +#include "parameters.h" #include #include "arith.h" #include "LLlex.h" -#include "idf.h" #include "label.h" #include "type.h" #include "declar.h" @@ -59,6 +56,7 @@ #include "code.h" #include "expr.h" #include "def.h" +#include "stack.h" #ifdef LINT #include "l_lint.h" #endif /* LINT */ diff --git a/lang/cem/cemcom.ansi/proto.c b/lang/cem/cemcom.ansi/proto.c index e1ff73a5e..1f7f6bf6d 100644 --- a/lang/cem/cemcom.ansi/proto.c +++ b/lang/cem/cemcom.ansi/proto.c @@ -5,19 +5,15 @@ /* $Id$ */ /* P R O T O T Y P E F I D D L I N G */ -#include "lint.h" -#include "debug.h" -#include "idfsize.h" -#include "nparams.h" -#include "botch_free.h" +#include "parameters.h" #include +#include "idf.h" #include "Lpars.h" #include "level.h" #include #include "arith.h" #include "align.h" #include "stack.h" -#include "idf.h" #include "def.h" #include "type.h" #include "struct.h" diff --git a/lang/cem/cemcom.ansi/replace.c b/lang/cem/cemcom.ansi/replace.c index 856c38d03..cde3aaf43 100644 --- a/lang/cem/cemcom.ansi/replace.c +++ b/lang/cem/cemcom.ansi/replace.c @@ -7,26 +7,18 @@ #include #include -#include "nopp.h" +#include "parameters.h" #ifndef NOPP -#include "debug.h" -#include "pathlength.h" -#include "strsize.h" -#include "nparams.h" -#include "idfsize.h" -#include "numsize.h" #include -#include "idf.h" +#include "idf.h" #include "input.h" #include "macro.h" #include "arith.h" #include "LLlex.h" #include "class.h" #include "assert.h" -#include "static.h" -#include "macbuf.h" #include "replace.h" extern struct idf *GetIdentifier(); diff --git a/lang/cem/cemcom.ansi/sizes.h b/lang/cem/cemcom.ansi/sizes.h index 69785fd04..0f38c5668 100644 --- a/lang/cem/cemcom.ansi/sizes.h +++ b/lang/cem/cemcom.ansi/sizes.h @@ -5,8 +5,7 @@ /* $Id$ */ /* VARIOUS TARGET MACHINE SIZE DESCRIPTORS */ -#include "nocross.h" -#include "trgt_sizes.h" +#include "parameters.h" #ifndef NOCROSS extern arith diff --git a/lang/cem/cemcom.ansi/skip.c b/lang/cem/cemcom.ansi/skip.c index c3687fd0a..d4a67142e 100644 --- a/lang/cem/cemcom.ansi/skip.c +++ b/lang/cem/cemcom.ansi/skip.c @@ -5,7 +5,7 @@ /* $Id$ */ /* PREPROCESSOR: INPUT SKIP FUNCTIONS */ -#include "nopp.h" +#include "parameters.h" #include "arith.h" #include "LLlex.h" #include "class.h" diff --git a/lang/cem/cemcom.ansi/stab.c b/lang/cem/cemcom.ansi/stab.c index 401d91b40..8c00838e3 100644 --- a/lang/cem/cemcom.ansi/stab.c +++ b/lang/cem/cemcom.ansi/stab.c @@ -9,7 +9,7 @@ /* $Id$ */ -#include "dbsymtab.h" +#include "parameters.h" #ifdef DBSYMTAB @@ -20,13 +20,13 @@ #include #include +#include "idf.h" #include "LLlex.h" #include "stack.h" #include "def.h" #include "type.h" #include "struct.h" #include "field.h" -#include "idf.h" #include "Lpars.h" #include "level.h" diff --git a/lang/cem/cemcom.ansi/stack.c b/lang/cem/cemcom.ansi/stack.c index b0cf97cab..49dfbfab4 100644 --- a/lang/cem/cemcom.ansi/stack.c +++ b/lang/cem/cemcom.ansi/stack.c @@ -5,21 +5,19 @@ /* $Id$ */ /* S T A C K / U N S T A C K R O U T I N E S */ -#include "lint.h" +#include "parameters.h" #include #ifndef LINT #include #else #include "l_em.h" #endif /* LINT */ -#include "debug.h" -#include "botch_free.h" #include +#include "idf.h" #include "Lpars.h" #include "arith.h" #include "stack.h" #include "type.h" -#include "idf.h" #include "def.h" #include "struct.h" #include "level.h" diff --git a/lang/cem/cemcom.ansi/statement.g b/lang/cem/cemcom.ansi/statement.g index 97fd969cc..9eb60d2ed 100644 --- a/lang/cem/cemcom.ansi/statement.g +++ b/lang/cem/cemcom.ansi/statement.g @@ -6,7 +6,7 @@ /* STATEMENT SYNTAX PARSER */ { -#include "lint.h" +#include "parameters.h" #ifndef LINT #include #else @@ -14,15 +14,11 @@ #include "l_lint.h" #endif /* LINT */ -#include "debug.h" -#include "botch_free.h" -#include "dbsymtab.h" - #include +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "type.h" -#include "idf.h" #include "label.h" #include "expr.h" #include "code.h" diff --git a/lang/cem/cemcom.ansi/struct.c b/lang/cem/cemcom.ansi/struct.c index 805df0ba5..505107cc8 100644 --- a/lang/cem/cemcom.ansi/struct.c +++ b/lang/cem/cemcom.ansi/struct.c @@ -5,13 +5,11 @@ /* $Id$ */ /* ADMINISTRATION OF STRUCT AND UNION DECLARATIONS */ -#include "nobitfield.h" -#include "debug.h" -#include "botch_free.h" +#include "parameters.h" #include +#include "idf.h" #include "arith.h" #include "stack.h" -#include "idf.h" #include "def.h" #include "type.h" #include "proto.h" diff --git a/lang/cem/cemcom.ansi/switch.c b/lang/cem/cemcom.ansi/switch.c index 59413f668..856e1b115 100644 --- a/lang/cem/cemcom.ansi/switch.c +++ b/lang/cem/cemcom.ansi/switch.c @@ -5,18 +5,14 @@ /* $Id$ */ /* S W I T C H - S T A T E M E N T A D M I N I S T R A T I O N */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include #else #include "l_em.h" #endif /* LINT */ -#include "debug.h" -#include "botch_free.h" #include -#include "density.h" #include "Lpars.h" -#include "idf.h" #include "label.h" #include #include "arith.h" diff --git a/lang/cem/cemcom.ansi/tokenname.c b/lang/cem/cemcom.ansi/tokenname.c index 75e593174..8c52b4dcb 100644 --- a/lang/cem/cemcom.ansi/tokenname.c +++ b/lang/cem/cemcom.ansi/tokenname.c @@ -5,7 +5,8 @@ /* $Id$ */ /* TOKEN NAME DEFINITIONS */ -#include "idf.h" +#include "parameters.h" +#include "idf.h" #include "arith.h" #include "LLlex.h" #include "tokenname.h" diff --git a/lang/cem/cemcom.ansi/type.c b/lang/cem/cemcom.ansi/type.c index ef0d2cdf0..2b477a725 100644 --- a/lang/cem/cemcom.ansi/type.c +++ b/lang/cem/cemcom.ansi/type.c @@ -5,14 +5,12 @@ /* $Id$ */ /* T Y P E D E F I N I T I O N M E C H A N I S M */ -#include "nobitfield.h" -#include "debug.h" -#include "botch_free.h" +#include "parameters.h" #include +#include "idf.h" #include "Lpars.h" #include "arith.h" #include "type.h" -#include "idf.h" #include "def.h" #include "proto.h" #include "sizes.h" diff --git a/lang/cem/cemcom.ansi/type.str b/lang/cem/cemcom.ansi/type.str index c1c6205d6..8796d61a4 100644 --- a/lang/cem/cemcom.ansi/type.str +++ b/lang/cem/cemcom.ansi/type.str @@ -5,8 +5,7 @@ /* $Id$ */ /* TYPE DESCRIPTOR */ -#include "nobitfield.h" -#include "dbsymtab.h" +#include "parameters.h" struct type { struct type *next; /* used for ARRAY and for qualifiers */ diff --git a/lang/cem/cemcom.ansi/util.c b/lang/cem/cemcom.ansi/util.c index 9b9d1151c..7326f04ec 100644 --- a/lang/cem/cemcom.ansi/util.c +++ b/lang/cem/cemcom.ansi/util.c @@ -11,7 +11,7 @@ allowing re-use. */ -#include "lint.h" +#include "parameters.h" #ifndef LINT #include #else @@ -22,10 +22,7 @@ #include #include -#include "debug.h" #include "util.h" -#include "use_tmp.h" -#include "regcount.h" #include "sizes.h" #include "align.h" #include "stack.h" diff --git a/lang/cem/cemcom/.distr b/lang/cem/cemcom/.distr deleted file mode 100644 index eee6d8f13..000000000 --- a/lang/cem/cemcom/.distr +++ /dev/null @@ -1,97 +0,0 @@ -pmfile -LLlex.c -LLlex.h -LLmessage.c -SmallPars -BigPars -align.h -arith.c -arith.h -asm.c -assert.h -atw.h -blocks.c -cemcom.1 -ch7.c -ch7bin.c -ch7mon.c -char.tab -class.h -code.c -code.str -conversion.c -cstoper.c -dataflow.c -declar.g -declar.str -declarator.c -decspecs.c -decspecs.str -def.str -domacro.c -dumpidf.c -error.c -estack.str -eval.c -expr.c -expr.str -expression.g -field.c -field.str -file_info.h -idf.c -idf.str -init.c -input.c -input.h -interface.h -ival.g -l_brace.str -l_class.h -l_comment.h -l_comment.c -l_em.h -l_ev_ord.c -l_lint.c -l_lint.h -l_misc.c -l_outdef.c -l_outdef.str -l_state.str -l_states.c -label.c -label.h -level.h -macro.str -main.c -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -mcomm.c -mes.h -options -options.c -program.g -replace.c -scan.c -sizes.h -skip.c -specials.h -stack.c -stack.str -statement.g -stb.c -stmt.str -struct.c -struct.str -switch.c -switch.str -tokenname.c -tokenname.h -type.c -type.str -util.str -util.c -stab.c diff --git a/lang/cem/cemcom/eval.c b/lang/cem/cemcom/eval.c index abfc1a2b1..542980db4 100644 --- a/lang/cem/cemcom/eval.c +++ b/lang/cem/cemcom/eval.c @@ -39,7 +39,7 @@ arith NewLocal(); /* util.c */ #define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER) /* EVAL() is the main expression-tree evaluator, which turns - any legal expression tree into EM code. Parameters: + any legal expression tree into EM code. parameters.h: struct expr *expr pointer to root of the expression tree to be evaluated diff --git a/lang/cem/cemcom/pmfile b/lang/cem/cemcom/pmfile deleted file mode 100644 index e415c38ed..000000000 --- a/lang/cem/cemcom/pmfile +++ /dev/null @@ -1,209 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/cemcom/" - -local extract_parameters = simple { - outputs = { - "%U%/lint.h", - "%U%/pathlength.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/nparams.h", - "%U%/ifdepth.h", - "%U%/density.h", - "%U%/lapbuf.h", - "%U%/strsize.h", - "%U%/target_sizes.h", - "%U%/botch_free.h", - "%U%/dataflow.h", - "%U%/debug.h", - "%U%/use_tmp.h", - "%U%/parbufsize.h", - "%U%/textsize.h", - "%U%/inputtype.h", - "%U%/nopp.h", - "%U%/nobitfield.h", - "%U%/spec_arith.h", - "%U%/static.h", - "%U%/nofloat.h", - "%U%/noRoption.h", - "%U%/nocross.h", - "%U%/regcount.h", - "%U%/dbsymtab.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."BigPars") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."program.g"), - file (d.."declar.g"), - file (d.."expression.g"), - file (d.."statement.g"), - file (d.."ival.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/code.h"}, (d.."code.str") }, - allocd_header { outputs = {"%U%/declar.h"}, (d.."declar.str") }, - allocd_header { outputs = {"%U%/def.h"}, (d.."def.str") }, - allocd_header { outputs = {"%U%/expr.h"}, (d.."expr.str") }, - allocd_header { outputs = {"%U%/field.h"}, (d.."field.str") }, - allocd_header { outputs = {"%U%/estack.h"}, (d.."estack.str") }, - allocd_header { outputs = {"%U%/util.h"}, (d.."util.str") }, - allocd_header { outputs = {"%U%/decspecs.h"}, (d.."decspecs.str") }, - allocd_header { outputs = {"%U%/idf.h"}, (d.."idf.str") }, - allocd_header { outputs = {"%U%/macro.h"}, (d.."macro.str") }, - allocd_header { outputs = {"%U%/stack.h"}, (d.."stack.str") }, - allocd_header { outputs = {"%U%/stmt.h"}, (d.."stmt.str") }, - allocd_header { outputs = {"%U%/struct.h"}, (d.."struct.str") }, - allocd_header { outputs = {"%U%/switch.h"}, (d.."switch.str") }, - allocd_header { outputs = {"%U%/type.h"}, (d.."type.str") }, - allocd_header { outputs = {"%U%/l_brace.h"}, (d.."l_brace.str") }, - allocd_header { outputs = {"%U%/l_state.h"}, (d.."l_state.str") }, - allocd_header { outputs = {"%U%/l_outdef.h"}, (d.."l_outdef.str") }, - lpars - } -} - -lang_cem_compiler = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."arith.c"), - cfile_with_headers (d.."asm.c"), - cfile_with_headers (d.."blocks.c"), - cfile_with_headers (d.."ch7.c"), - cfile_with_headers (d.."ch7bin.c"), - cfile_with_headers (d.."ch7mon.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."conversion.c"), - cfile_with_headers (d.."cstoper.c"), - cfile_with_headers (d.."dataflow.c"), - cfile_with_headers (d.."declarator.c"), - cfile_with_headers (d.."decspecs.c"), - cfile_with_headers (d.."domacro.c"), - cfile_with_headers (d.."dumpidf.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."eval.c"), - cfile_with_headers (d.."expr.c"), - cfile_with_headers (d.."field.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."init.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."l_comment.c"), - cfile_with_headers (d.."l_ev_ord.c"), - cfile_with_headers (d.."l_lint.c"), - cfile_with_headers (d.."l_misc.c"), - cfile_with_headers (d.."l_outdef.c"), - cfile_with_headers (d.."l_states.c"), - cfile_with_headers (d.."label.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."replace.c"), - cfile_with_headers (d.."scan.c"), - cfile_with_headers (d.."skip.c"), - cfile_with_headers (d.."stack.c"), - cfile_with_headers (d.."struct.c"), - cfile_with_headers (d.."switch.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."type.c"), - cfile_with_headers (d.."util.c"), - cfile_with_headers (d.."stab.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."code.str"), - file (d.."declar.str"), - file (d.."decspecs.str"), - file (d.."def.str"), - file (d.."expr.str"), - file (d.."field.str"), - file (d.."estack.str"), - file (d.."util.str"), - file (d.."idf.str"), - file (d.."macro.str"), - file (d.."stack.str"), - file (d.."stmt.str"), - file (d.."struct.str"), - file (d.."switch.str"), - file (d.."type.str"), - file (d.."l_brace.str"), - file (d.."l_state.str"), - file (d.."l_outdef.str"), - } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_input, - lib_assert, - lib_alloc, - lib_flt_arith, - lib_print, - lib_system, - lib_string, - - outputs = {"%U%/em_cemcom"}, - install = { - pm.install( BINDIR..PLATDEP.."/em_cemcom"), - pm.install(d.."cemcom.1", BINDIR.."/man/man1/cemcom.1"), - } -} diff --git a/lang/cem/cemcom/replace.c b/lang/cem/cemcom/replace.c index 15f9c1df8..758d14df8 100644 --- a/lang/cem/cemcom/replace.c +++ b/lang/cem/cemcom/replace.c @@ -70,7 +70,7 @@ replace(idef) return 0; } if (++mac->mc_count > 100) { - /* 100 must be some number in Parameters */ + /* 100 must be some number in parameters.h */ lexwarning("macro %s is assumed recursive", idef->id_text); return 0; diff --git a/lang/cem/cpp.ansi/.distr b/lang/cem/cpp.ansi/.distr deleted file mode 100644 index 28ed84cb2..000000000 --- a/lang/cem/cpp.ansi/.distr +++ /dev/null @@ -1,35 +0,0 @@ -pmfile -LLlex.c -LLlex.h -LLmessage.c -Parameters -arith.h -bits.h -ch3bin.c -ch3mon.c -char.tab -class.h -domacro.c -error.c -expr.c -expression.g -file_info.h -idf.c -idf.h -init.c -input.c -input.h -macro.str -main.c -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -ncpp.6 -options.c -preprocess.c -replace.c -replace.str -skip.c -tokenname.c diff --git a/lang/cem/cpp.ansi/LLlex.c b/lang/cem/cpp.ansi/LLlex.c index e828ac704..3cd162898 100644 --- a/lang/cem/cpp.ansi/LLlex.c +++ b/lang/cem/cpp.ansi/LLlex.c @@ -5,9 +5,7 @@ /* $Id$ */ /* L E X I C A L A N A L Y Z E R */ -#include "idfsize.h" -#include "numsize.h" -#include "strsize.h" +#include "parameters.h" #include #include "input.h" diff --git a/lang/cem/cpp.ansi/bits.h b/lang/cem/cpp.ansi/bits.h index 95eb2f3ca..7473d935a 100644 --- a/lang/cem/cpp.ansi/bits.h +++ b/lang/cem/cpp.ansi/bits.h @@ -3,7 +3,7 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ -#include "dobits.h" +#include "parameters.h" #ifdef DOBITS #define bit0 0x01 #define bit1 0x02 diff --git a/lang/cem/cpp.ansi/build.lua b/lang/cem/cpp.ansi/build.lua new file mode 100644 index 000000000..be124530f --- /dev/null +++ b/lang/cem/cpp.ansi/build.lua @@ -0,0 +1,111 @@ +include("util/cmisc/build.lua") +include("util/LLgen/build.lua") + +local allocd_header = definerule(nil, + { + srcs = { type="targets" } + }, + function (e) + return normalrule { + name = e.name, + ins = { + "./make.allocd", + e.srcs + }, + outleaves = basename(filenamesof(e.srcs)[1]):gsub("%.str$", ".h"), + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } + end +) + +allocd_header { + name = "macro_h", + srcs = { "./macro.str" } +} + +allocd_header { + name = "replace_h", + srcs = { "./replace.str" } +} + +normalrule { + name = "tokenfile_g", + ins = { + "./make.tokfile", + "./tokenname.c", + }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +normalrule { + name = "symbol2str_c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +normalrule { + name = "next_c", + ins = { + "./make.next", + "./*.str", + }, + outleaves = { "next.c" }, + commands = { + "sh %{ins} > %{outs}" + } +} + +local llgen = llgen { + name = "llgen", + srcs = { + "+tokenfile_g", + "./expression.g" + } +} + +tabgen { + name = "tabgen_c", + srcs = { "./char.tab" } +} + +cprogram { + name = "cpp", + srcs = concat( + "./*.c", + matching(filenamesof(llgen), "%.c$"), + "+next_c", + "+symbol2str_c", + "+tabgen_c" + ), + deps = { + "+llgen", + "+macro_h", + "+replace_h", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/cpp.ansi"] = "+cpp" + } +} + diff --git a/lang/cem/cpp.ansi/domacro.c b/lang/cem/cpp.ansi/domacro.c index 47f09af28..a5cc9407d 100644 --- a/lang/cem/cpp.ansi/domacro.c +++ b/lang/cem/cpp.ansi/domacro.c @@ -5,25 +5,19 @@ /* $Id$ */ /* PREPROCESSOR: CONTROLLINE INTERPRETER */ +#include #include "arith.h" #include "LLlex.h" #include "Lpars.h" #include "idf.h" #include "input.h" -#include "ifdepth.h" -#include "botch_free.h" -#include "nparams.h" -#include "parbufsize.h" -#include "textsize.h" -#include "idfsize.h" -#include "debug.h" +#include "parameters.h" #include #include #include "class.h" #include "macro.h" #include "bits.h" -#include "macbuf.h" #include "replace.h" extern char options[]; diff --git a/lang/cem/cpp.ansi/error.c b/lang/cem/cpp.ansi/error.c index a567b3d4a..0920976b8 100644 --- a/lang/cem/cpp.ansi/error.c +++ b/lang/cem/cpp.ansi/error.c @@ -12,8 +12,8 @@ #include #endif +#include "parameters.h" #include "arith.h" -#include "errout.h" #include "LLlex.h" /* This file contains the (non-portable) error-message and diagnostic diff --git a/lang/cem/cpp.ansi/input.h b/lang/cem/cpp.ansi/input.h index 97a81983a..55a79acde 100644 --- a/lang/cem/cpp.ansi/input.h +++ b/lang/cem/cpp.ansi/input.h @@ -4,7 +4,6 @@ */ /* $Id$ */ #define INP_PUSHBACK 3 -#include "inputtype.h" #include /* Note: The following macro only garuantees one PushBack. diff --git a/lang/cem/cpp.ansi/main.c b/lang/cem/cpp.ansi/main.c index 46f9fd2b7..db444ae80 100644 --- a/lang/cem/cpp.ansi/main.c +++ b/lang/cem/cpp.ansi/main.c @@ -5,14 +5,14 @@ /* $Id$ */ /* MAIN PROGRAM */ -#include "debug.h" +#include +#include "parameters.h" #include #include #include #include "arith.h" #include "file_info.h" -#include "idfsize.h" #include "idf.h" #include "macro.h" diff --git a/lang/cem/cpp.ansi/make.hfiles b/lang/cem/cpp.ansi/make.hfiles deleted file mode 100755 index 3bc972faf..000000000 --- a/lang/cem/cpp.ansi/make.hfiles +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -: Update Files from database - -PATH=/bin:/usr/bin - -case $# in -1) ;; -*) echo use: $0 file >&2 - exit 1 -esac - -( -IFCOMMAND="if [ -r \$FN ] ;\ - then if cmp -s \$FN \$TMP;\ - then rm \$TMP;\ - else mv \$TMP \$FN;\ - echo update \$FN;\ - fi;\ - else mv \$TMP \$FN;\ - echo create \$FN;\ - fi" -echo 'TMP=.uf$$' -echo 'FN=$TMP' -echo 'cat >$TMP <<\!EOF!' -sed -n '/^!File:/,${ -/^$/d -/^!File:[ ]*\(.*\)$/s@@!EOF!\ -'"$IFCOMMAND"'\ -FN=\1\ -cat >$TMP <<\\!EOF!@ -p -}' $1 -echo '!EOF!' -echo $IFCOMMAND -) | eval "$(cat)" diff --git a/lang/cem/cpp.ansi/options.c b/lang/cem/cpp.ansi/options.c index fb16ef8fb..21d1e2212 100644 --- a/lang/cem/cpp.ansi/options.c +++ b/lang/cem/cpp.ansi/options.c @@ -8,7 +8,7 @@ #include #include #include "alloc.h" -#include "idfsize.h" +#include "parameters.h" #include "class.h" #include "macro.h" #include "idf.h" diff --git a/lang/cem/cpp.ansi/Parameters b/lang/cem/cpp.ansi/parameters.h similarity index 72% rename from lang/cem/cpp.ansi/Parameters rename to lang/cem/cpp.ansi/parameters.h index 091744391..37bdebe12 100644 --- a/lang/cem/cpp.ansi/Parameters +++ b/lang/cem/cpp.ansi/parameters.h @@ -1,72 +1,67 @@ -!File: pathlength.h +#ifndef PARAMETERS_H +#define PARAMETERS_H + #define PATHLENGTH 1024 /* max. length of path to file */ -!File: errout.h #define ERROUT STDERR /* file pointer for writing messages */ #define MAXERR_LINE 5 /* maximum number of error messages given on the same input line. */ -!File: idfsize.h #define IDFSIZE 64 /* maximum significant length of an identifier */ -!File: numsize.h #define NUMSIZE 256 /* maximum length of a numeric constant */ -!File: nparams.h #define NPARAMS 32 /* maximum number of parameters of macros */ #define STDC_NPARAMS 31 /* ANSI limit on number of parameters */ -!File: ifdepth.h #define IFDEPTH 256 /* maximum number of nested if-constructions */ -!File: macbuf.h #define LAPBUF 128 /* initial size of macro replacement buffer */ #define ARGBUF 128 /* initial size of macro parameter buffer(s) */ -!File: strsize.h #define ISTRSIZE 16 /* minimum number of bytes allocated for storing a string */ -!File: botch_free.h -/*#define BOTCH_FREE 1 /* botch freed memory, as a check */ +#if 0 +#define BOTCH_FREE 1 /* botch freed memory, as a check */ +#endif -!File: debug.h -/*#define DEBUG 1 /* perform various self-tests */ +#if 0 +#define DEBUG 1 /* perform various self-tests */ +#endif #define NDEBUG 1 /* disable assertions */ -!File: parbufsize.h #define PARBUFSIZE 1024 -!File: textsize.h #define ITEXTSIZE 16 /* 1st piece of memory for repl. text */ -!File: inputtype.h -/*#define INP_READ_IN_ONE 1 /* read input file in one. */ +#if 0 +#define INP_READ_IN_ONE 1 /* read input file in one. */ /* If defined, we cannot read from a pipe */ +#endif -!File: obufsize.h #define OBUFSIZE 8192 /* output buffer size */ -!File: dobits.h #define DOBITS 1 /* use trick to reduce symboltable accesses */ -!File: ln_prefix.h #define LINE_PREFIX "#" /* prefix for generated line directives, either "#" or "#line" */ +#endif + diff --git a/lang/cem/cpp.ansi/pmfile b/lang/cem/cpp.ansi/pmfile deleted file mode 100644 index 2fb98fa8a..000000000 --- a/lang/cem/cpp.ansi/pmfile +++ /dev/null @@ -1,132 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/cpp.ansi/" - -local extract_parameters = simple { - outputs = { - "%U%/pathlength.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/nparams.h", - "%U%/ifdepth.h", - "%U%/macbuf.h", - "%U%/strsize.h", - "%U%/botch_free.h", - "%U%/debug.h", - "%U%/parbufsize.h", - "%U%/textsize.h", - "%U%/inputtype.h", - "%U%/obufsize.h", - "%U%/dobits.h", - "%U%/ln_prefix.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."Parameters") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."expression.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/replace.h"}, (d.."replace.str") }, - allocd_header { outputs = {"%U%/macro.h"}, (d.."macro.str") }, - lpars - } -} - -tool_cpp_ansi = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."ch3bin.c"), - cfile_with_headers (d.."ch3mon.c"), - cfile_with_headers (d.."domacro.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."init.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."preprocess.c"), - cfile_with_headers (d.."replace.c"), - cfile_with_headers (d.."skip.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."expr.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."macro.str"), - file (d.."replace.str"), - } - }, - - lib_input, - lib_assert, - lib_alloc, - lib_print, - lib_system, - lib_string, - - outputs = {"%U%/cpp.ansi"}, - install = { - pm.install( BINDIR..PLATDEP.."/cpp.ansi"), - pm.install(d.."ncpp.6", BINDIR.."/man/man6/cpp.ansi.6"), - } -} diff --git a/lang/cem/cpp.ansi/preprocess.c b/lang/cem/cpp.ansi/preprocess.c index 72fa647e9..7c3840d80 100644 --- a/lang/cem/cpp.ansi/preprocess.c +++ b/lang/cem/cpp.ansi/preprocess.c @@ -10,16 +10,13 @@ #include #include #include "input.h" -#include "obufsize.h" +#include "parameters.h" #include "arith.h" #include "LLlex.h" #include "class.h" #include "macro.h" #include "idf.h" -#include "idfsize.h" #include "bits.h" -#include "ln_prefix.h" -#include "textsize.h" char _obuf[OBUFSIZE]; #ifdef DOBITS diff --git a/lang/cem/cpp.ansi/replace.c b/lang/cem/cpp.ansi/replace.c index 94bb22f3a..255902f68 100644 --- a/lang/cem/cpp.ansi/replace.c +++ b/lang/cem/cpp.ansi/replace.c @@ -9,11 +9,7 @@ #include #include -#include "pathlength.h" -#include "strsize.h" -#include "nparams.h" -#include "idfsize.h" -#include "numsize.h" +#include "parameters.h" #include "alloc.h" #include "idf.h" #include "input.h" @@ -21,9 +17,7 @@ #include "arith.h" #include "LLlex.h" #include "class.h" -#include "debug.h" #include "assert.h" -#include "macbuf.h" #include "replace.h" extern char *GetIdentifier(); diff --git a/lang/cem/ctest/.distr b/lang/cem/ctest/.distr deleted file mode 100644 index 4d16951b4..000000000 --- a/lang/cem/ctest/.distr +++ /dev/null @@ -1,24 +0,0 @@ -READ_ME -Out2.std -Out2.nf.std -Out4.std -Out4.nf.std -ctconv -ctdecl -ctdivers -cterr -ctest1 -ctest2 -ctest3 -ctest5 -ctgen -ctill -ctinit -ctmargt -ctprof -ctstruct -ctsys -ctsetjmp -local.h -makefile.std -run diff --git a/lang/cem/ctest/ctconv/.distr b/lang/cem/ctest/ctconv/.distr deleted file mode 100644 index 27a2e123d..000000000 --- a/lang/cem/ctest/ctconv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -conv.c -conv.cem.g -run diff --git a/lang/cem/ctest/ctdecl/.distr b/lang/cem/ctest/ctdecl/.distr deleted file mode 100644 index 91583322f..000000000 --- a/lang/cem/ctest/ctdecl/.distr +++ /dev/null @@ -1,3 +0,0 @@ -decl.c -decl.cem.g -run diff --git a/lang/cem/ctest/ctdivers/.distr b/lang/cem/ctest/ctdivers/.distr deleted file mode 100644 index fd657769c..000000000 --- a/lang/cem/ctest/ctdivers/.distr +++ /dev/null @@ -1,3 +0,0 @@ -ops.c -ops.cem.g -run diff --git a/lang/cem/ctest/cterr/.distr b/lang/cem/ctest/cterr/.distr deleted file mode 100644 index e70e0e390..000000000 --- a/lang/cem/ctest/cterr/.distr +++ /dev/null @@ -1,3 +0,0 @@ -bugs.c -bugs.cem.g -run diff --git a/lang/cem/ctest/ctest1/.distr b/lang/cem/ctest/ctest1/.distr deleted file mode 100644 index bd848c069..000000000 --- a/lang/cem/ctest/ctest1/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -test.c -test.cem.g diff --git a/lang/cem/ctest/ctest2/.distr b/lang/cem/ctest/ctest2/.distr deleted file mode 100644 index 4bfd3f775..000000000 --- a/lang/cem/ctest/ctest2/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -t7.c -t7.cem.g diff --git a/lang/cem/ctest/ctest3/.distr b/lang/cem/ctest/ctest3/.distr deleted file mode 100644 index 116b88196..000000000 --- a/lang/cem/ctest/ctest3/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -test2.c -test2.cem.g diff --git a/lang/cem/ctest/ctest5/.distr b/lang/cem/ctest/ctest5/.distr deleted file mode 100644 index d9c45d565..000000000 --- a/lang/cem/ctest/ctest5/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -test1.c -test1.cem.g diff --git a/lang/cem/ctest/ctgen/.distr b/lang/cem/ctest/ctgen/.distr deleted file mode 100644 index 224da4cb7..000000000 --- a/lang/cem/ctest/ctgen/.distr +++ /dev/null @@ -1,37 +0,0 @@ -OPS -bf.cem.g -bf.sed -bfu.cem.g -bfu.sed -cel.cem.g -cel.sed -clu.cem.g -clu.sed -ec.cem.g -ec.sed -ef.cem.g -ef.sed -ei.cem.g -ei.sed -el.cem.g -el.sed -eu.cem.g -eu.sed -id.cem.g -id.sed -lc.cem.g -lc.sed -ld.cem.g -ld.sed -lf.cem.g -lf.sed -li.cem.g -li.sed -ll.cem.g -ll.sed -lu.cem.g -lu.sed -makefile -mkc -run -run1 diff --git a/lang/cem/ctest/ctill/.distr b/lang/cem/ctest/ctill/.distr deleted file mode 100644 index ee4a5b9eb..000000000 --- a/lang/cem/ctest/ctill/.distr +++ /dev/null @@ -1,3 +0,0 @@ -noarg.c -noarg.cem.g -run diff --git a/lang/cem/ctest/ctinit/.distr b/lang/cem/ctest/ctinit/.distr deleted file mode 100644 index 5b5a7cb78..000000000 --- a/lang/cem/ctest/ctinit/.distr +++ /dev/null @@ -1,3 +0,0 @@ -init.c -init.cem.g -run diff --git a/lang/cem/ctest/ctmargt/.distr b/lang/cem/ctest/ctmargt/.distr deleted file mode 100644 index 7565930b0..000000000 --- a/lang/cem/ctest/ctmargt/.distr +++ /dev/null @@ -1,3 +0,0 @@ -margt.c -margt.cem.g -run diff --git a/lang/cem/ctest/ctprof/.distr b/lang/cem/ctest/ctprof/.distr deleted file mode 100644 index da82c143d..000000000 --- a/lang/cem/ctest/ctprof/.distr +++ /dev/null @@ -1,5 +0,0 @@ -makefile -procentry.c -run -tp.c -tp.cem.g diff --git a/lang/cem/ctest/ctsetjmp/.distr b/lang/cem/ctest/ctsetjmp/.distr deleted file mode 100644 index 4c0526736..000000000 --- a/lang/cem/ctest/ctsetjmp/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -stjmp.c -stjmp.cem.g diff --git a/lang/cem/ctest/ctstruct/.distr b/lang/cem/ctest/ctstruct/.distr deleted file mode 100644 index 3f25919f1..000000000 --- a/lang/cem/ctest/ctstruct/.distr +++ /dev/null @@ -1,3 +0,0 @@ -run -str.c -str.cem.g diff --git a/lang/cem/ctest/ctsys/.distr b/lang/cem/ctest/ctsys/.distr deleted file mode 100644 index ca4fdc76a..000000000 --- a/lang/cem/ctest/ctsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -run -signal.c -tfork.c -tfork.cem.g diff --git a/lang/cem/libcc.ansi/.distr b/lang/cem/libcc.ansi/.distr deleted file mode 100644 index 65f515e93..000000000 --- a/lang/cem/libcc.ansi/.distr +++ /dev/null @@ -1,15 +0,0 @@ -pmfile -head_ac.e -assert -ctype -errno -headers -locale -math -misc -setjmp -signal -stdio -stdlib -string -time diff --git a/lang/cem/libcc.ansi/assert/.distr b/lang/cem/libcc.ansi/assert/.distr deleted file mode 100644 index 87515cc41..000000000 --- a/lang/cem/libcc.ansi/assert/.distr +++ /dev/null @@ -1 +0,0 @@ -assert.c diff --git a/lang/cem/libcc.ansi/build.lua b/lang/cem/libcc.ansi/build.lua new file mode 100644 index 000000000..3ca95b629 --- /dev/null +++ b/lang/cem/libcc.ansi/build.lua @@ -0,0 +1,79 @@ +include("plat/build.lua") + +tabgen { + name = "ctype_tab", + srcs = { "./ctype/char.tab" } +} + +normalrule { + name = "ctype_files", + ins = { "./ctype/genfiles" }, + outleaves = { + "isalnum.c", + "isalpha.c", + "isascii.c", + "iscntrl.c", + "isdigit.c", + "isgraph.c", + "islower.c", + "isprint.c", + "ispunct.c", + "isspace.c", + "isupper.c", + "isxdigit.c", + }, + commands = { + "sh %{ins[1]} %{dir}" + } +} + +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "+ctype_files", + "+ctype_tab", + "./ctype/*.c", + "./errno/*.c", + "./locale/*.c", + "./malloc/*.c", + "./math/*.c", + "./math/*.e", + "./misc/environ.c", -- don't build everything here as it's all obsolete + "./setjmp/*.c", + "./setjmp/*.e", + "./signal/*.c", + "./assert/*.c", + "./stdio/*.c", + "./stdlib/*.c", + "./string/*.c", + "./time/*.c", + + }, + hdrs = {}, -- must be empty + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/"..plat.."/include+headers", + }, + vars = { plat = plat } + } + + ackfile { + name = "crt_"..plat, + srcs = { "./head_ac.e" }, + vars = { plat = plat }, + deps = { + "h+emheaders" + } + } + + installable { + name = "pkg_"..plat, + map = { + "lang/cem/libcc.ansi/headers+pkg", + ["$(PLATIND)/"..plat.."/c-ansi.o"] = "+crt_"..plat, + ["$(PLATIND)/"..plat.."/libc.a"] = "+lib_"..plat, + } + } +end + diff --git a/lang/cem/libcc.ansi/ctype/.distr b/lang/cem/libcc.ansi/ctype/.distr deleted file mode 100644 index 63a07fcf4..000000000 --- a/lang/cem/libcc.ansi/ctype/.distr +++ /dev/null @@ -1,4 +0,0 @@ -toupper.c -tolower.c -char.tab -genfiles diff --git a/lang/cem/libcc.ansi/ctype/genfiles b/lang/cem/libcc.ansi/ctype/genfiles index 061a214bc..96121a3cd 100644 --- a/lang/cem/libcc.ansi/ctype/genfiles +++ b/lang/cem/libcc.ansi/ctype/genfiles @@ -3,7 +3,7 @@ for i in isalnum isalpha iscntrl isdigit isgraph islower isprint \ ispunct isspace isupper isxdigit isascii do -sed "s/xxxx/$i/" > $i.c << 'EOF' +sed "s/xxxx/$i/" > $1/$i.c << 'EOF' #include int (xxxx)(int c) { diff --git a/lang/cem/libcc.ansi/errno/.distr b/lang/cem/libcc.ansi/errno/.distr deleted file mode 100644 index fd69e9793..000000000 --- a/lang/cem/libcc.ansi/errno/.distr +++ /dev/null @@ -1 +0,0 @@ -errlist.c diff --git a/lang/cem/libcc.ansi/headers/.distr b/lang/cem/libcc.ansi/headers/.distr deleted file mode 100644 index cf35cec17..000000000 --- a/lang/cem/libcc.ansi/headers/.distr +++ /dev/null @@ -1,22 +0,0 @@ -sys/time.h -sys/ioctl.h -assert.h -ctype.h -errno.h -float.h -limits.h -math.h -setjmp.h -signal.h -stdarg.h -stddef.h -stdint.h -stdio.h -stdlib.h -string.h -time.h -iso646.h -stdbool.h -fcntl.h -tgmath.h -locale.h diff --git a/lang/cem/libcc.ansi/headers/build.lua b/lang/cem/libcc.ansi/headers/build.lua new file mode 100644 index 000000000..601d383ec --- /dev/null +++ b/lang/cem/libcc.ansi/headers/build.lua @@ -0,0 +1,26 @@ +include("plat/build.lua") + +local headers = {} +local installmap = {} + +local function addheader(dir, list) + for _, f in ipairs(list) do + local b = basename(f) + headers[dir..b] = f + installmap[concatpath("$(PLATIND)/include/ansi/", dir, b)] = f + end +end + +addheader("", filenamesof("./*.h")) +addheader("sys/", filenamesof("./sys/*.h")) + +acklibrary { + name = "headers", + hdrs = headers +} + +installable { + name = "pkg", + map = installmap +} + diff --git a/lang/cem/libcc.ansi/headers/malloc.h b/lang/cem/libcc.ansi/headers/malloc.h new file mode 100644 index 000000000..64a6de16c --- /dev/null +++ b/lang/cem/libcc.ansi/headers/malloc.h @@ -0,0 +1,66 @@ +/* + * stdlib.h - standard library + * + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#ifndef _STDLIB_H +#define _STDLIB_H + +#include + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 +#define RAND_MAX 32767 +#define MB_CUR_MAX sizeof(wchar_t) + +typedef struct { int quot, rem; } div_t; +typedef struct { long quot, rem; } ldiv_t; + +extern double atof(const char *_nptr); +extern int atoi(const char *_nptr); +extern long atol(const char *_nptr); +extern double strtod(const char *_nptr, char **_endptr); +extern long strtol(const char *_nptr, char **_endptr, int _base); +extern unsigned long strtoul(const char *_nptr, char **_endptr, int _base); +extern int rand(void); +extern void srand(unsigned int _seed); +extern void* calloc(size_t _nmemb, size_t _size); +extern void free(void *_ptr); +extern void* malloc(size_t _size); +extern void* realloc(void *_ptr, size_t _size); +extern void abort(void); +extern int atexit(void (*_func)(void)); +extern void exit(int _status); +extern void _Exit(int _status); +extern char* getenv(const char *_name); +extern int setenv(const char *_name, const char *_value, int _overwrite); +extern int unsetenv(const char *_name); +extern int putenv(char *_string); +extern int system(const char *_string); +extern void* bsearch(const void *_key, const void *_base, + size_t _nmemb, size_t _size, + int (*_compar)(const void *, const void *)); +extern void qsort(void *_base, size_t _nmemb, size_t _size, + int (*_compar)(const void *, const void *)); +extern int abs(int _j); +extern div_t div(int _numer, int _denom); +extern long labs(long _j); +extern ldiv_t ldiv(long _numer, long _denom); +extern int mblen(const char *_s, size_t _n); +extern int mbtowc(wchar_t *_pwc, const char *_s, size_t _n); +extern int wctomb(char *_s, wchar_t _wchar); +extern size_t mbstowcs(wchar_t *_pwcs, const char *_s, size_t _n); +extern size_t wcstombs(char *_s, const wchar_t *_pwcs, size_t _n); + +/* Extensions (not part of the standard) */ + +#define atof(n) strtod(n, (char **)NULL) +#define atoi(n) ((int)strtol(n, (char **)NULL, 10)) +#define atol(n) strtol(n, (char **)NULL, 10) +#define atoll(n) strtoll(n, (char **)NULL, 10) +#define mblen(s, n) mbtowc((wchar_t *)0, s, n) + +#endif diff --git a/lang/cem/libcc.ansi/headers/stdint.h b/lang/cem/libcc.ansi/headers/stdint.h index 86fd04815..ce9cf3e38 100644 --- a/lang/cem/libcc.ansi/headers/stdint.h +++ b/lang/cem/libcc.ansi/headers/stdint.h @@ -26,7 +26,7 @@ typedef unsigned short uint16_t; #if _EM_WSIZE == 4 typedef signed int int32_t; -typedef unsigned short uint32_t; +typedef unsigned int uint32_t; #else typedef signed long int32_t; typedef unsigned long uint32_t; diff --git a/lang/cem/libcc.ansi/headers/stdio.h b/lang/cem/libcc.ansi/headers/stdio.h index 4c5a42a08..52f286f20 100644 --- a/lang/cem/libcc.ansi/headers/stdio.h +++ b/lang/cem/libcc.ansi/headers/stdio.h @@ -72,10 +72,12 @@ extern int fscanf(FILE *_stream, const char *_format, ...); extern int printf(const char *_format, ...); extern int scanf(const char *_format, ...); extern int sprintf(char *_s, const char *_format, ...); +extern int snprintf(char *_s, size_t _len, const char *_format, ...); extern int sscanf(const char *_s, const char *_format, ...); extern int vfprintf(FILE *_stream, const char *_format, char *_arg); extern int vprintf(const char *_format, char *_arg); extern int vsprintf(char *_s, const char *_format, char *_arg); +extern int vsnprintf(char *_s, size_t _len, const char *_format, char *_arg); extern int fgetc(FILE *_stream); extern char *fgets(char *_s, int _n, FILE *_stream); extern int fputc(int _c, FILE *_stream); diff --git a/lang/cem/libcc.ansi/headers/stdlib.h b/lang/cem/libcc.ansi/headers/stdlib.h index c14db91a8..64a6de16c 100644 --- a/lang/cem/libcc.ansi/headers/stdlib.h +++ b/lang/cem/libcc.ansi/headers/stdlib.h @@ -36,6 +36,9 @@ extern int atexit(void (*_func)(void)); extern void exit(int _status); extern void _Exit(int _status); extern char* getenv(const char *_name); +extern int setenv(const char *_name, const char *_value, int _overwrite); +extern int unsetenv(const char *_name); +extern int putenv(char *_string); extern int system(const char *_string); extern void* bsearch(const void *_key, const void *_base, size_t _nmemb, size_t _size, diff --git a/lang/cem/libcc.ansi/headers/string.h b/lang/cem/libcc.ansi/headers/string.h index b9d50617b..eef924f74 100644 --- a/lang/cem/libcc.ansi/headers/string.h +++ b/lang/cem/libcc.ansi/headers/string.h @@ -33,5 +33,8 @@ extern char *strtok(char *_s1, const char *_s2); extern void *memset(void *_s, int _c, size_t _n); extern char *strerror(int _errnum); extern size_t strlen(const char *_s); +extern char *strdup(const char *_s); + +#define bcopy(s, d, z) memmove(d, s, z) #endif diff --git a/lang/cem/libcc.ansi/headers/sys/.distr b/lang/cem/libcc.ansi/headers/sys/.distr deleted file mode 100644 index c2d82be22..000000000 --- a/lang/cem/libcc.ansi/headers/sys/.distr +++ /dev/null @@ -1,2 +0,0 @@ -dirent.h -errno.h diff --git a/lang/cem/libcc.ansi/locale/.distr b/lang/cem/libcc.ansi/locale/.distr deleted file mode 100644 index 6ec7d31e6..000000000 --- a/lang/cem/libcc.ansi/locale/.distr +++ /dev/null @@ -1,2 +0,0 @@ -localeconv.c -setlocale.c diff --git a/lang/cem/libcc.ansi/malloc/malloc.c b/lang/cem/libcc.ansi/malloc/malloc.c new file mode 100644 index 000000000..7eaaacaba --- /dev/null +++ b/lang/cem/libcc.ansi/malloc/malloc.c @@ -0,0 +1,151 @@ +#include +#include +#include +#include "malloc.h" + +block_t __mem_root = {&__mem_root, 0}; +block_t* __mem_freelist = &__mem_root; + +/* Pulls more memory from the system. */ + +static block_t* brkmore(size_t nb) +{ + uintptr_t bytes; + block_t* p; + + if (nb < BRKSIZE) + nb = BRKSIZE; + bytes = nb * sizeof(block_t); + + /* Danger, will robinson! sbrk's parameter is *signed*... but malloc() takes a + * size_t. */ + + if (bytes > INTPTR_MAX) + return NULL; + + p = sbrk(bytes); + if (p == (block_t*)-1) + return NULL; + + /* Add it to the free list by pretending it's a used block and freeing it. */ + + p->size = nb; + free(p + 1); + return __mem_freelist; +} + +void* malloc(size_t size) +{ + block_t* p; + block_t* prev; + size_t nblocks; + + /* Add on space for the header; make sure we allocate a round number + * of blocks; avoid overflow. */ + nblocks = BLOCKCOUNT(size); + if (nblocks < size) + return NULL; + nblocks /= sizeof(block_t); + + prev = __mem_freelist; + p = prev->next; + for (;;) + { + if (p->size == nblocks) + { + /* We found a hole of exactly the right size. Unlink and return it. + * The size field is already set. */ + prev->next = p->next; + __mem_freelist = prev; + return (void*) (p+1); + } + else if (p->size > nblocks) + { + /* We found a hole bigger than we need. We shrink the hole and return + * what's left. */ + p->size -= nblocks; + p += p->size; /* p now points at our new block */ + p->size = nblocks; + __mem_freelist = prev; + return (void*) (p+1); + } + + if (p == __mem_freelist) + { + /* Uh-oh --- we've gone right round the ring and haven't found + * anything. Get more memory from the system and keep going. */ + p = brkmore(nblocks); + if (!p) + return NULL; + } + + prev = p; + p = p->next; + } +} + +void free(void *ptr) +{ + block_t* h = BLOCKOF(ptr); + block_t* p; + + if (!ptr) + return; + + /* __mem_freelist points into an ordered ring of free blocks. First, + * we run around the ring until we find the last block before this one. + */ + + p = __mem_freelist; + for (;;) + { + /* Is h between p and the block after p? If so, h needs to be inserted + * after p, so stop here. */ + if ((p < h) && (h < p->next)) + break; + + /* Is p the last block before the end of the address space? */ + if (p >= p->next) + { + /* Is h after p? (That is, will it become the new last block?) */ + if (p < h) + break; + + /* Is h going to become the new *first* block? */ + if (h < p->next) + break; + } + + p = p->next; + } + + /* If we can, merge the next block onto the end of h. */ + + if ((h + h->size) == p->next) + { + h->size += p->next->size; + h->next = p->next->next; + } + else + { + /* Otherwise, insert h before p->next. */ + h->next = p->next; + } + + /* Now try to merge h onto the end of p. */ + + if ((p + p->size) == h) + { + p->size += h->size; + p->next = h->next; + } + else + { + /* Okay, we couldn't do the merge. Fix up the linked list. */ + p->next = h; + } + + /* ...and update the ring pointer. */ + __mem_freelist = p; +} + diff --git a/lang/cem/libcc.ansi/malloc/malloc.h b/lang/cem/libcc.ansi/malloc/malloc.h new file mode 100644 index 000000000..d70e92ae0 --- /dev/null +++ b/lang/cem/libcc.ansi/malloc/malloc.h @@ -0,0 +1,25 @@ +/* This is an ANSI C version of the classic K&R memory allocator, with + * some improvements stolen from the Fuzix libc. + */ + +#ifndef MALLOC_H +#define MALLOC_H + +typedef struct block_s { + struct block_s* next; + size_t size; /* in sizeof(block_t) units */ +} block_t; + +extern block_t __mem_root; +extern block_t* __mem_first_free; + +#define BLOCKOF(p) (((block_t*)(p)) - 1) + +/* Smallest amount to allocate from brk */ +#define BRKSIZE (512 / sizeof(block_t)) + +#define BLOCKCOUNT(bytes) \ + (bytes + sizeof(block_t) + sizeof(block_t) - 1) + +#endif + diff --git a/lang/cem/libcc.ansi/malloc/realloc.c b/lang/cem/libcc.ansi/malloc/realloc.c new file mode 100644 index 000000000..7e6dfbb70 --- /dev/null +++ b/lang/cem/libcc.ansi/malloc/realloc.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include "malloc.h" + +void* realloc(void *ptr, size_t size) +{ + block_t* h; + size_t nblocks; + void* newptr; + + if (size == 0) + { + free(ptr); + return NULL; + } + + if (!ptr) + return malloc(size); + + h = BLOCKOF(ptr); + + nblocks = BLOCKCOUNT(size); + /* Overflow check. */ + if (nblocks < size) + return NULL; + + /* Shrinking the block? Don't bother doing anything (it's never worth it). */ + if (nblocks <= h->size) + return ptr; + + /* Allocate and copy. */ + + newptr = malloc(size); + if (!newptr) + return NULL; + memcpy(newptr, ptr, h->size * sizeof(block_t)); + free(ptr); + return newptr; +} diff --git a/lang/cem/libcc.ansi/math/.distr b/lang/cem/libcc.ansi/math/.distr deleted file mode 100644 index 39e542930..000000000 --- a/lang/cem/libcc.ansi/math/.distr +++ /dev/null @@ -1,22 +0,0 @@ -asin.c -atan.c -atan2.c -ceil.c -exp.c -fabs.c -floor.c -fmod.c -frexp.e -hugeval.c -ldexp.c -localmath.h -log.c -log10.c -modf.e -pow.c -sin.c -sinh.c -sqrt.c -tan.c -tanh.c -isnan.c diff --git a/lang/cem/libcc.ansi/misc/.distr b/lang/cem/libcc.ansi/misc/.distr deleted file mode 100644 index db3c72199..000000000 --- a/lang/cem/libcc.ansi/misc/.distr +++ /dev/null @@ -1 +0,0 @@ -environ.c diff --git a/lang/cem/libcc.ansi/misc/putenv.c b/lang/cem/libcc.ansi/misc/putenv.c index dc448fef2..a1f94aba4 100644 --- a/lang/cem/libcc.ansi/misc/putenv.c +++ b/lang/cem/libcc.ansi/misc/putenv.c @@ -10,18 +10,17 @@ #define ENTRY_INC 10 #define rounded(x) (((x / ENTRY_INC) + 1) * ENTRY_INC) -extern const char **_penvp; -extern const char **environ; /* environ is a shadow name for _penvp */ +extern char **environ; int putenv(char *name) { - register const char **v = _penvp; + register char **v = environ; register char *r; static int size = 0; /* When size != 0, it contains the number of entries in the * table (including the final NULL pointer). This means that the - * last non-null entry is _penvp[size - 2]. + * last non-null entry is environ[size - 2]. */ if (!name) return 0; @@ -48,11 +47,11 @@ putenv(char *name) } } *r = '='; - v = _penvp; + v = environ; } if (!size) { - register const char **p; + register char **p; register int i = 0; if (v) @@ -62,18 +61,17 @@ putenv(char *name) if (!(v = malloc(rounded(i) * sizeof(char **)))) return 1; size = i; - p = _penvp; - _penvp = v; + p = environ; + environ = v; while (*v++ = *p++); /* copy the environment */ - v = _penvp; + v = environ; } else if (!(size % ENTRY_INC)) { - if (!(v = realloc(_penvp, rounded(size) * sizeof(char **)))) + if (!(v = realloc(environ, rounded(size) * sizeof(char **)))) return 1; - _penvp = v; + environ = v; } v[size - 1] = name; v[size] = NULL; size++; - environ = _penvp; return 0; } diff --git a/lang/cem/libcc.ansi/pmfile b/lang/cem/libcc.ansi/pmfile deleted file mode 100644 index 21ac99219..000000000 --- a/lang/cem/libcc.ansi/pmfile +++ /dev/null @@ -1,300 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc.ansi/" - -local crt = ackfile { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - file (d.."head_ac.e"), - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/c-ansi.o") -} - -local libc = acklibrary { - ACKBUILDFLAGS = {PARENT, "-ansi"}, - ACKINCLUDES = {PARENT, "%ROOTDIR%h", d.."headers"}, - outputs = {"%U%/libc.a"}, - - -- assert - - ackfile (d.."assert/assert.c"), - - -- ctype - - ackfile (d.."ctype/tolower.c"), - ackfile (d.."ctype/toupper.c"), - ackfile { - tabgen (d.."ctype/char.tab") - }, - foreach { - rule = ackfile, - simple { - outputs = { - "%U%/isalnum.c", - "%U%/isalpha.c", - "%U%/iscntrl.c", - "%U%/isdigit.c", - "%U%/isgraph.c", - "%U%/islower.c", - "%U%/isprint.c", - "%U%/ispunct.c", - "%U%/isspace.c", - "%U%/isupper.c", - "%U%/isxdigit.c", - "%U%/isascii.c", - }, - command = { - "cd %out[1]:dirname% && sh %in[1]%" - }, - - file (d.."ctype/genfiles") - } - }, - - -- errno - - ackfile (d.."errno/errlist.c"), - - -- locale - - ackfile (d.."locale/localeconv.c"), - ackfile (d.."locale/setlocale.c"), - - -- math - - ackfile (d.."math/asin.c"), - ackfile (d.."math/atan2.c"), - ackfile (d.."math/atan.c"), - ackfile (d.."math/ceil.c"), - ackfile (d.."math/fabs.c"), - ackfile (d.."math/pow.c"), - ackfile (d.."math/log10.c"), - ackfile (d.."math/log.c"), - ackfile (d.."math/sin.c"), - ackfile (d.."math/sinh.c"), - ackfile (d.."math/sqrt.c"), - ackfile (d.."math/tan.c"), - ackfile (d.."math/tanh.c"), - ackfile (d.."math/exp.c"), - ackfile (d.."math/ldexp.c"), - ackfile (d.."math/fmod.c"), - ackfile (d.."math/floor.c"), - ackfile (d.."math/hugeval.c"), - ackfile (d.."math/frexp.e"), - ackfile (d.."math/modf.e"), - ackfile (d.."math/isnan.c"), - - -- misc - - ackfile (d.."misc/environ.c"), - --[[ - ackfile (d.."misc/getgrent.c"), - ackfile (d.."misc/getopt.c"), - ackfile (d.."misc/getpass.c"), - ackfile (d.."misc/getpw.c"), - ackfile (d.."misc/getw.c"), - ackfile (d.."misc/putw.c"), - ackfile (d.."misc/putenv.c"), - ackfile (d.."misc/environ.c"), - ackfile (d.."misc/popen.c"), - ackfile (d.."misc/sleep.c"), - ackfile (d.."misc/termcap.c"), - ackfile (d.."misc/fdopen.c"), - ackfile (d.."misc/closedir.c"), - group { - ACKDEFINES = {PARENT, "UFS"}, - ackfile (d.."misc/getdents.c") - }, - ackfile (d.."misc/opendir.c"), - ackfile (d.."misc/readdir.c"), - ackfile (d.."misc/rewinddir.c"), - ackfile (d.."misc/seekdir.c"), - ackfile (d.."misc/telldir.c"), - ackfile (d.."misc/isatty.c"), - ackfile (d.."misc/mktemp.c"), - ackfile (d.."misc/hypot.c"), - --]] - - -- setjmp - - ackfile (d.."setjmp/setjmp.e"), - --ackfile (d.."setjmp/sigmisc.c"), - - -- signal - - ackfile (d.."signal/raise.c"), - - -- stdio - - ackfile (d.."stdio/tmpfile.c"), - ackfile (d.."stdio/tmpnam.c"), --- ackfile (d.."stdio/rename.c"), --- ackfile (d.."stdio/remove.c"), - ackfile (d.."stdio/fopen.c"), - ackfile (d.."stdio/freopen.c"), - ackfile (d.."stdio/setbuf.c"), - ackfile (d.."stdio/setvbuf.c"), - ackfile (d.."stdio/perror.c"), - ackfile (d.."stdio/fprintf.c"), - ackfile (d.."stdio/printf.c"), - ackfile (d.."stdio/sprintf.c"), - ackfile (d.."stdio/vfprintf.c"), - ackfile (d.."stdio/vprintf.c"), - ackfile (d.."stdio/vsprintf.c"), - ackfile (d.."stdio/doprnt.c"), - ackfile (d.."stdio/icompute.c"), - ackfile (d.."stdio/fscanf.c"), - ackfile (d.."stdio/scanf.c"), - ackfile (d.."stdio/sscanf.c"), - ackfile (d.."stdio/doscan.c"), - ackfile (d.."stdio/fgetc.c"), - ackfile (d.."stdio/fgets.c"), - ackfile (d.."stdio/getc.c"), - ackfile (d.."stdio/getchar.c"), - ackfile (d.."stdio/gets.c"), - ackfile (d.."stdio/putc.c"), - ackfile (d.."stdio/putchar.c"), - ackfile (d.."stdio/fputc.c"), - ackfile (d.."stdio/puts.c"), - ackfile (d.."stdio/fputs.c"), - ackfile (d.."stdio/ungetc.c"), - ackfile (d.."stdio/fread.c"), - ackfile (d.."stdio/fwrite.c"), - ackfile (d.."stdio/fgetpos.c"), - ackfile (d.."stdio/fsetpos.c"), - ackfile (d.."stdio/rewind.c"), - ackfile (d.."stdio/fseek.c"), - ackfile (d.."stdio/ftell.c"), - ackfile (d.."stdio/clearerr.c"), - ackfile (d.."stdio/feof.c"), - ackfile (d.."stdio/ferror.c"), - ackfile (d.."stdio/fileno.c"), - ackfile (d.."stdio/fltpr.c"), - ackfile (d.."stdio/ecvt.c"), - ackfile (d.."stdio/fillbuf.c"), - ackfile (d.."stdio/fclose.c"), - ackfile (d.."stdio/flushbuf.c"), - ackfile (d.."stdio/fflush.c"), --- ackfile (d.."stdio/isatty.c"), - ackfile (d.."stdio/data.c"), - - -- stdlib - - ackfile (d.."stdlib/abort.c"), - ackfile (d.."stdlib/abs.c"), - ackfile (d.."stdlib/atof.c"), - ackfile (d.."stdlib/atoi.c"), - ackfile (d.."stdlib/atol.c"), - ackfile (d.."stdlib/bsearch.c"), - ackfile (d.."stdlib/div.c"), - ackfile (d.."stdlib/atexit.c"), - ackfile (d.."stdlib/exit.c"), - ackfile (d.."stdlib/getenv.c"), - ackfile (d.."stdlib/labs.c"), - ackfile (d.."stdlib/ldiv.c"), - ackfile (d.."stdlib/mblen.c"), - ackfile (d.."stdlib/mbstowcs.c"), - ackfile (d.."stdlib/mbtowc.c"), - ackfile (d.."stdlib/qsort.c"), - ackfile (d.."stdlib/rand.c"), - ackfile (d.."stdlib/strtod.c"), - ackfile (d.."stdlib/strtol.c"), --- ackfile (d.."stdlib/system.c"), - ackfile (d.."stdlib/wcstombs.c"), - ackfile (d.."stdlib/wctomb.c"), - ackfile (d.."stdlib/ext_comp.c"), - ackfile { - simple { - outputs = {"%U%/malloc.c"}, - command = { - "rm -f %out% && for i in %in[2-]%; do %in[1]% $i >> %out%; done" - }, - file (d.."stdlib/malloc/add_file"), - file (d.."stdlib/malloc/READ_ME"), - file (d.."stdlib/malloc/size_type.h"), - file (d.."stdlib/malloc/param.h"), - file (d.."stdlib/malloc/impl.h"), - file (d.."stdlib/malloc/check.h"), - file (d.."stdlib/malloc/log.h"), - file (d.."stdlib/malloc/phys.h"), - file (d.."stdlib/malloc/mal.c"), - file (d.."stdlib/malloc/log.c"), - file (d.."stdlib/malloc/phys.c"), - file (d.."stdlib/malloc/check.c"), - } - }, - - -- string - - ackfile (d.."string/memchr.c"), - ackfile (d.."string/memcmp.c"), - ackfile (d.."string/memcpy.c"), - ackfile (d.."string/memmove.c"), - ackfile (d.."string/memset.c"), - ackfile (d.."string/strcat.c"), - ackfile (d.."string/strchr.c"), - ackfile (d.."string/strcmp.c"), - ackfile (d.."string/strcoll.c"), - ackfile (d.."string/strcpy.c"), - ackfile (d.."string/strcspn.c"), - ackfile (d.."string/strerror.c"), - ackfile (d.."string/strncat.c"), - ackfile (d.."string/strncpy.c"), - ackfile (d.."string/strrchr.c"), - ackfile (d.."string/strstr.c"), - ackfile (d.."string/strlen.c"), - ackfile (d.."string/strtok.c"), - ackfile (d.."string/strpbrk.c"), - ackfile (d.."string/strspn.c"), - ackfile (d.."string/strncmp.c"), - ackfile (d.."string/strxfrm.c"), - - -- time - - ackfile (d.."time/ctime.c"), - ackfile (d.."time/asctime.c"), - ackfile (d.."time/localtime.c"), - ackfile (d.."time/clock.c"), - ackfile (d.."time/difftime.c"), - ackfile (d.."time/gmtime.c"), - ackfile (d.."time/mktime.c"), - ackfile (d.."time/strftime.c"), - ackfile (d.."time/time.c"), - ackfile (d.."time/tzset.c"), - ackfile (d.."time/misc.c"), - - install = { - pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libc.a") - } -} - -local headers = group { - install = { - pm.install(d.."headers/sys/time.h", "%BINDIR%include/ansi/sys/time.h"), - pm.install(d.."headers/sys/ioctl.h", "%BINDIR%include/ansi/sys/ioctl.h"), - pm.install(d.."headers/assert.h", "%BINDIR%include/ansi/assert.h"), - pm.install(d.."headers/ctype.h", "%BINDIR%include/ansi/ctype.h"), - pm.install(d.."headers/errno.h", "%BINDIR%include/ansi/errno.h"), - pm.install(d.."headers/float.h", "%BINDIR%include/ansi/float.h"), - pm.install(d.."headers/limits.h", "%BINDIR%include/ansi/limits.h"), - pm.install(d.."headers/math.h", "%BINDIR%include/ansi/math.h"), - pm.install(d.."headers/setjmp.h", "%BINDIR%include/ansi/setjmp.h"), - pm.install(d.."headers/signal.h", "%BINDIR%include/ansi/signal.h"), - pm.install(d.."headers/stdarg.h", "%BINDIR%include/ansi/stdarg.h"), - pm.install(d.."headers/stddef.h", "%BINDIR%include/ansi/stddef.h"), - pm.install(d.."headers/stdint.h", "%BINDIR%include/ansi/stdint.h"), - pm.install(d.."headers/stdio.h", "%BINDIR%include/ansi/stdio.h"), - pm.install(d.."headers/stdlib.h", "%BINDIR%include/ansi/stdlib.h"), - pm.install(d.."headers/string.h", "%BINDIR%include/ansi/string.h"), - pm.install(d.."headers/time.h", "%BINDIR%include/ansi/time.h"), - pm.install(d.."headers/iso646.h", "%BINDIR%include/ansi/iso646.h"), - pm.install(d.."headers/stdbool.h", "%BINDIR%include/ansi/stdbool.h"), - pm.install(d.."headers/locale.h", "%BINDIR%include/ansi/locale.h"), - pm.install(d.."headers/tgmath.h", "%BINDIR%include/ansi/tgmath.h"), - } -} - -lang_cem_ansi_runtime = group { - crt, - libc, - headers -} diff --git a/lang/cem/libcc.ansi/setjmp/.distr b/lang/cem/libcc.ansi/setjmp/.distr deleted file mode 100644 index 305ef0b22..000000000 --- a/lang/cem/libcc.ansi/setjmp/.distr +++ /dev/null @@ -1 +0,0 @@ -setjmp.e diff --git a/lang/cem/libcc.ansi/signal/.distr b/lang/cem/libcc.ansi/signal/.distr deleted file mode 100644 index ff77f128d..000000000 --- a/lang/cem/libcc.ansi/signal/.distr +++ /dev/null @@ -1 +0,0 @@ -raise.c diff --git a/lang/cem/libcc.ansi/stdio/.distr b/lang/cem/libcc.ansi/stdio/.distr deleted file mode 100644 index 5ad14e146..000000000 --- a/lang/cem/libcc.ansi/stdio/.distr +++ /dev/null @@ -1,49 +0,0 @@ -clearerr.c -data.c -doprnt.c -doscan.c -ecvt.c -fclose.c -feof.c -ferror.c -fflush.c -fgetc.c -fgetpos.c -fgets.c -fileno.c -fillbuf.c -fltpr.c -flushbuf.c -fopen.c -fprintf.c -fputc.c -fputs.c -fread.c -freopen.c -fscanf.c -fseek.c -fsetpos.c -ftell.c -fwrite.c -getc.c -getchar.c -gets.c -icompute.c -loc_incl.h -perror.c -printf.c -putc.c -putchar.c -puts.c -rewind.c -scanf.c -setbuf.c -setvbuf.c -sprintf.c -sscanf.c -tmpfile.c -tmpnam.c -ungetc.c -vfprintf.c -vprintf.c -vsprintf.c diff --git a/lang/cem/libcc.ansi/stdio/doprnt.c b/lang/cem/libcc.ansi/stdio/doprnt.c index 81714de47..395c45704 100644 --- a/lang/cem/libcc.ansi/stdio/doprnt.c +++ b/lang/cem/libcc.ansi/stdio/doprnt.c @@ -38,6 +38,16 @@ gnum(register const char *f, int *ip, va_list *app) #define set_pointer(flags) /* compilation might continue */ #endif +#define PUTC(c) \ + do { \ + int i = putc(c, stream); \ + if (i == EOF) \ + { \ + if (ferror(stream)) \ + return -1; \ + } \ + } while (0) + /* print an ordinal number */ static char * o_print(va_list *ap, int flags, char *s, char c, int precision, int is_signed) @@ -125,13 +135,10 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) if (c != '%') { #ifdef CPM if (c == '\n') { - if (putc('\r', stream) == EOF) - return nrchars ? -nrchars : -1; - nrchars++; + PUTC('\r'); } #endif - if (putc(c, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(c); nrchars++; continue; } @@ -181,13 +188,11 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) default: #ifdef CPM if (c == '\n') { - if (putc('\r', stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC('\r'); nrchars++; } #endif - if (putc(c, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(c); nrchars++; continue; case 'n': @@ -280,31 +285,26 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) if (between_fill) { if (flags & FL_SIGNEDCONV) { j--; nrchars++; - if (putc(*s1++, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(*s1++); } else { j -= 2; nrchars += 2; - if ((putc(*s1++, stream) == EOF) - || (putc(*s1++, stream) == EOF)) - return nrchars ? -nrchars : -1; - } + PUTC(*s1++); + PUTC(*s1++); + } } do { - if (putc(zfill, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(zfill); } while (--i); } nrchars += j; while (--j >= 0) { - if (putc(*s1++, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(*s1++); } if (i > 0) nrchars += i; while (--i >= 0) - if (putc(zfill, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(zfill); } return nrchars; } diff --git a/lang/cem/libcc.ansi/stdio/rename.c b/lang/cem/libcc.ansi/stdio/rename.c index 08c5ae85d..ff177ccd5 100644 --- a/lang/cem/libcc.ansi/stdio/rename.c +++ b/lang/cem/libcc.ansi/stdio/rename.c @@ -7,6 +7,8 @@ #include #include +/* Disabled, dtrg: rename is a system call these days. */ +#if 0 int _link(const char *name1, const char *name2); int diff --git a/lang/cem/libcc.ansi/stdio/snprintf.c b/lang/cem/libcc.ansi/stdio/snprintf.c new file mode 100644 index 000000000..7d428118c --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/snprintf.c @@ -0,0 +1,31 @@ +/* + * sprintf - print formatted output on an array + */ +/* $Id$ */ + +#include +#include +#include "loc_incl.h" + +int +snprintf(char * s, size_t len, const char *format, ...) +{ + va_list ap; + int retval; + FILE tmp_stream; + + va_start(ap, format); + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = len; + + retval = _doprnt(format, ap, &tmp_stream); + putc('\0',&tmp_stream); + + va_end(ap); + + return retval; +} diff --git a/lang/cem/libcc.ansi/stdio/vsnprintf.c b/lang/cem/libcc.ansi/stdio/vsnprintf.c new file mode 100644 index 000000000..870e23df2 --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/vsnprintf.c @@ -0,0 +1,26 @@ +/* + * vsprintf - print formatted output without ellipsis on an array + */ +/* $Id$ */ + +#include +#include +#include "loc_incl.h" + +int +vsnprintf(char *s, size_t len, const char *format, va_list arg) +{ + int retval; + FILE tmp_stream; + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = len; + + retval = _doprnt(format, arg, &tmp_stream); + putc('\0',&tmp_stream); + + return retval; +} diff --git a/lang/cem/libcc.ansi/stdlib/.distr b/lang/cem/libcc.ansi/stdlib/.distr deleted file mode 100644 index a556b3058..000000000 --- a/lang/cem/libcc.ansi/stdlib/.distr +++ /dev/null @@ -1,25 +0,0 @@ -abort.c -abs.c -atexit.c -atof.c -atoi.c -atol.c -bsearch.c -div.c -exit.c -ext_comp.c -ext_fmt.h -getenv.c -labs.c -ldiv.c -mblen.c -mbstowcs.c -mbtowc.c -qsort.c -rand.c -strtod.c -strtol.c -system.c -wcstombs.c -wctomb.c -malloc diff --git a/lang/cem/libcc.ansi/stdlib/getenv.c b/lang/cem/libcc.ansi/stdlib/getenv.c index 01b887a1d..592e0c05d 100644 --- a/lang/cem/libcc.ansi/stdlib/getenv.c +++ b/lang/cem/libcc.ansi/stdlib/getenv.c @@ -5,23 +5,47 @@ /* $Id$ */ #include -#include +#include -char * -getenv(const char *name) +extern char* _findenv(const char* name, int* offset); + +/* + * getenv(name) -- + * Returns ptr to value associated with name, if any, else NULL. + */ +char* getenv(const char* name) { - register char **v = environ; - register const char *p, *q; + int offset; - if (v == NULL || name == NULL) - return (char *)NULL; - while ((p = *v++) != NULL) { - q = name; - while (*q && (*q == *p++)) - q++; - if (*q || (*p != '=')) - continue; - return (char *)p + 1; - } - return (char *)NULL; + return(_findenv(name,&offset)); } + +/* + * _findenv(name,offset) -- + * Returns pointer to value associated with name, if any, else NULL. + * Sets offset to be the offset of the name/value combination in the + * environmental array, for use by setenv(3) and unsetenv(3). + * Explicitly removes '=' in argument name. + * + * This routine *should* be a static; don't use it. + */ +char* _findenv(register const char* name, int* offset) +{ + extern char **environ; + register int len; + register char **P; + register const char *C; + + if (!environ) + return NULL; + + for (C = name,len = 0;*C && *C != '=';++C,++len); + for (P = environ;*P;++P) + if (!strncmp(*P,name,len)) + if (*(C = *P + len) == '=') { + *offset = P - environ; + return (char*)(++C); + } + return(NULL); +} + diff --git a/lang/cem/libcc.ansi/stdlib/malloc/.distr b/lang/cem/libcc.ansi/stdlib/malloc/.distr deleted file mode 100644 index e23a0ee82..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/.distr +++ /dev/null @@ -1,13 +0,0 @@ -READ_ME -add_file -check.c -check.h -global.c -impl.h -log.c -log.h -mal.c -param.h -phys.c -phys.h -size_type.h diff --git a/lang/cem/libcc.ansi/stdlib/malloc/Makefile b/lang/cem/libcc.ansi/stdlib/malloc/Makefile deleted file mode 100644 index 11cf36765..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -DIR = . -MALLOC_C = $(DIR)/malloc.c -MALLOC_O = $(DIR)/malloc.o - -MALLOCSRC = READ_ME size_type.h param.h impl.h check.h log.h phys.h \ - mal.c log.c phys.c check.c - -$(MALLOC_C): $(MALLOCSRC) Makefile add_file - rm -f $(MALLOC_C) - for i in $(MALLOCSRC) ; do add_file $$i >> $(MALLOC_C) ; done - rm -f $(MALLOC_O) - -pr: - @pr Makefile add_file $(MALLOCSRC) - -opr: - make pr | opr - -clean: - rm -f *.o malloc.c diff --git a/lang/cem/libcc.ansi/stdlib/malloc/READ_ME b/lang/cem/libcc.ansi/stdlib/malloc/READ_ME deleted file mode 100644 index 2f0bd6f84..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/READ_ME +++ /dev/null @@ -1,27 +0,0 @@ -/* - PROGRAM - malloc(), free(), realloc() - AUTHOR - Dick Grune, Free University, Amsterdam - Modified by Ceriel Jacobs, Free University, Amsterdam, - to make it faster - VERSION - $Id$ - DESCRIPTION - This is an independent rewrite of the malloc/free package; it is - fast and efficient. Free blocks are kept in doubly linked lists, - list N holding blocks with sizes between 2**N and 2**(N+1)-1. - Consequently neither malloc nor free have to do any searching: - the cost of a call of malloc() (or free()) is constant, however - many blocks you have got. - - If you switch on the NON_STANDARD macro (see param.h) every block - costs 2 pointers overhead (otherwise it's 4). -*/ -/* - There is an organisational problem here: during devellopment - I want the package divided into modules, which implies external - names for the communication. The only external names I want in - the finished product are malloc, realloc and free. This requires - some hanky-panky. -*/ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/add_file b/lang/cem/libcc.ansi/stdlib/malloc/add_file deleted file mode 100755 index 58585bf05..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/add_file +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -echo "" -echo "/**********************************************************/" -echo "/* This was file $1 */" -echo "/**********************************************************/" -echo "" - -cat $1 | -sed ' - /#include[ ].*"/d - s/^public/private/ - s/^publicdata/static/ -' -echo '' diff --git a/lang/cem/libcc.ansi/stdlib/malloc/check.c b/lang/cem/libcc.ansi/stdlib/malloc/check.c deleted file mode 100644 index a0bfab331..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/check.c +++ /dev/null @@ -1,303 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include - -#ifdef CHECK /* otherwise this whole file is skipped */ - -/* ??? check these later */ -private acquire_malout(void), check_ml_last(const char *s); -private dump_all_mallinks(void), dump_free_list(int i); -private dump_mallink(const char *s, mallink *ml), print_loop(mallink *ml); -private working_on(mallink *ml); -private size_type checksum(mallink *ml); -static FILE *malout; - -private mallink *free_list_entry(int i); - -#define for_free_list(i,p) \ - for (p = free_list_entry(i); p; p = log_next_of(p)) - -#define for_all_mallinks(ml) /* backwards! */ \ - for (ml = ml_last; ml; \ - ml = first_mallink(ml) ? MAL_NULL : phys_prev_of(ml)) - -/* Maldump */ - -static int pr_cnt = 0; - -maldump(int n) { - /* Dump pertinent info in pseudo-readable format; - abort afterwards if n != 0. - */ - static int dumping = 0; - int i; - - if (dumping) - return; - dumping++; - acquire_malout(); - fprintf(malout, - ">>>>>>>>>>>>>>>> DUMP OF ALL MALLINKS <<<<<<<<<<<<<<<<"); - fprintf(malout, " ml_last = %p\n", ml_last); - if (++pr_cnt == 100) pr_cnt = 0; - dump_all_mallinks(); - fprintf(malout, - ">>>>>>>>>>>>>>>> DUMP OF FREE_LISTS <<<<<<<<<<<<<<<<\n"); - if (++pr_cnt == 100) pr_cnt = 0; - for (i = 0; i < MAX_FLIST; i++) - dump_free_list(i); - fprintf(malout, - ">>>>>>>>>>>>>>>> END OF DUMP <<<<<<<<<<<<<<<<\n"); - fclose(malout); - dumping--; - if (n) - abort(); -} - -private -acquire_malout(void) { - static char buf[BUFSIZ]; - - if (!malout) { - malout = freopen("mal.out", "w", stderr); - setbuf(malout, buf); - } -} - -private -dump_all_mallinks(void) { - mallink *ml; - - for_all_mallinks (ml) { - if (print_loop(ml)) - return; - dump_mallink((char *)0, ml); - } -} - -private -dump_free_list(int i) { - mallink *ml = free_list_entry(i); - - if (!ml) - return; - fprintf(malout, "%2d: ", i); - for_free_list(i, ml) { - if (print_loop(ml)) - return; - fprintf(malout, "%p ", ml); - } - fprintf(malout, "<\n"); -} - -private int -print_loop(mallink *ml) { - if (print_of(ml) == pr_cnt) { - fprintf(malout, "... PRINT LOOP\n"); - return 1; - } - set_print(ml, pr_cnt); - return 0; -} - -private -dump_mallink(const char *s, mallink *ml) { - acquire_malout(); - if (s) - fprintf(malout, "%s: ", s); - fprintf(malout, "@: %p;", ml); - if (ml && checksum_of(ml) != checksum(ml)) - fprintf(malout, ">>>> CORRUPTED <<<<"); - if (!ml) { - fprintf(malout, "\n"); - return; - } - if (free_of(ml)) { - fprintf(malout, " l_p: %p;", _log_prev_of(ml)); - fprintf(malout, " l_n: %p;", _log_next_of(ml)); - } - fprintf(malout, " p_s: %p;", prev_size_of(ml)); - fprintf(malout, " t_s: %p;", _this_size_of(ml)); - fprintf(malout, " sz: %lu;", (unsigned long) size_of(ml)); - fprintf(malout, " fr: %d;", free_of(ml)); - fprintf(malout, "\n"); -} - -/* Check_mallinks() checks the total data structure as accessible - through free_list[] and ml_last. All check_sums should be OK, - except those held in the small array off_colour. This is a - trick to allow to continue checking even when a few mallinks - are temporarily out of order. - Check_mallinks() tests for a lot of internal consistency. -*/ - -/* Some arbitrary constants */ -#define IN_ML_LAST 93 -#define IN_FREE_LIST 57 /* and in ml_last */ -#define CLEAR 21 - -#define VRIJ 1 -#define BEZET 2 - -private -check_mallinks(const char *s) { - mallink *ml; - size_type size; - int i; - char stat; - - check_ml_last(s); - stat = BEZET; - for_all_mallinks(ml) { - if (checksum_of(ml) != checksum(ml)) - Error("mallink info at %p corrupted", s, ml); - if (working_on(ml)) { - stat = BEZET; - continue; - } - if ( !last_mallink(ml) && - phys_prev_of(phys_next_of(ml)) != ml - ) - Error("upward chain bad at %p", s, ml); - if ( !first_mallink(ml) && - phys_next_of(phys_prev_of(ml)) != ml - ) - Error("downward chain bad at %p", s, ml); - if (free_of(ml)) { - if (stat == VRIJ) - Error("free mallink at %p follows free mallink", - s, ml); - stat = VRIJ; - } - else - stat = BEZET; - set_mark(ml, IN_ML_LAST); - } - - for (i = 0, size = MIN_SIZE; i < MAX_FLIST; i++, size *= 2) { - for_free_list(i, ml) { - if (working_on(ml)) - continue; - if (!free_of(ml)) - Error("occupied mallink %p occurs in free_list", s, ml); - switch (mark_of(ml)) { - case IN_ML_LAST: - set_mark(ml, IN_FREE_LIST); - break; - case IN_FREE_LIST: - Error("mallink %p occurs in 2 free_lists", - s, ml); - default: - Error("unknown mallink %p in free_list", - s, ml); - } - if (size_of(ml) < size) - Error("size of mallink %p too small", s, ml); - if (size_of(ml) >= 2*size) - Error("size of mallink %p too large", s, ml); - } - } - for_all_mallinks (ml) { - if (working_on(ml)) - continue; - if (free_of(ml) && mark_of(ml) != IN_FREE_LIST) - Error("free mallink %p is in no free_list", s, ml); - set_mark(ml, CLEAR); - } -} - -private -check_ml_last(const char *s) { - if (ml_last && _this_size_of(ml_last) == 0) - Error("size of ml_last == 0, at %p", s, ml_last); -} - -private size_type -checksum(mallink *ml) { - size_type sum = 0; - - if (free_of(ml)) { - sum += (size_type)_log_prev_of(ml); - sum += (size_type)_log_next_of(ml); - } - sum += (size_type)prev_size_of(ml); - sum += (size_type)_this_size_of(ml); - return sum; -} - -private -calc_checksum(mallink *ml) { - set_checksum(ml, checksum(ml)); -} - -#define N_COLOUR 10 -static mallink *off_colour[N_COLOUR]; - -private -started_working_on(mallink *ml) { - int i; - - for (i = 0; i < N_COLOUR; i++) - if (off_colour[i] == MAL_NULL) { - off_colour[i] = ml; - return; - } - Error("out of off_colour array at %p", "started_working_on", ml); -} - -private -stopped_working_on(mallink *ml) { - int i; - - for (i = 0; i < N_COLOUR; i++) - if (off_colour[i] == ml) { - off_colour[i] = MAL_NULL; - return; - } - Error("stopped working on mallink %p", "stopped_working_on", ml); -} - -private int -working_on(mallink *ml) { - int i; - - for (i = 0; i < N_COLOUR; i++) - if (off_colour[i] == ml) - return 1; - return 0; -} - -private -check_work_empty(const char *s) { - int i; - int cnt = 0; - - for (i = 0; i < N_COLOUR; i++) - if (off_colour[i] != MAL_NULL) - cnt++; - if (cnt != 0) - Error("off_colour not empty", s, MAL_NULL); -} - -private int -Error(const char *fmt, const char *s, mallink *ml) { - static int already_called = 0; - - if (already_called++) return 0; - setbuf(stdout, (char *) 0); - printf("%s: ", s); - printf(fmt, (long)ml); - printf("\n"); - acquire_malout(); - fprintf(malout, "%s: ", s); - fprintf(malout, fmt, (long)ml); - fprintf(malout, "\n"); - fflush(stdout); - maldump(1); - return 0; /* to satisfy lint */ -} - -#endif /* CHECK */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/check.h b/lang/cem/libcc.ansi/stdlib/malloc/check.h deleted file mode 100644 index bc6aafc4f..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/check.h +++ /dev/null @@ -1,21 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#ifdef CHECK - -public check_mallinks(const char *s), calc_checksum(mallink *ml); -public check_work_empty(const char *s); -public started_working_on(mallink *ml), stopped_working_on(mallink *ml); - -#else /* ifndef CHECK */ - -#define maldump(n) abort() -#define check_mallinks(s) 0 -#define calc_checksum(ml) 0 -#define started_working_on(ml) 0 -#define stopped_working_on(ml) 0 -#define check_work_empty(s) 0 - -#endif /* CHECK */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/impl.h b/lang/cem/libcc.ansi/stdlib/malloc/impl.h deleted file mode 100644 index bd454037c..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/impl.h +++ /dev/null @@ -1,84 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* This file essentially describes how the mallink info block - is implemented. -*/ - -#define MIN_SIZE (1<>= 1; - mlp++; - } - while (n >= MIN_SIZE); - - ml1 = *--mlp; - set_log_prev(ml, MAL_NULL); - set_log_next(ml, ml1); - calc_checksum(ml); - if (ml1) { - /* link backwards - */ - set_log_prev(ml1, ml); - calc_checksum(ml1); - } - *mlp = ml; -} - -public -unlink_free_chunk(register mallink *ml) -{ - /* Unlinks a free chunk from (the middle of) the - logical chain. - */ - register mallink *next = log_next_of(ml); - register mallink *prev = log_prev_of(ml); - - if (!prev) { - /* it is the first in the chain */ - register mallink **mlp = &free_list[-1]; - register size_type n = size_of(ml); - - assert(n < (1L << LOG_MAX_SIZE)); - do { - n >>= 1; - mlp++; - } - while (n >= MIN_SIZE); - *mlp = next; - } - else { - set_log_next(prev, next); - calc_checksum(prev); - } - if (next) { - set_log_prev(next, prev); - calc_checksum(next); - } -} - -public mallink * -search_free_list(int class, size_t n) -{ - /* Searches the free_list[class] for a chunk of at least size n; - since it is searching a slightly undersized list, - such a block may not be there. - */ - register mallink *ml; - - for (ml = free_list[class]; ml; ml = log_next_of(ml)) - if (size_of(ml) >= n) - return ml; - return MAL_NULL; /* nothing found */ -} - -public mallink * -first_present(int class) -{ - /* Find the index i in free_list[] such that: - i >= class && free_list[i] != MAL_NULL. - Return MAL_NULL if no such i exists; - Otherwise, return the first block of this list, after - unlinking it. - */ - register mallink **mlp, *ml; - - for (mlp = &free_list[class]; mlp < &free_list[MAX_FLIST]; mlp++) { - if ((ml = *mlp) != MAL_NULL) { - - *mlp = log_next_of(ml); /* may be MAL_NULL */ - if (*mlp) { - /* unhook backward link - */ - set_log_prev(*mlp, MAL_NULL); - calc_checksum(*mlp); - } - return ml; - } - } - return MAL_NULL; -} - -#ifdef CHECK -public mallink * -free_list_entry(int i) { - /* To allow maldump.c access to log.c's private data. - */ - return free_list[i]; -} -#endif /* CHECK */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/log.h b/lang/cem/libcc.ansi/stdlib/malloc/log.h deleted file mode 100644 index f2ba3c947..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/log.h +++ /dev/null @@ -1,26 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* Algorithms to manipulate the doubly-linked lists of free - chunks. -*/ - -public link_free_chunk(mallink *ml), unlink_free_chunk(mallink *ml); -public mallink *first_present(int class); -public mallink *search_free_list(int class, size_t n); - -#ifdef STORE -#define in_store(ml) ((size_type)_phys_prev_of(ml) & STORE_BIT) -#define set_store(ml, e) \ - (_phys_prev_of(ml) = (mallink *) \ - ((e) ? (size_type) _phys_prev_of(ml) | STORE_BIT : \ - (size_type) _phys_prev_of(ml) & ~STORE_BIT)) -#endif -#define set_log_prev(ml,e) (_log_prev_of(ml) = (e)) -#define log_prev_of(ml) (mallink *) (_log_prev_of(ml)) - -#define set_log_next(ml,e) (_log_next_of(ml) = (e)) -#define log_next_of(ml) (mallink *) (_log_next_of(ml)) - diff --git a/lang/cem/libcc.ansi/stdlib/malloc/mal.c b/lang/cem/libcc.ansi/stdlib/malloc/mal.c deleted file mode 100644 index d523c9ad1..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/mal.c +++ /dev/null @@ -1,385 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include -#include -#include "param.h" -#include "impl.h" -#include "check.h" -#include "log.h" -#include "phys.h" - -/* Malloc space is traversed by N doubly-linked lists of chunks, each - containing a couple of house-keeping data addressed as a - 'mallink' and a piece of useful space, called the block. - The N lists are accessed through their starting pointers in - free_list[]. Free_list[n] points to a list of chunks between - 2**(n+LOG_MIN_SIZE) and 2**(n+LOG_MIN_SIZE+1)-1, which means - that the smallest chunk is 2**LOG_MIN_SIZE (== MIN_SIZE). -*/ - -#ifdef SYSTEM -#include -#define SBRK sys_break -extern void *SBRK(int incr); -#else -#include -#define SBRK sbrk -#define ILL_BREAK (void *)(-1) /* funny failure value */ -#endif -#ifdef STORE -#define MAX_STORE 32 -private do_free(mallink *ml), sell_out(void); -privatedata mallink *store[MAX_STORE]; -#endif /* STORE */ - -void * -malloc(register size_t n) -{check_mallinks("malloc entry");{ - register mallink *ml; - register int min_class; - - if (n == 0) { - return NULL; - } - if (n < MIN_SIZE) n = align(MIN_SIZE); else n = align(n); -#ifdef STORE - if (n <= MAX_STORE*MIN_SIZE) { - /* look in the store first */ - register mallink **stp = &store[(n >> LOG_MIN_SIZE) - 1]; - - if (ml = *stp) { - *stp = log_next_of(ml); - set_store(ml, 0); - check_mallinks("malloc fast exit"); - assert(! in_store(ml)); - return block_of_mallink(ml); - } - } -#endif /* STORE */ - - check_work_empty("malloc, entry"); - - /* Acquire a chunk of at least size n if at all possible; - Try everything. - */ - { - /* Inline substitution of "smallest". - */ - register size_t n1 = n; - - assert(n1 < (1L << LOG_MAX_SIZE)); - min_class = 0; - - do { - n1 >>= 1; - min_class++; - } while (n1 >= MIN_SIZE); - } - - if (min_class >= MAX_FLIST) - return NULL; /* we don't deal in blocks that big */ - ml = first_present(min_class); - if (ml == MAL_NULL) { - /* Try and extend */ - register void *p; -#define GRABSIZE 4096 /* Power of 2 */ - register size_t req = - ((MIN_SIZE<= 0) p = SBRK((int)req); - } - if (p == ILL_BREAK) { - /* Now this is bad. The system will not give us - more memory. We can only liquidate our store - and hope it helps. - */ -#ifdef STORE - sell_out(); - ml = first_present(min_class); - if (ml == MAL_NULL) { -#endif /* STORE */ - /* In this emergency we try to locate a suitable - chunk in the free_list just below the safe - one; some of these chunks may fit the job. - */ - ml = search_free_list(min_class - 1, n); - if (!ml) /* really out of space */ - return NULL; - started_working_on(ml); - unlink_free_chunk(ml); - check_mallinks("suitable_chunk, forced"); -#ifdef STORE - } - else started_working_on(ml); -#endif /* STORE */ - } - else { - assert((size_type)p == align((size_type)p)); - ml = create_chunk(p, req); - } - check_mallinks("suitable_chunk, extended"); - } - else started_working_on(ml); - - /* we have a chunk */ - set_free(ml, 0); - calc_checksum(ml); - check_mallinks("suitable_chunk, removed"); - n += mallink_size(); - if (n + MIN_SIZE <= size_of(ml)) { - truncate(ml, n); - } - stopped_working_on(ml); - check_mallinks("malloc exit"); - check_work_empty("malloc exit"); -#ifdef STORE - assert(! in_store(ml)); -#endif - return block_of_mallink(ml); -}} - -void -free(void *addr) -{check_mallinks("free entry");{ - register mallink *ml; - - if (addr == NULL) { - check_mallinks("free(0) very fast exit"); - return; - } - - ml = mallink_of_block(addr); -#ifdef STORE - - if (free_of(ml) || in_store(ml)) - return; /* user frees free block */ - if (size_of(ml) <= MAX_STORE*MIN_SIZE) { - /* return to store */ - mallink **stp = &store[(size_of(ml) >> LOG_MIN_SIZE) - 1]; - - set_log_next(ml, *stp); - *stp = ml; - set_store(ml, 1); - calc_checksum(ml); - check_mallinks("free fast exit"); - } - else { - do_free(ml); - check_mallinks("free exit"); - } -}} - -private -do_free(register mallink *ml) -{{ -#endif - -#ifndef STORE - if (free_of(ml)) return; -#endif /* STORE */ - started_working_on(ml); - set_free(ml, 1); - calc_checksum(ml); - if (! last_mallink(ml)) { - register mallink *next = phys_next_of(ml); - - if (free_of(next)) coalesce_forw(ml, next); - } - - if (! first_mallink(ml)) { - register mallink *prev = phys_prev_of(ml); - - if (free_of(prev)) { - coalesce_backw(ml, prev); - ml = prev; - } - } - link_free_chunk(ml); - stopped_working_on(ml); - check_work_empty("free"); - - /* Compile-time checks on param.h */ - switch (0) { - case MIN_SIZE < OFF_SET * sizeof(mallink): break; - case 1: break; - /* If this statement does not compile due to duplicate case - entry, the minimum size block cannot hold the links for - the free blocks. Either raise LOG_MIN_SIZE or switch - off NON_STANDARD. - */ - } - switch(0) { - case sizeof(void *) != sizeof(size_type): break; - case 1: break; - /* If this statement does not compile due to duplicate - case entry, size_type is not defined correctly. - Redefine and compile again. - */ - } -}} - -void * -realloc(void *addr, register size_t n) -{check_mallinks("realloc entry");{ - register mallink *ml, *ph_next; - register size_type size; - - if (addr == NULL) { - /* Behave like most Unix realloc's when handed a - null-pointer - */ - return malloc(n); - } - if (n == 0) { - free(addr); - return NULL; - } - ml = mallink_of_block(addr); - if (n < MIN_SIZE) n = align(MIN_SIZE); else n = align(n); -#ifdef STORE - if (in_store(ml)) { - register mallink *stp = store[(size_of(ml) >> LOG_MIN_SIZE) - 1]; - mallink *stp1 = NULL; - while (ml != stp) { - stp1 = stp; - stp = log_next_of(stp); - } - stp = log_next_of(stp); - if (! stp1) store[(size_of(ml) >> LOG_MIN_SIZE) - 1] = stp; - else set_log_next(stp1, stp); - set_store(ml, 0); - calc_checksum(ml); - } -#endif - if (free_of(ml)) { - unlink_free_chunk(ml); - set_free(ml, 0); /* user reallocs free block */ - } - started_working_on(ml); - size = size_of(ml); - if ( /* we can simplify the problem by adding the next chunk: */ - n > size && - !last_mallink(ml) && - (ph_next = phys_next_of(ml), free_of(ph_next)) && - n <= size + mallink_size() + size_of(ph_next) - ) { - /* add in the physically next chunk */ - unlink_free_chunk(ph_next); - combine_chunks(ml, ph_next); - size = size_of(ml); - check_mallinks("realloc, combining"); - } - if (n > size) { /* this didn't help */ - void *new; - register char *l1, *l2 = addr; - - stopped_working_on(ml); - if (!(new = l1 = malloc(n))) return NULL; /* no way */ - while (size--) *l1++ = *l2++; - free(addr); - check_work_empty("mv_realloc"); -#ifdef STORE - assert(! in_store(mallink_of_block(new))); -#endif - return new; - } - /* it helped, but maybe too well */ - n += mallink_size(); - if (n + MIN_SIZE <= size_of(ml)) { - truncate(ml, n); - } - stopped_working_on(ml); - check_mallinks("realloc exit"); - check_work_empty("realloc"); -#ifdef STORE - assert(! in_store(ml)); -#endif - return addr; -}} - -void * -calloc(size_t nmemb, size_t size) -{check_mallinks("calloc entry");{ - long *l1, *l2; - size_t n; - - if (size == 0) return NULL; - if (nmemb == 0) return NULL; - - /* Check for overflow on the multiplication. The peephole-optimizer - * will eliminate all but one of the possibilities. - */ - if (sizeof(size_t) == sizeof(int)) { - if (UINT_MAX / size < nmemb) return NULL; - } else if (sizeof(size_t) == sizeof(long)) { - if (ULONG_MAX / size < nmemb) return NULL; - } else return NULL; /* can't happen, can it ? */ - - n = size * nmemb; - if (n < MIN_SIZE) n = align(MIN_SIZE); else n = align(n); - if (n >= (1L << LOG_MAX_SIZE)) return NULL; - l1 = (long *) malloc(n); - l2 = l1 + (n / sizeof(long)); /* n is at least long aligned */ - while ( l2 != l1 ) *--l2 = 0; - check_mallinks("calloc exit"); - check_work_empty("calloc exit"); - return (void *)l1; -}} -/* Auxiliary routines */ - -#ifdef STORE -private -sell_out(void) { - /* Frees all block in store. - */ - register mallink **stp; - - for (stp = &store[0]; stp < &store[MAX_STORE]; stp++) { - register mallink *ml = *stp; - - while (ml) { - *stp = log_next_of(ml); - set_store(ml, 0); - do_free(ml); - ml = *stp; - } - } - -} -#endif /* STORE */ - -#ifdef ASSERT -public -m_assert(const char *fn, int ln) -{ - char ch; - - while (*fn) - write(2, fn++, 1); - write(2, ": malloc assert failed in line ", 31); - ch = (ln / 100) + '0'; write(2, &ch, 1); ln %= 100; - ch = (ln / 10) + '0'; write(2, &ch, 1); ln %= 10; - ch = (ln / 1) + '0'; write(2, &ch, 1); - write(2, "\n", 1); - maldump(1); -} -#endif /* ASSERT */ diff --git a/lang/cem/libcc.ansi/stdlib/malloc/param.h b/lang/cem/libcc.ansi/stdlib/malloc/param.h deleted file mode 100644 index b47c0d430..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/param.h +++ /dev/null @@ -1,56 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include "size_type.h" - -# define NON_STANDARD /* If defined, the contents of a block - will NOT be left undisturbed after it - is freed, as opposed to what it says - in the manual (malloc(2)). - Setting this option reduces the memory - overhead considerably. I personally - consider the specified behaviour an - artefact of the original - implementation. - */ - -# undef ASSERT /* If defined, some inexpensive tests - will be made to ensure the - correctness of some sensitive data. - It often turns an uncontrolled crash - into a controlled one. - */ - -# undef CHECK /* If defined, extensive and expensive - tests will be done, inculding a - checksum on the mallinks (chunk - information blocks). The resulting - information will be printed on a file - called mal.out . - Additionally a function - maldump(n) int n; - will be defined, which will dump - pertinent info in pseudo-readable - form; it aborts afterwards if n != 0. - */ - -# undef EXTERN /* If defined, all static names will - become extern, which is a help in - using adb(1) or prof(1) - */ - -# define STORE /* If defined, separate free lists will - be kept of chunks with small sizes, - to speed things up a little. - */ - -# undef SYSTEM /* If defined, the system module is used. - Otherwise, "sbrk" is called directly. - */ - -#define ALIGNMENT 8 - /* alignment common to all types */ -#define LOG_MIN_SIZE 3 -#define LOG_MAX_SIZE 24 diff --git a/lang/cem/libcc.ansi/stdlib/malloc/phys.c b/lang/cem/libcc.ansi/stdlib/malloc/phys.c deleted file mode 100644 index 3d14fa35c..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/phys.c +++ /dev/null @@ -1,96 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#include -#include "param.h" -#include "impl.h" -#include "check.h" -#include "phys.h" - -/* Physical manipulations. - The blocks concerned are not in any logical chain. -*/ - -public mallink * -create_chunk(void *p, size_t n) -{ - /* The newly acquired piece of memory at p, of length n, - is turned into a free chunk, properly chained in the - physical chain. - The address of the chunk is returned. - */ - register mallink *ml; - /* All of malloc memory is followed by a virtual chunk, the - mallink of which starts mallink_size() bytes past the last - byte in memory. - Its use is prevented by testing for ml == ml_last first. - */ - register mallink *last = ml_last; - - assert(!last || p == (char *)phys_next_of(last) - mallink_size()); - ml = (mallink *)((char *)p + mallink_size()); /* bump ml */ - new_mallink(ml); - started_working_on(ml); - set_free(ml, 1); - set_phys_prev(ml, last); - ml_last = ml; - - set_phys_next(ml, (mallink *)((char *)ml + n)); - calc_checksum(ml); - assert(size_of(ml) + mallink_size() == n); - if (last && free_of(last)) { - coalesce_backw(ml, last); - ml = last; - } - check_mallinks("create_chunk, phys. linked"); - return ml; -} - -public -truncate(register mallink *ml, size_t size) -{ - /* The chunk ml is truncated. - The chunk at ml is split in two. - The remaining part is then freed. - */ - register mallink *new = (mallink *)((char *)ml + size); - register mallink *ph_next = phys_next_of(ml); - - new_mallink(new); - set_free(new, 1); - set_phys_prev(new, ml); - set_phys_next(new, ph_next); - calc_checksum(new); - if (! last_mallink(ml)) { - set_phys_prev(ph_next, new); - calc_checksum(ph_next); - if (free_of(ph_next)) coalesce_forw(new, ph_next); - } - else ml_last = new; - set_phys_next(ml, new); - calc_checksum(ml); - - started_working_on(new); - link_free_chunk(new); - stopped_working_on(new); - check_mallinks("truncate"); -} - -public -combine_chunks(register mallink *ml1, register mallink *ml2) -{ - /* The chunks ml1 and ml2 are combined. - */ - register mallink *ml3 = phys_next_of(ml2); - - set_phys_next(ml1, ml3); - calc_checksum(ml1); - if (!last_mallink(ml2)) { - set_phys_prev(ml3, ml1); - calc_checksum(ml3); - } - if (ml_last == ml2) - ml_last = ml1; -} diff --git a/lang/cem/libcc.ansi/stdlib/malloc/phys.h b/lang/cem/libcc.ansi/stdlib/malloc/phys.h deleted file mode 100644 index 67fb9838d..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/phys.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $Id$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -/* Algorithms to manipulate the doubly-linked list of physical - chunks. -*/ -publicdata mallink *ml_last; - -#define FREE_BIT 01 -#ifdef STORE -#define STORE_BIT 02 -#define BITS (FREE_BIT|STORE_BIT) -#else -#define BITS (FREE_BIT) -#endif - -#define __bits(ml) ((int)((size_type)_phys_prev_of(ml) & BITS)) -#define __free_of(ml) ((int)((size_type)_phys_prev_of(ml) & FREE_BIT)) -#define __phys_prev_of(ml) ((mallink *)((size_type)_phys_prev_of(ml) & ~BITS)) -#define prev_size_of(ml) ((char *)(ml) - \ - (char *)__phys_prev_of(ml) - \ - mallink_size() \ - ) -#define set_phys_prev(ml,e) \ - (_phys_prev_of(ml) = (mallink *) ((char *)e + __bits(ml))) - -#ifdef CHECK -public Error(const char *fmt, const char *s, mallink *ml); -#define phys_prev_of(ml) (mallink *) \ - (first_mallink(ml) ? \ - (char *)Error("phys_prev_of first_mallink %p", "somewhere", ml) : \ - (char *)__phys_prev_of(ml) \ - ) -#else /* ndef CHECK */ -#define phys_prev_of(ml) __phys_prev_of(ml) -#endif /* CHECK */ - -#define first_mallink(ml) (int) (__phys_prev_of(ml) == 0) -#define last_mallink(ml) (int) ((ml) == ml_last) - -/* There is an ambiguity in the semantics of phys_next_of: sometimes - one wants it to return MAL_NULL if there is no next chunk, at - other times one wants the address of the virtual chunk at the - end of memory. The present version returns the address of the - (virtual) chunk and relies on the user to test last_mallink(ml) - first. -*/ -#define size_of(ml) (_this_size_of(ml) - mallink_size()) -#define set_phys_next(ml,e) \ - (_this_size_of(ml) = (size_type)((char *)(e) - (char *)(ml))) -#define phys_next_of(ml) (mallink *) ((char *)(ml) + _this_size_of(ml)) - -#define set_free(ml,e) \ - (_phys_prev_of(ml) = (mallink *) \ - ((e) ? (size_type) _phys_prev_of(ml) | FREE_BIT : \ - (size_type) _phys_prev_of(ml) & ~FREE_BIT)) -#define free_of(ml) (__free_of(ml)) - -#define coalesce_forw(ml,nxt) ( unlink_free_chunk(nxt), \ - combine_chunks((ml), (nxt))) - -#define coalesce_backw(ml,prv) ( unlink_free_chunk(prv), \ - stopped_working_on(ml), \ - combine_chunks((prv), (ml)), \ - started_working_on(prv)) - -#ifdef CHECK -#define set_print(ml,e) (_print_of(ml) = (e)) -#define print_of(ml) (_print_of(ml)) -#endif /* CHECK */ - -public truncate(mallink *ml, size_t size); -public combine_chunks(register mallink *ml1, register mallink *ml2); -public mallink *create_chunk(void *p, size_t n); diff --git a/lang/cem/libcc.ansi/stdlib/malloc/size_type.h b/lang/cem/libcc.ansi/stdlib/malloc/size_type.h deleted file mode 100644 index b39609ea1..000000000 --- a/lang/cem/libcc.ansi/stdlib/malloc/size_type.h +++ /dev/null @@ -1,8 +0,0 @@ -#if _EM_WSIZE == _EM_PSIZE -typedef unsigned int size_type; -#elif _EM_LSIZE == _EM_PSIZE -typedef unsigned long size_type; -#else -#error funny pointer size -#endif -#include diff --git a/lang/cem/libcc.ansi/stdlib/setenv.c b/lang/cem/libcc.ansi/stdlib/setenv.c new file mode 100644 index 000000000..086b2118d --- /dev/null +++ b/lang/cem/libcc.ansi/stdlib/setenv.c @@ -0,0 +1,87 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#include +#include + +extern char* _findenv(const char* name, int* offset); +extern char **environ; + +/* + * setenv(name,value,rewrite) + * Set the value of the environmental variable "name" to be + * "value". If rewrite is set, replace any current value. + */ +int setenv(register const char* name, register const char* value, int rewrite) +{ + static int alloced = 0; /* if allocated space before */ + register char *C; + int l_value, + offset; + + if (*value == '=') /* no `=' in value */ + ++value; + l_value = strlen(value); + if ((C = _findenv(name,&offset))) { /* find if already exists */ + if (!rewrite) + return(0); + if (strlen(C) >= l_value) { /* old larger; copy over */ + while (*C++ = *value++); + return(0); + } + } + else { /* create new slot */ + register int cnt = 0; + register char **P; + + if (environ) + for (P = environ;*P;++P,++cnt); + if (alloced) { /* just increase size */ + environ = (char **)realloc((char *)environ, + (unsigned)(sizeof(char *) * (cnt + 2))); + if (!environ) + return(-1); + } + else { /* get new space */ + alloced = 1; /* copy old entries into it */ + P = (char **)malloc((unsigned)(sizeof(char *) * + (cnt + 2))); + if (!P) + return(-1); + if (environ) + bcopy(environ,P,cnt * sizeof(char *)); + environ = P; + } + environ[cnt + 1] = NULL; + offset = cnt; + } + for (C = name;*C && *C != '=';++C); /* no `=' in name */ + if (!(environ[offset] = /* name + `=' + value */ + malloc((unsigned)((int)(C - name) + l_value + 2)))) + return(-1); + for (C = environ[offset];(*C = *name++) && *C != '=';++C); + for (*C++ = '=';*C++ = *value++;); + return(0); +} + +/* + * unsetenv(name) -- + * Delete environmental variable "name". + */ +int +unsetenv(const char* name) +{ + register char **P; + int offset; + + while (_findenv(name,&offset)) /* if set multiple times */ + for (P = &environ[offset];;++P) + if (!(*P = *(P + 1))) + break; + + return 0; +} + diff --git a/lang/cem/libcc.ansi/string/.distr b/lang/cem/libcc.ansi/string/.distr deleted file mode 100644 index f7ff5cc28..000000000 --- a/lang/cem/libcc.ansi/string/.distr +++ /dev/null @@ -1,22 +0,0 @@ -memchr.c -memcmp.c -memcpy.c -memmove.c -memset.c -strcat.c -strchr.c -strcmp.c -strcoll.c -strcpy.c -strcspn.c -strerror.c -strlen.c -strncat.c -strncmp.c -strncpy.c -strpbrk.c -strrchr.c -strspn.c -strstr.c -strtok.c -strxfrm.c diff --git a/lang/cem/libcc.ansi/stdlib/malloc/global.c b/lang/cem/libcc.ansi/string/strdup.c similarity index 55% rename from lang/cem/libcc.ansi/stdlib/malloc/global.c rename to lang/cem/libcc.ansi/string/strdup.c index 49cb459c0..730796b5f 100644 --- a/lang/cem/libcc.ansi/stdlib/malloc/global.c +++ b/lang/cem/libcc.ansi/string/strdup.c @@ -1,11 +1,17 @@ -/* $Id$ */ /* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include "param.h" -#include "impl.h" +/* $Id$ */ -/* The only global data item: -*/ -mallink *ml_last; /* link to the world */ +#include + +char* +strdup(const char *s) +{ + int len = strlen(s); + char *p = malloc(len+1); + if (p) + memcpy(p, s, len+1); + return p; +} diff --git a/lang/cem/libcc.ansi/time/.distr b/lang/cem/libcc.ansi/time/.distr deleted file mode 100644 index b53265c96..000000000 --- a/lang/cem/libcc.ansi/time/.distr +++ /dev/null @@ -1,12 +0,0 @@ -asctime.c -clock.c -ctime.c -difftime.c -gmtime.c -loc_time.h -localtime.c -misc.c -mktime.c -strftime.c -time.c -tzset.c diff --git a/lang/cem/libcc/.distr b/lang/cem/libcc/.distr deleted file mode 100644 index 9412e8f87..000000000 --- a/lang/cem/libcc/.distr +++ /dev/null @@ -1,6 +0,0 @@ -pmfile -gen -headers -math -mon -stdio diff --git a/lang/cem/libcc/gen/.distr b/lang/cem/libcc/gen/.distr deleted file mode 100644 index a4b83bb42..000000000 --- a/lang/cem/libcc/gen/.distr +++ /dev/null @@ -1,75 +0,0 @@ -pmfile -head_cc.e -abs.c -atof.c -strtod.c -atoi.c -atol.c -strtol.c -bcmp.c -bfill.c -bmove.c -bzero.c -calloc.c -crypt.c -ctime.c -asctime.c -execvp.c -ffc.c -ffs.c -gcvt.c -ecvt.c -ext_comp.c -getlogin.c -index.c -l3.c -ldexp.c -localtime.c -gmtime.c -memccpy.c -memchr.c -memcmp.c -memcpy.c -memset.c -mktemp.c -monitor.c -perror.c -procentry.c -qsort.c -bsearch.c -rand.c -seekdir.c -sleep.c -stb.c -strstr.c -strchr.c -strcmp.c -strcspn.c -strncat.c -strrchr.c -strtok.c -strpbrk.c -strspn.c -swab.c -telldir.c -ttyslot.c -rindex.c -strncmp.c -ttyname.c -closedir.c -isatty.c -opendir.c -malloc.c -bcopy.c -readdir.c -strcat.c -strcpy.c -strlen.c -tzset.c -getenv.c -strncpy.c -_c2type.c -abort.e -frexp.e -modf.e -setjmp.e diff --git a/lang/cem/libcc/gen/pmfile b/lang/cem/libcc/gen/pmfile deleted file mode 100644 index f190777a8..000000000 --- a/lang/cem/libcc/gen/pmfile +++ /dev/null @@ -1,94 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/gen/" - -local head = acklibrary { - ackfile (d.."head_cc.e"), - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/c-knr.o") -} - -local tail = acklibrary { - ackfile (d.."abs.c"), - ackfile (d.."atof.c"), - ackfile (d.."strtod.c"), - ackfile (d.."atoi.c"), - ackfile (d.."atol.c"), - ackfile (d.."strtol.c"), - ackfile (d.."bcmp.c"), - ackfile (d.."bfill.c"), - ackfile (d.."bmove.c"), - ackfile (d.."bzero.c"), - ackfile (d.."calloc.c"), - ackfile (d.."crypt.c"), - ackfile (d.."ctime.c"), - ackfile (d.."asctime.c"), - ackfile (d.."execvp.c"), - ackfile (d.."ffc.c"), - ackfile (d.."ffs.c"), - ackfile (d.."gcvt.c"), - ackfile (d.."ecvt.c"), - ackfile (d.."ext_comp.c"), - ackfile (d.."getlogin.c"), - ackfile (d.."index.c"), - ackfile (d.."l3.c"), - ackfile (d.."ldexp.c"), - ackfile (d.."localtime.c"), - ackfile (d.."gmtime.c"), - ackfile (d.."memccpy.c"), - ackfile (d.."memchr.c"), - ackfile (d.."memcmp.c"), - ackfile (d.."memcpy.c"), - ackfile (d.."memset.c"), - ackfile (d.."mktemp.c"), - ackfile (d.."monitor.c"), - ackfile (d.."perror.c"), - ackfile (d.."procentry.c"), - ackfile (d.."qsort.c"), - ackfile (d.."bsearch.c"), - ackfile (d.."rand.c"), - ackfile (d.."seekdir.c"), - ackfile (d.."sleep.c"), - ackfile (d.."stb.c"), - ackfile (d.."strstr.c"), - ackfile (d.."strchr.c"), - ackfile (d.."strcmp.c"), - ackfile (d.."strcspn.c"), - ackfile (d.."strncat.c"), - ackfile (d.."strrchr.c"), - ackfile (d.."strtok.c"), - ackfile (d.."strpbrk.c"), - ackfile (d.."strspn.c"), - ackfile (d.."swab.c"), - ackfile (d.."telldir.c"), - ackfile (d.."ttyslot.c"), - ackfile (d.."rindex.c"), - ackfile (d.."strncmp.c"), - ackfile (d.."ttyname.c"), - ackfile (d.."closedir.c"), - ackfile (d.."isatty.c"), - ackfile (d.."opendir.c"), - ackfile (d.."malloc.c"), - ackfile (d.."bcopy.c"), - ackfile (d.."readdir.c"), - ackfile (d.."strcat.c"), - ackfile (d.."strcpy.c"), - ackfile (d.."strlen.c"), - ackfile (d.."tzset.c"), - ackfile (d.."getenv.c"), - ackfile (d.."strncpy.c"), - ackfile (d.."_c2type.c"), - ackfile (d.."abort.e"), - ackfile (d.."frexp.e"), - ackfile (d.."modf.e"), - ackfile (d.."setjmp.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libc-knr.a") -} - -lang_cem_gen_runtime = group { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - head, - tail -} diff --git a/lang/cem/libcc/headers/.distr b/lang/cem/libcc/headers/.distr deleted file mode 100644 index a415c0dd7..000000000 --- a/lang/cem/libcc/headers/.distr +++ /dev/null @@ -1,19 +0,0 @@ -assert.h -ctype.h -errno.h -fcntl.h -grp.h -math.h -pwd.h -setjmp.h -sgtty.h -signal.h -stdio.h -time.h -varargs.h -sys/dir.h -sys/errno.h -sys/stat.h -sys/stdtypes.h -sys/types.h -sys/timeb.h diff --git a/lang/cem/libcc/math/.distr b/lang/cem/libcc/math/.distr deleted file mode 100644 index a6b3b1220..000000000 --- a/lang/cem/libcc/math/.distr +++ /dev/null @@ -1,21 +0,0 @@ -pmfile -asin.c -atan2.c -atan.c -ceil.c -fabs.c -gamma.c -hypot.c -jn.c -j0.c -j1.c -log10.c -pow.c -log.c -sin.c -sinh.c -sqrt.c -tan.c -tanh.c -exp.c -floor.c diff --git a/lang/cem/libcc/math/pmfile b/lang/cem/libcc/math/pmfile deleted file mode 100644 index 9ba570868..000000000 --- a/lang/cem/libcc/math/pmfile +++ /dev/null @@ -1,31 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/math/" - -lang_cem_math_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - ackfile (d.."asin.c"), - ackfile (d.."atan2.c"), - ackfile (d.."atan.c"), - ackfile (d.."ceil.c"), - ackfile (d.."fabs.c"), - ackfile (d.."gamma.c"), - ackfile (d.."hypot.c"), - ackfile (d.."jn.c"), - ackfile (d.."j0.c"), - ackfile (d.."j1.c"), - ackfile (d.."log10.c"), - ackfile (d.."pow.c"), - ackfile (d.."log.c"), - ackfile (d.."sin.c"), - ackfile (d.."sinh.c"), - ackfile (d.."sqrt.c"), - ackfile (d.."tan.c"), - ackfile (d.."tanh.c"), - ackfile (d.."exp.c"), - ackfile (d.."floor.c"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libm-knr.a") -} diff --git a/lang/cem/libcc/mon/.distr b/lang/cem/libcc/mon/.distr deleted file mode 100644 index 0ec396a35..000000000 --- a/lang/cem/libcc/mon/.distr +++ /dev/null @@ -1,92 +0,0 @@ -pmfile -exit.c -gtty.c -signal.c -stty.c -tell.c -time.c -cleanup.c -access.e -acct.e -alarm.e -brk.e -chdir.e -chmod.e -chown.e -chroot.e -close.e -creat.e -dup.e -dup2.e -execl.e -execle.e -execv.e -execve.e -fork.e -fstat.e -ftime.e -getegid.e -geteuid.e -getgid.e -getpid.e -getuid.e -ioctl.e -kill.e -link.e -lock.e -lseek.e -mknod.e -mount.e -mpxcall.e -nice.e -open.e -pause.e -pipe.e -prof.e -ptrace.e -read.e -sbrk.e -setgid.e -setuid.e -setsig.e -sigtrp.e -stat.e -stime.e -sync.e -times.e -umask.e -umount.e -unlink.e -utime.e -wait.e -write.e -errno.e -_alarm.e -_brk.e -_close.e -_creat.e -_dup.e -_dup2.e -_execl.e -_execve.e -_exit.e -_fork.e -_fstat.e -_ftime.e -_getpid.e -_gtty.c -_stty.c -_ioctl.e -_kill.e -_link.e -_lseek.e -_open.e -_pause.e -_pipe.e -_read.e -_sbrk.e -_times.e -_unlink.e -_wait.e -_write.e -types diff --git a/lang/cem/libcc/mon/pmfile b/lang/cem/libcc/mon/pmfile deleted file mode 100644 index 43865f854..000000000 --- a/lang/cem/libcc/mon/pmfile +++ /dev/null @@ -1,101 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/mon/" - -lang_cem_mon_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h", "%ROOTDIR%include/_tail_mon"}, - - ackfile (d.."exit.c"), - ackfile (d.."gtty.c"), - ackfile (d.."signal.c"), - ackfile (d.."stty.c"), - ackfile (d.."tell.c"), - ackfile (d.."time.c"), - ackfile (d.."cleanup.c"), - ackfile (d.."access.e"), - ackfile (d.."acct.e"), - ackfile (d.."alarm.e"), - ackfile (d.."brk.e"), - ackfile (d.."chdir.e"), - ackfile (d.."chmod.e"), - ackfile (d.."chown.e"), - ackfile (d.."chroot.e"), - ackfile (d.."close.e"), - ackfile (d.."creat.e"), - ackfile (d.."dup.e"), - ackfile (d.."dup2.e"), - ackfile (d.."execl.e"), - ackfile (d.."execle.e"), - ackfile (d.."execv.e"), - ackfile (d.."execve.e"), - ackfile (d.."fork.e"), - ackfile (d.."fstat.e"), - ackfile (d.."ftime.e"), - ackfile (d.."getegid.e"), - ackfile (d.."geteuid.e"), - ackfile (d.."getgid.e"), - ackfile (d.."getpid.e"), - ackfile (d.."getuid.e"), - ackfile (d.."ioctl.e"), - ackfile (d.."kill.e"), - ackfile (d.."link.e"), - ackfile (d.."lock.e"), - ackfile (d.."lseek.e"), - ackfile (d.."mknod.e"), - ackfile (d.."mount.e"), - ackfile (d.."mpxcall.e"), - ackfile (d.."nice.e"), - ackfile (d.."open.e"), - ackfile (d.."pause.e"), - ackfile (d.."pipe.e"), - ackfile (d.."prof.e"), - ackfile (d.."ptrace.e"), - ackfile (d.."read.e"), - ackfile (d.."sbrk.e"), - ackfile (d.."setgid.e"), - ackfile (d.."setuid.e"), - ackfile (d.."setsig.e"), - ackfile (d.."sigtrp.e"), - ackfile (d.."stat.e"), - ackfile (d.."stime.e"), - ackfile (d.."sync.e"), - ackfile (d.."times.e"), - ackfile (d.."umask.e"), - ackfile (d.."umount.e"), - ackfile (d.."unlink.e"), - ackfile (d.."utime.e"), - ackfile (d.."wait.e"), - ackfile (d.."write.e"), - ackfile (d.."errno.e"), - ackfile (d.."_alarm.e"), - ackfile (d.."_brk.e"), - ackfile (d.."_close.e"), - ackfile (d.."_creat.e"), - ackfile (d.."_dup.e"), - ackfile (d.."_dup2.e"), - ackfile (d.."_execl.e"), - ackfile (d.."_execve.e"), - ackfile (d.."_exit.e"), - ackfile (d.."_fork.e"), - ackfile (d.."_fstat.e"), - ackfile (d.."_ftime.e"), - ackfile (d.."_getpid.e"), - ackfile (d.."_gtty.c"), - ackfile (d.."_stty.c"), - ackfile (d.."_ioctl.e"), - ackfile (d.."_kill.e"), - ackfile (d.."_link.e"), - ackfile (d.."_lseek.e"), - ackfile (d.."_open.e"), - ackfile (d.."_pause.e"), - ackfile (d.."_pipe.e"), - ackfile (d.."_read.e"), - ackfile (d.."_sbrk.e"), - ackfile (d.."_times.e"), - ackfile (d.."_unlink.e"), - ackfile (d.."_wait.e"), - ackfile (d.."_write.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libmon.a") -} diff --git a/lang/cem/libcc/pmfile b/lang/cem/libcc/pmfile deleted file mode 100644 index ec566096a..000000000 --- a/lang/cem/libcc/pmfile +++ /dev/null @@ -1,41 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/" - -include (d.."gen/pmfile") -include (d.."math/pmfile") -include (d.."mon/pmfile") -include (d.."stdio/pmfile") - -local headers = group { - install = { - pm.install(d.."headers/assert.h", "%BINDIR%include/knr/assert.h"), - pm.install(d.."headers/ctype.h", "%BINDIR%include/knr/ctype.h"), - pm.install(d.."headers/errno.h", "%BINDIR%include/knr/errno.h"), - pm.install(d.."headers/fcntl.h", "%BINDIR%include/knr/fcntl.h"), - pm.install(d.."headers/grp.h", "%BINDIR%include/knr/grp.h"), - pm.install(d.."headers/math.h", "%BINDIR%include/knr/math.h"), - pm.install(d.."headers/pwd.h", "%BINDIR%include/knr/pwd.h"), - pm.install(d.."headers/setjmp.h", "%BINDIR%include/knr/setjmp.h"), - pm.install(d.."headers/sgtty.h", "%BINDIR%include/knr/sgtty.h"), - pm.install(d.."headers/signal.h", "%BINDIR%include/knr/signal.h"), - pm.install(d.."headers/stdio.h", "%BINDIR%include/knr/stdio.h"), - pm.install(d.."headers/time.h", "%BINDIR%include/knr/time.h"), - pm.install(d.."headers/varargs.h", "%BINDIR%include/knr/varargs.h"), - pm.install(d.."headers/sys/dir.h", "%BINDIR%include/knr/sys/dir.h"), - pm.install(d.."headers/sys/errno.h", "%BINDIR%include/knr/sys/errno.h"), - pm.install(d.."headers/sys/stat.h", "%BINDIR%include/knr/sys/stat.h"), - pm.install(d.."headers/sys/stdtypes.h", "%BINDIR%include/knr/sys/stdtypes.h"), - pm.install(d.."headers/sys/types.h", "%BINDIR%include/knr/sys/types.h"), - pm.install(d.."headers/sys/timeb.h", "%BINDIR%include/knr/sys/timeb.h"), - } -} - -lang_cem_runtime = group { - headers, - lang_cem_gen_runtime, - lang_cem_math_runtime, - lang_cem_mon_runtime, - lang_cem_stdio_runtime -} diff --git a/lang/cem/libcc/stdio/.distr b/lang/cem/libcc/stdio/.distr deleted file mode 100644 index 728de5ee2..000000000 --- a/lang/cem/libcc/stdio/.distr +++ /dev/null @@ -1,48 +0,0 @@ -pmfile -vsprintf.c -vfprintf.c -vprintf.c -termcap.c -getopt.c -clearerr.c -fgetc.c -fgets.c -fprintf.c -fputc.c -fputs.c -fread.c -freopen.c -fscanf.c -ftell.c -fwrite.c -getchar.c -getgrent.c -getpass.c -getpw.c -fopen.c -getpwent.c -gets.c -getw.c -popen.c -fdopen.c -printf.c -putchar.c -puts.c -putw.c -rewind.c -fseek.c -scanf.c -setbuf.c -sprintf.c -doprnt.c -fltpr.c -flushbuf.c -fclose.c -data.c -fflush.c -sscanf.c -doscan.c -fillbuf.c -system.c -timezone.c -ungetc.c diff --git a/lang/cem/libcc/stdio/pmfile b/lang/cem/libcc/stdio/pmfile deleted file mode 100644 index 577885838..000000000 --- a/lang/cem/libcc/stdio/pmfile +++ /dev/null @@ -1,58 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/libcc/stdio/" - -lang_cem_stdio_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - ackfile (d.."vsprintf.c"), - ackfile (d.."vfprintf.c"), - ackfile (d.."vprintf.c"), - ackfile (d.."termcap.c"), - ackfile (d.."getopt.c"), - ackfile (d.."clearerr.c"), - ackfile (d.."fgetc.c"), - ackfile (d.."fgets.c"), - ackfile (d.."fprintf.c"), - ackfile (d.."fputc.c"), - ackfile (d.."fputs.c"), - ackfile (d.."fread.c"), - ackfile (d.."freopen.c"), - ackfile (d.."fscanf.c"), - ackfile (d.."ftell.c"), - ackfile (d.."fwrite.c"), - ackfile (d.."getchar.c"), - ackfile (d.."getgrent.c"), - ackfile (d.."getpass.c"), - ackfile (d.."getpw.c"), - ackfile (d.."fopen.c"), - ackfile (d.."getpwent.c"), - ackfile (d.."gets.c"), - ackfile (d.."getw.c"), - ackfile (d.."popen.c"), - ackfile (d.."fdopen.c"), - ackfile (d.."printf.c"), - ackfile (d.."putchar.c"), - ackfile (d.."puts.c"), - ackfile (d.."putw.c"), - ackfile (d.."rewind.c"), - ackfile (d.."fseek.c"), - ackfile (d.."scanf.c"), - ackfile (d.."setbuf.c"), - ackfile (d.."sprintf.c"), - ackfile (d.."doprnt.c"), - ackfile (d.."fltpr.c"), - ackfile (d.."flushbuf.c"), - ackfile (d.."fclose.c"), - ackfile (d.."data.c"), - ackfile (d.."fflush.c"), - ackfile (d.."sscanf.c"), - ackfile (d.."doscan.c"), - ackfile (d.."fillbuf.c"), - ackfile (d.."system.c"), - ackfile (d.."timezone.c"), - ackfile (d.."ungetc.c"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libc-stdio-knr.a") -} diff --git a/lang/cem/lint/.distr b/lang/cem/lint/.distr deleted file mode 100644 index 937488f69..000000000 --- a/lang/cem/lint/.distr +++ /dev/null @@ -1,6 +0,0 @@ -README -llib -lpass1 -lpass1.ansi -lpass2 -proto.make diff --git a/lang/cem/lint/llib/.distr b/lang/cem/lint/llib/.distr deleted file mode 100644 index 77008f041..000000000 --- a/lang/cem/lint/llib/.distr +++ /dev/null @@ -1,9 +0,0 @@ -ChangeLog -README -proto.make -c.llb -ansi_c.llb -curses.llb -m.llb -termlib.llb -unix7.c diff --git a/lang/cem/lint/lpass1.ansi/.distr b/lang/cem/lint/lpass1.ansi/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/lang/cem/lint/lpass1.ansi/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/lang/cem/lint/lpass1/.distr b/lang/cem/lint/lpass1/.distr deleted file mode 100644 index ebf6f5c24..000000000 --- a/lang/cem/lint/lpass1/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Parameters -proto.main -proto.make diff --git a/lang/cem/lint/lpass2/.distr b/lang/cem/lint/lpass2/.distr deleted file mode 100644 index 1936f79b6..000000000 --- a/lang/cem/lint/lpass2/.distr +++ /dev/null @@ -1,13 +0,0 @@ -ChangeLog -proto.make -checkargs.c -class.c -class.h -inpdef.str -l_print3ack.c -lint -lint.1 -lpass2.c -private.h -read.c -report.c diff --git a/lang/cem/pmfile b/lang/cem/pmfile deleted file mode 100644 index ca8eacd21..000000000 --- a/lang/cem/pmfile +++ /dev/null @@ -1,9 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/cem/" - --- include (d.."cemcom/pmfile") -include (d.."cemcom.ansi/pmfile") --- include (d.."libcc/pmfile") -include (d.."libcc.ansi/pmfile") diff --git a/lang/fortran/.distr b/lang/fortran/.distr deleted file mode 100644 index a9f8e4fd8..000000000 --- a/lang/fortran/.distr +++ /dev/null @@ -1,7 +0,0 @@ -changes -comp -disclaimer -fc -fixes -index -lib diff --git a/lang/fortran/comp/.distr b/lang/fortran/comp/.distr deleted file mode 100644 index 0c4266d77..000000000 --- a/lang/fortran/comp/.distr +++ /dev/null @@ -1,61 +0,0 @@ -Notice -README -cds.c -data.c -defines.h -defs.h -equiv.c -error.c -exec.c -expr.c -f2c.1 -f2c.1t -f2c.6 -f2c.h -format.c -format.h -formatdata.c -ftypes.h -gram.dcl -gram.exec -gram.expr -gram.head -gram.io -init.c -intr.c -io.c -iob.h -lex.c -machdefs.h -main.c -makefile -malloc.c -mem.c -memset.c -misc.c -names.c -names.h -niceprintf.c -niceprintf.h -output.c -output.h -p1defs.h -p1output.c -parse.h -parse_args.c -pccdefs.h -pread.c -proc.c -proto.make -put.c -putpcc.c -string.h -sysdep.c -sysdep.h -tokens -usignal.h -vax.c -version.c -xsum.c -xsum0.out -mk_tokdefs diff --git a/lang/fortran/lib/.distr b/lang/fortran/lib/.distr deleted file mode 100644 index 254dfd229..000000000 --- a/lang/fortran/lib/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libF77 -libI77 diff --git a/lang/fortran/lib/libF77/.distr b/lang/fortran/lib/libF77/.distr deleted file mode 100644 index 555cf9635..000000000 --- a/lang/fortran/lib/libF77/.distr +++ /dev/null @@ -1,118 +0,0 @@ -LIST -Notice -README -Version.c -abort_.c -c_abs.c -c_cos.c -c_div.c -c_exp.c -c_log.c -c_sin.c -c_sqrt.c -cabs.c -d_abs.c -d_acos.c -d_asin.c -d_atan.c -d_atn2.c -d_cnjg.c -d_cos.c -d_cosh.c -d_dim.c -d_exp.c -d_imag.c -d_int.c -d_lg10.c -d_log.c -d_mod.c -d_nint.c -d_prod.c -d_sign.c -d_sin.c -d_sinh.c -d_sqrt.c -d_tan.c -d_tanh.c -derf_.c -derfc_.c -ef1asc_.c -ef1cmc_.c -erf_.c -erfc_.c -getarg_.c -getenv_.c -h_abs.c -h_dim.c -h_dnnt.c -h_indx.c -h_len.c -h_mod.c -h_nint.c -h_sign.c -hl_ge.c -hl_gt.c -hl_le.c -hl_lt.c -i_abs.c -i_dim.c -i_dnnt.c -i_indx.c -i_len.c -i_mod.c -i_nint.c -i_sign.c -iargc_.c -l_ge.c -l_gt.c -l_le.c -l_lt.c -libF77.xsum -main.c -makefile -pow_ci.c -pow_dd.c -pow_di.c -pow_hh.c -pow_ii.c -pow_ri.c -pow_zi.c -pow_zz.c -r_abs.c -r_acos.c -r_asin.c -r_atan.c -r_atn2.c -r_cnjg.c -r_cos.c -r_cosh.c -r_dim.c -r_exp.c -r_imag.c -r_int.c -r_lg10.c -r_log.c -r_mod.c -r_nint.c -r_sign.c -r_sin.c -r_sinh.c -r_sqrt.c -r_tan.c -r_tanh.c -s_cat.c -s_cmp.c -s_copy.c -s_paus.c -s_rnge.c -s_stop.c -sig_die.c -signal_.c -system_.c -z_abs.c -z_cos.c -z_div.c -z_exp.c -z_log.c -z_sin.c -z_sqrt.c diff --git a/lang/fortran/lib/libI77/.distr b/lang/fortran/lib/libI77/.distr deleted file mode 100644 index 866b3077f..000000000 --- a/lang/fortran/lib/libI77/.distr +++ /dev/null @@ -1,42 +0,0 @@ -LIST -Notice -README -Version.c -backspace.c -close.c -dfe.c -dolio.c -due.c -endfile.c -err.c -fio.h -fmt.c -fmt.h -fmtlib.c -fp.h -iio.c -ilnw.c -inquire.c -libI77.xsum -lio.h -local.h -lread.c -lwrite.c -makefile -open.c -rdfmt.c -rewind.c -rsfe.c -rsli.c -rsne.c -sfe.c -sue.c -typesize.c -uio.c -util.c -wref.c -wrtfmt.c -wsfe.c -wsle.c -wsne.c -xwsne.c diff --git a/lang/m2/.distr b/lang/m2/.distr deleted file mode 100644 index 9ed8b06d4..000000000 --- a/lang/m2/.distr +++ /dev/null @@ -1,3 +0,0 @@ -pmfile -comp -libm2 diff --git a/lang/m2/comp/.distr b/lang/m2/comp/.distr deleted file mode 100644 index 1ea799dbd..000000000 --- a/lang/m2/comp/.distr +++ /dev/null @@ -1,61 +0,0 @@ -pmfile -LLlex.c -LLlex.h -LLmessage.c -BigPars -SmallPars -SYSTEM.h -casestat.C -char.tab -chk_expr.c -chk_expr.h -class.h -code.c -cstoper.c -debug.h -declar.g -def.H -def.c -defmodule.c -desig.c -desig.h -em_m2.6 -enter.c -error.c -expression.g -f_info.h -idf.c -idf.h -input.c -input.h -lookup.c -main.c -main.h -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -misc.c -misc.h -modula-2.1 -node.H -node.c -options.c -options -program.g -real.H -scope.C -scope.h -stab.c -standards.h -statement.g -tmpvar.C -tokenname.c -tokenname.h -type.H -type.c -typequiv.c -walk.c -walk.h -warning.h diff --git a/lang/m2/comp/LLlex.c b/lang/m2/comp/LLlex.c index edd166490..1eacae76f 100644 --- a/lang/m2/comp/LLlex.c +++ b/lang/m2/comp/LLlex.c @@ -13,10 +13,8 @@ #include #include +#include "parameters.h" #include "debug.h" -#include "idfsize.h" -#include "numsize.h" -#include "strsize.h" #include "alloc.h" #include "em_arith.h" @@ -32,7 +30,6 @@ #include "def.h" #include "type.h" #include "warning.h" -#include "errout.h" extern char *getwdir(); @@ -191,55 +188,57 @@ CheckForLineDirective() register char *c = buf; - if (ch != '#') { - PushBack(); - return; - } - do { /* - * Skip to next digit - * Do not skip newlines - */ - ch = getch(); - if (class(ch) == STNL || class(ch) == STEOI) { - LineNumber++; - error(s_error); + for (;;) { + if (ch != '#') { + PushBack(); return; } - } while (class(ch) != STNUM); - while (class(ch) == STNUM) { - i = i*10 + (ch - '0'); - ch = getch(); - } - while (ch != '"' && class(ch) != STNL && class(ch) != STEOI) - ch = getch(); - if (ch == '"') { - c = buf; - do { + do { /* + * Skip to next digit + * Do not skip newlines + */ ch = getch(); - if (c < &buf[IDFSIZE]) *c++ = ch; if (class(ch) == STNL || class(ch) == STEOI) { LineNumber++; error(s_error); return; } - } while (ch != '"'); - *--c = '\0'; - do { + } while (class(ch) != STNUM); + while (class(ch) == STNUM) { + i = i*10 + (ch - '0'); ch = getch(); - } while (class(ch) != STNL && class(ch) != STEOI); - /* - * Remember the file name - */ - if (class(ch) == STNL && strcmp(FileName,buf)) { - FileName = Salloc(buf,(unsigned) strlen(buf) + 1); - WorkingDir = getwdir(FileName); } + while (ch != '"' && class(ch) != STNL && class(ch) != STEOI) + ch = getch(); + if (ch == '"') { + c = buf; + do { + ch = getch(); + if (c < &buf[IDFSIZE]) *c++ = ch; + if (class(ch) == STNL || class(ch) == STEOI) { + LineNumber++; + error(s_error); + return; + } + } while (ch != '"'); + *--c = '\0'; + do { + ch = getch(); + } while (class(ch) != STNL && class(ch) != STEOI); + /* + * Remember the file name + */ + if (class(ch) == STNL && strcmp(FileName,buf)) { + FileName = Salloc(buf,(unsigned) strlen(buf) + 1); + WorkingDir = getwdir(FileName); + } + } + if (class(ch) == STEOI) { + error(s_error); + return; + } + LineNumber = i; } - if (class(ch) == STEOI) { - error(s_error); - return; - } - LineNumber = i; } STATIC diff --git a/lang/m2/comp/LLmessage.c b/lang/m2/comp/LLmessage.c index f8bc0cc43..673083f0b 100644 --- a/lang/m2/comp/LLmessage.c +++ b/lang/m2/comp/LLmessage.c @@ -19,6 +19,7 @@ #include #include +#include "parameters.h" #include "idf.h" #include "LLlex.h" #include "Lpars.h" diff --git a/lang/m2/comp/build.lua b/lang/m2/comp/build.lua new file mode 100644 index 000000000..95c4a30d7 --- /dev/null +++ b/lang/m2/comp/build.lua @@ -0,0 +1,134 @@ +normalrule { + name = "tokenfile_g", + ins = { + "./make.tokfile", + "./tokenname.c" + }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +llgen { + name = "llgen", + srcs = { + -- order here is important + "+tokenfile_g", + "./*.g", + } +} + +normalrule { + name = "parameters_h", + ins = { + "./make.parameters", + "./BigPars", + }, + outleaves = { "parameters.h" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +for _, f in ipairs(filenamesof("./*.H")) do + local name = replace(basename(f), "%.H$", "") + normalrule { + name = name.."_h", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".h" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +for _, f in ipairs(filenamesof("./*.C")) do + local name = replace(basename(f), "%.C$", "") + normalrule { + name = name.."_c", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +normalrule { + name = "next_c", + ins = { + "./make.next", + "./*.H", + "./*.C", + }, + outleaves = { "next.c" }, + commands = { + "sh %{ins} > %{outs}" + } +} + +normalrule { + name = "symbol2str_c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } +} + +tabgen { + name = "chartab_c", + srcs = { "./char.tab" }, +} + +cprogram { + name = "em_m2", + srcs = { + "./*.c", + "+casestat_c", + "+next_c", + "+scope_c", + "+symbol2str_c", + "+tmpvar_c", + "+chartab_c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+def_h", + "+llgen", + "+node_h", + "+parameters_h", + "+real_h", + "+type_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/em_data+lib", + "modules/src/em_mes+lib", + "modules/src/flt_arith+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_m2"] = "+em_m2", + ["$(INSDIR)/share/man/man6/em_m2.6"] = "./em_m2.6" + } +} diff --git a/lang/m2/comp/casestat.C b/lang/m2/comp/casestat.C index d5bedf503..d227e3117 100644 --- a/lang/m2/comp/casestat.C +++ b/lang/m2/comp/casestat.C @@ -16,6 +16,7 @@ cases themselves. */ +#include "parameters.h" #include "debug.h" #include @@ -33,8 +34,6 @@ #include "chk_expr.h" #include "def.h" -#include "density.h" - struct switch_hdr { label sh_break; /* label of statement after this one */ label sh_default; /* label of ELSE part, or 0 */ diff --git a/lang/m2/comp/chk_expr.c b/lang/m2/comp/chk_expr.c index d9a39c3a2..7dbe5abc6 100644 --- a/lang/m2/comp/chk_expr.c +++ b/lang/m2/comp/chk_expr.c @@ -14,6 +14,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include @@ -21,7 +22,6 @@ #include #include -#include "strict3rd.h" #include "Lpars.h" #include "idf.h" #include "type.h" @@ -34,7 +34,6 @@ #include "misc.h" #include "warning.h" #include "main.h" -#include "nostrict.h" extern char *symbol2str(); extern char *sprint(); diff --git a/lang/m2/comp/code.c b/lang/m2/comp/code.c index e0d05c584..f74231cb0 100644 --- a/lang/m2/comp/code.c +++ b/lang/m2/comp/code.c @@ -12,6 +12,7 @@ /* Code generation for expressions and coercions */ +#include "parameters.h" #include "debug.h" #include @@ -30,7 +31,6 @@ #include "Lpars.h" #include "standards.h" #include "walk.h" -#include "bigresult.h" extern int proclevel; extern char options[]; diff --git a/lang/m2/comp/cstoper.c b/lang/m2/comp/cstoper.c index fafb560f2..c55d4389f 100644 --- a/lang/m2/comp/cstoper.c +++ b/lang/m2/comp/cstoper.c @@ -9,9 +9,9 @@ /* $Id$ */ +#include +#include "parameters.h" #include "debug.h" -#include "target_sizes.h" -#include "uns_arith.h" #include #include diff --git a/lang/m2/comp/debug.h b/lang/m2/comp/debug.h index 865168335..1c2c34cb2 100644 --- a/lang/m2/comp/debug.h +++ b/lang/m2/comp/debug.h @@ -9,8 +9,6 @@ /* $Id$ */ -#include "debugcst.h" - #ifdef DEBUG #define DO_DEBUG(x, y) ((x) && (y)) #define STATIC diff --git a/lang/m2/comp/declar.g b/lang/m2/comp/declar.g index 9d7816e0c..49dac19c5 100644 --- a/lang/m2/comp/declar.g +++ b/lang/m2/comp/declar.g @@ -10,6 +10,7 @@ /* $Id$ */ { +#include "parameters.h" #include "debug.h" #include @@ -17,7 +18,6 @@ #include #include -#include "strict3rd.h" #include "idf.h" #include "LLlex.h" #include "def.h" @@ -28,7 +28,6 @@ #include "main.h" #include "chk_expr.h" #include "warning.h" -#include "nostrict.h" int proclevel = 0; /* nesting level of procedures */ int return_occurred; /* set if a return occurs in a block */ diff --git a/lang/m2/comp/def.c b/lang/m2/comp/def.c index 711f2d7e4..586875f5e 100644 --- a/lang/m2/comp/def.c +++ b/lang/m2/comp/def.c @@ -11,6 +11,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/defmodule.c b/lang/m2/comp/defmodule.c index e327f309b..f26168a28 100644 --- a/lang/m2/comp/defmodule.c +++ b/lang/m2/comp/defmodule.c @@ -9,8 +9,10 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" +#include #include #include #include diff --git a/lang/m2/comp/desig.c b/lang/m2/comp/desig.c index 5550b2720..f2ea83a81 100644 --- a/lang/m2/comp/desig.c +++ b/lang/m2/comp/desig.c @@ -16,6 +16,7 @@ or perform a store. */ +#include "parameters.h" #include "debug.h" #include @@ -32,7 +33,6 @@ #include "node.h" #include "warning.h" #include "walk.h" -#include "squeeze.h" extern int proclevel; extern arith NewPtr(); diff --git a/lang/m2/comp/enter.c b/lang/m2/comp/enter.c index 002caa838..12f3e4e9d 100644 --- a/lang/m2/comp/enter.c +++ b/lang/m2/comp/enter.c @@ -13,6 +13,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include "alloc.h" @@ -21,7 +22,6 @@ #include "em_code.h" #include "assert.h" -#include "dbsymtab.h" #include "idf.h" #include "LLlex.h" #include "def.h" diff --git a/lang/m2/comp/error.c b/lang/m2/comp/error.c index 2c265f7b6..410f7d15f 100644 --- a/lang/m2/comp/error.c +++ b/lang/m2/comp/error.c @@ -14,7 +14,7 @@ number of arguments! */ -#include "errout.h" +#include "parameters.h" #include "debug.h" #if __STDC__ @@ -28,14 +28,12 @@ #include #include -#include "strict3rd.h" #include "input.h" #include "f_info.h" #include "LLlex.h" #include "main.h" #include "node.h" #include "warning.h" -#include "nostrict.h" /* error classes */ #define ERROR 1 diff --git a/lang/m2/comp/expression.g b/lang/m2/comp/expression.g index 431b3aa93..1fe8024d3 100644 --- a/lang/m2/comp/expression.g +++ b/lang/m2/comp/expression.g @@ -10,6 +10,7 @@ /* $Id$ */ { +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/idf.c b/lang/m2/comp/idf.c index 471c5f5e8..697b3e011 100644 --- a/lang/m2/comp/idf.c +++ b/lang/m2/comp/idf.c @@ -9,5 +9,6 @@ /* $Id$ */ +#include "parameters.h" #include "idf.h" #include diff --git a/lang/m2/comp/input.c b/lang/m2/comp/input.c index 4c516a44e..ef8ee2982 100644 --- a/lang/m2/comp/input.c +++ b/lang/m2/comp/input.c @@ -12,6 +12,7 @@ #include #include #include +#include "parameters.h" #include "f_info.h" struct f_info file_info; #include "input.h" diff --git a/lang/m2/comp/input.h b/lang/m2/comp/input.h index 3a557a9f3..23c1ac582 100644 --- a/lang/m2/comp/input.h +++ b/lang/m2/comp/input.h @@ -9,8 +9,6 @@ /* $Id$ */ -#include "inputtype.h" - #define INP_NPUSHBACK 2 #define INP_TYPE struct f_info #define INP_VAR file_info diff --git a/lang/m2/comp/lookup.c b/lang/m2/comp/lookup.c index 39708353e..6d58791d6 100644 --- a/lang/m2/comp/lookup.c +++ b/lang/m2/comp/lookup.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/main.c b/lang/m2/comp/main.c index 4b181eb83..a21ecf8a5 100644 --- a/lang/m2/comp/main.c +++ b/lang/m2/comp/main.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include @@ -19,8 +20,6 @@ #include #include -#include "strict3rd.h" -#include "dbsymtab.h" #include "input.h" #include "f_info.h" #include "idf.h" diff --git a/lang/m2/comp/make.parameters b/lang/m2/comp/make.parameters new file mode 100755 index 000000000..3c9a515c5 --- /dev/null +++ b/lang/m2/comp/make.parameters @@ -0,0 +1,7 @@ +#!/bin/sh + +echo '#ifndef PARAMETERS_H' +echo '#define PARAMETERS_H' +grep -v '^!' +echo '#endif' + diff --git a/lang/m2/comp/misc.c b/lang/m2/comp/misc.c index d7a88ea5a..ada35fb02 100644 --- a/lang/m2/comp/misc.c +++ b/lang/m2/comp/misc.c @@ -17,6 +17,7 @@ #include "em_arith.h" #include "em_label.h" +#include "parameters.h" #include "f_info.h" #include "misc.h" #include "LLlex.h" diff --git a/lang/m2/comp/node.c b/lang/m2/comp/node.c index 2e2302504..910769e0d 100644 --- a/lang/m2/comp/node.c +++ b/lang/m2/comp/node.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/options.c b/lang/m2/comp/options.c index 568101cb3..b4b734fef 100644 --- a/lang/m2/comp/options.c +++ b/lang/m2/comp/options.c @@ -9,21 +9,16 @@ /* $Id$ */ -#include "idfsize.h" +#include "parameters.h" #include #include #include -#include "strict3rd.h" -#include "dbsymtab.h" #include "type.h" #include "main.h" #include "warning.h" -#include "nostrict.h" -#include "nocross.h" #include "class.h" -#include "squeeze.h" #define MINIDFSIZE 14 diff --git a/lang/m2/comp/pmfile b/lang/m2/comp/pmfile deleted file mode 100644 index 0e245b9cc..000000000 --- a/lang/m2/comp/pmfile +++ /dev/null @@ -1,177 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/m2/comp/" - -local extract_parameters = simple { - outputs = { - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/strsize.h", - "%U%/target_sizes.h", - "%U%/debugcst.h", - "%U%/inputtype.h", - "%U%/density.h", - "%U%/squeeze.h", - "%U%/strict3rd.h", - "%U%/nocross.h", - "%U%/nostrict.h", - "%U%/bigresult.h", - "%U%/dbsymtab.h", - "%U%/use_insert.h", - "%U%/uns_arith.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."BigPars") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."program.g"), - file (d.."declar.g"), - file (d.."expression.g"), - file (d.."statement.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/def.h"}, (d.."def.H") }, - allocd_header { outputs = {"%U%/type.h"}, (d.."type.H") }, - allocd_header { outputs = {"%U%/real.h"}, (d.."real.H") }, - allocd_header { outputs = {"%U%/node.h"}, (d.."node.H") }, - lpars - } -} - -lang_m2_compiler = cprogram { - CDEFINES = {PARENT, "STATIC=static"}, - - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."type.c"), - cfile_with_headers (d.."def.c"), - cfile_with_headers (d.."misc.c"), - cfile_with_headers (d.."enter.c"), - cfile_with_headers (d.."defmodule.c"), - cfile_with_headers (d.."typequiv.c"), - cfile_with_headers (d.."node.c"), - cfile_with_headers (d.."cstoper.c"), - cfile_with_headers (d.."chk_expr.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."walk.c"), - cfile_with_headers (d.."desig.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."lookup.c"), - cfile_with_headers (d.."stab.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."def.H"), - file (d.."type.H"), - file (d.."real.H"), - file (d.."node.H"), - file (d.."scope.C"), - file (d.."tmpvar.C"), - file (d.."casestat.C"), - } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-scope.c"}, (d.."scope.C") } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-tmpvar.c"}, (d.."tmpvar.C") } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-casestat.c"}, (d.."casestat.C") } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_input, - lib_assert, - lib_alloc, - lib_flt_arith, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_m2"}, - install = { - pm.install( "%BINDIR%%PLATDEP%/em_m2"), - pm.install(d.."em_m2.6", "%BINDIR%/man/man6/em_m2.6"), - } -} - --- Revision history --- $Log$ --- Revision 1.3 2006-10-15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/26 18:19:15 dtrg --- Tweaked the CVS settings. --- --- Revision 1.1 2006/07/26 17:12:19 dtrg --- Added support for the Modula-2 compiler. \ No newline at end of file diff --git a/lang/m2/comp/program.g b/lang/m2/comp/program.g index 05fedef61..e8ea7a0f3 100644 --- a/lang/m2/comp/program.g +++ b/lang/m2/comp/program.g @@ -12,6 +12,7 @@ { #include #include +#include "parameters.h" #include "debug.h" #include @@ -20,8 +21,6 @@ #include #include -#include "dbsymtab.h" -#include "strict3rd.h" #include "main.h" #include "idf.h" #include "LLlex.h" diff --git a/lang/m2/comp/scope.C b/lang/m2/comp/scope.C index 796475c23..085662232 100644 --- a/lang/m2/comp/scope.C +++ b/lang/m2/comp/scope.C @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/stab.c b/lang/m2/comp/stab.c index 54bf67408..5aae2a1e5 100644 --- a/lang/m2/comp/stab.c +++ b/lang/m2/comp/stab.c @@ -9,7 +9,7 @@ /* $Id$ */ -#include "dbsymtab.h" +#include "parameters.h" #ifdef DBSYMTAB diff --git a/lang/m2/comp/statement.g b/lang/m2/comp/statement.g index 0a60226e1..ca5e72bb3 100644 --- a/lang/m2/comp/statement.g +++ b/lang/m2/comp/statement.g @@ -14,6 +14,7 @@ #include #include +#include "parameters.h" #include "idf.h" #include "LLlex.h" #include "scope.h" diff --git a/lang/m2/comp/tmpvar.C b/lang/m2/comp/tmpvar.C index da91114e1..03acdaba0 100644 --- a/lang/m2/comp/tmpvar.C +++ b/lang/m2/comp/tmpvar.C @@ -16,6 +16,7 @@ have local variabes. */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/m2/comp/tokenname.c b/lang/m2/comp/tokenname.c index be72a8418..cea9139b4 100644 --- a/lang/m2/comp/tokenname.c +++ b/lang/m2/comp/tokenname.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "tokenname.h" #include "Lpars.h" #include "idf.h" diff --git a/lang/m2/comp/type.H b/lang/m2/comp/type.H index b677fa516..588ef28c7 100644 --- a/lang/m2/comp/type.H +++ b/lang/m2/comp/type.H @@ -9,8 +9,6 @@ /* $Id$ */ -#include "dbsymtab.h" - struct paramlist { /* structure for parameterlist of a PROCEDURE */ struct paramlist *par_next; struct def *par_def; /* "df" of parameter */ @@ -142,9 +140,7 @@ extern t_type *std_type, *error_type; /* All from type.c */ -#include "nocross.h" #ifdef NOCROSS -#include "target_sizes.h" #define word_align (AL_WORD) #define short_align (AL_SHORT) #define int_align (AL_INT) diff --git a/lang/m2/comp/type.c b/lang/m2/comp/type.c index fa0283d73..247e5e280 100644 --- a/lang/m2/comp/type.c +++ b/lang/m2/comp/type.c @@ -9,6 +9,7 @@ /* $Id$ */ +#include "parameters.h" #include "debug.h" #include @@ -17,7 +18,6 @@ #include #include -#include "nostrict.h" #include "LLlex.h" #include "def.h" #include "type.h" @@ -28,10 +28,8 @@ #include "main.h" #include "chk_expr.h" #include "warning.h" -#include "uns_arith.h" #ifndef NOCROSS -#include "target_sizes.h" int word_align = AL_WORD, short_align = AL_SHORT, diff --git a/lang/m2/comp/typequiv.c b/lang/m2/comp/typequiv.c index 2a3efbb7c..017e7a1d0 100644 --- a/lang/m2/comp/typequiv.c +++ b/lang/m2/comp/typequiv.c @@ -12,13 +12,13 @@ /* Routines for testing type equivalence, type compatibility, and assignment compatibility */ +#include "parameters.h" #include "debug.h" #include #include #include -#include "strict3rd.h" #include "type.h" #include "LLlex.h" #include "idf.h" diff --git a/lang/m2/comp/walk.c b/lang/m2/comp/walk.c index c79daed19..de9a63552 100644 --- a/lang/m2/comp/walk.c +++ b/lang/m2/comp/walk.c @@ -15,6 +15,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include @@ -26,8 +27,6 @@ #include #include -#include "strict3rd.h" -#include "dbsymtab.h" #include "LLlex.h" #include "def.h" #include "type.h" @@ -42,8 +41,6 @@ #include "walk.h" #include "misc.h" #include "warning.h" -#include "bigresult.h" -#include "use_insert.h" extern arith NewPtr(); extern arith NewInt(); diff --git a/lang/m2/comp/walk.h b/lang/m2/comp/walk.h index c81a57a59..cf43c3074 100644 --- a/lang/m2/comp/walk.h +++ b/lang/m2/comp/walk.h @@ -19,8 +19,6 @@ extern int (*WalkTable[])(); extern label text_label; extern label data_label; -#include "squeeze.h" - #ifndef SQUEEZE #define c_loc(x) C_loc((arith) (x)) #define c_lae_dlb(x) C_lae_dlb(x,(arith) 0) diff --git a/lang/m2/libm2/.distr b/lang/m2/libm2/.distr deleted file mode 100644 index 2cbf40d17..000000000 --- a/lang/m2/libm2/.distr +++ /dev/null @@ -1,74 +0,0 @@ -pmfile -Termcap.mod -CSP.mod -PascalIO.mod -RealInOut.mod -InOut.mod -Streams.mod -Terminal.mod -MathLib0.mod -Mathlib.mod -Processes.mod -RealConver.mod -Storage.mod -Conversion.mod -Semaphores.mod -random.mod -Strings.mod -ArraySort.mod -catch.c -Traps.mod -XXTermcap.c -dvi.c -Arguments.c -LtoUset.e -StrAss.c -cap.c -absd.c -absf.e -absi.c -absl.c -halt.c -SYSTEM.c -par_misc.e -init.c -sigtrp.c -store.c -confarray.c -load.c -blockmove.c -stackprio.c -ucheck.c -rcka.c -rcku.c -rcki.c -rckul.c -rckil.c -EM.e -ASCII.def -Arguments.def -Conversion.def -EM.def -PascalIO.def -InOut.def -Mathlib.def -MathLib0.def -Processes.def -RealInOut.def -RealConver.def -Semaphores.def -Storage.def -Strings.def -Terminal.def -Unix.def -head_m2.e -random.def -Traps.def -CSP.def -Epilogue.def -Streams.def -ArraySort.def -StripUnix.def -Termcap.def -XXTermcap.def -proto.make diff --git a/lang/m2/libm2/build.lua b/lang/m2/libm2/build.lua new file mode 100644 index 000000000..d0861b966 --- /dev/null +++ b/lang/m2/libm2/build.lua @@ -0,0 +1,58 @@ +include("plat/build.lua") + +local installmap = {} + +local function addheader(dir, list) + for _, f in ipairs(list) do + local b = basename(f) + installmap[concatpath("$(PLATIND)/include/modula2/", dir, b)] = f + end +end + +addheader("", filenamesof("./*.def")) + +installable { + name = "headers", + map = installmap +} + +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./*.c", + "./*.mod", + "./EM.e", + "./LtoUset.e", + "./absf.e", + "./par_misc.e", + }, + hdrs = {}, -- must be empty + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/"..plat.."/include+headers", + "h+emheaders", + }, + vars = { plat = plat } + } + + ackfile { + name = "mrt_"..plat, + srcs = { "./head_m2.e" }, + vars = { plat = plat }, + deps = { + "h+emheaders" + } + } + + installable { + name = "pkg_"..plat, + map = { + ["$(PLATIND)/"..plat.."/modula2.o"] = "+mrt_"..plat, + ["$(PLATIND)/"..plat.."/libmodula2.a"] = "+lib_"..plat, + "+headers", + } + } +end + + diff --git a/lang/m2/libm2/pmfile b/lang/m2/libm2/pmfile deleted file mode 100644 index 5b629dd07..000000000 --- a/lang/m2/libm2/pmfile +++ /dev/null @@ -1,99 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/m2/libm2/" - -local headers = group { - install = { - pm.install(d.."Arguments.def", "%BINDIR%include/m2/Arguments.def"), - pm.install(d.."ArraySort.def", "%BINDIR%include/m2/ArraySort.def"), - pm.install(d.."ASCII.def", "%BINDIR%include/m2/ASCII.def"), - pm.install(d.."Conversion.def", "%BINDIR%include/m2/Conversion.def"), - pm.install(d.."CSP.def", "%BINDIR%include/m2/CSP.def"), - pm.install(d.."EM.def", "%BINDIR%include/m2/EM.def"), - pm.install(d.."Epilogue.def", "%BINDIR%include/m2/Epilogue.def"), - pm.install(d.."InOut.def", "%BINDIR%include/m2/InOut.def"), - pm.install(d.."MathLib0.def", "%BINDIR%include/m2/MathLib0.def"), - pm.install(d.."Mathlib.def", "%BINDIR%include/m2/Mathlib.def"), - pm.install(d.."PascalIO.def", "%BINDIR%include/m2/PascalIO.def"), - pm.install(d.."Processes.def", "%BINDIR%include/m2/Processes.def"), - pm.install(d.."random.def", "%BINDIR%include/m2/random.def"), - pm.install(d.."RealConver.def", "%BINDIR%include/m2/RealConver.def"), - pm.install(d.."RealInOut.def", "%BINDIR%include/m2/RealInOut.def"), - pm.install(d.."Semaphores.def", "%BINDIR%include/m2/Semaphores.def"), - pm.install(d.."Storage.def", "%BINDIR%include/m2/Storage.def"), - pm.install(d.."Streams.def", "%BINDIR%include/m2/Streams.def"), - pm.install(d.."Strings.def", "%BINDIR%include/m2/Strings.def"), - pm.install(d.."StripUnix.def", "%BINDIR%include/m2/StripUnix.def"), - pm.install(d.."Termcap.def", "%BINDIR%include/m2/Termcap.def"), --- pm.install(d.."Terminal.def", "%BINDIR%include/m2/Terminal.def"), - pm.install(d.."Traps.def", "%BINDIR%include/m2/Traps.def"), - pm.install(d.."Unix.def", "%BINDIR%include/m2/Unix.def"), - pm.install(d.."XXTermcap.def", "%BINDIR%include/m2/XXTermcap.def"), - } -} - -local head = ackfile { - file (d.."head_m2.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/modula2.o") -} - -local tail = acklibrary { - ackfile (d.."Termcap.mod"), - ackfile (d.."CSP.mod"), - ackfile (d.."PascalIO.mod"), - ackfile (d.."RealInOut.mod"), - ackfile (d.."InOut.mod"), - ackfile (d.."Streams.mod"), --- ackfile (d.."Terminal.mod"), - ackfile (d.."MathLib0.mod"), - ackfile (d.."Mathlib.mod"), - ackfile (d.."Processes.mod"), - ackfile (d.."RealConver.mod"), - ackfile (d.."Storage.mod"), - ackfile (d.."Conversion.mod"), - ackfile (d.."Semaphores.mod"), - ackfile (d.."random.mod"), - ackfile (d.."Strings.mod"), - ackfile (d.."ArraySort.mod"), - ackfile (d.."catch.c"), - ackfile (d.."Traps.mod"), - ackfile (d.."XXTermcap.c"), - ackfile (d.."dvi.c"), - ackfile (d.."Arguments.c"), - ackfile (d.."LtoUset.e"), - ackfile (d.."StrAss.c"), - ackfile (d.."cap.c"), - ackfile (d.."absd.c"), - ackfile (d.."absf.e"), - ackfile (d.."absi.c"), - ackfile (d.."absl.c"), - ackfile (d.."halt.c"), - ackfile (d.."SYSTEM.c"), - ackfile (d.."par_misc.e"), - ackfile (d.."init.c"), - ackfile (d.."sigtrp.c"), - ackfile (d.."store.c"), - ackfile (d.."confarray.c"), - ackfile (d.."load.c"), - ackfile (d.."blockmove.c"), - ackfile (d.."stackprio.c"), - ackfile (d.."ucheck.c"), - ackfile (d.."rcka.c"), - ackfile (d.."rcku.c"), - ackfile (d.."rcki.c"), - ackfile (d.."rckul.c"), - ackfile (d.."rckil.c"), - ackfile (d.."EM.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libmodula2.a") -} - -lang_m2_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - headers, - head, - tail -} diff --git a/lang/m2/m2mm/.distr b/lang/m2/m2mm/.distr deleted file mode 100644 index 3a8bc4308..000000000 --- a/lang/m2/m2mm/.distr +++ /dev/null @@ -1,30 +0,0 @@ -LLlex.c -LLlex.h -LLmessage.c -proto.make -proto.main -char.tab -class.h -declar.g -error.c -expression.g -f_info.h -file_list.h -idf.c -idf.h -idfsize.h -input.c -input.h -inputtype.h -lib.c -m2mm.1 -main.c -main.h -make.tokcase -make.tokfile -misc.c -options.c -program.g -statement.g -tokenname.c -tokenname.h diff --git a/lang/m2/pmfile b/lang/m2/pmfile deleted file mode 100644 index 59270fd62..000000000 --- a/lang/m2/pmfile +++ /dev/null @@ -1,7 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/m2/" - -include (d.."comp/pmfile") -include (d.."libm2/pmfile") diff --git a/lang/m2/test/.distr b/lang/m2/test/.distr deleted file mode 100644 index 35e4dd24b..000000000 --- a/lang/m2/test/.distr +++ /dev/null @@ -1,5 +0,0 @@ -Thalmann -Wirth -getenv.mod -m2p.mod -queens.mod diff --git a/lang/m2/test/Thalmann/.distr b/lang/m2/test/Thalmann/.distr deleted file mode 100644 index f76368222..000000000 --- a/lang/m2/test/Thalmann/.distr +++ /dev/null @@ -1,5 +0,0 @@ -LifeGame.mod -Shoes.mod -StoreFetch.mod -bold.mod -characters.mod diff --git a/lang/m2/test/Wirth/.distr b/lang/m2/test/Wirth/.distr deleted file mode 100644 index 7f345b414..000000000 --- a/lang/m2/test/Wirth/.distr +++ /dev/null @@ -1,4 +0,0 @@ -PowersOf2.mod -TableHandl.def -TableHandl.mod -XREF.mod diff --git a/lang/occam/.distr b/lang/occam/.distr deleted file mode 100644 index 475b9ed71..000000000 --- a/lang/occam/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -comp -lib -test -headers diff --git a/lang/occam/comp/.distr b/lang/occam/comp/.distr deleted file mode 100644 index d220a92fb..000000000 --- a/lang/occam/comp/.distr +++ /dev/null @@ -1,16 +0,0 @@ -pmfile -builtin.c -code.c -code.h -em.c -expr.c -expr.h -keytab.c -lex.l -occam.g -report.c -sizes.h -symtab.c -symtab.h -token.h -occam-em.h \ No newline at end of file diff --git a/lang/occam/comp/pmfile b/lang/occam/comp/pmfile deleted file mode 100644 index 3a862d87d..000000000 --- a/lang/occam/comp/pmfile +++ /dev/null @@ -1,62 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/occam/comp/" - -local lpars = LLgen { - file (d.."occam.g"), -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - lpars - } -} - -lang_occam_compiler = cprogram { - CLIBRARIES = {PARENT, "fl"}, - - cfile_with_headers (d.."builtin.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."em.c"), - cfile_with_headers (d.."expr.c"), - cfile_with_headers (d.."keytab.c"), - cfile_with_headers (d.."report.c"), - cfile_with_headers (d.."symtab.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - flex (d.."lex.l") - }, - - lib_em_mes, - lib_emk, - lib_em_data, --- lib_input, --- lib_assert, - lib_alloc, --- lib_flt_arith, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_occam"}, - install = { - pm.install("%BINDIR%%PLATDEP%/em_occam"), - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-10-15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/26 18:23:32 dtrg --- Added support for the Occam compiler. --- \ No newline at end of file diff --git a/lang/occam/headers/.distr b/lang/occam/headers/.distr deleted file mode 100644 index c5db45ffa..000000000 --- a/lang/occam/headers/.distr +++ /dev/null @@ -1,3 +0,0 @@ -dec.ocm -printd.ocm -prints.ocm diff --git a/lang/occam/lib/.distr b/lang/occam/lib/.distr deleted file mode 100644 index 1f306717f..000000000 --- a/lang/occam/lib/.distr +++ /dev/null @@ -1,11 +0,0 @@ -pmfile -builtin.c -chan_strct.c -channel.c -co.c -now.c -par.c -parco.c -misc.e -ocrt.c -par_misc.e diff --git a/lang/occam/lib/pmfile b/lang/occam/lib/pmfile deleted file mode 100644 index 4ed36f62a..000000000 --- a/lang/occam/lib/pmfile +++ /dev/null @@ -1,21 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/occam/lib/" - -lang_occam_lib_runtime = acklibrary { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - ackfile (d.."builtin.c"), - ackfile (d.."chan_strct.c"), - ackfile (d.."channel.c"), - ackfile (d.."co.c"), - ackfile (d.."misc.e"), - ackfile (d.."now.c"), - ackfile (d.."ocrt.c"), - ackfile (d.."par.c"), - ackfile (d.."par_misc.e"), - ackfile (d.."parco.c"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/liboccam.a") -} diff --git a/lang/occam/pmfile b/lang/occam/pmfile deleted file mode 100644 index 7c46574af..000000000 --- a/lang/occam/pmfile +++ /dev/null @@ -1,20 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/occam/" - -include (d.."comp/pmfile") -include (d.."lib/pmfile") - -local headers = group { - install = { - pm.install(d.."headers/dec.ocm", "%BINDIR%include/occam/dec.ocm"), - pm.install(d.."headers/printd.ocm", "%BINDIR%include/occam/printd.ocm"), - pm.install(d.."headers/prints.ocm", "%BINDIR%include/occam/prints.ocm"), - } -} - -lang_occam_runtime = group { - headers, - lang_occam_lib_runtime -} diff --git a/lang/occam/test/.distr b/lang/occam/test/.distr deleted file mode 100644 index 6180270d7..000000000 --- a/lang/occam/test/.distr +++ /dev/null @@ -1,11 +0,0 @@ -Makefile -Huffman.ocm -READ_ME -aatob.ocm -copy.ocm -key.ocm -lifegame.ocm -matmul.ocm -sort.ocm -use_prnt.ocm -xxtoy.ocm diff --git a/lang/pc/.distr b/lang/pc/.distr deleted file mode 100644 index cbd3fb167..000000000 --- a/lang/pc/.distr +++ /dev/null @@ -1,3 +0,0 @@ -pmfile -libpc -comp diff --git a/lang/pc/comp/.distr b/lang/pc/comp/.distr deleted file mode 100644 index 3e7d26961..000000000 --- a/lang/pc/comp/.distr +++ /dev/null @@ -1,58 +0,0 @@ -pmfile -LLlex.c -LLlex.h -LLmessage.c -Parameters -body.c -casestat.C -char.tab -chk_expr.c -chk_expr.h -class.h -code.c -const.h -cstoper.c -debug.h -declar.g -def.H -def.c -desig.H -desig.c -em_pc.6 -enter.c -error.c -expression.g -f_info.h -idf.c -idf.h -input.c -input.h -label.c -lookup.c -main.c -main.h -make.allocd -make.hfiles -make.next -make.tokcase -make.tokfile -misc.c -misc.h -node.H -node.c -options -options.c -program.g -progs.c -readwrite.c -required.h -scope.H -scope.c -stab.c -statement.g -tmpvar.C -tokenname.c -tokenname.h -type.H -type.c -typequiv.c diff --git a/lang/pc/comp/LLlex.c b/lang/pc/comp/LLlex.c index 4c2b6b66d..6074870f7 100644 --- a/lang/pc/comp/LLlex.c +++ b/lang/pc/comp/LLlex.c @@ -3,10 +3,8 @@ #include #include #include +#include "parameters.h" #include "debug.h" -#include "idfsize.h" -#include "numsize.h" -#include "strsize.h" #include #include diff --git a/lang/pc/comp/LLmessage.c b/lang/pc/comp/LLmessage.c index 1f7fe0487..965887f41 100644 --- a/lang/pc/comp/LLmessage.c +++ b/lang/pc/comp/LLmessage.c @@ -10,6 +10,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "Lpars.h" #include "idf.h" diff --git a/lang/pc/comp/body.c b/lang/pc/comp/body.c index d628d85b2..f2f7a1a04 100644 --- a/lang/pc/comp/body.c +++ b/lang/pc/comp/body.c @@ -1,3 +1,4 @@ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/build.lua b/lang/pc/comp/build.lua new file mode 100644 index 000000000..a2cb9accb --- /dev/null +++ b/lang/pc/comp/build.lua @@ -0,0 +1,137 @@ +normalrule { + name = "tokenfile_g", + ins = { + "./make.tokfile", + "./tokenname.c" + }, + outleaves = { "tokenfile.g" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +llgen { + name = "llgen", + srcs = { + -- order here is important + "+tokenfile_g", + "./*.g", + } +} + +normalrule { + name = "parameters_h", + ins = { + "./make.parameters", + "./Parameters", + }, + outleaves = { "parameters.h" }, + commands = { + "sh %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +for _, f in ipairs(filenamesof("./*.H")) do + local name = replace(basename(f), "%.H$", "") + normalrule { + name = name.."_h", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".h" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +for _, f in ipairs(filenamesof("./*.C")) do + local name = replace(basename(f), "%.C$", "") + normalrule { + name = name.."_c", + ins = { + "./make.allocd", + f + }, + outleaves = { name..".c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } + } +end + +normalrule { + name = "next_c", + ins = { + "./make.next", + "./*.H", + "./*.C", + }, + outleaves = { "next.c" }, + commands = { + "sh %{ins} > %{outs}" + } +} + +normalrule { + name = "symbol2str_c", + ins = { + "./make.tokcase", + "./tokenname.c", + }, + outleaves = { "symbol2str.c" }, + commands = { + "%{ins[1]} < %{ins[2]} > %{outs}" + } +} + +tabgen { + name = "chartab_c", + srcs = { "./char.tab" }, +} + +cprogram { + name = "em_pc", + srcs = { + "./*.c", + "+casestat_c", + "+chartab_c", + "+next_c", + "+symbol2str_c", + "+tmpvar_c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+def_h", + "+desig_h", + "+llgen", + "+node_h", + "+parameters_h", + "+scope_h", + "+type_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/em_data+lib", + "modules/src/em_mes+lib", + "modules/src/flt_arith+lib", + "modules/src/idf+lib", + "modules/src/input+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + }, + vars = { + ["+cflags"] = "-DSTATIC=static" + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_pc"] = "+em_pc", + ["$(INSDIR)/share/man/man6/em_pc.6"] = "./em_pc.6" + } +} diff --git a/lang/pc/comp/casestat.C b/lang/pc/comp/casestat.C index 83223c09d..61eba13f7 100644 --- a/lang/pc/comp/casestat.C +++ b/lang/pc/comp/casestat.C @@ -1,4 +1,5 @@ /* C A S E S T A T E M E N T C O D E G E N E R A T I O N */ +#include "parameters.h" #include "debug.h" #include @@ -8,7 +9,6 @@ #include "LLlex.h" #include "Lpars.h" #include "chk_expr.h" -#include "density.h" #include "main.h" #include "node.h" #include "type.h" diff --git a/lang/pc/comp/chk_expr.c b/lang/pc/comp/chk_expr.c index 82e14c768..1c5cb58ea 100644 --- a/lang/pc/comp/chk_expr.c +++ b/lang/pc/comp/chk_expr.c @@ -3,8 +3,10 @@ /* Check expressions, and try to evaluate them as far as possible. */ +#include "parameters.h" #include "debug.h" +#include #include #include #include diff --git a/lang/pc/comp/code.c b/lang/pc/comp/code.c index 8f2efd8f0..17f0f7c32 100644 --- a/lang/pc/comp/code.c +++ b/lang/pc/comp/code.c @@ -2,6 +2,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include #include diff --git a/lang/pc/comp/cstoper.c b/lang/pc/comp/cstoper.c index fea4c7e14..be9dbc387 100644 --- a/lang/pc/comp/cstoper.c +++ b/lang/pc/comp/cstoper.c @@ -2,8 +2,8 @@ #include #include +#include "parameters.h" #include "debug.h" -#include "target_sizes.h" #include #include diff --git a/lang/pc/comp/debug.h b/lang/pc/comp/debug.h index 670c29d18..0da1c95c8 100644 --- a/lang/pc/comp/debug.h +++ b/lang/pc/comp/debug.h @@ -1,8 +1,6 @@ /* A debugging macro */ -#include "debugcst.h" - #ifdef DEBUG #define DO_DEBUG(x, y) ((x) && (y)) #else diff --git a/lang/pc/comp/declar.g b/lang/pc/comp/declar.g index 5f3a21ab8..4ee1fcf89 100644 --- a/lang/pc/comp/declar.g +++ b/lang/pc/comp/declar.g @@ -1,7 +1,8 @@ /* D E C L A R A T I O N S */ { -/* next line DEBUG */ +#include "parameters.h" +/* next line DEBUG */ #include "debug.h" #include @@ -19,7 +20,6 @@ #include "node.h" #include "scope.h" #include "type.h" -#include "dbsymtab.h" #define PC_BUFSIZ (sizeof(struct file) - (int)((struct file *)0)->bufadr) diff --git a/lang/pc/comp/def.c b/lang/pc/comp/def.c index bce524163..dfc33f459 100644 --- a/lang/pc/comp/def.c +++ b/lang/pc/comp/def.c @@ -1,5 +1,6 @@ /* D E F I N I T I O N M E C H A N I S M */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/desig.c b/lang/pc/comp/desig.c index a996aef6b..68c5512a9 100644 --- a/lang/pc/comp/desig.c +++ b/lang/pc/comp/desig.c @@ -7,6 +7,7 @@ or perform a store. */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/enter.c b/lang/pc/comp/enter.c index 703b37671..80e99f4c7 100644 --- a/lang/pc/comp/enter.c +++ b/lang/pc/comp/enter.c @@ -5,6 +5,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "def.h" #include "idf.h" @@ -12,7 +13,6 @@ #include "node.h" #include "scope.h" #include "type.h" -#include "dbsymtab.h" extern int proclevel; extern int parlevel; @@ -219,7 +219,7 @@ EnterParTypes(fpl, parlist) register struct node *fpl; struct paramlist **parlist; { - /* Parameters in heading of procedural and functional + /* parameters.h in heading of procedural and functional parameters (only types are important, not the names). */ register arith nb_pars = 0; diff --git a/lang/pc/comp/error.c b/lang/pc/comp/error.c index aa604fa6f..8a381c6fe 100644 --- a/lang/pc/comp/error.c +++ b/lang/pc/comp/error.c @@ -5,8 +5,8 @@ number of arguments! */ +#include "parameters.h" #include "debug.h" -#include "errout.h" #if __STDC__ #include diff --git a/lang/pc/comp/idf.c b/lang/pc/comp/idf.c index 6fc41b525..aa9781482 100644 --- a/lang/pc/comp/idf.c +++ b/lang/pc/comp/idf.c @@ -1,4 +1,5 @@ /* I N S T A N T I A T I O N O F I D F P A C K A G E */ +#include "parameters.h" #include "idf.h" #include diff --git a/lang/pc/comp/input.c b/lang/pc/comp/input.c index 34bb8b2c7..7497440c6 100644 --- a/lang/pc/comp/input.c +++ b/lang/pc/comp/input.c @@ -3,6 +3,7 @@ #include #include #include +#include "parameters.h" #include "f_info.h" struct f_info file_info; #include "input.h" diff --git a/lang/pc/comp/input.h b/lang/pc/comp/input.h index fcdeb21cb..4bc0b1eb8 100644 --- a/lang/pc/comp/input.h +++ b/lang/pc/comp/input.h @@ -1,7 +1,5 @@ /* I N S T A N T I A T I O N O F I N P U T M O D U L E */ -#include "inputtype.h" - #define INP_NPUSHBACK 3 #define INP_TYPE struct f_info #define INP_VAR file_info diff --git a/lang/pc/comp/label.c b/lang/pc/comp/label.c index 0f0fe8a7a..73745ba21 100644 --- a/lang/pc/comp/label.c +++ b/lang/pc/comp/label.c @@ -3,6 +3,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "def.h" #include "idf.h" diff --git a/lang/pc/comp/lookup.c b/lang/pc/comp/lookup.c index bcf4704a0..f051c99f4 100644 --- a/lang/pc/comp/lookup.c +++ b/lang/pc/comp/lookup.c @@ -5,6 +5,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "def.h" #include "idf.h" diff --git a/lang/pc/comp/main.c b/lang/pc/comp/main.c index fcab091a2..cef708fcd 100644 --- a/lang/pc/comp/main.c +++ b/lang/pc/comp/main.c @@ -2,6 +2,7 @@ #include #include +#include "parameters.h" #include "debug.h" #include @@ -23,7 +24,6 @@ #include "tokenname.h" #include "type.h" #include "scope.h" -#include "dbsymtab.h" char options[128]; char *ProgName; diff --git a/lang/pc/comp/make.next b/lang/pc/comp/make.next index 727867594..fa45e585c 100755 --- a/lang/pc/comp/make.next +++ b/lang/pc/comp/make.next @@ -1,3 +1,4 @@ +echo '#include "parameters.h"' echo '#include "debug.h"' sed -n ' s:^.*[ ]ALLOCDEF[ ].*"\(.*\)".*$:struct \1 *h_\1 = 0;\ diff --git a/lang/pc/comp/make.parameters b/lang/pc/comp/make.parameters new file mode 100755 index 000000000..3c9a515c5 --- /dev/null +++ b/lang/pc/comp/make.parameters @@ -0,0 +1,7 @@ +#!/bin/sh + +echo '#ifndef PARAMETERS_H' +echo '#define PARAMETERS_H' +grep -v '^!' +echo '#endif' + diff --git a/lang/pc/comp/misc.c b/lang/pc/comp/misc.c index 9ded3ef6a..cb9a40ef9 100644 --- a/lang/pc/comp/misc.c +++ b/lang/pc/comp/misc.c @@ -5,6 +5,7 @@ #include #include +#include "parameters.h" #include "LLlex.h" #include "f_info.h" #include "idf.h" diff --git a/lang/pc/comp/node.c b/lang/pc/comp/node.c index bdb1804cb..889e855f8 100644 --- a/lang/pc/comp/node.c +++ b/lang/pc/comp/node.c @@ -1,5 +1,6 @@ /* N O D E O F A N A B S T R A C T P A R S E T R E E */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/options.c b/lang/pc/comp/options.c index b80a98b72..4ecf51a68 100644 --- a/lang/pc/comp/options.c +++ b/lang/pc/comp/options.c @@ -3,13 +3,11 @@ #include #include +#include "parameters.h" #include "class.h" #include "const.h" -#include "idfsize.h" #include "main.h" #include "type.h" -#include "nocross.h" -#include "dbsymtab.h" #define MINIDFSIZE 9 diff --git a/lang/pc/comp/pmfile b/lang/pc/comp/pmfile deleted file mode 100644 index d0dae7907..000000000 --- a/lang/pc/comp/pmfile +++ /dev/null @@ -1,169 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/pc/comp/" - -local extract_parameters = simple { - outputs = { - "%U%/debugcst.h", - "%U%/density.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/inputtype.h", - "%U%/numsize.h", - "%U%/strsize.h", - "%U%/target_sizes.h", - "%U%/nocross.h", - "%U%/dbsymtab.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."Parameters") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."program.g"), - file (d.."declar.g"), - file (d.."expression.g"), - file (d.."statement.g"), -} - -local allocd_header = simple { - class = "allocd_header", - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.allocd") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - allocd_header { outputs = {"%U%/def.h"}, (d.."def.H") }, - allocd_header { outputs = {"%U%/type.h"}, (d.."type.H") }, - allocd_header { outputs = {"%U%/scope.h"}, (d.."scope.H") }, - allocd_header { outputs = {"%U%/node.h"}, (d.."node.H") }, - allocd_header { outputs = {"%U%/desig.h"}, (d.."desig.H") }, - lpars - } -} - -lang_pc_compiler = cprogram { - CDEFINES = {PARENT, "STATIC=static"}, - - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."body.c"), - cfile_with_headers (d.."chk_expr.c"), - cfile_with_headers (d.."code.c"), - cfile_with_headers (d.."cstoper.c"), - cfile_with_headers (d.."def.c"), - cfile_with_headers (d.."desig.c"), - cfile_with_headers (d.."enter.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."label.c"), - cfile_with_headers (d.."lookup.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."misc.c"), - cfile_with_headers (d.."node.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."progs.c"), - cfile_with_headers (d.."readwrite.c"), - cfile_with_headers (d.."scope.c"), - cfile_with_headers (d.."stab.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."type.c"), - cfile_with_headers (d.."typequiv.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - cfile_with_headers { - simple { - outputs = {"%U%-next.c"}, - command = { - "%in% > %out%" - }, - - file (d.."make.next"), - - file (d.."def.H"), - file (d.."type.H"), - file (d.."node.H"), - file (d.."scope.H"), - file (d.."desig.H"), - file (d.."tmpvar.C"), - file (d.."casestat.C"), - } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-tmpvar.c"}, (d.."tmpvar.C") } - }, - - cfile_with_headers { - allocd_header { outputs = {"%U%-casestat.c"}, (d.."casestat.C") } - }, - - lib_em_mes, - lib_emk, - lib_em_data, - lib_input, - lib_assert, - lib_alloc, - lib_flt_arith, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_pc"}, - install = { - pm.install( "%BINDIR%%PLATDEP%/em_pc"), - pm.install(d.."em_pc.6", "%BINDIR%/man/man6/em_pc.6"), - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-10-15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/22 21:03:07 dtrg --- Added support for the Pascal compiler. --- \ No newline at end of file diff --git a/lang/pc/comp/program.g b/lang/pc/comp/program.g index 45eacde05..dfd649e8e 100644 --- a/lang/pc/comp/program.g +++ b/lang/pc/comp/program.g @@ -1,6 +1,7 @@ /* The grammar of ISO-Pascal as given by the specification, BS6192: 1982. */ { +#include "parameters.h" #include #include #include @@ -14,7 +15,6 @@ #include "main.h" #include "node.h" #include "scope.h" -#include "dbsymtab.h" } %lexical LLlex; diff --git a/lang/pc/comp/progs.c b/lang/pc/comp/progs.c index fde2e2f12..173767526 100644 --- a/lang/pc/comp/progs.c +++ b/lang/pc/comp/progs.c @@ -1,3 +1,4 @@ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/readwrite.c b/lang/pc/comp/readwrite.c index e38c16163..7b62aaede 100644 --- a/lang/pc/comp/readwrite.c +++ b/lang/pc/comp/readwrite.c @@ -1,5 +1,6 @@ /* R E A D ( L N ) & W R I T E ( L N ) */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/scope.c b/lang/pc/comp/scope.c index f0f9e2cba..5c09ff925 100644 --- a/lang/pc/comp/scope.c +++ b/lang/pc/comp/scope.c @@ -1,5 +1,6 @@ /* S C O P E M E C H A N I S M */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/comp/stab.c b/lang/pc/comp/stab.c index 8ae0514f1..d5e4ee3fb 100644 --- a/lang/pc/comp/stab.c +++ b/lang/pc/comp/stab.c @@ -9,7 +9,7 @@ /* $Id$ */ -#include "dbsymtab.h" +#include "parameters.h" #ifdef DBSYMTAB diff --git a/lang/pc/comp/statement.g b/lang/pc/comp/statement.g index 3c4f6f4bb..686e20682 100644 --- a/lang/pc/comp/statement.g +++ b/lang/pc/comp/statement.g @@ -1,5 +1,6 @@ /* S T A T E M E N T S */ { +#include "parameters.h" #include #include #include @@ -15,7 +16,6 @@ #include "node.h" #include "scope.h" #include "type.h" -#include "dbsymtab.h" int slevel = 0; /* nesting level of statements */ } diff --git a/lang/pc/comp/tokenname.c b/lang/pc/comp/tokenname.c index 3f1e3fa49..547287347 100644 --- a/lang/pc/comp/tokenname.c +++ b/lang/pc/comp/tokenname.c @@ -1,5 +1,6 @@ /* T O K E N D E F I N I T I O N S */ +#include "parameters.h" #include "Lpars.h" #include "idf.h" #include "tokenname.h" diff --git a/lang/pc/comp/type.H b/lang/pc/comp/type.H index 2ee4f04ba..92e91231b 100644 --- a/lang/pc/comp/type.H +++ b/lang/pc/comp/type.H @@ -1,7 +1,5 @@ /* T Y P E D E S C R I P T O R S T R U C T U R E */ -#include "dbsymtab.h" - struct paramlist { /* structure for parameterlist of a PROCEDURE */ struct paramlist *next; struct def *par_def; /* "df" of parameter */ @@ -131,7 +129,6 @@ extern struct type *void_type, *error_type; /* All from type.c */ -#include "nocross.h" #ifdef NOCROSS #include "target_sizes.h" #define word_align (AL_WORD) diff --git a/lang/pc/comp/type.c b/lang/pc/comp/type.c index 6dd131b7a..b5662c658 100644 --- a/lang/pc/comp/type.c +++ b/lang/pc/comp/type.c @@ -1,5 +1,6 @@ /* T Y P E D E F I N I T I O N M E C H A N I S M */ +#include "parameters.h" #include "debug.h" #include @@ -18,7 +19,6 @@ #include "type.h" #ifndef NOCROSS -#include "target_sizes.h" int word_align = AL_WORD, int_align = AL_INT, diff --git a/lang/pc/comp/typequiv.c b/lang/pc/comp/typequiv.c index bb00760ce..1b90f39a2 100644 --- a/lang/pc/comp/typequiv.c +++ b/lang/pc/comp/typequiv.c @@ -3,6 +3,7 @@ /* Routines for testing type equivalence & type compatibility. */ +#include "parameters.h" #include "debug.h" #include diff --git a/lang/pc/libpc/.distr b/lang/pc/libpc/.distr deleted file mode 100644 index 0a10ca561..000000000 --- a/lang/pc/libpc/.distr +++ /dev/null @@ -1,75 +0,0 @@ -pmfile -abi.c -abl.c -abr.c -arg.c -ass.c -asz.c -atn.c -bcp.c -bts.e -buff.c -clock.c -diag.c -dis.c -efl.c -eln.c -encaps.e -exp.c -get.c -gto.e -hlt.c -ini.c -catch.c -log.c -mdi.c -mdl.c -new.c -nobuff.c -notext.c -opn.c -hol0.e -pac.c -pclose.c -pcreat.c -pentry.c -perrno.c -pexit.c -popen.c -cls.c -put.c -rdc.c -rdl.c -rdr.c -rdi.c -rln.c -rf.c -rnd.c -sav.e -sig.e -sin.c -sqt.c -fef.e -string.c -trap.e -unp.c -uread.c -uwrite.c -wdw.c -incpt.c -wrc.c -wrf.c -wri.c -wrl.c -wrr.c -cvt.c -fif.e -wrz.c -wrs.c -outcpt.c -wf.c -nfa.c -rcka.c -trp.e -READ_ME -head_pc.e diff --git a/lang/pc/libpc/build.lua b/lang/pc/libpc/build.lua new file mode 100644 index 000000000..61c4f7a3e --- /dev/null +++ b/lang/pc/libpc/build.lua @@ -0,0 +1,46 @@ +include("plat/build.lua") + +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./*.c", + "./bts.e", + "./encaps.e", + "./fef.e", + "./fif.e", + "./gto.e", + "./hol0.e", + "./sav.e", + "./sig.e", + "./trap.e", + "./trp.e", + }, + hdrs = {}, -- must be empty + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/"..plat.."/include+headers", + "h+emheaders", + }, + vars = { plat = plat } + } + + ackfile { + name = "prt_"..plat, + srcs = { "./head_pc.e" }, + vars = { plat = plat }, + deps = { + "h+emheaders" + } + } + + installable { + name = "pkg_"..plat, + map = { + ["$(PLATIND)/"..plat.."/pascal.o"] = "+prt_"..plat, + ["$(PLATIND)/"..plat.."/libpascal.a"] = "+lib_"..plat, + } + } +end + + diff --git a/lang/pc/libpc/pmfile b/lang/pc/libpc/pmfile deleted file mode 100644 index b63c635b2..000000000 --- a/lang/pc/libpc/pmfile +++ /dev/null @@ -1,95 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/pc/libpc/" - -head = ackfile { - file (d.."head_pc.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/pascal.o") -} - -tail = acklibrary { - ackfile (d.."abi.c"), - ackfile (d.."abl.c"), - ackfile (d.."abr.c"), - ackfile (d.."arg.c"), - ackfile (d.."ass.c"), - ackfile (d.."asz.c"), - ackfile (d.."atn.c"), - ackfile (d.."bcp.c"), - ackfile (d.."bts.e"), - ackfile (d.."buff.c"), - ackfile (d.."clock.c"), - ackfile (d.."diag.c"), - ackfile (d.."dis.c"), - ackfile (d.."efl.c"), - ackfile (d.."eln.c"), - ackfile (d.."encaps.e"), - ackfile (d.."exp.c"), - ackfile (d.."get.c"), - ackfile (d.."gto.e"), - ackfile (d.."hlt.c"), - ackfile (d.."ini.c"), - ackfile (d.."catch.c"), - ackfile (d.."log.c"), - ackfile (d.."mdi.c"), - ackfile (d.."mdl.c"), - ackfile (d.."new.c"), - ackfile (d.."nobuff.c"), - ackfile (d.."notext.c"), - ackfile (d.."opn.c"), - ackfile (d.."hol0.e"), - ackfile (d.."pac.c"), - ackfile (d.."pclose.c"), - ackfile (d.."pcreat.c"), - ackfile (d.."pentry.c"), - ackfile (d.."perrno.c"), - ackfile (d.."pexit.c"), - ackfile (d.."popen.c"), - ackfile (d.."cls.c"), - ackfile (d.."put.c"), - ackfile (d.."rdc.c"), - ackfile (d.."rdl.c"), - ackfile (d.."rdr.c"), - ackfile (d.."rdi.c"), - ackfile (d.."rln.c"), - ackfile (d.."rf.c"), - ackfile (d.."rnd.c"), - ackfile (d.."sav.e"), - ackfile (d.."sig.e"), - ackfile (d.."sin.c"), - ackfile (d.."sqt.c"), - ackfile (d.."fef.e"), - ackfile (d.."string.c"), - ackfile (d.."trap.e"), - ackfile (d.."unp.c"), - ackfile (d.."uread.c"), - ackfile (d.."uwrite.c"), - ackfile (d.."wdw.c"), - ackfile (d.."incpt.c"), - ackfile (d.."wrc.c"), - ackfile (d.."wrf.c"), - ackfile (d.."wri.c"), - ackfile (d.."wrl.c"), - ackfile (d.."wrr.c"), - ackfile (d.."cvt.c"), - ackfile (d.."fif.e"), - ackfile (d.."wrz.c"), - ackfile (d.."wrs.c"), - ackfile (d.."outcpt.c"), - ackfile (d.."wf.c"), - ackfile (d.."nfa.c"), - ackfile (d.."rcka.c"), - ackfile (d.."trp.e"), - - install = pm.install("%BINDIR%%PLATIND%/%PLATFORM%/libpascal.a") -} - -lang_pc_runtime = group { - ACKINCLUDES = {PARENT, "%ROOTDIR%h"}, - - head, - tail -} - diff --git a/lang/pc/pmfile b/lang/pc/pmfile deleted file mode 100644 index b1e0be707..000000000 --- a/lang/pc/pmfile +++ /dev/null @@ -1,7 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."lang/pc/" - -include (d.."comp/pmfile") -include (d.."libpc/pmfile") diff --git a/lang/pc/test/.distr b/lang/pc/test/.distr deleted file mode 100644 index 69d9c4981..000000000 --- a/lang/pc/test/.distr +++ /dev/null @@ -1,12 +0,0 @@ -Makefile -b.p -machar.p -t1.p -t2.p -t3.p -t4.p -t5.p -tstenc.p -tstgto.p -callc.p -cmod.c diff --git a/lib/.distr b/lib/.distr deleted file mode 100644 index 84032cfa4..000000000 --- a/lib/.distr +++ /dev/null @@ -1,31 +0,0 @@ -6500 -6800 -6805 -6809 -arm -descr -i80 -i86 -i386 -em22 -em24 -em44 -m68020 -m68k2 -m68k4 -mantra -minix -minixST -ns -pdp -pmds -pmds4 -s2650 -sun2 -sun3 -vax4 -xenix3 -z80 -z8000 -sparc -sparc_solaris diff --git a/lib/6500/.distr b/lib/6500/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/6500/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/6800/.distr b/lib/6800/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/6800/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/6805/.distr b/lib/6805/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/6805/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/6809/.distr b/lib/6809/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/6809/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/arm/.distr b/lib/arm/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/arm/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/descr/.distr b/lib/descr/.distr deleted file mode 100644 index a75b251a3..000000000 --- a/lib/descr/.distr +++ /dev/null @@ -1,2 +0,0 @@ -fe -cpm diff --git a/lib/descr/fe b/lib/descr/fe index aa2f33bac..e88663a6d 100644 --- a/lib/descr/fe +++ b/lib/descr/fe @@ -4,15 +4,15 @@ # Don't generate line updating code by default (i.e.: -L flag provided to cem). # To put it on again: use -NL var LFLAG=-L -var MODULA2_INCLUDES=-I{EM}/include/m2 -var OCCAM_INCLUDES=-I{EM}/include/occam -var C_INCLUDES=-I{EM}/include/ansi +var MODULA2_INCLUDES=-I{EM}/share/ack/include/modula2 +var OCCAM_INCLUDES=-I{EM}/share/ack/include/occam +var C_INCLUDES=-I{EM}/share/ack/include/ansi callname ack name cpp # no from, this is a preprocessor to .i - program {EM}/lib.bin/cpp.ansi + program {EM}/lib/ack/cpp.ansi mapflag -I* CPP_F={CPP_F?} -I* mapflag -U* CPP_F={CPP_F?} -U* mapflag -D* CPP_F={CPP_F?} -D* @@ -38,7 +38,7 @@ end name f77 from .f to .c - program {EM}/lib.bin/f2c + program {EM}/lib/ack/f2c mapflag -ansi F2_F={F2_F?} -A mapflag -w* F2_F={F2_F?} -w* args \ @@ -54,7 +54,7 @@ end name cem from .c to .k - program {EM}/lib.bin/em_cemcom.ansi + program {EM}/lib/ack/em_cemcom.ansi # mapflag -I* CPP_F={CPP_F?} -I* # mapflag -U* CPP_F={CPP_F?} -U* # mapflag -D* CPP_F={CPP_F?} -D* @@ -84,7 +84,7 @@ name cem -DEM_SSIZE={s} -DEM_LSIZE={l} -DEM_FSIZE={f} -DEM_DSIZE={d}) \ -D_EM_WSIZE={w} -D_EM_PSIZE={p} \ -D_EM_SSIZE={s} -D_EM_LSIZE={l} -D_EM_FSIZE={f} -D_EM_DSIZE={d} \ - -Vw{w}.{w}i{w}.{w}p{p}.{w}f{f}.{w}s{s}.{s}l{l}.{w}d{d}.{w} \ + -Vw{w}.{wa}i{w}.{wa}p{p}.{pa}f{f}.{fa}s{s}.{sa}l{l}.{la}d{d}.{da}x{x}.{xa} \ {CC_ALIGN?} \ {CEM_F?} {LFLAG?} < > callname acc @@ -93,7 +93,7 @@ end name pc from .p to .k - program {EM}/lib.bin/em_pc + program {EM}/lib/ack/em_pc mapflag -L PC_F={PC_F?} -L # mapflag -s PC_F={PC_F?} -s mapflag -_ PC_F={PC_F?} -U @@ -118,7 +118,7 @@ end name m2 from .mod.def to .k - program {EM}/lib.bin/em_m2 + program {EM}/lib/ack/em_m2 mapflag -I* M2_INCL={M2_INCL?} -I* mapflag -L M2_F={M2_F?} -L mapflag -g* M2_F={M2_F?} -g* @@ -142,7 +142,7 @@ end name ocm from .ocm to .k - program {EM}/lib.bin/em_occam + program {EM}/lib/ack/em_occam mapflag -L OCM_F={OCM_F?} -L mapflag -V* OCM_F={OCM_F?} -V* args -Vw{w}p{p}l{l} {OCM_F?} @@ -156,7 +156,7 @@ end name abc from .b to .k - program {EM}/lib.bin/em_bem + program {EM}/lib/ack/em_bem mapflag -h ABC_F={ABC_F?} -h mapflag -w ABC_F={ABC_F?} -w mapflag -L ABC_F={ABC_F?} -L @@ -168,11 +168,11 @@ name abc need .b callname abc end -var A68INIT={EM}/lib.bin/em_a68s_init +var A68INIT={EM}/lib/ack/em_a68s_init name a68s from .8.a68 to .k - program {EM}/lib.bin/em_a68s{w}{p} + program {EM}/lib/ack/em_a68s{w}{p} mapflag -PA* A68INIT=* args < > {SOURCE}.lst {A68INIT}{w}{p} /dev/null prep cond @@ -183,7 +183,7 @@ end name encode from .e to .k - program {EM}/lib.bin/em_encode + program {EM}/lib/ack/em_encode args < prep cond stdout @@ -191,7 +191,7 @@ end name opt from .k to .m - program {EM}/lib.bin/em_opt + program {EM}/lib/ack/em_opt mapflag -LIB OPT_F={OPT_F?} -L # when running the global optimizer, no multiplication optimization here. mapflag -O2 OPT2_F=-m0 @@ -204,21 +204,8 @@ end name ego from .m.ma to .gk - program {EM}/lib.bin/em_ego + program {EM}/lib/ack/em_ego mapflag -EGO-* EGO_F={EGO_F?} -* -# The following lines are obsolete, but here for backwards compatibility. -# They should be removed some day. - mapflag -IL* EGO_F={EGO_F?} -IL* - mapflag -CS* EGO_F={EGO_F?} -CS* - mapflag -SR* EGO_F={EGO_F?} -SR* - mapflag -UD* EGO_F={EGO_F?} -UD* - mapflag -LV* EGO_F={EGO_F?} -LV* - mapflag -SA* EGO_F={EGO_F?} -RA* - mapflag -SP* EGO_F={EGO_F?} -SP* - mapflag -BO* EGO_F={EGO_F?} -BO* - mapflag -CJ* EGO_F={EGO_F?} -CJ* - mapflag -EV EGO_F={EGO_F?} -V -# End of obsolete lines mapflag -Q* EGO_F={EGO_F?} -Q* mapflag -T* EGO_F={EGO_F?} -T* mapflag -S* EGO_F={EGO_F?} -S* @@ -226,8 +213,8 @@ name ego mapflag -a EGO_F={EGO_F?} -a mapflag -O* EGO_F={EGO_F?} -O* args \ - {EGO_F?} -P {EM}/lib.bin/ego \ - -M{EM}/lib.bin/ego/{ARCH}descr < + {EGO_F?} -P {EM}/lib/ack/ego \ + {EGO_PLAT_FLAGS?} < optimizer 2 stdout combiner @@ -237,7 +224,7 @@ name opt2 # of the em peephole optimizer from .gk to .g - program {EM}/lib.bin/em_opt2 + program {EM}/lib/ack/em_opt2 # mapflag -LIB OPT_F={OPT_F?} -L args {OPT_F?} {MACHOPT_F?} < optimizer @@ -246,7 +233,7 @@ end name decode from .k.m.g.gk to .e - program {EM}/lib.bin/em_decode + program {EM}/lib/ack/em_decode args < stdout end diff --git a/lib/em22/.distr b/lib/em22/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/em22/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/em24/.distr b/lib/em24/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/em24/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/em44/.distr b/lib/em44/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/em44/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/i386/.distr b/lib/i386/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/i386/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/i80/.distr b/lib/i80/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/i80/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/i86/.distr b/lib/i86/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/i86/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/m68020/.distr b/lib/m68020/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/m68020/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/m68k2/.distr b/lib/m68k2/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/m68k2/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/m68k4/.distr b/lib/m68k4/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/m68k4/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/mantra/.distr b/lib/mantra/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/mantra/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/minix/.distr b/lib/minix/.distr deleted file mode 100644 index a4c54f9c6..000000000 --- a/lib/minix/.distr +++ /dev/null @@ -1,2 +0,0 @@ -descr -include diff --git a/lib/minix/include/.distr b/lib/minix/include/.distr deleted file mode 100644 index b5ad15f97..000000000 --- a/lib/minix/include/.distr +++ /dev/null @@ -1,13 +0,0 @@ -ansi.h -fcntl.h -limits.h -lib.h -errno.h -minix -sgtty.h -signal.h -string.h -time.h -utime.h -unistd.h -sys diff --git a/lib/minix/include/minix/.distr b/lib/minix/include/minix/.distr deleted file mode 100644 index 144062138..000000000 --- a/lib/minix/include/minix/.distr +++ /dev/null @@ -1,5 +0,0 @@ -config.h -callnr.h -com.h -const.h -type.h diff --git a/lib/minix/include/sys/.distr b/lib/minix/include/sys/.distr deleted file mode 100644 index 2781e7784..000000000 --- a/lib/minix/include/sys/.distr +++ /dev/null @@ -1,5 +0,0 @@ -times.h -wait.h -types.h -stat.h -errno.h diff --git a/lib/minixST/.distr b/lib/minixST/.distr deleted file mode 100644 index a4c54f9c6..000000000 --- a/lib/minixST/.distr +++ /dev/null @@ -1,2 +0,0 @@ -descr -include diff --git a/lib/minixST/include/.distr b/lib/minixST/include/.distr deleted file mode 100644 index bdeac18ea..000000000 --- a/lib/minixST/include/.distr +++ /dev/null @@ -1,2 +0,0 @@ -a.out.h -minix diff --git a/lib/minixST/include/minix/.distr b/lib/minixST/include/minix/.distr deleted file mode 100644 index 0e56cf2f8..000000000 --- a/lib/minixST/include/minix/.distr +++ /dev/null @@ -1 +0,0 @@ -config.h diff --git a/lib/ns/.distr b/lib/ns/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/ns/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/pdp/.distr b/lib/pdp/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/pdp/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/pmds/.distr b/lib/pmds/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/pmds/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/pmds4/.distr b/lib/pmds4/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/pmds4/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/s2650/.distr b/lib/s2650/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/s2650/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/sparc/.distr b/lib/sparc/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/sparc/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/sparc_solaris/.distr b/lib/sparc_solaris/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/sparc_solaris/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/sun2/.distr b/lib/sun2/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/sun2/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/sun3/.distr b/lib/sun3/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/sun3/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/vax4/.distr b/lib/vax4/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/vax4/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/xenix3/.distr b/lib/xenix3/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/xenix3/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/z80/.distr b/lib/z80/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/z80/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/lib/z8000/.distr b/lib/z8000/.distr deleted file mode 100644 index 7a41a7d7b..000000000 --- a/lib/z8000/.distr +++ /dev/null @@ -1 +0,0 @@ -descr diff --git a/mach/.distr b/mach/.distr deleted file mode 100644 index fb9d533eb..000000000 --- a/mach/.distr +++ /dev/null @@ -1,32 +0,0 @@ -6500 -6800 -6805 -6809 -arm -i80 -con_float -i86 -i386 -em22 -em24 -em44 -m68k2 -m68k4 -m68020 -mantra -minix -minixST -ns -pdp -pmds -pmds4 -proto -s2650 -sun3 -sun2 -vax4 -xenix3 -z80 -z8000 -sparc -sparc_solaris diff --git a/mach/6500/.distr b/mach/6500/.distr deleted file mode 100644 index 4f6acc11d..000000000 --- a/mach/6500/.distr +++ /dev/null @@ -1,8 +0,0 @@ -Action -as -cg -dl -libem -libend -libmon -mach_params diff --git a/mach/6500/as/.distr b/mach/6500/as/.distr deleted file mode 100644 index d139683f8..000000000 --- a/mach/6500/as/.distr +++ /dev/null @@ -1,7 +0,0 @@ -READ_ME -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/6500/cg/.distr b/mach/6500/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/6500/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/6500/dl/.distr b/mach/6500/dl/.distr deleted file mode 100644 index f838529b7..000000000 --- a/mach/6500/dl/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -dl.c diff --git a/mach/6500/dl/pmfile b/mach/6500/dl/pmfile deleted file mode 100644 index b5c904c4b..000000000 --- a/mach/6500/dl/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = "mach/6500/dl/" - -tool_6500_dl = cprogram { - cfile (d.."dl.c"), - - lib_object, - - outputs = {"%U%/dl"}, - install = pm.install(BINDIR..PLATDEP.."/6500/dl") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/6500/libem/.distr b/mach/6500/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/6500/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/6500/libem/pmfile b/mach/6500/libem/pmfile deleted file mode 100644 index dd12b24be..000000000 --- a/mach/6500/libem/pmfile +++ /dev/null @@ -1,98 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/6500/libem/" - -libem_6500 = acklibrary { - outputs = {"%U%/libem-%ARCH%.a"}, - - ackfile (d.."adi4.s"), - ackfile (d.."cmi.s"), - ackfile (d.."cmi4.s"), - ackfile (d.."sbi4.s"), - ackfile (d.."addsub.s"), - ackfile (d.."cmu4.s"), - ackfile (d.."dum_float.s"), - ackfile (d.."dvi4.s"), - ackfile (d.."dvu4.s"), - ackfile (d.."lar.s"), - ackfile (d.."lol.s"), - ackfile (d.."los.s"), - ackfile (d.."loil.s"), - ackfile (d.."loi1.s"), - ackfile (d.."loi.s"), - ackfile (d.."mli4.s"), - ackfile (d.."mlu.s"), - ackfile (d.."mlu4.s"), - ackfile (d.."mul4.s"), - ackfile (d.."rmi.s"), - ackfile (d.."rmi4.s"), - ackfile (d.."div4.s"), - ackfile (d.."rmu.s"), - ackfile (d.."dvi.s"), - ackfile (d.."rmu4.s"), - ackfile (d.."duv4.s"), - ackfile (d.."ngi4.s"), - ackfile (d.."rtt.s"), - ackfile (d.."ret.s"), - ackfile (d.."sar.s"), - ackfile (d.."aar.s"), - ackfile (d.."adi.s"), - ackfile (d.."sbi.s"), - ackfile (d.."mli.s"), - ackfile (d.."ngi.s"), - ackfile (d.."set.s"), - ackfile (d.."zer.s"), - ackfile (d.."stl.s"), - ackfile (d.."sts.s"), - ackfile (d.."sdl.s"), - ackfile (d.."sti.s"), - ackfile (d.."stil.s"), - ackfile (d.."blm.s"), - ackfile (d.."sti1.s"), - ackfile (d.."test2.s"), - ackfile (d.."testFFh.s"), - ackfile (d.."trap.s"), - ackfile (d.."ldi.s"), - ackfile (d.."data.s"), - ackfile (d.."zri.s"), - ackfile (d.."locaddr.s"), - ackfile (d.."and.s"), - ackfile (d.."asp.s"), - ackfile (d.."cii.s"), - ackfile (d.."cms.s"), - ackfile (d.."cmu.s"), - ackfile (d.."com.s"), - ackfile (d.."csa.s"), - ackfile (d.."csb.s"), - ackfile (d.."dup.s"), - ackfile (d.."dvu.s"), - ackfile (d.."exg.s"), - ackfile (d.."exg2.s"), - ackfile (d.."gto.s"), - ackfile (d.."indir.s"), - ackfile (d.."inn.s"), - ackfile (d.."ior.s"), - ackfile (d.."lcs.s"), - ackfile (d.."lxa1.s"), - ackfile (d.."lxa2.s"), - ackfile (d.."lxl.s"), - ackfile (d.."pro.s"), - ackfile (d.."rol.s"), - ackfile (d.."rol4.s"), - ackfile (d.."ror.s"), - ackfile (d.."ror4.s"), - ackfile (d.."sli.s"), - ackfile (d.."sli4.s"), - ackfile (d.."sri.s"), - ackfile (d.."sri4.s"), - ackfile (d.."teq.s"), - ackfile (d.."tge.s"), - ackfile (d.."tgt.s"), - ackfile (d.."tle.s"), - ackfile (d.."tlt.s"), - ackfile (d.."tne.s"), - ackfile (d.."xor.s"), - - install = pm.install("%BINDIR%lib/%ARCH%/tail_em"), -} diff --git a/mach/6500/libend/.distr b/mach/6500/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/6500/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/6500/libmon/.distr b/mach/6500/libmon/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/6500/libmon/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/6500/pmfile b/mach/6500/pmfile deleted file mode 100644 index 3bd8606b9..000000000 --- a/mach/6500/pmfile +++ /dev/null @@ -1,33 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/6500/" - -include (d.."dl/pmfile") -include (d.."libem/pmfile") - -mach_6500 = group { - ARCH = "6500", - - proto_cg, - proto_as, - tool_6500_dl, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - -support_6500 = group { - ARCH = "6500", - OPTIMISATION = "-O", - - libem_6500, -} - --- Revision history --- $Log$ --- Revision 1.2 2006-10-15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/6800/.distr b/mach/6800/.distr deleted file mode 100644 index e6fdcfb35..000000000 --- a/mach/6800/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Action -as diff --git a/mach/6800/as/.distr b/mach/6800/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/6800/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/6800/pmfile b/mach/6800/pmfile deleted file mode 100644 index 516ab67de..000000000 --- a/mach/6800/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ - -mach_6800 = group { - ARCH = "6800", - - proto_as, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/mach/6805/.distr b/mach/6805/.distr deleted file mode 100644 index e6fdcfb35..000000000 --- a/mach/6805/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Action -as diff --git a/mach/6805/as/.distr b/mach/6805/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/6805/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/6805/pmfile b/mach/6805/pmfile deleted file mode 100644 index 926369a08..000000000 --- a/mach/6805/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ - -mach_6805 = group { - ARCH = "6805", - - proto_as, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/6809/.distr b/mach/6809/.distr deleted file mode 100644 index e6fdcfb35..000000000 --- a/mach/6809/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Action -as diff --git a/mach/6809/as/.distr b/mach/6809/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/6809/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/6809/pmfile b/mach/6809/pmfile deleted file mode 100644 index 3fc289783..000000000 --- a/mach/6809/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ - -mach_6809 = group { - ARCH = "6809", - - proto_as, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/arm/.distr b/mach/arm/.distr deleted file mode 100644 index ea3b4ee55..000000000 --- a/mach/arm/.distr +++ /dev/null @@ -1,11 +0,0 @@ -Action -READ_ME -as -cv -ncg -top -libem -libfp -libend -libmon -mach_params diff --git a/mach/arm/as/.distr b/mach/arm/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/arm/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/arm/cv/.distr b/mach/arm/cv/.distr deleted file mode 100644 index 457480833..000000000 --- a/mach/arm/cv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -arm.h -cv.c diff --git a/mach/arm/cv/pmfile b/mach/arm/cv/pmfile deleted file mode 100644 index 8ca8a9a4a..000000000 --- a/mach/arm/cv/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/arm/cv/" - -tool_arm_cv = cprogram { - cfile (d.."cv.c"), - - lib_object, - - outputs = {"%U%/cv"}, - install = pm.install(BINDIR.."%PLATDEP%/arm/dl") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/arm/libem/.distr b/mach/arm/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/arm/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/arm/libend/.distr b/mach/arm/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/arm/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/arm/libfp/.distr b/mach/arm/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/arm/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/arm/libmon/.distr b/mach/arm/libmon/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/arm/libmon/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/arm/ncg/.distr b/mach/arm/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/arm/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/arm/pmfile b/mach/arm/pmfile deleted file mode 100644 index a7dbafc16..000000000 --- a/mach/arm/pmfile +++ /dev/null @@ -1,26 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/arm/" - -include (d.."cv/pmfile") - -mach_arm = group { - ARCH = "arm", - - proto_as, - proto_ncg { ARCHDIR = "arm" }, - proto_top, - tool_arm_cv, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/arm/top/.distr b/mach/arm/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/arm/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/em22/.distr b/mach/em22/.distr deleted file mode 100644 index cdd423d7f..000000000 --- a/mach/em22/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libend -mach_params diff --git a/mach/em22/libend/.distr b/mach/em22/libend/.distr deleted file mode 100644 index 2519bac51..000000000 --- a/mach/em22/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_e.a diff --git a/mach/em24/.distr b/mach/em24/.distr deleted file mode 100644 index cdd423d7f..000000000 --- a/mach/em24/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libend -mach_params diff --git a/mach/em24/libend/.distr b/mach/em24/libend/.distr deleted file mode 100644 index 2519bac51..000000000 --- a/mach/em24/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_e.a diff --git a/mach/em44/.distr b/mach/em44/.distr deleted file mode 100644 index cdd423d7f..000000000 --- a/mach/em44/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libend -mach_params diff --git a/mach/em44/libend/.distr b/mach/em44/libend/.distr deleted file mode 100644 index 2519bac51..000000000 --- a/mach/em44/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_e.a diff --git a/mach/i386/.distr b/mach/i386/.distr deleted file mode 100644 index 86584ff3c..000000000 --- a/mach/i386/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -as -ncg -libem -libend diff --git a/mach/i386/as/.distr b/mach/i386/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/i386/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/i386/ce/.distr b/mach/i386/ce/.distr deleted file mode 100644 index de050f836..000000000 --- a/mach/i386/ce/.distr +++ /dev/null @@ -1,7 +0,0 @@ -EM_table -proto.make -as.c -as.h -as_table -mach.c -mach.h diff --git a/mach/i386/cv/.distr b/mach/i386/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/i386/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/i386/cv/pmfile b/mach/i386/cv/pmfile deleted file mode 100644 index c68a47b79..000000000 --- a/mach/i386/cv/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/i386/cv/" - -tool_i386_cv = cprogram { - cfile (d.."cv.c"), - - lib_object, - - outputs = {"%U%/cv"}, - install = pm.install(BINDIR.."%PLATDEP%/i386/dl") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/i386/libdb/.distr b/mach/i386/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/i386/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/i386/libem/.distr b/mach/i386/libem/.distr deleted file mode 100644 index 670d9e145..000000000 --- a/mach/i386/libem/.distr +++ /dev/null @@ -1,45 +0,0 @@ -pmfile -adi.s -and.s -blm.s -cii.s -cms.s -com.s -csa4.s -csb4.s -cuu.s -dup.s -dvi.s -dvu.s -error.s -exg.s -fat.s -fp8087.s -gto.s -iaar.s -ilar.s -inn.s -ior.s -isar.s -lar4.s -loi.s -mli.s -mon.s -ngi.s -nop.s -print.s -rck.s -rmi.s -rmu.s -rol.s -ror.s -sar4.s -sbi.s -set.s -sli.s -sri.s -sti.s -strhp.s -trp.s -unknown.s -xor.s diff --git a/mach/i386/libem/build.lua b/mach/i386/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i386/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i386/libem/pmfile b/mach/i386/libem/pmfile deleted file mode 100644 index d477e8170..000000000 --- a/mach/i386/libem/pmfile +++ /dev/null @@ -1,56 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i386/libem/" - -libem_i386 = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ackfile (d.."adi.s"), - ackfile (d.."and.s"), - ackfile (d.."blm.s"), - ackfile (d.."cii.s"), - ackfile (d.."cms.s"), - ackfile (d.."com.s"), - ackfile (d.."csa4.s"), - ackfile (d.."csb4.s"), - ackfile (d.."cuu.s"), - ackfile (d.."dup.s"), - ackfile (d.."dvi.s"), - ackfile (d.."dvu.s"), - ackfile (d.."error.s"), - ackfile (d.."exg.s"), - ackfile (d.."fp8087.s"), - ackfile (d.."fat.s"), - ackfile (d.."gto.s"), - ackfile (d.."iaar.s"), - ackfile (d.."ilar.s"), - ackfile (d.."inn.s"), - ackfile (d.."ior.s"), - ackfile (d.."isar.s"), - ackfile (d.."lar4.s"), - ackfile (d.."loi.s"), - ackfile (d.."mli.s"), - ackfile (d.."mon.s"), - ackfile (d.."ngi.s"), - ackfile (d.."nop.s"), - ackfile (d.."print.s"), - ackfile (d.."rck.s"), - ackfile (d.."rmi.s"), - ackfile (d.."rmu.s"), - ackfile (d.."rol.s"), - ackfile (d.."ror.s"), - ackfile (d.."sar4.s"), - ackfile (d.."sbi.s"), - ackfile (d.."set.s"), - ackfile (d.."sli.s"), - ackfile (d.."sri.s"), - ackfile (d.."sti.s"), - ackfile (d.."strhp.s"), - ackfile (d.."trp.s"), - ackfile (d.."unknown.s"), - ackfile (d.."xor.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/i386/libend/.distr b/mach/i386/libend/.distr deleted file mode 100644 index 1508ebdc7..000000000 --- a/mach/i386/libend/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -edata.s -em_end.s -end.s -etext.s diff --git a/mach/i386/libend/build.lua b/mach/i386/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i386/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i386/libend/pmfile b/mach/i386/libend/pmfile deleted file mode 100644 index a5ae6730c..000000000 --- a/mach/i386/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i386/libend/" - -libend_i386 = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/i386/libfp/.distr b/mach/i386/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/i386/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/i386/libsys/.distr b/mach/i386/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/i386/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/i386/ncg/.distr b/mach/i386/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/i386/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/i386/pmfile b/mach/i386/pmfile deleted file mode 100644 index 250bce325..000000000 --- a/mach/i386/pmfile +++ /dev/null @@ -1,22 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i386/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_i386 = group { - proto_as, - proto_ncg { ARCHDIR = "i386" }, - ego_descr, -} - -support_i386 = group { - OPTIMISATION = "-O", - - libem_i386, - libend_i386, -} - diff --git a/mach/i80/.distr b/mach/i80/.distr deleted file mode 100644 index c4ce2f711..000000000 --- a/mach/i80/.distr +++ /dev/null @@ -1,6 +0,0 @@ -pmfile -as -top -ncg -libem -libend diff --git a/mach/i80/as/.distr b/mach/i80/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/i80/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/i80/dl/.distr b/mach/i80/dl/.distr deleted file mode 100644 index c1d697e3d..000000000 --- a/mach/i80/dl/.distr +++ /dev/null @@ -1,4 +0,0 @@ -proto.make -README -mccpm.c -nascom.c diff --git a/mach/i80/libem/.distr b/mach/i80/libem/.distr deleted file mode 100644 index b6454fbc7..000000000 --- a/mach/i80/libem/.distr +++ /dev/null @@ -1,38 +0,0 @@ -pmfile -aar2.s -adi4.s -and.s -blm.s -cii.s -cmi4.s -cms.s -com.s -csa.s -csb.s -dup.s -dvi2.s -dvi4.s -exg.s -flp.s -inn.s -ior.s -lar2.s -loi.s -mli2.s -mli4.s -mlu2.s -ngi4.s -nop.s -rck.s -rol4.s -ror4.s -sar2.s -sbi4.s -set2.s -set.s -sli2.s -sli4.s -sri2.s -sri4.s -sti.s -xor.s diff --git a/mach/i80/libem/build.lua b/mach/i80/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i80/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i80/libem/pmfile b/mach/i80/libem/pmfile deleted file mode 100644 index ecc69cf16..000000000 --- a/mach/i80/libem/pmfile +++ /dev/null @@ -1,49 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i80/libem/" - -libem_i80 = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ackfile (d.."aar2.s"), - ackfile (d.."adi4.s"), - ackfile (d.."and.s"), - ackfile (d.."blm.s"), - ackfile (d.."cii.s"), - ackfile (d.."cmi4.s"), - ackfile (d.."cms.s"), - ackfile (d.."com.s"), - ackfile (d.."csa.s"), - ackfile (d.."csb.s"), - ackfile (d.."dup.s"), - ackfile (d.."dvi2.s"), - ackfile (d.."exg.s"), - ackfile (d.."flp.s"), - ackfile (d.."inn.s"), - ackfile (d.."ior.s"), - ackfile (d.."lar2.s"), - ackfile (d.."mli2.s"), - ackfile (d.."mli4.s"), - ackfile (d.."mlu2.s"), - ackfile (d.."ngi4.s"), - ackfile (d.."nop.s"), - ackfile (d.."rol4.s"), - ackfile (d.."ror4.s"), - ackfile (d.."sar2.s"), - ackfile (d.."sbi4.s"), - ackfile (d.."set.s"), - ackfile (d.."set2.s"), - ackfile (d.."sli2.s"), - ackfile (d.."sli4.s"), - ackfile (d.."sri2.s"), - ackfile (d.."sri4.s"), - ackfile (d.."xor.s"), - ackfile (d.."loi.s"), - ackfile (d.."sti.s"), - ackfile (d.."dvi4.s"), - ackfile (d.."rck.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/i80/libend/.distr b/mach/i80/libend/.distr deleted file mode 100644 index 1508ebdc7..000000000 --- a/mach/i80/libend/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -edata.s -em_end.s -end.s -etext.s diff --git a/mach/i80/libend/build.lua b/mach/i80/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i80/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i80/libend/pmfile b/mach/i80/libend/pmfile deleted file mode 100644 index 78e6bb5f3..000000000 --- a/mach/i80/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i80/libend/" - -libend_i80 = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/i80/libmon/.distr b/mach/i80/libmon/.distr deleted file mode 100644 index 90063c137..000000000 --- a/mach/i80/libmon/.distr +++ /dev/null @@ -1,5 +0,0 @@ -LIST -README -libmon_s.a -char.nas.s -head_em.s diff --git a/mach/i80/ncg/.distr b/mach/i80/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/i80/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/i80/pmfile b/mach/i80/pmfile deleted file mode 100644 index d87cef81f..000000000 --- a/mach/i80/pmfile +++ /dev/null @@ -1,25 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/i80/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_i80 = group { - ARCH = "i80", - - proto_as, - proto_ncg { ARCHDIR = "i80" }, - proto_top, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - -support_i80 = group { - OPTIMISATION = "-O", - - libem_i80, - libend_i80, -} - diff --git a/mach/i80/top/.distr b/mach/i80/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/i80/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/i86/.distr b/mach/i86/.distr deleted file mode 100644 index 86584ff3c..000000000 --- a/mach/i86/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -as -ncg -libem -libend diff --git a/mach/i86/as/.distr b/mach/i86/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/i86/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/i86/ce/.distr b/mach/i86/ce/.distr deleted file mode 100644 index 813bb6922..000000000 --- a/mach/i86/ce/.distr +++ /dev/null @@ -1,7 +0,0 @@ -EM_table -as.c -as.h -as_table -mach.c -mach.h -proto.make diff --git a/mach/i86/cv/.distr b/mach/i86/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/i86/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/i86/libem/.distr b/mach/i86/libem/.distr deleted file mode 100644 index a580bcb0c..000000000 --- a/mach/i86/libem/.distr +++ /dev/null @@ -1,60 +0,0 @@ -pmfile -adi.s -and.s -cii.s -cms.s -cmi4.s -cmu4.s -com.s -csa2.s -csb2.s -csa4.s -csb4.s -cuu.s -dup.s -dvi.s -dvi4.s -dvu.s -dvu4.s -exg.s -fp8087.s -gto.s -iaar.s -ilar.s -inn.s -ior.s -isar.s -lar2.s -loi.s -mli.s -mli4.s -mon.s -ngi.s -nop.s -rck.s -rmi.s -rmi4.s -rmu.s -rmu4.s -rol.s -ror.s -sar2.s -sbi.s -set.s -sli.s -sri.s -sti.s -strhp.s -xor.s -error.s -unknown.s -fat.s -trp.s -print.s -ret6.s -ret8.s -lfr6.s -lfr8.s -retarea.s -blm.s -return.s diff --git a/mach/i86/libem/build.lua b/mach/i86/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i86/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i86/libem/pmfile b/mach/i86/libem/pmfile deleted file mode 100644 index b0baa9ede..000000000 --- a/mach/i86/libem/pmfile +++ /dev/null @@ -1,71 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i86/libem/" - -libem_i86 = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ackfile (d.."adi.s"), - ackfile (d.."and.s"), - ackfile (d.."cii.s"), - ackfile (d.."cms.s"), - ackfile (d.."cmi4.s"), - ackfile (d.."cmu4.s"), - ackfile (d.."com.s"), - ackfile (d.."csa2.s"), - ackfile (d.."csb2.s"), - ackfile (d.."csa4.s"), - ackfile (d.."csb4.s"), - ackfile (d.."cuu.s"), - ackfile (d.."dup.s"), - ackfile (d.."dvi.s"), - ackfile (d.."dvi4.s"), - ackfile (d.."dvu.s"), - ackfile (d.."dvu4.s"), - ackfile (d.."exg.s"), - ackfile (d.."fp8087.s"), - ackfile (d.."gto.s"), - ackfile (d.."iaar.s"), - ackfile (d.."ilar.s"), - ackfile (d.."inn.s"), - ackfile (d.."ior.s"), - ackfile (d.."isar.s"), - ackfile (d.."lar2.s"), - ackfile (d.."loi.s"), - ackfile (d.."mli.s"), - ackfile (d.."mli4.s"), - ackfile (d.."mon.s"), - ackfile (d.."ngi.s"), - ackfile (d.."nop.s"), - ackfile (d.."rck.s"), - ackfile (d.."rmi.s"), - ackfile (d.."rmi4.s"), - ackfile (d.."rmu.s"), - ackfile (d.."rmu4.s"), - ackfile (d.."rol.s"), - ackfile (d.."ror.s"), - ackfile (d.."sar2.s"), - ackfile (d.."sbi.s"), - ackfile (d.."set.s"), - ackfile (d.."sli.s"), - ackfile (d.."sri.s"), - ackfile (d.."sti.s"), - ackfile (d.."strhp.s"), - ackfile (d.."xor.s"), - ackfile (d.."error.s"), - ackfile (d.."unknown.s"), - ackfile (d.."fat.s"), - ackfile (d.."trp.s"), - ackfile (d.."print.s"), - ackfile (d.."ret6.s"), - ackfile (d.."ret8.s"), - ackfile (d.."lfr6.s"), - ackfile (d.."lfr8.s"), - ackfile (d.."retarea.s"), - ackfile (d.."blm.s"), - ackfile (d.."return.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/i86/libend/.distr b/mach/i86/libend/.distr deleted file mode 100644 index 1508ebdc7..000000000 --- a/mach/i86/libend/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -edata.s -em_end.s -end.s -etext.s diff --git a/mach/i86/libend/build.lua b/mach/i86/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i86/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i86/libend/pmfile b/mach/i86/libend/pmfile deleted file mode 100644 index 4b6843bd0..000000000 --- a/mach/i86/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/i86/libend/" - -libend_i86 = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/i86/libfp/.distr b/mach/i86/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/i86/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/i86/libsys/.distr b/mach/i86/libsys/.distr deleted file mode 100644 index 5f4d84d7d..000000000 --- a/mach/i86/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libmon_s.a -head_em.s diff --git a/mach/i86/libsys/build.lua b/mach/i86/libsys/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/i86/libsys/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/i86/ncg/.distr b/mach/i86/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/i86/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/i86/pmfile b/mach/i86/pmfile deleted file mode 100644 index f2a26337e..000000000 --- a/mach/i86/pmfile +++ /dev/null @@ -1,22 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/i86/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_i86 = group { - proto_as, - proto_ncg { ARCHDIR = "i86" }, - ego_descr, -} - -support_i86 = group { - OPTIMISATION = "-O", - ACKBUILDFLAGS = {PARENT, "-ansi"}, - - libem_i86, - libend_i86, -} - diff --git a/mach/m68020/.distr b/mach/m68020/.distr deleted file mode 100644 index 096a7b2f4..000000000 --- a/mach/m68020/.distr +++ /dev/null @@ -1,12 +0,0 @@ -Action -as -cv -libem -libend -libsys -ncg -libfp -libdb -top -ce -mach_params diff --git a/mach/m68020/as/.distr b/mach/m68020/as/.distr deleted file mode 100644 index ff35f2bd0..000000000 --- a/mach/m68020/as/.distr +++ /dev/null @@ -1,7 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c -Expect diff --git a/mach/m68020/as/mach0.c b/mach/m68020/as/mach0.c index 2884213be..498620c0e 100644 --- a/mach/m68020/as/mach0.c +++ b/mach/m68020/as/mach0.c @@ -10,7 +10,7 @@ #define THREE_PASS /* branch and offset optimization */ #define BYTES_REVERSED /* high order byte has lowest address */ #define WORDS_REVERSED /* high order word has lowest address */ -/*#define LISTING /* enable listing facilities */ +/*#define LISTING */ /* enable listing facilities */ #define RELOCATION /* generate relocatable code */ #define DEBUG 0 diff --git a/mach/m68020/ce/.distr b/mach/m68020/ce/.distr deleted file mode 100644 index f2261a886..000000000 --- a/mach/m68020/ce/.distr +++ /dev/null @@ -1,7 +0,0 @@ -proto.make -as_table -mach.c -mach.h -as.c -as.h -EM_table diff --git a/mach/m68020/cv/.distr b/mach/m68020/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/m68020/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/m68020/libdb/.distr b/mach/m68020/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/m68020/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/m68020/libem/.distr b/mach/m68020/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/m68020/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/m68020/libem/build.lua b/mach/m68020/libem/build.lua new file mode 100644 index 000000000..d17adcd92 --- /dev/null +++ b/mach/m68020/libem/build.lua @@ -0,0 +1,14 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { + "./*.s", + "./*.c" + }, + vars = { plat = plat }, + deps = { + "h+emheaders" + } + } +end + diff --git a/mach/m68020/libem/pmfile b/mach/m68020/libem/pmfile deleted file mode 100644 index 0969eaa67..000000000 --- a/mach/m68020/libem/pmfile +++ /dev/null @@ -1,38 +0,0 @@ --- $Source: /cvsroot/tack/Ack/mach/i386/libem/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."mach/m68020/libem/" - -libem_m68020 = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ACKINCLUDES = {PARENT, ROOTDIR.."h"}, - - ackfile (d.."fp68881.s"), - ackfile (d.."aar.s"), - ackfile (d.."lar.s"), - ackfile (d.."sar.s"), - ackfile (d.."csa.s"), - ackfile (d.."csb.s"), - ackfile (d.."shp.s"), - ackfile (d.."set.s"), - ackfile (d.."inn.s"), - ackfile (d.."fat.s"), - ackfile (d.."trp.s"), - ackfile (d.."trpstr.c"), - ackfile (d.."mon.s"), - ackfile (d.."nop.s"), - ackfile (d.."dia.s"), - ackfile (d.."cii.s"), - ackfile (d.."cuu.s"), - ackfile (d.."cmi.s"), - ackfile (d.."cms.s"), - ackfile (d.."cmu.s"), - ackfile (d.."cvf.s"), - ackfile (d.."exg.s"), - ackfile (d.."los.s"), - ackfile (d.."sts.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/m68020/libend/.distr b/mach/m68020/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/m68020/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/m68020/libend/build.lua b/mach/m68020/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/m68020/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/m68020/libend/pmfile b/mach/m68020/libend/pmfile deleted file mode 100644 index 5e7e7e95e..000000000 --- a/mach/m68020/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source: /cvsroot/tack/Ack/mach/i386/libend/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."mach/m68020/libend/" - -libend_m68020 = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/m68020/libfp/.distr b/mach/m68020/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/m68020/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/m68020/libsys/.distr b/mach/m68020/libsys/.distr deleted file mode 100644 index 1e8ac2ce6..000000000 --- a/mach/m68020/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -README -head_em.s -libmon_s.a diff --git a/mach/m68020/ncg/.distr b/mach/m68020/ncg/.distr deleted file mode 100644 index 67ed469fd..000000000 --- a/mach/m68020/ncg/.distr +++ /dev/null @@ -1,6 +0,0 @@ -README -mach.c -mach.h -table -whichone.h -instrmacs.h diff --git a/mach/m68020/ncg/table b/mach/m68020/ncg/table index e771b3de8..9aede9929 100644 --- a/mach/m68020/ncg/table +++ b/mach/m68020/ncg/table @@ -12,7 +12,7 @@ rscid = "$Id$" * * ********************************/ -#include +#include "whichone.h" #if TBL68881 && ! TBL68020 Something very wrong here! diff --git a/mach/m68020/pmfile b/mach/m68020/pmfile deleted file mode 100644 index 9481a3bbb..000000000 --- a/mach/m68020/pmfile +++ /dev/null @@ -1,23 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/m68020/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_m68020 = group { - ARCH = "m68020", - - proto_as, - proto_ncg { ARCHDIR = "m68020" }, - proto_top, - ego_descr, -} - -support_m68020 = group { - OPTIMISATION = "-O6", - - libem_m68020, - libend_m68020, -} diff --git a/mach/m68020/top/.distr b/mach/m68020/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/m68020/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/m68k2/.distr b/mach/m68k2/.distr deleted file mode 100644 index 7d818f74d..000000000 --- a/mach/m68k2/.distr +++ /dev/null @@ -1,13 +0,0 @@ -Action -README -Unisoft_bug -as -ncg -cv -dl -libem -libend -libsys -top -libfp -mach_params diff --git a/mach/m68k2/as/.distr b/mach/m68k2/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/m68k2/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/m68k2/cv/.distr b/mach/m68k2/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/m68k2/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/m68k2/dl/.distr b/mach/m68k2/dl/.distr deleted file mode 100644 index f838529b7..000000000 --- a/mach/m68k2/dl/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -dl.c diff --git a/mach/m68k2/libem/.distr b/mach/m68k2/libem/.distr deleted file mode 100644 index 82a73034b..000000000 --- a/mach/m68k2/libem/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libem_s.a -READ_ME diff --git a/mach/m68k2/libend/.distr b/mach/m68k2/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/m68k2/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/m68k2/libfp/.distr b/mach/m68k2/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/m68k2/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/m68k2/libsys/.distr b/mach/m68k2/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/m68k2/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/m68k2/ncg/.distr b/mach/m68k2/ncg/.distr deleted file mode 100644 index 052914faf..000000000 --- a/mach/m68k2/ncg/.distr +++ /dev/null @@ -1,2 +0,0 @@ -table_dir -whichone.h diff --git a/mach/m68k2/pmfile b/mach/m68k2/pmfile deleted file mode 100644 index 30c0e5545..000000000 --- a/mach/m68k2/pmfile +++ /dev/null @@ -1,30 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/m68k2/" - -mach_m68k2 = group { - ARCH = "m68k2", - - proto_as, - proto_ncg { ARCHDIR = "m68020" }, - proto_top, - ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } -} - - --- Revision history --- $Log$ --- Revision 1.3 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.2 2006/07/22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/m68k2/top/.distr b/mach/m68k2/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/m68k2/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/m68k4/.distr b/mach/m68k4/.distr deleted file mode 100644 index 87d1405a0..000000000 --- a/mach/m68k4/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Action -ncg -libem -libend -libfp -libsys -mach_params diff --git a/mach/m68k4/libem/.distr b/mach/m68k4/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/m68k4/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/m68k4/libend/.distr b/mach/m68k4/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/m68k4/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/m68k4/libfp/.distr b/mach/m68k4/libfp/.distr deleted file mode 100644 index 8f5939461..000000000 --- a/mach/m68k4/libfp/.distr +++ /dev/null @@ -1 +0,0 @@ -byte_order.h diff --git a/mach/m68k4/libsys/.distr b/mach/m68k4/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/m68k4/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/m68k4/ncg/.distr b/mach/m68k4/ncg/.distr deleted file mode 100644 index 052914faf..000000000 --- a/mach/m68k4/ncg/.distr +++ /dev/null @@ -1,2 +0,0 @@ -table_dir -whichone.h diff --git a/mach/m68k4/pmfile b/mach/m68k4/pmfile deleted file mode 100644 index 161b6ba2c..000000000 --- a/mach/m68k4/pmfile +++ /dev/null @@ -1,25 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/m68k4/" - -mach_m68k4 = group { - ARCH = "m68k4", - - proto_ncg { ARCHDIR = "m68020" }, - ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } -} - - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/mantra/.distr b/mach/mantra/.distr deleted file mode 100644 index 4ef816f4f..000000000 --- a/mach/mantra/.distr +++ /dev/null @@ -1,5 +0,0 @@ -Action -libsys -cv -int -mach_params diff --git a/mach/mantra/cv/.distr b/mach/mantra/cv/.distr deleted file mode 100644 index 5598b65a7..000000000 --- a/mach/mantra/cv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -Xcv.c -cv.c diff --git a/mach/mantra/int/.distr b/mach/mantra/int/.distr deleted file mode 100644 index 5f80d6561..000000000 --- a/mach/mantra/int/.distr +++ /dev/null @@ -1,19 +0,0 @@ -copyright -deffile -em.c -em.1 -proto.make -mloop0 -mloop1 -mloop2 -mloop3 -mloop4 -mloop5 -mloop6 -mloop7 -mloop8 -mloop9 -mloopa -mloopb -mloopc -con_float.c diff --git a/mach/mantra/libsys/.distr b/mach/mantra/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/mantra/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/minix/.distr b/mach/minix/.distr deleted file mode 100644 index 83f8debe0..000000000 --- a/mach/minix/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libsys -mach_params diff --git a/mach/minix/libsys/.distr b/mach/minix/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/minix/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/minixST/.distr b/mach/minixST/.distr deleted file mode 100644 index 0e1e702e5..000000000 --- a/mach/minixST/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Action -cv -libsys -mach_params diff --git a/mach/minixST/cv/.distr b/mach/minixST/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/minixST/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/minixST/libsys/.distr b/mach/minixST/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/minixST/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/moon3/ncg/.distr b/mach/moon3/ncg/.distr deleted file mode 100644 index 052914faf..000000000 --- a/mach/moon3/ncg/.distr +++ /dev/null @@ -1,2 +0,0 @@ -table_dir -whichone.h diff --git a/mach/ns/.distr b/mach/ns/.distr deleted file mode 100644 index 8d2e3f04d..000000000 --- a/mach/ns/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Action -as -ncg -libem -libend -libmon -mach_params diff --git a/mach/ns/as/.distr b/mach/ns/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/ns/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/ns/libem/.distr b/mach/ns/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/ns/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/ns/libend/.distr b/mach/ns/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/ns/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/ns/libmon/.distr b/mach/ns/libmon/.distr deleted file mode 100644 index 5f4d84d7d..000000000 --- a/mach/ns/libmon/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libmon_s.a -head_em.s diff --git a/mach/ns/ncg/.distr b/mach/ns/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/ns/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/ns/pmfile b/mach/ns/pmfile deleted file mode 100644 index 6696e302d..000000000 --- a/mach/ns/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/ns/" - -mach_ns = group { - ARCH = "ns", - - proto_as, - proto_ncg { ARCHDIR = "ns" }, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/pdp/.distr b/mach/pdp/.distr deleted file mode 100644 index 74fda7967..000000000 --- a/mach/pdp/.distr +++ /dev/null @@ -1,10 +0,0 @@ -Action -as -cg -top -cv -int -libem -libend -libsys -mach_params diff --git a/mach/pdp/as/.distr b/mach/pdp/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/pdp/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/pdp/cg/.distr b/mach/pdp/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/pdp/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/pdp/cv/.distr b/mach/pdp/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/pdp/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/pdp/int/.distr b/mach/pdp/int/.distr deleted file mode 100644 index 0193284f9..000000000 --- a/mach/pdp/int/.distr +++ /dev/null @@ -1,15 +0,0 @@ -proto.make -README -em.1 -eminform.1 -em.c -em_int.s -eminform.s -c+ -c- -f+ -f- -p+ -p- -t+ -t- diff --git a/mach/pdp/libem/.distr b/mach/pdp/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/pdp/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/pdp/libend/.distr b/mach/pdp/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/pdp/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/pdp/libsys/.distr b/mach/pdp/libsys/.distr deleted file mode 100644 index 3a76f61cf..000000000 --- a/mach/pdp/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -libmon_s.a -sys.h -head_em.s diff --git a/mach/pdp/ncg/.distr b/mach/pdp/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/pdp/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/pdp/pmfile b/mach/pdp/pmfile deleted file mode 100644 index 65cfc62f7..000000000 --- a/mach/pdp/pmfile +++ /dev/null @@ -1,30 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/pdp/" - -mach_pdp = group { - ARCH = "pdp", - - proto_as, - proto_cg, - proto_ncg { ARCHDIR = "pdp" }, - proto_top, - ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } -} - --- Revision history --- $Log$ --- Revision 1.3 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.2 2006/07/22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:19 dtrg --- First version in CVS. --- diff --git a/mach/pdp/top/.distr b/mach/pdp/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/pdp/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/pmds/.distr b/mach/pmds/.distr deleted file mode 100644 index 0e1e702e5..000000000 --- a/mach/pmds/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Action -cv -libsys -mach_params diff --git a/mach/pmds/cv/.distr b/mach/pmds/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/pmds/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/pmds/libsys/.distr b/mach/pmds/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/pmds/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/pmds4/.distr b/mach/pmds4/.distr deleted file mode 100644 index 83f8debe0..000000000 --- a/mach/pmds4/.distr +++ /dev/null @@ -1,3 +0,0 @@ -Action -libsys -mach_params diff --git a/mach/pmds4/libsys/.distr b/mach/pmds4/libsys/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/pmds4/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/powerpc/as/.distr b/mach/powerpc/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/powerpc/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/powerpc/libem/.distr b/mach/powerpc/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/powerpc/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/powerpc/libem/pmfile b/mach/powerpc/libem/pmfile deleted file mode 100644 index 8c851f81e..000000000 --- a/mach/powerpc/libem/pmfile +++ /dev/null @@ -1,30 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/powerpc/libem/" - -libem_powerpc = acklibrary { - outputs = {"%U%/libem-%PLATFORM%.a"}, - - ACKINCLUDES = {PARENT, d}, - - ackfile (d.."ret.s"), - ackfile (d.."tge.s"), - ackfile (d.."csa.s"), - ackfile (d.."csb.s"), - ackfile (d.."los.s"), - ackfile (d.."sts.s"), - ackfile (d.."aar4.s"), - ackfile (d.."fef8.c"), - ackfile (d.."fif8.s"), - ackfile (d.."cif8.s"), - ackfile (d.."cuf8.s"), - ackfile (d.."cfi8.s"), - ackfile (d.."cfu8.s"), - ackfile (d.."fd_00000000.s"), - ackfile (d.."fd_80000000.s"), - ackfile (d.."fd_FFFFFFFF.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libem.a"), -} diff --git a/mach/powerpc/libend/.distr b/mach/powerpc/libend/.distr deleted file mode 100644 index 1508ebdc7..000000000 --- a/mach/powerpc/libend/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -edata.s -em_end.s -end.s -etext.s diff --git a/mach/powerpc/libend/pmfile b/mach/powerpc/libend/pmfile deleted file mode 100644 index 83f1c038d..000000000 --- a/mach/powerpc/libend/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."mach/powerpc/libend/" - -libend_powerpc = acklibrary { - outputs = {"%U%/libend-%PLATFORM%.a"}, - - ackfile (d.."edata.s"), - ackfile (d.."em_end.s"), - ackfile (d.."end.s"), - ackfile (d.."etext.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libend.a"), -} diff --git a/mach/powerpc/ncg/.distr b/mach/powerpc/ncg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/powerpc/ncg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/powerpc/pmfile b/mach/powerpc/pmfile deleted file mode 100644 index 8e4913560..000000000 --- a/mach/powerpc/pmfile +++ /dev/null @@ -1,23 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/powerpc/" - -include (d.."libem/pmfile") -include (d.."libend/pmfile") - -mach_powerpc = group { - ARCH = "powerpc", - - proto_as, - proto_ncg { ARCHDIR = "powerpc" }, - proto_top, --- ego_descr, -} - -support_powerpc = group { - OPTIMISATION = "-O", - - libem_powerpc, - libend_powerpc, -} diff --git a/mach/powerpc/top/.distr b/mach/powerpc/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/powerpc/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/proto/.distr b/mach/proto/.distr deleted file mode 100644 index e34b0c9d7..000000000 --- a/mach/proto/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -as -cg -ncg -top diff --git a/mach/proto/as/.distr b/mach/proto/as/.distr deleted file mode 100644 index 4c6af5c3e..000000000 --- a/mach/proto/as/.distr +++ /dev/null @@ -1,10 +0,0 @@ -pmfile -comm0.h -comm1.h -comm2.y -comm3.c -comm4.c -comm5.c -comm6.c -comm7.c -comm8.c diff --git a/mach/proto/as/build.lua b/mach/proto/as/build.lua new file mode 100644 index 000000000..6d846682e --- /dev/null +++ b/mach/proto/as/build.lua @@ -0,0 +1,49 @@ +include("first/yacc.lua") + +definerule("build_as", + { + arch = { type="string" } + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + local archlib = clibrary { + name = e.name.."/archlib", + srcs = {}, + hdrs = { + "mach/"..e.arch.."/as/mach*.c", + "mach/"..e.arch.."/as/*.h" + } + } + + local preprocessedy = cppfile { + name = e.name.."/yaccinput", + srcs = { "mach/proto/as/comm2.y" }, + outleaf = "comm2.y", + deps = { + "h+emheaders", + archlib, + }, + } + + local yaccfiles = yacc { + name = e.name.."/yacc", + srcs = { preprocessedy } + } + + return cprogram { + name = e.name, + srcs = concat( + "mach/proto/as/*.c", + matching(filenamesof(yaccfiles), "%.c$") + ), + deps = { + "h+emheaders", + "modules/src/object+lib", + archlib, + yaccfiles + } + } + end +) + diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 11f1231a9..4996350ac 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -265,3 +265,4 @@ typedef struct sect_t sect_t; #endif extern FILE *fopen(); /* some systems don't have this in stdio.h */ + diff --git a/mach/proto/as/comm1.h b/mach/proto/as/comm1.h index 7e4620471..6a40a2e90 100644 --- a/mach/proto/as/comm1.h +++ b/mach/proto/as/comm1.h @@ -116,6 +116,10 @@ extern valu_t load(); extern FILE *ffcreat(); extern FILE *fftemp(); +extern void fatal(const char* s, ...); +extern void serror(const char* s, ...); +extern void warning(const char* s, ...); + /* ========== Machine dependent C declarations ========== */ #include "mach1.c" diff --git a/mach/proto/as/comm3.c b/mach/proto/as/comm3.c index a5490e249..f35d1818c 100644 --- a/mach/proto/as/comm3.c +++ b/mach/proto/as/comm3.c @@ -26,9 +26,9 @@ item_t keytab[] = { 0, EXTERN, 0, ".define", 0, EXTERN, 0, ".extern", 0, DOT, 0, ".", - 0, DATA, 1, ".data1", - 0, DATA, 2, ".data2", - 0, DATA, 4, ".data4", + 0, DATA, RELO1, ".data1", + 0, DATA, RELO2, ".data2", + 0, DATA, RELO4, ".data4", 0, ASCII, 0, ".ascii", 0, ASCII, 1, ".asciz", 0, ALIGN, 0, ".align", diff --git a/mach/proto/as/comm6.c b/mach/proto/as/comm6.c index 5c51d34e5..f5bd87f39 100644 --- a/mach/proto/as/comm6.c +++ b/mach/proto/as/comm6.c @@ -281,8 +281,8 @@ newrelo(s, n) return; } s &= ~S_VAR; - outrelo.or_type = (char)n; - outrelo.or_sect = (char)DOTTYP; + outrelo.or_type = n; + outrelo.or_sect = DOTTYP; #ifndef ASLD if (s == S_UND || iscomm) { assert(relonami != 0); diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index fbbe42392..3c7871fbe 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -11,6 +11,7 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" +#include valu_t load(ip) @@ -27,7 +28,7 @@ register item_t *ip; if ((ip->i_type & S_TYP) == S_UND || (ip->i_type & S_COM)) { if (pass == PASS_3) { if (relonami != 0) - serror("relocation error"); + serror("relocation error (relonami=%d, type=%08x)", relonami, ip->i_type); relonami = ip->i_valu+1; } return(0); @@ -293,16 +294,16 @@ valu_t val; int n; { switch (n) { - case 1: + case RELO1: emit1((int)val); break; - case 2: + case RELO2: #ifdef BYTES_REVERSED emit1(((int)val>>8)); emit1((int)val); #else emit1((int)val); emit1(((int)val>>8)); #endif break; - case 4: + case RELO4: #ifdef WORDS_REVERSED emit2((int)(val>>16)); emit2((int)(val)); #else @@ -380,13 +381,28 @@ wr_fatal() fatal("write error"); } -/* VARARGS1 */ -fatal(s, a1, a2, a3, a4) -char *s; +void diag(const char* tail, const char* s, va_list ap) { + fflush(stdout); + if (modulename) + fprintf(stderr, "\"%s\", line %ld: ", modulename, lineno); + else + fprintf(stderr, "%s: ", progname); + vfprintf(stderr, s, ap); + fprintf(stderr, "%s", tail); +} + +/* VARARGS1 */ +void fatal(const char* s, ...) +{ + va_list ap; + va_start(ap, s); + nerrors++; - diag(" (fatal)\n", s, a1, a2, a3, a4); + diag(" (fatal)\n", s, ap); stop(); + + va_end(ap); } #if DEBUG == 2 @@ -400,37 +416,34 @@ char *file; #if DEBUG == 1 assert1() { - diag(" (fatal)\n", "assertion failed"); + fatal("assertion failed"); abort(); } #endif -/* VARARGS1 */ -serror(s, a1, a2, a3, a4) -char *s; +void serror(const char* s, ...) { + va_list ap; + va_start(ap, s); + nerrors++; - diag("\n", s, a1, a2, a3, a4); + diag("\n", s, ap); + stop(); + + va_end(ap); } /* VARARGS1 */ -warning(s, a1, a2, a3, a4) -char *s; +void warning(const char* s, ...) { - diag(" (warning)\n", s, a1, a2, a3, a4); -} + va_list ap; + va_start(ap, s); -/* VARARGS1 */ -diag(tail, s, a1, a2, a3, a4) -char *tail, *s; -{ - fflush(stdout); - if (modulename) - fprintf(stderr, "\"%s\", line %ld: ", modulename, lineno); - else - fprintf(stderr, "%s: ", progname); - fprintf(stderr, s, a1, a2, a3, a4); - fprintf(stderr, tail); + nerrors++; + diag(" (warning)\n", s, ap); + stop(); + + va_end(ap); } nofit() diff --git a/mach/proto/as/pmfile b/mach/proto/as/pmfile deleted file mode 100644 index c908fceb5..000000000 --- a/mach/proto/as/pmfile +++ /dev/null @@ -1,67 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/proto/as/" - -local parser = yacc { - simple { - outputs = {"%U%-%I%.y"}, - command = { - "cd %out[1]:dirname% && ".. - "%BINDIR%%PLATDEP%/cpp.ansi -P -I%ROOTDIR%mach/%ARCH%/as -I"..d.." %CINCLUDES:cincludes% %in[1]% > %out[1]%" - }, - - file (d.."comm2.y"), - } -} - -local cfile_with_tables = cfile { - class = "cfile_with_tables", - CINCLUDES = {PARENT, "%ROOTDIR%mach/%ARCH%/as"}, - - dynamicheaders = { - parser, - } -} - -proto_as = cprogram { - class = "proto_as", - - cfile_with_tables (d.."comm3.c"), - cfile_with_tables (d.."comm4.c"), - cfile_with_tables (d.."comm5.c"), - cfile_with_tables (d.."comm6.c"), - cfile_with_tables (d.."comm7.c"), - cfile_with_tables (d.."comm8.c"), - - cfile { - parser, - }, - - lib_object, - - outputs = {"%U%/%PLATFORM%-as"}, - install = pm.install(BINDIR.."%PLATDEP%/%PLATFORM%/as") -} - --- Revision history --- $Log$ --- Revision 1.5 2007-04-21 22:55:59 dtrg --- yacc source files are now run through the ANSI C preprocessor, not the K&R one. --- --- Revision 1.4 2007/02/20 00:45:19 dtrg --- Done a major overhaul of the way target include files are installed and --- how platform libraries are built. The ARCH pm variable has now been --- renamed PLATFORM (which is more accurate) and a different ARCH --- variable added, which represents the CPU family rather than the --- hardware platform. --- --- Revision 1.3 2006/10/15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/30 23:41:16 dtrg --- Broke dependency on tool_cpp in order to speed up the build. --- --- Revision 1.1 2006/07/20 23:18:19 dtrg --- First version in CVS. --- diff --git a/mach/proto/cg/.distr b/mach/proto/cg/.distr deleted file mode 100644 index dc488f32f..000000000 --- a/mach/proto/cg/.distr +++ /dev/null @@ -1,26 +0,0 @@ -pmfile -assert.h -codegen.c -compute.c -data.h -equiv.c -equiv.h -extern.h -fillem.c -gencode.c -glosym.c -glosym.h -main.c -move.c -nextem.c -param.h -reg.c -regvar.c -regvar.h -result.h -salloc.c -state.c -state.h -subr.c -types.h -var.c diff --git a/mach/proto/cg/pmfile b/mach/proto/cg/pmfile deleted file mode 100644 index d74c4ecbc..000000000 --- a/mach/proto/cg/pmfile +++ /dev/null @@ -1,67 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/proto/cg/" - -local make_tables = cgg { - CGGINCLUDEDIR = (ROOTDIR.."mach/%PLATFORM%/cg/"), - file (ROOTDIR.."mach/%PLATFORM%/cg/table") -} - -local cfile_with_tables = cfile { - class = "cfile_with_tables", - dynamicheaders = { - make_tables, - file (ROOTDIR.."mach/%PLATFORM%/cg/"), - file (ROOTDIR.."mach/") - } -} - -proto_cg = cprogram { - class = "proto_cg", - - cfile_with_tables (d.."codegen.c"), - cfile_with_tables (d.."compute.c"), - cfile_with_tables (d.."equiv.c"), - cfile_with_tables (d.."gencode.c"), - cfile_with_tables (d.."glosym.c"), - cfile_with_tables (d.."move.c"), - cfile_with_tables (d.."nextem.c"), - cfile_with_tables (d.."reg.c"), - cfile_with_tables (d.."regvar.c"), - cfile_with_tables (d.."salloc.c"), - cfile_with_tables (d.."state.c"), - cfile_with_tables (d.."subr.c"), - cfile_with_tables (d.."var.c"), - cfile_with_tables (d.."fillem.c"), - cfile_with_tables (d.."main.c"), - - cfile { - ith { make_tables, i = 1 }, - dynamicheaders = { - file (ROOTDIR.."mach/%PLATFORM%/cg/"), - file (d) - } - }, - - lib_em_data, - lib_flt_arith, - - outputs = {"%U%/%PLATFORM%-cg"}, - install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/cg") -} - --- Revision history --- $Log$ --- Revision 1.3 2007-02-20 00:45:19 dtrg --- Done a major overhaul of the way target include files are installed and --- how platform libraries are built. The ARCH pm variable has now been --- renamed PLATFORM (which is more accurate) and a different ARCH --- variable added, which represents the CPU family rather than the --- hardware platform. --- --- Revision 1.2 2006/10/15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:19 dtrg --- First version in CVS. diff --git a/mach/proto/fp/.distr b/mach/proto/fp/.distr deleted file mode 100644 index 512283b1e..000000000 --- a/mach/proto/fp/.distr +++ /dev/null @@ -1,44 +0,0 @@ -FP.script -FP_bias.h -FP_shift.h -FP_trap.h -FP_types.h -add_ext.c -adder.c -adf4.c -adf8.c -cff4.c -cff8.c -cfi.c -cfu.c -cif4.c -cif8.c -cmf4.c -cmf8.c -compact.c -cuf4.c -cuf8.c -div_ext.c -dvf4.c -dvf8.c -extend.c -fef4.c -fef8.c -fif4.c -fif8.c -fptrp.e -get_put.h -mlf4.c -mlf8.c -mul_ext.c -ngf4.c -ngf8.c -nrm_ext.c -sbf4.c -sbf8.c -sft_ext.c -shifter.c -sub_ext.c -zrf4.c -zrf8.c -zrf_ext.c diff --git a/mach/proto/grind/.distr b/mach/proto/grind/.distr deleted file mode 100644 index b57d195b7..000000000 --- a/mach/proto/grind/.distr +++ /dev/null @@ -1,4 +0,0 @@ -READ_ME -atlin.c -lib.e -par_misc.e diff --git a/mach/proto/libg/.distr b/mach/proto/libg/.distr deleted file mode 100644 index e411a18b0..000000000 --- a/mach/proto/libg/.distr +++ /dev/null @@ -1,17 +0,0 @@ -barrier.c -proto.libbc -proto.libfp -proto.libdb -proto.libpc -proto.libcc -proto.libm2 -proto.libf77 -proto.libsys -proto.sysmon -proto.libcc.ansi -proto.libmon -proto.libem -proto.libend -proto.liboc -proto.make -compmodule diff --git a/mach/proto/ncg/.distr b/mach/proto/ncg/.distr deleted file mode 100644 index d8d384103..000000000 --- a/mach/proto/ncg/.distr +++ /dev/null @@ -1,28 +0,0 @@ -pmfile -assert.h -codegen.c -compute.c -data.h -equiv.c -equiv.h -extern.h -fillem.c -gencode.c -glosym.c -glosym.h -label.c -label.h -main.c -move.c -nextem.c -param.h -reg.c -regvar.c -regvar.h -result.h -salloc.c -state.c -state.h -subr.c -types.h -var.c diff --git a/mach/proto/ncg/build.lua b/mach/proto/ncg/build.lua new file mode 100644 index 000000000..e2345ca0c --- /dev/null +++ b/mach/proto/ncg/build.lua @@ -0,0 +1,43 @@ +include("util/ncgg/build.lua") + +definerule("build_ncg", + { + arch = { type="string" } + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + local headers = clibrary { + name = e.name.."/headers", + srcs = {}, + hdrs = { + "mach/proto/ncg/*.h", + "mach/"..e.arch.."/ncg/mach.c", + "mach/"..e.arch.."/ncg/*.h", + } + } + + local tables = ncgg { + name = e.name.."/tables", + srcs = { "mach/"..e.arch.."/ncg/table" } + } + + return cprogram { + name = e.name, + srcs = { + "mach/proto/ncg/*.c", + matching(filenamesof(tables), "%.c$") + }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/flt_arith+lib", + "modules/src/object+lib", + "modules/src/em_data+lib", + headers, + tables, -- for .h file + } + } + end +) + diff --git a/mach/proto/ncg/fillem.c b/mach/proto/ncg/fillem.c index 8838d8f9c..516239b3d 100644 --- a/mach/proto/ncg/fillem.c +++ b/mach/proto/ncg/fillem.c @@ -82,6 +82,8 @@ extern char em_flag[]; extern short em_ptyp[]; extern double atof(); +void prolog(full nlocals); + /* Own version of atol that continues computing on overflow. We don't know that about the ANSI C one. */ diff --git a/mach/proto/ncg/nextem.c b/mach/proto/ncg/nextem.c index 9023f8a22..75f0d0fec 100644 --- a/mach/proto/ncg/nextem.c +++ b/mach/proto/ncg/nextem.c @@ -87,6 +87,13 @@ extern char em_flag[]; argtyp(mn) { + /* op_lab is a special opcode which represents a label definition. It's + * not actually a real EM instruction. Therefore if we try to look it + * up in em_flag, we'll get a buffer overrun... */ + + if (mn == op_lab) + return EV_UNDEF; + switch(em_flag[mn-sp_fmnem]&EM_PAR) { case PAR_W: case PAR_S: diff --git a/mach/proto/ncg/pmfile b/mach/proto/ncg/pmfile deleted file mode 100644 index 7f29aaa09..000000000 --- a/mach/proto/ncg/pmfile +++ /dev/null @@ -1,57 +0,0 @@ --- $Source: /cvsroot/tack/Ack/mach/proto/ncg/pmfile,v $ --- $State: Exp $ - -local d = ROOTDIR.."mach/proto/ncg/" - -local make_tables = ncgg { - NCGGINCLUDEDIR = (ROOTDIR.."mach/%ARCHDIR%/ncg/"), - file (ROOTDIR.."mach/%ARCHDIR%/ncg/table") -} - -local cfile_with_tables = cfile { - class = "cfile_with_tables", - dynamicheaders = { - make_tables, - } -} - -proto_ncg = cprogram { - class = "proto_ncg", - - exename = "ncg", - - CINCLUDES = { - PARENT, - "mach/%PLATFORM%/ncg", - "mach/%ARCHDIR%/ncg", - "mach" - }, - - cfile_with_tables (d.."codegen.c"), - cfile_with_tables (d.."compute.c"), - cfile_with_tables (d.."equiv.c"), - cfile_with_tables (d.."fillem.c"), - cfile_with_tables (d.."gencode.c"), - cfile_with_tables (d.."glosym.c"), - cfile_with_tables (d.."label.c"), - cfile_with_tables (d.."main.c"), - cfile_with_tables (d.."move.c"), - cfile_with_tables (d.."nextem.c"), - cfile_with_tables (d.."reg.c"), - cfile_with_tables (d.."regvar.c"), - cfile_with_tables (d.."salloc.c"), - cfile_with_tables (d.."state.c"), - cfile_with_tables (d.."subr.c"), - cfile_with_tables (d.."var.c"), - - cfile { - ith { make_tables, i = 1 }, - CINCLUDES = {PARENT, d}, - }, - - lib_em_data, - lib_flt_arith, - - outputs = {"%U%/%PLATFORM%-%exename%"}, - install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/%exename%") -} diff --git a/mach/proto/pmfile b/mach/proto/pmfile deleted file mode 100644 index 9ae89d391..000000000 --- a/mach/proto/pmfile +++ /dev/null @@ -1,18 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/proto/" - -include (d.."as/pmfile") -include (d.."cg/pmfile") -include (d.."ncg/pmfile") -include (d.."top/pmfile") - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/proto/top/.distr b/mach/proto/top/.distr deleted file mode 100644 index bb14a80cf..000000000 --- a/mach/proto/top/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -queue.c -queue.h -top.c -top.h diff --git a/mach/proto/top/build.lua b/mach/proto/top/build.lua new file mode 100644 index 000000000..56ee652b9 --- /dev/null +++ b/mach/proto/top/build.lua @@ -0,0 +1,19 @@ +include("util/topgen/build.lua") + +definerule("build_top", + { + arch = { type="string" }, + }, + function(e) + local t = topgen { + name = e.name.."_topgen", + srcs = { "mach/"..e.arch.."/top/table" } + } + + return cprogram { + name = e.name, + srcs = { "mach/proto/top/*.c", }, + deps = { t }, + } + end +) diff --git a/mach/proto/top/pmfile b/mach/proto/top/pmfile deleted file mode 100644 index 121bb6ce2..000000000 --- a/mach/proto/top/pmfile +++ /dev/null @@ -1,32 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/proto/top/" - -local make_tables = topgen { - file (ROOTDIR.."mach/%ARCH%/top/table") -} - -local cfile_with_tables = cfile { - class = "cfile_with_tables", - dynamicheaders = { - make_tables, - } -} - -proto_top = cprogram { - CINCLUDES = { - PARENT, - "mach/%ARCH%/ncg", - "mach", - d - }, - - cfile_with_tables (d.."queue.c"), - cfile_with_tables (d.."top.c"), - - lib_string, - - outputs = {"%U%/%ARCH%-top"}, - install = pm.install("%BINDIR%%PLATDEP%/%PLATFORM%/top") -} diff --git a/mach/s2650/.distr b/mach/s2650/.distr deleted file mode 100644 index e6fdcfb35..000000000 --- a/mach/s2650/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Action -as diff --git a/mach/s2650/as/.distr b/mach/s2650/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/s2650/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/s2650/pmfile b/mach/s2650/pmfile deleted file mode 100644 index d9d41c9cd..000000000 --- a/mach/s2650/pmfile +++ /dev/null @@ -1,16 +0,0 @@ --- $Source$ --- $State$ - -mach_s2650 = group { - ARCH = "s2650", - - proto_as, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/sparc/.distr b/mach/sparc/.distr deleted file mode 100644 index 154fc06cb..000000000 --- a/mach/sparc/.distr +++ /dev/null @@ -1,9 +0,0 @@ -Action -mach_params -ce -ce_cg -top -libem -libsys -libend -libdb diff --git a/mach/sparc/ce/.distr b/mach/sparc/ce/.distr deleted file mode 100644 index bb33187f0..000000000 --- a/mach/sparc/ce/.distr +++ /dev/null @@ -1,15 +0,0 @@ -EM_table -EM_table.x -Makefile -back.src -cache.c -cache.c.x -ce.src -cegpp -mach.c -mach.h -mach_em.h -misc.h -ms_reg.h -proto.make -push_pop.h diff --git a/mach/sparc/ce/back.src/.distr b/mach/sparc/ce/back.src/.distr deleted file mode 100644 index abd59b90e..000000000 --- a/mach/sparc/ce/back.src/.distr +++ /dev/null @@ -1,9 +0,0 @@ -Makefile -back.h -con_str.c -const.h -do_open.c -gen_str.c -header.h -rom_str.c -symboldef.c diff --git a/mach/sparc/ce/ce.src/.distr b/mach/sparc/ce/ce.src/.distr deleted file mode 100644 index b264bf3a7..000000000 --- a/mach/sparc/ce/ce.src/.distr +++ /dev/null @@ -1,14 +0,0 @@ -C_con_scon.c -C_cst.c -C_dlb.c -C_dnam.c -C_ilb.c -C_mes_begin.c -C_mes_end.c -C_pnam.c -C_rom_scon.c -C_scon.c -C_pro.c -C_exa_dnam.c -misc.c -ms_reg.c diff --git a/mach/sparc/ce_cg/.distr b/mach/sparc/ce_cg/.distr deleted file mode 100644 index c9c9751db..000000000 --- a/mach/sparc/ce_cg/.distr +++ /dev/null @@ -1,2 +0,0 @@ -convert.c -proto.make diff --git a/mach/sparc/libdb/.distr b/mach/sparc/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/sparc/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/sparc/libem/.distr b/mach/sparc/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/sparc/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/sparc/libend/.distr b/mach/sparc/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/sparc/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/sparc/libsys/.distr b/mach/sparc/libsys/.distr deleted file mode 100644 index 930a523fd..000000000 --- a/mach/sparc/libsys/.distr +++ /dev/null @@ -1,5 +0,0 @@ -LIST -libmon_s.a -head_em.s -SYS.h -syscall.h diff --git a/mach/sparc/top/.distr b/mach/sparc/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/sparc/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/sparc_solaris/.distr b/mach/sparc_solaris/.distr deleted file mode 100644 index 99e11b974..000000000 --- a/mach/sparc_solaris/.distr +++ /dev/null @@ -1,8 +0,0 @@ -Action -ce -ce_cg -libdb -libem -libend -libsys -mach_params diff --git a/mach/sparc_solaris/ce/.distr b/mach/sparc_solaris/ce/.distr deleted file mode 100644 index cafc23097..000000000 --- a/mach/sparc_solaris/ce/.distr +++ /dev/null @@ -1 +0,0 @@ -proto.make diff --git a/mach/sparc_solaris/ce_cg/.distr b/mach/sparc_solaris/ce_cg/.distr deleted file mode 100644 index cafc23097..000000000 --- a/mach/sparc_solaris/ce_cg/.distr +++ /dev/null @@ -1 +0,0 @@ -proto.make diff --git a/mach/sparc_solaris/libdb/.distr b/mach/sparc_solaris/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/sparc_solaris/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/sparc_solaris/libem/.distr b/mach/sparc_solaris/libem/.distr deleted file mode 100644 index 52c8084b9..000000000 --- a/mach/sparc_solaris/libem/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -libem_s.a -READ_ME -Makefile diff --git a/mach/sparc_solaris/libend/.distr b/mach/sparc_solaris/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/sparc_solaris/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/sparc_solaris/libsys/.distr b/mach/sparc_solaris/libsys/.distr deleted file mode 100644 index 0a68a588d..000000000 --- a/mach/sparc_solaris/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -libmon_s.a -head_em.s -SYS.h diff --git a/mach/sun2/.distr b/mach/sun2/.distr deleted file mode 100644 index 0e1e702e5..000000000 --- a/mach/sun2/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Action -cv -libsys -mach_params diff --git a/mach/sun2/cv/.distr b/mach/sun2/cv/.distr deleted file mode 100644 index cafc23097..000000000 --- a/mach/sun2/cv/.distr +++ /dev/null @@ -1 +0,0 @@ -proto.make diff --git a/mach/sun2/libsys/.distr b/mach/sun2/libsys/.distr deleted file mode 100644 index 52a9f74e4..000000000 --- a/mach/sun2/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -head_em.s -libmon_s.a -syscall.h diff --git a/mach/sun3/.distr b/mach/sun3/.distr deleted file mode 100644 index a1f6171f7..000000000 --- a/mach/sun3/.distr +++ /dev/null @@ -1,6 +0,0 @@ -Action -cv -libsys -ce -libce -mach_params diff --git a/mach/sun3/ce/.distr b/mach/sun3/ce/.distr deleted file mode 100644 index 34f604f30..000000000 --- a/mach/sun3/ce/.distr +++ /dev/null @@ -1,14 +0,0 @@ -EM_table -Make.back -proto.make -as.c -as.h -as_table -do_close.c -do_open.c -end_back.c -mach.c -mach.h -misc.c -output.c -relocation.c diff --git a/mach/sun3/cv/.distr b/mach/sun3/cv/.distr deleted file mode 100644 index 1ea8d092c..000000000 --- a/mach/sun3/cv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -cv.c -Xcv.c diff --git a/mach/sun3/liba68s/.distr b/mach/sun3/liba68s/.distr deleted file mode 100644 index 37100a8aa..000000000 --- a/mach/sun3/liba68s/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -compmodule diff --git a/mach/sun3/libce/.distr b/mach/sun3/libce/.distr deleted file mode 100644 index cb69c33b0..000000000 --- a/mach/sun3/libce/.distr +++ /dev/null @@ -1,23 +0,0 @@ -proto.make -adf4.s -adf8.s -cff.s -cfi.s -cfu.s -cif.s -cmf4.s -cmf8.s -cuf.s -dvf4.s -dvf8.s -fef4.s -fef8.s -fif4.s -fif8.s -mlf4.s -mlf8.s -sbf4.s -sbf8.s -vars.s -sys.s -head_em.s diff --git a/mach/sun3/libsys/.distr b/mach/sun3/libsys/.distr deleted file mode 100644 index 52a9f74e4..000000000 --- a/mach/sun3/libsys/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -head_em.s -libmon_s.a -syscall.h diff --git a/mach/vax4/.distr b/mach/vax4/.distr deleted file mode 100644 index 8eedeeff4..000000000 --- a/mach/vax4/.distr +++ /dev/null @@ -1,14 +0,0 @@ -Action -as -cg -libem -libce -libend -libbsd4_1a -libbsd4_2 -libsysV_2 -libdb -top -ce -cv -mach_params diff --git a/mach/vax4/as/.distr b/mach/vax4/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/vax4/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/vax4/ce/.distr b/mach/vax4/ce/.distr deleted file mode 100644 index e5974f654..000000000 --- a/mach/vax4/ce/.distr +++ /dev/null @@ -1,13 +0,0 @@ -EM_table -Make.back -proto.make -as.c -as.h -as_table -do_close.c -do_open.c -end_back.c -mach.c -mach.h -output.c -relocation.c diff --git a/mach/vax4/cg/.distr b/mach/vax4/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/vax4/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/vax4/cv/.distr b/mach/vax4/cv/.distr deleted file mode 100644 index cead68bd2..000000000 --- a/mach/vax4/cv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -cv.c diff --git a/mach/vax4/libbsd4_1a/.distr b/mach/vax4/libbsd4_1a/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/vax4/libbsd4_1a/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/vax4/libbsd4_2/.distr b/mach/vax4/libbsd4_2/.distr deleted file mode 100644 index 52a9f74e4..000000000 --- a/mach/vax4/libbsd4_2/.distr +++ /dev/null @@ -1,4 +0,0 @@ -LIST -head_em.s -libmon_s.a -syscall.h diff --git a/mach/vax4/libce/.distr b/mach/vax4/libce/.distr deleted file mode 100644 index a24fc2610..000000000 --- a/mach/vax4/libce/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -sys.s diff --git a/mach/vax4/libdb/.distr b/mach/vax4/libdb/.distr deleted file mode 100644 index af5eda499..000000000 --- a/mach/vax4/libdb/.distr +++ /dev/null @@ -1 +0,0 @@ -machdep.s diff --git a/mach/vax4/libem/.distr b/mach/vax4/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/vax4/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/vax4/libend/.distr b/mach/vax4/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/vax4/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/vax4/libsysV_2/.distr b/mach/vax4/libsysV_2/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/vax4/libsysV_2/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/vax4/pmfile b/mach/vax4/pmfile deleted file mode 100644 index 55ac2a34f..000000000 --- a/mach/vax4/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/vax4/" - -mach_vax4 = group { - ARCH = "vax4", - - proto_as, - proto_cg, - proto_top, - ego_descr, - - install = { - pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr"), - } -} - --- Revision history --- $Log$ --- Revision 1.3 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.2 2006/07/22 00:52:01 dtrg --- Added support for the ego global optimisation suite. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/vax4/top/.distr b/mach/vax4/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/vax4/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/vc4/as/binary.h b/mach/vc4/as/binary.h new file mode 100644 index 000000000..c00e73550 --- /dev/null +++ b/mach/vc4/as/binary.h @@ -0,0 +1,34 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef BINARY_H +#define BINARY_H + +/* This grotesque nonsense allows us to use binary constants from C. */ + +#define HEX__(n) 0x##n##LU +#define B8__(x) \ + ((x&0x0000000FLU)?1:0) \ + +((x&0x000000F0LU)?2:0) \ + +((x&0x00000F00LU)?4:0) \ + +((x&0x0000F000LU)?8:0) \ + +((x&0x000F0000LU)?16:0) \ + +((x&0x00F00000LU)?32:0) \ + +((x&0x0F000000LU)?64:0) \ + +((x&0xF0000000LU)?128:0) + +#define B8(d) \ + ((unsigned char)B8__(HEX__(d))) +#define B16(dmsb,dlsb) \ + (((unsigned short)B8(dmsb)<<8) + B8(dlsb)) +#define B32(dmsb,db2,db3,dlsb) \ + (((unsigned long)B8(dmsb)<<24) \ + + ((unsigned long)B8(db2)<<16) \ + + ((unsigned long)B8(db3)<<8) \ + + B8(dlsb)) + +#endif diff --git a/mach/vc4/as/mach0.c b/mach/vc4/as/mach0.c new file mode 100644 index 000000000..2df70061c --- /dev/null +++ b/mach/vc4/as/mach0.c @@ -0,0 +1,32 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#define THREE_PASS /* branch and offset optimization */ +#define LISTING /* enable listing facilities */ +#define RELOCATION /* generate relocatable code */ +#define DEBUG 0 + +#undef valu_t +#define valu_t long + +#undef ADDR_T +#define ADDR_T long + +#undef word_t +#define word_t long + +typedef unsigned long quad; + +#undef ALIGNWORD +#define ALIGNWORD 4 + +#undef ALIGNSECT +#define ALIGNSECT 4 + +#undef VALWIDTH +#define VALWIDTH 8 + diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c new file mode 100644 index 000000000..44caf0c57 --- /dev/null +++ b/mach/vc4/as/mach1.c @@ -0,0 +1,28 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "binary.h" + +#define ALWAYS 14 + +extern void alu_instr_reg(quad opcode, int cc, int rd, int ra, int rb); +extern void alu_instr_lit(quad opcode, int cc, int rd, int ra, long value); +extern void misc_instr_reg(quad opcode, int cc, int rd, int ra, int rb); +extern void misc_instr_lit(quad opcode, int cc, int rd, int ra, quad value); +extern void branch_instr(int bl, int cc, struct expr_t* expr); +extern void stack_instr(quad opcode, int loreg, int hireg, int extrareg); +extern void mem_instr(quad opcode, int cc, int rd, long offset, int rs); +extern void mem_offset_instr(quad opcode, int cc, int rd, int qa, int rb); +extern void mem_postincr_instr(quad opcode, int cc, int rd, int rs); +extern void mem_address_instr(quad opcode, int rd, struct expr_t* expr); +extern void branch_addcmp_reg_reg_instr(int cc, int rd, int ra, int rs, struct expr_t* expr); +extern void branch_addcmp_lit_reg_instr(int cc, int rd, long va, int rs, struct expr_t* expr); +extern void branch_addcmp_reg_lit_instr(int cc, int rd, int ra, long vs, struct expr_t* expr); +extern void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr); +extern void lea_stack_instr(int rd, long va, int rs); +extern void lea_address_instr(int rd, struct expr_t* expr); +extern void fltcnv_instr(quad opcode, int cc, int rd, int ra, quad shift); diff --git a/mach/vc4/as/mach2.c b/mach/vc4/as/mach2.c new file mode 100644 index 000000000..ec7a948d8 --- /dev/null +++ b/mach/vc4/as/mach2.c @@ -0,0 +1,24 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +%token GPR +%token CC + +%token OP +%token OP_BRANCH OP_BRANCHLINK OP_ADDCMPB +%token OP_ONEREG +%token OP_ONELREG +%token OP_ALU +%token OP_FPU +%token OP_MEM +%token OP_MISC +%token OP_MISCL +%token OP_FLTCNV +%token OP_STACK +%token OP_LEA + + diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c new file mode 100644 index 000000000..4ca73f4ed --- /dev/null +++ b/mach/vc4/as/mach3.c @@ -0,0 +1,153 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +/* Integer registers */ + +0, GPR, 0, "r0", +0, GPR, 1, "r1", +0, GPR, 2, "r2", +0, GPR, 3, "r3", +0, GPR, 4, "r4", +0, GPR, 5, "r5", + +0, GPR, 6, "r6", +0, GPR, 7, "r7", +0, GPR, 8, "r8", +0, GPR, 9, "r9", +0, GPR, 10, "r10", +0, GPR, 11, "r11", +0, GPR, 12, "r12", +0, GPR, 13, "r13", +0, GPR, 14, "r14", +0, GPR, 15, "r15", +0, GPR, 16, "r16", +0, GPR, 17, "r17", +0, GPR, 18, "r18", +0, GPR, 19, "r19", +0, GPR, 20, "r20", +0, GPR, 21, "r21", +0, GPR, 22, "r22", +0, GPR, 23, "r23", +0, GPR, 24, "r24", +0, GPR, 24, "fp", + +0, GPR, 25, "r25", +0, GPR, 25, "sp", +0, GPR, 26, "r26", +0, GPR, 26, "lr", +0, GPR, 27, "r27", +0, GPR, 28, "r28", +0, GPR, 29, "r29", +0, GPR, 30, "r30", +0, GPR, 30, "sr", +0, GPR, 31, "r31", +0, GPR, 31, "pc", + +/* Condition codes */ + +0, CC, 0, ".eq", +0, CC, 1, ".ne", +0, CC, 2, ".cs", +0, CC, 2, ".lo", +0, CC, 3, ".cc", +0, CC, 3, ".hs", +0, CC, 4, ".mi", +0, CC, 5, ".pl", +0, CC, 6, ".vs", +0, CC, 7, ".vc", +0, CC, 8, ".hi", +0, CC, 9, ".ls", +0, CC, 10, ".ge", +0, CC, 11, ".lt", +0, CC, 12, ".gt", +0, CC, 13, ".le", +0, CC, 15, ".f", + +/* Special instructions */ + +0, OP, B16(00000000,00000001), "nop", +0, OP, B16(00000000,00001010), "rti", + +0, OP_BRANCH, 0, "b", +0, OP_BRANCHLINK, 0, "bl", +0, OP_ADDCMPB, 0, "addcmpb", + +0, OP_ONELREG, B16(00000000,10000000), "tbb", +0, OP_ONELREG, B16(00000000,10100000), "tbs", + +0, OP_ALU, B8(00000000), "mov", +0, OP_ALU, B8(00000001), "cmn", +0, OP_ALU, B8(00000010), "add", +0, OP_ALU, B8(00000011), "bic", +0, OP_ALU, B8(00000100), "mul", +0, OP_ALU, B8(00000101), "eor", +0, OP_ALU, B8(00000110), "sub", +0, OP_ALU, B8(00000111), "and", +0, OP_ALU, B8(00001000), "mvn", +0, OP_ALU, B8(00001001), "ror", +0, OP_ALU, B8(00001010), "cmp", +0, OP_ALU, B8(00001011), "rsb", +0, OP_ALU, B8(00001100), "btst", +0, OP_ALU, B8(00001101), "or", +0, OP_ALU, B8(00001110), "extu", +0, OP_ALU, B8(00001111), "max", +0, OP_ALU, B8(00010000), "bset", +0, OP_ALU, B8(00010001), "min", +0, OP_ALU, B8(00010010), "bclr", +0, OP_ALU, B8(00010011), "adds2", +0, OP_ALU, B8(00010100), "bchg", +0, OP_ALU, B8(00010101), "adds4", +0, OP_ALU, B8(00010110), "adds8", +0, OP_ALU, B8(00010111), "adds16", +0, OP_ALU, B8(00011000), "exts", +0, OP_ALU, B8(00011001), "neg", +0, OP_ALU, B8(00011010), "lsr", +0, OP_ALU, B8(00011011), "log2", +0, OP_ALU, B8(00011100), "lsl", +0, OP_ALU, B8(00011101), "brev", +0, OP_ALU, B8(00011110), "asr", +0, OP_ALU, B8(00011111), "abs", + +0, OP_MISC, B16(11001000,00000000), "fadd", +0, OP_MISC, B16(11001000,00100000), "fsub", +0, OP_MISC, B16(11001000,01000000), "fmul", +0, OP_MISC, B16(11001000,01100000), "fdiv", +0, OP_MISC, B16(11001000,10000000), "fcmp", +0, OP_MISC, B16(11001000,10100000), "fabs", +0, OP_MISC, B16(11001000,11000000), "frsb", +0, OP_MISC, B16(11001000,11100000), "fmax", +0, OP_MISC, B16(11001001,00000000), "frcp", +0, OP_MISC, B16(11001001,00100000), "frsqrt", +0, OP_MISC, B16(11001001,01000000), "fnmul", +0, OP_MISC, B16(11001001,01100000), "fmin", +0, OP_MISC, B16(11001001,10000000), "fld1", +0, OP_MISC, B16(11001001,10100000), "fld0", +0, OP_MISC, B16(11001001,11000000), "log2", +0, OP_MISC, B16(11001001,11100000), "exp2", +0, OP_MISC, B16(11000101,11100000), "adds256", + +0, OP_FLTCNV, B16(11001010,00000000), "ftrunc", +0, OP_FLTCNV, B16(11001010,00100000), "floor", +0, OP_FLTCNV, B16(11001010,01000000), "flts", +0, OP_FLTCNV, B16(11001010,01100000), "fltu", + +0, OP_MISCL, B16(11000100,10000000), "divs", +0, OP_MISCL, B16(11000100,11100000), "divu", + +0, OP_STACK, B16(00000010,10000000), "push", +0, OP_STACK, B16(00000010,00000000), "pop", + +0, OP_MEM, B8(00000000), "ld", +0, OP_MEM, B8(00000001), "st", +0, OP_MEM, B8(00000010), "ldh", +0, OP_MEM, B8(00000011), "sth", +0, OP_MEM, B8(00000100), "ldb", +0, OP_MEM, B8(00000101), "stb", +0, OP_MEM, B8(00000110), "ldhs", +0, OP_MEM, B8(00000111), "sths", + +0, OP_LEA, 0, "lea", diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c new file mode 100644 index 000000000..99c368c12 --- /dev/null +++ b/mach/vc4/as/mach4.c @@ -0,0 +1,87 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +operation + : OP { emit2($1); } + + | OP_BRANCH GPR { emit2(B16(00000000,01000000) | ($2<<0)); } + | OP_BRANCHLINK GPR { emit2(B16(00000000,01100000) | ($2<<0)); } + + | OP_BRANCH expr { branch_instr(0, ALWAYS, &$2); } + | OP_BRANCHLINK expr { branch_instr(1, ALWAYS, &$2); } + | OP_BRANCH CC expr { branch_instr(0, $2, &$3); } + | OP_BRANCHLINK CC expr { branch_instr(1, $2, &$3); } + + | OP_BRANCH GPR ',' GPR ',' expr { branch_addcmp_lit_reg_instr(ALWAYS, $2, 0, $4, &$6); } + | OP_BRANCH CC GPR ',' GPR ',' expr { branch_addcmp_lit_reg_instr($2, $3, 0, $5, &$7); } + | OP_BRANCH GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr(ALWAYS, $2, 0, $5, &$7); } + | OP_BRANCH CC GPR ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr($2, $3, 0, $6, &$8); } + | OP_ADDCMPB GPR ',' GPR ',' GPR ',' expr { branch_addcmp_reg_reg_instr(ALWAYS, $2, $4, $6, &$8); } + | OP_ADDCMPB CC GPR ',' GPR ',' GPR ',' expr { branch_addcmp_reg_reg_instr($2, $3, $5, $7, &$9); } + | OP_ADDCMPB GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_lit_reg_instr(ALWAYS, $2, $5, $7, &$9); } + | OP_ADDCMPB CC GPR ',' '#' absexp ',' GPR ',' expr { branch_addcmp_lit_reg_instr($2, $3, $6, $8, &$10); } + | OP_ADDCMPB GPR ',' GPR ',' '#' absexp ',' expr { branch_addcmp_reg_lit_instr(ALWAYS, $2, $4, $7, &$9); } + | OP_ADDCMPB CC GPR ',' GPR ',' '#' absexp ',' expr { branch_addcmp_reg_lit_instr($2, $3, $5, $8, &$10); } + | OP_ADDCMPB GPR ',' '#' absexp ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr(ALWAYS, $2, $5, $8, &$10); } + | OP_ADDCMPB CC GPR ',' '#' absexp ',' '#' absexp ',' expr { branch_addcmp_lit_lit_instr($2, $3, $6, $9, &$11); } + + | OP_ONELREG GPR + { + if ($2 >= 0x10) + serror("cannot use r16+ here"); + emit2($1 | ($2<<0)); + } + + | OP_ALU GPR ',' GPR { alu_instr_reg($1, ALWAYS, $2, $2, $4); } + | OP_ALU GPR ',' GPR ',' GPR { alu_instr_reg($1, ALWAYS, $2, $4, $6); } + | OP_ALU CC GPR ',' GPR { alu_instr_reg($1, $2, $3, $3, $5); } + | OP_ALU CC GPR ',' GPR ',' GPR { alu_instr_reg($1, $2, $3, $5, $7); } + + | OP_ALU GPR ',' '#' absexp { alu_instr_lit($1, ALWAYS, $2, $2, $5); } + | OP_ALU GPR ',' GPR ',' '#' absexp { alu_instr_lit($1, ALWAYS, $2, $4, $7); } + | OP_ALU CC GPR ',' '#' absexp { alu_instr_lit($1, $2, $3, $3, $6); } + | OP_ALU CC GPR ',' GPR ',' '#' absexp { alu_instr_lit($1, $2, $3, $5, $8); } + + | OP_MISC GPR ',' GPR ',' GPR { misc_instr_reg($1, ALWAYS, $2, $4, $6); } + | OP_MISC CC GPR ',' GPR ',' GPR { misc_instr_reg($1, $2, $3, $5, $7); } + + | OP_MISCL GPR ',' GPR ',' GPR { misc_instr_reg($1, ALWAYS, $2, $4, $6); } + | OP_MISCL CC GPR ',' GPR ',' GPR { misc_instr_reg($1, $2, $3, $5, $7); } + | OP_MISCL GPR ',' GPR ',' '#' absexp { misc_instr_lit($1, ALWAYS, $2, $4, $7); } + | OP_MISCL CC GPR ',' GPR ',' '#' absexp { misc_instr_lit($1, $2, $3, $5, $8); } + + | OP_STACK GPR { stack_instr($1, $2, $2, -1); } + | OP_STACK GPR ',' GPR { stack_instr($1, $2, $2, $4); } + | OP_STACK GPR '-' GPR { stack_instr($1, $2, $4, -1); } + | OP_STACK GPR '-' GPR ',' GPR { stack_instr($1, $2, $4, $6); } + + | OP_MEM GPR ',' '(' GPR ')' { mem_instr($1, ALWAYS, $2, 0, $5); } + | OP_MEM CC GPR ',' '(' GPR ')' { mem_instr($1, $2, $3, 0, $6); } + | OP_MEM GPR ',' absexp '(' GPR ')' { mem_instr($1, ALWAYS, $2, $4, $6); } + | OP_MEM CC GPR ',' absexp '(' GPR ')' { mem_instr($1, $2, $3, $5, $7); } + + | OP_MEM GPR ',' '(' GPR ',' GPR ')' { mem_offset_instr($1, ALWAYS, $2, $5, $7); } + | OP_MEM CC GPR ',' '(' GPR ',' GPR ')' { mem_offset_instr($1, $2, $3, $6, $8); } + + | OP_MEM GPR ',' '(' GPR ')' '+' '+' { mem_postincr_instr($1, ALWAYS, $2, $5); } + | OP_MEM CC GPR ',' '(' GPR ')' '+' '+' { mem_postincr_instr($1, $2, $3, $6); } + + | OP_MEM GPR ',' expr { mem_address_instr($1, $2, &$4); } + + | OP_LEA GPR ',' absexp '(' GPR ')' { lea_stack_instr($2, $4, $6); } + | OP_LEA GPR ',' expr { lea_address_instr($2, &$4); } + + | OP_FLTCNV GPR ',' GPR { fltcnv_instr($1, ALWAYS, $2, $4, 0); } + | OP_FLTCNV CC GPR ',' GPR { fltcnv_instr($1, $2, $3, $5, 0); } + | OP_FLTCNV GPR ',' GPR ',' shift '#' absexp { fltcnv_instr($1, ALWAYS, $2, $4, $8); } + | OP_FLTCNV CC GPR ',' GPR ',' shift '#' absexp { fltcnv_instr($1, $2, $3, $5, $9); } + ; + +shift + : 'l' 's' 'r' + | 'l' 's' 'l'; + diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c new file mode 100644 index 000000000..5ff56f779 --- /dev/null +++ b/mach/vc4/as/mach5.c @@ -0,0 +1,501 @@ +/* + * VideoCore IV assembler for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include + +#define maskx(v, x) (v & ((1<<(x))-1)) + +static void toobig(void) +{ + serror("offset too big to encode into instruction"); +} + +/* Assemble an ALU instruction where rb is a register. */ + +void alu_instr_reg(quad op, int cc, int rd, int ra, int rb) +{ + /* Can we use short form? */ + + if ((cc == ALWAYS) && (ra == rd) && (ra < 0x10) && (rb < 0x10)) + { + emit2(B16(01000000,00000000) | (op<<8) | (rb<<4) | (rd<<0)); + return; + } + + /* Long form, then. */ + + emit2(B16(11000000,00000000) | (op<<5) | (rd<<0)); + emit2(B16(00000000,00000000) | (ra<<11) | (cc<<7) | (rb<<0)); +} + +/* Assemble an ALU instruction where rb is a literal. */ + +void alu_instr_lit(quad op, int cc, int rd, int ra, long value) +{ + /* 16 bit short form? */ + + if ((cc == ALWAYS) && !(op & 1) && (value >= 0) && (value <= 0x1f) && + (ra == rd) && (ra < 0x10)) + { + emit2(B16(01100000,00000000) | (op<<8) | (value<<4) | (rd<<0)); + return; + } + + /* 32 bit medium form? */ + + if ((value >= 0) && (value <= 0x1f)) + { + emit2(B16(11000000,00000000) | (op<<5) | (rd<<0)); + emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | (value<<0)); + return; + } + + /* Long form, then. */ + + if (cc != ALWAYS) + serror("cannot use condition codes with ALU literals this big"); + + /* add is special. */ + + if (op == B8(00000010)) + emit2(B16(11101100,00000000) | (ra<<5) | (rd<<0)); + else + { + if (ra != rd) + serror("can only use 2op form of ALU instructions with literals this big"); + emit2(B16(11101000,00000000) | (op<<5) | (rd<<0)); + } + + emit4(value); +} + +/* Miscellaneous instructions with three registers and a cc. */ + +void misc_instr_reg(quad op, int cc, int rd, int ra, int rb) +{ + emit2(op | (rd<<0)); + emit2(B16(00000000,00000000) | (ra<<11) | (cc<<7) | (rb<<0)); +} + +/* Miscellaneous instructions with two registers, a literal, and a cc. */ + +void misc_instr_lit(quad op, int cc, int rd, int ra, quad value) +{ + if (value < 0x1f) + serror("only constants from 0..31 can be used here"); + + emit2(op | (rd<<0)); + emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | (value<<0)); +} + +/* Assemble a branch instruction. This may be a near branch into this + * object file, or a far branch which requires a fixup. */ + +void branch_instr(int bl, int cc, struct expr_t* expr) +{ + quad pc = DOTVAL; + quad type = expr->typ & S_TYP; + int d; + + /* Sanity checking. */ + + if (bl && (cc != ALWAYS)) + serror("can't use condition codes with bl"); + if (type == S_ABS) + serror("can't use absolute addresses here"); + + /* The VC4 branch instructions express distance in 2-byte + * words. */ + + d = (int32_t)expr->val - (int32_t)pc; + if ((pass == 2) && (d > 0) && !(expr->typ & S_DOT)) + d -= DOTGAIN; + d /= 2; + + /* If this is a reference to code within this section, and it's + * close enough to the program counter, we can use a short- + * form instruction. */ + + if (small(!bl && (type == DOTTYP) && fitx(d, 7), 2)) + { + emit2(B16(00011000,00000000) | (cc<<7) | (d&0x7f)); + return; + } + + /* Absolute addresses and references to other sections + * need the full 32 bits. */ + + newrelo(expr->typ, RELOVC4|RELPC); + + if (bl) + { + quad v, hiv, lov; + + if (!fitx(d, 27)) + toobig(); + + v = maskx(d, 27); + hiv = v >> 23; + lov = v & 0x007fffff; + emit2(B16(10010000,10000000) | (lov>>16) | (hiv<<8)); + emit2(B16(00000000,00000000) | (lov&0xffff)); + } + else + { + quad v; + + if (!fitx(d, 23)) + toobig(); + + v = maskx(d, 23); + emit2(B16(10010000,00000000) | (cc<<8) | (v>>16)); + emit2(B16(00000000,00000000) | (v&0xffff)); + } +} + +/* Push/pop. */ + +void stack_instr(quad opcode, int loreg, int hireg, int extrareg) +{ + int b; + int m; + + switch (loreg) + { + case 0: b = 0; break; + case 6: b = 1; break; + case 16: b = 2; break; + case 24: b = 3; break; + + case 26: /* lr */ + extrareg = 26; + hireg = loreg = -1; + break; + + case 31: /* pc */ + extrareg = 31; + hireg = loreg = -1; + break; + + default: + serror("base register for push or pop may be only r0, r6, r16, r24, lr or pc"); + } + + if (opcode & 0x0080) + { + /* Push */ + if (extrareg == 31) + serror("cannot push pc"); + } + else + { + /* Pop */ + if (extrareg == 26) + serror("cannot pop lr"); + } + + if (hireg < loreg) + serror("invalid register range"); + + if (hireg == -1) + { + b = 3; + m = 15; + } + else + m = hireg - loreg; + + emit2(opcode | (b<<5) | (m<<0) | ((extrareg != -1) ? 0x0100 : 0)); +} + +/* Memory operations where the offset is a fixed value (including zero). */ + +void mem_instr(quad opcode, int cc, int rd, long offset, int rs) +{ + quad uoffset = (quad) offset; + int multiple4 = !(offset & 3); + int intonly = ((opcode & B8(00000110)) == 0); + + /* If no CC, there are some special forms we can use. */ + + if (cc == ALWAYS) + { + /* Very short form, special for stack offsets. */ + + if (intonly && (rs == 25) && multiple4 && fitx(offset, 7) && (rd < 0x10)) + { + quad o = maskx(offset, 7) / 4; + emit2(B16(00000100,00000000) | (opcode<<9) | (o<<4) | (rd<<0)); + return; + } + + /* Slightly longer form for directly dereferencing via a register. */ + + if ((rs < 0x10) && (rd < 0x10) && (offset == 0)) + { + emit2(B16(00001000,00000000) | (opcode<<8) | (rs<<4) | (rd<<0)); + return; + } + + /* Integer only, but a limited offset. */ + + if (intonly && (uoffset <= 0x3f) && (rs < 0x10) && (rd < 0x10)) + { + quad o = uoffset / 4; + emit2(B16(00100000,00000000) | (opcode<<12) | (o<<8) | + (rs<<4) | (rd<<0)); + return; + } + + /* Certain registers support 16-bit offsets. */ + + if (fitx(offset, 16)) + { + switch (rs) + { + case 0: opcode = B16(10101011,00000000) | (opcode<<5); goto specialreg; + case 24: opcode = B16(10101000,00000000) | (opcode<<5); goto specialreg; + case 25: opcode = B16(10101001,00000000) | (opcode<<5); goto specialreg; + case 31: opcode = B16(10101010,00000000) | (opcode<<5); goto specialreg; + default: break; + + specialreg: + { + quad o = maskx(offset, 16); + emit2(opcode | (rd<<0)); + emit2(o); + return; + } + } + } + + /* 12-bit displacements. */ + + if (fitx(offset, 12)) + { + quad looffset = maskx(offset, 11); + quad hioffset = (offset >> 11) & 1; + + emit2(B16(10100010,00000000) | (opcode<<5) | (rd<<0) | (hioffset<<8)); + emit2(B16(00000000,00000000) | (rs<<11) | (looffset<<0)); + return; + } + + /* Everything else uses Very Long Form. */ + + if (!fitx(offset, 27)) + serror("offset will not fit into load/store instruction"); + + if (rs == 31) + opcode = B16(11100111,00000000) | (opcode<<5); + else + opcode = B16(11100110,00000000) | (opcode<<5); + + emit2(opcode | (rd<<0)); + emit4((rs<<27) | maskx(offset, 27)); + return; + } + + /* Now we're on to load/store instructions with ccs. */ + + if (uoffset <= 0x1f) + { + emit2(B16(10100000,00000000) | (opcode<<5) | (rd<<0)); + emit2(B16(00000000,01000000) | (rs<<11) | (cc<<7) | (uoffset<<0)); + return; + } + + /* No encoding for this instruction. */ + + serror("invalid load/store instruction"); +} + +/* Memory operations where the destination address is a sum of two + * registers. */ + +void mem_offset_instr(quad opcode, int cc, int rd, int ra, int rb) +{ + emit2(B16(10100000,00000000) | (opcode<<5) | (rd<<0)); + emit2(B16(00000000,00000000) | (ra<<11) | (cc<<7) | (rb<<0)); +} + +/* Memory operations with postincrement. */ + +void mem_postincr_instr(quad opcode, int cc, int rd, int rs) +{ + emit2(B16(10100101,00000000) | (opcode<<5) | (rd<<0)); + emit2(B16(00000000,00000000) | (rs<<11) | (cc<<7)); +} + +/* Memory operations where the destination is an address literal. */ + +void mem_address_instr(quad opcode, int rd, struct expr_t* expr) +{ + static const char sizes[] = {4, 4, 2, 2, 1, 1, 2, 2}; + int size = sizes[opcode]; + quad type = expr->typ & S_TYP; + int d, scaledd; + + /* Sanity checking. */ + + if (type == S_ABS) + serror("can't use absolute addresses here"); + + d = expr->val - DOTVAL; + if ((pass == 2) && (d > 0) && !(expr->typ & S_DOT)) + d -= DOTGAIN; + scaledd = d/size; + + /* If this is a reference to an address within this section, and + * it's close enough to the program counter, we can use a + * shorter instruction. */ + + if (small((type==DOTTYP) && fitx(scaledd, 16), 2)) + { + emit2(B16(10101010,00000000) | (opcode<<5) | (rd<<0)); + emit2(scaledd); + return; + } + + /* Otherwise we need the full 48 bits. */ + + newrelo(expr->typ, RELOVC4|RELPC); + + /* VC4 relocations store the PC-relative delta into the + * destination section in the instruction data. The linker will + * massage this, and scale it appropriately. */ + + if (!fitx(d, 27)) + toobig(); + + emit2(B16(11100111,00000000) | (opcode<<5) | (rd<<0)); + emit4((31<<27) | maskx(d, 27)); +} + +/* Common code for handling addcmp: merge in as much of expr as will fit to + * the second pair of the addcmp opcode. */ + +static void branch_addcmp_common(quad opcode, int bits, struct expr_t* expr) +{ + quad type = expr->typ & S_TYP; + int d; + + if ((pass>0) && (type != DOTTYP)) + serror("can't use this type of branch to jump outside the section"); + + /* The VC4 branch instructions express distance in 2-byte + * words. */ + + d = (expr->val - DOTVAL-2 + 4); + if ((pass == 2) && (d > 0) && !(expr->typ & S_DOT)) + d -= DOTGAIN; + d /= 2; + + if ((pass == 2) && !fitx(d, bits)) + serror("target of branch is too far away"); + + emit2(opcode | maskx(d, bits)); +} + +void branch_addcmp_reg_reg_instr(int cc, int rd, int ra, int rs, struct expr_t* expr) +{ + if ((rd >= 0x10) || (ra >= 0x10) || (rs >= 0x10)) + serror("can only use r0-r15 in this instruction"); + + emit2(B16(10000000,00000000) | (cc<<8) | (ra<<4) | (rd<<0)); + branch_addcmp_common(B16(00000000,00000000) | (rs<<10), 10, expr); +} + +void branch_addcmp_lit_reg_instr(int cc, int rd, long va, int rs, struct expr_t* expr) +{ + if ((rd >= 0x10) || (rs >= 0x10)) + serror("can only use r0-r15 in this instruction"); + + if (!fitx(va, 4)) + serror("value too big to encode into instruction"); + va = maskx(va, 4); + + emit2(B16(10000000,00000000) | (cc<<8) | (va<<4) | (rd<<0)); + branch_addcmp_common(B16(01000000,00000000) | (rs<<10), 10, expr); +} + +void branch_addcmp_reg_lit_instr(int cc, int rd, int ra, long vs, struct expr_t* expr) +{ + if ((rd >= 0x10) || (ra >= 0x10)) + serror("can only use r0-r15 in this instruction"); + + if (!fitx(vs, 6)) + serror("value too big to encode into instruction"); + vs = maskx(vs, 6); + + emit2(B16(10000000,00000000) | (cc<<8) | (ra<<4) | (rd<<0)); + branch_addcmp_common(B16(10000000,00000000) | (vs<<8), 8, expr); +} + +void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr) +{ + if (rd >= 0x10) + serror("can only use r0-r15 in this instruction"); + + if (!fitx(va, 4) || !fitx(vs, 6)) + serror("value too big to encode into instruction"); + va = maskx(va, 4); + vs = maskx(vs, 6); + + emit2(B16(10000000,00000000) | (cc<<8) | (va<<4) | (rd<<0)); + branch_addcmp_common(B16(11000000,00000000) | (vs<<8), 8, expr); +} + +/* lea, where the source is relative to the stack. */ + +void lea_stack_instr(int rd, long va, int rs) +{ + if (rs != 25) + serror("source register must be sp"); + + va /= 4; + if (!fitx(va, 6)) + serror("offset too big to encode in instruction"); + va = maskx(va, 6); + + emit2(B16(00010000,00000000) | (rd<<0) | (va<<5)); +} + +/* lea, where the source is an address. */ + +void lea_address_instr(int rd, struct expr_t* expr) +{ + quad pc = DOTVAL; + quad type = expr->typ & S_TYP; + int d = expr->val - pc; + + if ((pass == 2) && (d > 0) && !(expr->typ & S_DOT)) + d -= DOTGAIN; + + if (type == S_ABS) + serror("can't use absolute addresses here"); + + newrelo(expr->typ, RELOVC4|RELPC); + + /* VC4 relocations store the PC-relative delta into the + * destination section in the instruction data. The linker will + * massage this, and scale it appropriately. */ + + emit2(B16(11100101,00000000) | (rd<<0)); + emit4(expr->val - pc); +} + +/* Floating point conversion opcodes (ftrunc, floor, flts, fltu). */ + +void fltcnv_instr(quad opcode, int cc, int rd, int ra, quad shift) +{ + fitx(shift, 6); + + emit2(opcode | (rd<<0)); + emit2(B16(00000000,01000000) | (ra<<11) | (cc<<7) | shift); +} + diff --git a/mach/vc4/libem/build.lua b/mach/vc4/libem/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/vc4/libem/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/vc4/libem/csa.s b/mach/vc4/libem/csa.s new file mode 100644 index 000000000..25332f2a7 --- /dev/null +++ b/mach/vc4/libem/csa.s @@ -0,0 +1,36 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "videocore.h" + +.define .csa +.sect .data +.csa: + ! on entry: + ! r0 = un-fixed-up descriptor + ! r1 = value + add r0, gp + + ld r2, 4 (r0) ! check lower bound + + b.lo r1, r2, default ! jump to default if r1 < r2 + + sub r1, r2 ! adjust value to be 0-based + + ld r2, 8 (r0) ! check upper bound + b.hi r1, r2, default ! jump to default if r1 > r2 + + add r1, #3 +go: + ld r1, (r0, r1) ! load destination address + add r1, gp + b r1 ! ...and go + +default: + mov r1, #0 ! index of default value + b go diff --git a/mach/vc4/libem/csb.s b/mach/vc4/libem/csb.s new file mode 100644 index 000000000..7ed74c39f --- /dev/null +++ b/mach/vc4/libem/csb.s @@ -0,0 +1,33 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "videocore.h" + +.define .csb +.sect .data +.csb: + ! on entry: + ! r0 = un-fixed-up descriptor + ! r1 = value + add r0, gp ! r0 = fixed up descriptor + + adds8 r2, r0, #1 ! r2 = moving pointer + ld r3, 4 (r0) ! r3 = count + adds8 r3, r0, r3 ! r3 = end ptr + +loop: + ld r4, (r2)++ + b.eq r4, r1, matched ! r2 points at matching addr + addcmpb.le r2, #4, r3, loop +notmatched: + mov r2, r0 ! r2 points at default jump +matched: + ld r2, (r2) ! load destination address + add r2, gp ! fix up r2 + b r2 ! ...and go + diff --git a/mach/vc4/libem/videocore.h b/mach/vc4/libem/videocore.h new file mode 100644 index 000000000..8ccb981ee --- /dev/null +++ b/mach/vc4/libem/videocore.h @@ -0,0 +1,17 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +#define gp r15 + diff --git a/mach/vc4/libend/build.lua b/mach/vc4/libend/build.lua new file mode 100644 index 000000000..ca5a13c65 --- /dev/null +++ b/mach/vc4/libend/build.lua @@ -0,0 +1,8 @@ +for _, plat in ipairs(vars.plats) do + acklibrary { + name = "lib_"..plat, + srcs = { "./*.s" }, + vars = { plat = plat }, + } +end + diff --git a/mach/vc4/libend/edata.s b/mach/vc4/libend/edata.s new file mode 100644 index 000000000..e706877db --- /dev/null +++ b/mach/vc4/libend/edata.s @@ -0,0 +1,15 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _edata +.sect .data +_edata: diff --git a/mach/vc4/libend/em_end.s b/mach/vc4/libend/em_end.s new file mode 100644 index 000000000..bae5aaa0c --- /dev/null +++ b/mach/vc4/libend/em_end.s @@ -0,0 +1,24 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .end ! only for declaration of _end, __end and endbss. +.define endtext, endrom, enddata, endbss, __end + + .sect .text +endtext: + .sect .rom +endrom: + .sect .data +enddata: + .sect .end +__end: +endbss: diff --git a/mach/vc4/libend/end.s b/mach/vc4/libend/end.s new file mode 100644 index 000000000..5ce2882b6 --- /dev/null +++ b/mach/vc4/libend/end.s @@ -0,0 +1,15 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _end +.sect .end ! only for declaration of _end, __end and endbss. +_end: diff --git a/mach/vc4/libend/etext.s b/mach/vc4/libend/etext.s new file mode 100644 index 000000000..973ab1814 --- /dev/null +++ b/mach/vc4/libend/etext.s @@ -0,0 +1,15 @@ +# +/* + * VideoCore IV support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.define _etext +.sect .text +_etext: diff --git a/mach/vc4/ncg/mach.c b/mach/vc4/ncg/mach.c new file mode 100644 index 000000000..124e8a965 --- /dev/null +++ b/mach/vc4/ncg/mach.c @@ -0,0 +1,86 @@ +/* + * VideoCore IV code generator for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include + +int framesize; + +/* Write out a constant data section. */ + +con_part(int sz, word w) +{ + while (part_size % sz) + part_size++; + if (part_size == TEM_WSIZE) + part_flush(); + if (sz == 1 || sz == 2) { + w &= (sz == 1 ? 0xFF : 0xFFFF); + w <<= 8 * part_size; + part_word |= w; + } else { + assert(sz == 4); + part_word = w; + } + part_size += sz; +} + +con_mult(word sz) +{ + if (argval != 4) + fatal("bad icon/ucon size"); + fprintf(codefile,".data4 %s\n", str); +} + +#define CODE_GENERATOR +#define IEEEFLOAT +#define FL_MSL_AT_LOW_ADDRESS 0 +#define FL_MSW_AT_LOW_ADDRESS 0 +#define FL_MSB_AT_LOW_ADDRESS 0 +#include + +void prolog(full nlocals) +{ + int ss = nlocals + 8; + fprintf(codefile, "push fp, lr\n"); + fprintf(codefile, "mov fp, sp\n"); + if (nlocals > 0) + fprintf(codefile, "sub sp, #%d\n", nlocals); + + framesize = nlocals; +} + +mes(word type) +{ + int argt ; + + switch ( (int)type ) { + case ms_ext : + for (;;) { + switch ( argt=getarg( + ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) { + case sp_cend : + return ; + default: + strarg(argt) ; + fprintf(codefile,".define %s\n",argstr) ; + break ; + } + } + default : + while ( getarg(any_ptyp) != sp_cend ) ; + break ; + } +} + +char *segname[] = { + ".sect .text", + ".sect .data", + ".sect .rom", + ".sect .bss" +}; + diff --git a/mach/vc4/ncg/mach.h b/mach/vc4/ncg/mach.h new file mode 100644 index 000000000..89d2b8a97 --- /dev/null +++ b/mach/vc4/ncg/mach.h @@ -0,0 +1,32 @@ +/* + * VideoCore IV code generator for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#define ex_ap(y) fprintf(codefile,".extern %s\n",y) +#define in_ap(y) /* nothing */ + +#define newilb(x) fprintf(codefile,"%s:\n",x) +#define newdlb(x) fprintf(codefile,"%s:\n",x) +#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y) +#define newlbss(l,x) fprintf(codefile,".comm %s,%u\n",l,x); + +#define cst_fmt "%d" +#define off_fmt "%d" +#define ilb_fmt "I%x_%x" +#define dlb_fmt "_%d" +#define hol_fmt "hol%d" + +#define hol_off "%ld+hol%d" + +#define con_cst(x) fprintf(codefile,".data4\t%ld\n",x) +#define con_ilb(x) fprintf(codefile,".data4\t%s\n",x) +#define con_dlb(x) fprintf(codefile,".data4\t%s\n",x) + +#define fmt_id(sf, st) sprintf(st,"_%s",sf) + +#define modhead ".sect .text; .sect .rom; .sect .data; .sect .bss\n" + +#define BSS_INIT 0 diff --git a/mach/vc4/ncg/table b/mach/vc4/ncg/table new file mode 100644 index 000000000..8b4fe60a5 --- /dev/null +++ b/mach/vc4/ncg/table @@ -0,0 +1,1560 @@ +/* + * VideoCore IV code generator for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +EM_WSIZE = 4 +EM_PSIZE = 4 +EM_BSIZE = 8 /* two words saved in call frame */ + +BYTE = 1 /* Size of values */ +WORD = 2 +QUAD = 4 + +FP_OFFSET = 0 /* Offset of saved FP relative to our FP */ +PC_OFFSET = 4 /* Offset of saved PC relative to our FP */ + +#define COMMENT(n) /* noop */ + + +#define nicesize(x) ((x)==BYTE || (x)==WORD || (x)==QUAD) + + + +PROPERTIES + + GPR /* any GPR */ + REG /* any allocatable GPR */ + STACKABLE /* a register than can be used with push/pop */ + + GPR0 GPR1 GPR2 GPR3 GPR4 GPR5 GPR6 GPR7 + GPR8 GPR9 GPR10 GPR11 GPR12 GPR13 GPR14 GPR15 + GPR16 GPR17 GPR18 GPR19 GPR20 GPR21 GPR22 GPR23 + + GPRGP GPRFP GPRSP GPRLR GPRPC + +REGISTERS + + R0("r0") : GPR, REG, GPR0, STACKABLE. + R1("r1") : GPR, REG, GPR1. + R2("r2") : GPR, REG, GPR2. + R3("r3") : GPR, REG, GPR3. + R4("r4") : GPR, REG, GPR4. + R5("r5") : GPR, REG, GPR5. + R6("r6") : GPR, GPR6. + R7("r7") : GPR, REG, GPR7. + R8("r8") : GPR, REG, GPR8. + R9("r9") : GPR, REG, GPR9. + R10("r10") : GPR, REG, GPR10. + R11("r11") : GPR, REG, GPR11. + R12("r12") : GPR, REG, GPR12. + R13("r13") : GPR, REG, GPR13. + R14("r14") : GPR, REG, GPR14. + GP("r15") : GPR, GPRGP. + + R16("r16") : GPR, GPR16. + + R23("r23") : GPR. + FP("fp") : GPR, GPRFP. + SP("sp") : GPR, GPRSP. + LR("lr") : GPR, GPRLR. + PC("pc") : GPR, GPRPC. + /* r26 to r31 are special and the code generator doesn't touch them. */ + + #define SCRATCH R6 + +TOKENS + +/* Used only in instruction descriptions (to generate the correct syntax). */ + + GPROFFSET = { GPR reg; INT off; } 4 off "(" reg ")". + GPRGPR = { GPR reg1; GPR reg2; } 4 "(" reg1 "," reg2 ")". + GPRINC = { GPR reg; } 4 "(" reg ")++". + ADDCMPB_LL = { GPR rd; INT val; INT vs; ADDR dest; } 4 rd ",#" val ",#" vs "," dest. + +/* Primitives */ + + LABEL = { ADDR adr; } 4 adr. + CONST = { INT val; } 4 "#" val. + +/* Sign extended values. */ + + /* The size refers to the *source*. */ + SIGNEX8 = { GPR reg; } 4 reg. + SIGNEX16 = { GPR reg; } 4 reg. + +/* The results of comparisons. */ + + TRISTATE_RC_S = { GPR reg; INT val; } 4. + TRISTATE_RC_U = { GPR reg; INT val; } 4. + TRISTATE_RR_S = { GPR reg1; GPR reg2; } 4. + TRISTATE_RR_U = { GPR reg1; GPR reg2; } 4. + + + +SETS + + TOKEN = LABEL + CONST. + OP = TOKEN + SIGNEX8 + SIGNEX16. + ANY = GPR + OP. + + + +INSTRUCTIONS + + add GPR:wo, GPR:ro, GPR+CONST:ro. + add GPR:rw, GPR+CONST:ro. + addcmpbge "addcmpb.ge" ADDCMPB_LL:rw. + adds2 GPR:rw, GPR+CONST:ro. + adds4 GPR:rw, GPR+CONST:ro. + adds8 GPR:rw, GPR+CONST:ro. + adds16 GPR:rw, GPR+CONST:ro. + adds256 GPR:rw, GPR:rw, GPR:ro. + and GPR:rw, GPR+CONST:ro. + asr GPR:rw, GPR+CONST:ro. + beq "b.eq" LABEL:ro. + bne "b.ne" LABEL:ro. + bgt "b.gt" LABEL:ro. + blt "b.lt" LABEL:ro. + bhi "b.hi" LABEL:ro. + bset GPR:rw, GPR+CONST:ro. + b GPR+LABEL:ro. + bl GPR+LABEL:ro. + cmp GPR:ro, GPR+CONST:ro kills :cc. + divs GPR:wo, GPR:ro, GPR+CONST:ro. + divu GPR:wo, GPR:ro, GPR+CONST:ro. + eor GPR:rw, GPR+CONST:ro. + exts GPR:wo, GPR:ro, GPR+CONST:ro. + exts GPR:rw, GPR+CONST:ro. + fadd GPR:wo, GPR:ro, GPR:ro. + fcmp GPR:wo, GPR:ro, GPR:ro. + fdiv GPR:wo, GPR:ro, GPR:ro. + flts GPR:wo, GPR:ro. + fltu GPR:wo, GPR:ro. + fmul GPR:wo, GPR:ro, GPR:ro. + fsub GPR:wo, GPR:ro, GPR:ro. + ftrunc GPR:wo, GPR:ro. + ld GPR:wo, GPRINC:rw. + ld GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldb GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldh GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. + ldhs GPR:wo, GPROFFSET+GPRGPR+LABEL:ro. + lea GPR:wo, LABEL:ro. + lsl GPR:rw, GPR+CONST:ro. + lsl GPR:wo, GPR:ro, GPR+CONST:ro. + lsr GPR:rw, GPR+CONST:ro. + mov GPR:wo, GPR+CONST:ro. + mul GPR:rw, GPR+CONST:ro. + mvn GPR:wo, GPR+CONST:ro. + neg GPR:rw, GPR+CONST:ro. + or GPR:rw, GPR+CONST:ro. + pop GPR0+GPR6+GPR16+GPRFP+GPRPC:wo. + pop GPR0+GPR6+GPR16+GPRFP:wo, GPRPC:wo. + push GPR0+GPR6+GPR16+GPRFP+GPRLR:ro. + push GPR0+GPR6+GPR16+GPRFP:ro, GPRLR:ro. + rsb GPR:rw, GPR+CONST:ro. + sub GPR:wo, GPR:ro, CONST+GPR:ro. + sub GPR:rw, GPR+CONST:ro. + st GPR:ro, GPRINC:rw. + st GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. + stb GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. + sth GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. + sths GPR:ro, GPROFFSET+GPRGPR+LABEL:ro. + + invalid "invalid". + comment "!" LABEL:ro. + + + +MOVES + + from GPR to GPR + gen + COMMENT("mov GPR->GPR") + mov %2, %1 + +/* Constants */ + + from CONST to GPR + gen + mov %2, %1 + + from LABEL to GPR + gen + lea %2, {LABEL, %1.adr} + sub %2, GP + +/* Sign extension */ + + from SIGNEX8 to GPR + gen + exts %2, %1.reg, {CONST, 8} + + from SIGNEX16 to GPR + gen + exts %2, %1.reg, {CONST, 16} + +/* Miscellaneous */ + + from CONST+LABEL+GPR to GPR + gen + move %1, %2 + + +TESTS + + to test GPR + gen + cmp %1, {CONST, 0} + + + +STACKINGRULES + + from GPR0+GPR6+GPR16 to STACK + gen + comment {LABEL, "push stackable"} + push %1 + + from OP+GPR to STACK + uses GPR0 + gen + move %1, %a + push %a + + from OP to STACK + uses STACKABLE + gen + move %1, %a + push %a + + from OP+GPR to STACK + gen + comment {LABEL, "push via scratch"} + move %1, SCRATCH + push SCRATCH + + + + +COERCIONS + + from OP + uses REG + gen + move %1, %a + yields %a + + from STACK + uses REG + gen + pop SCRATCH + move SCRATCH, %a + yields %a + + + +PATTERNS + +/* Intrinsics */ + + pat nop /* Does nothing */ + + pat loc /* Load constant */ + yields {CONST, $1} + + pat dup $1<=QUAD /* Duplicate word on top of stack */ + with ANY + yields %1 %1 + + pat dup $1==(2*QUAD) /* Duplicate word pair on top of stack */ + with ANY ANY + yields %1 %2 %1 %2 + + pat exg $1<=QUAD /* Exchange top two words on stack */ + with ANY ANY + yields %1 %2 + + pat exg $1==(2*QUAD) /* Exchange top two word pairs on stack */ + with ANY ANY ANY ANY + yields %2 %1 %4 %3 + + pat stl lol $1==$2 /* Store then load local */ + leaving + dup QUAD + stl $1 + + pat lal sti lal loi $1==$3 && $2==$4 /* Store then load local, of a different size */ + leaving + dup $2 + lal $1 + sti $2 + + pat ste loe $1==$2 /* Store then load external */ + leaving + dup QUAD + ste $1 + + + +/* Type conversions */ + + pat loc loc cii loc loc cii $1==$4 && $2==$5 /* madness, generated by the C compiler */ + leaving + loc $1 + loc $2 + cii + + pat loc loc cii loc loc cii $2==QUAD && $5==QUAD && $4<$2 /* madness, generated by the C compiler */ + leaving + loc $4 + loc $5 + cii + + pat loc loc ciu /* signed X -> unsigned X */ + leaving + loc $1 + loc $2 + cuu + + pat loc loc cuu $1==$2 /* unsigned X -> unsigned X */ + /* nop */ + + pat loc loc cii $1==$2 /* signed X -> signed X */ + /* nop */ + + pat loc loc cui $1==$2 /* unsigned X -> signed X */ + /* nop */ + + pat loc loc cui $1==BYTE && $2==QUAD /* unsigned char -> signed int */ + /* nop */ + + pat loc loc cui $1==WORD && $2==QUAD /* unsigned short -> signed int */ + /* nop */ + + pat loc loc cii $1==BYTE && $2>BYTE /* signed char -> anything */ + with GPR + yields {SIGNEX8, %1} + with SIGNEX8 + yields {SIGNEX8, %1.reg} + with SIGNEX16 + yields {SIGNEX8, %1.reg} + + pat loc loc cii $1==WORD && $2>WORD /* signed short -> anything */ + with GPR + yields {SIGNEX16, %1} + with SIGNEX8 + yields {SIGNEX16, %1.reg} + with SIGNEX16 + yields {SIGNEX16, %1.reg} + + + +/* Local variables */ + + pat lal /* Load address of local */ + uses REG + gen + sub %a, FP, GP + add %a, {CONST, $1} + yields %a + + pat lol /* Load quad from local */ + uses REG + gen + ld %a, {GPROFFSET, FP, $1} + yields %a + + pat ldl /* Load double-word from local */ + leaving + lol $1 + QUAD*1 + lol $1 + QUAD*0 + + pat stl /* Store to local */ + with GPR + gen + st %1, {GPROFFSET, FP, $1} + + pat sdl /* Store double-word to local */ + leaving + stl $1 + QUAD*0 + stl $1 + QUAD*1 + + pat lil /* Load from indirected local */ + leaving + lol $1 + loi QUAD + + pat sil /* Save to indirected local */ + leaving + lol $1 + sti QUAD + + pat stl lol $1==$2 /* Save then load (generated by C compiler) */ + leaving + dup QUAD + stl $1 + + pat zrl /* Zero local */ + leaving + loc 0 + stl $1 + + pat inl /* Increment local in register */ + leaving + lol $1 + loc 1 + adi QUAD + stl $1 + + pat del /* Decrement local in register */ + leaving + lol $1 + loc 1 + sbi QUAD + stl $1 + + + +/* Global variables */ + + pat lpi /* Load address of external function */ + leaving + lae $1 + + pat lae /* Load address of external */ + yields {LABEL, $1} + + pat loe /* Load word external */ + leaving + lae $1 + loi QUAD + + pat ste /* Store word external */ + leaving + lae $1 + sti QUAD + + pat zre /* Zero external */ + leaving + loc 0 + ste $1 + + pat ine /* Increment external */ + leaving + loe $1 + inc + ste $1 + + pat dee /* Decrement external */ + leaving + loe $1 + dec + ste $1 + + pat lde /* Load double external */ + leaving + lae $1 + loi QUAD*2 + + pat sde /* Store double external */ + leaving + lae $1 + sti QUAD*2 + + +/* Structures */ + + pat lof /* Load word offsetted */ + leaving + adp $1 + loi QUAD + + pat ldf /* Load double offsetted */ + with GPR + uses reusing %1, REG=%1, REG + gen + add %a, GP + ld %b, {GPROFFSET, %a, $1+4} + ld %a, {GPROFFSET, %a, $1+0} + yields %a %b + + pat stf /* Store word offsetted */ + leaving + adp $1 + sti QUAD + + pat sdf /* Store double offsetted */ + with GPR GPR GPR + uses reusing %3, REG=%3 + gen + add %a, GP + st %1, {GPROFFSET, %a, $1+0} + st %2, {GPROFFSET, %a, $1+4} + + + + +/* Loads and stores */ + + pat loi $1==BYTE /* Load byte indirect */ + with LABEL + uses REG + gen + ldb %a, %1 + yields %a + with GPR + uses reusing %1, REG + gen + ldb %a, {GPRGPR, %1, GP} + yields %a + + pat loi loc loc cii $1==WORD && $2==WORD && $3==QUAD /* Load short indirect and sign extend */ + with LABEL + uses REG + gen + ldhs %a, %1 + yields %a + with GPR + uses reusing %1, REG + gen + add %a, %1, GP + ldhs %a, {GPROFFSET, %a, 0} + yields %a + + pat loi $1==WORD /* Load short indirect */ + with LABEL + uses REG + gen + ldh %a, %1 + yields %a + with GPR + uses reusing %1, REG + gen + add %a, %1, GP + ldh %a, {GPROFFSET, %a, 0} + yields %a + + pat loi $1==QUAD /* Load quad indirect */ + with LABEL + uses REG + gen + ld %a, %1 + yields %a + with GPR + uses reusing %1, REG + gen + add %a, %1, GP + ld %a, {GPROFFSET, %a, 0} + yields %a + + pat loi $1==2*QUAD /* Load double-quad indirect */ + with LABEL + uses REG, REG + gen + lea %b, %1 + ld %a, {GPROFFSET, %b, 0} + ld %b, {GPROFFSET, %b, 4} + yields %b %a + with GPR + uses reusing %1, REG, REG + gen + add %b, %1, GP + ld %a, {GPROFFSET, %b, 0} + ld %b, {GPROFFSET, %b, 4} + yields %b %a + + pat loi $1==3*QUAD /* Load triple-quad indirect */ + with LABEL + uses REG, REG, REG + gen + lea %b, %1 + ld %a, {GPROFFSET, %b, 0} + ld %b, {GPROFFSET, %b, 4} + ld %b, {GPROFFSET, %b, 8} + yields %c %b %a + with GPR + uses reusing %1, REG, REG, REG + gen + add %b, %1, GP + ld %a, {GPROFFSET, %b, 0} + ld %b, {GPROFFSET, %b, 4} + ld %c, {GPROFFSET, %b, 8} + yields %c %b %a + + pat loi /* Load arbitrary size */ + leaving + loc $1 + los QUAD + + pat los /* Load arbitrary size */ + leaving + cal ".los" + + pat sti $1==BYTE /* Store byte indirect */ + with LABEL GPR + gen + stb %2, %1 + with LABEL SIGNEX8+SIGNEX16 + gen + stb %2.reg, %1 + with GPR GPR + gen + stb %2, {GPRGPR, %1, GP} + with GPR SIGNEX8+SIGNEX16 + gen + stb %2.reg, {GPRGPR, %1, GP} + + pat sti $1==WORD /* Store half-word indirect */ + with LABEL GPR + gen + sth %2, %1 + with LABEL SIGNEX16 + gen + sth %2.reg, %1 + with GPR GPR + uses reusing %1, REG + gen + add %a, %1, GP + sth %2, {GPROFFSET, %a, 0} + with GPR SIGNEX16 + uses reusing %1, REG + gen + add %a, %1, GP + sth %2.reg, {GPROFFSET, %a, 0} + + pat sti $1==QUAD /* Store quad indirect */ + with LABEL GPR + gen + st %2, %1 + with GPR GPR + uses reusing %1, REG + gen + add %a, %1, GP + st %2, {GPROFFSET, %a, 0} + + pat sti $1==2*QUAD /* Load double-quad indirect */ + with LABEL GPR GPR + uses REG + gen + lea %a, %1 + st %2, {GPROFFSET, %a, 0} + st %3, {GPROFFSET, %a, 4} + with GPR GPR GPR + uses reusing %1, REG=%1 + gen + add %a, GP + st %2, {GPROFFSET, %a, 0} + st %3, {GPROFFSET, %a, 4} + + pat sti $1==3*QUAD /* Load triple-quad indirect */ + with LABEL GPR GPR GPR + uses REG + gen + lea %a, %1 + st %2, {GPROFFSET, %a, 0} + st %3, {GPROFFSET, %a, 4} + st %4, {GPROFFSET, %a, 8} + with GPR GPR GPR GPR + uses reusing %1, REG=%1 + gen + add %a, GP + st %2, {GPROFFSET, %a, 0} + st %3, {GPROFFSET, %a, 4} + st %4, {GPROFFSET, %a, 8} + + pat sti /* Store arbitrary size */ + leaving + loc $1 + sts QUAD + + pat sts /* Store arbitrary size */ + leaving + cal ".sts" + + + +/* Arithmetic wrappers */ + + pat ads /* Add var to pointer */ + leaving adi $1 + + pat sbs /* Subtract var from pointer */ + leaving sbi $1 + + pat adp /* Add constant to pointer */ + leaving + loc $1 + adi QUAD + + pat adu /* Add unsigned */ + leaving + adi $1 + + pat sbu /* Subtract unsigned */ + leaving + sbi $1 + + pat inc /* Add 1 */ + leaving + loc 1 + adi QUAD + + pat dec /* Subtract 1 */ + leaving + loc 1 + sbi QUAD + + pat loc mlu /* Unsigned multiply by constant */ + leaving + loc $1 + mli QUAD + + pat mlu /* Unsigned multiply by var */ + leaving + mli QUAD + + pat loc slu /* Shift left unsigned by constant amount */ + leaving + loc $1 + sli $2 + + pat slu /* Shift left unsigned by variable amount */ + leaving + sli $1 + + + +/* Word arithmetic */ + + pat loc adi $1==0 /* Add nothing */ + /* nop */ + + pat adi $1==QUAD /* Add word (second + top) */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + add %a, %1 + yields %a + with GPR GPR+CONST + uses reusing %1, REG=%1 + gen + add %a, %2 + yields %a + + pat loc sbi $1==0 /* Subtract nothing */ + /* nop */ + + pat sbi $1==QUAD /* Subtract word (second - top) */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + sub %a, %1 + yields %a + + pat mli $1==QUAD /* Multiply word (second * top) */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + mul %a, %1 + yields %a + with GPR GPR+CONST + uses reusing %1, REG=%1 + gen + mul %a, %2 + yields %a + + pat mlu + leaving + mli $1 + + pat dvi $1==QUAD /* Divide word (second / top) */ + with GPR GPR + uses reusing %2, REG + gen + divs %a, %2, %1 + yields %a + + pat dvu $1==QUAD /* Divide unsigned word (second / top) */ + with GPR GPR + uses reusing %2, REG + gen + divu %a, %2, %1 + yields %a + + pat rmu $1==QUAD /* Remainder unsigned word (second % top) */ + with GPR GPR + uses REG + gen + divu %a, %2, %1 + mul %a, %1 + rsb %a, %2 + yields %a + + pat rmi $1==QUAD /* Remainder signed word (second % top) */ + with GPR GPR + uses REG + gen + divs %a, %2, %1 + mul %a, %1 + rsb %a, %2 + yields %a + + pat ngi $1==QUAD /* Negate word */ + with GPR + uses reusing %1, REG=%1 + gen + neg %a, %a + yields %a + + pat and $1==QUAD /* AND word */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + and %a, %1 + yields %a + with GPR GPR+CONST + uses reusing %1, REG=%1 + gen + and %a, %2 + yields %a + + pat ior $1==QUAD /* OR word */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + or %a, %1 + yields %a + with GPR GPR+CONST + uses reusing %1, REG=%1 + gen + or %a, %2 + yields %a + + pat xor $1==QUAD /* XOR word */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + eor %a, %1 + yields %a + with GPR GPR+CONST + uses reusing %1, REG=%1 + gen + eor %a, %2 + yields %a + + pat com $1==QUAD /* Complement */ + with GPR + uses reusing %1, REG=%1 + gen + mvn %a, %1 + yields %a + + pat dvi $1==QUAD /* Divide word (second / top) */ + with GPR GPR + uses reusing %2, REG + gen + divs %a, %2, %1 + yields %a + + pat dvu $1==QUAD /* Divide unsigned word (second / top) */ + with GPR GPR + uses reusing %2, REG + gen + divu %a, %2, %1 + yields %a + + pat rmu $1==QUAD /* Remainder unsigned word (second % top) */ + with GPR GPR + uses REG + gen + divu %a, %2, %1 + mul %a, %1 + sub %a, %2 + yields %a + + pat rmi $1==QUAD /* Remainder signed word (second % top) */ + with GPR GPR + uses REG + gen + divs %a, %2, %1 + mul %a, %1 + sub %a, %2 + yields %a + +#if 0 + pat mli $1==4 /* Multiply word (second * top) */ + with REG REG + uses reusing %2, REG + gen + mullw %a, %2, %1 + yields %a + + + pat xor $1==4 /* XOR word */ + with GPR GPR + yields {XOR_RR, %1, %2} + with GPR CONST + yields {XOR_RC, %1, %2.val} + with CONST GPR + yields {XOR_RC, %2, %1.val} + + pat xor !defined($1) /* XOR set */ + with STACK + gen + bl {LABEL, ".xor"} + + pat com $1==QUAD /* NOT word */ + with AND_RR + uses REG + gen + nand %a, %1.reg1, %1.reg2 + yields %a + with OR_RR + uses REG + gen + nor %a, %1.reg1, %1.reg2 + yields %a + with XOR_RR + uses REG + gen + eqv %a, %1.reg1, %1.reg2 + yields %a + with GPR + yields {NOT_R, %1} + + pat com !defined($1) /* NOT set */ + with STACK + gen + bl {LABEL, ".com"} +#endif + + pat sli $1==4 /* Shift left (second << top) */ + with CONST+GPR GPR + uses reusing %2, REG=%2 + gen + lsl %a, %1 + yields %a + + pat sri $1==4 /* Shift right signed (second >> top) */ + with CONST+GPR GPR + uses reusing %2, REG=%2 + gen + asr %2, %1 + yields %a + + pat sru $1==4 /* Shift right unsigned (second >> top) */ + with CONST+GPR GPR + uses reusing %2, REG=%2 + gen + lsr %2, %1 + yields %a + + + +/* Special arithmetic */ + + pat loc sli adi $1==1 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<1) */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + adds2 %a, %1 + yields %a + + pat loc sli adi $1==2 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<2) */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + adds4 %a, %1 + yields %a + + pat loc sli adi $1==3 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<3) */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + adds8 %a, %1 + yields %a + + pat loc sli adi $1==4 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<4) */ + with GPR+CONST GPR + uses reusing %2, REG=%2 + gen + adds16 %a, %1 + yields %a + + pat loc sli adi $1==8 && $2==QUAD && $3==QUAD /* Shift and add (second + top<<8) */ + with GPR GPR + uses reusing %2, REG + gen + adds256 %a, %2, %1 + yields %a + + pat loc sli ads + leaving + loc $1 + sli $2 + adi $3 + + + +/* Arrays */ + + pat aar $1==QUAD /* Index array */ + with STACK + uses GPR0 + gen + bl {LABEL, ".aar4stack"} + yields R0 + with GPR0 GPR1 GPR2 + uses GPR0 + gen + bl {LABEL, ".aar4"} + yields R0 + + pat lae lar $2==QUAD && nicesize(rom($1, 3)) /* Load array */ + leaving + lae $1 + aar QUAD + loi rom($1, 3) + + pat lar $1==QUAD /* Load array */ + with STACK + uses GPR0 + gen + bl {LABEL, ".lar4stack"} + yields R0 + with GPR0 GPR1 GPR2 + uses GPR0 + gen + bl {LABEL, ".lar4"} + yields R0 + + pat lae sar $2==QUAD && nicesize(rom($1, 3)) /* Store array */ + leaving + lae $1 + aar QUAD + sti rom($1, 3) + + pat sar $1==QUAD /* Store array */ + with STACK + uses GPR0 + gen + bl {LABEL, ".sar4stack"} + yields R0 + with GPR0 GPR1 GPR2 + uses GPR0 + gen + bl {LABEL, ".sar4"} + + + +/* Sets */ + + pat set $1==QUAD /* Create quad with one bit set */ + with GPR + uses reusing %1, REG + gen + bset %a, %1 + yields %a + + pat set defined($1) /* Any other set */ + leaving + loc $1 + cal ".set" + + pat set !defined($1) /* Create structure with set bit (variable) */ + leaving + cal ".set" + + pat inn defined($1) /* Test for set bit */ + leaving + set $1 + and $1 + + pat inn !defined($1) /* Test for set bit (variable) */ + leaving + cal ".inn" + + pat ior !nicesize($1) /* OR set */ + leaving + cal ".ior" + + pat ior !defined($1) /* OR set */ + leaving + cal ".ior" + + pat and !nicesize($1) /* AND set */ + leaving + loc $1 + cal ".and" + + pat and !defined($1) /* AND set */ + leaving + cal ".and" + + + +/* Boolean resolutions */ + + proc cm_t example teq + with GPR GPR + uses reusing %1, REG + gen + cmp %1, %2 + mov %a, {CONST, 0} + add[1] %a, {CONST, 1} + yields %a + + pat cmu teq call cm_t("add.eq") /* top = (second == top) */ + pat cmu tne call cm_t("add.ne") /* top = (second != top) */ + pat cmu tlt call cm_t("add.lo") /* top = unsigned (second < top) */ + pat cmu tle call cm_t("add.ls") /* top = unsigned (second <= top) */ + pat cmu tgt call cm_t("add.hi") /* top = unsigned (second < top) */ + pat cmu tge call cm_t("add.hs") /* top = unsigned (second >= top) */ + pat cmi teq call cm_t("add.eq") /* top = (second == top) */ + pat cmi tne call cm_t("add.ne") /* top = (second != top) */ + pat cmi tlt call cm_t("add.lt") /* top = signed (second < top) */ + pat cmi tle call cm_t("add.le") /* top = signed (second <= top) */ + pat cmi tgt call cm_t("add.gt") /* top = signed (second < top) */ + pat cmi tge call cm_t("add.ge") /* top = signed (second >= top) */ + + proc cmf_t example teq + with GPR GPR + uses reusing %1, REG + gen + fcmp %a, %1, %2 + mov %a, {CONST, 0} + add[1] %a, {CONST, 1} + yields %a + + pat cmf teq call cmf_t("add.eq") /* top = float (second == top) */ + pat cmf tne call cmf_t("add.ne") /* top = float (second != top) */ + pat cmf tlt call cmf_t("add.lo") /* top = float (second < top) */ + pat cmf tle call cmf_t("add.ls") /* top = float (second <= top) */ + pat cmf tgt call cmf_t("add.hi") /* top = float (second > top) */ + pat cmf tge call cmf_t("add.hs") /* top = float (second >= top) */ + + proc fallback_t example teq + with GPR + uses reusing %1, REG + gen + cmp %1, {CONST, 0} + mov %a, {CONST, 0} + add[1] %a, {CONST, 1} + yields %a + + pat teq call fallback_t("add.eq") /* top = float (top == 0) */ + pat tne call fallback_t("add.ne") /* top = float (top != 0) */ + pat tlt call fallback_t("add.lo") /* top = float (top < 0) */ + pat tle call fallback_t("add.ls") /* top = float (top <= 0) */ + pat tgt call fallback_t("add.hi") /* top = float (top > 0) */ + pat tge call fallback_t("add.hs") /* top = float (top >= 0) */ + + + +/* Simple branches */ + + proc anyz example zeq + with GPR STACK + kills ALL + gen + cmp %1, {CONST, 0} + beq[1] {LABEL, $1} + + pat zeq call anyz("b.eq") /* Branch if signed top == 0 */ + pat zne call anyz("b.ne") /* Branch if signed top != 0 */ + pat zgt call anyz("b.gt") /* Branch if signed top > 0 */ + pat zlt call anyz("b.lt") /* Branch if signed top < 0 */ + pat zge call anyz("b.ge") /* Branch if signed top >= 0 */ + pat zle call anyz("b.le") /* Branch if signed top <= 0 */ + + proc anyb example beq + with GPR+CONST GPR STACK + kills ALL + gen + cmp %2, %1 + beq[1] {LABEL, $1} + + pat beq call anyb("b.eq") /* Branch if signed second == top */ + pat bne call anyb("b.ne") /* Branch if signed second != top */ + pat bgt call anyb("b.gt") /* Branch if signed second > top */ + pat bge call anyb("b.ge") /* Branch if signed second >= top */ + pat blt call anyb("b.lt") /* Branch if signed second < top */ + pat ble call anyb("b.le") /* Branch if signed second <= top */ + + proc cmu_z example cmu zeq + with GPR+CONST GPR STACK + kills ALL + gen + cmp %2, %1 + beq[1] {LABEL, $2} + + pat cmu zeq call cmu_z("b.eq") /* Branch if unsigned second == top */ + pat cmu zne call cmu_z("b.ne") /* Branch if unsigned second != top */ + pat cmu zgt call cmu_z("b.hi") /* Branch if unsigned second > top */ + pat cmu zlt call cmu_z("b.lo") /* Branch if unsigned second < top */ + pat cmu zge call cmu_z("b.hs") /* Branch if unsigned second >= top */ + pat cmu zle call cmu_z("b.ls") /* Branch if unsigned second <= top */ + pat cmi zeq call cmu_z("b.eq") /* Branch if signed second == top */ + pat cmi zne call cmu_z("b.ne") /* Branch if signed second != top */ + pat cmi zgt call cmu_z("b.gt") /* Branch if signed second > top */ + pat cmi zlt call cmu_z("b.lt") /* Branch if signed second < top */ + pat cmi zge call cmu_z("b.ge") /* Branch if signed second >= top */ + pat cmi zle call cmu_z("b.le") /* Branch if signed second <= top */ + + proc cmf_z example cmu zeq + with GPR GPR STACK + kills ALL + gen + fcmp %2, %2, %1 + beq[1] {LABEL, $2} + + pat cmf zeq call cmf_z("b.eq") /* Branch if float second == top */ + pat cmf zne call cmf_z("b.ne") /* Branch if float second != top */ + pat cmf zgt call cmf_z("b.gt") /* Branch if float second > top */ + pat cmf zlt call cmf_z("b.lt") /* Branch if float second < top */ + pat cmf zge call cmf_z("b.ge") /* Branch if float second >= top */ + pat cmf zle call cmf_z("b.le") /* Branch if float second <= top */ + + pat cmp /* Compare pointers */ + leaving + cmu QUAD + + pat cms $1==QUAD /* Compare blocks (word sized) */ + leaving + cmi QUAD + + + + + +/* Other branching and labelling */ + +#if 0 + pat lab topeltsize($1)<=4 && !fallthrough($1) + gen + labeldef $1 + yields R0 + + pat lab topeltsize($1)<=4 && fallthrough($1) + with GPR0 + gen + labeldef $1 + yields %1 + + pat lab topeltsize($1)>4 + with STACK + kills ALL + gen + labeldef $1 + + pat bra topeltsize($1)<=4 /* Unconditional jump with TOS register */ + with GPR0 STACK + gen + b {LABEL, $1} + + pat bra topeltsize($1)>4 /* Unconditional jump without TOS register */ + with STACK + gen + b {LABEL, $1} +#endif + + pat lab + with STACK + kills ALL + gen + labeldef $1 + + pat bra + with STACK + kills ALL + gen + b {LABEL, $1} + + + + +/* Miscellaneous */ + + pat cal /* Call procedure */ + with STACK + kills ALL + gen + bl {LABEL, $1} + + pat cai /* Call procedure indirect */ + with GPR STACK + kills ALL + gen + bl %1 + + pat lfr $1==QUAD /* Load function result, word */ + yields R0 + + pat lfr $1==QUAD*2 /* Load function result, word */ + yields R1 R0 + + pat ret $1==0 /* Return from procedure */ + gen + mov SP, FP + pop FP, PC + + pat ret $1==QUAD /* Return from procedure, word */ + with GPR0 + gen + mov SP, FP + pop FP, PC + + pat ret $1==QUAD*2 /* Return from procedure, word */ + with GPR GPR + gen + move %1, R0 + move %2, R1 + mov SP, FP + pop FP, PC + + pat blm /* Block move constant length */ + leaving + loc $1 + bls + + pat bls /* Block move variable length */ + with STACK + kills ALL + gen + bl {LABEL, "_memmove"} + + pat csa /* Array-lookup switch */ + with GPR0 GPR1 STACK + kills ALL + gen + b {LABEL, ".csa"} + + pat csb /* Table-lookup switch */ + with GPR0 GPR1 STACK + kills ALL + gen + bl {LABEL, ".csb"} + + + +/* EM specials */ + + pat fil /* Set current filename */ + leaving + lae $1 + ste ".filename" + + pat lin /* Set current line number */ + leaving + loc $1 + ste ".linenumber" + + pat lni /* Increment line number */ + leaving + ine ".linenumber" + + pat lim /* Load EM trap ignore mask */ + leaving + lde ".ignmask" + + pat sim /* Store EM trap ignore mask */ + leaving + ste ".ignmask" + + pat trp /* Raise EM trap */ + leaving + cal ".trap" + + pat sig /* Set trap handler */ + leaving + ste ".trppc" + + pat rtt /* Return from trap */ + leaving + ret 0 + + pat lxl $1==0 /* Load FP */ + leaving + lor 0 + + pat lxl $1==1 /* Load caller's FP */ + leaving + lxl 0 + dch + + pat dch /* FP -> caller FP */ + with GPR + uses reusing %1, REG + gen + ld %a, {GPROFFSET, %1, FP_OFFSET} + sub %a, GP + yields %a + + pat lpb /* Convert FP to argument address */ + leaving + adp EM_BSIZE + + pat lxa /* Load caller's SP */ + leaving + lxl $1 + lpb + + pat gto /* longjmp */ + uses REG, REG + gen + move {LABEL, $1}, %a + ld %b, {GPROFFSET, %a, 8} + add FP, %b, GP + ld %b, {GPROFFSET, %a, 4} + add SP, %b, GP + ld %b, {GPROFFSET, %a, 0} + add %b, GP + b %b + +#if 0 + + pat gto /* longjmp */ + with STACK + gen + ld {LABEL, $1+2} + wspec {CONST, 1} + ld {LABEL, $1+4} + wspec {CONST, 0} + ld {LABEL, $1+0} + wspec {CONST, 2} + + pat str $1==1 /* Store special GPRister */ + with GPR0 + gen + wspec {CONST, $1} + +#endif + + pat lor $1==0 /* Load FP */ + uses REG + gen + move FP, %a + yields %a + + pat lor $1==1 /* Load SP */ + uses REG + gen + move SP, %a + yields %a + + pat lor $1==2 /* Load HP */ + leaving + loe ".reghp" + + pat str $1==0 /* Store FP */ + with GPR + gen + sub FP, %1, GP + + pat str $1==1 /* Store SP */ + with GPR + gen + sub SP, %1, GP + + pat str $1==2 /* Store HP */ + leaving + ste ".reghp" + + pat ass /* Adjust stack by variable amount */ + with CONST+GPR STACK + gen + add SP, %1 + + pat asp $1==QUAD /* Adjust stack by constant amount */ + with GPR + /* silently ignore GPR */ + with STACK + gen + pop SCRATCH + + pat asp $1==(2*QUAD) /* Adjust stack by constant amount */ + with GPR GPR + /* silently ignore GPR */ + with STACK + gen + add SP, {CONST, 2*QUAD} + + pat asp /* Adjust stack by constant amount */ + leaving + loc $1 + ass + + + +/* Floating point */ + + pat ngf /* Negate float */ + leaving + loc 0 + exg QUAD + sbf QUAD + + proc simple_f example adf + with GPR GPR + uses reusing %1, REG + gen + fadd[1] %a, %2, %1 + yields %a + + pat adf call simple_f("fadd") /* Float subtract (second + top) */ + pat sbf call simple_f("fsub") /* Float subtract (second - top) */ + pat mlf call simple_f("fmul") /* Float multiply (second * top) */ + pat dvf call simple_f("fdiv") /* Float divide (second / top) */ + + pat loc loc cff $1==$2 && $1==QUAD /* Convert float to float */ + leaving + nop + + pat loc loc cfi $1==$2 && $1==QUAD /* Convert float -> integer */ + with GPR + uses reusing %1, REG + gen + ftrunc %a, %1 + yields %a + + pat loc loc cfu $1==$2 && $1==QUAD /* Convert float -> unsigned */ + with GPR + uses reusing %1, REG + gen + ftrunc %a, %1 + yields %a + + pat loc loc cif $1==$2 && $1==QUAD /* Convert integer -> float */ + with GPR + uses reusing %1, REG + gen + flts %a, %1 + yields %a + + pat loc loc cuf $1==$2 && $1==QUAD /* Convert unsigned -> float */ + with GPR + uses reusing %1, REG + gen + fltu %a, %1 + yields %a + + pat fef /* Split float */ + leaving + loc 0 + loc 0 +#if 0 + cal ".cuf" + lfr QUAD*2 +#endif + + pat fif /* Multiply float and split (?) */ + leaving + mlf QUAD + fef + + pat zrf /* Load a floating zero */ + leaving + loc 0 diff --git a/mach/vc4/test/opcodes.s b/mach/vc4/test/opcodes.s new file mode 100644 index 000000000..87a50d070 --- /dev/null +++ b/mach/vc4/test/opcodes.s @@ -0,0 +1,362 @@ +# +/* + * VideoCore IV assembler test file + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +main: + nop + rti + + b r0 + b r31 + bl r0 + bl r31 + tbb r0 + tbb r15 + tbs r0 + tbs r15 + + nop + + mov r0, r1 + cmn r0, r1 + add r0, r1 + bic r0, r1 + mul r0, r1 + eor r0, r1 + sub r0, r1 + and r0, r1 + mvn r0, r1 + ror r0, r1 + cmp r0, r1 + rsb r0, r1 + btst r0, r1 + or r0, r1 + extu r0, r1 + max r0, r1 + bset r0, r1 + min r0, r1 + bclr r0, r1 + adds2 r0, r1 + bchg r0, r1 + adds4 r0, r1 + adds8 r0, r1 + adds16 r0, r1 + exts r0, r1 + neg r0, r1 + lsr r0, r1 + clz r0, r1 + lsl r0, r1 + brev r0, r1 + asr r0, r1 + abs r0, r1 + + nop + + mov.f r0, r1 + cmn.f r0, r1 + add.f r0, r1 + bic.f r0, r1 + mul.f r0, r1 + eor.f r0, r1 + sub.f r0, r1 + and.f r0, r1 + mvn.f r0, r1 + ror.f r0, r1 + cmp.f r0, r1 + rsb.f r0, r1 + btst.f r0, r1 + or.f r0, r1 + extu.f r0, r1 + max.f r0, r1 + bset.f r0, r1 + min.f r0, r1 + bclr.f r0, r1 + adds2.f r0, r1 + bchg.f r0, r1 + adds4.f r0, r1 + adds8.f r0, r1 + adds16.f r0, r1 + exts.f r0, r1 + neg.f r0, r1 + lsr.f r0, r1 + clz.f r0, r1 + lsl.f r0, r1 + brev.f r0, r1 + asr.f r0, r1 + abs.f r0, r1 + + nop + + mov r0, r1, r2 + cmn r0, r1, r2 + add r0, r1, r2 + bic r0, r1, r2 + mul r0, r1, r2 + eor r0, r1, r2 + sub r0, r1, r2 + and r0, r1, r2 + mvn r0, r1, r2 + ror r0, r1, r2 + cmp r0, r1, r2 + rsb r0, r1, r2 + btst r0, r1, r2 + or r0, r1, r2 + extu r0, r1, r2 + max r0, r1, r2 + bset r0, r1, r2 + min r0, r1, r2 + bclr r0, r1, r2 + adds2 r0, r1, r2 + bchg r0, r1, r2 + adds4 r0, r1, r2 + adds8 r0, r1, r2 + adds16 r0, r1, r2 + exts r0, r1, r2 + neg r0, r1, r2 + lsr r0, r1, r2 + clz r0, r1, r2 + lsl r0, r1, r2 + brev r0, r1, r2 + asr r0, r1, r2 + abs r0, r1, r2 + + nop + + mov r0, #0x1f + cmn r0, #0x1f + add r0, #0x1f + bic r0, #0x1f + mul r0, #0x1f + eor r0, #0x1f + sub r0, #0x1f + and r0, #0x1f + mvn r0, #0x1f + ror r0, #0x1f + cmp r0, #0x1f + rsb r0, #0x1f + btst r0, #0x1f + or r0, #0x1f + extu r0, #0x1f + max r0, #0x1f + bset r0, #0x1f + min r0, #0x1f + bclr r0, #0x1f + adds2 r0, #0x1f + bchg r0, #0x1f + adds4 r0, #0x1f + adds8 r0, #0x1f + adds16 r0, #0x1f + exts r0, #0x1f + neg r0, #0x1f + lsr r0, #0x1f + clz r0, #0x1f + lsl r0, #0x1f + brev r0, #0x1f + asr r0, #0x1f + abs r0, #0x1f + + nop + + mov.f r0, #0x1f + cmn.f r0, #0x1f + add.f r0, #0x1f + bic.f r0, #0x1f + mul.f r0, #0x1f + eor.f r0, #0x1f + sub.f r0, #0x1f + and.f r0, #0x1f + mvn.f r0, #0x1f + ror.f r0, #0x1f + cmp.f r0, #0x1f + rsb.f r0, #0x1f + btst.f r0, #0x1f + or.f r0, #0x1f + extu.f r0, #0x1f + max.f r0, #0x1f + bset.f r0, #0x1f + min.f r0, #0x1f + bclr.f r0, #0x1f + adds2.f r0, #0x1f + bchg.f r0, #0x1f + adds4.f r0, #0x1f + adds8.f r0, #0x1f + adds16.f r0, #0x1f + exts.f r0, #0x1f + neg.f r0, #0x1f + lsr.f r0, #0x1f + clz.f r0, #0x1f + lsl.f r0, #0x1f + brev.f r0, #0x1f + asr.f r0, #0x1f + abs.f r0, #0x1f + + add r0, #0x12345678 + add r0, r1, #0x12345678 + sub r0, #0x12345678 + + nop + + fadd r0, r1, r2 + fsub r0, r1, r2 + fmul r0, r1, r2 + fdiv r0, r1, r2 + fcmp r0, r1, r2 + fabs r0, r1, r2 + frsb r0, r1, r2 + fmax r0, r1, r2 + frcp r0, r1, r2 + frsqrt r0, r1, r2 + fnmul r0, r1, r2 + fmin r0, r1, r2 + fld1 r0, r1, r2 + fld0 r0, r1, r2 + log2 r0, r1, r2 + exp2 r0, r1, r2 + divs r0, r1, r2 + divu r0, r1, r2 + divs r0, r1, #31 + divu r0, r1, #31 + adds256 r0, r1, r2 + + nop + + fadd.f r0, r1, r2 + fsub.f r0, r1, r2 + fmul.f r0, r1, r2 + fdiv.f r0, r1, r2 + fcmp.f r0, r1, r2 + fabs.f r0, r1, r2 + frsb.f r0, r1, r2 + fmax.f r0, r1, r2 + frcp.f r0, r1, r2 + frsqrt.f r0, r1, r2 + fnmul.f r0, r1, r2 + fmin.f r0, r1, r2 + fld1.f r0, r1, r2 + fld0.f r0, r1, r2 + log2.f r0, r1, r2 + exp2.f r0, r1, r2 + divs.f r0, r1, r2 + divu.f r0, r1, r2 + divs.f r0, r1, #31 + divu.f r0, r1, #31 + adds256.f r0, r1, r2 + +label: + b label + b forward + b label + b main + b.f label + b.f forward + b.f main + bl label + bl forward + bl main +forward: + + push r0 + push r0, lr + push r0-r5 + push r0-r5, lr + push r6 + push r16 + push r24 + push lr + + pop r0 + pop r0, pc + pop r0-r5 + pop r0-r5, pc + pop r6 + pop r16 + pop r24 + pop pc + + nop + + ld r0, (sp) + st r0, (sp) + ld r0, 4(sp) + st r0, 4(sp) + ld r0, -4(sp) + st r0, -4(sp) + ld r0, 5(sp) + st r0, 5(sp) + ld r0, -5(sp) + st r0, -5(sp) + + ld r0, (r1) + st r0, (r1) + ld r16, (r1) + st r16, (r1) + ldh r0, (r1) + sth r0, (r1) + ldb r0, (r1) + stb r0, (r1) + ldhs r0, (r1) + sths r0, (r1) + ldh r16, (r1) + sth r16, (r1) + ldb r16, (r1) + stb r16, (r1) + ldhs r16, (r1) + sths r16, (r1) + ld r0, 0x3c (r1) + st r0, 0x3c (r1) + ld r0, 0xfff (r1) + st r0, 0xfff (r1) + ld r1, 0xffff (r0) + st r1, 0xffff (r0) + ld r0, -1 (r1) + st r0, -1 (r1) + ld r16, 0x3c (r1) + st r16, 0x3c (r1) + ld r16, 0xfff (r1) + st r16, 0xfff (r1) + ld r16, 0xffff (r0) + st r16, 0xffff (r0) + ld r16, -1 (r1) + st r16, -1 (r1) + + ld.f r0, (r1) + st.f r0, (r1) + ld.f r0, 8 (r1) + st.f r0, 8 (r1) + + ld r0, (r1, r2) + st r0, (r1, r2) + ld.f r0, (pc, pc) + st.f r0, (pc, pc) + +near: + ld r0, (r1)++ + st r0, (r1)++ + ld.f pc, (pc)++ + st.f pc, (pc)++ + + ld r0, near + ld r0, main + st r0, near + st r0, main + ldb r0, near + ldb r0, main + stb r0, near + stb r0, main + + b.eq r0, r1, near + b r0, r1, near + addcmpb r0, r1, r2, . + addcmpb r0, #1, r2, . + addcmpb r0, r1, #1, . + addcmpb r0, #1, #2, . diff --git a/mach/xenix3/.distr b/mach/xenix3/.distr deleted file mode 100644 index 0e1e702e5..000000000 --- a/mach/xenix3/.distr +++ /dev/null @@ -1,4 +0,0 @@ -Action -cv -libsys -mach_params diff --git a/mach/xenix3/cv/.distr b/mach/xenix3/cv/.distr deleted file mode 100644 index bf760c7ee..000000000 --- a/mach/xenix3/cv/.distr +++ /dev/null @@ -1,3 +0,0 @@ -cv.c -chstack.c -proto.make diff --git a/mach/xenix3/libsys/.distr b/mach/xenix3/libsys/.distr deleted file mode 100644 index 5f4d84d7d..000000000 --- a/mach/xenix3/libsys/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -libmon_s.a -head_em.s diff --git a/mach/z80/.distr b/mach/z80/.distr deleted file mode 100644 index 8e820e454..000000000 --- a/mach/z80/.distr +++ /dev/null @@ -1,8 +0,0 @@ -Action -as -cg -int -libem -libend -libmon -mach_params diff --git a/mach/z80/as/.distr b/mach/z80/as/.distr deleted file mode 100644 index 8ebe3797c..000000000 --- a/mach/z80/as/.distr +++ /dev/null @@ -1,6 +0,0 @@ -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/z80/cg/.distr b/mach/z80/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/z80/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/z80/int/.distr b/mach/z80/int/.distr deleted file mode 100644 index d59fdf593..000000000 --- a/mach/z80/int/.distr +++ /dev/null @@ -1,13 +0,0 @@ -proto.make -READ_ME -atof.s -cv.c -dl.c -dosort -dvi4.s -dvu4.s -eb.s -em.s -fpp.s -em22 -mli4.s diff --git a/mach/z80/libem/.distr b/mach/z80/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/z80/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/z80/libend/.distr b/mach/z80/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/z80/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/z80/libmon/.distr b/mach/z80/libmon/.distr deleted file mode 100644 index 4580c5cd4..000000000 --- a/mach/z80/libmon/.distr +++ /dev/null @@ -1,8 +0,0 @@ -README -LIST -libmon_s.a -char.her.s -head_em.s -mon.cpm.s -mon.s -char.nas.s diff --git a/mach/z80/libsys/.distr b/mach/z80/libsys/.distr deleted file mode 100644 index 4580c5cd4..000000000 --- a/mach/z80/libsys/.distr +++ /dev/null @@ -1,8 +0,0 @@ -README -LIST -libmon_s.a -char.her.s -head_em.s -mon.cpm.s -mon.s -char.nas.s diff --git a/mach/z80/pmfile b/mach/z80/pmfile deleted file mode 100644 index 41d92d389..000000000 --- a/mach/z80/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/z80/" - -mach_z80 = group { - ARCH = "z80", - - proto_as, - proto_cg, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/mach/z80/top/.distr b/mach/z80/top/.distr deleted file mode 100644 index ecbe2e6d5..000000000 --- a/mach/z80/top/.distr +++ /dev/null @@ -1 +0,0 @@ -table diff --git a/mach/z8000/.distr b/mach/z8000/.distr deleted file mode 100644 index 1d705d670..000000000 --- a/mach/z8000/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Action -as -cg -libem -libend -libmon -mach_params diff --git a/mach/z8000/as/.distr b/mach/z8000/as/.distr deleted file mode 100644 index ec89e8dd1..000000000 --- a/mach/z8000/as/.distr +++ /dev/null @@ -1,7 +0,0 @@ -README -mach0.c -mach1.c -mach2.c -mach3.c -mach4.c -mach5.c diff --git a/mach/z8000/cg/.distr b/mach/z8000/cg/.distr deleted file mode 100644 index ccdf9bf7e..000000000 --- a/mach/z8000/cg/.distr +++ /dev/null @@ -1,3 +0,0 @@ -mach.c -mach.h -table diff --git a/mach/z8000/libem/.distr b/mach/z8000/libem/.distr deleted file mode 100644 index d2b4f2884..000000000 --- a/mach/z8000/libem/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -libem_s.a diff --git a/mach/z8000/libend/.distr b/mach/z8000/libend/.distr deleted file mode 100644 index b48ec8483..000000000 --- a/mach/z8000/libend/.distr +++ /dev/null @@ -1,2 +0,0 @@ -LIST -end_s.a diff --git a/mach/z8000/libmon/.distr b/mach/z8000/libmon/.distr deleted file mode 100644 index 1edec9f14..000000000 --- a/mach/z8000/libmon/.distr +++ /dev/null @@ -1,3 +0,0 @@ -LIST -head_em.s -libmon_s.a diff --git a/mach/z8000/pmfile b/mach/z8000/pmfile deleted file mode 100644 index a596356c2..000000000 --- a/mach/z8000/pmfile +++ /dev/null @@ -1,19 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."mach/z8000/" - -mach_z8000 = group { - ARCH = "z8000", - - proto_as, - proto_cg, - - install = pm.install("%ROOTDIR%/lib/%ARCH%/descr", "%BINDIR%%PLATIND%/%ARCH%/descr") -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/man/.distr b/man/.distr deleted file mode 100644 index d21bfd287..000000000 --- a/man/.distr +++ /dev/null @@ -1,20 +0,0 @@ -6500_as.6 -6800_as.6 -6805_as.6 -6809_as.6 -8080_as.6 -z8000_as.6 -i86_as.6 -i386_as.6 -m68k2_as.6 -ns_as.6 -pdp_as.6 -z80_as.6 -em_cg.6 -em_ncg.6 -libmon.7 -libpc.7 -head -pc_prlib.7 -uni_ass.6 -proto.make diff --git a/man/8080_as.6 b/man/i80_as.6 similarity index 100% rename from man/8080_as.6 rename to man/i80_as.6 diff --git a/man/m68k2_as.6 b/man/m68020_as.6 similarity index 100% rename from man/m68k2_as.6 rename to man/m68020_as.6 diff --git a/man/vc4_as.6 b/man/vc4_as.6 new file mode 100644 index 000000000..81b10813d --- /dev/null +++ b/man/vc4_as.6 @@ -0,0 +1,45 @@ +.\" $Header$ +.TH VC4_AS 1 +.ad +.SH NAME +vc4_as \- assembler for Broadcom VideoCore IV + +.SH SYNOPSIS +/usr/em/lib/vc4_as [options] argument ... + +.SH DESCRIPTION +This assembler is made with the general framework +described in \fIuni_ass\fP(6). + +.SH SYNTAX +The assembler uses a modified version of the syntax described in +https://github.com/hermanhermitage/videocoreiv/wiki/VideoCore-IV-Programmers-Manual: +condition codes must be prefixed with a full stop. Vector instructions are not +yet supported. + +.SH "SEE ALSO" +uni_ass(6), +ack(1), +.br +https://github.com/hermanhermitage/videocoreiv +.SH EXAMPLE +.nf +.ta 8n 16n 24n 32n 40n 48n +An example of VideoCore IV assembly language: + + ldb r0, __uart_status + b.eq r0, #0, 1b + + ! receive 1 byte (returned in r0) + mov r1, #AUX_MU_LSR_REG + mov r2, #AUX_MU_IO_REG + ! loop until char available +recvwait: + ld r3, (r1) + and r3, #0x1 + b.ne r3, #0x1, recvwait + + ldb r0, (r2) +1: + b lr +.fi diff --git a/modules/.distr b/modules/.distr deleted file mode 100644 index e5c549d70..000000000 --- a/modules/.distr +++ /dev/null @@ -1,2 +0,0 @@ -src -h diff --git a/modules/build.lua b/modules/build.lua new file mode 100644 index 000000000..a2228f2a8 --- /dev/null +++ b/modules/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "headers", + hdrs = { + "./h/*.h" + } +} + diff --git a/modules/h/.distr b/modules/h/.distr deleted file mode 100644 index a365a15ef..000000000 --- a/modules/h/.distr +++ /dev/null @@ -1,10 +0,0 @@ -ansi.h -em.h -em_arith.h -em_code.h -em_label.h -#em_codeCE.h -#emO_code.h -em_mesX.h -#em_codeO.h -#proto.make diff --git a/modules/h/proto.make b/modules/h/proto.make deleted file mode 100644 index 48f61cdc4..000000000 --- a/modules/h/proto.make +++ /dev/null @@ -1,33 +0,0 @@ -# $Id$ - -#PARAMS do not delete this line! - -SRC_DIR = $(SRC_HOME)/modules/h -MOD_DIR = $(TARGET_HOME)/modules -FILES = \ - $(SRC_DIR)/ansi.h \ - $(SRC_DIR)/em.h \ - $(SRC_DIR)/em_arith.h \ - $(SRC_DIR)/em_code.h \ - $(SRC_DIR)/em_label.h \ - $(SRC_DIR)/em_codeCE.h \ - $(SRC_DIR)/emO_code.h \ - $(SRC_DIR)/em_codeO.h \ - $(SRC_DIR)/em_mesX.h - -all: - -install: all - -mkdir $(MOD_DIR)/h - cp $(FILES) $(MOD_DIR)/h - -cmp: all - -pr: - @pr $(SRC_DIR)/proto.make $(FILES) - -opr: - make pr | opr - -clean: -lintlib: diff --git a/modules/src/.distr b/modules/src/.distr deleted file mode 100644 index c22f4c010..000000000 --- a/modules/src/.distr +++ /dev/null @@ -1,16 +0,0 @@ -Action -Action.lint -alloc -assert -em_code -em_mes -em_opt -flt_arith -idf -input -malloc -object -print -read_em -string -system diff --git a/modules/src/Xmalloc/.distr b/modules/src/Xmalloc/.distr deleted file mode 100644 index 228eaa800..000000000 --- a/modules/src/Xmalloc/.distr +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Xmalloc.c diff --git a/modules/src/alloc/.distr b/modules/src/alloc/.distr deleted file mode 100644 index fa07cf5d1..000000000 --- a/modules/src/alloc/.distr +++ /dev/null @@ -1,12 +0,0 @@ -pmfile -Malloc.c -Srealloc.c -Realloc.c -Salloc.c -alloc.3 -alloc.h -botch.c -clear.c -st_alloc.c -std_alloc.c -No_Mem.c diff --git a/modules/src/alloc/build.lua b/modules/src/alloc/build.lua new file mode 100644 index 000000000..a274c390e --- /dev/null +++ b/modules/src/alloc/build.lua @@ -0,0 +1,10 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./alloc.h" }, + deps = { + "modules+headers", + "modules/src/system+lib" + }, +} + diff --git a/modules/src/alloc/pmfile b/modules/src/alloc/pmfile deleted file mode 100644 index 5200f3097..000000000 --- a/modules/src/alloc/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."modules/src/alloc/" -lib_alloc = file (LIBDIR.."liballoc.a") - -module_alloc = clibrary { - cfile (d.."Malloc.c"), - cfile (d.."Salloc.c"), - cfile (d.."Srealloc.c"), - cfile (d.."Realloc.c"), - cfile (d.."botch.c"), - cfile (d.."clear.c"), - cfile (d.."st_alloc.c"), - cfile (d.."std_alloc.c"), - cfile (d.."No_Mem.c"), - - outputs = {"%U%/liballoc.a"}, - install = { - pm.install(LIBDIR.."liballoc.a"), - pm.install(d.."alloc.h", HEADERDIR.."alloc.h") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/alloc/proto.make b/modules/src/alloc/proto.make deleted file mode 100644 index bd419ce71..000000000 --- a/modules/src/alloc/proto.make +++ /dev/null @@ -1,87 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/alloc -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(INCLUDES) $(COPTIONS) - -CSRC = $(SRC_DIR)/Malloc.c\ - $(SRC_DIR)/Salloc.c\ - $(SRC_DIR)/Srealloc.c\ - $(SRC_DIR)/Realloc.c\ - $(SRC_DIR)/botch.c\ - $(SRC_DIR)/clear.c\ - $(SRC_DIR)/st_alloc.c\ - $(SRC_DIR)/std_alloc.c \ - $(SRC_DIR)/No_Mem.c -SOURCES = $(SRC_DIR)/alloc.h\ - $(CSRC) - -OBJECTS = botch.$(SUF) clear.$(SUF) st_alloc.$(SUF) Malloc.$(SUF) \ - Salloc.$(SUF) \ - Srealloc.$(SUF) Realloc.$(SUF) std_alloc.$(SUF) No_Mem.$(SUF) - - -LIBALLOC = liballoc.$(LIBSUF) - -all: $(LIBALLOC) - -$(LIBALLOC): $(OBJECTS) - rm -f $(LIBALLOC) - $(AR) r $(LIBALLOC) $(OBJECTS) - $(RANLIB) $(LIBALLOC) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBALLOC) $(MOD_DIR)/lib/$(LIBALLOC) - $(RANLIB) $(MOD_DIR)/lib/$(LIBALLOC) - cp $(SRC_DIR)/alloc.h $(MOD_DIR)/h/alloc.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/alloc.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBALLOC) $(MOD_DIR)/lib/$(LIBALLOC) - -cmp $(SRC_DIR)/alloc.h $(MOD_DIR)/h/alloc.h - -pr: - @pr $(SRC_DIR)/proto.make $(SOURCES) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) alloc $(MOD_DIR)/lib $(INCLUDES) $(CSRC) - -st_alloc.$(SUF): $(SRC_DIR)/alloc.h $(SRC_DIR)/st_alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/st_alloc.c - -std_alloc.$(SUF): $(SRC_DIR)/alloc.h $(SRC_DIR)/std_alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/std_alloc.c - -Malloc.$(SUF): $(SRC_DIR)/alloc.h $(SRC_DIR)/Malloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/Malloc.c - -No_Mem.$(SUF): $(SRC_DIR)/No_Mem.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/No_Mem.c - -Realloc.$(SUF): $(SRC_DIR)/Realloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/Realloc.c - -Salloc.$(SUF): $(SRC_DIR)/Salloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/Salloc.c - -Srealloc.$(SUF): $(SRC_DIR)/Srealloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/Srealloc.c - -botch.$(SUF): $(SRC_DIR)/botch.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/botch.c - -clear.$(SUF): $(SRC_DIR)/clear.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/clear.c diff --git a/modules/src/assert/.distr b/modules/src/assert/.distr deleted file mode 100644 index 34e11b290..000000000 --- a/modules/src/assert/.distr +++ /dev/null @@ -1,4 +0,0 @@ -pmfile -BadAssert.c -assert.3 -assert.h diff --git a/modules/src/assert/build.lua b/modules/src/assert/build.lua new file mode 100644 index 000000000..bd1230bfe --- /dev/null +++ b/modules/src/assert/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./assert.h" }, +} + + diff --git a/modules/src/assert/pmfile b/modules/src/assert/pmfile deleted file mode 100644 index 72d72b5bb..000000000 --- a/modules/src/assert/pmfile +++ /dev/null @@ -1,20 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/assert/" -lib_assert = file (LIBDIR.."libassert.a") - -module_assert = clibrary { - cfile (d.."BadAssert.c"), - - outputs = {"%U%/libassert.a"}, - install = { - pm.install(LIBDIR.."libassert.a") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/modules/src/assert/proto.make b/modules/src/assert/proto.make deleted file mode 100644 index cf63c41f2..000000000 --- a/modules/src/assert/proto.make +++ /dev/null @@ -1,43 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/assert -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(COPTIONS) $(INCLUDES) - -all: libassert.$(LIBSUF) - -libassert.$(LIBSUF): BadAssert.$(SUF) - $(AR) r libassert.$(LIBSUF) BadAssert.$(SUF) - $(RANLIB) libassert.$(LIBSUF) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp libassert.$(LIBSUF) $(MOD_DIR)/lib/libassert.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libassert.$(LIBSUF) - cp $(SRC_DIR)/assert.h $(MOD_DIR)/h/assert.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/assert.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp libassert.$(LIBSUF) $(MOD_DIR)/lib/libassert.$(LIBSUF) - -cmp $(SRC_DIR)/assert.h $(MOD_DIR)/h/assert.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/assert.h $(SRC_DIR)/BadAssert.c - -opr: - make pr | opr - -clean: - rm -f *.$(LIBSUF) *.$(SUF) - -lintlib: - $(MK_LINT_LIB) assert $(MOD_DIR)/lib $(INCLUDES) $(SRC_DIR)/BadAssert.c - -BadAssert.$(SUF): $(SRC_DIR)/BadAssert.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/BadAssert.c diff --git a/modules/src/em_code/.distr b/modules/src/em_code/.distr deleted file mode 100644 index 45a94e8d3..000000000 --- a/modules/src/em_code/.distr +++ /dev/null @@ -1,58 +0,0 @@ -pmfile -C_out.c -bhcst.c -bhdlb.c -bhdnam.c -bhfcon.c -bhicon.c -bhilb.c -bhpnam.c -bhucon.c -convert.c -crcst.c -crdlb.c -crdnam.c -crxcon.c -crilb.c -crpnam.c -crscon.c -cst.c -dfdlb.c -dfdnam.c -dfilb.c -dlb.c -dnam.c -em.c -em.nogen -em_private.h -end.c -endarg.c -exc.c -failed.c -fcon.c -getid.c -icon.c -ilb.c -insert.c -insert.h -internerr.c -make.em.gen -make.sh -msend.c -msstart.c -op.c -opcst.c -opdlb.c -opdnam.c -opilb.c -opnarg.c -oppnam.c -pnam.c -pro.c -pronarg.c -psdlb.c -psdnam.c -pspnam.c -scon.c -ucon.c -em_code.3X diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua new file mode 100644 index 000000000..a1316df2f --- /dev/null +++ b/modules/src/em_code/build.lua @@ -0,0 +1,101 @@ +normalrule { + name = "em_code_ek_h", + ins = { + "./make.em.gen", + "./em.nogen", + "h/em_table" + }, + outleaves = { "em_codeEK.h" }, + commands = { + "%{ins[1]} %{ins[3]} > %{outs}", + "cat %{ins[2]} >> %{outs}" + } +} + +clibrary { + name = "headers", + srcs = {}, + hdrs = { + "+em_code_ek_h", + "./em_code.h", + "./em_codeCE.h", + "./em_codeO.h", + } +} + +local function build_variant(code, cflags) + clibrary { + name = "lib_"..code, + srcs = { + "./C_out.c", + "./bhcst.c", + "./bhdlb.c", + "./bhdnam.c", + "./bhfcon.c", + "./bhicon.c", + "./bhilb.c", + "./bhpnam.c", + "./bhucon.c", + "./crcst.c", + "./crdlb.c", + "./crdnam.c", + "./crilb.c", + "./crpnam.c", + "./crscon.c", + "./crxcon.c", + "./cst.c", + "./dfdlb.c", + "./dfdnam.c", + "./dfilb.c", + "./dlb.c", + "./dnam.c", + "./em.c", + "./end.c", + "./endarg.c", + "./exc.c", + "./failed.c", + "./fcon.c", + "./getid.c", + "./icon.c", + "./ilb.c", + "./insert.c", + "./internerr.c", + "./msend.c", + "./msstart.c", + "./op.c", + "./opcst.c", + "./opdlb.c", + "./opdnam.c", + "./opilb.c", + "./opnarg.c", + "./oppnam.c", + "./pnam.c", + "./pro.c", + "./pronarg.c", + "./psdlb.c", + "./psdnam.c", + "./pspnam.c", + "./scon.c", + "./ucon.c", + }, + hdrs = { + "+headers" + }, + deps = { + "+headers", + "h+emheaders", + "h+local", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_data+lib", + "modules/src/system+lib", + }, + vars = { + ["+cflags"] = cflags + }, + } +end + +build_variant("e", { "-DREADABLE_EM" }) +build_variant("k", { }) + diff --git a/modules/h/em_code.h b/modules/src/em_code/em_code.h similarity index 100% rename from modules/h/em_code.h rename to modules/src/em_code/em_code.h diff --git a/modules/h/em_codeCE.h b/modules/src/em_code/em_codeCE.h similarity index 100% rename from modules/h/em_codeCE.h rename to modules/src/em_code/em_codeCE.h diff --git a/modules/h/em_codeO.h b/modules/src/em_code/em_codeO.h similarity index 100% rename from modules/h/em_codeO.h rename to modules/src/em_code/em_codeO.h diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index 9da09a430..f7526b8e4 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -9,6 +9,7 @@ they can be written immediately. */ +#include #include #include #include "insert.h" diff --git a/modules/src/em_code/pmfile b/modules/src/em_code/pmfile deleted file mode 100644 index 60ce20d91..000000000 --- a/modules/src/em_code/pmfile +++ /dev/null @@ -1,112 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/em_code/" -lib_eme = file (LIBDIR.."libeme.a") -lib_emk = file (LIBDIR.."libemk.a") - -local em_codeMK_h = simple { - outputs = {"%U%-%I%.h"}, - command = { - "%in[1]% %in[2]% "..d.."em.nogen > %out%", - "cat "..d.."em.nogen >> %out%" - }, - install = pm.install(HEADERDIR.."em_codeEK.h"), - - file (d.."make.em.gen"), - file ("%ROOTDIR%h/em_table") -} - -local em_cfile = cfile { - class = "em_cfile", - dynamicheaders = em_codeMK_h -} - -local library_core = group { - em_cfile (d.."bhcst.c"), - em_cfile (d.."bhdlb.c"), - em_cfile (d.."bhdnam.c"), - em_cfile (d.."bhfcon.c"), - em_cfile (d.."bhicon.c"), - em_cfile (d.."bhilb.c"), - em_cfile (d.."bhpnam.c"), - em_cfile (d.."bhucon.c"), - em_cfile (d.."crcst.c"), - em_cfile (d.."crdlb.c"), - em_cfile (d.."crdnam.c"), - em_cfile (d.."crxcon.c"), - em_cfile (d.."crilb.c"), - em_cfile (d.."crpnam.c"), - em_cfile (d.."crscon.c"), - em_cfile (d.."cst.c"), - em_cfile (d.."dfdlb.c"), - em_cfile (d.."dfdnam.c"), - em_cfile (d.."dfilb.c"), - em_cfile (d.."dlb.c"), - em_cfile (d.."dnam.c"), - em_cfile (d.."end.c"), - em_cfile (d.."endarg.c"), - em_cfile (d.."exc.c"), - em_cfile (d.."fcon.c"), - em_cfile (d.."getid.c"), - em_cfile (d.."icon.c"), - em_cfile (d.."ilb.c"), - em_cfile (d.."insert.c"), - em_cfile (d.."internerr.c"), - em_cfile (d.."msend.c"), - em_cfile (d.."op.c"), - em_cfile (d.."opcst.c"), - em_cfile (d.."opdlb.c"), - em_cfile (d.."opdnam.c"), - em_cfile (d.."opilb.c"), - em_cfile (d.."opnarg.c"), - em_cfile (d.."oppnam.c"), - em_cfile (d.."pnam.c"), - em_cfile (d.."pro.c"), - em_cfile (d.."pronarg.c"), - em_cfile (d.."msstart.c"), - em_cfile (d.."psdlb.c"), - em_cfile (d.."psdnam.c"), - em_cfile (d.."pspnam.c"), - em_cfile (d.."scon.c"), - em_cfile (d.."ucon.c"), - em_cfile (d.."C_out.c"), - em_cfile (d.."failed.c"), - em_cfile (d.."em.c") -} - -module_eme = clibrary { - CDEFINES = {PARENT, "READABLE_EM"}, - library_core, - - outputs = {"%U%/libeme.a"}, - install = { - pm.install(LIBDIR.."libeme.a") - } -} - -module_emk = clibrary { - library_core, - - outputs = {"%U%/libemk.a"}, - install = { - pm.install(LIBDIR.."libemk.a") - } -} - -module_em_code = group { - module_eme, - module_emk, -} - --- Revision history --- $Log$ --- Revision 1.3 2007-02-25 12:46:41 dtrg --- em_table is now in /h, not /etc. --- --- Revision 1.2 2006/10/15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/em_code/proto.make b/modules/src/em_code/proto.make deleted file mode 100644 index 60c0bda9b..000000000 --- a/modules/src/em_code/proto.make +++ /dev/null @@ -1,128 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -ETC = $(SRC_HOME)/etc -SRC_DIR = $(SRC_HOME)/modules/src/em_code -MOD_DIR = $(TARGET_HOME)/modules - -INCLUDES = -I. -I$(TARGET_HOME)/h -I$(TARGET_HOME)/config -I$(MOD_DIR)/h -I$(SRC_HOME)/modules/src/read_em -I$(SRC_DIR) -CFLAGS = $(INCLUDES) $(COPTIONS) -SRC = $(SRC_DIR)/bhcst.c\ - $(SRC_DIR)/bhdlb.c\ - $(SRC_DIR)/bhdnam.c\ - $(SRC_DIR)/bhfcon.c\ - $(SRC_DIR)/bhicon.c\ - $(SRC_DIR)/bhilb.c\ - $(SRC_DIR)/bhpnam.c\ - $(SRC_DIR)/bhucon.c\ - $(SRC_DIR)/crcst.c\ - $(SRC_DIR)/crdlb.c\ - $(SRC_DIR)/crdnam.c\ - $(SRC_DIR)/crxcon.c\ - $(SRC_DIR)/crilb.c\ - $(SRC_DIR)/crpnam.c\ - $(SRC_DIR)/crscon.c \ - $(SRC_DIR)/cst.c\ - $(SRC_DIR)/dfdlb.c\ - $(SRC_DIR)/dfdnam.c\ - $(SRC_DIR)/dfilb.c\ - $(SRC_DIR)/dlb.c\ - $(SRC_DIR)/dnam.c\ - $(SRC_DIR)/end.c\ - $(SRC_DIR)/endarg.c \ - $(SRC_DIR)/exc.c\ - $(SRC_DIR)/fcon.c\ - $(SRC_DIR)/getid.c\ - $(SRC_DIR)/icon.c\ - $(SRC_DIR)/ilb.c\ - $(SRC_DIR)/insert.c\ - $(SRC_DIR)/internerr.c \ - $(SRC_DIR)/msend.c\ - $(SRC_DIR)/op.c\ - $(SRC_DIR)/opcst.c\ - $(SRC_DIR)/opdlb.c\ - $(SRC_DIR)/opdnam.c\ - $(SRC_DIR)/opilb.c\ - $(SRC_DIR)/opnarg.c\ - $(SRC_DIR)/oppnam.c\ - $(SRC_DIR)/pnam.c \ - $(SRC_DIR)/pro.c\ - $(SRC_DIR)/pronarg.c\ - $(SRC_DIR)/msstart.c\ - $(SRC_DIR)/psdlb.c\ - $(SRC_DIR)/psdnam.c\ - $(SRC_DIR)/pspnam.c\ - $(SRC_DIR)/scon.c\ - $(SRC_DIR)/ucon.c \ - $(SRC_DIR)/C_out.c\ - $(SRC_DIR)/failed.c\ - $(SRC_DIR)/em.c - -OBS = failed.$(SUF) insert.$(SUF) internerr.$(SUF) getid.$(SUF) - -all: em_codeEK.h libeme.$(LIBSUF) libemk.$(LIBSUF) em_code.3 - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp libeme.$(LIBSUF) $(MOD_DIR)/lib/libeme.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libeme.$(LIBSUF) - cp libemk.$(LIBSUF) $(MOD_DIR)/lib/libemk.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libemk.$(LIBSUF) - cp em_codeEK.h $(MOD_DIR)/h/em_codeEK.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage em_code.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp libeme.$(LIBSUF) $(MOD_DIR)/lib/libeme.$(LIBSUF) - -cmp libemk.$(LIBSUF) $(MOD_DIR)/lib/libemk.$(LIBSUF) - -cmp em_codeEK.h $(MOD_DIR)/h/em_codeEK.h - -em_code.3: $(SRC_DIR)/em_code.3X - -sh -c 'tbl < $(SRC_DIR)/em_code.3X > em_code.3' - -sh -c 'if test -s em_code.3 ; then : ; else cp $(SRC_DIR)/em_code.3X em_code.3 ; fi ' - -libeme.$(LIBSUF): $(SRC_DIR)/em_private.h $(SRC) $(OBS) - cc="$(CC)"; suf="$(SUF)"; libsuf="$(LIBSUF)"; cflags="-c -DREADABLE_EM $(CFLAGS)"; ar="$(AR)"; export cc ar suf libsuf cflags; sh $(SRC_DIR)/make.sh e $(SRC) - $(RANLIB) libeme.$(LIBSUF) - -libemk.$(LIBSUF): $(SRC_DIR)/em_private.h $(SRC) $(OBS) - cc="$(CC)"; suf="$(SUF)"; libsuf="$(LIBSUF)"; cflags="-c $(CFLAGS)"; ar="$(AR)"; export cc ar suf libsuf cflags; sh $(SRC_DIR)/make.sh k $(SRC) - $(RANLIB) libemk.$(LIBSUF) - -em_codeEK.h: $(SRC_DIR)/make.em.gen $(ETC)/em_table $(SRC_DIR)/em.nogen - $(SRC_DIR)/make.em.gen $(ETC)/em_table > em_codeEK.h - cat $(SRC_DIR)/em.nogen >> em_codeEK.h - -pr: - @pr $(SRC_DIR)/proto.make \ - $(SRC_DIR)/em.nogen \ - $(SRC_DIR)/make.em.gen \ - $(SRC_DIR)/make.sh \ - $(SRC_DIR)/insert.h \ - $(SRC) \ - $(SRC_DIR)/em_private.h - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) em_code.3 em_codeEK.h - -lintlib: $(SRC_DIR)/make.sh - $(MK_LINT_LIB) eme $(MOD_DIR)/lib $(INCLUDES) -DREADABLE_EM $(SRC) - $(MK_LINT_LIB) emk $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -insert.$(SUF): $(SRC_DIR)/insert.c $(SRC_DIR)/insert.h - $(CC) $(CFLAGS) -c $(SRC_DIR)/insert.c - -failed.$(SUF): $(SRC_DIR)/failed.c - $(CC) $(CFLAGS) -c $(SRC_DIR)/failed.c - -internerr.$(SUF): $(SRC_DIR)/internerr.c - $(CC) $(CFLAGS) -c $(SRC_DIR)/internerr.c - -getid.$(SUF): $(SRC_DIR)/getid.c - $(CC) $(CFLAGS) -c $(SRC_DIR)/getid.c diff --git a/modules/src/em_data/build.lua b/modules/src/em_data/build.lua new file mode 100644 index 000000000..20312201d --- /dev/null +++ b/modules/src/em_data/build.lua @@ -0,0 +1,36 @@ +local generated = normalrule { + name = "generated", + ins = { + "./new_table", + "h/em_table", -- relative to root, which is a bit evil + }, + outleaves = { + "em_flag.c", + "em_pseu.c", + "em_mnem.c", + "em_spec.h", + "em_pseu.h", + "em_mnem.h", + }, + deps = { + "h+emheaders" + }, + commands = { + "%{ins[1]} %{ins[2]} %{dir} %{dir}" + } +} + +clibrary { + name = "lib", + srcs = concat( + "./em_ptyp.c", + matching(filenamesof(generated), "%.c$") + ), + hdrs = { + "+generated" -- so we export the H files + }, + deps = { + "+generated", -- so we can see the H files + "h+emheaders" + } +} diff --git a/util/data/em_ptyp.c b/modules/src/em_data/em_ptyp.c similarity index 100% rename from util/data/em_ptyp.c rename to modules/src/em_data/em_ptyp.c diff --git a/util/data/new_table b/modules/src/em_data/new_table similarity index 100% rename from util/data/new_table rename to modules/src/em_data/new_table diff --git a/modules/src/em_mes/.distr b/modules/src/em_mes/.distr deleted file mode 100644 index 14eca8bbf..000000000 --- a/modules/src/em_mes/.distr +++ /dev/null @@ -1,14 +0,0 @@ -pmfile -C_ms_com.c -C_ms_ego.c -C_ms_emx.c -C_ms_err.c -C_ms_flt.c -C_ms_gto.c -C_ms_opt.c -C_ms_par.c -C_ms_reg.c -C_ms_src.c -C_ms_std.c -C_ms_stb.c -em_mes.3 diff --git a/modules/src/em_mes/build.lua b/modules/src/em_mes/build.lua new file mode 100644 index 000000000..b094f4a84 --- /dev/null +++ b/modules/src/em_mes/build.lua @@ -0,0 +1,11 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/em_code+headers", + "modules/src/em_data+lib", + } +} + diff --git a/modules/src/em_mes/pmfile b/modules/src/em_mes/pmfile deleted file mode 100644 index f70ff2081..000000000 --- a/modules/src/em_mes/pmfile +++ /dev/null @@ -1,35 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/em_mes/" -lib_em_mes = file (LIBDIR.."libem_mes.a") - -local library_core = group { - cfile (d.."C_ms_err.c"), - cfile (d.."C_ms_opt.c"), - cfile (d.."C_ms_emx.c"), - cfile (d.."C_ms_reg.c"), - cfile (d.."C_ms_src.c"), - cfile (d.."C_ms_flt.c"), - cfile (d.."C_ms_com.c"), - cfile (d.."C_ms_par.c"), - cfile (d.."C_ms_ego.c"), - cfile (d.."C_ms_gto.c"), - cfile (d.."C_ms_stb.c"), - cfile (d.."C_ms_std.c"), -} - -module_em_mes = clibrary { - library_core, - - outputs = {"%U%/libem_mes.a"}, - install = { - pm.install(LIBDIR.."libem_mes.a") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/modules/src/em_mes/proto.make b/modules/src/em_mes/proto.make deleted file mode 100644 index 005e63bd9..000000000 --- a/modules/src/em_mes/proto.make +++ /dev/null @@ -1,110 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/em_mes -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES=-I$(TARGET_HOME)/h -I$(MOD_DIR)/h -CFLAGS = $(INCLUDES) $(COPTIONS) - -SRC = $(SRC_DIR)/C_ms_err.c \ - $(SRC_DIR)/C_ms_opt.c \ - $(SRC_DIR)/C_ms_emx.c \ - $(SRC_DIR)/C_ms_reg.c \ - $(SRC_DIR)/C_ms_src.c \ - $(SRC_DIR)/C_ms_flt.c \ - $(SRC_DIR)/C_ms_com.c \ - $(SRC_DIR)/C_ms_par.c \ - $(SRC_DIR)/C_ms_ego.c \ - $(SRC_DIR)/C_ms_gto.c \ - $(SRC_DIR)/C_ms_stb.c \ - $(SRC_DIR)/C_ms_std.c -OBJ = C_ms_err.$(SUF) C_ms_opt.$(SUF) C_ms_emx.$(SUF) C_ms_reg.$(SUF) \ - C_ms_src.$(SUF) C_ms_flt.$(SUF) C_ms_com.$(SUF) C_ms_par.$(SUF) \ - C_ms_ego.$(SUF) C_ms_gto.$(SUF) C_ms_stb.$(SUF) C_ms_std.$(SUF) - -all: libem_mes.$(LIBSUF) libem_mesCE.$(LIBSUF) libem_mesO.$(LIBSUF) - -libem_mes.$(LIBSUF): $(OBJ) - rm -f libem_mes.$(LIBSUF) - $(AR) r libem_mes.$(LIBSUF) $(OBJ) - $(RANLIB) libem_mes.$(LIBSUF) - -libem_mesO.$(LIBSUF): - rm -f *.$(SUF) libem_mesO.$(LIBSUF) - $(CC) -c $(CFLAGS) -DPEEPHOLE $(SRC) - $(AR) r libem_mesO.$(LIBSUF) $(OBJ) - $(RANLIB) libem_mesO.$(LIBSUF) - rm -f *.$(SUF) - -libem_mesCE.$(LIBSUF): - rm -f *.$(SUF) libem_mesCE.$(LIBSUF) - $(CC) -c $(CFLAGS) -DCODE_EXPANDER $(SRC) - $(AR) r libem_mesCE.$(LIBSUF) $(OBJ) - $(RANLIB) libem_mesCE.$(LIBSUF) - rm -f *.$(SUF) - -install: all - -mkdir $(MOD_DIR)/lib - cp libem_mes.$(LIBSUF) $(MOD_DIR)/lib/libem_mes.$(LIBSUF) - cp libem_mesCE.$(LIBSUF) $(MOD_DIR)/lib/libem_mesCE.$(LIBSUF) - cp libem_mesO.$(LIBSUF) $(MOD_DIR)/lib/libem_mesO.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libem_mes.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libem_mesCE.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libem_mesO.$(LIBSUF) - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/em_mes.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp libem_mes.$(LIBSUF) $(MOD_DIR)/lib/libem_mes.$(LIBSUF) - -cmp libem_mesCE.$(LIBSUF) $(MOD_DIR)/lib/libem_mesCE.$(LIBSUF) - -cmp libem_mesO.$(LIBSUF) $(MOD_DIR)/lib/libem_mesO.$(LIBSUF) - -pr: - @pr $(SRC_DIR)/proto.make $(SRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) em_mes $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -C_ms_err.$(SUF): $(SRC_DIR)/C_ms_err.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_err.c - -C_ms_opt.$(SUF): $(SRC_DIR)/C_ms_opt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_opt.c - -C_ms_emx.$(SUF): $(SRC_DIR)/C_ms_emx.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_emx.c - -C_ms_reg.$(SUF): $(SRC_DIR)/C_ms_reg.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_reg.c - -C_ms_src.$(SUF): $(SRC_DIR)/C_ms_src.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_src.c - -C_ms_flt.$(SUF): $(SRC_DIR)/C_ms_flt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_flt.c - -C_ms_com.$(SUF): $(SRC_DIR)/C_ms_com.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_com.c - -C_ms_par.$(SUF): $(SRC_DIR)/C_ms_par.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_par.c - -C_ms_ego.$(SUF): $(SRC_DIR)/C_ms_ego.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_ego.c - -C_ms_gto.$(SUF): $(SRC_DIR)/C_ms_gto.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_gto.c - -C_ms_stb.$(SUF): $(SRC_DIR)/C_ms_stb.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_stb.c - -C_ms_std.$(SUF): $(SRC_DIR)/C_ms_std.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/C_ms_std.c diff --git a/modules/src/em_opt/.distr b/modules/src/em_opt/.distr deleted file mode 100644 index d11f07afd..000000000 --- a/modules/src/em_opt/.distr +++ /dev/null @@ -1,19 +0,0 @@ -proto.make -aux.c -em_nopt.6 -em_opt.3 -findworst.c -initlex.c -main.c -makefuns.awk -mkstrct.c -nopt.c -nopt.h -outcalls.c -outputdfa.c -parser.g -parser.h -patterns -pseudo.r -syntax.l -em_codeO.h diff --git a/modules/src/em_opt/proto.make b/modules/src/em_opt/proto.make deleted file mode 100644 index 68327cb98..000000000 --- a/modules/src/em_opt/proto.make +++ /dev/null @@ -1,241 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/em_opt -MOD_DIR = $(TARGET_HOME)/modules - -# set HOWMUCH to head -20 to limit number of patterns used -#HOWMUCH = head -20 -HOWMUCH = cat - -INCLUDES = -I$(TARGET_HOME)/h -I$(MOD_DIR)/h \ - -I$(MOD_DIR)/pkg -I$(SRC_DIR) -I. -UINCLUDES = -I$(UTIL_HOME)/h -I$(UTIL_HOME)/modules/h \ - -I$(UTIL_HOME)/modules/pkg -I$(SRC_DIR) -I. -PREFLAGS = $(INCLUDES) -DPRIVATE=static# -DDEBUG -UPREFLAGS = $(UINCLUDES) -DPRIVATE=static# -DDEBUG - -# Enable the next line to produce a version that output's the line number -# from the patterns file each time an optimization is performed. -#PREFLAGS = $(PREFLAGS) -DSTATS - -CFLAGS = $(PREFLAGS) $(COPTIONS) -LINTFLAGS = $(PREFLAGS) -DNORCSID -LDFLAGS = $(LDOPTIONS) -UCFLAGS = $(UPREFLAGS) $(UCOPTIONS) -ULDFLAGS = $(ULDOPTIONS) -LLOPT = -CMD = '$(CC) -c $(CFLAGS)' - -LIBOPT = libemopt.$(LIBSUF) -LIBCEOPT = libCEopt.$(LIBSUF) - -.SUFFIXES: .d .r - -.r.d: ; CMD=$(CMD); export CMD; awk -f $(SRC_DIR)/makefuns.awk prototypes=/dev/null $*.r | sh -x - touch $@ - -.SUFFIXES: .$(SUF) -.c.$(SUF): - $(CC) -c $(CFLAGS) $*.c - -CSRC = $(SRC_DIR)/main.c $(SRC_DIR)/nopt.c $(SRC_DIR)/mkstrct.c \ - $(SRC_DIR)/aux.c $(SRC_DIR)/outputdfa.c $(SRC_DIR)/outcalls.c\ - $(SRC_DIR)/findworst.c $(SRC_DIR)/initlex.c - -SRCS = $(SRC_DIR)/proto.make $(SRC_DIR)/nopt.h $(SRC_DIR)/parser.h \ - $(SRC_DIR)/parser.g $(SRC_DIR)/syntax.l $(SRC_DIR)/pseudo.r\ - $(SRC_DIR)/patterns $(CSRC) - -NOFILES = nopt.$(SUF) dfa.$(SUF) trans.$(SUF) aux.$(SUF) mkstrct.$(SUF) - -POFILES = parser.$(USUF) syntax.$(USUF) outputdfa.$(USUF) outcalls.$(USUF)\ - findworst.$(USUF) initlex.$(USUF) Lpars.$(USUF) - -GENFILES = Lpars.h Lpars.c parserdummy parser.c syntax.c \ - dfa.c dfa.c.new trans.c trans.c.new\ - incalls.d incalls.r incalls.r.new pseudo.d pseudo.r - -all: em_nopt $(LIBOPT) $(LIBCEOPT) prototypes - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBOPT) $(MOD_DIR)/lib/$(LIBOPT) - $(RANLIB) $(MOD_DIR)/lib/$(LIBOPT) - cp $(LIBCEOPT) $(MOD_DIR)/lib/$(LIBCEOPT) - $(RANLIB) $(MOD_DIR)/lib/$(LIBCEOPT) - cp em_nopt $(TARGET_HOME)/lib.bin/em_nopt - cp prototypes $(MOD_DIR)/h/em_codeO.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/em_opt.3 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/em_nopt.6 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBOPT) $(MOD_DIR)/lib/$(LIBOPT) - -cmp $(LIBCEOPT) $(MOD_DIR)/lib/$(LIBCEOPT) - -cmp em_nopt $(TARGET_HOME)/lib.bin/em_nopt - -cmp prototypes $(MOD_DIR)/h/em_codeO.h - - -pr: - @pr $(SRCS) - -opr: - make pr | opr - -lint: lintparser lintnopt - -clean: - rm -f O_*.$(SUF) - rm -f O_*.c - rm -f $(NOFILES) main.$(SUF) $(POFILES) prototypes - rm -f $(GENFILES) parser em_nopt $(LIBOPT) $(LIBCEOPT) - -# How to build stand alone version of the optimizer - -NOPTLIB = $(MOD_DIR)/lib/libread_emk.$(LIBSUF)\ - $(MOD_DIR)/lib/libemk.$(LIBSUF)\ - $(MOD_DIR)/lib/liballoc.$(LIBSUF)\ - $(MOD_DIR)/lib/malloc.$(SUF)\ - $(MOD_DIR)/lib/libprint.$(LIBSUF)\ - $(MOD_DIR)/lib/libstring.$(LIBSUF)\ - $(MOD_DIR)/lib/libsystem.$(LIBSUF)\ - $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) - -em_nopt: incalls.r main.$(SUF) $(NOFILES) - $(CC) $(LDFLAGS) -o em_nopt main.$(SUF) $(NOFILES) $(NOPTLIB) - -OLINT = $(SRC_DIR)/main.c $(SRC_DIR)/mkstrct.c $(SRC_DIR)/nopt.c $(SRC_DIR)/aux.c dfa.c trans.c - -OLINTLIB = $(UTIL_HOME)/modules/lib/$(LINTPREF)read_emkV.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)emk.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)system.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)alloc.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)print.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)string.$(LINTSUF) - -lintnopt: incalls.r $(OLINT) - $(LINT) $(LINTFLAGS) $(OLINT) $(OLINTLIB) - -# How to build the library version of the optimizer - -$(LIBOPT): $(NOFILES) pseudo.d incalls.d - rm -f $(LIBOPT) - $(AR) r $(LIBOPT) O_*.$(SUF) $(NOFILES) - $(RANLIB) $(LIBOPT) - -$(LIBCEOPT): incalls.r - rm -f O_*.$(SUF) $(NOFILES) pseudo.d incalls.d - -mv $(LIBOPT) $(LIBOPT).saved - make PREFLAGS='$(INCLUDES) -DPRIVATE=static -DCODE_EXPANDER' $(LIBOPT) - mv $(LIBOPT) $(LIBCEOPT) - -mv $(LIBOPT).saved $(LIBOPT) - rm -f O_*.$(SUF) $(NOFILES) - -prototypes: pseudo.r incalls.r - cp $(SRC_DIR)/em_codeO.h prototypes - echo >> prototypes - awk -f $(SRC_DIR)/makefuns.awk pseudo.r incalls.r > /dev/null - -incalls.r: $(SRC_DIR)/patterns parser - -$(UTIL_HOME)/lib.bin/cpp $(SRC_DIR)/patterns | $(HOWMUCH) >/tmp/patts - parser syntax.c - -parserdummy: $(SRC_DIR)/parser.g - LLgen $(LLOPT) $(SRC_DIR)/parser.g - touch parserdummy - -PLINT = parser.c syntax.c $(SRC_DIR)/outputdfa.c $(SRC_DIR)/outcalls.c\ - $(SRC_DIR)/findworst.c $(SRC_DIR)/initlex.c Lpars.c - -PLINTLIB = $(UTIL_HOME)/modules/lib/$(LINTPREF)alloc.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)string.$(LINTSUF)\ - $(UTIL_HOME)/modules/lib/$(LINTPREF)system.$(LINTSUF) - -LINTFLAGS = $(LINTOPTIONS) - -lintparser: parserdummy $(PLINT) - $(LINT) $(LINTFLAGS) $(PLINT) $(PLINTLIB) - -# Dependancies - -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c -main.$(SUF): $(SRC_DIR)/nopt.h - -nopt.$(SUF): $(SRC_DIR)/nopt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/nopt.c -nopt.$(SUF): $(SRC_DIR)/nopt.h - -mkstrct.$(SUF): $(SRC_DIR)/mkstrct.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/mkstrct.c -mkstrct.$(SUF): $(SRC_DIR)/nopt.h - -aux.$(SUF): $(SRC_DIR)/aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/aux.c -aux.$(SUF): $(SRC_DIR)/nopt.h - -dfa.$(SUF): dfa.c - $(CC) -c $(CFLAGS) dfa.c -dfa.$(SUF): $(SRC_DIR)/nopt.h - -trans.$(SUF): trans.c - $(CC) -c $(CFLAGS) trans.c -trans.$(SUF): $(SRC_DIR)/nopt.h - -incalls.d: $(SRC_DIR)/nopt.h $(SRC_DIR)/makefuns.awk -pseudo.d: $(SRC_DIR)/nopt.h $(SRC_DIR)/makefuns.awk -pseudo.r: $(SRC_DIR)/pseudo.r - cp $(SRC_DIR)/pseudo.r pseudo.r - -parser.$(USUF): parser.c - $(UCC) -c $(UCFLAGS) parser.c -parser.$(USUF): Lpars.h $(SRC_DIR)/parser.h - -Lpars.$(USUF): Lpars.c - $(UCC) -c $(UCFLAGS) Lpars.c -Lpars.$(USUF): Lpars.h - -syntax.$(USUF): syntax.c - $(UCC) -c $(UCFLAGS) syntax.c -sybtax.$(USUF): $(SRC_DIR)/parser.h Lpars.h - -outputdfa.$(USUF): $(SRC_DIR)/outputdfa.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/outputdfa.c -outputdfa.$(USUF): $(SRC_DIR)/parser.h Lpars.h - -outcalls.$(USUF): $(SRC_DIR)/outcalls.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/outcalls.c -outcalls.$(USUF): $(SRC_DIR)/parser.h - -findworst.$(USUF): $(SRC_DIR)/findworst.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/findworst.c -findworst.$(USUF): $(SRC_DIR)/parser.h - -initlex.$(USUF): $(SRC_DIR)/initlex.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/initlex.c -initlex.$(USUF): $(SRC_DIR)/parser.h diff --git a/modules/src/flt_arith/.distr b/modules/src/flt_arith/.distr deleted file mode 100644 index c5c0292b5..000000000 --- a/modules/src/flt_arith/.distr +++ /dev/null @@ -1,20 +0,0 @@ -pmfile -b64_add.c -b64_sft.c -flt_add.c -flt_arith.h -flt_ar2flt.c -flt_chk.c -flt_cmp.c -flt_div.c -flt_flt2ar.c -flt_modf.c -flt_mul.c -flt_nrm.c -flt_str2fl.c -flt_umin.c -flt_misc.h -ucmp.c -split.c -flt_arith.3 -test.c diff --git a/modules/src/flt_arith/build.lua b/modules/src/flt_arith/build.lua new file mode 100644 index 000000000..a3da4b801 --- /dev/null +++ b/modules/src/flt_arith/build.lua @@ -0,0 +1,26 @@ +clibrary { + name = "lib", + srcs = { + "./flt_ar2flt.c", + "./flt_div.c", + "./flt_flt2ar.c", + "./flt_modf.c", + "./flt_str2fl.c", + "./flt_cmp.c", + "./flt_add.c", + "./b64_add.c", + "./flt_mul.c", + "./flt_nrm.c", + "./b64_sft.c", + "./flt_umin.c", + "./flt_chk.c", + "./split.c", + "./ucmp.c", + }, + hdrs = { "./flt_arith.h" }, + deps = { + "modules+headers" + } +} + + diff --git a/modules/src/flt_arith/pmfile b/modules/src/flt_arith/pmfile deleted file mode 100644 index 683cbffa4..000000000 --- a/modules/src/flt_arith/pmfile +++ /dev/null @@ -1,35 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."modules/src/flt_arith/" -lib_flt_arith = file (LIBDIR.."libflt_arith.a") - -module_flt_arith = clibrary { - cfile (d.."flt_ar2flt.c"), - cfile (d.."flt_div.c"), - cfile (d.."flt_flt2ar.c"), - cfile (d.."flt_modf.c"), - cfile (d.."flt_str2fl.c"), - cfile (d.."flt_cmp.c"), - cfile (d.."flt_add.c"), - cfile (d.."b64_add.c"), - cfile (d.."flt_mul.c"), - cfile (d.."flt_nrm.c"), - cfile (d.."b64_sft.c"), - cfile (d.."flt_umin.c"), - cfile (d.."flt_chk.c"), - cfile (d.."split.c"), - cfile (d.."ucmp.c"), - - outputs = {"%U%/libflt_arith.a"}, - install = { - pm.install(LIBDIR.."libflt_arith.a"), - pm.install(d.."flt_arith.h", HEADERDIR.."flt_arith.h") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/flt_arith/proto.make b/modules/src/flt_arith/proto.make deleted file mode 100644 index c0fb20517..000000000 --- a/modules/src/flt_arith/proto.make +++ /dev/null @@ -1,117 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/flt_arith -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(INCLUDES) $(COPTIONS) -LDFLAGS = $(LDOPTIONS) - -LIBFLT = libflt.$(LIBSUF) - -SRC = $(SRC_DIR)/flt_ar2flt.c \ - $(SRC_DIR)/flt_div.c \ - $(SRC_DIR)/flt_flt2ar.c \ - $(SRC_DIR)/flt_modf.c \ - $(SRC_DIR)/flt_str2fl.c \ - $(SRC_DIR)/flt_cmp.c \ - $(SRC_DIR)/flt_add.c \ - $(SRC_DIR)/b64_add.c \ - $(SRC_DIR)/flt_mul.c \ - $(SRC_DIR)/flt_nrm.c \ - $(SRC_DIR)/b64_sft.c \ - $(SRC_DIR)/flt_umin.c \ - $(SRC_DIR)/flt_chk.c \ - $(SRC_DIR)/split.c \ - $(SRC_DIR)/ucmp.c - -OBJ = flt_ar2flt.$(SUF) flt_div.$(SUF) flt_flt2ar.$(SUF) flt_modf.$(SUF) \ - flt_str2fl.$(SUF) flt_cmp.$(SUF) flt_add.$(SUF) b64_add.$(SUF) \ - flt_mul.$(SUF) flt_nrm.$(SUF) b64_sft.$(SUF) flt_umin.$(SUF) \ - flt_chk.$(SUF) split.$(SUF) ucmp.$(SUF) - -all: $(LIBFLT) - -test: $(LIBFLT) test.$(SUF) - $(CC) $(LDFLAGS) -o tst test.$(SUF) $(LIBFLT) - ./tst - -$(LIBFLT): $(OBJ) - rm -f $(LIBFLT) - $(AR) r $(LIBFLT) $(OBJ) - $(RANLIB) $(LIBFLT) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBFLT) $(MOD_DIR)/lib/$(LIBFLT) - $(RANLIB) $(MOD_DIR)/lib/$(LIBFLT) - cp $(SRC_DIR)/flt_arith.h $(MOD_DIR)/h/flt_arith.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/flt_arith.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBFLT) $(MOD_DIR)/lib/$(LIBFLT) - -cmp $(SRC_DIR)/flt_arith.h $(MOD_DIR)/h/flt_arith.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) $(LIBFLT) tst - -lintlib: - $(MK_LINT_LIB) flt $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -b64_add.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/b64_add.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/b64_add.c - -flt_ar2flt.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_ar2flt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_ar2flt.c - -flt_div.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_div.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_div.c - -flt_nrm.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_nrm.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_nrm.c - -b64_sft.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/b64_sft.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/b64_sft.c - -flt_chk.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_chk.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_chk.c - -flt_flt2ar.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_flt2ar.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_flt2ar.c - -flt_str2fl.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_str2fl.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_str2fl.c - -flt_add.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_add.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_add.c - -flt_cmp.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_cmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_cmp.c - -flt_mul.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_mul.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_mul.c - -flt_modf.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/flt_modf.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_modf.c - -flt_umin.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_umin.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flt_umin.c - -ucmp.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/ucmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ucmp.c - -split.$(SUF): $(SRC_DIR)/flt_misc.h $(SRC_DIR)/flt_arith.h $(SRC_DIR)/split.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/split.c - -test.$(SUF): $(SRC_DIR)/flt_arith.h $(SRC_DIR)/test.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/test.c diff --git a/modules/src/idf/.distr b/modules/src/idf/.distr deleted file mode 100644 index 4402cca9f..000000000 --- a/modules/src/idf/.distr +++ /dev/null @@ -1,4 +0,0 @@ -pmfile -idf.3 -idf_pkg.body -idf_pkg.spec diff --git a/modules/src/idf/build.lua b/modules/src/idf/build.lua new file mode 100644 index 000000000..ac30ac54e --- /dev/null +++ b/modules/src/idf/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "lib", + srcs = {}, + hdrs = { "./idf_pkg.*" }, +} + + diff --git a/modules/src/idf/pmfile b/modules/src/idf/pmfile deleted file mode 100644 index 80acffcdb..000000000 --- a/modules/src/idf/pmfile +++ /dev/null @@ -1,17 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/idf/" - -module_idf = group { - install = { - pm.install(d.."idf_pkg.spec", HEADERDIR.."idf_pkg.spec"), - pm.install(d.."idf_pkg.body", HEADERDIR.."idf_pkg.body"), - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/modules/src/idf/proto.make b/modules/src/idf/proto.make deleted file mode 100644 index 259c2df41..000000000 --- a/modules/src/idf/proto.make +++ /dev/null @@ -1,29 +0,0 @@ -# $Id$ - -#PARAMS do not delete this line! - -SRC_DIR = $(SRC_HOME)/modules/src/idf -MOD_DIR = $(TARGET_HOME)/modules - -all: - -install: all - -mkdir $(MOD_DIR)/pkg - cp $(SRC_DIR)/idf_pkg.body $(MOD_DIR)/pkg/idf_pkg.body - cp $(SRC_DIR)/idf_pkg.spec $(MOD_DIR)/pkg/idf_pkg.spec - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/idf.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(SRC_DIR)/idf_pkg.body $(MOD_DIR)/pkg/idf_pkg.body - -cmp $(SRC_DIR)/idf_pkg.spec $(MOD_DIR)/pkg/idf_pkg.spec - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/idf_pkg.spec $(SRC_DIR)/idf_pkg.body - -opr: - make pr | opr - -clean: -lintlib: diff --git a/modules/src/input/.distr b/modules/src/input/.distr deleted file mode 100644 index fc3c9413f..000000000 --- a/modules/src/input/.distr +++ /dev/null @@ -1,6 +0,0 @@ -pmfile -AtEoIF.c -AtEoIT.c -inp_pkg.body -inp_pkg.spec -input.3 diff --git a/modules/src/input/build.lua b/modules/src/input/build.lua new file mode 100644 index 000000000..7f59455e0 --- /dev/null +++ b/modules/src/input/build.lua @@ -0,0 +1,9 @@ +clibrary { + name = "lib", + srcs = { + "./*.c" + }, + hdrs = { "./inp_pkg.*" } +} + + diff --git a/modules/src/input/pmfile b/modules/src/input/pmfile deleted file mode 100644 index 71be8dbb9..000000000 --- a/modules/src/input/pmfile +++ /dev/null @@ -1,23 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/input/" -lib_input = file (LIBDIR.."libinput.a") - -module_input = clibrary { - cfile (d.."AtEoIF.c"), - cfile (d.."AtEoIT.c"), - - outputs = {"%U%/libinput.a"}, - install = { - pm.install(LIBDIR.."libinput.a"), - pm.install(d.."inp_pkg.spec", HEADERDIR.."inp_pkg.spec"), - pm.install(d.."inp_pkg.body", HEADERDIR.."inp_pkg.body") - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/input/proto.make b/modules/src/input/proto.make deleted file mode 100644 index d8e542d81..000000000 --- a/modules/src/input/proto.make +++ /dev/null @@ -1,52 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/input -MOD_DIR = $(TARGET_HOME)/modules - -OBJECTS = AtEoIF.$(SUF)\ - AtEoIT.$(SUF) - -CFLAGS = $(COPTIONS) - -all: libinput.$(LIBSUF) - -libinput.$(LIBSUF): $(OBJECTS) - rm -f libinput.$(LIBSUF) - $(AR) r libinput.$(LIBSUF) $(OBJECTS) - $(RANLIB) libinput.$(LIBSUF) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/pkg - cp libinput.$(LIBSUF) $(MOD_DIR)/lib/libinput.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libinput.$(LIBSUF) - cp $(SRC_DIR)/inp_pkg.body $(MOD_DIR)/pkg/inp_pkg.body - cp $(SRC_DIR)/inp_pkg.spec $(MOD_DIR)/pkg/inp_pkg.spec - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/input.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp libinput.$(LIBSUF) $(MOD_DIR)/lib/libinput.$(LIBSUF) - -cmp $(SRC_DIR)/inp_pkg.body $(MOD_DIR)/pkg/inp_pkg.body - -cmp $(SRC_DIR)/inp_pkg.spec $(MOD_DIR)/pkg/inp_pkg.spec - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/inp_pkg.spec $(SRC_DIR)/inp_pkg.body $(SRC_DIR)/AtEoIF.c $(SRC_DIR)/AtEoIT.c - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) input $(MOD_DIR)/lib $(SRC_DIR)/AtEoIF.c $(SRC_DIR)/AtEoIT.c - -AtEoIT.$(SUF): $(SRC_DIR)/AtEoIT.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/AtEoIT.c - -AtEoIF.$(SUF): $(SRC_DIR)/AtEoIF.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/AtEoIF.c diff --git a/modules/src/malloc/.distr b/modules/src/malloc/.distr deleted file mode 100644 index f2d23b8a6..000000000 --- a/modules/src/malloc/.distr +++ /dev/null @@ -1,15 +0,0 @@ -proto.make -READ_ME -add_file -check.c -check.h -getsize.c -global.c -impl.h -log.c -log.h -mal.c -param.h -phys.c -phys.h -size_type.h diff --git a/modules/src/malloc/proto.make b/modules/src/malloc/proto.make deleted file mode 100644 index ad4eae7c6..000000000 --- a/modules/src/malloc/proto.make +++ /dev/null @@ -1,53 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/malloc -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(MOD_DIR)/h -CFLAGS = $(INCLUDES) $(COPTIONS) - -MALLOCSRC = $(SRC_DIR)/READ_ME $(SRC_DIR)/size_type.h \ - gensize_type.h $(SRC_DIR)/param.h $(SRC_DIR)/impl.h \ - $(SRC_DIR)/check.h $(SRC_DIR)/log.h $(SRC_DIR)/phys.h \ - $(SRC_DIR)/mal.c $(SRC_DIR)/log.c $(SRC_DIR)/phys.c \ - $(SRC_DIR)/check.c - -all: malloc.$(SUF) - -install: all - -mkdir $(MOD_DIR)/lib - cp malloc.$(SUF) $(MOD_DIR)/lib/malloc.$(SUF) - -cmp: all - -cmp malloc.$(SUF) $(MOD_DIR)/lib/malloc.$(SUF) - -malloc1.c: $(MALLOCSRC) $(SRC_DIR)/add_file - rm -f malloc1.c - for i in $(MALLOCSRC) ; do $(SRC_DIR)/add_file $$i >> malloc1.c ; done - -malloc.c: malloc1.c - cclash -l7 -c malloc1.c > clashes - cid -Fclashes < malloc1.c > malloc.c - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/add_file $(MALLOCSRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) clashes malloc1.c gensize_type.h getsize malloc.c - -gensize_type.h: getsize - getsize > gensize_type.h - -getsize: $(SRC_DIR)/getsize.c - $(UCC) -o getsize $(SRC_DIR)/getsize.c -# use $(UCC), not $(CC) as this must produce runnable binary. - -malloc.$(SUF): malloc.c - $(CC) -c $(CFLAGS) malloc.c -# to avoid options that the SUN make adds. - -lintlib: diff --git a/modules/src/object/.distr b/modules/src/object/.distr deleted file mode 100644 index 1ad72d93d..000000000 --- a/modules/src/object/.distr +++ /dev/null @@ -1,18 +0,0 @@ -pmfile -object.3 -object.h -obj.h -rd.c -rd_arhdr.c -rd_bytes.c -rd_int2.c -rd_long.c -rd_ranlib.c -rd_unsig2.c -wr.c -wr_arhdr.c -wr_bytes.c -wr_int2.c -wr_long.c -wr_putc.c -wr_ranlib.c diff --git a/modules/src/object/build.lua b/modules/src/object/build.lua new file mode 100644 index 000000000..61a9907f1 --- /dev/null +++ b/modules/src/object/build.lua @@ -0,0 +1,11 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + deps = { + "modules+headers", + "h+local", + "h+emheaders", + }, +} + + diff --git a/modules/src/object/obj.h b/modules/src/object/obj.h index a725ed5bd..8f7fd8d32 100644 --- a/modules/src/object/obj.h +++ b/modules/src/object/obj.h @@ -15,38 +15,16 @@ #define CHAR_UNSIGNED 0 #endif -#if CHAR_UNSIGNED -#define Xchar(ch) (ch) -#else -#define Xchar(ch) ((ch) & 0377) -#endif +#define Xchar(ch) (uint32_t)(uint8_t)(ch) -#if ! defined(BYTE_ORDER) -#define BYTE_ORDER 0x3210 -#endif -#if (BYTE_ORDER == 0x3210 || BYTE_ORDER == 0x1032) -#define uget2(c) (Xchar((c)[0]) | ((unsigned) Xchar((c)[1]) << 8)) -#define Xput2(i, c) (((c)[0] = (i)), ((c)[1] = (i) >> 8)) -#define put2(i, c) { register int j = (i); Xput2(j, c); } -#else -#define uget2(c) (* ((unsigned short *) (c))) -#define Xput2(i, c) (* ((short *) (c)) = (i)) -#define put2(i, c) Xput2(i, c) -#endif +#define uget2(c) (Xchar((c)[0]) | (Xchar((c)[1])<<8)) +#define get2(c) ((int16_t) uget2(c)) +#define put2(i, c) (((c)[0] = i), ((c)[1] = i>>8)) -#define get2(c) ((short) uget2(c)) - -#if BYTE_ORDER != 0x0123 -#define get4(c) (uget2(c) | ((long) uget2((c)+2) << 16)) -#define put4(l, c) { register long x=(l); \ - Xput2((int)x,c); \ - Xput2((int)(x>>16),(c)+2); \ - } -#else -#define get4(c) (* ((long *) (c))) -#define put4(l, c) (* ((long *) (c)) = (l)) -#endif +#define uget4(c) (uget2(c) | (uget2((c)+2)<<16)) +#define get4(c) ((int32_t) uget4(c)) +#define put4(i, c) (put2(i, c), put2((i)>>16, (c)+2)) #define SECTCNT 3 /* number of sections with own output buffer */ #if BIGMACHINE diff --git a/modules/src/object/pmfile b/modules/src/object/pmfile deleted file mode 100644 index 2806f50b3..000000000 --- a/modules/src/object/pmfile +++ /dev/null @@ -1,55 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/object/" -lib_object = file (LIBDIR.."libobject.a") - -module_object = clibrary { - cfile (d.."rd_arhdr.c"), - cfile (d.."rd_bytes.c"), - cfile (d.."rd_int2.c"), - cfile (d.."rd_long.c"), - cfile (d.."rd_ranlib.c"), - cfile (d.."rd_unsig2.c"), - cfile (d.."rd.c"), - cfile (d.."wr_arhdr.c"), - cfile (d.."wr_bytes.c"), - cfile (d.."wr_int2.c"), - cfile (d.."wr_long.c"), - cfile (d.."wr_putc.c"), - cfile (d.."wr_ranlib.c"), - cfile (d.."wr.c"), - - outputs = {"%U%/lib_object.a"}, - install = { - pm.install(LIBDIR.."libobject.a") - } -} ---[[ - - -# genmakefile -# This genmakefile doesn't have a real comment yet. -# -# $Source$ -# $State$ - -push - addincludeq src/lib/object - - - hostlibrary $LIBDIR/libobject.a $OBJS -pop - -# Revision history -# $Log$ -# Revision 1.1 2006-07-20 23:18:18 dtrg -# First version in CVS. -# ---]] - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/object/proto.make b/modules/src/object/proto.make deleted file mode 100644 index 3fbc17260..000000000 --- a/modules/src/object/proto.make +++ /dev/null @@ -1,95 +0,0 @@ -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/object -MOD_DIR = $(TARGET_HOME)/modules -INCLUDES = -I$(TARGET_HOME)/h -I$(MOD_DIR)/h -I$(TARGET_HOME)/config -I$(SRC_DIR) -CFLAGS = $(INCLUDES) $(COPTIONS) - -CFILES = $(SRC_DIR)/rd_arhdr.c $(SRC_DIR)/wr_arhdr.c \ - $(SRC_DIR)/rd_ranlib.c $(SRC_DIR)/wr_ranlib.c \ - $(SRC_DIR)/rd_bytes.c $(SRC_DIR)/wr_bytes.c \ - $(SRC_DIR)/rd.c $(SRC_DIR)/wr.c \ - $(SRC_DIR)/wr_putc.c \ - $(SRC_DIR)/rd_int2.c $(SRC_DIR)/wr_int2.c \ - $(SRC_DIR)/rd_unsig2.c \ - $(SRC_DIR)/rd_long.c $(SRC_DIR)/wr_long.c -# do not change the order in OFILES -OFILES = rd.$(SUF) rd_arhdr.$(SUF) rd_int2.$(SUF) rd_long.$(SUF) \ - rd_ranlib.$(SUF) rd_unsig2.$(SUF) rd_bytes.$(SUF) \ - wr_arhdr.$(SUF) wr_int2.$(SUF) wr_long.$(SUF) wr_putc.$(SUF) \ - wr.$(SUF) wr_ranlib.$(SUF) wr_bytes.$(SUF) - -all: libobject.$(LIBSUF) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp libobject.$(LIBSUF) $(MOD_DIR)/lib/libobject.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libobject.$(LIBSUF) - cp $(SRC_DIR)/object.h $(MOD_DIR)/h/object.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/object.3 $(TARGET_HOME) ; \ - fi - -compare: all - -cmp libobject.$(LIBSUF) $(MOD_DIR)/lib/libobject.$(LIBSUF) - -cmp $(SRC_DIR)/object.h $(MOD_DIR)/h/object.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/object.h $(CFILES) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) nohup.out Out - -libobject.$(LIBSUF): $(OFILES) - rm -f libobject.$(LIBSUF) - $(AR) r libobject.$(LIBSUF) $(OFILES) - $(RANLIB) libobject.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) object $(MOD_DIR)/lib $(INCLUDES) $(CFILES) - -rd_arhdr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_arhdr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_arhdr.c - -wr_arhdr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_arhdr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_arhdr.c - -rd_ranlib.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_ranlib.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_ranlib.c - -wr_ranlib.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_ranlib.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_ranlib.c - -rd.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd.c - -wr.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr.c - -wr_putc.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_putc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_putc.c - -rd_int2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_int2.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_int2.c - -wr_int2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_int2.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_int2.c - -rd_unsig2.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_unsig2.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_unsig2.c - -rd_long.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/rd_long.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_long.c - -wr_long.$(SUF): $(SRC_DIR)/object.h $(SRC_DIR)/wr_long.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_long.c - -rd_bytes.$(SUF): $(SRC_DIR)/rd_bytes.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rd_bytes.c - -wr_bytes.$(SUF): $(SRC_DIR)/wr_bytes.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/wr_bytes.c diff --git a/modules/src/object/rd.c b/modules/src/object/rd.c index 55f67bb8d..7790a4720 100644 --- a/modules/src/object/rd.c +++ b/modules/src/object/rd.c @@ -109,9 +109,6 @@ rd_ohead(head) register long off; OUTREAD(PARTEMIT, (char *) head, (long) SZ_HEAD); -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outhead) != SZ_HEAD) -#endif { register char *c = (char *) head + (SZ_HEAD-4); @@ -157,16 +154,13 @@ rd_sect(sect, cnt) offcnt += cnt; while (cnt--) { sect--; -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outsect) != SZ_SECT) -#endif - { - c -= 4; sect->os_lign = get4(c); - c -= 4; sect->os_flen = get4(c); - c -= 4; sect->os_foff = get4(c); - c -= 4; sect->os_size = get4(c); - c -= 4; sect->os_base = get4(c); - } + + c -= 4; sect->os_lign = get4(c); + c -= 4; sect->os_flen = get4(c); + c -= 4; sect->os_foff = get4(c); + c -= 4; sect->os_size = get4(c); + c -= 4; sect->os_base = get4(c); + offset[--offcnt] = sect->os_foff + rd_base; } } @@ -197,9 +191,6 @@ rd_relo(relo, cnt) { OUTREAD(PARTRELO, (char *) relo, (long) cnt * SZ_RELO); -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outrelo) != SZ_RELO) -#endif { register char *c = (char *) relo + (long) cnt * SZ_RELO; @@ -208,8 +199,8 @@ rd_relo(relo, cnt) relo--; c -= 4; relo->or_addr = get4(c); c -= 2; relo->or_nami = uget2(c); - relo->or_sect = *--c; - relo->or_type = *--c; + c -= 2; relo->or_sect = uget2(c); + c -= 2; relo->or_type = uget2(c); } } } @@ -221,9 +212,6 @@ rd_name(name, cnt) { OUTREAD(PARTNAME, (char *) name, (long) cnt * SZ_NAME); -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outname) != SZ_NAME) -#endif { register char *c = (char *) name + (long) cnt * SZ_NAME; diff --git a/modules/src/object/rd_ranlib.c b/modules/src/object/rd_ranlib.c index 63bc6964a..0a3d4d760 100644 --- a/modules/src/object/rd_ranlib.c +++ b/modules/src/object/rd_ranlib.c @@ -11,9 +11,6 @@ rd_ranlib(fd, ran, cnt) register long cnt; { rd_bytes(fd, (char *) ran, cnt * SZ_RAN); -#if BYTE_ORDER == 0x0123 - if (sizeof (struct ranlib) != SZ_RAN) -#endif { register char *c = (char *) ran + cnt * SZ_RAN; diff --git a/modules/src/object/wr.c b/modules/src/object/wr.c index 53267d0ee..20e5132f2 100644 --- a/modules/src/object/wr.c +++ b/modules/src/object/wr.c @@ -198,7 +198,7 @@ wr_ohead(head) BEGINSEEK(PARTDBUG, off); #endif } - if (BYTE_ORDER != 0x0123 || sizeof(struct outhead) != SZ_HEAD) + { char buf[SZ_HEAD]; @@ -214,7 +214,6 @@ wr_ohead(head) put4(head->oh_nchar, c); OUTWRITE(PARTEMIT, buf, (long)SZ_HEAD); } - else OUTWRITE(PARTEMIT, (char *)head, (long)SZ_HEAD); } void @@ -233,9 +232,6 @@ wr_sect(sect, cnt) } sect -= cnt; } -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outsect) != SZ_SECT) -#endif while (cnt) { register char *c; @@ -259,11 +255,6 @@ wr_sect(sect, cnt) __wr_flush(&__parts[PARTEMIT]); } } -#if BYTE_ORDER == 0x0123 - else { - OUTWRITE(PARTEMIT, (char *) sect, (long) cnt * SZ_SECT); - } -#endif } void @@ -313,9 +304,6 @@ wr_relo(relo, cnt) unsigned int cnt; { -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outrelo) != SZ_RELO) -#endif while (cnt) { register char *c; @@ -327,8 +315,8 @@ wr_relo(relo, cnt) cnt -= i; __parts[PARTRELO].cnt -= (i*SZ_RELO); while (i--) { - *c++ = relo->or_type; - *c++ = relo->or_sect; + put2(relo->or_type, c); c += 2; + put2(relo->or_sect, c); c += 2; put2(relo->or_nami, c); c += 2; put4(relo->or_addr, c); c += 4; relo++; @@ -338,11 +326,6 @@ wr_relo(relo, cnt) __wr_flush(&__parts[PARTRELO]); } } -#if BYTE_ORDER == 0x0123 - else { - OUTWRITE(PARTRELO, (char *) relo, (long) cnt * SZ_RELO); - } -#endif } void @@ -350,9 +333,6 @@ wr_name(name, cnt) register struct outname *name; unsigned int cnt; { -#if BYTE_ORDER == 0x0123 - if (sizeof(struct outname) != SZ_NAME) -#endif while (cnt) { register char *c; @@ -373,12 +353,6 @@ wr_name(name, cnt) __parts[PARTNAME].pnow = c; if (cnt) __wr_flush(&__parts[PARTNAME]); } -#if BYTE_ORDER == 0x0123 - else { - OUTWRITE(PARTNAME, (char *) name, (long)cnt * SZ_NAME); - } -#endif - } void diff --git a/modules/src/object/wr_ranlib.c b/modules/src/object/wr_ranlib.c index f55cef3cd..91274d71c 100644 --- a/modules/src/object/wr_ranlib.c +++ b/modules/src/object/wr_ranlib.c @@ -10,9 +10,6 @@ wr_ranlib(fd, ran, cnt1) struct ranlib *ran; long cnt1; { -#if BYTE_ORDER == 0x0123 - if (sizeof (struct ranlib) != SZ_RAN) -#endif { register long cnt = cnt1; register struct ranlib *r = ran; diff --git a/modules/src/print/.distr b/modules/src/print/.distr deleted file mode 100644 index b23ff8f37..000000000 --- a/modules/src/print/.distr +++ /dev/null @@ -1,9 +0,0 @@ -pmfile -doprnt.c -format.c -fprint.c -param.h -print.3 -print.c -print.h -sprint.c diff --git a/modules/src/print/build.lua b/modules/src/print/build.lua new file mode 100644 index 000000000..a3bc48b06 --- /dev/null +++ b/modules/src/print/build.lua @@ -0,0 +1,11 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./print.h" }, + deps = { + "modules+headers", + "modules/src/system+lib" + } +} + + diff --git a/modules/src/print/pmfile b/modules/src/print/pmfile deleted file mode 100644 index 6f7c0504d..000000000 --- a/modules/src/print/pmfile +++ /dev/null @@ -1,27 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/print/" -lib_print = file (LIBDIR.."libprint.a") - -module_print = clibrary { - cfile (d.."doprnt.c"), - cfile (d.."fprint.c"), - cfile (d.."print.c"), - cfile (d.."sprint.c"), - cfile (d.."format.c"), - - outputs = {"%U%/libprint.a"}, - install = { - pm.install("%LIBDIR%libprint.a"), - pm.install(d.."print.h", "%HEADERDIR%print.h") - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 20:59:22 dtrg --- Changed to export a header file so it can be correctly referred to. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. diff --git a/modules/src/print/proto.make b/modules/src/print/proto.make deleted file mode 100644 index 61004de70..000000000 --- a/modules/src/print/proto.make +++ /dev/null @@ -1,62 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/print -MOD_DIR = $(TARGET_HOME)/modules -LIBPRINT = libprint.$(LIBSUF) -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h - -CFLAGS = $(COPTIONS) $(INCLUDES) - -SRC = $(SRC_DIR)/doprnt.c $(SRC_DIR)/fprint.c $(SRC_DIR)/print.c \ - $(SRC_DIR)/sprint.c $(SRC_DIR)/format.c -OBJ = doprnt.$(SUF) fprint.$(SUF) print.$(SUF) sprint.$(SUF) format.$(SUF) - -all: $(LIBPRINT) - -$(LIBPRINT): $(OBJ) - rm -f $(LIBPRINT) - $(AR) r $(LIBPRINT) $(OBJ) - $(RANLIB) $(LIBPRINT) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBPRINT) $(MOD_DIR)/lib/$(LIBPRINT) - $(RANLIB) $(MOD_DIR)/lib/$(LIBPRINT) - cp $(SRC_DIR)/print.h $(MOD_DIR)/h/print.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/print.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBPRINT) $(MOD_DIR)/lib/$(LIBPRINT) - -cmp $(SRC_DIR)/print.h $(MOD_DIR)/h/print.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) $(LIBPRINT) - -lintlib: - $(MK_LINT_LIB) print $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -doprnt.$(SUF): $(SRC_DIR)/param.h $(SRC_DIR)/doprnt.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/doprnt.c - -fprint.$(SUF): $(SRC_DIR)/param.h $(SRC_DIR)/fprint.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/fprint.c - -print.$(SUF): $(SRC_DIR)/param.h $(SRC_DIR)/print.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/print.c - -sprint.$(SUF): $(SRC_DIR)/param.h $(SRC_DIR)/sprint.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sprint.c - -format.$(SUF): $(SRC_DIR)/format.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/format.c diff --git a/modules/src/read_em/.distr b/modules/src/read_em/.distr deleted file mode 100644 index 100499ee0..000000000 --- a/modules/src/read_em/.distr +++ /dev/null @@ -1,11 +0,0 @@ -pmfile -EM_vars.c -argtype -em_comp.h -m_C_mnem -m_C_mnem_na -mkcalls.c -read_em.3 -read_em.c -reade.c -readk.c diff --git a/modules/src/read_em/build.lua b/modules/src/read_em/build.lua new file mode 100644 index 000000000..f559831bd --- /dev/null +++ b/modules/src/read_em/build.lua @@ -0,0 +1,63 @@ + +normalrule { + name = "c_mnem_narg_h", + ins = { + "./m_C_mnem_na", + "h/em_table", + "./argtype" + }, + outleaves = "C_mnem_narg.h", + commands = { + "%{ins} > %{outs}" + } +} + +normalrule { + name = "c_mnem_h", + ins = { + "./m_C_mnem", + "h/em_table", + "./argtype" + }, + outleaves = "C_mnem.h", + commands = { + "%{ins} > %{outs}" + } +} + +local function variant(name, cflags) + clibrary { + name = name, + vars = { + ["+cflags"] = { + "-DPRIVATE=static", + "-DEXPORT=", + "-DNDEBUG", + "-DCHECKING", + unpack(cflags) + }, + }, + srcs = { + "./EM_vars.c", + "./read_em.c", + "./mkcalls.c", + }, + hdrs = { + "./em_comp.h", + }, + deps = { + "+c_mnem_h", + "+c_mnem_narg_h", + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+headers", + "modules/src/em_data+lib", + "modules/src/system+lib", + } + } +end + +variant("lib_ev", {}) +variant("lib_kv", { "-DCOMPACT" }) + diff --git a/modules/src/read_em/m_C_mnem b/modules/src/read_em/m_C_mnem index 70152f5c4..67b6056b5 100755 --- a/modules/src/read_em/m_C_mnem +++ b/modules/src/read_em/m_C_mnem @@ -1,10 +1,11 @@ #!/bin/sh EM_TABLE=$1 +ARGTYPE=$2 echo "switch(p->em_opcode) {" for i in - cdflnorswz p b do - list=`./argtype $i $EM_TABLE` + list=`$ARGTYPE $i $EM_TABLE` case $i in -) args='()' echo " /* no arguments */" @@ -34,7 +35,7 @@ do EOF done done -list=`./argtype g $EM_TABLE` +list=`$ARGTYPE g $EM_TABLE` cat << 'EOF' default: /* a "g" argument */ diff --git a/modules/src/read_em/m_C_mnem_na b/modules/src/read_em/m_C_mnem_na index 535ea0831..07e80daad 100755 --- a/modules/src/read_em/m_C_mnem_na +++ b/modules/src/read_em/m_C_mnem_na @@ -1,5 +1,6 @@ EM_TABLE=$1 -list=`./argtype w $EM_TABLE` +ARGTYPE=$2 +list=`$ARGTYPE w $EM_TABLE` echo "switch(p->em_opcode) {" for i in $list do diff --git a/modules/src/read_em/pmfile b/modules/src/read_em/pmfile deleted file mode 100644 index 1b8dddad7..000000000 --- a/modules/src/read_em/pmfile +++ /dev/null @@ -1,96 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/read_em/" -lib_read_emk = file (LIBDIR.."libread_emk.a") -lib_read_emkV = file (LIBDIR.."libread_emkV.a") -lib_read_emeV = file (LIBDIR.."libread_emeV.a") - -local C_mnem_h = simple { - command = {"(cd "..d.." && sh %in[1]% %in[2]%) > %out%"}, - outputs = {"%U%-%I%.h"}, - install = pm.install(HEADERDIR.."C_mnem.h"), - - file (ROOTDIR..d.."m_C_mnem"), - file ("%ROOTDIR%h/em_table") -} - -local C_mnem_narg_h = simple { - command = {"(cd "..d.." && %in[1]% %in[2]%) > %out%"}, - outputs = {"%U%-%I%.h"}, - install = pm.install(HEADERDIR.."C_mnem_narg.h"), - - file (ROOTDIR..d.."m_C_mnem_na"), - file ("%ROOTDIR%h/em_table") -} - -local withdynamic = cfile { - dynamicheaders = {C_mnem_h, C_mnem_narg_h} -} - -module_read_emk = clibrary { - CDEFINES = {PARENT, "PRIVATE=static", "EXPORT=", "NDEBUG"}, - cfile (d.."EM_vars.c"), - cfile { - CDEFINES = {PARENT, "COMPACT"}, - (d.."read_em.c") - }, - withdynamic (d.."mkcalls.c"), - - outputs = {"%U%/libread_emk.a"}, - install = pm.install(LIBDIR.."libread_emk.a") -} - -module_read_emkV = clibrary { - CDEFINES = {PARENT, "PRIVATE=static", "EXPORT=", "NDEBUG"}, - cfile (d.."EM_vars.c"), - cfile { - CDEFINES = {PARENT, "COMPACT", "CHECKING"}, - (d.."read_em.c") - }, - withdynamic { - CDEFINES = {PARENT, "CHECKING"}, - (d.."mkcalls.c"), - }, - - outputs = {"%U%/libread_emkV.a"}, - install = pm.install(LIBDIR.."libread_emkV.a") -} - -module_read_emeV = clibrary { - CDEFINES = {PARENT, "PRIVATE=static", "EXPORT=", "NDEBUG"}, - cfile (d.."EM_vars.c"), - cfile { - CDEFINES = {PARENT, "CHECKING"}, - (d.."read_em.c") - }, - withdynamic { - CDEFINES = {PARENT, "CHECKING"}, - (d.."mkcalls.c"), - }, - - outputs = {"%U%/lib_read_emeV.a"}, - install = pm.install(LIBDIR.."libread_emeV.a") -} - -module_read_em = group { - module_read_emk, - module_read_emkV, - module_read_emeV, - - install = { - pm.install(d.."em_comp.h", HEADERDIR.."em_comp.h"), - } -} - --- Revision history --- $Log$ --- Revision 1.3 2007-02-25 12:47:10 dtrg --- em_table is now in /h, not /etc. --- --- Revision 1.2 2006/10/15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/read_em/proto.make b/modules/src/read_em/proto.make deleted file mode 100644 index 07b38cf16..000000000 --- a/modules/src/read_em/proto.make +++ /dev/null @@ -1,123 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/read_em -MOD_DIR = $(TARGET_HOME)/modules -EM_TABLE = $(SRC_HOME)/etc/em_table -INCLUDES = -I$(TARGET_HOME)/h -I$(MOD_DIR)/h -I$(SRC_DIR) -I. -DEFINES = -DPRIVATE=static -DEXPORT= -DNDEBUG -CFLAGS = $(INCLUDES) $(DEFINES) $(COPTIONS) - -TARGETS = libread_emk.$(LIBSUF) \ - libread_emkV.$(LIBSUF) \ - libread_emeV.$(LIBSUF) - -ESRCFILES = $(SRC_DIR)/read_em.c\ - $(SRC_DIR)/mkcalls.c\ - $(SRC_DIR)/EM_vars.c - -KSRCFILES = $(SRC_DIR)/read_em.c\ - $(SRC_DIR)/mkcalls.c\ - $(SRC_DIR)/EM_vars.c - -SRCFILES = $(SRC_DIR)/em_comp.h\ - $(SRC_DIR)/read_em.c\ - $(SRC_DIR)/reade.c\ - $(SRC_DIR)/readk.c \ - $(SRC_DIR)/mkcalls.c\ - $(SRC_DIR)/EM_vars.c - -EV_OFILES = read_emeV.$(SUF) makecallsV.$(SUF) EM_vars.$(SUF) -KV_OFILES = read_emkV.$(SUF) makecallsV.$(SUF) EM_vars.$(SUF) -K_OFILES = read_emk.$(SUF) makecalls.$(SUF) EM_vars.$(SUF) - -all: $(TARGETS) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(SRC_DIR)/em_comp.h $(MOD_DIR)/h/em_comp.h - cp libread_emk.$(LIBSUF) $(MOD_DIR)/lib/libread_emk.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libread_emk.$(LIBSUF) - cp libread_emkV.$(LIBSUF) $(MOD_DIR)/lib/libread_emkV.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libread_emkV.$(LIBSUF) - cp libread_emeV.$(LIBSUF) $(MOD_DIR)/lib/libread_emeV.$(LIBSUF) - $(RANLIB) $(MOD_DIR)/lib/libread_emeV.$(LIBSUF) - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/read_em.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(SRC_DIR)/em_comp.h $(MOD_DIR)/h/em_comp.h - -cmp libread_emk.$(LIBSUF) $(MOD_DIR)/lib/libread_emk.$(LIBSUF) - -cmp libread_emkV.$(LIBSUF) $(MOD_DIR)/lib/libread_emkV.$(LIBSUF) - -cmp libread_emeV.$(LIBSUF) $(MOD_DIR)/lib/libread_emeV.$(LIBSUF) - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/m_C_mnem $(SRC_DIR)/m_C_mnem_na $(SRC_DIR)/argtype $(SRCFILES) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) C_mnem C_mnem_narg - -libread_emk.$(LIBSUF): $(K_OFILES) - rm -f libread_emk.$(LIBSUF) - $(AR) r libread_emk.$(LIBSUF) $(K_OFILES) - $(RANLIB) libread_emk.$(LIBSUF) - -libread_emkV.$(LIBSUF): $(KV_OFILES) - rm -f libread_emkV.$(LIBSUF) - $(AR) r libread_emkV.$(LIBSUF) $(KV_OFILES) - $(RANLIB) libread_emkV.$(LIBSUF) - -libread_emeV.$(LIBSUF): $(EV_OFILES) - rm -f libread_emeV.$(LIBSUF) - $(AR) r libread_emeV.$(LIBSUF) $(EV_OFILES) - $(RANLIB) libread_emeV.$(LIBSUF) - -read_emk.$(SUF): $(SRC_DIR)/read_em.c $(SRC_DIR)/em_comp.h $(SRC_DIR)/readk.c - $(CC) -c $(CFLAGS) -DCOMPACT $(SRC_DIR)/read_em.c - mv read_em.$(SUF) read_emk.$(SUF) - -read_emkV.$(SUF): $(SRC_DIR)/read_em.c $(SRC_DIR)/em_comp.h $(SRC_DIR)/readk.c - $(CC) -c $(CFLAGS) -DCOMPACT -DCHECKING $(SRC_DIR)/read_em.c - mv read_em.$(SUF) read_emkV.$(SUF) - -read_emeV.$(SUF): $(SRC_DIR)/read_em.c $(SRC_DIR)/em_comp.h $(SRC_DIR)/reade.c - $(CC) -c $(CFLAGS) -DCHECKING $(SRC_DIR)/read_em.c - mv read_em.$(SUF) read_emeV.$(SUF) - -makecalls.$(SUF): C_mnem C_mnem_narg $(SRC_DIR)/em_comp.h $(SRC_DIR)/mkcalls.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/mkcalls.c - mv mkcalls.$(SUF) makecalls.$(SUF) - -makecallsV.$(SUF): C_mnem C_mnem_narg $(SRC_DIR)/em_comp.h $(SRC_DIR)/mkcalls.c - $(CC) -c $(CFLAGS) -DCHECKING $(SRC_DIR)/mkcalls.c - mv mkcalls.$(SUF) makecallsV.$(SUF) - -makecallsO.$(SUF): C_mnem C_mnem_narg $(SRC_DIR)/em_comp.h $(SRC_DIR)/mkcalls.c - $(CC) -c -DPEEPHOLE $(CFLAGS) $(SRC_DIR)/mkcalls.c - mv mkcalls.$(SUF) makecallsO.$(SUF) - -makecallsCE.$(SUF): C_mnem C_mnem_narg $(SRC_DIR)/em_comp.h $(SRC_DIR)/mkcalls.c - $(CC) -c -DCODE_EXPANDER $(CFLAGS) $(SRC_DIR)/mkcalls.c - mv mkcalls.$(SUF) makecallsCE.$(SUF) - -C_mnem: $(SRC_DIR)/m_C_mnem argtype $(EM_TABLE) - sh $(SRC_DIR)/m_C_mnem $(EM_TABLE) > C_mnem - -C_mnem_narg: $(SRC_DIR)/m_C_mnem_na argtype $(EM_TABLE) - sh $(SRC_DIR)/m_C_mnem_na $(EM_TABLE) > C_mnem_narg - -argtype: $(SRC_DIR)/argtype - cp $(SRC_DIR)/argtype argtype - -lintlib: C_mnem C_mnem_narg - $(MK_LINT_LIB) read_emkV $(MOD_DIR)/lib $(INCLUDES) $(DEFINES) -DCOMPACT -DCHECKING $(KSRCFILES) - $(MK_LINT_LIB) read_emeV $(MOD_DIR)/lib $(INCLUDES) $(DEFINES) -DCHECKING $(ESRCFILES) - -EM_vars.$(SUF): $(SRC_DIR)/EM_vars.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/EM_vars.c diff --git a/modules/src/string/.distr b/modules/src/string/.distr deleted file mode 100644 index 77bb9697d..000000000 --- a/modules/src/string/.distr +++ /dev/null @@ -1,21 +0,0 @@ -pmfile -bts2str.c -btscat.c -btscmp.c -btscpy.c -btszero.c -long2str.c -str2bts.c -str2long.c -strcat.c -strcmp.c -strcpy.c -strindex.c -string.3 -strlen.c -strncat.c -strncmp.c -strncpy.c -strrindex.c -strzero.c -ack_string.h diff --git a/modules/src/string/build.lua b/modules/src/string/build.lua new file mode 100644 index 000000000..c45a84577 --- /dev/null +++ b/modules/src/string/build.lua @@ -0,0 +1,7 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + deps = { "modules+headers" }, +} + + diff --git a/modules/src/string/pmfile b/modules/src/string/pmfile deleted file mode 100644 index 3090ce637..000000000 --- a/modules/src/string/pmfile +++ /dev/null @@ -1,41 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/string/" -lib_string = file (LIBDIR.."libstring.a") - -module_string = clibrary { - cfile (d.."bts2str.c"), - cfile (d.."btscat.c"), - cfile (d.."btscmp.c"), - cfile (d.."btscpy.c"), - cfile (d.."btszero.c"), - cfile (d.."long2str.c"), - cfile (d.."str2bts.c"), - cfile (d.."str2long.c"), --- cfile (d.."strcat.c"), --- cfile (d.."strcmp.c"), --- cfile (d.."strcpy.c"), --- cfile (d.."strindex.c"), --- cfile (d.."strlen.c"), --- cfile (d.."strncat.c"), --- cfile (d.."strncmp.c"), --- cfile (d.."strncpy.c"), --- cfile (d.."strrindex.c"), - cfile (d.."strzero.c"), - - outputs = {"%U%/lib_string.a"}, - install = { - pm.install(LIBDIR.."libstring.a") - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-23 19:58:27 dtrg --- Modified to no longer build unoptimised duplicates of all the standard --- string functions (strcpy, strlen, etc). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/modules/src/string/proto.make b/modules/src/string/proto.make deleted file mode 100644 index 58184e7c5..000000000 --- a/modules/src/string/proto.make +++ /dev/null @@ -1,110 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/string -MOD_DIR = $(TARGET_HOME)/modules - -SRC = $(SRC_DIR)/bts2str.c $(SRC_DIR)/btscat.c $(SRC_DIR)/btscmp.c \ - $(SRC_DIR)/btscpy.c $(SRC_DIR)/btszero.c $(SRC_DIR)/long2str.c \ - $(SRC_DIR)/str2bts.c $(SRC_DIR)/str2long.c $(SRC_DIR)/strcat.c \ - $(SRC_DIR)/strcmp.c $(SRC_DIR)/strcpy.c $(SRC_DIR)/strindex.c \ - $(SRC_DIR)/strlen.c $(SRC_DIR)/strncat.c $(SRC_DIR)/strncmp.c \ - $(SRC_DIR)/strncpy.c $(SRC_DIR)/strrindex.c $(SRC_DIR)/strzero.c - -OBJ = bts2str.$(SUF) btscat.$(SUF) btscmp.$(SUF) btscpy.$(SUF) \ - btszero.$(SUF) long2str.$(SUF) str2bts.$(SUF) str2long.$(SUF) \ - strcat.$(SUF) strcmp.$(SUF) strcpy.$(SUF) strindex.$(SUF) \ - strlen.$(SUF) strncat.$(SUF) strncmp.$(SUF) strncpy.$(SUF) \ - strrindex.$(SUF) strzero.$(SUF) - -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(COPTIONS) $(INCLUDES) - -LIBSTRING = libstring.$(LIBSUF) - -all: $(LIBSTRING) - -$(LIBSTRING): $(OBJ) - $(AR) r $(LIBSTRING) $(OBJ) - $(RANLIB) $(LIBSTRING) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBSTRING) $(MOD_DIR)/lib/$(LIBSTRING) - $(RANLIB) $(MOD_DIR)/lib/$(LIBSTRING) - cp $(SRC_DIR)/ack_string.h $(MOD_DIR)/h/ack_string.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/string.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBSTRING) $(MOD_DIR)/lib/$(LIBSTRING) - -cmp $(SRC_DIR)/ack_string.h $(MOD_DIR)/h/ack_string.h - -pr: - @pr $(SRC_DIR)/proto.make $(SRC) - -opr: - make pr | opr - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -lintlib: - $(MK_LINT_LIB) string $(MOD_DIR)/lib $(INCLUDES) $(SRC) - -bts2str.$(SUF): $(SRC_DIR)/bts2str.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/bts2str.c - -btscat.$(SUF): $(SRC_DIR)/btscat.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/btscat.c - -btscmp.$(SUF): $(SRC_DIR)/btscmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/btscmp.c - -btscpy.$(SUF): $(SRC_DIR)/btscpy.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/btscpy.c - -btszero.$(SUF): $(SRC_DIR)/btszero.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/btszero.c - -long2str.$(SUF): $(SRC_DIR)/long2str.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/long2str.c - -str2bts.$(SUF): $(SRC_DIR)/str2bts.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/str2bts.c - -str2long.$(SUF): $(SRC_DIR)/str2long.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/str2long.c - -strcat.$(SUF): $(SRC_DIR)/strcat.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strcat.c - -strcmp.$(SUF): $(SRC_DIR)/strcmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strcmp.c - -strcpy.$(SUF): $(SRC_DIR)/strcpy.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strcpy.c - -strindex.$(SUF): $(SRC_DIR)/strindex.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strindex.c - -strlen.$(SUF): $(SRC_DIR)/strlen.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strlen.c - -strncat.$(SUF): $(SRC_DIR)/strncat.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strncat.c - -strncmp.$(SUF): $(SRC_DIR)/strncmp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strncmp.c - -strncpy.$(SUF): $(SRC_DIR)/strncpy.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strncpy.c - -strrindex.$(SUF): $(SRC_DIR)/strrindex.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strrindex.c - -strzero.$(SUF): $(SRC_DIR)/strzero.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strzero.c diff --git a/modules/src/system/.distr b/modules/src/system/.distr deleted file mode 100644 index 2bfeb1de9..000000000 --- a/modules/src/system/.distr +++ /dev/null @@ -1,21 +0,0 @@ -pmfile -access.c -break.c -chmode.c -close.c -create.c -filesize.c -lock.c -modtime.c -open.c -read.c -remove.c -rename.c -stop.c -system.3 -system.c -system.h -time.c -unlock.c -write.c -seek.c diff --git a/modules/src/system/build.lua b/modules/src/system/build.lua new file mode 100644 index 000000000..47587e122 --- /dev/null +++ b/modules/src/system/build.lua @@ -0,0 +1,8 @@ +clibrary { + name = "lib", + srcs = { "./*.c" }, + hdrs = { "./system.h" }, + deps = { "modules+headers" }, +} + + diff --git a/modules/src/system/pmfile b/modules/src/system/pmfile deleted file mode 100644 index c58cfcd70..000000000 --- a/modules/src/system/pmfile +++ /dev/null @@ -1,42 +0,0 @@ --- $Source$ --- $State$ - -local d = "modules/src/system/" -lib_system = file (LIBDIR.."libsystem.a") - -module_system = clibrary { - cfile (d.."access.c"), - cfile (d.."break.c"), - cfile (d.."chmode.c"), - cfile (d.."close.c"), - cfile (d.."create.c"), - cfile (d.."filesize.c"), - cfile (d.."modtime.c"), --- cfile (d.."lock.c"), - cfile (d.."open.c"), - cfile (d.."read.c"), - cfile (d.."remove.c"), - cfile (d.."stop.c"), - cfile (d.."system.c"), - cfile (d.."time.c"), --- cfile (d.."unlock.c"), - cfile (d.."write.c"), - cfile (d.."seek.c"), - cfile (d.."rename.c"), - - outputs = {"%U%/libsystem.a"}, - install = { - pm.install(LIBDIR.."libsystem.a"), - pm.install(d.."system.h", HEADERDIR.."system.h") - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-26 12:40:59 dtrg --- Changed to no longer build sys_lock() and sys_unlock(); they only work --- on platforms that support hardlinks, and nobody uses them anyway. --- --- Revision 1.1 2006/07/20 23:18:19 dtrg --- First version in CVS. --- diff --git a/modules/src/system/proto.make b/modules/src/system/proto.make deleted file mode 100644 index 50d21ccfc..000000000 --- a/modules/src/system/proto.make +++ /dev/null @@ -1,109 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/modules/src/system -MOD_DIR = $(TARGET_HOME)/modules - -LIBSYS = libsystem.$(LIBSUF) -OBJ = access.$(SUF) break.$(SUF) chmode.$(SUF) close.$(SUF) create.$(SUF) \ - filesize.$(SUF) modtime.$(SUF) lock.$(SUF) open.$(SUF) read.$(SUF) \ - remove.$(SUF) stop.$(SUF) system.$(SUF) time.$(SUF) unlock.$(SUF) \ - write.$(SUF) seek.$(SUF) rename.$(SUF) -CSRC = $(SRC_DIR)/access.c $(SRC_DIR)/break.c $(SRC_DIR)/chmode.c \ - $(SRC_DIR)/close.c $(SRC_DIR)/create.c $(SRC_DIR)/filesize.c \ - $(SRC_DIR)/modtime.c $(SRC_DIR)/lock.c $(SRC_DIR)/open.c \ - $(SRC_DIR)/read.c $(SRC_DIR)/remove.c $(SRC_DIR)/stop.c \ - $(SRC_DIR)/system.c $(SRC_DIR)/time.c $(SRC_DIR)/unlock.c \ - $(SRC_DIR)/write.c $(SRC_DIR)/seek.c $(SRC_DIR)/rename.c -SRC = $(SRC_DIR)/proto.make $(SRC_DIR)/system.h $(CSRC) - -INCLUDES = -I$(SRC_DIR) -I$(MOD_DIR)/h -CFLAGS = $(COPTIONS) $(INCLUDES) - -all: $(LIBSYS) - -$(LIBSYS): $(OBJ) - rm -f $(LIBSYS) - $(AR) r $(LIBSYS) $(OBJ) - $(RANLIB) $(LIBSYS) - -install: all - -mkdir $(MOD_DIR)/lib - -mkdir $(MOD_DIR)/h - cp $(LIBSYS) $(MOD_DIR)/lib/$(LIBSYS) - $(RANLIB) $(MOD_DIR)/lib/$(LIBSYS) - cp $(SRC_DIR)/system.h $(MOD_DIR)/h/system.h - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/system.3 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp $(LIBSYS) $(MOD_DIR)/lib/$(LIBSYS) - -cmp $(SRC_DIR)/system.h $(MOD_DIR)/h/system.h - -clean: - rm -f *.$(SUF) *.$(LIBSUF) - -pr: - @pr $(SRC) - -opr: - make pr | opr - -lintlib: - $(MK_LINT_LIB) system $(MOD_DIR)/lib $(INCLUDES) $(CSRC) - -access.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/access.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/access.c - -break.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/break.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/break.c - -chmode.$(SUF): $(SRC_DIR)/chmode.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/chmode.c - -close.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/close.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/close.c - -create.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/create.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/create.c - -filesize.$(SUF): $(SRC_DIR)/filesize.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/filesize.c - -lock.$(SUF): $(SRC_DIR)/lock.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lock.c - -modtime.$(SUF): $(SRC_DIR)/modtime.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/modtime.c - -open.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/open.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/open.c - -read.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/read.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/read.c - -remove.$(SUF): $(SRC_DIR)/remove.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/remove.c - -rename.$(SUF): $(SRC_DIR)/rename.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rename.c - -seek.$(SUF): $(SRC_DIR)/seek.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/seek.c - -stop.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/stop.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/stop.c - -system.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/system.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/system.c - -time.$(SUF): $(SRC_DIR)/time.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/time.c - -unlock.$(SUF): $(SRC_DIR)/unlock.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/unlock.c - -write.$(SUF): $(SRC_DIR)/system.h $(SRC_DIR)/write.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/write.c diff --git a/plat/build.lua b/plat/build.lua new file mode 100644 index 000000000..dc0e87c5e --- /dev/null +++ b/plat/build.lua @@ -0,0 +1,100 @@ +include("mach/proto/as/build.lua") +include("mach/proto/ncg/build.lua") +include("mach/proto/top/build.lua") + +definerule("ackfile", + { + srcs = { type="targets" }, + deps = { type="targets", default={} }, + }, + function (e) + local plat = e.vars.plat + + return cfile { + name = e.name, + srcs = e.srcs, + deps = { + "lang/cem/cemcom.ansi+pkg", + "lang/cem/cpp.ansi+pkg", + "lang/m2/comp+pkg", + "lang/pc/comp+pkg", + "plat/"..plat.."+tools", + "util/ack+pkg", + "util/ego+pkg", + "util/misc+pkg", + e.deps + }, + commands = { + "ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} -c -o %{outs} %{ins} %{hdrpaths} %{ackcflags}" + } + } + end +) + +definerule("acklibrary", + { + srcs = { type="targets", default={} }, + hdrs = { type="targets", default={} }, + deps = { type="targets", default={} }, + }, + function (e) + return clibrary { + name = e.name, + srcs = e.srcs, + hdrs = e.hdrs, + deps = { + "util/arch+pkg", + e.deps + }, + _cfile = ackfile, + commands = { + "rm -f %{outs[1]}", + "ACKDIR=$(INSDIR) $(INSDIR)/bin/aal qc %{outs[1]} %{ins}" + } + } + end +) + +definerule("ackprogram", + { + srcs = { type="targets", default={} }, + deps = { type="targets", default={} }, + }, + function (e) + return cprogram { + name = e.name, + srcs = e.srcs, + deps = { + "plat/"..e.vars.plat.."+pkg", + "util/ack+pkg", + "util/led+pkg", + e.deps + }, + _clibrary = acklibrary, + commands = { + "ACKDIR=$(INSDIR) $(INSDIR)/bin/ack -m%{plat} -.%{lang} -o %{outs} %{ins}" + } + } + end +) + +definerule("build_plat_libs", + { + arch = { type="string" }, + plat = { type="string" }, + }, + function(e) + return installable { + name = e.name, + map = { + "lang/basic/lib+pkg_"..e.plat, + "lang/cem/libcc.ansi+pkg_"..e.plat, + "lang/m2/libm2+pkg_"..e.plat, + "lang/pc/libpc+pkg_"..e.plat, + ["$(PLATIND)/"..e.plat.."/libem.a"] = "mach/"..e.arch.."/libem+lib_"..e.plat, + ["$(PLATIND)/"..e.plat.."/libend.a"] = "mach/"..e.arch.."/libend+lib_"..e.plat, + } + } + end +) + diff --git a/plat/cpm/.distr b/plat/cpm/.distr deleted file mode 100644 index 04a32eaa3..000000000 --- a/plat/cpm/.distr +++ /dev/null @@ -1,25 +0,0 @@ -descr -boot.s -pmfile -README -include/ack/config.h -include/unistd.h -include/cpm.h -libsys/pmfile -libsys/_bdos.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/_hol0.s -libsys/_inn2.s -libsys/isatty.c -libsys/kill.c -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/signal.c -libsys/time.c -libsys/_trap.s -libsys/write.c diff --git a/plat/cpm/boot.s b/plat/cpm/boot.s index b36d1ce02..960dc400d 100644 --- a/plat/cpm/boot.s +++ b/plat/cpm/boot.s @@ -15,12 +15,21 @@ MAX_ARGV = 8 .sect .bss STACKSIZE = 2*1024 .comm stack, STACKSIZE -.comm oldstack, 2 .sect .text begtext: - ! The absolute first thing we have to do is to clear the bss. (argify - ! requires it.) + ! Check if bss would overlap BDOS. We must not overwrite + ! BDOS and crash CP/M. We cheat by comparing only high bytes + ! of each address. + + lxi b, __end + lda 0x0007 + mov c, a ! c = high byte of BDOS address + mov a, b ! a = high byte of _end + cmp c + jnc __exit ! emergency exit if a >= c + + ! We have to clear the bss. (argify requires it.) lxi h, begbss lxi b, endbss @@ -36,8 +45,8 @@ begtext: jnz 1b ! Set up the stack (now it's been cleared, since it's in the BSS). - - lxi sp, oldstack + STACKSIZE + + lxi sp, stack + STACKSIZE ! C-ify the command line at 0x0080. @@ -54,43 +63,38 @@ begtext: ! Now argify it. lxi b, 0x0081 ! bc = command line pointer - lxi d, argv ! de = argv pointer - - ldax b ! peek for any leading whitespace - ora a - cpi ' ' - jz 3f - -1: xchg ! write out the next argument - mov m, c - inx h - mov m, b - inx h - xchg + lxi h, argv ! hl = argv pointer - lda argc ! exit if this was the last argument +loop_of_argify: + ldax b ! a = next character + ora a ! check for end of string + jz end_of_argify + cpi ' ' ! scan for non-space + jz 2f + + mov m, c ! put next argument in argv + inx h + mov m, b + inx h + + lda argc ! increment argc inr a sta argc - cpi MAX_ARGV - jz end_of_argify - -2: inx b ! scan for whitespace - ldax b - ora a - jz end_of_argify - cpi ' ' - jnz 2b - - xra a ! replace the space with a \0 - stax b - -3: inx b ! scan for non-whitespace - ldax b - ora a - jz end_of_argify - cpi ' ' - jz 3b - jmp 1b + cpi MAX_ARGV ! exit loop if argv is full + jz end_of_argify + +1: inx b ! scan for space + ldax b + ora a + jz end_of_argify + cpi ' ' + jnz 1b + + xra a ! replace the space with a '\0' + stax b + +2: inx b + jmp loop_of_argify end_of_argify: ! Add the fake parameter for the program name. @@ -110,8 +114,8 @@ end_of_argify: mvi h, 0 push h call __m_a_i_n - jmp EXIT - + ! FALLTHROUGH + ! Emergency exit routine. .define EXIT, __exit diff --git a/plat/cpm/build-pkg.lua b/plat/cpm/build-pkg.lua new file mode 100644 index 000000000..0a4da3be0 --- /dev/null +++ b/plat/cpm/build-pkg.lua @@ -0,0 +1,26 @@ +include("plat/build.lua") +include("lang/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "cpm" } +} + +build_plat_libs { + name = "libs", + arch = "i80", + plat = "cpm", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/cpm/boot.o"] = "+boot", + ["$(PLATIND)/cpm/libsys.a"] = "./libsys+lib", + } +} + diff --git a/plat/cpm/build-tools.lua b/plat/cpm/build-tools.lua new file mode 100644 index 000000000..383cf8c17 --- /dev/null +++ b/plat/cpm/build-tools.lua @@ -0,0 +1,27 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "i80", +} + +build_ncg { + name = "ncg", + arch = "i80", +} + +build_top { + name = "top", + arch = "i80", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/cpm/as"] = "+as", + ["$(PLATDEP)/cpm/ncg"] = "+ncg", + ["$(PLATDEP)/cpm/top"] = "+top", + ["$(PLATIND)/descr/cpm"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/cpm/descr b/plat/cpm/descr index da320fe39..2d626295a 100644 --- a/plat/cpm/descr +++ b/plat/cpm/descr @@ -3,14 +3,22 @@ # $Revision$ var w=2 +var wa=1 var p=2 +var pa=1 var s=2 +var sa=1 var l=4 +var la=1 var f=4 +var fa=1 var d=8 +var da=1 +var x=8 +var xa=1 var ARCH=i80 var PLATFORM=cpm -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 -b0:0x0100 var MACHOPT_F=-m8 @@ -18,12 +26,12 @@ var MACHOPT_F=-m8 # Override the setting in fe so that files compiled for linux386 can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{EM}/share/ack/{PLATFORM}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg args < stdout need .e @@ -31,7 +39,7 @@ end name asopt from .s to .so - program {EM}/lib.bin/{PLATFORM}/top + program {EM}/lib/ack/{PLATFORM}/top args optimizer stdin @@ -40,14 +48,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -i SEPID=-b1:0 mapflag -fp FLOATS={EM}/{ILIB}fp diff --git a/plat/cpm/include/build.lua b/plat/cpm/include/build.lua new file mode 100644 index 000000000..b6f713684 --- /dev/null +++ b/plat/cpm/include/build.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/cpm/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("cpm.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + + diff --git a/plat/cpm/libsys/build.lua b/plat/cpm/libsys/build.lua new file mode 100644 index 000000000..c2a75a4c3 --- /dev/null +++ b/plat/cpm/libsys/build.lua @@ -0,0 +1,15 @@ +acklibrary { + name = "lib", + srcs = { + "./*.c", + "./*.s", + }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/cpm/include+headers", + }, + vars = { + plat = "cpm" + } +} + diff --git a/plat/cpm/libsys/pmfile b/plat/cpm/libsys/pmfile deleted file mode 100644 index cb564e9c3..000000000 --- a/plat/cpm/libsys/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/cpm/libsys/" - -libsys_cpm = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."errno.s"), - ackfile (d.."_hol0.s"), - ackfile (d.."_bdos.s"), - ackfile (d.."_trap.s"), - ackfile (d.."_inn2.s"), - ackfile (d.."open.c"), - ackfile (d.."creat.c"), - ackfile (d.."close.c"), - ackfile (d.."read.c"), - ackfile (d.."write.c"), - ackfile (d.."brk.c"), - ackfile (d.."getpid.c"), - ackfile (d.."kill.c"), - ackfile (d.."isatty.c"), - ackfile (d.."lseek.c"), - ackfile (d.."time.c"), - ackfile (d.."signal.c"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/cpm/pmfile b/plat/cpm/pmfile deleted file mode 100644 index 43320f1c2..000000000 --- a/plat/cpm/pmfile +++ /dev/null @@ -1,47 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/cpm/" - -include (d.."libsys/pmfile") - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/cpm/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - pm.install(d.."include/cpm.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/cpm.h"), - } -} - -platform_cpm = group { - ARCH = "i80", - PLATFORM = "cpm", - OPTIMISATION = "-O", - - -- Ensure the descr and headers are installed first because we'll need - -- them to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_i80, - support_i80, - lang_runtimes, - - -- Build the CP/M syscall library. - - libsys_cpm, - bootsector, -} diff --git a/plat/linux/liblinux/pmfile b/plat/linux/liblinux/pmfile deleted file mode 100644 index a5d008dc5..000000000 --- a/plat/linux/liblinux/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."plat/linux/liblinux/" - -liblinux = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."errno.s"), - ackfile (d.."_hol0.s"), - - ackfile (d.."brk.c"), - ackfile (d.."close.c"), - ackfile (d.."creat.c"), - ackfile (d.."getpid.c"), - ackfile (d.."gettimeofday.c"), - ackfile (d.."_exit.c"), - ackfile (d.."isatty.c"), - ackfile (d.."kill.c"), - ackfile (d.."lseek.c"), - ackfile (d.."open.c"), - ackfile (d.."read.c"), - ackfile (d.."sbrk.c"), - ackfile (d.."signal.c"), - ackfile (d.."write.c"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/liblinux.a"), -} diff --git a/plat/linux/liblinux/_exit.c b/plat/linux/libsys/_exit.c similarity index 100% rename from plat/linux/liblinux/_exit.c rename to plat/linux/libsys/_exit.c diff --git a/plat/linux/liblinux/_hol0.s b/plat/linux/libsys/_hol0.s similarity index 100% rename from plat/linux/liblinux/_hol0.s rename to plat/linux/libsys/_hol0.s diff --git a/plat/linux/liblinux/brk.c b/plat/linux/libsys/brk.c similarity index 63% rename from plat/linux/liblinux/brk.c rename to plat/linux/libsys/brk.c index 8bb53d31d..7ce5c5fc8 100644 --- a/plat/linux/liblinux/brk.c +++ b/plat/linux/libsys/brk.c @@ -5,9 +5,13 @@ #include #include +#include #include "libsys.h" int brk(void* end) { - return _syscall(__NR_brk, (quad) end, 0, 0); + int e = _syscall(__NR_brk, (quad) end, 0, 0); + if (e == -1) + errno = ENOMEM; + return e; } diff --git a/plat/linux/liblinux/close.c b/plat/linux/libsys/close.c similarity index 100% rename from plat/linux/liblinux/close.c rename to plat/linux/libsys/close.c diff --git a/plat/linux/liblinux/creat.c b/plat/linux/libsys/creat.c similarity index 100% rename from plat/linux/liblinux/creat.c rename to plat/linux/libsys/creat.c diff --git a/plat/linux/liblinux/errno.s b/plat/linux/libsys/errno.s similarity index 100% rename from plat/linux/liblinux/errno.s rename to plat/linux/libsys/errno.s diff --git a/plat/linux/liblinux/getpid.c b/plat/linux/libsys/getpid.c similarity index 100% rename from plat/linux/liblinux/getpid.c rename to plat/linux/libsys/getpid.c diff --git a/plat/linux/liblinux/gettimeofday.c b/plat/linux/libsys/gettimeofday.c similarity index 100% rename from plat/linux/liblinux/gettimeofday.c rename to plat/linux/libsys/gettimeofday.c diff --git a/plat/linux/liblinux/isatty.c b/plat/linux/libsys/isatty.c similarity index 100% rename from plat/linux/liblinux/isatty.c rename to plat/linux/libsys/isatty.c diff --git a/plat/linux/liblinux/kill.c b/plat/linux/libsys/kill.c similarity index 100% rename from plat/linux/liblinux/kill.c rename to plat/linux/libsys/kill.c diff --git a/plat/linux/liblinux/libsys.h b/plat/linux/libsys/libsys.h similarity index 100% rename from plat/linux/liblinux/libsys.h rename to plat/linux/libsys/libsys.h diff --git a/plat/linux/liblinux/lseek.c b/plat/linux/libsys/lseek.c similarity index 100% rename from plat/linux/liblinux/lseek.c rename to plat/linux/libsys/lseek.c diff --git a/plat/linux/liblinux/open.c b/plat/linux/libsys/open.c similarity index 100% rename from plat/linux/liblinux/open.c rename to plat/linux/libsys/open.c diff --git a/plat/linux/liblinux/read.c b/plat/linux/libsys/read.c similarity index 100% rename from plat/linux/liblinux/read.c rename to plat/linux/libsys/read.c diff --git a/plat/linux/liblinux/sbrk.c b/plat/linux/libsys/sbrk.c similarity index 53% rename from plat/linux/liblinux/sbrk.c rename to plat/linux/libsys/sbrk.c index 17b273f42..35810ef89 100644 --- a/plat/linux/liblinux/sbrk.c +++ b/plat/linux/libsys/sbrk.c @@ -1,32 +1,39 @@ -/* $Source: /cvsroot/tack/Ack/plat/linux386/libsys/sbrk.c,v $ - * $State: Exp $ - * $Revision: 1.1 $ +/* $Source$ + * $State$ + * $Revision$ */ #include -#include #include +#include #include "libsys.h" #define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ -extern char _end[1]; - -static char* current = _end; +static char* current = NULL; void* sbrk(intptr_t increment) { char* old; char* new; + char* actual; + + if (!current) + current = (char*) _syscall(__NR_brk, 0, 0, 0); if (increment == 0) return current; old = current; new = old + increment; - if (brk(new) < 0) + + actual = (char*) _syscall(__NR_brk, (quad) new, 0, 0); + if (actual < new) + { + errno = ENOMEM; return OUT_OF_MEMORY; + } - current = new; + current = actual; return old; } diff --git a/plat/linux/liblinux/signal.c b/plat/linux/libsys/signal.c similarity index 100% rename from plat/linux/liblinux/signal.c rename to plat/linux/libsys/signal.c diff --git a/plat/linux/liblinux/syscalls.h b/plat/linux/libsys/syscalls.h similarity index 100% rename from plat/linux/liblinux/syscalls.h rename to plat/linux/libsys/syscalls.h diff --git a/plat/linux/libsys/unlink.c b/plat/linux/libsys/unlink.c new file mode 100644 index 000000000..29eaad108 --- /dev/null +++ b/plat/linux/libsys/unlink.c @@ -0,0 +1,8 @@ +#include +#include "libsys.h" + +int unlink(const char* pathname) +{ + return _syscall(__NR_unlink, (quad) pathname, 0, 0); +} + diff --git a/plat/linux/liblinux/write.c b/plat/linux/libsys/write.c similarity index 100% rename from plat/linux/liblinux/write.c rename to plat/linux/libsys/write.c diff --git a/plat/linux386/.distr b/plat/linux386/.distr deleted file mode 100644 index da4420e2f..000000000 --- a/plat/linux386/.distr +++ /dev/null @@ -1,26 +0,0 @@ -descr -boot.s -pmfile -README -include/ack/config.h -include/unistd.h -libsys/pmfile -libsys/_exit.c -libsys/_hol0.s -libsys/_syscall.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/gettimeofday.c -libsys/isatty.c -libsys/kill.c -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/sbrk.c -libsys/signal.c -libsys/syscalls.h -libsys/write.c diff --git a/plat/linux386/build-pkg.lua b/plat/linux386/build-pkg.lua new file mode 100644 index 000000000..14251ee8a --- /dev/null +++ b/plat/linux386/build-pkg.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "linux386" } +} + +build_plat_libs { + name = "libs", + arch = "i386", + plat = "linux386", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/linux386/boot.o"] = "+boot", + ["$(PLATIND)/linux386/libsys.a"] = "./libsys+lib", + } +} + diff --git a/plat/linux386/build-tools.lua b/plat/linux386/build-tools.lua new file mode 100644 index 000000000..d711f85fd --- /dev/null +++ b/plat/linux386/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "i386", +} + +build_ncg { + name = "ncg", + arch = "i386", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/linux386/as"] = "+as", + ["$(PLATDEP)/linux386/ncg"] = "+ncg", + ["$(PLATIND)/descr/linux386"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/linux386/descr b/plat/linux386/descr index 9121df924..611e96e44 100644 --- a/plat/linux386/descr +++ b/plat/linux386/descr @@ -3,14 +3,22 @@ # $Revision$ var w=4 -var p=4 +var wa=4 +var p={w} +var pa={w} var s=2 -var l=4 -var f=4 +var sa={s} +var l={w} +var la={w} +var f={w} +var fa={w} var d=8 +var da={d} +var x=8 +var xa={x} var ARCH=i386 var PLATFORM=linux386 -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08048054 var C_LIB={PLATFORMDIR}/libc-ansi.a @@ -18,16 +26,17 @@ var C_LIB={PLATFORMDIR}/libc-ansi.a var CC_ALIGN=-Vr var OLD_C_LIB={C_LIB} var MACHOPT_F=-m10 +var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr # Override the setting in fe so that files compiled for linux386 can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,14 +45,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -fp FLOATS={EM}/{LIB}fp args {ALIGN} {SEPID?} \ @@ -59,9 +68,7 @@ name led (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \ (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ {FLOATS?} \ - (.e:{TAIL}={PLATFORMDIR}/liblinux.a \ - {PLATFORMDIR}/libem.a \ - {PLATFORMDIR}/liblinux.a \ + (.e:{TAIL}={PLATFORMDIR}/libem.a \ {PLATFORMDIR}/libsys.a \ {PLATFORMDIR}/libend.a) linker diff --git a/plat/linux386/include/build.lua b/plat/linux386/include/build.lua new file mode 100644 index 000000000..ce1f2adc6 --- /dev/null +++ b/plat/linux386/include/build.lua @@ -0,0 +1,24 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/linux386/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("sys/ioctl.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + diff --git a/plat/linux386/libsys/build.lua b/plat/linux386/libsys/build.lua new file mode 100644 index 000000000..a4d2d7447 --- /dev/null +++ b/plat/linux386/libsys/build.lua @@ -0,0 +1,16 @@ +acklibrary { + name = "lib", + srcs = { + "./*.s", + "plat/linux/libsys/*.c", + "plat/linux/libsys/*.s", + }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/linux386/include+headers", + }, + vars = { + plat = "linux386" + } +} + diff --git a/plat/linux386/libsys/pmfile b/plat/linux386/libsys/pmfile deleted file mode 100644 index d7d4930c5..000000000 --- a/plat/linux386/libsys/pmfile +++ /dev/null @@ -1,13 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."plat/linux386/libsys/" - -libsys_linux386 = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."_syscall.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/linux386/pmfile b/plat/linux386/pmfile deleted file mode 100644 index b7ce18123..000000000 --- a/plat/linux386/pmfile +++ /dev/null @@ -1,48 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/linux386/" - -include (d.."libsys/pmfile") -include "plat/linux/liblinux/pmfile" - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/linux386/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - } -} - -platform_linux386 = group { - ARCH = "i386", - PLATFORM = "linux386", - OPTIMISATION = "-O", - - -- Ensure the descr and headers are installed first because we'll need it - -- to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_i386, - support_i386, - lang_runtimes, - - -- Build the PC standalone syscall library. - - liblinux, - libsys_linux386, - bootsector, -} diff --git a/plat/linux68k/.distr b/plat/linux68k/.distr deleted file mode 100644 index da4420e2f..000000000 --- a/plat/linux68k/.distr +++ /dev/null @@ -1,26 +0,0 @@ -descr -boot.s -pmfile -README -include/ack/config.h -include/unistd.h -libsys/pmfile -libsys/_exit.c -libsys/_hol0.s -libsys/_syscall.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/gettimeofday.c -libsys/isatty.c -libsys/kill.c -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/sbrk.c -libsys/signal.c -libsys/syscalls.h -libsys/write.c diff --git a/plat/linux68k/build-pkg.lua b/plat/linux68k/build-pkg.lua new file mode 100644 index 000000000..34925f15c --- /dev/null +++ b/plat/linux68k/build-pkg.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "linux68k" } +} + +build_plat_libs { + name = "libs", + arch = "m68020", + plat = "linux68k", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/linux68k/boot.o"] = "+boot", + ["$(PLATIND)/linux68k/libsys.a"] = "./libsys+lib", + } +} + diff --git a/plat/linux68k/build-tools.lua b/plat/linux68k/build-tools.lua new file mode 100644 index 000000000..944e57f47 --- /dev/null +++ b/plat/linux68k/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "m68020", +} + +build_ncg { + name = "ncg", + arch = "m68020", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/linux68k/as"] = "+as", + ["$(PLATDEP)/linux68k/ncg"] = "+ncg", + ["$(PLATIND)/descr/linux68k"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/linux68k/descr b/plat/linux68k/descr index 43cdb95de..9347ad2b2 100644 --- a/plat/linux68k/descr +++ b/plat/linux68k/descr @@ -3,14 +3,22 @@ # $Revision: 1.1 $ var w=4 -var p=4 +var wa=4 +var p={w} +var pa={w} var s=2 -var l=4 -var f=4 +var sa={s} +var l={w} +var la={w} +var f={w} +var fa={w} var d=8 +var da={d} +var x=8 +var xa={x} var ARCH=m68020 var PLATFORM=linux68k -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix -D__mc68020 -D__m68k -D__mc68000 -D__M68020 var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x08000054 var C_LIB={PLATFORMDIR}/libc-ansi.a @@ -18,16 +26,17 @@ var C_LIB={PLATFORMDIR}/libc-ansi.a var CC_ALIGN=-Vr var OLD_C_LIB={C_LIB} var MACHOPT_F=-ml10 +var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr # Override the setting in fe so that files compiled for linux68k can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,14 +45,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -fp FLOATS={EM}/{LIB}fp args {ALIGN} {SEPID?} \ @@ -60,7 +69,6 @@ name led (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ {FLOATS?} \ (.e:{TAIL}={PLATFORMDIR}/libem.a \ - {PLATFORMDIR}/liblinux.a \ {PLATFORMDIR}/libsys.a \ {PLATFORMDIR}/libend.a) linker diff --git a/plat/linux68k/include/build.lua b/plat/linux68k/include/build.lua new file mode 100644 index 000000000..291fa0c36 --- /dev/null +++ b/plat/linux68k/include/build.lua @@ -0,0 +1,24 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/linux68k/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("sys/ioctl.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + diff --git a/plat/linux68k/libsys/build.lua b/plat/linux68k/libsys/build.lua new file mode 100644 index 000000000..ded71cdd1 --- /dev/null +++ b/plat/linux68k/libsys/build.lua @@ -0,0 +1,16 @@ +acklibrary { + name = "lib", + srcs = { + "./*.s", + "plat/linux/libsys/*.c", + "plat/linux/libsys/*.s", + }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/linux68k/include+headers", + }, + vars = { + plat = "linux68k" + } +} + diff --git a/plat/linux68k/libsys/pmfile b/plat/linux68k/libsys/pmfile deleted file mode 100644 index 2bcf6b939..000000000 --- a/plat/linux68k/libsys/pmfile +++ /dev/null @@ -1,13 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."plat/linux68k/libsys/" - -libsys_linux68k = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."_syscall.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/linux68k/pmfile b/plat/linux68k/pmfile deleted file mode 100644 index f28fd1cb8..000000000 --- a/plat/linux68k/pmfile +++ /dev/null @@ -1,48 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $ --- $State: Exp $ --- $Revision: 1.3 $ - -local d = ROOTDIR.."plat/linux68k/" - -include (d.."libsys/pmfile") -include "plat/linux/liblinux/pmfile" - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - } -} - -platform_linux68k = group { - ARCH = "m68020", - PLATFORM = "linux68k", - OPTIMISATION = "-O6", - - -- Ensure the descr and headers are installed first because we'll need it - -- to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_m68020, - support_m68020, - lang_runtimes, - - -- Build the PC standalone syscall library. - - liblinux, - libsys_linux68k, - bootsector, -} diff --git a/plat/linuxppc/.distr b/plat/linuxppc/.distr deleted file mode 100644 index da4420e2f..000000000 --- a/plat/linuxppc/.distr +++ /dev/null @@ -1,26 +0,0 @@ -descr -boot.s -pmfile -README -include/ack/config.h -include/unistd.h -libsys/pmfile -libsys/_exit.c -libsys/_hol0.s -libsys/_syscall.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/gettimeofday.c -libsys/isatty.c -libsys/kill.c -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/sbrk.c -libsys/signal.c -libsys/syscalls.h -libsys/write.c diff --git a/plat/linuxppc/descr b/plat/linuxppc/descr index 06005f660..69b00fbc5 100644 --- a/plat/linuxppc/descr +++ b/plat/linuxppc/descr @@ -3,14 +3,22 @@ # $Revision: 1.1 $ var w=4 -var p=4 +var wa=4 +var p={w} +var pa={w} var s=2 -var l=4 -var f=4 +var sa={s} +var l={w} +var la={w} +var f={w} +var fa={w} var d=8 +var da={d} +var x=8 +var xa={x} var ARCH=powerpc var PLATFORM=linuxppc -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix -D__POWERPC var ALIGN=-a0:4 -a1:4 -a2:4 -a3:4 -b0:0x80000054 var C_LIB={PLATFORMDIR}/libc-ansi.a @@ -22,12 +30,12 @@ var MACHOPT_F= # Override the setting in fe so that files compiled for linuxppc can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{ARCH}/ncg mapflag -gdb GF=-gdb args {GF?} < stdout @@ -36,7 +44,7 @@ end name asopt from .s to .so - program {EM}/lib.bin/{PLATFORM}/top + program {EM}/lib/ack/{ARCH}/top args optimizer stdin @@ -45,14 +53,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{ARCH}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -fp FLOATS={EM}/{LIB}fp args {ALIGN} {SEPID?} \ diff --git a/plat/linuxppc/libsys/pmfile b/plat/linuxppc/libsys/pmfile deleted file mode 100644 index 0b3839aae..000000000 --- a/plat/linuxppc/libsys/pmfile +++ /dev/null @@ -1,14 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/libsys/pmfile,v $ --- $State: Exp $ --- $Revision: 1.1 $ - -local d = ROOTDIR.."plat/linuxppc/libsys/" - -libsys_linuxppc = acklibrary { - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."_syscall.s"), - ackfile (d.."trap.s"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/linuxppc/pmfile b/plat/linuxppc/pmfile deleted file mode 100644 index 34acd7002..000000000 --- a/plat/linuxppc/pmfile +++ /dev/null @@ -1,48 +0,0 @@ --- $Source: /cvsroot/tack/Ack/plat/linux386/pmfile,v $ --- $State: Exp $ --- $Revision: 1.3 $ - -local d = ROOTDIR.."plat/linuxppc/" - -include (d.."libsys/pmfile") -include "plat/linux/liblinux/pmfile" - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/%PLATFORM%/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - } -} - -platform_linuxppc = group { - ARCH = "powerpc", - PLATFORM = "linuxppc", - OPTIMISATION = "-O", - - -- Ensure the descr and headers are installed first because we'll need it - -- to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_powerpc, - support_powerpc, - lang_runtimes, - - -- Build the PC standalone syscall library. - - liblinux, - libsys_linuxppc, - bootsector, -} diff --git a/plat/pc86/.distr b/plat/pc86/.distr deleted file mode 100644 index 9bcdd612a..000000000 --- a/plat/pc86/.distr +++ /dev/null @@ -1,24 +0,0 @@ -descr -boot.s -pmfile -README -include/ack/config.h -include/unistd.h -libsys/pmfile -libsys/_hol0.s -libsys/brk.c -libsys/close.c -libsys/creat.c -libsys/errno.s -libsys/getpid.c -libsys/isatty.c -libsys/kill.c -libsys/libsys.h -libsys/lseek.c -libsys/open.c -libsys/read.c -libsys/signal.c -libsys/time.c -libsys/write.c -libsys/_sys_rawread.s -libsys/_sys_rawwrite.s diff --git a/plat/pc86/build-pkg.lua b/plat/pc86/build-pkg.lua new file mode 100644 index 000000000..b4ff7b767 --- /dev/null +++ b/plat/pc86/build-pkg.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "pc86" } +} + +build_plat_libs { + name = "libs", + arch = "i86", + plat = "pc86", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/pc86/boot.o"] = "+boot", + ["$(PLATIND)/pc86/libsys.a"] = "./libsys+lib", + } +} + diff --git a/plat/pc86/build-tools.lua b/plat/pc86/build-tools.lua new file mode 100644 index 000000000..fbb34bd3a --- /dev/null +++ b/plat/pc86/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "i86", +} + +build_ncg { + name = "ncg", + arch = "i86", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/pc86/as"] = "+as", + ["$(PLATDEP)/pc86/ncg"] = "+ncg", + ["$(PLATIND)/descr/pc86"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/pc86/descr b/plat/pc86/descr index 65b63a1f8..d8cb006e6 100644 --- a/plat/pc86/descr +++ b/plat/pc86/descr @@ -3,27 +3,36 @@ # $Revision$ var w=2 +var wa=1 var p=2 +var pa=1 var s=2 +var sa=1 var l=4 +var la=1 var f=4 +var fa=1 var d=8 +var da=1 +var x=8 +var xa=1 var ARCH=i86 var PLATFORM=pc86 -var PLATFORMDIR={EM}/lib/{PLATFORM} +var PLATFORMDIR={EM}/share/ack/{PLATFORM} var CPP_F=-D__unix var ALIGN=-a0:1 -a1:1 -a2:1 -a3:1 var MACHOPT_F=-m8 +var EGO_PLAT_FLAGS=-M{EM}/share/ack/ego/{ARCH}.descr -# Override the setting in fe so that files compiled for linux386 can see +# Override the setting in fe so that files compiled for this platform can see # the platform-specific headers. -var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/include/ansi +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi name be from .m.g to .s - program {EM}/lib.bin/{PLATFORM}/ncg + program {EM}/lib/ack/{PLATFORM}/ncg args < stdout need .e @@ -31,14 +40,14 @@ end name as from .s.so to .o - program {EM}/lib.bin/{PLATFORM}/as + program {EM}/lib/ack/{PLATFORM}/as args - -o > < prep cond end name led from .o.a to .out - program {EM}/lib.bin/em_led + program {EM}/lib/ack/em_led mapflag -l* LNAME={PLATFORMDIR}/lib* mapflag -i SEPID=-b1:0 mapflag -fp FLOATS={EM}/{ILIB}fp diff --git a/plat/pc86/include/build.lua b/plat/pc86/include/build.lua new file mode 100644 index 000000000..6ae120358 --- /dev/null +++ b/plat/pc86/include/build.lua @@ -0,0 +1,24 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/pc86/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + + diff --git a/plat/pc86/libsys/build.lua b/plat/pc86/libsys/build.lua new file mode 100644 index 000000000..a30ecae9e --- /dev/null +++ b/plat/pc86/libsys/build.lua @@ -0,0 +1,15 @@ +acklibrary { + name = "lib", + srcs = { + "./*.c", + "./*.s", + }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/pc86/include+headers", + }, + vars = { + plat = "pc86" + } +} + diff --git a/plat/pc86/libsys/pmfile b/plat/pc86/libsys/pmfile deleted file mode 100644 index 99a4ee85b..000000000 --- a/plat/pc86/libsys/pmfile +++ /dev/null @@ -1,29 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/pc86/libsys/" - -libsys_pc86 = acklibrary { - ACKBUILDFLAGS = {PARENT, "-ansi"}, - ACKINCLUDES = {"%BINDIR%include"}, - - ackfile (d.."errno.s"), - ackfile (d.."_hol0.s"), - ackfile (d.."_sys_rawread.s"), - ackfile (d.."_sys_rawwrite.s"), - ackfile (d.."open.c"), - ackfile (d.."creat.c"), - ackfile (d.."close.c"), - ackfile (d.."read.c"), - ackfile (d.."write.c"), - ackfile (d.."brk.c"), - ackfile (d.."getpid.c"), - ackfile (d.."kill.c"), - ackfile (d.."isatty.c"), - ackfile (d.."lseek.c"), - ackfile (d.."time.c"), - ackfile (d.."signal.c"), - - install = pm.install("%BINDIR%lib/%PLATFORM%/libsys.a"), -} diff --git a/plat/pc86/pmfile b/plat/pc86/pmfile deleted file mode 100644 index 0afe6a5b0..000000000 --- a/plat/pc86/pmfile +++ /dev/null @@ -1,46 +0,0 @@ --- $Source$ --- $State$ --- $Revision$ - -local d = ROOTDIR.."plat/pc86/" - -include (d.."libsys/pmfile") - -local bootsector = ackfile { - file (d.."boot.s"), - install = pm.install("%BINDIR%lib/pc86/boot.o"), -} - -local descr = group { - install = pm.install(d.."descr", "%BINDIR%%PLATIND%/%PLATFORM%/descr") -} - -local headers = group { - install = { - pm.install(d.."include/ack/config.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/ack/config.h"), - pm.install(d.."include/unistd.h", "%BINDIR%%PLATIND%/%PLATFORM%/include/unistd.h"), - } -} - -platform_pc86 = group { - ARCH = "i86", - PLATFORM = "pc86", - OPTIMISATION = "-O", - - -- Ensure the descr and headers are installed first because we'll need - -- them to build the libraries. - - descr, - headers, - - -- Build the back-end support. - - mach_i86, - support_i86, - lang_runtimes, - - -- Build the PC standalone syscall library. - - libsys_pc86, - bootsector, -} diff --git a/plat/rpi/README b/plat/rpi/README new file mode 100644 index 000000000..7d78433dd --- /dev/null +++ b/plat/rpi/README @@ -0,0 +1,69 @@ +VideoCore IV support in the ACK +=============================== + +This is a fairly crude port of the ACK to produce VideoCore IV machine +code, suitable for use on the Raspberry Pi. It produces terrible but +working code. The resulting binaries can be used either bare metal or +loaded as a GPU kernel and executed using a modified mailbox.c (see below). +Currently floating point support is present but incomplete; and as the +VideoCore IV does not have double-precision float support, the C compiler +treats doubles as single precision. + +As much of the standard C library as is relevant works; if +you're running in bare-metal mode, you can hook stdin/stdout up to the +mini UART. (Obviously, in kernel mode you can't.) + +Important note! The malloc heap expects your program to be loaded into a +chunk of memory that's 128kB large. You must make sure that this is the case, +or Bad Stuff will happen. + +Output binaries are fully PIC and can be loaded anywhere (this is one of the +things that makes the code so terrible). You must use the pi_user_to_phys() +and pi_phys_to_user() to translate pointers from physical to user and vice +versa. If you don't, Bad Stuff will happen. + + + +Bare metal mode +--------------- + +To run a binary bare metal, compile it: + + ack -mrpi -O program.c -o bootcode.bin + +...and copy the bootcode.bin file to the root of an SD card. Boot the Pi. +Your program will run. + +To use the UART, #include and call pi_init_uart() at the top of your +program. This will set it up and connect it to stdin/stdout. It's 115200 8n1. + + + +Kernel mode +----------- + +This will require some hacking at your end. + +Go here, and follow the instructions. + +https://github.com/hermanhermitage/videocoreiv/wiki/VideoCore-IV-Kernels-under-Linux + +Now compile your program: + + ack -mrpi -O program.c -o alpha.bin + +MAKE SURE YOU AREN'T USING ANY MEMORY ALLOCATION. Copy the alpha.bin onto +the Pi, and run it with mailbox.c. + +To get data in and out, #include and look at the pi_kernel_parameters +variable. It's a structure that is initialised with the data that's passed in +from mailbox.c (currently four pointers and two integers). + +If you want to use malloc() and friends, you'll need to hack mailbox.c so +that the buffer containing the code is at least 128kB, or you're likely to +corrupt the VideoCore's workspace and crash it. + + +David Given +2013-06-06 + diff --git a/plat/rpi/boot.s b/plat/rpi/boot.s new file mode 100644 index 000000000..a76d1e7a7 --- /dev/null +++ b/plat/rpi/boot.s @@ -0,0 +1,120 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +.sect .text + +#define gp r15 +#define STACKSIZE 1*1024 + +! MAIN ENTRY POINT + +begtext: + ! This empty space is required by the boot loader. + +kernel_start: + ! When running as a kernel, we need to preserve all registers. We save + ! them onto the default stack. + push r0-r24 + b baremetal_start + .space 506 ! first 512 bytes are ignored by the boot loader +baremetal_start: + ! Wipe the bss (including the new stack). + + lea r6, begbss + lea r7, endbss + mov r8, #0 +_1: + stb r8, (r6) + addcmpb.lt r6, #1, r7, _1 + + ! Save system registers. + + st fp, .returnfp + st sp, .returnsp + st lr, .returnlr + + lea gp, begtext + lea sp, .stack + STACKSIZE + + ! Save the kernel parameters. + + sub r0, gp ! fix up pointer + sub r1, gp ! fix up pointer + sub r2, gp ! fix up pointer + sub r3, gp ! fix up pointer + push r0-r5 + sub r0, sp, gp + st r0, _pi_kernel_parameters + + ! Push standard parameters onto the stack and go. + + mov r0, #0 + push r0 ! envp + push r0 ! argv + push r0 ! argc + + ! Call the language startup code. + + bl __m_a_i_n + + ! Fall through to __exit if this returns. + +.define __exit +__exit: + ! It only makes sense to get here if we're in kernel mode. If we're in + ! bare-metal mode, we'll just crash, but that's fine. + + st r0, _pi_kernel_parameters ! save return value + mov r0, sr + ld fp, .returnfp + ld sp, .returnsp + ld lr, .returnlr + pop r0-r24 + ld r0, _pi_kernel_parameters ! restore return value + b lr + +! Define symbols at the beginning of our various segments, so that we can find +! them. (Except .text, which has already been done.) + +.define begtext, begdata, begbss +.sect .data; begdata: +.sect .rom; begrom: +.sect .bss; begbss: + +! Some magic data. All EM systems need these. + +.define .trppc, .ignmask, _errno +.comm .trppc, 4 +.comm .ignmask, 4 +.comm _errno, 4 + +! We store the stack pointer and return address on entry so that we can +! cleanly exit. + +.comm .returnfp, 4 +.comm .returnsp, 4 +.comm .returnlr, 4 + +.define _pi_kernel_parameters +.comm _pi_kernel_parameters, 4 + +.define .linenumber, .filename +.comm .linenumber, 4 ! current linenumber (used for debugging) +.comm .filename, 4 ! ptr to current filename (used for debugging) + +! User stack. + +.comm .stack, STACKSIZE + diff --git a/plat/rpi/build-pkg.lua b/plat/rpi/build-pkg.lua new file mode 100644 index 000000000..b6bc4ab56 --- /dev/null +++ b/plat/rpi/build-pkg.lua @@ -0,0 +1,25 @@ +include("plat/build.lua") + +ackfile { + name = "boot", + srcs = { "./boot.s" }, + vars = { plat = "rpi" } +} + +build_plat_libs { + name = "libs", + arch = "vc4", + plat = "rpi", +} + +installable { + name = "pkg", + map = { + "+tools", + "+libs", + "./include+pkg", + ["$(PLATIND)/rpi/boot.o"] = "+boot", + ["$(PLATIND)/rpi/libsys.a"] = "./libsys+lib", + } +} + diff --git a/plat/rpi/build-tools.lua b/plat/rpi/build-tools.lua new file mode 100644 index 000000000..eb3cbfef2 --- /dev/null +++ b/plat/rpi/build-tools.lua @@ -0,0 +1,21 @@ +include("plat/build.lua") + +build_as { + name = "as", + arch = "vc4", +} + +build_ncg { + name = "ncg", + arch = "vc4", +} + +return installable { + name = "tools", + map = { + ["$(PLATDEP)/rpi/as"] = "+as", + ["$(PLATDEP)/rpi/ncg"] = "+ncg", + ["$(PLATIND)/descr/rpi"] = "./descr", + "util/opt+pkg", + } +} diff --git a/plat/rpi/descr b/plat/rpi/descr new file mode 100644 index 000000000..6daff9606 --- /dev/null +++ b/plat/rpi/descr @@ -0,0 +1,77 @@ +# $Source$ +# $State$ +# $Revision$ + +var w=4 +var wa=4 +var p={w} +var pa={w} +var s=2 +var sa={s} +var l={w} +var la={w} +var f={w} +var fa={w} +var d={w} +var da={w} +var x={w} +var xa={w} +var ARCH=vc4 +var PLATFORM=rpi +var PLATFORMDIR={EM}/share/ack/{PLATFORM} +var CPP_F=-D__unix +var ALIGN=-a0:2 -a1:4 -a2:4 -a3:4 +var MACHOPT_F=-m8 + +# Override the setting in fe so that files compiled for this platform can see +# the platform-specific headers. + +var C_INCLUDES=-I{PLATFORMDIR}/include -I{EM}/share/ack/include/ansi + +name be + from .m.g + to .s + program {EM}/lib/ack/{PLATFORM}/ncg + args < + stdout + need .e +end +name as + from .s.so + to .o + program {EM}/lib/ack/{PLATFORM}/as + args - -o > < + prep cond +end +name led + from .o.a + to .out + program {EM}/lib/ack/em_led + mapflag -l* LNAME={PLATFORMDIR}/lib* + mapflag -i SEPID=-b1:0 + mapflag -fp FLOATS={EM}/{ILIB}fp + args {ALIGN} {SEPID?} \ + (.e:{HEAD}={PLATFORMDIR}/boot.o) \ + ({RTS}:.ocm.b={PLATFORMDIR}/c-ansi.o) \ + ({RTS}:.c={PLATFORMDIR}/c-ansi.o) \ + ({RTS}:.mod={PLATFORMDIR}/modula2.o) \ + ({RTS}:.p={PLATFORMDIR}/pascal.o) \ + -o > < \ + (.p:{TAIL}={PLATFORMDIR}/libpascal.a) \ + (.b:{TAIL}={PLATFORMDIR}/libbasic.a) \ + (.mod:{TAIL}={PLATFORMDIR}/libmodula2.a) \ + (.ocm:{TAIL}={PLATFORMDIR}/liboccam.a) \ + (.ocm.b.mod.c.p:{TAIL}={PLATFORMDIR}/libc.a) \ + {FLOATS?} \ + (.e:{TAIL}={PLATFORMDIR}/libem.a \ + {PLATFORMDIR}/libsys.a \ + {PLATFORMDIR}/libend.a) + linker +end +name cv + from .out + to .img + program {EM}/bin/aslod + args < > + outfile raspberrypi.bin +end diff --git a/plat/rpi/include/ack/config.h b/plat/rpi/include/ack/config.h new file mode 100644 index 000000000..995673236 --- /dev/null +++ b/plat/rpi/include/ack/config.h @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef _ACK_CONFIG_H +#define _ACK_CONFIG_H + +/* We're providing a time() system call rather than wanting a wrapper around + * gettimeofday() in the libc. */ + +#define ACKCONF_TIME_IS_A_SYSCALL + +#endif diff --git a/plat/rpi/include/build.lua b/plat/rpi/include/build.lua new file mode 100644 index 000000000..4e6b8521b --- /dev/null +++ b/plat/rpi/include/build.lua @@ -0,0 +1,27 @@ +include("plat/build.lua") + +headermap = {} +packagemap = {} + +local function addheader(h) + headermap[h] = "./"..h + packagemap["$(PLATIND)/rpi/include/"..h] = "./"..h +end + +addheader("ack/config.h") +addheader("pi.h") +addheader("sys/select.h") +addheader("termios.h") +addheader("unistd.h") + +acklibrary { + name = "headers", + hdrs = headermap +} + +installable { + name = "pkg", + map = packagemap +} + + diff --git a/plat/rpi/include/pi.h b/plat/rpi/include/pi.h new file mode 100644 index 000000000..24e89a9a1 --- /dev/null +++ b/plat/rpi/include/pi.h @@ -0,0 +1,48 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef PI_H +#define PI_H + +/* When running in kernel mode, this structure gets the incoming parameters. + * In bare metal mode, it's gibberish. */ + +struct pi_kernel_parameters +{ + int r5; + int r4; + void* r3; + void* r2; + void* r1; + void* r0; +}; + +extern struct pi_kernel_parameters* pi_kernel_parameters; + +/* Initialise the mini UART (only do this if running on bare metal! */ +extern void pi_init_uart(void); + +/* Converts a pointer from a physical address to a user address. */ +extern void* pi_phys_to_user(void* ptr); + +/* Converts a pointer from a user address to a physical address. */ +extern void* pi_user_to_phys(void* ptr); + +/* Change the clock speed from 19.2MHz to 250MHz. Must be called *before* + * pi_init_uart(). */ +extern void pi_fast_mode(void); + +/* Initialise the RAM. */ +extern void pi_init_ram(void); + +/* The current clock speed (used by pi_init_uart to calculate the correct + * UART settings). */ + +extern int pi_clock_speed; + +#endif + diff --git a/plat/rpi/include/sys/select.h b/plat/rpi/include/sys/select.h new file mode 100644 index 000000000..df7488da4 --- /dev/null +++ b/plat/rpi/include/sys/select.h @@ -0,0 +1,13 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef _SYS_SELECT_H +#define _SYS_SELECT_H + +#include + +#endif diff --git a/plat/rpi/include/termios.h b/plat/rpi/include/termios.h new file mode 100644 index 000000000..8e0dbb8e8 --- /dev/null +++ b/plat/rpi/include/termios.h @@ -0,0 +1,47 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef _TERMIOS_H +#define _TERMIOS_H + +typedef unsigned char tcflag_t; + +struct termios +{ + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_lflag; + tcflag_t c_cflag; +}; + +#define ONLCR 1 +#define ECHO 2 +#define INLCR 4 + +/* Dummied parameters for compatibility --- only the ones above are + * honoured. */ + +#define BRKINT 0 +#define ICRNL 0 +#define INPCK 0 +#define ISTRIP 0 +#define IXON 0 +#define CS8 0 +#define ICANON 0 +#define IEXTEN 0 +#define ISIG 0 + +#define OPOST ONLCR + +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +extern int tcgetattr(int fd, struct termios* t); +extern int tcsetattr(int fd, int actions, struct termios* t); + +#endif diff --git a/plat/rpi/include/unistd.h b/plat/rpi/include/unistd.h new file mode 100644 index 000000000..a4d0c4507 --- /dev/null +++ b/plat/rpi/include/unistd.h @@ -0,0 +1,105 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef _UNISTD_H +#define _UNISTD_H + +#include +#include + +/* Types */ + +typedef int pid_t; +typedef int mode_t; + +typedef long suseconds_t; + +/* Time handling. */ + +struct timeval +{ + time_t tv_sec; + suseconds_t tv_usec; +}; + +struct timezone +{ + int tz_minuteswest; + int tz_dsttime; +}; /* obsolete, unused */ + +extern int gettimeofday(struct timeval* tv, struct timezone* tz); +extern int settimeofday(const struct timeval* tv, const struct timezone* tz); + +/* Constants for file access (open and friends) */ + +enum +{ + O_ACCMODE = 0x3, + + O_RDONLY = 0, + O_WRONLY = 1, + O_RDWR = 2, + + O_CREAT = 0100, + O_TRUNC = 01000, + O_APPEND = 02000, + O_NONBLOCK = 04000 +}; + +/* Special variables */ + +extern char** environ; + +/* Implemented system calls */ + +extern void _exit(int); +extern pid_t getpid(void); +extern void* sbrk(intptr_t increment); +extern int isatty(int d); +extern off_t lseek(int fildes, off_t offset, int whence); +extern int close(int d); +extern int open(const char* path, int access, ...); +extern int creat(const char* path, mode_t mode); +extern int read(int fd, void* buffer, size_t count); +extern int write(int fd, void* buffer, size_t count); + +/* Unimplemented system calls (these are just prototypes to let the library + * compile). */ + +extern int fcntl(int fd, int op, ...); + +/* Signal handling */ + +typedef int sig_atomic_t; + +#define SIG_ERR ((sighandler_t) -1) /* Error return. */ +#define SIG_DFL ((sighandler_t) 0) /* Default action. */ +#define SIG_IGN ((sighandler_t) 1) /* Ignore signal. */ + +#define SIGABRT 6 /* Abort (ANSI) */ +#define SIGILL 11 /* Illegal instruction */ + +#define _NSIG 32 /* Biggest signal number + 1 + (not including real-time signals). */ +typedef void (*sighandler_t)(int); +extern sighandler_t signal(int signum, sighandler_t handler); +extern int raise(int signum); + +/* Select */ + +typedef uint32_t fd_set; + +extern int select(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout); + +#define FD_ZERO(set) do { *set = 0; } while (0) +#define FD_SET(fd, set) do { *set |= (1< +#include +#include +#include + +#define OUT_OF_MEMORY (void*)(-1) /* sbrk returns this on failure */ +#define STACK_BUFFER 1024 /* number of bytes to leave for stack */ + +extern char _end[1]; +static char* current = _end; + +/* Top of heap: we assume that the block of memory the binary is loaded in + * is 256kB long. Because user pointers are always relative to the beginning + * of the block, this makes the end address easy to calculate. */ +static char* max = (char*) (128*1024); + +int brk(void* newend) +{ + if ((newend >= (void*)max) || (newend < (void*)_end)) + return -1; + + current = newend; + return 0; +} + +void* sbrk(intptr_t increment) +{ + char* old; + + if (increment == 0) + return current; + + old = current; + if (brk(old + increment) < 0) + return OUT_OF_MEMORY; + + return old; +} diff --git a/plat/rpi/libsys/build.lua b/plat/rpi/libsys/build.lua new file mode 100644 index 000000000..db579d41b --- /dev/null +++ b/plat/rpi/libsys/build.lua @@ -0,0 +1,15 @@ +acklibrary { + name = "lib", + srcs = { + "./*.c", + "./*.s", + }, + deps = { + "lang/cem/libcc.ansi/headers+headers", + "plat/rpi/include+headers", + }, + vars = { + plat = "rpi" + } +} + diff --git a/plat/rpi/libsys/close.c b/plat/rpi/libsys/close.c new file mode 100644 index 000000000..60fa0f96b --- /dev/null +++ b/plat/rpi/libsys/close.c @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +int close(int fd) +{ + errno = EBADF; + return -1; +} diff --git a/plat/rpi/libsys/creat.c b/plat/rpi/libsys/creat.c new file mode 100644 index 000000000..7c009e6a0 --- /dev/null +++ b/plat/rpi/libsys/creat.c @@ -0,0 +1,17 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include "libsys.h" + +int open(const char* path, int access, ...) +{ + errno = EACCES; + return -1; +} diff --git a/plat/rpi/libsys/errno.s b/plat/rpi/libsys/errno.s new file mode 100644 index 000000000..a2e1f8b55 --- /dev/null +++ b/plat/rpi/libsys/errno.s @@ -0,0 +1,31 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +#define D(e) .define e; e + +.sect .data + +! Define various ACK error numbers. Note that these are *not* ANSI C +! errnos, and are used for different purposes. + +D(ERANGE) = 1 +D(ESET) = 2 +D(EIDIVZ) = 6 +D(EHEAP) = 17 +D(EILLINS) = 18 +D(EODDZ) = 19 +D(ECASE) = 20 +D(EBADMON) = 25 + diff --git a/plat/rpi/libsys/getpid.c b/plat/rpi/libsys/getpid.c new file mode 100644 index 000000000..0ae1f6154 --- /dev/null +++ b/plat/rpi/libsys/getpid.c @@ -0,0 +1,15 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +pid_t getpid(void) +{ + return 0; +} diff --git a/plat/rpi/libsys/isatty.c b/plat/rpi/libsys/isatty.c new file mode 100644 index 000000000..83837ba9c --- /dev/null +++ b/plat/rpi/libsys/isatty.c @@ -0,0 +1,15 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +int isatty(int fd) +{ + return 1; +} diff --git a/plat/rpi/libsys/kill.c b/plat/rpi/libsys/kill.c new file mode 100644 index 000000000..bacc405df --- /dev/null +++ b/plat/rpi/libsys/kill.c @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +int kill(pid_t pid, int sig) +{ + errno = EINVAL; + return -1; +} diff --git a/plat/rpi/libsys/libsys.h b/plat/rpi/libsys/libsys.h new file mode 100644 index 000000000..44b3c7818 --- /dev/null +++ b/plat/rpi/libsys/libsys.h @@ -0,0 +1,19 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef LIBSYS_H +#define LIBSYS_H + +extern void _sys_rawwrite(unsigned char b); +extern unsigned char _sys_rawread(void); +extern int _sys_rawpoll(void); + +extern void _sys_write_tty(char c); + +extern int _sys_ttyflags; + +#endif diff --git a/plat/rpi/libsys/libsysasm.h b/plat/rpi/libsys/libsysasm.h new file mode 100644 index 000000000..16dbbcfba --- /dev/null +++ b/plat/rpi/libsys/libsysasm.h @@ -0,0 +1,20 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#ifndef LIBSYSASM_H +#define LIBSYSASM_H + +! Declare segments (the order is important). + +.sect .text +.sect .rom +.sect .data +.sect .bss + +#define gp r15 + +#endif diff --git a/plat/rpi/libsys/lseek.c b/plat/rpi/libsys/lseek.c new file mode 100644 index 000000000..9a487d747 --- /dev/null +++ b/plat/rpi/libsys/lseek.c @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include + +off_t lseek(int fd, off_t offset, int whence) +{ + errno = EINVAL; + return -1; +} diff --git a/plat/rpi/libsys/open.c b/plat/rpi/libsys/open.c new file mode 100644 index 000000000..cbdc30ec1 --- /dev/null +++ b/plat/rpi/libsys/open.c @@ -0,0 +1,16 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include "libsys.h" + +int creat(const char* path, int mode) +{ + return open(path, O_CREAT|O_WRONLY|O_TRUNC, mode); +} diff --git a/plat/rpi/libsys/pi_fast_mode.s b/plat/rpi/libsys/pi_fast_mode.s new file mode 100644 index 000000000..8b50990f0 --- /dev/null +++ b/plat/rpi/libsys/pi_fast_mode.s @@ -0,0 +1,70 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "libsysasm.h" + +.sect .text + +#define PASSWD 0x5a000000 +#define PLLC 5 +#define OSC 1 + +#define A2W 0x7e102000 +#define A2W_PLLC_MULT 0x7e102020 +#define A2W_PLLC_MULT2 0x7e102120 +#define A2W_PLLC_MULT_FRACT 0x7e102220 +#define A2W_PLLx_DIV 0x7e102620 + +#define CM 0x7e101000 +#define CM_VPU_CTL 0x7e101008 +#define CM_VPU_DIV 0x7e10100c +#define CM_TIME_DIV 0x7e1010ec +#define CM_TIME_CTL 0x7e1010e8 + +#define hash # +#define copy(A) A +#define poke(A, V) \ + mov r0, copy(hash) V; mov r1, copy(hash) A; st r0, (r1) + +! Changes the clock speed to 250MHz. + +.define _pi_fast_mode +_pi_fast_mode: + poke(A2W + 0x190, 0x5a000001) + poke(A2W_PLLC_MULT_FRACT, PASSWD | 87380) + poke(A2W_PLLC_MULT2, PASSWD | 52 | 0x1000) + poke(A2W + 0x3c, 0x5a000100) + poke(A2W + 0x38, 0x5a000000) + poke(A2W + 0x34, 0x5a144000) + poke(A2W + 0x30, 0x5a000000) + poke(CM + 0x108, 0x5a000200) + poke(CM + 0x108, 0x5a0002aa) + poke(A2W + 0x2c, 0x5a000000) + poke(A2W + 0x28, 0x5a400000) + poke(A2W + 0x24, 0x5a000005) + poke(A2W_PLLC_MULT, PASSWD | 52 | 0x555000) + poke(A2W_PLLC_MULT2, PASSWD | 52 | 0x21000) + poke(A2W + 0x2c, 0x5a000042) + poke(A2W + 0x28, 0x5a500401) + poke(A2W + 0x24, 0x5a004005) + poke(A2W_PLLC_MULT, PASSWD | 52 | 0x555000) + poke(A2W_PLLx_DIV, PASSWD | 2) + poke(CM + 0x108, 0x5a0002ab) + poke(CM + 0x108, 0x5a0002aa) + poke(CM + 0x108, 0x5a0002a8) + poke(CM_VPU_CTL, PASSWD | 0x200 | OSC | 0x40) + poke(CM_VPU_DIV, PASSWD | [4 << 12]) + poke(CM_VPU_CTL, PASSWD | PLLC | 0x40) + poke(CM_VPU_CTL, PASSWD | PLLC | 0x50) + poke(CM_TIME_DIV, PASSWD | [19 << 12] | 819) + poke(CM_TIME_CTL, PASSWD | OSC | 0x10) + + mov r0, #250000000 + st r0, _pi_clock_speed + b lr + diff --git a/plat/rpi/libsys/pi_phys_to_user.s b/plat/rpi/libsys/pi_phys_to_user.s new file mode 100644 index 000000000..d67cac895 --- /dev/null +++ b/plat/rpi/libsys/pi_phys_to_user.s @@ -0,0 +1,20 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "libsysasm.h" + +.sect .text + +! Transforms a physical address into a user address. + +.define _pi_phys_to_user +_pi_phys_to_user: + ld r0, 0 (sp) + sub r0, gp + b lr + diff --git a/plat/rpi/libsys/pi_uart.s b/plat/rpi/libsys/pi_uart.s new file mode 100644 index 000000000..b7ce9898e --- /dev/null +++ b/plat/rpi/libsys/pi_uart.s @@ -0,0 +1,185 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "libsysasm.h" + +.sect .text + +! Because of the low system clock rate, this baud rate might be inaccurate +! So be careful with your serial/terminal, some adjustment may be necessary. +TARGET_BAUD_RATE = 115200 + +GPFSEL1 = 0x7e200004 +GPSET0 = 0x7e20001C +GPCLR0 = 0x7e200028 +GPPUD = 0x7e200094 +GPPUDCLK0 = 0x7e200098 + +AUX_ENABLES = 0x7e215004 +AUX_MU_IO_REG = 0x7e215040 +AUX_MU_IER_REG = 0x7e215044 +AUX_MU_IIR_REG = 0x7e215048 +AUX_MU_LCR_REG = 0x7e21504C +AUX_MU_MCR_REG = 0x7e215050 +AUX_MU_LSR_REG = 0x7e215054 +AUX_MU_MSR_REG = 0x7e215058 +AUX_MU_SCRATCH = 0x7e21505C +AUX_MU_CNTL_REG = 0x7e215060 +AUX_MU_STAT_REG = 0x7e215064 +AUX_MU_BAUD_REG = 0x7e215068 + +! Sets up the mini UART for use as a console. + +.define _pi_init_uart +_pi_init_uart: + ! Configure TX and RX GPIO pins for Mini Uart function. + mov r1, #GPFSEL1 + ld r0, (r1) + and r0, #~[7<<12] + or r0, #2<<12 + and r0, #~[7<<15] + or r0, #2<<15 + st r0, (r1) + + mov r1, #GPPUD + mov r0, #0 + st r0, (r1) + +delay1: + add r0, #1 + cmp r0, #150 + b.ne delay1 + + mov r1, #GPPUDCLK0 + mov r0, #[1<<14]|[1<<15] + st r0, (r1) + + mov r0, #0 +delay2: + add r0, #1 + cmp r0, #150 + b.ne delay2 + + mov r1, #GPPUDCLK0 + mov r0, #0 + st r0, (r1) + + ! Set up serial port + mov r1, #AUX_ENABLES + mov r0, #1 + st r0, (r1) + + mov r1, #AUX_MU_IER_REG + mov r0, #0 + st r0, (r1) + + mov r1, #AUX_MU_CNTL_REG + mov r0, #0 + st r0, (r1) + + mov r1, #AUX_MU_LCR_REG + mov r0, #3 + st r0, (r1) + + mov r1, #AUX_MU_MCR_REG + mov r0, #0 + st r0, (r1) + + mov r1, #AUX_MU_IER_REG + mov r0, #0 + st r0, (r1) + + mov r1, #AUX_MU_IIR_REG + mov r0, #0xC6 + st r0, (r1) + + mov r1, #AUX_MU_BAUD_REG + ld r0, _pi_clock_speed + mov r2, #TARGET_BAUD_RATE*8 + divu r0, r0, r2 + sub r0, #1 + st r0, (r1) + + mov r1, #AUX_MU_LCR_REG + mov r0, #3 + st r0, (r1) + + mov r1, #AUX_MU_CNTL_REG + mov r0, #3 + st r0, (r1) + + ! Mark the uart as being initialised. + mov r0, #1 + stb r0, __uart_status + + b lr + +! Send a single byte. + +.define __sys_rawwrite +__sys_rawwrite: + ldb r0, __uart_status + b.eq r0, #0, 1f + + ld r0, (sp) + mov r1, #AUX_MU_LSR_REG + ! loop until space available in Tx buffer +sendwait: + ld r2, (r1) + and r2, #0x20 + cmp r2, #0x20 + b.ne sendwait + + mov r1, #AUX_MU_IO_REG + stb r0, (r1) + +1: + b lr + +! Poll to see if there's incoming data available. + +.define __sys_rawpoll +.define __sys_rawpoll +__sys_rawpoll: + ldb r0, __uart_status + b.eq r0, #0, 1b + + mov r1, #AUX_MU_LSR_REG + ld r0, (r1) + and r0, #0x1 ! 0 if no data, 1 if data +1: + b lr + +! Receive a single byte. + +.define __sys_rawread +__sys_rawread: + ldb r0, __uart_status + b.eq r0, #0, 1b + + ! receive 1 byte (returned in r0) + mov r1, #AUX_MU_LSR_REG + mov r2, #AUX_MU_IO_REG + ! loop until char available +recvwait: + ld r3, (r1) + and r3, #0x1 + b.ne r3, #0x1, recvwait + + ldb r0, (r2) +1: + b lr + +.comm __uart_status, 1 + +.sect .data +.define _pi_clock_speed + +! System clock is running directly off the 19.2MHz crystal at initial reset +_pi_clock_speed: + .data4 19200000 diff --git a/plat/rpi/libsys/pi_user_to_phys.s b/plat/rpi/libsys/pi_user_to_phys.s new file mode 100644 index 000000000..dd62c069a --- /dev/null +++ b/plat/rpi/libsys/pi_user_to_phys.s @@ -0,0 +1,20 @@ +# +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include "libsysasm.h" + +.sect .text + +! Transforms a user address into a physical address. + +.define _pi_user_to_phys +_pi_user_to_phys: + ld r0, 0 (sp) + add r0, gp + b lr + diff --git a/plat/rpi/libsys/read.c b/plat/rpi/libsys/read.c new file mode 100644 index 000000000..227c89997 --- /dev/null +++ b/plat/rpi/libsys/read.c @@ -0,0 +1,41 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +int read(int fd, void* buffer, size_t count) +{ + char i; + + /* We're only allowed to read from fd 0, 1 or 2. */ + + if ((fd < 0) || (fd > 2)) + { + errno = EBADF; + return -1; + } + + /* Empty buffer? */ + + if (count == 0) + return 0; + + /* Read one byte. */ + + i = _sys_rawread(); + if ((i == '\r') && !(_sys_ttyflags & INLCR)) + i = '\n'; + if (_sys_ttyflags & ECHO) + _sys_write_tty(i); + + *(char*)buffer = i; + return 1; +} diff --git a/plat/rpi/libsys/select.c b/plat/rpi/libsys/select.c new file mode 100644 index 000000000..280bfd694 --- /dev/null +++ b/plat/rpi/libsys/select.c @@ -0,0 +1,65 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include +#include "libsys.h" + +#define TICKS_PER_SEC 1000000 + +typedef int condition_t(void); + +static int nop_condition(void) +{ + return 0; +} + +int select(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout) +{ + int result = 0; + condition_t* condition = nop_condition; + + if (FD_ISSET(0, readfds)) + condition = _sys_rawpoll; + + FD_ZERO(readfds); + FD_ZERO(writefds); + FD_ZERO(exceptfds); + + if (timeout) + { + /* Wait for a specified amount of time. */ + + uint32_t ticks = (timeout->tv_sec * TICKS_PER_SEC) + + (timeout->tv_usec * (TICKS_PER_SEC/1000000)); + uint32_t* timer_clo = pi_phys_to_user((void*) 0x7e003004); + uint32_t ra = *timer_clo; + + while (!condition() && ((*timer_clo - ra) < ticks)) + ; + } + else + { + /* Wait forever. */ + + while (!condition()) + ; + + } + + if ((condition == _sys_rawpoll) && condition()) + { + FD_SET(0, readfds); + result = 1; + } + + return result; +} diff --git a/plat/rpi/libsys/signal.c b/plat/rpi/libsys/signal.c new file mode 100644 index 000000000..10a2ded29 --- /dev/null +++ b/plat/rpi/libsys/signal.c @@ -0,0 +1,17 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +sighandler_t signal(int signum, sighandler_t handler) +{ + return SIG_DFL; +} diff --git a/plat/rpi/libsys/tcgetattr.c b/plat/rpi/libsys/tcgetattr.c new file mode 100644 index 000000000..3b099afb5 --- /dev/null +++ b/plat/rpi/libsys/tcgetattr.c @@ -0,0 +1,22 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +int tcgetattr(int fd, struct termios* t) +{ + t->c_iflag = _sys_ttyflags & INLCR; + t->c_oflag = _sys_ttyflags & ONLCR; + t->c_lflag = _sys_ttyflags & ECHO; + t->c_cflag = 0; + return 0; +} + diff --git a/plat/rpi/libsys/tcsetattr.c b/plat/rpi/libsys/tcsetattr.c new file mode 100644 index 000000000..1943d33e0 --- /dev/null +++ b/plat/rpi/libsys/tcsetattr.c @@ -0,0 +1,19 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +int tcsetattr(int fd, int actions, struct termios* t) +{ + _sys_ttyflags = t->c_iflag | t->c_oflag | t->c_lflag; + return 0; +} + diff --git a/plat/rpi/libsys/time.c b/plat/rpi/libsys/time.c new file mode 100644 index 000000000..e448a33d0 --- /dev/null +++ b/plat/rpi/libsys/time.c @@ -0,0 +1,19 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +time_t time(time_t* t) +{ + if (t) + *t = 0; + return 0; +} diff --git a/plat/rpi/libsys/write.c b/plat/rpi/libsys/write.c new file mode 100644 index 000000000..0fba49884 --- /dev/null +++ b/plat/rpi/libsys/write.c @@ -0,0 +1,49 @@ +/* + * Raspberry Pi support library for the ACK + * © 2013 David Given + * This file is redistributable under the terms of the 3-clause BSD license. + * See the file 'Copying' in the root of the distribution for the full text. + */ + +#include +#include +#include +#include +#include "libsys.h" + +int _sys_ttyflags = ONLCR | INLCR | ECHO; + +void _sys_write_tty(char c) +{ + _sys_rawwrite(c); + if ((c == '\n') && (_sys_ttyflags & ONLCR)) + _sys_rawwrite('\r'); +} + +int write(int fd, void* buffer, size_t count) +{ + int i; + char* p = buffer; + + /* We're only allowed to write to fd 0, 1 or 2. */ + + if ((fd < 0) || (fd > 2)) + { + errno = EBADF; + return -1; + } + + /* Write all data. */ + + i = 0; + while (i < count) + { + _sys_write_tty(*p++); + + i++; + } + + /* No failures. */ + + return count; +} diff --git a/pm b/pm deleted file mode 100755 index 23560e2c6..000000000 --- a/pm +++ /dev/null @@ -1,5669 +0,0 @@ -#!/bin/sh -# Prime Mover -# -# (C) 2006 David Given. -# Prime Mover is licensed under the MIT open source license. To get the full -# license text, run this file with the '--license' option. -# -# $Id: shell 52 2006-10-03 22:12:33Z dtrg $ - -if [ -x "$(which arch 2>/dev/null)" ]; then - ARCH="$(arch)" -elif [ -x "$(which machine 2>/dev/null)" ]; then - ARCH="$(machine)" -elif [ -x "$(which uname 2>/dev/null)" ]; then - ARCH="$(uname -m)" -else - echo "pm: unable to determine target type, proceeding anyway" - ARCH=unknown -fi - -THISFILE="$0" -PMEXEC="./.pm-exec-$ARCH" -set -e - -GZFILE=/tmp/pm-$$.gz -CFILE=/tmp/pm-$$.c -trap "rm -f $GZFILE $CFILE" EXIT - -extract_section() { - sed -e "1,/^XXXXSTART$1/d" "$THISFILE" | ( - read size - dd bs=1 count=$size 2> /dev/null - ) > $GZFILE - cat $GZFILE | cat -} - -# If the bootstrap's built, run it. - -if [ "$PMEXEC" -nt $0 ]; then - extract_section script | "$PMEXEC" /dev/stdin "$@" - exit $? -fi - -# Otherwise, compile it and restart. - -echo "pm: bootstrapping..." - -if [ -x "$(which gcc 2>/dev/null)" ]; then - CC="gcc -O -s" -else - CC="cc" -fi - -extract_section interpreter > /tmp/pm-$$.c -$CC $CFILE -o "$PMEXEC" && exec "$THISFILE" "$@" - -echo "pm: bootstrap failed." -exit 1 - -XXXXSTARTscript -38405 -#!/usr/bin/lua --- Prime Mover --- --- © 2006 David Given. --- Prime Mover is licensed under the MIT open source license. Search --- for 'MIT' in this file to find the full license text. --- --- $Id: pm 93 2007-02-24 21:20:53Z dtrg $ - --- ======================================================================= -- --- GLOBALS -- --- ======================================================================= -- - -local VERSION = "0.1.1" - --- Fast versions of useful system variables. - -local stdin = io.stdin -local stdout = io.stdout -local stderr = io.stderr - -local string_find = string.find -local string_gsub = string.gsub -local string_sub = string.sub -local string_byte = string.byte - -local table_insert = table.insert -local table_getn = table.getn -local table_concat = table.concat - -local posix_stat = posix.stat -local posix_readlink = posix.readlink -local posix_unlink = posix.unlink -local posix_rmdir = posix.rmdir - -local os_time = os.time - -local _G = _G -local _ - --- Option settings. - -local delete_output_files_on_error = true -local purge_intermediate_cache = false -local no_execute = false -local input_files = {} -local targets = {} -intermediate_cache_dir = ".pm-cache/" -verbose = false -quiet = false - --- Application globals. - -local sandbox = {} -local scope = {object=sandbox, next=nil} -local intermediate_cache = {} -local intermediate_cache_count = 0 -local buildstages = 0 - --- Atoms. - -local PARENT = {} -local EMPTY = {} -local REDIRECT = {} - --- Exported symbols (set to dummy values). - -message = 0 -filetime = 0 -filetouch = 0 -install = 0 -rendertable = 0 -stringmodifier = {} - -setmetatable(_G, {__newindex = function(t, key, value) - error("Attempt to write to new global "..key) -end}) - --- ======================================================================= -- --- UTILITIES -- --- ======================================================================= -- - -local function message(...) - stderr:write("pm: ") - stderr:write(unpack(arg)) - stderr:write("\n") -end -_G.message = message - -local function usererror(...) - stderr:write("pm: ") - stderr:write(unpack(arg)) - stderr:write("\n") - os.exit(1) -end - -local function traceoutput(...) - stdout:write(unpack(arg)) - stdout:write("\n") -end - -local function assert(message, result, e) - if result then - return result - end - - if (type(message) == "string") then - message = {message} - end - - table.insert(message, ": ") - table.insert(message, e) - usererror(unpack(message)) -end - --- Concatenates the contents of its arguments to the specified table. --- (Numeric indices only.) - -local function table_append(t, ...) - for _, i in ipairs(arg) do - if (type(i) == "table") then - for _, j in ipairs(i) do - table_insert(t, j) - end - else - table_insert(t, i) - end - end -end - --- Merge the contents of its arguments to the specified table. --- (Name indices. Will break on numeric indices.) - -local function table_merge(t, ...) - for _, i in ipairs(arg) do - for j, k in pairs(i) do - t[j] = k - end - end -end - --- Turn a list of strings into a single quoted string. - -function rendertable(i) - if (type(i) == "string") or (type(i) == "number") then - return i - end - - if (i == nil) or (i == EMPTY) then - return "" - end - - local t = {} - for _, j in ipairs(i) do - local r = string_gsub(j, "\\", "\\\\") - r = string_gsub(r, '"', '\\"') - table_insert(t, r) - end - return '"'..table_concat(t, '" "')..'"' -end -local rendertable = rendertable - --- Returns just the directory part of a path. - -local function dirname(f) - local f, n = string_gsub(f, "/[^/]*$", "") - if (n == 0) then - return "." - end - return f -end -posix.dirname = dirname - --- Makes an absolute path. - -local function absname(f) - if string.find(f, "^/") then - return f - end - - return posix.getcwd().."/"..f -end -posix.absname = absname - --- Copies a file. - -local function copy(src, dest) - local s = string_gsub(src, "'", "'\"'\"'") - local d = string_gsub(dest, "'", "'\"'\"'") - local r = os.execute("cp '"..s.."' '"..d.."'") - if (r ~= 0) then - return nil, "unable to copy file" - end - return 0, nil -end -posix.copy = copy - --- Makes all directories that contain f - -local function mkcontainerdir(f) - f = dirname(f) - if not posix_stat(f, "type") then - mkcontainerdir(f) - local r = posix.mkdir(f) - if not r then - usererror("unable to create directory '"..f.."'") - end - end -end - --- Install a file (suitable as a command list entry). - -local function do_install(self, src, dest) - src = absname(self:__expand(src)) - dest = absname(self:__expand(dest)) - if verbose then - message("installing '", src, "' --> '", dest, "'") - end - - mkcontainerdir(dest) - local f, e = posix.symlink(src, dest) - if f then - return - end - - if (e ~= nil) then - f, e = posix.unlink(dest) - if f then - f, e = posix.symlink(src, dest) - if f then - return - end - end - end - - self:__error("couldn't install '", src, "' to '", dest, - "': ", e) -end - -function install(src, dest) - return function(self, inputs, outputs) - local src = src - local dest = dest - - if (dest == nil) then - dest = src - src = outputs[1] - end - if (type(src) ~= "string") then - self:__error("pm.install needs a string or an object for an input") - end - if (type(dest) ~= "string") then - self:__error("pm.install needs a string for a destination") - end - return do_install(self, src, dest) - end -end - --- Perform an error traceback. - -local function traceback(e) - local i = 1 - while true do - local t = debug.getinfo(i) - if not t then - break - end - if (t.short_src ~= "stdin") and (t.short_src ~= "[C]") then - if (t.currentline == -1) then - t.currentline = "" - end - message(" ", t.short_src, ":", t.currentline) - end - i = i + 1 - end - - e = string_gsub(e, "^stdin:[0-9]*: ", "") - usererror("error: ", e) -end - --- ======================================================================= -- --- CACHE MANAGEMENT -- --- ======================================================================= -- - -local statted_files = {} -local function clear_stat_cache() - statted_files = {} -end - --- Returns the timestamp of a file, or 0 if it doesn't exist. - -local statted_files = {} -local function filetime(f) - local t = statted_files[f] - if t then - return t - end - - -- Stupid BeOS doesn't dereference symlinks on stat(). - - local realf = f - while true do - local newf, e = posix_readlink(realf) - if e then - break - end - realf = newf - end - - t = posix_stat(realf, "mtime") or 0 - statted_files[f] = t - return t -end -_G.filetime = filetime - --- Pretends to touch a file by manipulating the stat cache. - -local function filetouch(f) - if (type(f) == "string") then - f = {f} - end - - local t = os_time() - for _, i in ipairs(f) do - statted_files[i] = t - end -end -_G.filetouch = filetouch - -local function create_intermediate_cache() - local d = dirname(intermediate_cache_dir) - if not quiet then - message("creating new intermediate file cache in '"..d.."'") - end - - -- Attempt to wipe the old cache directory. - - local f = posix.files(d) - if not f then - -- The directory doesn't exist, so create it. - - mkcontainerdir(d) - f = posix.mkdir(d) - if not f then - usererror("unable to create intermediate file cache directory") - end - else - -- The directory exists. Delete all files in it recursively. - - local function rmdir(root) - local f = posix.files(root) - if not f then - return - end - - for i in f do - if ((i ~= ".") and (i ~= "..")) then - local fn = root.."/"..i - local t = posix_stat(fn, "type") - if (t == "regular") then - if not posix_unlink(fn) then - usererror("unable to purge intermediate file cache directory") - end - elseif (t == "directory") then - rmdir(fn) - posix_rmdir(fn) - end - end - end - end - - rmdir(d) - end -end - -local function save_intermediate_cache() - local fn = intermediate_cache_dir.."index" - local f = io.open(fn, "w") - if not f then - usererror("unable to save intermediate cache index file '", fn, "'") - end - - f:write(intermediate_cache_count, "\n") - for i, j in pairs(intermediate_cache) do - f:write(i, "\n") - f:write(j, "\n") - end - - f:close() -end - -local function load_intermediate_cache() - local fn = intermediate_cache_dir.."index" - local f = io.open(fn, "r") - if not f then - create_intermediate_cache() - return - end - - intermediate_cache_count = f:read("*l") - while true do - local l1 = f:read("*l") - local l2 = f:read("*l") - - if (l1 == nil) or (l2 == nil) then - break - end - - intermediate_cache[l1] = l2 - end - - f:close() -end - -local function create_intermediate_cache_key(key) - local u = intermediate_cache[key] - if not u then - intermediate_cache_count = intermediate_cache_count + 1 - u = intermediate_cache_count - intermediate_cache[key] = u - save_intermediate_cache() - end - - return u -end - --- ======================================================================= -- --- STRING MODIFIERS -- --- ======================================================================= -- - -function stringmodifier.dirname(self, s) - if (type(s) == "table") then - if (table_getn(s) == 1) then - s = s[1] - else - self:__error("tried to use string modifier 'dirname' on a table with more than one entry") - end - end - - return dirname(s) -end - --- ======================================================================= -- --- CLASS SYSTEM -- --- ======================================================================= -- - ---- Base class -------------------------------------------------------------- - -local metaclass = { - class = "metaclass", - - -- Creates a new instance of a class by creating a new object and cloning - -- all properties of the called class onto it. - - __call = function (self, ...) - local o = {} - for i, j in pairs(self) do - o[i] = j - end - setmetatable(o, o) - - -- Determine where this object was defined. - - local i = 1 - while true do - local s = debug.getinfo(i, "Sl") - if s then - if (string_byte(s.source) == 64) then - o.definedat = string_sub(s.source, 2)..":"..s.currentline - end - else - break - end - i = i + 1 - end - - -- Call the object's constructor and return it. - - o:__init(unpack(arg)) - return o - end, - - -- Dummy constructor. - - __init = function (self, ...) - end, -} -setmetatable(metaclass, metaclass) - ---- Top-level build node ---------------------------------------------------- - -local node = metaclass() -node.class = "node" - --- When constructed, nodes initialise themselves from a supplied table of --- properties. All node children take exactly one argument, allowing the --- "constructor {properties}" construction pattern. - -function node:__init(t) - metaclass.__init(self) - - if (type(t) == "string") then - t = {t} - end - if (type(t) ~= "table") then - self:__error("can't be constructed with a ", type(t), "; try a table or a string") - end - - -- Copy over non-numeric parameters. - - for i, j in pairs(t) do - if (tonumber(i) == nil) then - self[i] = j - end - end - - -- Copy any numeric parameters. - - for _, i in ipairs(t) do - table_insert(self, i) - end - - -- If we're a class, don't verify. - - if t.class then - return - end - - -- ensure_n_children - -- When true, ensures that the node has exactly the number of children - -- specified. - - if self.ensure_n_children then - local n = self.ensure_n_children - if (table.getn(self) ~= n) then - local one - if (n == 1) then - one = "one child" - else - one = n.." children" - end - self:_error("must have exactly ", one) - end - end - - -- ensure_at_least_one_child - -- When true, ensures the the node has at least one child. - - if self.ensure_at_least_one_child then - if (table_getn(self) < 1) then - self:__error("must have at least one child") - end - end - - -- construct_string_children_with - -- If set, any string children are automatically converted using the - -- specified constructor. - - if self.construct_string_children_with then - local constructor = self.construct_string_children_with - for i, j in ipairs(self) do - if (type(j) == "string") then - self[i] = constructor {j} - end - end - end - - -- all_children_are_objects - -- When true, verifies that all children are objects and not something - -- else (such as strings). - - if self.all_children_are_objects then - for i, j in ipairs(self) do - if (type(j) ~= "table") then - self:__error("doesn't know what to do with child ", i, - ", which is a ", type(j)) - end - end - end - - -- Ensure that self.install is valid. - - if self.install then - local t = type(self.install) - if (t == "string") or - (t == "function") then - self.install = {self.install} - end - - if (type(self.install) ~= "table") then - self:__error("doesn't know what to do with its installation command, ", - "which is a ", type(self.install), " but should be a table, function ", - "or string") - end - end -end - --- If an attempt is made to access a variable on a node that doesn't exist, --- and the variable starts with a capital letter, it's looked up in the --- property scope. - -function node:__index(key) - local i = string_byte(key, 1) - if (i >= 65) and (i <= 90) then - -- Scan up the class hierarchy. - - local recurse - recurse = function(s, key) - if not s then - return nil - end - local o = rawget(s.object, key) - if o then - if (type(o) == "table") then - - -- Handle lists of the form {PARENT, "foo", "bar"...} - if (o[1] == PARENT) then - local parent = recurse(s.next, key) - local newo = {} - - if parent then - if (type(parent) ~= "table") then - parent = {parent} - end - for _, j in ipairs(parent) do - table_insert(newo, j) - end - end - for _, j in ipairs(o) do - if (j ~= PARENT) then - table_insert(newo, j) - end - end - return newo - - -- Handle lists of the form {REDIRECT, "newkey"} - elseif (o[1] == REDIRECT) then - return self:__index(o[2]) - end - end - return o - end - -- Tail recursion. - return recurse(s.next, key) - end - - -- We want this node looked at first, so fake up a scope entry for it. - local fakescope = { - next = scope, - object = self - } - - -- Tail recursion. - return recurse(fakescope, key) - end - - -- For local properties, just return what's here. - return rawget(self, key) -end - --- Little utility that emits an error message. - -function node:__error(...) - usererror("object '", self.class, "', defined at ", - self.definedat, ", ", unpack(arg)) -end - --- Causes a node to return its outputs; that is, the files the node will --- produce when built. The parameter contains a list of input filenames; the --- outputs of the node's children. - -function node:__outputs(inputs) - self:__error("didn't implement __outputs when it should have") -end - --- Causes a node to return its dependencies; that is, a list of *filenames* --- whose timestamps need to be considered when checking whether a node needs --- to be rebuilt. This is usually, but not always, the same as the inputs. - -function node:__dependencies(inputs, outputs) - return inputs -end - --- Returns the node's timestamp. It will only get built if this is older than its --- children's timestamps. - -function node:__timestamp(inputs, outputs) - local t = 0 - for _, i in ipairs(outputs) do - local tt = filetime(i) - if (tt > t) then - t = tt - end - end - return t -end - --- Unconditionally builds the nodes' children, collating their outputs. We --- push a new scope while we do so, to make this object's definitions visible --- to the children. (Almost never overridden. Only file() will want to do --- this, most likely.) - -function node:__buildchildren() - local inputs = {} - scope = {object=self, next=scope} - - for _, i in ipairs(self) do - table_append(inputs, i:__build()) - end - self:__buildadditionalchildren() - scope = scope.next - return inputs -end - --- Provides a hook for building any additional children that aren't actually --- in the child list. - -function node:__buildadditionalchildren() -end - --- Cause the node's children to be built, collating their outputs, and if --- any output is newer than the node itself, causes the node to be built. - -function node:__build() - -- Build children and collate their outputs. These will become this node's - -- inputs. - - local inputs = self:__buildchildren() - - -- Determine the node's outputs. This will usually be automatically - -- generated, in which case the name will depend on the overall environment --- - -- including the inputs. - - local outputs = self:__outputs(inputs) - - -- Get the current node's timestamp. If anything this node depends on is - -- newer than that, the node needs rebuilding. - - local t = self:__timestamp(inputs, outputs) - local depends = self:__dependencies(inputs, outputs) - local rebuild = false - - if (t == 0) then - rebuild = true - end - - if (not rebuild and depends) then - for _, i in ipairs(depends) do - local tt = filetime(i) --- message("comparing ", t, " with ", tt, " (", rendertable({i}), ")") - if (tt > t) then - if verbose then - message("rebuilding ", self.class, " because ", i, " newer than ", rendertable(outputs)) - end - rebuild = true - break - end - end - end - - if rebuild then - self:__dobuild(inputs, outputs) - filetouch(outputs) - end - - -- If an installation command was specified, execute it now. - - if self.install then - self:__invoke(self.install, inputs, outputs) - end - - -- And return this nodes' outputs. - - return outputs -end - --- Builds this node from the specified input files (the node's childrens' --- outputs). - -function node:__dobuild(inputs, outputs) - self:__error("didn't implement __dobuild when it should have") -end - --- Recursively expands any variables in a string. - -function node:__expand(s) - local searching = true - while searching do - searching = false - - -- Expand %{expressions}% - - s = string_gsub(s, "%%{(.-)}%%", function (expr) - searching = true - - local f, e = loadstring(expr, "expression") - if not f then - self:__error("couldn't compile the expression '", expr, "': ", e) - end - - local env = {self=self} - setmetatable(env, { - __index = function(_, key) - return sandbox[key] - end - }) - setfenv(f, env) - - f, e = pcall(f, self) - if not f then - self:__error("couldn't evaluate the expression '", expr, "': ", e) - end - - return rendertable(e) - end) - - -- Expand %varnames% - - s = string_gsub(s, "%%(.-)%%", function (varname) - searching = true - - -- Parse the string reference. - - local _, _, leftcolon, rightcolon = string_find(varname, "([^:]*):?(.*)$") - local _, _, varname, selectfrom, hyphen, selectto = string_find(leftcolon, "^([^[]*)%[?([^-%]]*)(%-?)([^%]]*)]?$") - - -- Get the basic value that the rest of the reference is going to - -- depend on. - - local result = self:__index(varname) - if not result then - self:__error("doesn't understand variable '", varname, "'") - end - - -- Process any selector, if specified. - - if (selectfrom ~= "") or (hyphen ~= "") or (selectto ~= "") then - if (type(result) ~= "table") then - self:__error("tried to use a [] selector on variable '", varname, - "', which doesn't contain a table") - end - local n = table_getn(result) - - selectfrom = tonumber(selectfrom) - selectto = tonumber(selectto) - - if (hyphen ~= "") then - if not selectfrom then - selectfrom = 1 - end - if not selectto then - selectto = n - end - else - if not selectto then - selectto = selectfrom - end - if not selectfrom then - self:__error("tried to use an empty selector on variable '", varname, "'") - end - end - - if (selectfrom < 1) or (selectto < 1) or - (selectfrom > n) or (selectto > n) or - (selectto < selectfrom) then - self:__error("tried to use an invalid selector [", - selectfrom, "-", selectto, "] on variable '", varname, - "'; only [1-", n, "] is valid") - end - - local newresult = {} - for i = selectfrom, selectto do - table_insert(newresult, result[i]) - end - result = newresult - end - - -- Process any string modifier, if supplied. - - if (rightcolon ~= "") then - local f = stringmodifier[rightcolon] - if not f then - self:__error("tried to use an unknown string modifier '", - rightcolon, "' on variable '", varname, "'") - end - - result = f(self, result) - end - - return rendertable(result) - end) - end - - -- Any remaining %% sequences must be empty, and so convert them into - -- single % sequences. - - s = string_gsub(s, "%%%%", "%") - return s -end - --- Expands any variables in a command table, and executes it. - -function node:__invoke(command, inputs, outputs) - if (type(command) ~= "table") then - command = {command} - end - - for _, s in ipairs(command) do - if (type(s) == "string") then - s = self:__expand(s) - if not quiet then - traceoutput(s) - end - if not no_execute then - local r = os.execute(s) - if (r ~= 0) then - return r - end - end - elseif (type(s) == "function") then - local r = s(self, inputs, outputs) - if r then - return r - end - end - end - return false -end - --- ======================================================================= -- --- PROLOGUE -- --- ======================================================================= -- - --- The prologue contains the standard library that all pmfiles can refer to. --- For simplicity, it's implemented by code running inside the sandbox, --- which means that it's basically identical to user code (and could, in --- fact, be kept in a seperate file). - --- Here we set up the sandbox. - -table_merge(sandbox, { - VERSION = VERSION, - - assert = assert, - collectgarbage = collectgarbage, - dofile = dofile, - error = error, - getfenv = getfenv, - getmetatable = getmetatable, - gcinfo = gcinfo, - ipairs = ipairs, - loadfile = loadfile, - loadlib = loadlib, - loadstring = loadstring, - next = next, - pairs = pairs, - pcall = pcall, - print = print, - rawequal = rawequal, - rawget = rawget, - rawset = rawset, - require = require, - setfenv = setfenv, - setmetatable = setmetatable, - tonumber = tonumber, - tostring = tostring, - type = type, - unpack = unpack, - _VERSION = _VERSION, - xpcall = xpcall, - - table = table, - io = io, - os = os, - posix = posix, - string = string, - debug = debug, - loadlib = loadlib, - - pm = _G, - node = node, - - PARENT = PARENT, - EMPTY = EMPTY, - REDIRECT = REDIRECT, -}) - --- Cause any reads from undefined keys in the sandbox to fail with an error. --- This helps debugging pmfiles somewhat. - -setmetatable(sandbox, { - __index = function(self, key) - local value = rawget(self, key) - if (value == nil) then - error(key.." could not be found in any applicable scope") - end - return value - end -}) - --- Switch into sandbox mode. - -setfenv(1, sandbox) - ---- Assorted utilities ------------------------------------------------------ - --- Includes a file. - -function include(f, ...) - local c, e = loadfile(f) - if not c then - usererror("script compilation error: ", e) - end - - setfenv(c, sandbox) - local arguments = arg - xpcall( - function() - c(unpack(arguments)) - end, - function(e) - message("script execution error --- traceback follows:") - traceback(e) - end - ) -end - ---- file -------------------------------------------------------------------- - --- file() is pretty much the simplest clause. It takes a list of filenames, --- and outputs them. --- --- * Building does nothing. --- * Its outputs are its inputs. --- --- Note: this clause only takes *strings* as its children. If a reference is --- made to a file that doesn't exist, an error occurs. - -file = node { - class = "file", - ensure_at_least_one_child = true, - - __init = function(self, p) - node.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- Ensure that the file's children are strings. - - for i, j in ipairs(self) do - if (type(j) ~= "string") then - self:__error("doesn't know what to do with child ", i, - ", which is a ", type(j)) - end - end - end, - - -- File's timestamp is special and will bail if it meets a nonexistant file. - - __timestamp = function(self, inputs, outputs) - local t = 0 - for _, i in ipairs(outputs) do - i = self:__expand(i) - local tt = filetime(i) - if (tt == 0) then - self:__error("is referring to the file '", i, "' which does not exist") - end - if (tt > t) then - t = tt - end - end - return t - end, - - -- Outputs are inputs. - - __outputs = function(self, inputs) - local o = {} - local n - if self.only_n_children_are_outputs then - n = self.only_n_children_are_outputs - else - n = table_getn(inputs) - end - - for i = 1, n do - o[i] = inputs[i] - end - - return o - end, - - -- Building children does nothing; outputs are inputs. - - __buildchildren = function(self) - local outputs = {} - table_append(outputs, self) - return outputs - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - ---- group ------------------------------------------------------------------- - --- group() is also the simplest clause. It does nothing, existing only to --- group together its children. - -group = node { - class = "group", - - -- Outputs are inputs. - - __outputs = function(self, inputs) - return inputs - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - ---- deponly ----------------------------------------------------------------- - --- deponly() is the one-and-a-halfth most simplest clause. It acts like --- group {}, but returns no outputs. It's useful for ensuring that building --- one node causes another node to be built without actually using the --- second node's outputs. - -deponly = node { - class = "deponly", - ensure_at_least_one_child = true, - - -- Emits no outputs - - __outputs = function(self, inputs) - return {} - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - ---- ith --------------------------------------------------------------------- - --- ith() is the second simplest clause. It acts like group {}, but returns --- only some of the specified output. It is suitable for extracting, say, --- one output from a clause to pass to cfile {}. - -ith = node { - class = "ith", - ensure_at_least_one_child = true, - - __init = function(self, p) - node.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- If we have an i property, ensure we don't have a from or - -- to property. - - if self.i then - if self.from or self.to then - self:__error("can't have both an i property and a from or to property") - end - - if (type(self.i) ~= "number") then - self:__error("doesn't know what to do with its i property, ", - "which is a ", type(self.i), " where a number was expected") - end - - self.from = self.i - self.to = self.i - end - - -- Ensure the from and to properties are numbers, if they exist. - - if self.from then - if (type(self.from) ~= "number") then - self:__error("doesn't know what to do with its from property, ", - "which is a ", type(self.from), " where a number was expected") - end - end - - if self.to then - if (type(self.to) ~= "number") then - self:__error("doesn't know what to do with its to property, ", - "which is a ", type(self.to), " where a number was expected") - end - end - end, - - -- Emits one output, which is one of the inputs. - - __outputs = function(self, inputs) - local n = table_getn(inputs) - local from = self.from or 1 - local to = self.to or n - - if (from < 1) or (to > n) then - self:__error("tried to select range ", from, " to ", to, - " from only ", n, " inputs") - end - - local range = {} - for i = from, to do - table_append(range, inputs[i]) - end - return range - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - - ---- foreach ----------------------------------------------------------------- - --- foreach {} is the counterpart to ith {}. It applies a particular rule to --- all of its children. - -foreach = node { - class = "foreach", - - __init = function(self, p) - node.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- Ensure we have a rule property which is a table. - - if not self.rule then - self:__error("must have a rule property") - end - if (type(self.rule) ~= "table") then - self:__error("doesn't know what to do with its rule property, ", - "which is a ", type(self.rule), " where a table was expected") - end - end, - - -- Build all our children via the rule. - -- - -- This is pretty much a copy of node.__buildchildren(). - - __buildchildren = function(self) - scope = {object=self, next=scope} - - local intermediate = {} - for _, i in ipairs(self) do - table_append(intermediate, i:__build()) - end - - local inputs = {} - for _, i in ipairs(intermediate) do - local r = self.rule { i } - table_append(inputs, r:__build()) - end - - self:__buildadditionalchildren() - scope = scope.next - return inputs - end, - - -- Inputs are outputs --- because __buildchildren has already done the - -- necessary work. - - __outputs = function(self, inputs) - return inputs - end, - - -- Building does nothing. - - __dobuild = function(self, inputs, outputs) - end, -} - ---- Simple --------------------------------------------------------------- - --- simple is the most common clause, and implements make-like behaviour: --- the named command is executed in order to rebuild the node. --- --- * The timestamp is the newest timestamp of its outputs. --- * Building executes the command. --- * Its outputs are automatically generated by expanding the templates --- in the 'outputs' variable. - -simple = node { - class = "file", - construct_string_children_with = file, - all_children_are_objects = true, - - __init = function(self, p) - node.__init(self, p) - - -- If we're a class, don't verify. - - if ((type(p) == "table") and p.class) then - return - end - - -- outputs must exist, and must be a table. - - if not self.outputs then - self:__error("must have an outputs template set") - end - - if (type(self.outputs) ~= "table") then - self:__error("doesn't know what to do with its outputs, which is a ", - type(self.outputs), " but should be a table") - end - - -- There must be a command which must be a string or table. - - if not self.command then - self:__error("must have a command specified") - end - if (type(self.command) == "string") then - self.command = {self.command} - end - if (type(self.command) ~= "table") then - self:__error("doesn't know what to do with its command, which is a ", - type(self.command), " but should be a string or a table") - end - end, - - -- Outputs are specified manually. - - __outputs = function(self, inputs) - self["in"] = inputs - - local input - if inputs then - input = inputs[1] - end - if not input then - input = "" - end - - self.I = string_gsub(input, "^.*/", "") - self.I = string_gsub(self.I, "%..-$", "") - - -- Construct an outputs array for use in the cache key. This mirrors - -- what the final array will be, but the unique ID is going to be 0. - - self.out = {} - self.U = 0 - for _, i in ipairs(self.outputs) do - i = self:__expand(i) - table_append(self.out, i) - end - - -- Determine the cache key we're going to use. - - local cachekey = table_concat(self.command, " && ") - cachekey = self:__expand(cachekey) - cachekey = create_intermediate_cache_key(cachekey) - - -- Work out the unique ID. - -- - -- Note: we're running in the sandbox, so we need to fully qualify - -- pm.intermediate_cache_dir. - - self.U = pm.intermediate_cache_dir..cachekey - - -- Construct the real outputs array. - - self.out = {} - for _, i in ipairs(self.outputs) do - i = self:__expand(i) - mkcontainerdir(i) - table_append(self.out, i) - end - - return self.out - end, - - -- Building causes the command to be expanded and invoked. The 'children' - -- variable is set to the input files. - - __dobuild = function(self, inputs, outputs) - self["in"] = inputs - self.out = outputs - local r = self:__invoke(self.command, inputs, outputs) - if r then - if delete_output_files_on_error then - self:__invoke({"%RM% %out%"}) - end - self:__error("failed to build with return code ", r) - end - end, -} - ---- End of prologue --------------------------------------------------------- - --- Set a few useful global variables. - -RM = "rm -f" -INSTALL = "ln -f" - --- Now we're done, switch out of sandbox mode again. This only works --- because we made _G local at the top of the file, which makes it --- lexically scoped rather than looked up via the environment. - -setfenv(1, _G) - --- ======================================================================= -- --- APPLICATION DRIVER -- --- ======================================================================= -- - --- Parse and process the command line options. - -do - local function do_help(opt) - message("Prime Mover version ", VERSION, " © 2006 David Given") - stdout:write([[ -Syntax: pm [] [] -Options: - -h --help Displays this message. - --license List Prime Mover's redistribution license. - -cX --cachedir X Sets the object file cache to directory X. - -p --purge Purges the cache before execution. - WARNING: will remove *everything* in the cache dir! - -fX --file X Reads in the pmfile X. May be specified multiple times. - -DX=Y --define X=Y Defines variable X to value Y (or true if Y omitted) - -n --no-execute Don't actually execute anything - -v --verbose Be more verbose - -q --quiet Be more quiet - -If no pmfiles are explicitly specified, 'pmfile' is read. -If no targets are explicitly specified, 'default' is built. -Options and targets may be specified in any order. -]]) - os.exit(0) - end - - local function do_license(opt) - message("Prime Mover version ", VERSION, " © 2006 David Given") - stdout:write([[ - -Prime Mover is licensed under the MIT open source license. - -Copyright © 2006 David Given - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -]]) - os.exit(0) - end - - local function needarg(opt) - if not opt then - usererror("missing option parameter") - end - end - - local function do_cachedir(opt) - needarg(opt) - intermediate_cache_dir = opt - return 1 - end - - local function do_inputfile(opt) - needarg(opt) - table_append(input_files, opt) - return 1 - end - - local function do_purgecache(opt) - purge_intermediate_cache = true - return 0 - end - - local function do_define(opt) - needarg(opt) - - local s, e, key, value = string_find(opt, "^([^=]*)=(.*)$") - if not key then - key = opt - value = true - end - - sandbox[key] = value - return 1 - end - - local function do_no_execute(opt) - no_execute = true - return 0 - end - - local function do_verbose(opt) - verbose = true - return 0 - end - - local function do_quiet(opt) - quiet = true - return 0 - end - - local argmap = { - ["h"] = do_help, - ["help"] = do_help, - ["c"] = do_cachedir, - ["cachedir"] = do_cachedir, - ["p"] = do_purgecache, - ["purge"] = do_purgecache, - ["f"] = do_inputfile, - ["file"] = do_inputfile, - ["D"] = do_define, - ["define"] = do_define, - ["n"] = do_no_execute, - ["no-execute"] = do_no_execute, - ["v"] = do_verbose, - ["verbose"] = do_verbose, - ["q"] = do_quiet, - ["quiet"] = do_quiet, - ["license"] = do_license, - } - - -- Called on an unrecognised option. - - local function unrecognisedarg(arg) - usererror("unrecognised option '", arg, "' --- try --help for help") - end - - -- Do the actual argument parsing. - - for i = 1, table_getn(arg) do - local o = arg[i] - local op - - if (string_byte(o, 1) == 45) then - -- This is an option. - if (string_byte(o, 2) == 45) then - -- ...with a -- prefix. - o = string_sub(o, 3) - local fn = argmap[o] - if not fn then - unrecognisedarg("--"..o) - end - local op = arg[i+1] - i = i + fn(op) - else - -- ...without a -- prefix. - local od = string_sub(o, 2, 2) - local fn = argmap[od] - if not fn then - unrecognisedarg("-"..od) - end - op = string_sub(o, 3) - if (op == "") then - op = arg[i+1] - i = i + fn(op) - else - fn(op) - end - end - else - -- This is a target name. - table_append(targets, o) - end - end - - -- Option fallbacks. - - if (table_getn(input_files) == 0) then - input_files = {"pmfile"} - end - - if (table_getn(targets) == 0) then - targets = {"default"} - end -end - --- Load any input files. - -for _, i in ipairs(input_files) do - sandbox.include(i, unpack(arg)) -end - --- Set up the intermediate cache. - -if purge_intermediate_cache then - create_intermediate_cache() -else - load_intermediate_cache() -end - --- Build any targets. - -for _, i in ipairs(targets) do - local o = sandbox[i] - if not o then - usererror("don't know how to build '", i, "'") - end - if ((type(o) ~= "table") and not o.class) then - usererror("'", i, "' doesn't seem to be a valid target") - end - - xpcall( - function() - o:__build() - end, - function(e) - message("rule engine execution error --- traceback follows:") - traceback(e) - end - ) -end - -XXXXSTARTinterpreter -253583 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#line 1 "lapi.c" -#define lapi_c -#line 1 "lua.h" -#ifndef lua_h -#define lua_h -#define LUA_NUMBER int -#define LUA_NUMBER_SCAN "%d" -#define LUA_NUMBER_FMT "%d" -#define LUA_VERSION "Lua 5.0.2 (patched for Prime Mover)" -#define LUA_COPYRIGHT "Copyright (C) 1994-2004 Tecgraf, PUC-Rio" -#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" -#define LUA_MULTRET (-1) -#define LUA_REGISTRYINDEX (-10000) -#define LUA_GLOBALSINDEX (-10001) -#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) -#define LUA_ERRRUN 1 -#define LUA_ERRFILE 2 -#define LUA_ERRSYNTAX 3 -#define LUA_ERRMEM 4 -#define LUA_ERRERR 5 -typedef struct lua_State lua_State;typedef int(*lua_CFunction)(lua_State*L); -typedef const char*(*lua_Chunkreader)(lua_State*L,void*ud,size_t*sz);typedef -int(*lua_Chunkwriter)(lua_State*L,const void*p,size_t sz,void*ud); -#define LUA_TNONE (-1) -#define LUA_TNIL 0 -#define LUA_TBOOLEAN 1 -#define LUA_TLIGHTUSERDATA 2 -#define LUA_TNUMBER 3 -#define LUA_TSTRING 4 -#define LUA_TTABLE 5 -#define LUA_TFUNCTION 6 -#define LUA_TUSERDATA 7 -#define LUA_TTHREAD 8 -#define LUA_MINSTACK 20 -#ifdef LUA_USER_H -#include LUA_USER_H -#endif -#ifndef LUA_NUMBER -typedef double lua_Number; -#else -typedef LUA_NUMBER lua_Number; -#endif -#ifndef LUA_API -#define LUA_API extern -#endif -LUA_API lua_State*lua_open(void);LUA_API void lua_close(lua_State*L);LUA_API -lua_State*lua_newthread(lua_State*L);LUA_API lua_CFunction lua_atpanic( -lua_State*L,lua_CFunction panicf);LUA_API int lua_gettop(lua_State*L);LUA_API -void lua_settop(lua_State*L,int idx);LUA_API void lua_pushvalue(lua_State*L, -int idx);LUA_API void lua_remove(lua_State*L,int idx);LUA_API void lua_insert( -lua_State*L,int idx);LUA_API void lua_replace(lua_State*L,int idx);LUA_API int - lua_checkstack(lua_State*L,int sz);LUA_API void lua_xmove(lua_State*from, -lua_State*to,int n);LUA_API int lua_isnumber(lua_State*L,int idx);LUA_API int -lua_isstring(lua_State*L,int idx);LUA_API int lua_iscfunction(lua_State*L,int -idx);LUA_API int lua_isuserdata(lua_State*L,int idx);LUA_API int lua_type( -lua_State*L,int idx);LUA_API const char*lua_typename(lua_State*L,int tp); -LUA_API int lua_equal(lua_State*L,int idx1,int idx2);LUA_API int lua_rawequal( -lua_State*L,int idx1,int idx2);LUA_API int lua_lessthan(lua_State*L,int idx1, -int idx2);LUA_API lua_Number lua_tonumber(lua_State*L,int idx);LUA_API int -lua_toboolean(lua_State*L,int idx);LUA_API const char*lua_tostring(lua_State*L -,int idx);LUA_API size_t lua_strlen(lua_State*L,int idx);LUA_API lua_CFunction - lua_tocfunction(lua_State*L,int idx);LUA_API void*lua_touserdata(lua_State*L, -int idx);LUA_API lua_State*lua_tothread(lua_State*L,int idx);LUA_API const -void*lua_topointer(lua_State*L,int idx);LUA_API void lua_pushnil(lua_State*L); -LUA_API void lua_pushnumber(lua_State*L,lua_Number n);LUA_API void -lua_pushlstring(lua_State*L,const char*s,size_t l);LUA_API void lua_pushstring -(lua_State*L,const char*s);LUA_API const char*lua_pushvfstring(lua_State*L, -const char*fmt,va_list argp);LUA_API const char*lua_pushfstring(lua_State*L, -const char*fmt,...);LUA_API void lua_pushcclosure(lua_State*L,lua_CFunction fn -,int n);LUA_API void lua_pushboolean(lua_State*L,int b);LUA_API void -lua_pushlightuserdata(lua_State*L,void*p);LUA_API void lua_gettable(lua_State* -L,int idx);LUA_API void lua_rawget(lua_State*L,int idx);LUA_API void -lua_rawgeti(lua_State*L,int idx,int n);LUA_API void lua_newtable(lua_State*L); -LUA_API void*lua_newuserdata(lua_State*L,size_t sz);LUA_API int -lua_getmetatable(lua_State*L,int objindex);LUA_API void lua_getfenv(lua_State* -L,int idx);LUA_API void lua_settable(lua_State*L,int idx);LUA_API void -lua_rawset(lua_State*L,int idx);LUA_API void lua_rawseti(lua_State*L,int idx, -int n);LUA_API int lua_setmetatable(lua_State*L,int objindex);LUA_API int -lua_setfenv(lua_State*L,int idx);LUA_API void lua_call(lua_State*L,int nargs, -int nresults);LUA_API int lua_pcall(lua_State*L,int nargs,int nresults,int -errfunc);LUA_API int lua_cpcall(lua_State*L,lua_CFunction func,void*ud); -LUA_API int lua_load(lua_State*L,lua_Chunkreader reader,void*dt,const char* -chunkname);LUA_API int lua_dump(lua_State*L,lua_Chunkwriter writer,void*data); -LUA_API int lua_yield(lua_State*L,int nresults);LUA_API int lua_resume( -lua_State*L,int narg);LUA_API int lua_getgcthreshold(lua_State*L);LUA_API int -lua_getgccount(lua_State*L);LUA_API void lua_setgcthreshold(lua_State*L,int -newthreshold);LUA_API const char*lua_version(void);LUA_API int lua_error( -lua_State*L);LUA_API int lua_next(lua_State*L,int idx);LUA_API void lua_concat -(lua_State*L,int n); -#define lua_boxpointer(L,u) (*(void**)(lua_newuserdata(L,sizeof(void*)))=(u)) -#define lua_unboxpointer(L,i) (*(void**)(lua_touserdata(L,i))) -#define lua_pop(L,n) lua_settop(L,-(n)-1) -#define lua_register(L,n,f) (lua_pushstring(L,n),lua_pushcfunction(L,f),\ -lua_settable(L,LUA_GLOBALSINDEX)) -#define lua_pushcfunction(L,f) lua_pushcclosure(L,f,0) -#define lua_isfunction(L,n) (lua_type(L,n)==LUA_TFUNCTION) -#define lua_istable(L,n) (lua_type(L,n)==LUA_TTABLE) -#define lua_islightuserdata(L,n) (lua_type(L,n)==LUA_TLIGHTUSERDATA) -#define lua_isnil(L,n) (lua_type(L,n)==LUA_TNIL) -#define lua_isboolean(L,n) (lua_type(L,n)==LUA_TBOOLEAN) -#define lua_isnone(L,n) (lua_type(L,n)==LUA_TNONE) -#define lua_isnoneornil(L, n)(lua_type(L,n)<=0) -#define lua_pushliteral(L, s)lua_pushlstring(L,""s,(sizeof(s)/sizeof(char))-1) -LUA_API int lua_pushupvalues(lua_State*L); -#define lua_getregistry(L) lua_pushvalue(L,LUA_REGISTRYINDEX) -#define lua_setglobal(L,s) (lua_pushstring(L,s),lua_insert(L,-2),lua_settable(\ -L,LUA_GLOBALSINDEX)) -#define lua_getglobal(L,s) (lua_pushstring(L,s),lua_gettable(L,\ -LUA_GLOBALSINDEX)) -#define LUA_NOREF (-2) -#define LUA_REFNIL (-1) -#define lua_ref(L,lock) ((lock)?luaL_ref(L,LUA_REGISTRYINDEX):(lua_pushstring(\ -L,"unlocked references are obsolete"),lua_error(L),0)) -#define lua_unref(L,ref) luaL_unref(L,LUA_REGISTRYINDEX,(ref)) -#define lua_getref(L,ref) lua_rawgeti(L,LUA_REGISTRYINDEX,ref) -#ifndef LUA_NUMBER_SCAN -#define LUA_NUMBER_SCAN "%lf" -#endif -#ifndef LUA_NUMBER_FMT -#define LUA_NUMBER_FMT "%.14g" -#endif -#define LUA_HOOKCALL 0 -#define LUA_HOOKRET 1 -#define LUA_HOOKLINE 2 -#define LUA_HOOKCOUNT 3 -#define LUA_HOOKTAILRET 4 -#define LUA_MASKCALL (1<2147483640L -#define BITS_INT 32 -#else -#error "you must define BITS_INT with number of bits in an integer" -#endif -#endif -#endif -typedef unsigned int lu_hash;typedef int ls_hash;typedef unsigned long lu_mem; -#define MAX_LUMEM ULONG_MAX -typedef long ls_nstr;typedef unsigned char lu_byte; -#define MAX_SIZET ((size_t)(~(size_t)0)-2) -#define MAX_INT (INT_MAX-2) -#define IntPoint(p) ((lu_hash)(p)) -#ifndef LUSER_ALIGNMENT_T -typedef union{double u;void*s;long l;}L_Umaxalign; -#else -typedef LUSER_ALIGNMENT_T L_Umaxalign; -#endif -#ifndef LUA_UACNUMBER -typedef double l_uacNumber; -#else -typedef LUA_UACNUMBER l_uacNumber; -#endif -#ifndef lua_assert -#define lua_assert(c) -#endif -#ifndef check_exp -#define check_exp(c,e) (e) -#endif -#ifndef UNUSED -#define UNUSED(x) ((void)(x)) -#endif -#ifndef cast -#define cast(t, exp)((t)(exp)) -#endif -typedef unsigned long Instruction; -#ifndef LUA_MAXCALLS -#define LUA_MAXCALLS 4096 -#endif -#ifndef LUA_MAXCCALLS -#define LUA_MAXCCALLS 200 -#endif -#ifndef LUA_MAXCSTACK -#define LUA_MAXCSTACK 2048 -#endif -#define MAXSTACK 250 -#ifndef MAXVARS -#define MAXVARS 200 -#endif -#ifndef MAXUPVALUES -#define MAXUPVALUES 32 -#endif -#ifndef MAXPARAMS -#define MAXPARAMS 100 -#endif -#ifndef MINSTRTABSIZE -#define MINSTRTABSIZE 32 -#endif -#ifndef LUA_MINBUFFER -#define LUA_MINBUFFER 32 -#endif -#ifndef LUA_MAXPARSERLEVEL -#define LUA_MAXPARSERLEVEL 200 -#endif -#endif -#line 12 "lobject.h" -#define NUM_TAGS LUA_TTHREAD -#define LUA_TPROTO (NUM_TAGS+1) -#define LUA_TUPVAL (NUM_TAGS+2) -typedef union GCObject GCObject; -#define CommonHeader GCObject*next;lu_byte tt;lu_byte marked -typedef struct GCheader{CommonHeader;}GCheader;typedef union{GCObject*gc;void* -p;lua_Number n;int b;}Value;typedef struct lua_TObject{int tt;Value value;} -TObject; -#define ttisnil(o) (ttype(o)==LUA_TNIL) -#define ttisnumber(o) (ttype(o)==LUA_TNUMBER) -#define ttisstring(o) (ttype(o)==LUA_TSTRING) -#define ttistable(o) (ttype(o)==LUA_TTABLE) -#define ttisfunction(o) (ttype(o)==LUA_TFUNCTION) -#define ttisboolean(o) (ttype(o)==LUA_TBOOLEAN) -#define ttisuserdata(o) (ttype(o)==LUA_TUSERDATA) -#define ttisthread(o) (ttype(o)==LUA_TTHREAD) -#define ttislightuserdata(o) (ttype(o)==LUA_TLIGHTUSERDATA) -#define ttype(o) ((o)->tt) -#define gcvalue(o) check_exp(iscollectable(o),(o)->value.gc) -#define pvalue(o) check_exp(ttislightuserdata(o),(o)->value.p) -#define nvalue(o) check_exp(ttisnumber(o),(o)->value.n) -#define tsvalue(o) check_exp(ttisstring(o),&(o)->value.gc->ts) -#define uvalue(o) check_exp(ttisuserdata(o),&(o)->value.gc->u) -#define clvalue(o) check_exp(ttisfunction(o),&(o)->value.gc->cl) -#define hvalue(o) check_exp(ttistable(o),&(o)->value.gc->h) -#define bvalue(o) check_exp(ttisboolean(o),(o)->value.b) -#define thvalue(o) check_exp(ttisthread(o),&(o)->value.gc->th) -#define l_isfalse(o) (ttisnil(o)||(ttisboolean(o)&&bvalue(o)==0)) -#define setnvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TNUMBER;i_o->value.n=(\ -x);} -#define chgnvalue(obj,x) check_exp(ttype(obj)==LUA_TNUMBER,(obj)->value.n=(x)) -#define setpvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TLIGHTUSERDATA;i_o->\ -value.p=(x);} -#define setbvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TBOOLEAN;i_o->value.b=\ -(x);} -#define setsvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TSTRING;i_o->value.gc=\ -cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TSTRING);} -#define setuvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TUSERDATA;i_o->value.\ -gc=cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TUSERDATA);} -#define setthvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TTHREAD;i_o->value.gc\ -=cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TTHREAD);} -#define setclvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TFUNCTION;i_o->value.\ -gc=cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TFUNCTION);} -#define sethvalue(obj,x) {TObject*i_o=(obj);i_o->tt=LUA_TTABLE;i_o->value.gc=\ -cast(GCObject*,(x));lua_assert(i_o->value.gc->gch.tt==LUA_TTABLE);} -#define setnilvalue(obj) ((obj)->tt=LUA_TNIL) -#define checkconsistency(obj) lua_assert(!iscollectable(obj)||(ttype(obj)==(\ -obj)->value.gc->gch.tt)) -#define setobj(obj1,obj2) {const TObject*o2=(obj2);TObject*o1=(obj1);\ -checkconsistency(o2);o1->tt=o2->tt;o1->value=o2->value;} -#define setobjs2s setobj -#define setobj2s setobj -#define setsvalue2s setsvalue -#define setobjt2t setobj -#define setobj2t setobj -#define setobj2n setobj -#define setsvalue2n setsvalue -#define setttype(obj, tt)(ttype(obj)=(tt)) -#define iscollectable(o) (ttype(o)>=LUA_TSTRING) -typedef TObject*StkId;typedef union TString{L_Umaxalign dummy;struct{ -CommonHeader;lu_byte reserved;lu_hash hash;size_t len;}tsv;}TString; -#define getstr(ts) cast(const char*,(ts)+1) -#define svalue(o) getstr(tsvalue(o)) -typedef union Udata{L_Umaxalign dummy;struct{CommonHeader;struct Table* -metatable;size_t len;}uv;}Udata;typedef struct Proto{CommonHeader;TObject*k; -Instruction*code;struct Proto**p;int*lineinfo;struct LocVar*locvars;TString** -upvalues;TString*source;int sizeupvalues;int sizek;int sizecode;int -sizelineinfo;int sizep;int sizelocvars;int lineDefined;GCObject*gclist;lu_byte - nups;lu_byte numparams;lu_byte is_vararg;lu_byte maxstacksize;}Proto;typedef -struct LocVar{TString*varname;int startpc;int endpc;}LocVar;typedef struct -UpVal{CommonHeader;TObject*v;TObject value;}UpVal; -#define ClosureHeader CommonHeader;lu_byte isC;lu_byte nupvalues;GCObject*\ -gclist -typedef struct CClosure{ClosureHeader;lua_CFunction f;TObject upvalue[1];} -CClosure;typedef struct LClosure{ClosureHeader;struct Proto*p;TObject g;UpVal* -upvals[1];}LClosure;typedef union Closure{CClosure c;LClosure l;}Closure; -#define iscfunction(o) (ttype(o)==LUA_TFUNCTION&&clvalue(o)->c.isC) -#define isLfunction(o) (ttype(o)==LUA_TFUNCTION&&!clvalue(o)->c.isC) -typedef struct Node{TObject i_key;TObject i_val;struct Node*next;}Node;typedef - struct Table{CommonHeader;lu_byte flags;lu_byte lsizenode;struct Table* -metatable;TObject*array;Node*node;Node*firstfree;GCObject*gclist;int sizearray -;}Table; -#define lmod(s,size) check_exp((size&(size-1))==0,(cast(int,(s)&((size)-1)))) -#define twoto(x) (1<<(x)) -#define sizenode(t) (twoto((t)->lsizenode)) -extern const TObject luaO_nilobject;int luaO_log2(unsigned int x);int -luaO_int2fb(unsigned int x); -#define fb2int(x) (((x)&7)<<((x)>>3)) -int luaO_rawequalObj(const TObject*t1,const TObject*t2);int luaO_str2d(const -char*s,lua_Number*result);const char*luaO_pushvfstring(lua_State*L,const char* -fmt,va_list argp);const char*luaO_pushfstring(lua_State*L,const char*fmt,...); -void luaO_chunkid(char*out,const char*source,int len); -#endif -#line 12 "lapi.h" -void luaA_pushobject(lua_State*L,const TObject*o); -#endif -#line 16 "lapi.c" -#line 1 "ldebug.h" -#ifndef ldebug_h -#define ldebug_h -#line 1 "lstate.h" -#ifndef lstate_h -#define lstate_h -#line 1 "ltm.h" -#ifndef ltm_h -#define ltm_h -typedef enum{TM_INDEX,TM_NEWINDEX,TM_GC,TM_MODE,TM_EQ,TM_ADD,TM_SUB,TM_MUL, -TM_DIV,TM_POW,TM_UNM,TM_LT,TM_LE,TM_CONCAT,TM_CALL,TM_N}TMS; -#define gfasttm(g,et,e) (((et)->flags&(1u<<(e)))?NULL:luaT_gettm(et,e,(g)->\ -tmname[e])) -#define fasttm(l,et,e) gfasttm(G(l),et,e) -const TObject*luaT_gettm(Table*events,TMS event,TString*ename);const TObject* -luaT_gettmbyobj(lua_State*L,const TObject*o,TMS event);void luaT_init( -lua_State*L);extern const char*const luaT_typenames[]; -#endif -#line 14 "lstate.h" -#line 1 "lzio.h" -#ifndef lzio_h -#define lzio_h -#define EOZ (-1) -typedef struct Zio ZIO; -#define char2int(c) cast(int,cast(unsigned char,(c))) -#define zgetc(z) (((z)->n--)>0?char2int(*(z)->p++):luaZ_fill(z)) -#define zname(z) ((z)->name) -void luaZ_init(ZIO*z,lua_Chunkreader reader,void*data,const char*name);size_t -luaZ_read(ZIO*z,void*b,size_t n);int luaZ_lookahead(ZIO*z);typedef struct -Mbuffer{char*buffer;size_t buffsize;}Mbuffer;char*luaZ_openspace(lua_State*L, -Mbuffer*buff,size_t n); -#define luaZ_initbuffer(L, buff)((buff)->buffer=NULL,(buff)->buffsize=0) -#define luaZ_sizebuffer(buff) ((buff)->buffsize) -#define luaZ_buffer(buff) ((buff)->buffer) -#define luaZ_resizebuffer(L, buff,size)(luaM_reallocvector(L,(buff)->buffer,(\ -buff)->buffsize,size,char),(buff)->buffsize=size) -#define luaZ_freebuffer(L, buff)luaZ_resizebuffer(L,buff,0) -struct Zio{size_t n;const char*p;lua_Chunkreader reader;void*data;const char* -name;};int luaZ_fill(ZIO*z); -#endif -#line 15 "lstate.h" -#ifndef lua_lock -#define lua_lock(L) ((void)0) -#endif -#ifndef lua_unlock -#define lua_unlock(L) ((void)0) -#endif -#ifndef lua_userstateopen -#define lua_userstateopen(l) -#endif -struct lua_longjmp; -#define defaultmeta(L) (&G(L)->_defaultmeta) -#define gt(L) (&L->_gt) -#define registry(L) (&G(L)->_registry) -#define EXTRA_STACK 5 -#define BASIC_CI_SIZE 8 -#define BASIC_STACK_SIZE (2*LUA_MINSTACK) -typedef struct stringtable{GCObject**hash;ls_nstr nuse;int size;}stringtable; -typedef struct CallInfo{StkId base;StkId top;int state;union{struct{const -Instruction*savedpc;const Instruction**pc;int tailcalls;}l;struct{int dummy;}c -;}u;}CallInfo; -#define CI_C (1<<0) -#define CI_HASFRAME (1<<1) -#define CI_CALLING (1<<2) -#define CI_SAVEDPC (1<<3) -#define CI_YIELD (1<<4) -#define ci_func(ci) (clvalue((ci)->base-1)) -typedef struct global_State{stringtable strt;GCObject*rootgc;GCObject* -rootudata;GCObject*tmudata;Mbuffer buff;lu_mem GCthreshold;lu_mem nblocks; -lua_CFunction panic;TObject _registry;TObject _defaultmeta;struct lua_State* -mainthread;Node dummynode[1];TString*tmname[TM_N];}global_State;struct -lua_State{CommonHeader;StkId top;StkId base;global_State*l_G;CallInfo*ci;StkId - stack_last;StkId stack;int stacksize;CallInfo*end_ci;CallInfo*base_ci; -unsigned short size_ci;unsigned short nCcalls;lu_byte hookmask;lu_byte -allowhook;lu_byte hookinit;int basehookcount;int hookcount;lua_Hook hook; -TObject _gt;GCObject*openupval;GCObject*gclist;struct lua_longjmp*errorJmp; -ptrdiff_t errfunc;}; -#define G(L) (L->l_G) -union GCObject{GCheader gch;union TString ts;union Udata u;union Closure cl; -struct Table h;struct Proto p;struct UpVal uv;struct lua_State th;}; -#define gcotots(o) check_exp((o)->gch.tt==LUA_TSTRING,&((o)->ts)) -#define gcotou(o) check_exp((o)->gch.tt==LUA_TUSERDATA,&((o)->u)) -#define gcotocl(o) check_exp((o)->gch.tt==LUA_TFUNCTION,&((o)->cl)) -#define gcotoh(o) check_exp((o)->gch.tt==LUA_TTABLE,&((o)->h)) -#define gcotop(o) check_exp((o)->gch.tt==LUA_TPROTO,&((o)->p)) -#define gcotouv(o) check_exp((o)->gch.tt==LUA_TUPVAL,&((o)->uv)) -#define ngcotouv(o) check_exp((o)==NULL||(o)->gch.tt==LUA_TUPVAL,&((o)->uv)) -#define gcototh(o) check_exp((o)->gch.tt==LUA_TTHREAD,&((o)->th)) -#define valtogco(v) (cast(GCObject*,(v))) -lua_State*luaE_newthread(lua_State*L);void luaE_freethread(lua_State*L, -lua_State*L1); -#endif -#line 12 "ldebug.h" -#define pcRel(pc, p)(cast(int,(pc)-(p)->code)-1) -#define getline(f,pc) (((f)->lineinfo)?(f)->lineinfo[pc]:0) -#define resethookcount(L) (L->hookcount=L->basehookcount) -void luaG_inithooks(lua_State*L);void luaG_typeerror(lua_State*L,const TObject -*o,const char*opname);void luaG_concaterror(lua_State*L,StkId p1,StkId p2); -void luaG_aritherror(lua_State*L,const TObject*p1,const TObject*p2);int -luaG_ordererror(lua_State*L,const TObject*p1,const TObject*p2);void -luaG_runerror(lua_State*L,const char*fmt,...);void luaG_errormsg(lua_State*L); -int luaG_checkcode(const Proto*pt); -#endif -#line 17 "lapi.c" -#line 1 "ldo.h" -#ifndef ldo_h -#define ldo_h -#ifndef HARDSTACKTESTS -#define condhardstacktests(x) {} -#else -#define condhardstacktests(x) x -#endif -#define luaD_checkstack(L,n) if((char*)L->stack_last-(char*)L->top<=(n)*(int)\ -sizeof(TObject))luaD_growstack(L,n);else condhardstacktests(luaD_reallocstack(\ -L,L->stacksize)); -#define incr_top(L) {luaD_checkstack(L,1);L->top++;} -#define savestack(L,p) ((char*)(p)-(char*)L->stack) -#define restorestack(L,n) ((TObject*)((char*)L->stack+(n))) -#define saveci(L,p) ((char*)(p)-(char*)L->base_ci) -#define restoreci(L,n) ((CallInfo*)((char*)L->base_ci+(n))) -typedef void(*Pfunc)(lua_State*L,void*ud);void luaD_resetprotection(lua_State* -L);int luaD_protectedparser(lua_State*L,ZIO*z,int bin);void luaD_callhook( -lua_State*L,int event,int line);StkId luaD_precall(lua_State*L,StkId func); -void luaD_call(lua_State*L,StkId func,int nResults);int luaD_pcall(lua_State*L -,Pfunc func,void*u,ptrdiff_t oldtop,ptrdiff_t ef);void luaD_poscall(lua_State* -L,int wanted,StkId firstResult);void luaD_reallocCI(lua_State*L,int newsize); -void luaD_reallocstack(lua_State*L,int newsize);void luaD_growstack(lua_State* -L,int n);void luaD_throw(lua_State*L,int errcode);int luaD_rawrunprotected( -lua_State*L,Pfunc f,void*ud); -#endif -#line 18 "lapi.c" -#line 1 "lfunc.h" -#ifndef lfunc_h -#define lfunc_h -Proto*luaF_newproto(lua_State*L);Closure*luaF_newCclosure(lua_State*L,int -nelems);Closure*luaF_newLclosure(lua_State*L,int nelems,TObject*e);UpVal* -luaF_findupval(lua_State*L,StkId level);void luaF_close(lua_State*L,StkId -level);void luaF_freeproto(lua_State*L,Proto*f);void luaF_freeclosure( -lua_State*L,Closure*c);const char*luaF_getlocalname(const Proto*func,int -local_number,int pc); -#endif -#line 19 "lapi.c" -#line 1 "lgc.h" -#ifndef lgc_h -#define lgc_h -#define luaC_checkGC(L) {lua_assert(!(L->ci->state&CI_CALLING));if(G(L)->\ -nblocks>=G(L)->GCthreshold)luaC_collectgarbage(L);} -size_t luaC_separateudata(lua_State*L);void luaC_callGCTM(lua_State*L);void -luaC_sweep(lua_State*L,int all);void luaC_collectgarbage(lua_State*L);void -luaC_link(lua_State*L,GCObject*o,lu_byte tt); -#endif -#line 20 "lapi.c" -#line 1 "lmem.h" -#ifndef lmem_h -#define lmem_h -#define MEMERRMSG "not enough memory" -void*luaM_realloc(lua_State*L,void*oldblock,lu_mem oldsize,lu_mem size);void* -luaM_growaux(lua_State*L,void*block,int*size,int size_elem,int limit,const -char*errormsg); -#define luaM_free(L, b,s)luaM_realloc(L,(b),(s),0) -#define luaM_freelem(L, b)luaM_realloc(L,(b),sizeof(*(b)),0) -#define luaM_freearray(L, b,n,t)luaM_realloc(L,(b),cast(lu_mem,n)*cast(lu_mem,\ -sizeof(t)),0) -#define luaM_malloc(L, t)luaM_realloc(L,NULL,0,(t)) -#define luaM_new(L, t)cast(t*,luaM_malloc(L,sizeof(t))) -#define luaM_newvector(L, n,t)cast(t*,luaM_malloc(L,cast(lu_mem,n)*cast(lu_mem\ -,sizeof(t)))) -#define luaM_growvector(L,v,nelems,size,t,limit,e) if(((nelems)+1)>(size))((v)\ -=cast(t*,luaM_growaux(L,v,&(size),sizeof(t),limit,e))) -#define luaM_reallocvector(L, v,oldn,n,t)((v)=cast(t*,luaM_realloc(L,v,cast(\ -lu_mem,oldn)*cast(lu_mem,sizeof(t)),cast(lu_mem,n)*cast(lu_mem,sizeof(t))))) -#endif -#line 21 "lapi.c" -#line 1 "lstring.h" -#ifndef lstring_h -#define lstring_h -#define sizestring(l) (cast(lu_mem,sizeof(union TString))+(cast(lu_mem,l)+1)*\ -sizeof(char)) -#define sizeudata(l) (cast(lu_mem,sizeof(union Udata))+(l)) -#define luaS_new(L, s)(luaS_newlstr(L,s,strlen(s))) -#define luaS_newliteral(L, s)(luaS_newlstr(L,""s,(sizeof(s)/sizeof(char))-1)) -#define luaS_fix(s) ((s)->tsv.marked|=(1<<4)) -void luaS_resize(lua_State*L,int newsize);Udata*luaS_newudata(lua_State*L, -size_t s);void luaS_freeall(lua_State*L);TString*luaS_newlstr(lua_State*L, -const char*str,size_t l); -#endif -#line 24 "lapi.c" -#line 1 "ltable.h" -#ifndef ltable_h -#define ltable_h -#define gnode(t,i) (&(t)->node[i]) -#define gkey(n) (&(n)->i_key) -#define gval(n) (&(n)->i_val) -const TObject*luaH_getnum(Table*t,int key);TObject*luaH_setnum(lua_State*L, -Table*t,int key);const TObject*luaH_getstr(Table*t,TString*key);const TObject* -luaH_get(Table*t,const TObject*key);TObject*luaH_set(lua_State*L,Table*t,const - TObject*key);Table*luaH_new(lua_State*L,int narray,int lnhash);void luaH_free -(lua_State*L,Table*t);int luaH_next(lua_State*L,Table*t,StkId key);Node* -luaH_mainposition(const Table*t,const TObject*key); -#endif -#line 25 "lapi.c" -#line 1 "lundump.h" -#ifndef lundump_h -#define lundump_h -Proto*luaU_undump(lua_State*L,ZIO*Z,Mbuffer*buff);int luaU_endianness(void); -void luaU_dump(lua_State*L,const Proto*Main,lua_Chunkwriter w,void*data);void -luaU_print(const Proto*Main); -#define LUA_SIGNATURE "\033Lua" -#define VERSION 0x50 -#define VERSION0 0x50 -#define TEST_NUMBER ((lua_Number)3.14159265358979323846E7) -#endif -#line 27 "lapi.c" -#line 1 "lvm.h" -#ifndef lvm_h -#define lvm_h -#define tostring(L,o) ((ttype(o)==LUA_TSTRING)||(luaV_tostring(L,o))) -#define tonumber(o,n) (ttype(o)==LUA_TNUMBER||(((o)=luaV_tonumber(o,n))!=NULL)\ -) -#define equalobj(L,o1,o2) (ttype(o1)==ttype(o2)&&luaV_equalval(L,o1,o2)) -int luaV_lessthan(lua_State*L,const TObject*l,const TObject*r);int -luaV_equalval(lua_State*L,const TObject*t1,const TObject*t2);const TObject* -luaV_tonumber(const TObject*obj,TObject*n);int luaV_tostring(lua_State*L,StkId - obj);const TObject*luaV_gettable(lua_State*L,const TObject*t,TObject*key,int -loop);void luaV_settable(lua_State*L,const TObject*t,TObject*key,StkId val); -StkId luaV_execute(lua_State*L);void luaV_concat(lua_State*L,int total,int -last); -#endif -#line 28 "lapi.c" -const char lua_ident[]="$Lua: "LUA_VERSION" "LUA_COPYRIGHT" $\n""$Authors: " -LUA_AUTHORS" $\n""$URL: www.lua.org $\n"; -#ifndef api_check -#define api_check(L, o) -#endif -#define api_checknelems(L, n)api_check(L,(n)<=(L->top-L->base)) -#define api_incr_top(L) {api_check(L,L->topci->top);L->top++;} -static TObject*negindex(lua_State*L,int idx){if(idx>LUA_REGISTRYINDEX){ -api_check(L,idx!=0&&-idx<=L->top-L->base);return L->top+idx;}else switch(idx){ -case LUA_REGISTRYINDEX:return registry(L);case LUA_GLOBALSINDEX:return gt(L); -default:{TObject*func=(L->base-1);idx=LUA_GLOBALSINDEX-idx;lua_assert( -iscfunction(func));return(idx<=clvalue(func)->c.nupvalues)?&clvalue(func)->c. -upvalue[idx-1]:NULL;}}}static TObject*luaA_index(lua_State*L,int idx){if(idx>0 -){api_check(L,idx<=L->top-L->base);return L->base+idx-1;}else{TObject*o= -negindex(L,idx);api_check(L,o!=NULL);return o;}}static TObject* -luaA_indexAcceptable(lua_State*L,int idx){if(idx>0){TObject*o=L->base+(idx-1); -api_check(L,idx<=L->stack_last-L->base);if(o>=L->top)return NULL;else return o -;}else return negindex(L,idx);}void luaA_pushobject(lua_State*L,const TObject* -o){setobj2s(L->top,o);incr_top(L);}LUA_API int lua_checkstack(lua_State*L,int -size){int res;lua_lock(L);if((L->top-L->base+size)>LUA_MAXCSTACK)res=0;else{ -luaD_checkstack(L,size);if(L->ci->toptop+size)L->ci->top=L->top+size;res=1 -;}lua_unlock(L);return res;}LUA_API void lua_xmove(lua_State*from,lua_State*to -,int n){int i;lua_lock(to);api_checknelems(from,n);from->top-=n;for(i=0;itop,from->top+i);api_incr_top(to);}lua_unlock(to);}LUA_API -lua_CFunction lua_atpanic(lua_State*L,lua_CFunction panicf){lua_CFunction old; -lua_lock(L);old=G(L)->panic;G(L)->panic=panicf;lua_unlock(L);return old;} -LUA_API lua_State*lua_newthread(lua_State*L){lua_State*L1;lua_lock(L); -luaC_checkGC(L);L1=luaE_newthread(L);setthvalue(L->top,L1);api_incr_top(L); -lua_unlock(L);lua_userstateopen(L1);return L1;}LUA_API int lua_gettop( -lua_State*L){return(L->top-L->base);}LUA_API void lua_settop(lua_State*L,int -idx){lua_lock(L);if(idx>=0){api_check(L,idx<=L->stack_last-L->base);while(L-> -topbase+idx)setnilvalue(L->top++);L->top=L->base+idx;}else{api_check(L,-( -idx+1)<=(L->top-L->base));L->top+=idx+1;}lua_unlock(L);}LUA_API void -lua_remove(lua_State*L,int idx){StkId p;lua_lock(L);p=luaA_index(L,idx);while( -++ptop)setobjs2s(p-1,p);L->top--;lua_unlock(L);}LUA_API void lua_insert( -lua_State*L,int idx){StkId p;StkId q;lua_lock(L);p=luaA_index(L,idx);for(q=L-> -top;q>p;q--)setobjs2s(q,q-1);setobjs2s(p,L->top);lua_unlock(L);}LUA_API void -lua_replace(lua_State*L,int idx){lua_lock(L);api_checknelems(L,1);setobj( -luaA_index(L,idx),L->top-1);L->top--;lua_unlock(L);}LUA_API void lua_pushvalue -(lua_State*L,int idx){lua_lock(L);setobj2s(L->top,luaA_index(L,idx)); -api_incr_top(L);lua_unlock(L);}LUA_API int lua_type(lua_State*L,int idx){StkId - o=luaA_indexAcceptable(L,idx);return(o==NULL)?LUA_TNONE:ttype(o);}LUA_API -const char*lua_typename(lua_State*L,int t){UNUSED(L);return(t==LUA_TNONE)? -"no value":luaT_typenames[t];}LUA_API int lua_iscfunction(lua_State*L,int idx) -{StkId o=luaA_indexAcceptable(L,idx);return(o==NULL)?0:iscfunction(o);}LUA_API - int lua_isnumber(lua_State*L,int idx){TObject n;const TObject*o= -luaA_indexAcceptable(L,idx);return(o!=NULL&&tonumber(o,&n));}LUA_API int -lua_isstring(lua_State*L,int idx){int t=lua_type(L,idx);return(t==LUA_TSTRING -||t==LUA_TNUMBER);}LUA_API int lua_isuserdata(lua_State*L,int idx){const -TObject*o=luaA_indexAcceptable(L,idx);return(o!=NULL&&(ttisuserdata(o)|| -ttislightuserdata(o)));}LUA_API int lua_rawequal(lua_State*L,int index1,int -index2){StkId o1=luaA_indexAcceptable(L,index1);StkId o2=luaA_indexAcceptable( -L,index2);return(o1==NULL||o2==NULL)?0:luaO_rawequalObj(o1,o2);}LUA_API int -lua_equal(lua_State*L,int index1,int index2){StkId o1,o2;int i;lua_lock(L);o1= -luaA_indexAcceptable(L,index1);o2=luaA_indexAcceptable(L,index2);i=(o1==NULL|| -o2==NULL)?0:equalobj(L,o1,o2);lua_unlock(L);return i;}LUA_API int lua_lessthan -(lua_State*L,int index1,int index2){StkId o1,o2;int i;lua_lock(L);o1= -luaA_indexAcceptable(L,index1);o2=luaA_indexAcceptable(L,index2);i=(o1==NULL|| -o2==NULL)?0:luaV_lessthan(L,o1,o2);lua_unlock(L);return i;}LUA_API lua_Number -lua_tonumber(lua_State*L,int idx){TObject n;const TObject*o= -luaA_indexAcceptable(L,idx);if(o!=NULL&&tonumber(o,&n))return nvalue(o);else -return 0;}LUA_API int lua_toboolean(lua_State*L,int idx){const TObject*o= -luaA_indexAcceptable(L,idx);return(o!=NULL)&&!l_isfalse(o);}LUA_API const char -*lua_tostring(lua_State*L,int idx){StkId o=luaA_indexAcceptable(L,idx);if(o== -NULL)return NULL;else if(ttisstring(o))return svalue(o);else{const char*s; -lua_lock(L);s=(luaV_tostring(L,o)?svalue(o):NULL);luaC_checkGC(L);lua_unlock(L -);return s;}}LUA_API size_t lua_strlen(lua_State*L,int idx){StkId o= -luaA_indexAcceptable(L,idx);if(o==NULL)return 0;else if(ttisstring(o))return -tsvalue(o)->tsv.len;else{size_t l;lua_lock(L);l=(luaV_tostring(L,o)?tsvalue(o) -->tsv.len:0);lua_unlock(L);return l;}}LUA_API lua_CFunction lua_tocfunction( -lua_State*L,int idx){StkId o=luaA_indexAcceptable(L,idx);return(o==NULL||! -iscfunction(o))?NULL:clvalue(o)->c.f;}LUA_API void*lua_touserdata(lua_State*L, -int idx){StkId o=luaA_indexAcceptable(L,idx);if(o==NULL)return NULL;switch( -ttype(o)){case LUA_TUSERDATA:return(uvalue(o)+1);case LUA_TLIGHTUSERDATA: -return pvalue(o);default:return NULL;}}LUA_API lua_State*lua_tothread( -lua_State*L,int idx){StkId o=luaA_indexAcceptable(L,idx);return(o==NULL||! -ttisthread(o))?NULL:thvalue(o);}LUA_API const void*lua_topointer(lua_State*L, -int idx){StkId o=luaA_indexAcceptable(L,idx);if(o==NULL)return NULL;else{ -switch(ttype(o)){case LUA_TTABLE:return hvalue(o);case LUA_TFUNCTION:return -clvalue(o);case LUA_TTHREAD:return thvalue(o);case LUA_TUSERDATA:case -LUA_TLIGHTUSERDATA:return lua_touserdata(L,idx);default:return NULL;}}}LUA_API - void lua_pushnil(lua_State*L){lua_lock(L);setnilvalue(L->top);api_incr_top(L) -;lua_unlock(L);}LUA_API void lua_pushnumber(lua_State*L,lua_Number n){lua_lock -(L);setnvalue(L->top,n);api_incr_top(L);lua_unlock(L);}LUA_API void -lua_pushlstring(lua_State*L,const char*s,size_t len){lua_lock(L);luaC_checkGC( -L);setsvalue2s(L->top,luaS_newlstr(L,s,len));api_incr_top(L);lua_unlock(L);} -LUA_API void lua_pushstring(lua_State*L,const char*s){if(s==NULL)lua_pushnil(L -);else lua_pushlstring(L,s,strlen(s));}LUA_API const char*lua_pushvfstring( -lua_State*L,const char*fmt,va_list argp){const char*ret;lua_lock(L); -luaC_checkGC(L);ret=luaO_pushvfstring(L,fmt,argp);lua_unlock(L);return ret;} -LUA_API const char*lua_pushfstring(lua_State*L,const char*fmt,...){const char* -ret;va_list argp;lua_lock(L);luaC_checkGC(L);va_start(argp,fmt);ret= -luaO_pushvfstring(L,fmt,argp);va_end(argp);lua_unlock(L);return ret;}LUA_API -void lua_pushcclosure(lua_State*L,lua_CFunction fn,int n){Closure*cl;lua_lock( -L);luaC_checkGC(L);api_checknelems(L,n);cl=luaF_newCclosure(L,n);cl->c.f=fn;L -->top-=n;while(n--)setobj2n(&cl->c.upvalue[n],L->top+n);setclvalue(L->top,cl); -api_incr_top(L);lua_unlock(L);}LUA_API void lua_pushboolean(lua_State*L,int b) -{lua_lock(L);setbvalue(L->top,(b!=0));api_incr_top(L);lua_unlock(L);}LUA_API -void lua_pushlightuserdata(lua_State*L,void*p){lua_lock(L);setpvalue(L->top,p) -;api_incr_top(L);lua_unlock(L);}LUA_API void lua_gettable(lua_State*L,int idx) -{StkId t;lua_lock(L);t=luaA_index(L,idx);setobj2s(L->top-1,luaV_gettable(L,t,L -->top-1,0));lua_unlock(L);}LUA_API void lua_rawget(lua_State*L,int idx){StkId -t;lua_lock(L);t=luaA_index(L,idx);api_check(L,ttistable(t));setobj2s(L->top-1, -luaH_get(hvalue(t),L->top-1));lua_unlock(L);}LUA_API void lua_rawgeti( -lua_State*L,int idx,int n){StkId o;lua_lock(L);o=luaA_index(L,idx);api_check(L -,ttistable(o));setobj2s(L->top,luaH_getnum(hvalue(o),n));api_incr_top(L); -lua_unlock(L);}LUA_API void lua_newtable(lua_State*L){lua_lock(L);luaC_checkGC -(L);sethvalue(L->top,luaH_new(L,0,0));api_incr_top(L);lua_unlock(L);}LUA_API -int lua_getmetatable(lua_State*L,int objindex){const TObject*obj;Table*mt=NULL -;int res;lua_lock(L);obj=luaA_indexAcceptable(L,objindex);if(obj!=NULL){switch -(ttype(obj)){case LUA_TTABLE:mt=hvalue(obj)->metatable;break;case -LUA_TUSERDATA:mt=uvalue(obj)->uv.metatable;break;}}if(mt==NULL||mt==hvalue( -defaultmeta(L)))res=0;else{sethvalue(L->top,mt);api_incr_top(L);res=1;} -lua_unlock(L);return res;}LUA_API void lua_getfenv(lua_State*L,int idx){StkId -o;lua_lock(L);o=luaA_index(L,idx);setobj2s(L->top,isLfunction(o)?&clvalue(o)-> -l.g:gt(L));api_incr_top(L);lua_unlock(L);}LUA_API void lua_settable(lua_State* -L,int idx){StkId t;lua_lock(L);api_checknelems(L,2);t=luaA_index(L,idx); -luaV_settable(L,t,L->top-2,L->top-1);L->top-=2;lua_unlock(L);}LUA_API void -lua_rawset(lua_State*L,int idx){StkId t;lua_lock(L);api_checknelems(L,2);t= -luaA_index(L,idx);api_check(L,ttistable(t));setobj2t(luaH_set(L,hvalue(t),L-> -top-2),L->top-1);L->top-=2;lua_unlock(L);}LUA_API void lua_rawseti(lua_State*L -,int idx,int n){StkId o;lua_lock(L);api_checknelems(L,1);o=luaA_index(L,idx); -api_check(L,ttistable(o));setobj2t(luaH_setnum(L,hvalue(o),n),L->top-1);L->top ---;lua_unlock(L);}LUA_API int lua_setmetatable(lua_State*L,int objindex){ -TObject*obj,*mt;int res=1;lua_lock(L);api_checknelems(L,1);obj=luaA_index(L, -objindex);mt=(!ttisnil(L->top-1))?L->top-1:defaultmeta(L);api_check(L, -ttistable(mt));switch(ttype(obj)){case LUA_TTABLE:{hvalue(obj)->metatable= -hvalue(mt);break;}case LUA_TUSERDATA:{uvalue(obj)->uv.metatable=hvalue(mt); -break;}default:{res=0;break;}}L->top--;lua_unlock(L);return res;}LUA_API int -lua_setfenv(lua_State*L,int idx){StkId o;int res=0;lua_lock(L);api_checknelems -(L,1);o=luaA_index(L,idx);L->top--;api_check(L,ttistable(L->top));if( -isLfunction(o)){res=1;clvalue(o)->l.g=*(L->top);}lua_unlock(L);return res;} -LUA_API void lua_call(lua_State*L,int nargs,int nresults){StkId func;lua_lock( -L);api_checknelems(L,nargs+1);func=L->top-(nargs+1);luaD_call(L,func,nresults) -;lua_unlock(L);}struct CallS{StkId func;int nresults;};static void f_call( -lua_State*L,void*ud){struct CallS*c=cast(struct CallS*,ud);luaD_call(L,c->func -,c->nresults);}LUA_API int lua_pcall(lua_State*L,int nargs,int nresults,int -errfunc){struct CallS c;int status;ptrdiff_t func;lua_lock(L);func=(errfunc==0 -)?0:savestack(L,luaA_index(L,errfunc));c.func=L->top-(nargs+1);c.nresults= -nresults;status=luaD_pcall(L,f_call,&c,savestack(L,c.func),func);lua_unlock(L) -;return status;}struct CCallS{lua_CFunction func;void*ud;};static void f_Ccall -(lua_State*L,void*ud){struct CCallS*c=cast(struct CCallS*,ud);Closure*cl;cl= -luaF_newCclosure(L,0);cl->c.f=c->func;setclvalue(L->top,cl);incr_top(L); -setpvalue(L->top,c->ud);incr_top(L);luaD_call(L,L->top-2,0);}LUA_API int -lua_cpcall(lua_State*L,lua_CFunction func,void*ud){struct CCallS c;int status; -lua_lock(L);c.func=func;c.ud=ud;status=luaD_pcall(L,f_Ccall,&c,savestack(L,L-> -top),0);lua_unlock(L);return status;}LUA_API int lua_load(lua_State*L, -lua_Chunkreader reader,void*data,const char*chunkname){ZIO z;int status;int c; -lua_lock(L);if(!chunkname)chunkname="?";luaZ_init(&z,reader,data,chunkname);c= -luaZ_lookahead(&z);status=luaD_protectedparser(L,&z,(c==LUA_SIGNATURE[0])); -lua_unlock(L);return status;}LUA_API int lua_dump(lua_State*L,lua_Chunkwriter -writer,void*data){int status;TObject*o;lua_lock(L);api_checknelems(L,1);o=L-> -top-1;if(isLfunction(o)&&clvalue(o)->l.nupvalues==0){luaU_dump(L,clvalue(o)->l -.p,writer,data);status=1;}else status=0;lua_unlock(L);return status;} -#define GCscalel(x) ((x)>>10) -#define GCscale(x) (cast(int,GCscalel(x))) -#define GCunscale(x) (cast(lu_mem,x)<<10) -LUA_API int lua_getgcthreshold(lua_State*L){int threshold;lua_lock(L); -threshold=GCscale(G(L)->GCthreshold);lua_unlock(L);return threshold;}LUA_API -int lua_getgccount(lua_State*L){int count;lua_lock(L);count=GCscale(G(L)-> -nblocks);lua_unlock(L);return count;}LUA_API void lua_setgcthreshold(lua_State -*L,int newthreshold){lua_lock(L);if(cast(lu_mem,newthreshold)>GCscalel( -MAX_LUMEM))G(L)->GCthreshold=MAX_LUMEM;else G(L)->GCthreshold=GCunscale( -newthreshold);luaC_checkGC(L);lua_unlock(L);}LUA_API const char*lua_version( -void){return LUA_VERSION;}LUA_API int lua_error(lua_State*L){lua_lock(L); -api_checknelems(L,1);luaG_errormsg(L);lua_unlock(L);return 0;}LUA_API int -lua_next(lua_State*L,int idx){StkId t;int more;lua_lock(L);t=luaA_index(L,idx) -;api_check(L,ttistable(t));more=luaH_next(L,hvalue(t),L->top-1);if(more){ -api_incr_top(L);}else L->top-=1;lua_unlock(L);return more;}LUA_API void -lua_concat(lua_State*L,int n){lua_lock(L);luaC_checkGC(L);api_checknelems(L,n) -;if(n>=2){luaV_concat(L,n,L->top-L->base-1);L->top-=(n-1);}else if(n==0){ -setsvalue2s(L->top,luaS_newlstr(L,NULL,0));api_incr_top(L);}lua_unlock(L);} -LUA_API void*lua_newuserdata(lua_State*L,size_t size){Udata*u;lua_lock(L); -luaC_checkGC(L);u=luaS_newudata(L,size);setuvalue(L->top,u);api_incr_top(L); -lua_unlock(L);return u+1;}LUA_API int lua_pushupvalues(lua_State*L){Closure* -func;int n,i;lua_lock(L);api_check(L,iscfunction(L->base-1));func=clvalue(L-> -base-1);n=func->c.nupvalues;luaD_checkstack(L,n+LUA_MINSTACK);for(i=0;itop,&func->c.upvalue[i]);L->top++;}lua_unlock(L);return n;}static - const char*aux_upvalue(lua_State*L,int funcindex,int n,TObject**val){Closure* -f;StkId fi=luaA_index(L,funcindex);if(!ttisfunction(fi))return NULL;f=clvalue( -fi);if(f->c.isC){if(n>f->c.nupvalues)return NULL;*val=&f->c.upvalue[n-1]; -return"";}else{Proto*p=f->l.p;if(n>p->sizeupvalues)return NULL;*val=f->l. -upvals[n-1]->v;return getstr(p->upvalues[n-1]);}}LUA_API const char* -lua_getupvalue(lua_State*L,int funcindex,int n){const char*name;TObject*val; -lua_lock(L);name=aux_upvalue(L,funcindex,n,&val);if(name){setobj2s(L->top,val) -;api_incr_top(L);}lua_unlock(L);return name;}LUA_API const char*lua_setupvalue -(lua_State*L,int funcindex,int n){const char*name;TObject*val;lua_lock(L); -api_checknelems(L,1);name=aux_upvalue(L,funcindex,n,&val);if(name){L->top--; -setobj(val,L->top);}lua_unlock(L);return name;} -#line 1 "lauxlib.c" -#define lauxlib_c -#line 1 "lauxlib.h" -#ifndef lauxlib_h -#define lauxlib_h -#ifndef LUALIB_API -#define LUALIB_API LUA_API -#endif -typedef struct luaL_reg{const char*name;lua_CFunction func;}luaL_reg; -LUALIB_API void luaL_openlib(lua_State*L,const char*libname,const luaL_reg*l, -int nup);LUALIB_API int luaL_getmetafield(lua_State*L,int obj,const char*e); -LUALIB_API int luaL_callmeta(lua_State*L,int obj,const char*e);LUALIB_API int -luaL_typerror(lua_State*L,int narg,const char*tname);LUALIB_API int -luaL_argerror(lua_State*L,int numarg,const char*extramsg);LUALIB_API const -char*luaL_checklstring(lua_State*L,int numArg,size_t*l);LUALIB_API const char* -luaL_optlstring(lua_State*L,int numArg,const char*def,size_t*l);LUALIB_API -lua_Number luaL_checknumber(lua_State*L,int numArg);LUALIB_API lua_Number -luaL_optnumber(lua_State*L,int nArg,lua_Number def);LUALIB_API void -luaL_checkstack(lua_State*L,int sz,const char*msg);LUALIB_API void -luaL_checktype(lua_State*L,int narg,int t);LUALIB_API void luaL_checkany( -lua_State*L,int narg);LUALIB_API int luaL_newmetatable(lua_State*L,const char* -tname);LUALIB_API void luaL_getmetatable(lua_State*L,const char*tname); -LUALIB_API void*luaL_checkudata(lua_State*L,int ud,const char*tname); -LUALIB_API void luaL_where(lua_State*L,int lvl);LUALIB_API int luaL_error( -lua_State*L,const char*fmt,...);LUALIB_API int luaL_findstring(const char*st, -const char*const lst[]);LUALIB_API int luaL_ref(lua_State*L,int t);LUALIB_API -void luaL_unref(lua_State*L,int t,int ref);LUALIB_API int luaL_getn(lua_State* -L,int t);LUALIB_API void luaL_setn(lua_State*L,int t,int n);LUALIB_API int -luaL_loadfile(lua_State*L,const char*filename);LUALIB_API int luaL_loadbuffer( -lua_State*L,const char*buff,size_t sz,const char*name); -#define luaL_argcheck(L, cond,numarg,extramsg)if(!(cond))luaL_argerror(L,\ -numarg,extramsg) -#define luaL_checkstring(L,n) (luaL_checklstring(L,(n),NULL)) -#define luaL_optstring(L,n,d) (luaL_optlstring(L,(n),(d),NULL)) -#define luaL_checkint(L,n) ((int)luaL_checknumber(L,n)) -#define luaL_checklong(L,n) ((long)luaL_checknumber(L,n)) -#define luaL_optint(L,n,d) ((int)luaL_optnumber(L,n,(lua_Number)(d))) -#define luaL_optlong(L,n,d) ((long)luaL_optnumber(L,n,(lua_Number)(d))) -#ifndef LUAL_BUFFERSIZE -#define LUAL_BUFFERSIZE BUFSIZ -#endif -typedef struct luaL_Buffer{char*p;int lvl;lua_State*L;char buffer[ -LUAL_BUFFERSIZE];}luaL_Buffer; -#define luaL_putchar(B,c) ((void)((B)->p<((B)->buffer+LUAL_BUFFERSIZE)||\ -luaL_prepbuffer(B)),(*(B)->p++=(char)(c))) -#define luaL_addsize(B,n) ((B)->p+=(n)) -LUALIB_API void luaL_buffinit(lua_State*L,luaL_Buffer*B);LUALIB_API char* -luaL_prepbuffer(luaL_Buffer*B);LUALIB_API void luaL_addlstring(luaL_Buffer*B, -const char*s,size_t l);LUALIB_API void luaL_addstring(luaL_Buffer*B,const char -*s);LUALIB_API void luaL_addvalue(luaL_Buffer*B);LUALIB_API void -luaL_pushresult(luaL_Buffer*B);LUALIB_API int lua_dofile(lua_State*L,const -char*filename);LUALIB_API int lua_dostring(lua_State*L,const char*str); -LUALIB_API int lua_dobuffer(lua_State*L,const char*buff,size_t sz,const char*n -); -#define luaL_check_lstr luaL_checklstring -#define luaL_opt_lstr luaL_optlstring -#define luaL_check_number luaL_checknumber -#define luaL_opt_number luaL_optnumber -#define luaL_arg_check luaL_argcheck -#define luaL_check_string luaL_checkstring -#define luaL_opt_string luaL_optstring -#define luaL_check_int luaL_checkint -#define luaL_check_long luaL_checklong -#define luaL_opt_int luaL_optint -#define luaL_opt_long luaL_optlong -#endif -#line 24 "lauxlib.c" -#define RESERVED_REFS 2 -#define FREELIST_REF 1 -#define ARRAYSIZE_REF 2 -#define abs_index(L, i)((i)>0||(i)<=LUA_REGISTRYINDEX?(i):lua_gettop(L)+(i)+1) -LUALIB_API int luaL_argerror(lua_State*L,int narg,const char*extramsg){ -lua_Debug ar;lua_getstack(L,0,&ar);lua_getinfo(L,"n",&ar);if(strcmp(ar. -namewhat,"method")==0){narg--;if(narg==0)return luaL_error(L, -"calling `%s' on bad self (%s)",ar.name,extramsg);}if(ar.name==NULL)ar.name= -"?";return luaL_error(L,"bad argument #%d to `%s' (%s)",narg,ar.name,extramsg) -;}LUALIB_API int luaL_typerror(lua_State*L,int narg,const char*tname){const -char*msg=lua_pushfstring(L,"%s expected, got %s",tname,lua_typename(L,lua_type -(L,narg)));return luaL_argerror(L,narg,msg);}static void tag_error(lua_State*L -,int narg,int tag){luaL_typerror(L,narg,lua_typename(L,tag));}LUALIB_API void -luaL_where(lua_State*L,int level){lua_Debug ar;if(lua_getstack(L,level,&ar)){ -lua_getinfo(L,"Snl",&ar);if(ar.currentline>0){lua_pushfstring(L,"%s:%d: ",ar. -short_src,ar.currentline);return;}}lua_pushliteral(L,"");}LUALIB_API int -luaL_error(lua_State*L,const char*fmt,...){va_list argp;va_start(argp,fmt); -luaL_where(L,1);lua_pushvfstring(L,fmt,argp);va_end(argp);lua_concat(L,2); -return lua_error(L);}LUALIB_API int luaL_findstring(const char*name,const char -*const list[]){int i;for(i=0;list[i];i++)if(strcmp(list[i],name)==0)return i; -return-1;}LUALIB_API int luaL_newmetatable(lua_State*L,const char*tname){ -lua_pushstring(L,tname);lua_rawget(L,LUA_REGISTRYINDEX);if(!lua_isnil(L,-1)) -return 0;lua_pop(L,1);lua_newtable(L);lua_pushstring(L,tname);lua_pushvalue(L, --2);lua_rawset(L,LUA_REGISTRYINDEX);lua_pushvalue(L,-1);lua_pushstring(L,tname -);lua_rawset(L,LUA_REGISTRYINDEX);return 1;}LUALIB_API void luaL_getmetatable( -lua_State*L,const char*tname){lua_pushstring(L,tname);lua_rawget(L, -LUA_REGISTRYINDEX);}LUALIB_API void*luaL_checkudata(lua_State*L,int ud,const -char*tname){const char*tn;if(!lua_getmetatable(L,ud))return NULL;lua_rawget(L, -LUA_REGISTRYINDEX);tn=lua_tostring(L,-1);if(tn&&(strcmp(tn,tname)==0)){lua_pop -(L,1);return lua_touserdata(L,ud);}else{lua_pop(L,1);return NULL;}}LUALIB_API -void luaL_checkstack(lua_State*L,int space,const char*mes){if(!lua_checkstack( -L,space))luaL_error(L,"stack overflow (%s)",mes);}LUALIB_API void -luaL_checktype(lua_State*L,int narg,int t){if(lua_type(L,narg)!=t)tag_error(L, -narg,t);}LUALIB_API void luaL_checkany(lua_State*L,int narg){if(lua_type(L, -narg)==LUA_TNONE)luaL_argerror(L,narg,"value expected");}LUALIB_API const char -*luaL_checklstring(lua_State*L,int narg,size_t*len){const char*s=lua_tostring( -L,narg);if(!s)tag_error(L,narg,LUA_TSTRING);if(len)*len=lua_strlen(L,narg); -return s;}LUALIB_API const char*luaL_optlstring(lua_State*L,int narg,const -char*def,size_t*len){if(lua_isnoneornil(L,narg)){if(len)*len=(def?strlen(def): -0);return def;}else return luaL_checklstring(L,narg,len);}LUALIB_API -lua_Number luaL_checknumber(lua_State*L,int narg){lua_Number d=lua_tonumber(L, -narg);if(d==0&&!lua_isnumber(L,narg))tag_error(L,narg,LUA_TNUMBER);return d;} -LUALIB_API lua_Number luaL_optnumber(lua_State*L,int narg,lua_Number def){if( -lua_isnoneornil(L,narg))return def;else return luaL_checknumber(L,narg);} -LUALIB_API int luaL_getmetafield(lua_State*L,int obj,const char*event){if(! -lua_getmetatable(L,obj))return 0;lua_pushstring(L,event);lua_rawget(L,-2);if( -lua_isnil(L,-1)){lua_pop(L,2);return 0;}else{lua_remove(L,-2);return 1;}} -LUALIB_API int luaL_callmeta(lua_State*L,int obj,const char*event){obj= -abs_index(L,obj);if(!luaL_getmetafield(L,obj,event))return 0;lua_pushvalue(L, -obj);lua_call(L,1,1);return 1;}LUALIB_API void luaL_openlib(lua_State*L,const -char*libname,const luaL_reg*l,int nup){if(libname){lua_pushstring(L,libname); -lua_gettable(L,LUA_GLOBALSINDEX);if(lua_isnil(L,-1)){lua_pop(L,1);lua_newtable -(L);lua_pushstring(L,libname);lua_pushvalue(L,-2);lua_settable(L, -LUA_GLOBALSINDEX);}lua_insert(L,-(nup+1));}for(;l->name;l++){int i; -lua_pushstring(L,l->name);for(i=0;ifunc,nup);lua_settable(L,-(nup+3));}lua_pop(L,nup);} -static int checkint(lua_State*L,int topop){int n=(int)lua_tonumber(L,-1);if(n -==0&&!lua_isnumber(L,-1))n=-1;lua_pop(L,topop);return n;}static void getsizes( -lua_State*L){lua_rawgeti(L,LUA_REGISTRYINDEX,ARRAYSIZE_REF);if(lua_isnil(L,-1) -){lua_pop(L,1);lua_newtable(L);lua_pushvalue(L,-1);lua_setmetatable(L,-2); -lua_pushliteral(L,"__mode");lua_pushliteral(L,"k");lua_rawset(L,-3); -lua_pushvalue(L,-1);lua_rawseti(L,LUA_REGISTRYINDEX,ARRAYSIZE_REF);}}void -luaL_setn(lua_State*L,int t,int n){t=abs_index(L,t);lua_pushliteral(L,"n"); -lua_rawget(L,t);if(checkint(L,1)>=0){lua_pushliteral(L,"n");lua_pushnumber(L,( -lua_Number)n);lua_rawset(L,t);}else{getsizes(L);lua_pushvalue(L,t); -lua_pushnumber(L,(lua_Number)n);lua_rawset(L,-3);lua_pop(L,1);}}int luaL_getn( -lua_State*L,int t){int n;t=abs_index(L,t);lua_pushliteral(L,"n");lua_rawget(L, -t);if((n=checkint(L,1))>=0)return n;getsizes(L);lua_pushvalue(L,t);lua_rawget( -L,-2);if((n=checkint(L,2))>=0)return n;for(n=1;;n++){lua_rawgeti(L,t,n);if( -lua_isnil(L,-1))break;lua_pop(L,1);}lua_pop(L,1);return n-1;} -#define bufflen(B) ((B)->p-(B)->buffer) -#define bufffree(B) ((size_t)(LUAL_BUFFERSIZE-bufflen(B))) -#define LIMIT (LUA_MINSTACK/2) -static int emptybuffer(luaL_Buffer*B){size_t l=bufflen(B);if(l==0)return 0; -else{lua_pushlstring(B->L,B->buffer,l);B->p=B->buffer;B->lvl++;return 1;}} -static void adjuststack(luaL_Buffer*B){if(B->lvl>1){lua_State*L=B->L;int toget -=1;size_t toplen=lua_strlen(L,-1);do{size_t l=lua_strlen(L,-(toget+1));if(B-> -lvl-toget+1>=LIMIT||toplen>l){toplen+=l;toget++;}else break;}while(toget -lvl);lua_concat(L,toget);B->lvl=B->lvl-toget+1;}}LUALIB_API char* -luaL_prepbuffer(luaL_Buffer*B){if(emptybuffer(B))adjuststack(B);return B-> -buffer;}LUALIB_API void luaL_addlstring(luaL_Buffer*B,const char*s,size_t l){ -while(l--)luaL_putchar(B,*s++);}LUALIB_API void luaL_addstring(luaL_Buffer*B, -const char*s){luaL_addlstring(B,s,strlen(s));}LUALIB_API void luaL_pushresult( -luaL_Buffer*B){emptybuffer(B);lua_concat(B->L,B->lvl);B->lvl=1;}LUALIB_API -void luaL_addvalue(luaL_Buffer*B){lua_State*L=B->L;size_t vl=lua_strlen(L,-1); -if(vl<=bufffree(B)){memcpy(B->p,lua_tostring(L,-1),vl);B->p+=vl;lua_pop(L,1);} -else{if(emptybuffer(B))lua_insert(L,-2);B->lvl++;adjuststack(B);}}LUALIB_API -void luaL_buffinit(lua_State*L,luaL_Buffer*B){B->L=L;B->p=B->buffer;B->lvl=0;} -LUALIB_API int luaL_ref(lua_State*L,int t){int ref;t=abs_index(L,t);if( -lua_isnil(L,-1)){lua_pop(L,1);return LUA_REFNIL;}lua_rawgeti(L,t,FREELIST_REF) -;ref=(int)lua_tonumber(L,-1);lua_pop(L,1);if(ref!=0){lua_rawgeti(L,t,ref); -lua_rawseti(L,t,FREELIST_REF);}else{ref=luaL_getn(L,t);if(ref=0){t=abs_index(L -,t);lua_rawgeti(L,t,FREELIST_REF);lua_rawseti(L,t,ref);lua_pushnumber(L,( -lua_Number)ref);lua_rawseti(L,t,FREELIST_REF);}}typedef struct LoadF{FILE*f; -char buff[LUAL_BUFFERSIZE];}LoadF;static const char*getF(lua_State*L,void*ud, -size_t*size){LoadF*lf=(LoadF*)ud;(void)L;if(feof(lf->f))return NULL;*size= -fread(lf->buff,1,LUAL_BUFFERSIZE,lf->f);return(*size>0)?lf->buff:NULL;}static -int errfile(lua_State*L,int fnameindex){const char*filename=lua_tostring(L, -fnameindex)+1;lua_pushfstring(L,"cannot read %s: %s",filename,strerror(errno)) -;lua_remove(L,fnameindex);return LUA_ERRFILE;}LUALIB_API int luaL_loadfile( -lua_State*L,const char*filename){LoadF lf;int status,readstatus;int c;int -fnameindex=lua_gettop(L)+1;if(filename==NULL){lua_pushliteral(L,"=stdin");lf.f -=stdin;}else{lua_pushfstring(L,"@%s",filename);lf.f=fopen(filename,"r");}if(lf -.f==NULL)return errfile(L,fnameindex);c=ungetc(getc(lf.f),lf.f);if(!(isspace(c -)||isprint(c))&&lf.f!=stdin){fclose(lf.f);lf.f=fopen(filename,"rb");if(lf.f== -NULL)return errfile(L,fnameindex);}status=lua_load(L,getF,&lf,lua_tostring(L,- -1));readstatus=ferror(lf.f);if(lf.f!=stdin)fclose(lf.f);if(readstatus){ -lua_settop(L,fnameindex);return errfile(L,fnameindex);}lua_remove(L,fnameindex -);return status;}typedef struct LoadS{const char*s;size_t size;}LoadS;static -const char*getS(lua_State*L,void*ud,size_t*size){LoadS*ls=(LoadS*)ud;(void)L; -if(ls->size==0)return NULL;*size=ls->size;ls->size=0;return ls->s;}LUALIB_API -int luaL_loadbuffer(lua_State*L,const char*buff,size_t size,const char*name){ -LoadS ls;ls.s=buff;ls.size=size;return lua_load(L,getS,&ls,name);}static void -callalert(lua_State*L,int status){if(status!=0){lua_getglobal(L,"_ALERT");if( -lua_isfunction(L,-1)){lua_insert(L,-2);lua_call(L,1,0);}else{fprintf(stderr, -"%s\n",lua_tostring(L,-2));lua_pop(L,2);}}}static int aux_do(lua_State*L,int -status){if(status==0){status=lua_pcall(L,0,LUA_MULTRET,0);}callalert(L,status) -;return status;}LUALIB_API int lua_dofile(lua_State*L,const char*filename){ -return aux_do(L,luaL_loadfile(L,filename));}LUALIB_API int lua_dobuffer( -lua_State*L,const char*buff,size_t size,const char*name){return aux_do(L, -luaL_loadbuffer(L,buff,size,name));}LUALIB_API int lua_dostring(lua_State*L, -const char*str){return lua_dobuffer(L,str,strlen(str),str);} -#line 1 "lbaselib.c" -#define lbaselib_c -#line 1 "lualib.h" -#ifndef lualib_h -#define lualib_h -#ifndef LUALIB_API -#define LUALIB_API LUA_API -#endif -#define LUA_COLIBNAME "coroutine" -LUALIB_API int luaopen_base(lua_State*L); -#define LUA_TABLIBNAME "table" -LUALIB_API int luaopen_table(lua_State*L); -#define LUA_IOLIBNAME "io" -#define LUA_OSLIBNAME "os" -LUALIB_API int luaopen_io(lua_State*L); -#define LUA_STRLIBNAME "string" -LUALIB_API int luaopen_string(lua_State*L); -#define LUA_MATHLIBNAME "math" -LUALIB_API int luaopen_math(lua_State*L); -#define LUA_DBLIBNAME "debug" -LUALIB_API int luaopen_debug(lua_State*L);LUALIB_API int luaopen_loadlib( -lua_State*L); -#ifndef lua_assert -#define lua_assert(c) -#endif -#define lua_baselibopen luaopen_base -#define lua_tablibopen luaopen_table -#define lua_iolibopen luaopen_io -#define lua_strlibopen luaopen_string -#define lua_mathlibopen luaopen_math -#define lua_dblibopen luaopen_debug -#endif -#line 20 "lbaselib.c" -static int luaB_print(lua_State*L){int n=lua_gettop(L);int i;lua_getglobal(L, -"tostring");for(i=1;i<=n;i++){const char*s;lua_pushvalue(L,-1);lua_pushvalue(L -,i);lua_call(L,1,1);s=lua_tostring(L,-1);if(s==NULL)return luaL_error(L, -"`tostring' must return a string to `print'");if(i>1)fputs("\t",stdout);fputs( -s,stdout);lua_pop(L,1);}fputs("\n",stdout);return 0;}static int luaB_tonumber( -lua_State*L){int base=luaL_optint(L,2,10);if(base==10){luaL_checkany(L,1);if( -lua_isnumber(L,1)){lua_pushnumber(L,lua_tonumber(L,1));return 1;}}else{const -char*s1=luaL_checkstring(L,1);char*s2;unsigned long n;luaL_argcheck(L,2<=base -&&base<=36,2,"base out of range");n=strtoul(s1,&s2,base);if(s1!=s2){while( -isspace((unsigned char)(*s2)))s2++;if(*s2=='\0'){lua_pushnumber(L,(lua_Number) -n);return 1;}}}lua_pushnil(L);return 1;}static int luaB_error(lua_State*L){int - level=luaL_optint(L,2,1);luaL_checkany(L,1);if(!lua_isstring(L,1)||level==0) -lua_pushvalue(L,1);else{luaL_where(L,level);lua_pushvalue(L,1);lua_concat(L,2) -;}return lua_error(L);}static int luaB_getmetatable(lua_State*L){luaL_checkany -(L,1);if(!lua_getmetatable(L,1)){lua_pushnil(L);return 1;}luaL_getmetafield(L, -1,"__metatable");return 1;}static int luaB_setmetatable(lua_State*L){int t= -lua_type(L,2);luaL_checktype(L,1,LUA_TTABLE);luaL_argcheck(L,t==LUA_TNIL||t== -LUA_TTABLE,2,"nil or table expected");if(luaL_getmetafield(L,1,"__metatable")) -luaL_error(L,"cannot change a protected metatable");lua_settop(L,2); -lua_setmetatable(L,1);return 1;}static void getfunc(lua_State*L){if( -lua_isfunction(L,1))lua_pushvalue(L,1);else{lua_Debug ar;int level=luaL_optint -(L,1,1);luaL_argcheck(L,level>=0,1,"level must be non-negative");if( -lua_getstack(L,level,&ar)==0)luaL_argerror(L,1,"invalid level");lua_getinfo(L, -"f",&ar);if(lua_isnil(L,-1))luaL_error(L, -"no function environment for tail call at level %d",level);}}static int -aux_getfenv(lua_State*L){lua_getfenv(L,-1);lua_pushliteral(L,"__fenv"); -lua_rawget(L,-2);return!lua_isnil(L,-1);}static int luaB_getfenv(lua_State*L){ -getfunc(L);if(!aux_getfenv(L))lua_pop(L,1);return 1;}static int luaB_setfenv( -lua_State*L){luaL_checktype(L,2,LUA_TTABLE);getfunc(L);if(aux_getfenv(L)) -luaL_error(L,"`setfenv' cannot change a protected environment");else lua_pop(L -,2);lua_pushvalue(L,2);if(lua_isnumber(L,1)&&lua_tonumber(L,1)==0)lua_replace( -L,LUA_GLOBALSINDEX);else if(lua_setfenv(L,-2)==0)luaL_error(L, -"`setfenv' cannot change environment of given function");return 0;}static int -luaB_rawequal(lua_State*L){luaL_checkany(L,1);luaL_checkany(L,2); -lua_pushboolean(L,lua_rawequal(L,1,2));return 1;}static int luaB_rawget( -lua_State*L){luaL_checktype(L,1,LUA_TTABLE);luaL_checkany(L,2);lua_rawget(L,1) -;return 1;}static int luaB_rawset(lua_State*L){luaL_checktype(L,1,LUA_TTABLE); -luaL_checkany(L,2);luaL_checkany(L,3);lua_rawset(L,1);return 1;}static int -luaB_gcinfo(lua_State*L){lua_pushnumber(L,(lua_Number)lua_getgccount(L)); -lua_pushnumber(L,(lua_Number)lua_getgcthreshold(L));return 2;}static int -luaB_collectgarbage(lua_State*L){lua_setgcthreshold(L,luaL_optint(L,1,0)); -return 0;}static int luaB_type(lua_State*L){luaL_checkany(L,1);lua_pushstring( -L,lua_typename(L,lua_type(L,1)));return 1;}static int luaB_next(lua_State*L){ -luaL_checktype(L,1,LUA_TTABLE);lua_settop(L,2);if(lua_next(L,1))return 2;else{ -lua_pushnil(L);return 1;}}static int luaB_pairs(lua_State*L){luaL_checktype(L, -1,LUA_TTABLE);lua_pushliteral(L,"next");lua_rawget(L,LUA_GLOBALSINDEX); -lua_pushvalue(L,1);lua_pushnil(L);return 3;}static int luaB_ipairs(lua_State*L -){lua_Number i=lua_tonumber(L,2);luaL_checktype(L,1,LUA_TTABLE);if(i==0&& -lua_isnone(L,2)){lua_pushliteral(L,"ipairs");lua_rawget(L,LUA_GLOBALSINDEX); -lua_pushvalue(L,1);lua_pushnumber(L,0);return 3;}else{i++;lua_pushnumber(L,i); -lua_rawgeti(L,1,(int)i);return(lua_isnil(L,-1))?0:2;}}static int load_aux( -lua_State*L,int status){if(status==0)return 1;else{lua_pushnil(L);lua_insert(L -,-2);return 2;}}static int luaB_loadstring(lua_State*L){size_t l;const char*s= -luaL_checklstring(L,1,&l);const char*chunkname=luaL_optstring(L,2,s);return -load_aux(L,luaL_loadbuffer(L,s,l,chunkname));}static int luaB_loadfile( -lua_State*L){const char*fname=luaL_optstring(L,1,NULL);return load_aux(L, -luaL_loadfile(L,fname));}static int luaB_dofile(lua_State*L){const char*fname= -luaL_optstring(L,1,NULL);int n=lua_gettop(L);int status=luaL_loadfile(L,fname) -;if(status!=0)lua_error(L);lua_call(L,0,LUA_MULTRET);return lua_gettop(L)-n;} -static int luaB_assert(lua_State*L){luaL_checkany(L,1);if(!lua_toboolean(L,1)) -return luaL_error(L,"%s",luaL_optstring(L,2,"assertion failed!"));lua_settop(L -,1);return 1;}static int luaB_unpack(lua_State*L){int n,i;luaL_checktype(L,1, -LUA_TTABLE);n=luaL_getn(L,1);luaL_checkstack(L,n,"table too big to unpack"); -for(i=1;i<=n;i++)lua_rawgeti(L,1,i);return n;}static int luaB_pcall(lua_State* -L){int status;luaL_checkany(L,1);status=lua_pcall(L,lua_gettop(L)-1, -LUA_MULTRET,0);lua_pushboolean(L,(status==0));lua_insert(L,1);return -lua_gettop(L);}static int luaB_xpcall(lua_State*L){int status;luaL_checkany(L, -2);lua_settop(L,2);lua_insert(L,1);status=lua_pcall(L,0,LUA_MULTRET,1); -lua_pushboolean(L,(status==0));lua_replace(L,1);return lua_gettop(L);}static -int luaB_tostring(lua_State*L){char buff[128];luaL_checkany(L,1);if( -luaL_callmeta(L,1,"__tostring"))return 1;switch(lua_type(L,1)){case -LUA_TNUMBER:lua_pushstring(L,lua_tostring(L,1));return 1;case LUA_TSTRING: -lua_pushvalue(L,1);return 1;case LUA_TBOOLEAN:lua_pushstring(L,(lua_toboolean( -L,1)?"true":"false"));return 1;case LUA_TTABLE:sprintf(buff,"table: %p", -lua_topointer(L,1));break;case LUA_TFUNCTION:sprintf(buff,"function: %p", -lua_topointer(L,1));break;case LUA_TUSERDATA:case LUA_TLIGHTUSERDATA:sprintf( -buff,"userdata: %p",lua_touserdata(L,1));break;case LUA_TTHREAD:sprintf(buff, -"thread: %p",(void*)lua_tothread(L,1));break;case LUA_TNIL:lua_pushliteral(L, -"nil");return 1;}lua_pushstring(L,buff);return 1;}static int luaB_newproxy( -lua_State*L){lua_settop(L,1);lua_newuserdata(L,0);if(lua_toboolean(L,1)==0) -return 1;else if(lua_isboolean(L,1)){lua_newtable(L);lua_pushvalue(L,-1); -lua_pushboolean(L,1);lua_rawset(L,lua_upvalueindex(1));}else{int validproxy=0; -if(lua_getmetatable(L,1)){lua_rawget(L,lua_upvalueindex(1));validproxy= -lua_toboolean(L,-1);lua_pop(L,1);}luaL_argcheck(L,validproxy,1, -"boolean or proxy expected");lua_getmetatable(L,1);}lua_setmetatable(L,2); -return 1;} -#define REQTAB "_LOADED" -#define LUA_PATH "LUA_PATH" -#ifndef LUA_PATH_SEP -#define LUA_PATH_SEP ';' -#endif -#ifndef LUA_PATH_MARK -#define LUA_PATH_MARK '?' -#endif -#ifndef LUA_PATH_DEFAULT -#define LUA_PATH_DEFAULT "?;?.lua" -#endif -static const char*getpath(lua_State*L){const char*path;lua_getglobal(L, -LUA_PATH);path=lua_tostring(L,-1);lua_pop(L,1);if(path)return path;path=getenv -(LUA_PATH);if(path)return path;return LUA_PATH_DEFAULT;}static const char* -pushnextpath(lua_State*L,const char*path){const char*l;if(*path=='\0')return -NULL;if(*path==LUA_PATH_SEP)path++;l=strchr(path,LUA_PATH_SEP);if(l==NULL)l= -path+strlen(path);lua_pushlstring(L,path,l-path);return l;}static void -pushcomposename(lua_State*L){const char*path=lua_tostring(L,-1);const char* -wild;int n=1;while((wild=strchr(path,LUA_PATH_MARK))!=NULL){luaL_checkstack(L, -3,"too many marks in a path component");lua_pushlstring(L,path,wild-path); -lua_pushvalue(L,1);path=wild+1;n+=2;}lua_pushstring(L,path);lua_concat(L,n);} -static int luaB_require(lua_State*L){const char*path;int status=LUA_ERRFILE; -luaL_checkstring(L,1);lua_settop(L,1);lua_getglobal(L,REQTAB);if(!lua_istable( -L,2))return luaL_error(L,"`"REQTAB"' is not a table");path=getpath(L); -lua_pushvalue(L,1);lua_rawget(L,2);if(lua_toboolean(L,-1))return 1;else{while( -status==LUA_ERRFILE){lua_settop(L,3);if((path=pushnextpath(L,path))==NULL) -break;pushcomposename(L);status=luaL_loadfile(L,lua_tostring(L,-1));}}switch( -status){case 0:{lua_getglobal(L,"_REQUIREDNAME");lua_insert(L,-2); -lua_pushvalue(L,1);lua_setglobal(L,"_REQUIREDNAME");lua_call(L,0,1);lua_insert -(L,-2);lua_setglobal(L,"_REQUIREDNAME");if(lua_isnil(L,-1)){lua_pushboolean(L, -1);lua_replace(L,-2);}lua_pushvalue(L,1);lua_pushvalue(L,-2);lua_rawset(L,2); -return 1;}case LUA_ERRFILE:{return luaL_error(L, -"could not load package `%s' from path `%s'",lua_tostring(L,1),getpath(L));} -default:{return luaL_error(L,"error loading package `%s' (%s)",lua_tostring(L, -1),lua_tostring(L,-1));}}}static const luaL_reg base_funcs[]={{"error", -luaB_error},{"getmetatable",luaB_getmetatable},{"setmetatable", -luaB_setmetatable},{"getfenv",luaB_getfenv},{"setfenv",luaB_setfenv},{"next", -luaB_next},{"ipairs",luaB_ipairs},{"pairs",luaB_pairs},{"print",luaB_print},{ -"tonumber",luaB_tonumber},{"tostring",luaB_tostring},{"type",luaB_type},{ -"assert",luaB_assert},{"unpack",luaB_unpack},{"rawequal",luaB_rawequal},{ -"rawget",luaB_rawget},{"rawset",luaB_rawset},{"pcall",luaB_pcall},{"xpcall", -luaB_xpcall},{"collectgarbage",luaB_collectgarbage},{"gcinfo",luaB_gcinfo},{ -"loadfile",luaB_loadfile},{"dofile",luaB_dofile},{"loadstring",luaB_loadstring -},{"require",luaB_require},{NULL,NULL}};static int auxresume(lua_State*L, -lua_State*co,int narg){int status;if(!lua_checkstack(co,narg))luaL_error(L, -"too many arguments to resume");lua_xmove(L,co,narg);status=lua_resume(co,narg -);if(status==0){int nres=lua_gettop(co);if(!lua_checkstack(L,nres))luaL_error( -L,"too many results to resume");lua_xmove(co,L,nres);return nres;}else{ -lua_xmove(co,L,1);return-1;}}static int luaB_coresume(lua_State*L){lua_State* -co=lua_tothread(L,1);int r;luaL_argcheck(L,co,1,"coroutine expected");r= -auxresume(L,co,lua_gettop(L)-1);if(r<0){lua_pushboolean(L,0);lua_insert(L,-2); -return 2;}else{lua_pushboolean(L,1);lua_insert(L,-(r+1));return r+1;}}static -int luaB_auxwrap(lua_State*L){lua_State*co=lua_tothread(L,lua_upvalueindex(1)) -;int r=auxresume(L,co,lua_gettop(L));if(r<0){if(lua_isstring(L,-1)){luaL_where -(L,1);lua_insert(L,-2);lua_concat(L,2);}lua_error(L);}return r;}static int -luaB_cocreate(lua_State*L){lua_State*NL=lua_newthread(L);luaL_argcheck(L, -lua_isfunction(L,1)&&!lua_iscfunction(L,1),1,"Lua function expected"); -lua_pushvalue(L,1);lua_xmove(L,NL,1);return 1;}static int luaB_cowrap( -lua_State*L){luaB_cocreate(L);lua_pushcclosure(L,luaB_auxwrap,1);return 1;} -static int luaB_yield(lua_State*L){return lua_yield(L,lua_gettop(L));}static -int luaB_costatus(lua_State*L){lua_State*co=lua_tothread(L,1);luaL_argcheck(L, -co,1,"coroutine expected");if(L==co)lua_pushliteral(L,"running");else{ -lua_Debug ar;if(lua_getstack(co,0,&ar)==0&&lua_gettop(co)==0)lua_pushliteral(L -,"dead");else lua_pushliteral(L,"suspended");}return 1;}static const luaL_reg -co_funcs[]={{"create",luaB_cocreate},{"wrap",luaB_cowrap},{"resume", -luaB_coresume},{"yield",luaB_yield},{"status",luaB_costatus},{NULL,NULL}}; -static void base_open(lua_State*L){lua_pushliteral(L,"_G");lua_pushvalue(L, -LUA_GLOBALSINDEX);luaL_openlib(L,NULL,base_funcs,0);lua_pushliteral(L, -"_VERSION");lua_pushliteral(L,LUA_VERSION);lua_rawset(L,-3);lua_pushliteral(L, -"newproxy");lua_newtable(L);lua_pushvalue(L,-1);lua_setmetatable(L,-2); -lua_pushliteral(L,"__mode");lua_pushliteral(L,"k");lua_rawset(L,-3); -lua_pushcclosure(L,luaB_newproxy,1);lua_rawset(L,-3);lua_rawset(L,-1);} -LUALIB_API int luaopen_base(lua_State*L){base_open(L);luaL_openlib(L, -LUA_COLIBNAME,co_funcs,0);lua_newtable(L);lua_setglobal(L,REQTAB);return 0;} -#line 1 "lcode.c" -#define lcode_c -#line 1 "lcode.h" -#ifndef lcode_h -#define lcode_h -#line 1 "llex.h" -#ifndef llex_h -#define llex_h -#define FIRST_RESERVED 257 -#define TOKEN_LEN (sizeof("function")/sizeof(char)) -enum RESERVED{TK_AND=FIRST_RESERVED,TK_BREAK,TK_DO,TK_ELSE,TK_ELSEIF,TK_END, -TK_FALSE,TK_FOR,TK_FUNCTION,TK_IF,TK_IN,TK_LOCAL,TK_NIL,TK_NOT,TK_OR,TK_REPEAT -,TK_RETURN,TK_THEN,TK_TRUE,TK_UNTIL,TK_WHILE,TK_NAME,TK_CONCAT,TK_DOTS,TK_EQ, -TK_GE,TK_LE,TK_NE,TK_NUMBER,TK_STRING,TK_EOS}; -#define NUM_RESERVED (cast(int,TK_WHILE-FIRST_RESERVED+1)) -typedef union{lua_Number r;TString*ts;}SemInfo;typedef struct Token{int token; -SemInfo seminfo;}Token;typedef struct LexState{int current;int linenumber;int -lastline;Token t;Token lookahead;struct FuncState*fs;struct lua_State*L;ZIO*z; -Mbuffer*buff;TString*source;int nestlevel;}LexState;void luaX_init(lua_State*L -);void luaX_setinput(lua_State*L,LexState*LS,ZIO*z,TString*source);int -luaX_lex(LexState*LS,SemInfo*seminfo);void luaX_checklimit(LexState*ls,int val -,int limit,const char*msg);void luaX_syntaxerror(LexState*ls,const char*s); -void luaX_errorline(LexState*ls,const char*s,const char*token,int line);const -char*luaX_token2str(LexState*ls,int token); -#endif -#line 11 "lcode.h" -#line 1 "lopcodes.h" -#ifndef lopcodes_h -#define lopcodes_h -enum OpMode{iABC,iABx,iAsBx}; -#define SIZE_C 9 -#define SIZE_B 9 -#define SIZE_Bx (SIZE_C+SIZE_B) -#define SIZE_A 8 -#define SIZE_OP 6 -#define POS_C SIZE_OP -#define POS_B (POS_C+SIZE_C) -#define POS_Bx POS_C -#define POS_A (POS_B+SIZE_B) -#if SIZE_Bx >1) -#else -#define MAXARG_Bx MAX_INT -#define MAXARG_sBx MAX_INT -#endif -#define MAXARG_A ((1<>POS_A)) -#define SETARG_A(i,u) ((i)=(((i)&MASK0(SIZE_A,POS_A))|((cast(Instruction,u)<<\ -POS_A)&MASK1(SIZE_A,POS_A)))) -#define GETARG_B(i) (cast(int,((i)>>POS_B)&MASK1(SIZE_B,0))) -#define SETARG_B(i,b) ((i)=(((i)&MASK0(SIZE_B,POS_B))|((cast(Instruction,b)<<\ -POS_B)&MASK1(SIZE_B,POS_B)))) -#define GETARG_C(i) (cast(int,((i)>>POS_C)&MASK1(SIZE_C,0))) -#define SETARG_C(i,b) ((i)=(((i)&MASK0(SIZE_C,POS_C))|((cast(Instruction,b)<<\ -POS_C)&MASK1(SIZE_C,POS_C)))) -#define GETARG_Bx(i) (cast(int,((i)>>POS_Bx)&MASK1(SIZE_Bx,0))) -#define SETARG_Bx(i,b) ((i)=(((i)&MASK0(SIZE_Bx,POS_Bx))|((cast(Instruction,b)\ -<=OPR_NE) -typedef enum UnOpr{OPR_MINUS,OPR_NOT,OPR_NOUNOPR}UnOpr; -#define getcode(fs,e) ((fs)->f->code[(e)->info]) -#define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) -int luaK_code(FuncState*fs,Instruction i,int line);int luaK_codeABx(FuncState* -fs,OpCode o,int A,unsigned int Bx);int luaK_codeABC(FuncState*fs,OpCode o,int -A,int B,int C);void luaK_fixline(FuncState*fs,int line);void luaK_nil( -FuncState*fs,int from,int n);void luaK_reserveregs(FuncState*fs,int n);void -luaK_checkstack(FuncState*fs,int n);int luaK_stringK(FuncState*fs,TString*s); -int luaK_numberK(FuncState*fs,lua_Number r);void luaK_dischargevars(FuncState* -fs,expdesc*e);int luaK_exp2anyreg(FuncState*fs,expdesc*e);void -luaK_exp2nextreg(FuncState*fs,expdesc*e);void luaK_exp2val(FuncState*fs, -expdesc*e);int luaK_exp2RK(FuncState*fs,expdesc*e);void luaK_self(FuncState*fs -,expdesc*e,expdesc*key);void luaK_indexed(FuncState*fs,expdesc*t,expdesc*k); -void luaK_goiftrue(FuncState*fs,expdesc*e);void luaK_goiffalse(FuncState*fs, -expdesc*e);void luaK_storevar(FuncState*fs,expdesc*var,expdesc*e);void -luaK_setcallreturns(FuncState*fs,expdesc*var,int nresults);int luaK_jump( -FuncState*fs);void luaK_patchlist(FuncState*fs,int list,int target);void -luaK_patchtohere(FuncState*fs,int list);void luaK_concat(FuncState*fs,int*l1, -int l2);int luaK_getlabel(FuncState*fs);void luaK_prefix(FuncState*fs,UnOpr op -,expdesc*v);void luaK_infix(FuncState*fs,BinOpr op,expdesc*v);void luaK_posfix -(FuncState*fs,BinOpr op,expdesc*v1,expdesc*v2); -#endif -#line 15 "lcode.c" -#define hasjumps(e) ((e)->t!=(e)->f) -void luaK_nil(FuncState*fs,int from,int n){Instruction*previous;if(fs->pc>fs-> -lasttarget&&GET_OPCODE(*(previous=&fs->f->code[fs->pc-1]))==OP_LOADNIL){int -pfrom=GETARG_A(*previous);int pto=GETARG_B(*previous);if(pfrom<=from&&from<= -pto+1){if(from+n-1>pto)SETARG_B(*previous,from+n-1);return;}}luaK_codeABC(fs, -OP_LOADNIL,from,from+n-1,0);}int luaK_jump(FuncState*fs){int jpc=fs->jpc;int j -;fs->jpc=NO_JUMP;j=luaK_codeAsBx(fs,OP_JMP,0,NO_JUMP);luaK_concat(fs,&j,jpc); -return j;}static int luaK_condjump(FuncState*fs,OpCode op,int A,int B,int C){ -luaK_codeABC(fs,op,A,B,C);return luaK_jump(fs);}static void luaK_fixjump( -FuncState*fs,int pc,int dest){Instruction*jmp=&fs->f->code[pc];int offset=dest --(pc+1);lua_assert(dest!=NO_JUMP);if(abs(offset)>MAXARG_sBx)luaX_syntaxerror( -fs->ls,"control structure too long");SETARG_sBx(*jmp,offset);}int -luaK_getlabel(FuncState*fs){fs->lasttarget=fs->pc;return fs->pc;}static int -luaK_getjump(FuncState*fs,int pc){int offset=GETARG_sBx(fs->f->code[pc]);if( -offset==NO_JUMP)return NO_JUMP;else return(pc+1)+offset;}static Instruction* -getjumpcontrol(FuncState*fs,int pc){Instruction*pi=&fs->f->code[pc];if(pc>=1&& -testOpMode(GET_OPCODE(*(pi-1)),OpModeT))return pi-1;else return pi;}static int - need_value(FuncState*fs,int list,int cond){for(;list!=NO_JUMP;list= -luaK_getjump(fs,list)){Instruction i=*getjumpcontrol(fs,list);if(GET_OPCODE(i) -!=OP_TEST||GETARG_C(i)!=cond)return 1;}return 0;}static void patchtestreg( -Instruction*i,int reg){if(reg==NO_REG)reg=GETARG_B(*i);SETARG_A(*i,reg);} -static void luaK_patchlistaux(FuncState*fs,int list,int ttarget,int treg,int -ftarget,int freg,int dtarget){while(list!=NO_JUMP){int next=luaK_getjump(fs, -list);Instruction*i=getjumpcontrol(fs,list);if(GET_OPCODE(*i)!=OP_TEST){ -lua_assert(dtarget!=NO_JUMP);luaK_fixjump(fs,list,dtarget);}else{if(GETARG_C(* -i)){lua_assert(ttarget!=NO_JUMP);patchtestreg(i,treg);luaK_fixjump(fs,list, -ttarget);}else{lua_assert(ftarget!=NO_JUMP);patchtestreg(i,freg);luaK_fixjump( -fs,list,ftarget);}}list=next;}}static void luaK_dischargejpc(FuncState*fs){ -luaK_patchlistaux(fs,fs->jpc,fs->pc,NO_REG,fs->pc,NO_REG,fs->pc);fs->jpc= -NO_JUMP;}void luaK_patchlist(FuncState*fs,int list,int target){if(target==fs-> -pc)luaK_patchtohere(fs,list);else{lua_assert(targetpc);luaK_patchlistaux( -fs,list,target,NO_REG,target,NO_REG,target);}}void luaK_patchtohere(FuncState* -fs,int list){luaK_getlabel(fs);luaK_concat(fs,&fs->jpc,list);}void luaK_concat -(FuncState*fs,int*l1,int l2){if(l2==NO_JUMP)return;else if(*l1==NO_JUMP)*l1=l2 -;else{int list=*l1;int next;while((next=luaK_getjump(fs,list))!=NO_JUMP)list= -next;luaK_fixjump(fs,list,l2);}}void luaK_checkstack(FuncState*fs,int n){int -newstack=fs->freereg+n;if(newstack>fs->f->maxstacksize){if(newstack>=MAXSTACK) -luaX_syntaxerror(fs->ls,"function or expression too complex");fs->f-> -maxstacksize=cast(lu_byte,newstack);}}void luaK_reserveregs(FuncState*fs,int n -){luaK_checkstack(fs,n);fs->freereg+=n;}static void freereg(FuncState*fs,int -reg){if(reg>=fs->nactvar&®freereg--;lua_assert(reg==fs-> -freereg);}}static void freeexp(FuncState*fs,expdesc*e){if(e->k==VNONRELOC) -freereg(fs,e->info);}static int addk(FuncState*fs,TObject*k,TObject*v){const -TObject*idx=luaH_get(fs->h,k);if(ttisnumber(idx)){lua_assert(luaO_rawequalObj( -&fs->f->k[cast(int,nvalue(idx))],v));return cast(int,nvalue(idx));}else{Proto* -f=fs->f;luaM_growvector(fs->L,f->k,fs->nk,f->sizek,TObject,MAXARG_Bx, -"constant table overflow");setobj2n(&f->k[fs->nk],v);setnvalue(luaH_set(fs->L, -fs->h,k),cast(lua_Number,fs->nk));return fs->nk++;}}int luaK_stringK(FuncState -*fs,TString*s){TObject o;setsvalue(&o,s);return addk(fs,&o,&o);}int -luaK_numberK(FuncState*fs,lua_Number r){TObject o;setnvalue(&o,r);return addk( -fs,&o,&o);}static int nil_constant(FuncState*fs){TObject k,v;setnilvalue(&v); -sethvalue(&k,fs->h);return addk(fs,&k,&v);}void luaK_setcallreturns(FuncState* -fs,expdesc*e,int nresults){if(e->k==VCALL){SETARG_C(getcode(fs,e),nresults+1); -if(nresults==1){e->k=VNONRELOC;e->info=GETARG_A(getcode(fs,e));}}}void -luaK_dischargevars(FuncState*fs,expdesc*e){switch(e->k){case VLOCAL:{e->k= -VNONRELOC;break;}case VUPVAL:{e->info=luaK_codeABC(fs,OP_GETUPVAL,0,e->info,0) -;e->k=VRELOCABLE;break;}case VGLOBAL:{e->info=luaK_codeABx(fs,OP_GETGLOBAL,0,e -->info);e->k=VRELOCABLE;break;}case VINDEXED:{freereg(fs,e->aux);freereg(fs,e -->info);e->info=luaK_codeABC(fs,OP_GETTABLE,0,e->info,e->aux);e->k=VRELOCABLE; -break;}case VCALL:{luaK_setcallreturns(fs,e,1);break;}default:break;}}static -int code_label(FuncState*fs,int A,int b,int jump){luaK_getlabel(fs);return -luaK_codeABC(fs,OP_LOADBOOL,A,b,jump);}static void discharge2reg(FuncState*fs, -expdesc*e,int reg){luaK_dischargevars(fs,e);switch(e->k){case VNIL:{luaK_nil( -fs,reg,1);break;}case VFALSE:case VTRUE:{luaK_codeABC(fs,OP_LOADBOOL,reg,e->k -==VTRUE,0);break;}case VK:{luaK_codeABx(fs,OP_LOADK,reg,e->info);break;}case -VRELOCABLE:{Instruction*pc=&getcode(fs,e);SETARG_A(*pc,reg);break;}case -VNONRELOC:{if(reg!=e->info)luaK_codeABC(fs,OP_MOVE,reg,e->info,0);break;} -default:{lua_assert(e->k==VVOID||e->k==VJMP);return;}}e->info=reg;e->k= -VNONRELOC;}static void discharge2anyreg(FuncState*fs,expdesc*e){if(e->k!= -VNONRELOC){luaK_reserveregs(fs,1);discharge2reg(fs,e,fs->freereg-1);}}static -void luaK_exp2reg(FuncState*fs,expdesc*e,int reg){discharge2reg(fs,e,reg);if(e -->k==VJMP)luaK_concat(fs,&e->t,e->info);if(hasjumps(e)){int final;int p_f= -NO_JUMP;int p_t=NO_JUMP;if(need_value(fs,e->t,1)||need_value(fs,e->f,0)){int -fj=NO_JUMP;if(e->k!=VJMP)fj=luaK_jump(fs);p_f=code_label(fs,reg,0,1);p_t= -code_label(fs,reg,1,0);luaK_patchtohere(fs,fj);}final=luaK_getlabel(fs); -luaK_patchlistaux(fs,e->f,p_f,NO_REG,final,reg,p_f);luaK_patchlistaux(fs,e->t, -final,reg,p_t,NO_REG,p_t);}e->f=e->t=NO_JUMP;e->info=reg;e->k=VNONRELOC;}void -luaK_exp2nextreg(FuncState*fs,expdesc*e){luaK_dischargevars(fs,e);freeexp(fs,e -);luaK_reserveregs(fs,1);luaK_exp2reg(fs,e,fs->freereg-1);}int luaK_exp2anyreg -(FuncState*fs,expdesc*e){luaK_dischargevars(fs,e);if(e->k==VNONRELOC){if(! -hasjumps(e))return e->info;if(e->info>=fs->nactvar){luaK_exp2reg(fs,e,e->info) -;return e->info;}}luaK_exp2nextreg(fs,e);return e->info;}void luaK_exp2val( -FuncState*fs,expdesc*e){if(hasjumps(e))luaK_exp2anyreg(fs,e);else -luaK_dischargevars(fs,e);}int luaK_exp2RK(FuncState*fs,expdesc*e){luaK_exp2val -(fs,e);switch(e->k){case VNIL:{if(fs->nk+MAXSTACK<=MAXARG_C){e->info= -nil_constant(fs);e->k=VK;return e->info+MAXSTACK;}else break;}case VK:{if(e-> -info+MAXSTACK<=MAXARG_C)return e->info+MAXSTACK;else break;}default:break;} -return luaK_exp2anyreg(fs,e);}void luaK_storevar(FuncState*fs,expdesc*var, -expdesc*exp){switch(var->k){case VLOCAL:{freeexp(fs,exp);luaK_exp2reg(fs,exp, -var->info);return;}case VUPVAL:{int e=luaK_exp2anyreg(fs,exp);luaK_codeABC(fs, -OP_SETUPVAL,e,var->info,0);break;}case VGLOBAL:{int e=luaK_exp2anyreg(fs,exp); -luaK_codeABx(fs,OP_SETGLOBAL,e,var->info);break;}case VINDEXED:{int e= -luaK_exp2RK(fs,exp);luaK_codeABC(fs,OP_SETTABLE,var->info,var->aux,e);break;} -default:{lua_assert(0);break;}}freeexp(fs,exp);}void luaK_self(FuncState*fs, -expdesc*e,expdesc*key){int func;luaK_exp2anyreg(fs,e);freeexp(fs,e);func=fs-> -freereg;luaK_reserveregs(fs,2);luaK_codeABC(fs,OP_SELF,func,e->info, -luaK_exp2RK(fs,key));freeexp(fs,key);e->info=func;e->k=VNONRELOC;}static void -invertjump(FuncState*fs,expdesc*e){Instruction*pc=getjumpcontrol(fs,e->info); -lua_assert(testOpMode(GET_OPCODE(*pc),OpModeT)&&GET_OPCODE(*pc)!=OP_TEST); -SETARG_A(*pc,!(GETARG_A(*pc)));}static int jumponcond(FuncState*fs,expdesc*e, -int cond){if(e->k==VRELOCABLE){Instruction ie=getcode(fs,e);if(GET_OPCODE(ie) -==OP_NOT){fs->pc--;return luaK_condjump(fs,OP_TEST,NO_REG,GETARG_B(ie),!cond); -}}discharge2anyreg(fs,e);freeexp(fs,e);return luaK_condjump(fs,OP_TEST,NO_REG, -e->info,cond);}void luaK_goiftrue(FuncState*fs,expdesc*e){int pc; -luaK_dischargevars(fs,e);switch(e->k){case VK:case VTRUE:{pc=NO_JUMP;break;} -case VFALSE:{pc=luaK_jump(fs);break;}case VJMP:{invertjump(fs,e);pc=e->info; -break;}default:{pc=jumponcond(fs,e,0);break;}}luaK_concat(fs,&e->f,pc);}void -luaK_goiffalse(FuncState*fs,expdesc*e){int pc;luaK_dischargevars(fs,e);switch( -e->k){case VNIL:case VFALSE:{pc=NO_JUMP;break;}case VTRUE:{pc=luaK_jump(fs); -break;}case VJMP:{pc=e->info;break;}default:{pc=jumponcond(fs,e,1);break;}} -luaK_concat(fs,&e->t,pc);}static void codenot(FuncState*fs,expdesc*e){ -luaK_dischargevars(fs,e);switch(e->k){case VNIL:case VFALSE:{e->k=VTRUE;break; -}case VK:case VTRUE:{e->k=VFALSE;break;}case VJMP:{invertjump(fs,e);break;} -case VRELOCABLE:case VNONRELOC:{discharge2anyreg(fs,e);freeexp(fs,e);e->info= -luaK_codeABC(fs,OP_NOT,0,e->info,0);e->k=VRELOCABLE;break;}default:{lua_assert -(0);break;}}{int temp=e->f;e->f=e->t;e->t=temp;}}void luaK_indexed(FuncState* -fs,expdesc*t,expdesc*k){t->aux=luaK_exp2RK(fs,k);t->k=VINDEXED;}void -luaK_prefix(FuncState*fs,UnOpr op,expdesc*e){if(op==OPR_MINUS){luaK_exp2val(fs -,e);if(e->k==VK&&ttisnumber(&fs->f->k[e->info]))e->info=luaK_numberK(fs,- -nvalue(&fs->f->k[e->info]));else{luaK_exp2anyreg(fs,e);freeexp(fs,e);e->info= -luaK_codeABC(fs,OP_UNM,0,e->info,0);e->k=VRELOCABLE;}}else codenot(fs,e);}void - luaK_infix(FuncState*fs,BinOpr op,expdesc*v){switch(op){case OPR_AND:{ -luaK_goiftrue(fs,v);luaK_patchtohere(fs,v->t);v->t=NO_JUMP;break;}case OPR_OR: -{luaK_goiffalse(fs,v);luaK_patchtohere(fs,v->f);v->f=NO_JUMP;break;}case -OPR_CONCAT:{luaK_exp2nextreg(fs,v);break;}default:{luaK_exp2RK(fs,v);break;}}} -static void codebinop(FuncState*fs,expdesc*res,BinOpr op,int o1,int o2){if(op -<=OPR_POW){OpCode opc=cast(OpCode,(op-OPR_ADD)+OP_ADD);res->info=luaK_codeABC( -fs,opc,0,o1,o2);res->k=VRELOCABLE;}else{static const OpCode ops[]={OP_EQ,OP_EQ -,OP_LT,OP_LE,OP_LT,OP_LE};int cond=1;if(op>=OPR_GT){int temp;temp=o1;o1=o2;o2= -temp;}else if(op==OPR_NE)cond=0;res->info=luaK_condjump(fs,ops[op-OPR_NE],cond -,o1,o2);res->k=VJMP;}}void luaK_posfix(FuncState*fs,BinOpr op,expdesc*e1, -expdesc*e2){switch(op){case OPR_AND:{lua_assert(e1->t==NO_JUMP); -luaK_dischargevars(fs,e2);luaK_concat(fs,&e1->f,e2->f);e1->k=e2->k;e1->info=e2 -->info;e1->aux=e2->aux;e1->t=e2->t;break;}case OPR_OR:{lua_assert(e1->f== -NO_JUMP);luaK_dischargevars(fs,e2);luaK_concat(fs,&e1->t,e2->t);e1->k=e2->k;e1 -->info=e2->info;e1->aux=e2->aux;e1->f=e2->f;break;}case OPR_CONCAT:{ -luaK_exp2val(fs,e2);if(e2->k==VRELOCABLE&&GET_OPCODE(getcode(fs,e2))== -OP_CONCAT){lua_assert(e1->info==GETARG_B(getcode(fs,e2))-1);freeexp(fs,e1); -SETARG_B(getcode(fs,e2),e1->info);e1->k=e2->k;e1->info=e2->info;}else{ -luaK_exp2nextreg(fs,e2);freeexp(fs,e2);freeexp(fs,e1);e1->info=luaK_codeABC(fs -,OP_CONCAT,0,e1->info,e2->info);e1->k=VRELOCABLE;}break;}default:{int o1= -luaK_exp2RK(fs,e1);int o2=luaK_exp2RK(fs,e2);freeexp(fs,e2);freeexp(fs,e1); -codebinop(fs,e1,op,o1,o2);}}}void luaK_fixline(FuncState*fs,int line){fs->f-> -lineinfo[fs->pc-1]=line;}int luaK_code(FuncState*fs,Instruction i,int line){ -Proto*f=fs->f;luaK_dischargejpc(fs);luaM_growvector(fs->L,f->code,fs->pc,f-> -sizecode,Instruction,MAX_INT,"code size overflow");f->code[fs->pc]=i; -luaM_growvector(fs->L,f->lineinfo,fs->pc,f->sizelineinfo,int,MAX_INT, -"code size overflow");f->lineinfo[fs->pc]=line;return fs->pc++;}int -luaK_codeABC(FuncState*fs,OpCode o,int a,int b,int c){lua_assert(getOpMode(o) -==iABC);return luaK_code(fs,CREATE_ABC(o,a,b,c),fs->ls->lastline);}int -luaK_codeABx(FuncState*fs,OpCode o,int a,unsigned int bc){lua_assert(getOpMode -(o)==iABx||getOpMode(o)==iAsBx);return luaK_code(fs,CREATE_ABx(o,a,bc),fs->ls -->lastline);} -#line 1 "ldblib.c" -#define ldblib_c -static void settabss(lua_State*L,const char*i,const char*v){lua_pushstring(L,i -);lua_pushstring(L,v);lua_rawset(L,-3);}static void settabsi(lua_State*L,const - char*i,int v){lua_pushstring(L,i);lua_pushnumber(L,(lua_Number)v);lua_rawset( -L,-3);}static int getinfo(lua_State*L){lua_Debug ar;const char*options= -luaL_optstring(L,2,"flnSu");if(lua_isnumber(L,1)){if(!lua_getstack(L,(int)( -lua_tonumber(L,1)),&ar)){lua_pushnil(L);return 1;}}else if(lua_isfunction(L,1) -){lua_pushfstring(L,">%s",options);options=lua_tostring(L,-1);lua_pushvalue(L, -1);}else return luaL_argerror(L,1,"function or level expected");if(! -lua_getinfo(L,options,&ar))return luaL_argerror(L,2,"invalid option"); -lua_newtable(L);for(;*options;options++){switch(*options){case'S':settabss(L, -"source",ar.source);settabss(L,"short_src",ar.short_src);settabsi(L, -"linedefined",ar.linedefined);settabss(L,"what",ar.what);break;case'l': -settabsi(L,"currentline",ar.currentline);break;case'u':settabsi(L,"nups",ar. -nups);break;case'n':settabss(L,"name",ar.name);settabss(L,"namewhat",ar. -namewhat);break;case'f':lua_pushliteral(L,"func");lua_pushvalue(L,-3); -lua_rawset(L,-3);break;}}return 1;}static int getlocal(lua_State*L){lua_Debug -ar;const char*name;if(!lua_getstack(L,luaL_checkint(L,1),&ar))return -luaL_argerror(L,1,"level out of range");name=lua_getlocal(L,&ar,luaL_checkint( -L,2));if(name){lua_pushstring(L,name);lua_pushvalue(L,-2);return 2;}else{ -lua_pushnil(L);return 1;}}static int setlocal(lua_State*L){lua_Debug ar;if(! -lua_getstack(L,luaL_checkint(L,1),&ar))return luaL_argerror(L,1, -"level out of range");luaL_checkany(L,3);lua_pushstring(L,lua_setlocal(L,&ar, -luaL_checkint(L,2)));return 1;}static int auxupvalue(lua_State*L,int get){ -const char*name;int n=luaL_checkint(L,2);luaL_checktype(L,1,LUA_TFUNCTION);if( -lua_iscfunction(L,1))return 0;name=get?lua_getupvalue(L,1,n):lua_setupvalue(L, -1,n);if(name==NULL)return 0;lua_pushstring(L,name);lua_insert(L,-(get+1)); -return get+1;}static int getupvalue(lua_State*L){return auxupvalue(L,1);} -static int setupvalue(lua_State*L){luaL_checkany(L,3);return auxupvalue(L,0);} -static const char KEY_HOOK='h';static void hookf(lua_State*L,lua_Debug*ar){ -static const char*const hooknames[]={"call","return","line","count", -"tail return"};lua_pushlightuserdata(L,(void*)&KEY_HOOK);lua_rawget(L, -LUA_REGISTRYINDEX);if(lua_isfunction(L,-1)){lua_pushstring(L,hooknames[(int)ar -->event]);if(ar->currentline>=0)lua_pushnumber(L,(lua_Number)ar->currentline); -else lua_pushnil(L);lua_assert(lua_getinfo(L,"lS",ar));lua_call(L,2,0);}else -lua_pop(L,1);}static int makemask(const char*smask,int count){int mask=0;if( -strchr(smask,'c'))mask|=LUA_MASKCALL;if(strchr(smask,'r'))mask|=LUA_MASKRET;if -(strchr(smask,'l'))mask|=LUA_MASKLINE;if(count>0)mask|=LUA_MASKCOUNT;return -mask;}static char*unmakemask(int mask,char*smask){int i=0;if(mask&LUA_MASKCALL -)smask[i++]='c';if(mask&LUA_MASKRET)smask[i++]='r';if(mask&LUA_MASKLINE)smask[ -i++]='l';smask[i]='\0';return smask;}static int sethook(lua_State*L){if( -lua_isnoneornil(L,1)){lua_settop(L,1);lua_sethook(L,NULL,0,0);}else{const char -*smask=luaL_checkstring(L,2);int count=luaL_optint(L,3,0);luaL_checktype(L,1, -LUA_TFUNCTION);lua_sethook(L,hookf,makemask(smask,count),count);} -lua_pushlightuserdata(L,(void*)&KEY_HOOK);lua_pushvalue(L,1);lua_rawset(L, -LUA_REGISTRYINDEX);return 0;}static int gethook(lua_State*L){char buff[5];int -mask=lua_gethookmask(L);lua_Hook hook=lua_gethook(L);if(hook!=NULL&&hook!= -hookf)lua_pushliteral(L,"external hook");else{lua_pushlightuserdata(L,(void*)& -KEY_HOOK);lua_rawget(L,LUA_REGISTRYINDEX);}lua_pushstring(L,unmakemask(mask, -buff));lua_pushnumber(L,(lua_Number)lua_gethookcount(L));return 3;}static int -debug(lua_State*L){for(;;){char buffer[250];fputs("lua_debug> ",stderr);if( -fgets(buffer,sizeof(buffer),stdin)==0||strcmp(buffer,"cont\n")==0)return 0; -lua_dostring(L,buffer);lua_settop(L,0);}} -#define LEVELS1 12 -#define LEVELS2 10 -static int errorfb(lua_State*L){int level=1;int firstpart=1;lua_Debug ar;if( -lua_gettop(L)==0)lua_pushliteral(L,"");else if(!lua_isstring(L,1))return 1; -else lua_pushliteral(L,"\n");lua_pushliteral(L,"stack traceback:");while( -lua_getstack(L,level++,&ar)){if(level>LEVELS1&&firstpart){if(!lua_getstack(L, -level+LEVELS2,&ar))level--;else{lua_pushliteral(L,"\n\t...");while( -lua_getstack(L,level+LEVELS2,&ar))level++;}firstpart=0;continue;} -lua_pushliteral(L,"\n\t");lua_getinfo(L,"Snl",&ar);lua_pushfstring(L,"%s:",ar. -short_src);if(ar.currentline>0)lua_pushfstring(L,"%d:",ar.currentline);switch( -*ar.namewhat){case'g':case'l':case'f':case'm':lua_pushfstring(L, -" in function `%s'",ar.name);break;default:{if(*ar.what=='m')lua_pushfstring(L -," in main chunk");else if(*ar.what=='C'||*ar.what=='t')lua_pushliteral(L," ?" -);else lua_pushfstring(L," in function <%s:%d>",ar.short_src,ar.linedefined);} -}lua_concat(L,lua_gettop(L));}lua_concat(L,lua_gettop(L));return 1;}static -const luaL_reg dblib[]={{"getlocal",getlocal},{"getinfo",getinfo},{"gethook", -gethook},{"getupvalue",getupvalue},{"sethook",sethook},{"setlocal",setlocal},{ -"setupvalue",setupvalue},{"debug",debug},{"traceback",errorfb},{NULL,NULL}}; -LUALIB_API int luaopen_debug(lua_State*L){luaL_openlib(L,LUA_DBLIBNAME,dblib,0 -);lua_pushliteral(L,"_TRACEBACK");lua_pushcfunction(L,errorfb);lua_settable(L, -LUA_GLOBALSINDEX);return 1;} -#line 1 "ldebug.c" -#define ldebug_c -static const char*getfuncname(CallInfo*ci,const char**name); -#define isLua(ci) (!((ci)->state&CI_C)) -static int currentpc(CallInfo*ci){if(!isLua(ci))return-1;if(ci->state& -CI_HASFRAME)ci->u.l.savedpc=*ci->u.l.pc;return pcRel(ci->u.l.savedpc,ci_func( -ci)->l.p);}static int currentline(CallInfo*ci){int pc=currentpc(ci);if(pc<0) -return-1;else return getline(ci_func(ci)->l.p,pc);}void luaG_inithooks( -lua_State*L){CallInfo*ci;for(ci=L->ci;ci!=L->base_ci;ci--)currentpc(ci);L-> -hookinit=1;}LUA_API int lua_sethook(lua_State*L,lua_Hook func,int mask,int -count){if(func==NULL||mask==0){mask=0;func=NULL;}L->hook=func;L->basehookcount -=count;resethookcount(L);L->hookmask=cast(lu_byte,mask);L->hookinit=0;return 1 -;}LUA_API lua_Hook lua_gethook(lua_State*L){return L->hook;}LUA_API int -lua_gethookmask(lua_State*L){return L->hookmask;}LUA_API int lua_gethookcount( -lua_State*L){return L->basehookcount;}LUA_API int lua_getstack(lua_State*L,int - level,lua_Debug*ar){int status;CallInfo*ci;lua_lock(L);for(ci=L->ci;level>0&& -ci>L->base_ci;ci--){level--;if(!(ci->state&CI_C))level-=ci->u.l.tailcalls;}if( -level>0||ci==L->base_ci)status=0;else if(level<0){status=1;ar->i_ci=0;}else{ -status=1;ar->i_ci=ci-L->base_ci;}lua_unlock(L);return status;}static Proto* -getluaproto(CallInfo*ci){return(isLua(ci)?ci_func(ci)->l.p:NULL);}LUA_API -const char*lua_getlocal(lua_State*L,const lua_Debug*ar,int n){const char*name; -CallInfo*ci;Proto*fp;lua_lock(L);name=NULL;ci=L->base_ci+ar->i_ci;fp= -getluaproto(ci);if(fp){name=luaF_getlocalname(fp,n,currentpc(ci));if(name) -luaA_pushobject(L,ci->base+(n-1));}lua_unlock(L);return name;}LUA_API const -char*lua_setlocal(lua_State*L,const lua_Debug*ar,int n){const char*name; -CallInfo*ci;Proto*fp;lua_lock(L);name=NULL;ci=L->base_ci+ar->i_ci;fp= -getluaproto(ci);L->top--;if(fp){name=luaF_getlocalname(fp,n,currentpc(ci));if( -!name||name[0]=='(')name=NULL;else setobjs2s(ci->base+(n-1),L->top);} -lua_unlock(L);return name;}static void funcinfo(lua_Debug*ar,StkId func){ -Closure*cl=clvalue(func);if(cl->c.isC){ar->source="=[C]";ar->linedefined=-1;ar -->what="C";}else{ar->source=getstr(cl->l.p->source);ar->linedefined=cl->l.p-> -lineDefined;ar->what=(ar->linedefined==0)?"main":"Lua";}luaO_chunkid(ar-> -short_src,ar->source,LUA_IDSIZE);}static const char*travglobals(lua_State*L, -const TObject*o){Table*g=hvalue(gt(L));int i=sizenode(g);while(i--){Node*n= -gnode(g,i);if(luaO_rawequalObj(o,gval(n))&&ttisstring(gkey(n)))return getstr( -tsvalue(gkey(n)));}return NULL;}static void info_tailcall(lua_State*L, -lua_Debug*ar){ar->name=ar->namewhat="";ar->what="tail";ar->linedefined=ar-> -currentline=-1;ar->source="=(tail call)";luaO_chunkid(ar->short_src,ar->source -,LUA_IDSIZE);ar->nups=0;setnilvalue(L->top);}static int auxgetinfo(lua_State*L -,const char*what,lua_Debug*ar,StkId f,CallInfo*ci){int status=1;for(;*what; -what++){switch(*what){case'S':{funcinfo(ar,f);break;}case'l':{ar->currentline= -(ci)?currentline(ci):-1;break;}case'u':{ar->nups=clvalue(f)->c.nupvalues;break -;}case'n':{ar->namewhat=(ci)?getfuncname(ci,&ar->name):NULL;if(ar->namewhat== -NULL){if((ar->name=travglobals(L,f))!=NULL)ar->namewhat="global";else ar-> -namewhat="";}break;}case'f':{setobj2s(L->top,f);break;}default:status=0;}} -return status;}LUA_API int lua_getinfo(lua_State*L,const char*what,lua_Debug* -ar){int status=1;lua_lock(L);if(*what=='>'){StkId f=L->top-1;if(!ttisfunction( -f))luaG_runerror(L,"value for `lua_getinfo' is not a function");status= -auxgetinfo(L,what+1,ar,f,NULL);L->top--;}else if(ar->i_ci!=0){CallInfo*ci=L-> -base_ci+ar->i_ci;lua_assert(ttisfunction(ci->base-1));status=auxgetinfo(L,what -,ar,ci->base-1,ci);}else info_tailcall(L,ar);if(strchr(what,'f'))incr_top(L); -lua_unlock(L);return status;} -#define check(x) if(!(x))return 0; -#define checkjump(pt,pc) check(0<=pc&&pcsizecode) -#define checkreg(pt,reg) check((reg)<(pt)->maxstacksize) -static int precheck(const Proto*pt){check(pt->maxstacksize<=MAXSTACK);check(pt -->sizelineinfo==pt->sizecode||pt->sizelineinfo==0);lua_assert(pt->numparams+pt -->is_vararg<=pt->maxstacksize);check(GET_OPCODE(pt->code[pt->sizecode-1])== -OP_RETURN);return 1;}static int checkopenop(const Proto*pt,int pc){Instruction - i=pt->code[pc+1];switch(GET_OPCODE(i)){case OP_CALL:case OP_TAILCALL:case -OP_RETURN:{check(GETARG_B(i)==0);return 1;}case OP_SETLISTO:return 1;default: -return 0;}}static int checkRK(const Proto*pt,int r){return(rmaxstacksize -||(r>=MAXSTACK&&r-MAXSTACKsizek));}static Instruction luaG_symbexec(const - Proto*pt,int lastpc,int reg){int pc;int last;last=pt->sizecode-1;check( -precheck(pt));for(pc=0;pccode[pc];OpCode - op=GET_OPCODE(i);int a=GETARG_A(i);int b=0;int c=0;checkreg(pt,a);switch( -getOpMode(op)){case iABC:{b=GETARG_B(i);c=GETARG_C(i);if(testOpMode(op, -OpModeBreg)){checkreg(pt,b);}else if(testOpMode(op,OpModeBrk))check(checkRK(pt -,b));if(testOpMode(op,OpModeCrk))check(checkRK(pt,c));break;}case iABx:{b= -GETARG_Bx(i);if(testOpMode(op,OpModeK))check(bsizek);break;}case iAsBx:{b -=GETARG_sBx(i);break;}}if(testOpMode(op,OpModesetA)){if(a==reg)last=pc;}if( -testOpMode(op,OpModeT)){check(pc+2sizecode);check(GET_OPCODE(pt->code[pc+ -1])==OP_JMP);}switch(op){case OP_LOADBOOL:{check(c==0||pc+2sizecode); -break;}case OP_LOADNIL:{if(a<=reg&®<=b)last=pc;break;}case OP_GETUPVAL:case - OP_SETUPVAL:{check(bnups);break;}case OP_GETGLOBAL:case OP_SETGLOBAL:{ -check(ttisstring(&pt->k[b]));break;}case OP_SELF:{checkreg(pt,a+1);if(reg==a+1 -)last=pc;break;}case OP_CONCAT:{check(c=a)last=pc;case OP_FORLOOP:checkreg(pt,a+2);case -OP_JMP:{int dest=pc+1+b;check(0<=dest&&destsizecode);if(reg!=NO_REG&&pc< -dest&&dest<=lastpc)pc+=b;break;}case OP_CALL:case OP_TAILCALL:{if(b!=0){ -checkreg(pt,a+b-1);}c--;if(c==LUA_MULTRET){check(checkopenop(pt,pc));}else if( -c!=0)checkreg(pt,a+c-1);if(reg>=a)last=pc;break;}case OP_RETURN:{b--;if(b>0) -checkreg(pt,a+b-1);break;}case OP_SETLIST:{checkreg(pt,a+(b&(LFIELDS_PER_FLUSH --1))+1);break;}case OP_CLOSURE:{int nup;check(bsizep);nup=pt->p[b]->nups; -check(pc+nupsizecode);for(;nup>0;nup--){OpCode op1=GET_OPCODE(pt->code[pc -+nup]);check(op1==OP_GETUPVAL||op1==OP_MOVE);}break;}default:break;}}return pt -->code[last];} -#undef check -#undef checkjump -#undef checkreg -int luaG_checkcode(const Proto*pt){return luaG_symbexec(pt,pt->sizecode,NO_REG -);}static const char*kname(Proto*p,int c){c=c-MAXSTACK;if(c>=0&&ttisstring(&p -->k[c]))return svalue(&p->k[c]);else return"?";}static const char*getobjname( -CallInfo*ci,int stackpos,const char**name){if(isLua(ci)){Proto*p=ci_func(ci)-> -l.p;int pc=currentpc(ci);Instruction i;*name=luaF_getlocalname(p,stackpos+1,pc -);if(*name)return"local";i=luaG_symbexec(p,pc,stackpos);lua_assert(pc!=-1); -switch(GET_OPCODE(i)){case OP_GETGLOBAL:{int g=GETARG_Bx(i);lua_assert( -ttisstring(&p->k[g]));*name=svalue(&p->k[g]);return"global";}case OP_MOVE:{int - a=GETARG_A(i);int b=GETARG_B(i);if(bu.l.tailcalls>0)||!isLua(ci-1))return NULL;ci ---;i=ci_func(ci)->l.p->code[currentpc(ci)];if(GET_OPCODE(i)==OP_CALL|| -GET_OPCODE(i)==OP_TAILCALL)return getobjname(ci,GETARG_A(i),name);else return -NULL;}static int isinstack(CallInfo*ci,const TObject*o){StkId p;for(p=ci->base -;ptop;p++)if(o==p)return 1;return 0;}void luaG_typeerror(lua_State*L, -const TObject*o,const char*op){const char*name=NULL;const char*t= -luaT_typenames[ttype(o)];const char*kind=(isinstack(L->ci,o))?getobjname(L->ci -,o-L->base,&name):NULL;if(kind)luaG_runerror(L, -"attempt to %s %s `%s' (a %s value)",op,kind,name,t);else luaG_runerror(L, -"attempt to %s a %s value",op,t);}void luaG_concaterror(lua_State*L,StkId p1, -StkId p2){if(ttisstring(p1))p1=p2;lua_assert(!ttisstring(p1));luaG_typeerror(L -,p1,"concatenate");}void luaG_aritherror(lua_State*L,const TObject*p1,const -TObject*p2){TObject temp;if(luaV_tonumber(p1,&temp)==NULL)p2=p1;luaG_typeerror -(L,p2,"perform arithmetic on");}int luaG_ordererror(lua_State*L,const TObject* -p1,const TObject*p2){const char*t1=luaT_typenames[ttype(p1)];const char*t2= -luaT_typenames[ttype(p2)];if(t1[2]==t2[2])luaG_runerror(L, -"attempt to compare two %s values",t1);else luaG_runerror(L, -"attempt to compare %s with %s",t1,t2);return 0;}static void addinfo(lua_State -*L,const char*msg){CallInfo*ci=L->ci;if(isLua(ci)){char buff[LUA_IDSIZE];int -line=currentline(ci);luaO_chunkid(buff,getstr(getluaproto(ci)->source), -LUA_IDSIZE);luaO_pushfstring(L,"%s:%d: %s",buff,line,msg);}}void luaG_errormsg -(lua_State*L){if(L->errfunc!=0){StkId errfunc=restorestack(L,L->errfunc);if(! -ttisfunction(errfunc))luaD_throw(L,LUA_ERRERR);setobjs2s(L->top,L->top-1); -setobjs2s(L->top-1,errfunc);incr_top(L);luaD_call(L,L->top-2,1);}luaD_throw(L, -LUA_ERRRUN);}void luaG_runerror(lua_State*L,const char*fmt,...){va_list argp; -va_start(argp,fmt);addinfo(L,luaO_pushvfstring(L,fmt,argp));va_end(argp); -luaG_errormsg(L);} -#line 1 "ldo.c" -#define ldo_c -struct lua_longjmp{struct lua_longjmp*previous;jmp_buf b;volatile int status;} -;static void seterrorobj(lua_State*L,int errcode,StkId oldtop){switch(errcode) -{case LUA_ERRMEM:{setsvalue2s(oldtop,luaS_new(L,MEMERRMSG));break;}case -LUA_ERRERR:{setsvalue2s(oldtop,luaS_new(L,"error in error handling"));break;} -case LUA_ERRSYNTAX:case LUA_ERRRUN:{setobjs2s(oldtop,L->top-1);break;}}L->top= -oldtop+1;}void luaD_throw(lua_State*L,int errcode){if(L->errorJmp){L->errorJmp -->status=errcode;longjmp(L->errorJmp->b,1);}else{G(L)->panic(L);exit( -EXIT_FAILURE);}}int luaD_rawrunprotected(lua_State*L,Pfunc f,void*ud){struct -lua_longjmp lj;lj.status=0;lj.previous=L->errorJmp;L->errorJmp=&lj;if(setjmp( -lj.b)==0)(*f)(L,ud);L->errorJmp=lj.previous;return lj.status;}static void -restore_stack_limit(lua_State*L){L->stack_last=L->stack+L->stacksize-1;if(L-> -size_ci>LUA_MAXCALLS){int inuse=(L->ci-L->base_ci);if(inuse+1top=(L->top-oldstack)+L->stack;for(up=L-> -openupval;up!=NULL;up=up->gch.next)gcotouv(up)->v=(gcotouv(up)->v-oldstack)+L -->stack;for(ci=L->base_ci;ci<=L->ci;ci++){ci->top=(ci->top-oldstack)+L->stack; -ci->base=(ci->base-oldstack)+L->stack;}L->base=L->ci->base;}void -luaD_reallocstack(lua_State*L,int newsize){TObject*oldstack=L->stack; -luaM_reallocvector(L,L->stack,L->stacksize,newsize,TObject);L->stacksize= -newsize;L->stack_last=L->stack+newsize-1-EXTRA_STACK;correctstack(L,oldstack); -}void luaD_reallocCI(lua_State*L,int newsize){CallInfo*oldci=L->base_ci; -luaM_reallocvector(L,L->base_ci,L->size_ci,newsize,CallInfo);L->size_ci=cast( -unsigned short,newsize);L->ci=(L->ci-oldci)+L->base_ci;L->end_ci=L->base_ci+L -->size_ci;}void luaD_growstack(lua_State*L,int n){if(n<=L->stacksize) -luaD_reallocstack(L,2*L->stacksize);else luaD_reallocstack(L,L->stacksize+n+ -EXTRA_STACK);}static void luaD_growCI(lua_State*L){if(L->size_ci>LUA_MAXCALLS) -luaD_throw(L,LUA_ERRERR);else{luaD_reallocCI(L,2*L->size_ci);if(L->size_ci> -LUA_MAXCALLS)luaG_runerror(L,"stack overflow");}}void luaD_callhook(lua_State* -L,int event,int line){lua_Hook hook=L->hook;if(hook&&L->allowhook){ptrdiff_t -top=savestack(L,L->top);ptrdiff_t ci_top=savestack(L,L->ci->top);lua_Debug ar; -ar.event=event;ar.currentline=line;if(event==LUA_HOOKTAILRET)ar.i_ci=0;else ar -.i_ci=L->ci-L->base_ci;luaD_checkstack(L,LUA_MINSTACK);L->ci->top=L->top+ -LUA_MINSTACK;L->allowhook=0;lua_unlock(L);(*hook)(L,&ar);lua_lock(L); -lua_assert(!L->allowhook);L->allowhook=1;L->ci->top=restorestack(L,ci_top);L-> -top=restorestack(L,top);}}static void adjust_varargs(lua_State*L,int nfixargs, -StkId base){int i;Table*htab;TObject nname;int actual=L->top-base;if(actual< -nfixargs){luaD_checkstack(L,nfixargs-actual);for(;actualtop++);}actual-=nfixargs;htab=luaH_new(L,actual,1);for(i=0;i< -actual;i++)setobj2n(luaH_setnum(L,htab,i+1),L->top-actual+i);setsvalue(&nname, -luaS_newliteral(L,"n"));setnvalue(luaH_set(L,htab,&nname),cast(lua_Number, -actual));L->top-=actual;sethvalue(L->top,htab);incr_top(L);}static StkId -tryfuncTM(lua_State*L,StkId func){const TObject*tm=luaT_gettmbyobj(L,func, -TM_CALL);StkId p;ptrdiff_t funcr=savestack(L,func);if(!ttisfunction(tm)) -luaG_typeerror(L,func,"call");for(p=L->top;p>func;p--)setobjs2s(p,p-1); -incr_top(L);func=restorestack(L,funcr);setobj2s(func,tm);return func;}StkId -luaD_precall(lua_State*L,StkId func){LClosure*cl;ptrdiff_t funcr=savestack(L, -func);if(!ttisfunction(func))func=tryfuncTM(L,func);if(L->ci+1==L->end_ci) -luaD_growCI(L);else condhardstacktests(luaD_reallocCI(L,L->size_ci));cl=& -clvalue(func)->l;if(!cl->isC){CallInfo*ci;Proto*p=cl->p;if(p->is_vararg) -adjust_varargs(L,p->numparams,func+1);luaD_checkstack(L,p->maxstacksize);ci=++ -L->ci;L->base=L->ci->base=restorestack(L,funcr)+1;ci->top=L->base+p-> -maxstacksize;ci->u.l.savedpc=p->code;ci->u.l.tailcalls=0;ci->state=CI_SAVEDPC; -while(L->toptop)setnilvalue(L->top++);L->top=ci->top;return NULL;}else{ -CallInfo*ci;int n;luaD_checkstack(L,LUA_MINSTACK);ci=++L->ci;L->base=L->ci-> -base=restorestack(L,funcr)+1;ci->top=L->top+LUA_MINSTACK;ci->state=CI_C;if(L-> -hookmask&LUA_MASKCALL)luaD_callhook(L,LUA_HOOKCALL,-1);lua_unlock(L); -#ifdef LUA_COMPATUPVALUES -lua_pushupvalues(L); -#endif -n=(*clvalue(L->base-1)->c.f)(L);lua_lock(L);return L->top-n;}}static StkId -callrethooks(lua_State*L,StkId firstResult){ptrdiff_t fr=savestack(L, -firstResult);luaD_callhook(L,LUA_HOOKRET,-1);if(!(L->ci->state&CI_C)){while(L -->ci->u.l.tailcalls--)luaD_callhook(L,LUA_HOOKTAILRET,-1);}return restorestack -(L,fr);}void luaD_poscall(lua_State*L,int wanted,StkId firstResult){StkId res; -if(L->hookmask&LUA_MASKRET)firstResult=callrethooks(L,firstResult);res=L->base --1;L->ci--;L->base=L->ci->base;while(wanted!=0&&firstResulttop){setobjs2s( -res++,firstResult++);wanted--;}while(wanted-->0)setnilvalue(res++);L->top=res; -}void luaD_call(lua_State*L,StkId func,int nResults){StkId firstResult; -lua_assert(!(L->ci->state&CI_CALLING));if(++L->nCcalls>=LUA_MAXCCALLS){if(L-> -nCcalls==LUA_MAXCCALLS)luaG_runerror(L,"C stack overflow");else if(L->nCcalls ->=(LUA_MAXCCALLS+(LUA_MAXCCALLS>>3)))luaD_throw(L,LUA_ERRERR);}firstResult= -luaD_precall(L,func);if(firstResult==NULL)firstResult=luaV_execute(L); -luaD_poscall(L,nResults,firstResult);L->nCcalls--;luaC_checkGC(L);}static void - resume(lua_State*L,void*ud){StkId firstResult;int nargs=*cast(int*,ud); -CallInfo*ci=L->ci;if(ci==L->base_ci){lua_assert(nargstop-L->base); -luaD_precall(L,L->top-(nargs+1));}else{lua_assert(ci->state&CI_YIELD);if(ci-> -state&CI_C){int nresults;lua_assert((ci-1)->state&CI_SAVEDPC);lua_assert( -GET_OPCODE(*((ci-1)->u.l.savedpc-1))==OP_CALL||GET_OPCODE(*((ci-1)->u.l. -savedpc-1))==OP_TAILCALL);nresults=GETARG_C(*((ci-1)->u.l.savedpc-1))-1; -luaD_poscall(L,nresults,L->top-nargs);if(nresults>=0)L->top=L->ci->top;}else{ -ci->state&=~CI_YIELD;}}firstResult=luaV_execute(L);if(firstResult!=NULL) -luaD_poscall(L,LUA_MULTRET,firstResult);}static int resume_error(lua_State*L, -const char*msg){L->top=L->ci->base;setsvalue2s(L->top,luaS_new(L,msg)); -incr_top(L);lua_unlock(L);return LUA_ERRRUN;}LUA_API int lua_resume(lua_State* -L,int nargs){int status;lu_byte old_allowhooks;lua_lock(L);if(L->ci==L-> -base_ci){if(nargs>=L->top-L->base)return resume_error(L, -"cannot resume dead coroutine");}else if(!(L->ci->state&CI_YIELD))return -resume_error(L,"cannot resume non-suspended coroutine");old_allowhooks=L-> -allowhook;lua_assert(L->errfunc==0&&L->nCcalls==0);status=luaD_rawrunprotected -(L,resume,&nargs);if(status!=0){L->ci=L->base_ci;L->base=L->ci->base;L-> -nCcalls=0;luaF_close(L,L->base);seterrorobj(L,status,L->base);L->allowhook= -old_allowhooks;restore_stack_limit(L);}lua_unlock(L);return status;}LUA_API -int lua_yield(lua_State*L,int nresults){CallInfo*ci;lua_lock(L);ci=L->ci;if(L -->nCcalls>0)luaG_runerror(L, -"attempt to yield across metamethod/C-call boundary");if(ci->state&CI_C){if(( -ci-1)->state&CI_C)luaG_runerror(L,"cannot yield a C function");if(L->top- -nresults>L->base){int i;for(i=0;ibase+i,L->top- -nresults+i);L->top=L->base+nresults;}}ci->state|=CI_YIELD;lua_unlock(L);return --1;}int luaD_pcall(lua_State*L,Pfunc func,void*u,ptrdiff_t old_top,ptrdiff_t -ef){int status;unsigned short oldnCcalls=L->nCcalls;ptrdiff_t old_ci=saveci(L, -L->ci);lu_byte old_allowhooks=L->allowhook;ptrdiff_t old_errfunc=L->errfunc;L -->errfunc=ef;status=luaD_rawrunprotected(L,func,u);if(status!=0){StkId oldtop= -restorestack(L,old_top);luaF_close(L,oldtop);seterrorobj(L,status,oldtop);L-> -nCcalls=oldnCcalls;L->ci=restoreci(L,old_ci);L->base=L->ci->base;L->allowhook= -old_allowhooks;restore_stack_limit(L);}L->errfunc=old_errfunc;return status;} -struct SParser{ZIO*z;Mbuffer buff;int bin;};static void f_parser(lua_State*L, -void*ud){struct SParser*p;Proto*tf;Closure*cl;luaC_checkGC(L);p=cast(struct -SParser*,ud);tf=p->bin?luaU_undump(L,p->z,&p->buff):luaY_parser(L,p->z,&p-> -buff);cl=luaF_newLclosure(L,0,gt(L));cl->l.p=tf;setclvalue(L->top,cl);incr_top -(L);}int luaD_protectedparser(lua_State*L,ZIO*z,int bin){struct SParser p;int -status;ptrdiff_t oldtopr=savestack(L,L->top);p.z=z;p.bin=bin;luaZ_initbuffer(L -,&p.buff);status=luaD_rawrunprotected(L,f_parser,&p);luaZ_freebuffer(L,&p.buff -);if(status!=0){StkId oldtop=restorestack(L,oldtopr);seterrorobj(L,status, -oldtop);}return status;} -#line 1 "ldump.c" -#define ldump_c -#define DumpVector(b,n,size,D) DumpBlock(b,(n)*(size),D) -#define DumpLiteral(s,D) DumpBlock(""s,(sizeof(s))-1,D) -typedef struct{lua_State*L;lua_Chunkwriter write;void*data;}DumpState;static -void DumpBlock(const void*b,size_t size,DumpState*D){lua_unlock(D->L);(*D-> -write)(D->L,b,size,D->data);lua_lock(D->L);}static void DumpByte(int y, -DumpState*D){char x=(char)y;DumpBlock(&x,sizeof(x),D);}static void DumpInt(int - x,DumpState*D){DumpBlock(&x,sizeof(x),D);}static void DumpSize(size_t x, -DumpState*D){DumpBlock(&x,sizeof(x),D);}static void DumpNumber(lua_Number x, -DumpState*D){DumpBlock(&x,sizeof(x),D);}static void DumpString(TString*s, -DumpState*D){if(s==NULL||getstr(s)==NULL)DumpSize(0,D);else{size_t size=s->tsv -.len+1;DumpSize(size,D);DumpBlock(getstr(s),size,D);}}static void DumpCode( -const Proto*f,DumpState*D){DumpInt(f->sizecode,D);DumpVector(f->code,f-> -sizecode,sizeof(*f->code),D);}static void DumpLocals(const Proto*f,DumpState*D -){int i,n=f->sizelocvars;DumpInt(n,D);for(i=0;ilocvars[i -].varname,D);DumpInt(f->locvars[i].startpc,D);DumpInt(f->locvars[i].endpc,D);} -}static void DumpLines(const Proto*f,DumpState*D){DumpInt(f->sizelineinfo,D); -DumpVector(f->lineinfo,f->sizelineinfo,sizeof(*f->lineinfo),D);}static void -DumpUpvalues(const Proto*f,DumpState*D){int i,n=f->sizeupvalues;DumpInt(n,D); -for(i=0;iupvalues[i],D);}static void DumpFunction(const -Proto*f,const TString*p,DumpState*D);static void DumpConstants(const Proto*f, -DumpState*D){int i,n;DumpInt(n=f->sizek,D);for(i=0;ik[i];DumpByte(ttype(o),D);switch(ttype(o)){case LUA_TNUMBER:DumpNumber( -nvalue(o),D);break;case LUA_TSTRING:DumpString(tsvalue(o),D);break;case -LUA_TNIL:break;default:lua_assert(0);break;}}DumpInt(n=f->sizep,D);for(i=0;ip[i],f->source,D);}static void DumpFunction(const Proto*f -,const TString*p,DumpState*D){DumpString((f->source==p)?NULL:f->source,D); -DumpInt(f->lineDefined,D);DumpByte(f->nups,D);DumpByte(f->numparams,D); -DumpByte(f->is_vararg,D);DumpByte(f->maxstacksize,D);DumpLines(f,D);DumpLocals -(f,D);DumpUpvalues(f,D);DumpConstants(f,D);DumpCode(f,D);}static void -DumpHeader(DumpState*D){DumpLiteral(LUA_SIGNATURE,D);DumpByte(VERSION,D); -DumpByte(luaU_endianness(),D);DumpByte(sizeof(int),D);DumpByte(sizeof(size_t), -D);DumpByte(sizeof(Instruction),D);DumpByte(SIZE_OP,D);DumpByte(SIZE_A,D); -DumpByte(SIZE_B,D);DumpByte(SIZE_C,D);DumpByte(sizeof(lua_Number),D); -DumpNumber(TEST_NUMBER,D);}void luaU_dump(lua_State*L,const Proto*Main, -lua_Chunkwriter w,void*data){DumpState D;D.L=L;D.write=w;D.data=data; -DumpHeader(&D);DumpFunction(Main,NULL,&D);} -#line 1 "lfunc.c" -#define lfunc_c -#define sizeCclosure(n) (cast(int,sizeof(CClosure))+cast(int,sizeof(TObject)*(\ -(n)-1))) -#define sizeLclosure(n) (cast(int,sizeof(LClosure))+cast(int,sizeof(TObject*)*\ -((n)-1))) -Closure*luaF_newCclosure(lua_State*L,int nelems){Closure*c=cast(Closure*, -luaM_malloc(L,sizeCclosure(nelems)));luaC_link(L,valtogco(c),LUA_TFUNCTION);c -->c.isC=1;c->c.nupvalues=cast(lu_byte,nelems);return c;}Closure* -luaF_newLclosure(lua_State*L,int nelems,TObject*e){Closure*c=cast(Closure*, -luaM_malloc(L,sizeLclosure(nelems)));luaC_link(L,valtogco(c),LUA_TFUNCTION);c -->l.isC=0;c->l.g=*e;c->l.nupvalues=cast(lu_byte,nelems);return c;}UpVal* -luaF_findupval(lua_State*L,StkId level){GCObject**pp=&L->openupval;UpVal*p; -UpVal*v;while((p=ngcotouv(*pp))!=NULL&&p->v>=level){if(p->v==level)return p;pp -=&p->next;}v=luaM_new(L,UpVal);v->tt=LUA_TUPVAL;v->marked=1;v->v=level;v->next -=*pp;*pp=valtogco(v);return v;}void luaF_close(lua_State*L,StkId level){UpVal* -p;while((p=ngcotouv(L->openupval))!=NULL&&p->v>=level){setobj(&p->value,p->v); -p->v=&p->value;L->openupval=p->next;luaC_link(L,valtogco(p),LUA_TUPVAL);}} -Proto*luaF_newproto(lua_State*L){Proto*f=luaM_new(L,Proto);luaC_link(L, -valtogco(f),LUA_TPROTO);f->k=NULL;f->sizek=0;f->p=NULL;f->sizep=0;f->code=NULL -;f->sizecode=0;f->sizelineinfo=0;f->sizeupvalues=0;f->nups=0;f->upvalues=NULL; -f->numparams=0;f->is_vararg=0;f->maxstacksize=0;f->lineinfo=NULL;f-> -sizelocvars=0;f->locvars=NULL;f->lineDefined=0;f->source=NULL;return f;}void -luaF_freeproto(lua_State*L,Proto*f){luaM_freearray(L,f->code,f->sizecode, -Instruction);luaM_freearray(L,f->p,f->sizep,Proto*);luaM_freearray(L,f->k,f-> -sizek,TObject);luaM_freearray(L,f->lineinfo,f->sizelineinfo,int); -luaM_freearray(L,f->locvars,f->sizelocvars,struct LocVar);luaM_freearray(L,f-> -upvalues,f->sizeupvalues,TString*);luaM_freelem(L,f);}void luaF_freeclosure( -lua_State*L,Closure*c){int size=(c->c.isC)?sizeCclosure(c->c.nupvalues): -sizeLclosure(c->l.nupvalues);luaM_free(L,c,size);}const char*luaF_getlocalname -(const Proto*f,int local_number,int pc){int i;for(i=0;isizelocvars&&f-> -locvars[i].startpc<=pc;i++){if(pclocvars[i].endpc){local_number--;if( -local_number==0)return getstr(f->locvars[i].varname);}}return NULL;} -#line 1 "lgc.c" -#define lgc_c -typedef struct GCState{GCObject*tmark;GCObject*wk;GCObject*wv;GCObject*wkv; -global_State*g;}GCState; -#define setbit(x,b) ((x)|=(1<<(b))) -#define resetbit(x,b) ((x)&=cast(lu_byte,~(1<<(b)))) -#define testbit(x,b) ((x)&(1<<(b))) -#define unmark(x) resetbit((x)->gch.marked,0) -#define ismarked(x) ((x)->gch.marked&((1<<4)|1)) -#define stringmark(s) setbit((s)->tsv.marked,0) -#define isfinalized(u) (!testbit((u)->uv.marked,1)) -#define markfinalized(u) resetbit((u)->uv.marked,1) -#define KEYWEAKBIT 1 -#define VALUEWEAKBIT 2 -#define KEYWEAK (1<gch.marked,0);switch(o->gch.tt){case LUA_TUSERDATA:{markvalue(st, -gcotou(o)->uv.metatable);break;}case LUA_TFUNCTION:{gcotocl(o)->c.gclist=st-> -tmark;st->tmark=o;break;}case LUA_TTABLE:{gcotoh(o)->gclist=st->tmark;st-> -tmark=o;break;}case LUA_TTHREAD:{gcototh(o)->gclist=st->tmark;st->tmark=o; -break;}case LUA_TPROTO:{gcotop(o)->gclist=st->tmark;st->tmark=o;break;}default -:lua_assert(o->gch.tt==LUA_TSTRING);}}static void marktmu(GCState*st){GCObject -*u;for(u=st->g->tmudata;u;u=u->gch.next){unmark(u);reallymarkobject(st,u);}} -size_t luaC_separateudata(lua_State*L){size_t deadmem=0;GCObject**p=&G(L)-> -rootudata;GCObject*curr;GCObject*collected=NULL;GCObject**lastcollected=& -collected;while((curr=*p)!=NULL){lua_assert(curr->gch.tt==LUA_TUSERDATA);if( -ismarked(curr)||isfinalized(gcotou(curr)))p=&curr->gch.next;else if(fasttm(L, -gcotou(curr)->uv.metatable,TM_GC)==NULL){markfinalized(gcotou(curr));p=&curr-> -gch.next;}else{deadmem+=sizeudata(gcotou(curr)->uv.len);*p=curr->gch.next;curr -->gch.next=NULL;*lastcollected=curr;lastcollected=&curr->gch.next;}}* -lastcollected=G(L)->tmudata;G(L)->tmudata=collected;return deadmem;}static -void removekey(Node*n){setnilvalue(gval(n));if(iscollectable(gkey(n)))setttype -(gkey(n),LUA_TNONE);}static void traversetable(GCState*st,Table*h){int i;int -weakkey=0;int weakvalue=0;const TObject*mode;markvalue(st,h->metatable); -lua_assert(h->lsizenode||h->node==st->g->dummynode);mode=gfasttm(st->g,h-> -metatable,TM_MODE);if(mode&&ttisstring(mode)){weakkey=(strchr(svalue(mode),'k' -)!=NULL);weakvalue=(strchr(svalue(mode),'v')!=NULL);if(weakkey||weakvalue){ -GCObject**weaklist;h->marked&=~(KEYWEAK|VALUEWEAK);h->marked|=cast(lu_byte,( -weakkey<wkv:(weakkey)?&st->wk:&st->wv;h->gclist=*weaklist;*weaklist=valtogco(h);} -}if(!weakvalue){i=h->sizearray;while(i--)markobject(st,&h->array[i]);}i= -sizenode(h);while(i--){Node*n=gnode(h,i);if(!ttisnil(gval(n))){lua_assert(! -ttisnil(gkey(n)));condmarkobject(st,gkey(n),!weakkey);condmarkobject(st,gval(n -),!weakvalue);}}}static void traverseproto(GCState*st,Proto*f){int i; -stringmark(f->source);for(i=0;isizek;i++){if(ttisstring(f->k+i))stringmark -(tsvalue(f->k+i));}for(i=0;isizeupvalues;i++)stringmark(f->upvalues[i]); -for(i=0;isizep;i++)markvalue(st,f->p[i]);for(i=0;isizelocvars;i++) -stringmark(f->locvars[i].varname);lua_assert(luaG_checkcode(f));}static void -traverseclosure(GCState*st,Closure*cl){if(cl->c.isC){int i;for(i=0;ic. -nupvalues;i++)markobject(st,&cl->c.upvalue[i]);}else{int i;lua_assert(cl->l. -nupvalues==cl->l.p->nups);markvalue(st,hvalue(&cl->l.g));markvalue(st,cl->l.p) -;for(i=0;il.nupvalues;i++){UpVal*u=cl->l.upvals[i];if(!u->marked){ -markobject(st,&u->value);u->marked=1;}}}}static void checkstacksizes(lua_State -*L,StkId max){int used=L->ci-L->base_ci;if(4*usedsize_ci&&2*BASIC_CI_SIZE< -L->size_ci)luaD_reallocCI(L,L->size_ci/2);else condhardstacktests( -luaD_reallocCI(L,L->size_ci));used=max-L->stack;if(4*usedstacksize&&2*( -BASIC_STACK_SIZE+EXTRA_STACK)stacksize)luaD_reallocstack(L,L->stacksize/2) -;else condhardstacktests(luaD_reallocstack(L,L->stacksize));}static void -traversestack(GCState*st,lua_State*L1){StkId o,lim;CallInfo*ci;markobject(st, -gt(L1));lim=L1->top;for(ci=L1->base_ci;ci<=L1->ci;ci++){lua_assert(ci->top<=L1 -->stack_last);lua_assert(ci->state&(CI_C|CI_HASFRAME|CI_SAVEDPC));if(lim -top)lim=ci->top;}for(o=L1->stack;otop;o++)markobject(st,o);for(;o<=lim;o -++)setnilvalue(o);checkstacksizes(L1,lim);}static void propagatemarks(GCState* -st){while(st->tmark){switch(st->tmark->gch.tt){case LUA_TTABLE:{Table*h=gcotoh -(st->tmark);st->tmark=h->gclist;traversetable(st,h);break;}case LUA_TFUNCTION: -{Closure*cl=gcotocl(st->tmark);st->tmark=cl->c.gclist;traverseclosure(st,cl); -break;}case LUA_TTHREAD:{lua_State*th=gcototh(st->tmark);st->tmark=th->gclist; -traversestack(st,th);break;}case LUA_TPROTO:{Proto*p=gcotop(st->tmark);st-> -tmark=p->gclist;traverseproto(st,p);break;}default:lua_assert(0);}}}static int - valismarked(const TObject*o){if(ttisstring(o))stringmark(tsvalue(o));return! -iscollectable(o)||testbit(o->value.gc->gch.marked,0);}static void -cleartablekeys(GCObject*l){while(l){Table*h=gcotoh(l);int i=sizenode(h); -lua_assert(h->marked&KEYWEAK);while(i--){Node*n=gnode(h,i);if(!valismarked( -gkey(n)))removekey(n);}l=h->gclist;}}static void cleartablevalues(GCObject*l){ -while(l){Table*h=gcotoh(l);int i=h->sizearray;lua_assert(h->marked&VALUEWEAK); -while(i--){TObject*o=&h->array[i];if(!valismarked(o))setnilvalue(o);}i= -sizenode(h);while(i--){Node*n=gnode(h,i);if(!valismarked(gval(n)))removekey(n) -;}l=h->gclist;}}static void freeobj(lua_State*L,GCObject*o){switch(o->gch.tt){ -case LUA_TPROTO:luaF_freeproto(L,gcotop(o));break;case LUA_TFUNCTION: -luaF_freeclosure(L,gcotocl(o));break;case LUA_TUPVAL:luaM_freelem(L,gcotouv(o) -);break;case LUA_TTABLE:luaH_free(L,gcotoh(o));break;case LUA_TTHREAD:{ -lua_assert(gcototh(o)!=L&&gcototh(o)!=G(L)->mainthread);luaE_freethread(L, -gcototh(o));break;}case LUA_TSTRING:{luaM_free(L,o,sizestring(gcotots(o)->tsv. -len));break;}case LUA_TUSERDATA:{luaM_free(L,o,sizeudata(gcotou(o)->uv.len)); -break;}default:lua_assert(0);}}static int sweeplist(lua_State*L,GCObject**p, -int limit){GCObject*curr;int count=0;while((curr=*p)!=NULL){if(curr->gch. -marked>limit){unmark(curr);p=&curr->gch.next;}else{count++;*p=curr->gch.next; -freeobj(L,curr);}}return count;}static void sweepstrings(lua_State*L,int all){ -int i;for(i=0;istrt.size;i++){G(L)->strt.nuse-=sweeplist(L,&G(L)->strt. -hash[i],all);}}static void checkSizes(lua_State*L,size_t deadmem){if(G(L)-> -strt.nusestrt.size/4)&&G(L)->strt.size>MINSTRTABSIZE*2) -luaS_resize(L,G(L)->strt.size/2);if(luaZ_sizebuffer(&G(L)->buff)>LUA_MINBUFFER -*2){size_t newsize=luaZ_sizebuffer(&G(L)->buff)/2;luaZ_resizebuffer(L,&G(L)-> -buff,newsize);}G(L)->GCthreshold=2*G(L)->nblocks-deadmem;}static void do1gcTM( -lua_State*L,Udata*udata){const TObject*tm=fasttm(L,udata->uv.metatable,TM_GC); -if(tm!=NULL){setobj2s(L->top,tm);setuvalue(L->top+1,udata);L->top+=2;luaD_call -(L,L->top-2,0);}}void luaC_callGCTM(lua_State*L){lu_byte oldah=L->allowhook;L -->allowhook=0;L->top++;while(G(L)->tmudata!=NULL){GCObject*o=G(L)->tmudata; -Udata*udata=gcotou(o);G(L)->tmudata=udata->uv.next;udata->uv.next=G(L)-> -rootudata;G(L)->rootudata=o;setuvalue(L->top-1,udata);unmark(o);markfinalized( -udata);do1gcTM(L,udata);}L->top--;L->allowhook=oldah;}void luaC_sweep( -lua_State*L,int all){if(all)all=256;sweeplist(L,&G(L)->rootudata,all); -sweepstrings(L,all);sweeplist(L,&G(L)->rootgc,all);}static void markroot( -GCState*st,lua_State*L){global_State*g=st->g;markobject(st,defaultmeta(L)); -markobject(st,registry(L));traversestack(st,g->mainthread);if(L!=g->mainthread -)markvalue(st,L);}static size_t mark(lua_State*L){size_t deadmem;GCState st; -GCObject*wkv;st.g=G(L);st.tmark=NULL;st.wkv=st.wk=st.wv=NULL;markroot(&st,L); -propagatemarks(&st);cleartablevalues(st.wkv);cleartablevalues(st.wv);wkv=st. -wkv;st.wkv=NULL;st.wv=NULL;deadmem=luaC_separateudata(L);marktmu(&st); -propagatemarks(&st);cleartablekeys(wkv);cleartablekeys(st.wk);cleartablevalues -(st.wv);cleartablekeys(st.wkv);cleartablevalues(st.wkv);return deadmem;}void -luaC_collectgarbage(lua_State*L){size_t deadmem=mark(L);luaC_sweep(L,0); -checkSizes(L,deadmem);luaC_callGCTM(L);}void luaC_link(lua_State*L,GCObject*o, -lu_byte tt){o->gch.next=G(L)->rootgc;G(L)->rootgc=o;o->gch.marked=0;o->gch.tt= -tt;} -#line 1 "liolib.c" -#define liolib_c -#ifndef USE_TMPNAME -#ifdef __GNUC__ -#define USE_TMPNAME 0 -#else -#define USE_TMPNAME 1 -#endif -#endif -#ifndef USE_POPEN -#ifdef _POSIX_C_SOURCE -#if _POSIX_C_SOURCE >=2 -#define USE_POPEN 1 -#endif -#endif -#endif -#ifndef USE_POPEN -#define USE_POPEN 0 -#endif -#if !USE_POPEN -#define pclose(f) (-1) -#endif -#define FILEHANDLE "FILE*" -#define IO_INPUT "_input" -#define IO_OUTPUT "_output" -static int pushresult(lua_State*L,int i,const char*filename){if(i){ -lua_pushboolean(L,1);return 1;}else{lua_pushnil(L);if(filename)lua_pushfstring -(L,"%s: %s",filename,strerror(errno));else lua_pushfstring(L,"%s",strerror( -errno));lua_pushnumber(L,errno);return 3;}}static FILE**topfile(lua_State*L, -int findex){FILE**f=(FILE**)luaL_checkudata(L,findex,FILEHANDLE);if(f==NULL) -luaL_argerror(L,findex,"bad file");return f;}static int io_type(lua_State*L){ -FILE**f=(FILE**)luaL_checkudata(L,1,FILEHANDLE);if(f==NULL)lua_pushnil(L);else - if(*f==NULL)lua_pushliteral(L,"closed file");else lua_pushliteral(L,"file"); -return 1;}static FILE*tofile(lua_State*L,int findex){FILE**f=topfile(L,findex) -;if(*f==NULL)luaL_error(L,"attempt to use a closed file");return*f;}static -FILE**newfile(lua_State*L){FILE**pf=(FILE**)lua_newuserdata(L,sizeof(FILE*));* -pf=NULL;luaL_getmetatable(L,FILEHANDLE);lua_setmetatable(L,-2);return pf;} -static void registerfile(lua_State*L,FILE*f,const char*name,const char*impname -){lua_pushstring(L,name);*newfile(L)=f;if(impname){lua_pushstring(L,impname); -lua_pushvalue(L,-2);lua_settable(L,-6);}lua_settable(L,-3);}static int -aux_close(lua_State*L){FILE*f=tofile(L,1);if(f==stdin||f==stdout||f==stderr) -return 0;else{int ok=(pclose(f)!=-1)||(fclose(f)==0);if(ok)*(FILE**) -lua_touserdata(L,1)=NULL;return ok;}}static int io_close(lua_State*L){if( -lua_isnone(L,1)&&lua_type(L,lua_upvalueindex(1))==LUA_TTABLE){lua_pushstring(L -,IO_OUTPUT);lua_rawget(L,lua_upvalueindex(1));}return pushresult(L,aux_close(L -),NULL);}static int io_gc(lua_State*L){FILE**f=topfile(L,1);if(*f!=NULL) -aux_close(L);return 0;}static int io_tostring(lua_State*L){char buff[128];FILE -**f=topfile(L,1);if(*f==NULL)strcpy(buff,"closed");else sprintf(buff,"%p", -lua_touserdata(L,1));lua_pushfstring(L,"file (%s)",buff);return 1;}static int -io_open(lua_State*L){const char*filename=luaL_checkstring(L,1);const char*mode -=luaL_optstring(L,2,"r");FILE**pf=newfile(L);*pf=fopen(filename,mode);return(* -pf==NULL)?pushresult(L,0,filename):1;}static int io_popen(lua_State*L){ -#if !USE_POPEN -luaL_error(L,"`popen' not supported");return 0; -#else -const char*filename=luaL_checkstring(L,1);const char*mode=luaL_optstring(L,2, -"r");FILE**pf=newfile(L);*pf=popen(filename,mode);return(*pf==NULL)?pushresult -(L,0,filename):1; -#endif -}static int io_tmpfile(lua_State*L){FILE**pf=newfile(L);*pf=tmpfile();return(* -pf==NULL)?pushresult(L,0,NULL):1;}static FILE*getiofile(lua_State*L,const char -*name){lua_pushstring(L,name);lua_rawget(L,lua_upvalueindex(1));return tofile( -L,-1);}static int g_iofile(lua_State*L,const char*name,const char*mode){if(! -lua_isnoneornil(L,1)){const char*filename=lua_tostring(L,1);lua_pushstring(L, -name);if(filename){FILE**pf=newfile(L);*pf=fopen(filename,mode);if(*pf==NULL){ -lua_pushfstring(L,"%s: %s",filename,strerror(errno));luaL_argerror(L,1, -lua_tostring(L,-1));}}else{tofile(L,1);lua_pushvalue(L,1);}lua_rawset(L, -lua_upvalueindex(1));}lua_pushstring(L,name);lua_rawget(L,lua_upvalueindex(1)) -;return 1;}static int io_input(lua_State*L){return g_iofile(L,IO_INPUT,"r");} -static int io_output(lua_State*L){return g_iofile(L,IO_OUTPUT,"w");}static int - io_readline(lua_State*L);static void aux_lines(lua_State*L,int idx,int close) -{lua_pushliteral(L,FILEHANDLE);lua_rawget(L,LUA_REGISTRYINDEX);lua_pushvalue(L -,idx);lua_pushboolean(L,close);lua_pushcclosure(L,io_readline,3);}static int -f_lines(lua_State*L){tofile(L,1);aux_lines(L,1,0);return 1;}static int -io_lines(lua_State*L){if(lua_isnoneornil(L,1)){lua_pushstring(L,IO_INPUT); -lua_rawget(L,lua_upvalueindex(1));return f_lines(L);}else{const char*filename= -luaL_checkstring(L,1);FILE**pf=newfile(L);*pf=fopen(filename,"r"); -luaL_argcheck(L,*pf,1,strerror(errno));aux_lines(L,lua_gettop(L),1);return 1;} -}static int read_number(lua_State*L,FILE*f){lua_Number d;if(fscanf(f, -LUA_NUMBER_SCAN,&d)==1){lua_pushnumber(L,d);return 1;}else return 0;}static -int test_eof(lua_State*L,FILE*f){int c=getc(f);ungetc(c,f);lua_pushlstring(L, -NULL,0);return(c!=EOF);}static int read_line(lua_State*L,FILE*f){luaL_Buffer b -;luaL_buffinit(L,&b);for(;;){size_t l;char*p=luaL_prepbuffer(&b);if(fgets(p, -LUAL_BUFFERSIZE,f)==NULL){luaL_pushresult(&b);return(lua_strlen(L,-1)>0);}l= -strlen(p);if(p[l-1]!='\n')luaL_addsize(&b,l);else{luaL_addsize(&b,l-1); -luaL_pushresult(&b);return 1;}}}static int read_chars(lua_State*L,FILE*f, -size_t n){size_t rlen;size_t nr;luaL_Buffer b;luaL_buffinit(L,&b);rlen= -LUAL_BUFFERSIZE;do{char*p=luaL_prepbuffer(&b);if(rlen>n)rlen=n;nr=fread(p, -sizeof(char),rlen,f);luaL_addsize(&b,nr);n-=nr;}while(n>0&&nr==rlen); -luaL_pushresult(&b);return(n==0||lua_strlen(L,-1)>0);}static int g_read( -lua_State*L,FILE*f,int first){int nargs=lua_gettop(L)-1;int success;int n;if( -nargs==0){success=read_line(L,f);n=first+1;}else{luaL_checkstack(L,nargs+ -LUA_MINSTACK,"too many arguments");success=1;for(n=first;nargs--&&success;n++) -{if(lua_type(L,n)==LUA_TNUMBER){size_t l=(size_t)lua_tonumber(L,n);success=(l -==0)?test_eof(L,f):read_chars(L,f,l);}else{const char*p=lua_tostring(L,n); -luaL_argcheck(L,p&&p[0]=='*',n,"invalid option");switch(p[1]){case'n':success= -read_number(L,f);break;case'l':success=read_line(L,f);break;case'a':read_chars -(L,f,~((size_t)0));success=1;break;case'w':return luaL_error(L, -"obsolete option `*w' to `read'");default:return luaL_argerror(L,n, -"invalid format");}}}}if(!success){lua_pop(L,1);lua_pushnil(L);}return n-first -;}static int io_read(lua_State*L){return g_read(L,getiofile(L,IO_INPUT),1);} -static int f_read(lua_State*L){return g_read(L,tofile(L,1),2);}static int -io_readline(lua_State*L){FILE*f=*(FILE**)lua_touserdata(L,lua_upvalueindex(2)) -;if(f==NULL)luaL_error(L,"file is already closed");if(read_line(L,f))return 1; -else{if(lua_toboolean(L,lua_upvalueindex(3))){lua_settop(L,0);lua_pushvalue(L, -lua_upvalueindex(2));aux_close(L);}return 0;}}static int g_write(lua_State*L, -FILE*f,int arg){int nargs=lua_gettop(L)-1;int status=1;for(;nargs--;arg++){if( -lua_type(L,arg)==LUA_TNUMBER){status=status&&fprintf(f,LUA_NUMBER_FMT, -lua_tonumber(L,arg))>0;}else{size_t l;const char*s=luaL_checklstring(L,arg,&l) -;status=status&&(fwrite(s,sizeof(char),l,f)==l);}}return pushresult(L,status, -NULL);}static int io_write(lua_State*L){return g_write(L,getiofile(L,IO_OUTPUT -),1);}static int f_write(lua_State*L){return g_write(L,tofile(L,1),2);}static -int f_seek(lua_State*L){static const int mode[]={SEEK_SET,SEEK_CUR,SEEK_END}; -static const char*const modenames[]={"set","cur","end",NULL};FILE*f=tofile(L,1 -);int op=luaL_findstring(luaL_optstring(L,2,"cur"),modenames);long offset= -luaL_optlong(L,3,0);luaL_argcheck(L,op!=-1,2,"invalid mode");op=fseek(f,offset -,mode[op]);if(op)return pushresult(L,0,NULL);else{lua_pushnumber(L,ftell(f)); -return 1;}}static int io_flush(lua_State*L){return pushresult(L,fflush( -getiofile(L,IO_OUTPUT))==0,NULL);}static int f_flush(lua_State*L){return -pushresult(L,fflush(tofile(L,1))==0,NULL);}static const luaL_reg iolib[]={{ -"input",io_input},{"output",io_output},{"lines",io_lines},{"close",io_close},{ -"flush",io_flush},{"open",io_open},{"popen",io_popen},{"read",io_read},{ -"tmpfile",io_tmpfile},{"type",io_type},{"write",io_write},{NULL,NULL}};static -const luaL_reg flib[]={{"flush",f_flush},{"read",f_read},{"lines",f_lines},{ -"seek",f_seek},{"write",f_write},{"close",io_close},{"__gc",io_gc},{ -"__tostring",io_tostring},{NULL,NULL}};static void createmeta(lua_State*L){ -luaL_newmetatable(L,FILEHANDLE);lua_pushliteral(L,"__index");lua_pushvalue(L,- -2);lua_rawset(L,-3);luaL_openlib(L,NULL,flib,0);}static int io_execute( -lua_State*L){lua_pushnumber(L,system(luaL_checkstring(L,1)));return 1;}static -int io_remove(lua_State*L){const char*filename=luaL_checkstring(L,1);return -pushresult(L,remove(filename)==0,filename);}static int io_rename(lua_State*L){ -const char*fromname=luaL_checkstring(L,1);const char*toname=luaL_checkstring(L -,2);return pushresult(L,rename(fromname,toname)==0,fromname);}static int -io_tmpname(lua_State*L){ -#if !USE_TMPNAME -luaL_error(L,"`tmpname' not supported");return 0; -#else -char buff[L_tmpnam];if(tmpnam(buff)!=buff)return luaL_error(L, -"unable to generate a unique filename in `tmpname'");lua_pushstring(L,buff); -return 1; -#endif -}static int io_getenv(lua_State*L){lua_pushstring(L,getenv(luaL_checkstring(L, -1)));return 1;}static int io_clock(lua_State*L){lua_pushnumber(L,((lua_Number) -clock())/(lua_Number)CLOCKS_PER_SEC);return 1;}static void setfield(lua_State* -L,const char*key,int value){lua_pushstring(L,key);lua_pushnumber(L,value); -lua_rawset(L,-3);}static void setboolfield(lua_State*L,const char*key,int -value){lua_pushstring(L,key);lua_pushboolean(L,value);lua_rawset(L,-3);}static - int getboolfield(lua_State*L,const char*key){int res;lua_pushstring(L,key); -lua_gettable(L,-2);res=lua_toboolean(L,-1);lua_pop(L,1);return res;}static int - getfield(lua_State*L,const char*key,int d){int res;lua_pushstring(L,key); -lua_gettable(L,-2);if(lua_isnumber(L,-1))res=(int)(lua_tonumber(L,-1));else{if -(d==-2)return luaL_error(L,"field `%s' missing in date table",key);res=d;} -lua_pop(L,1);return res;}static int io_date(lua_State*L){const char*s= -luaL_optstring(L,1,"%c");time_t t=(time_t)(luaL_optnumber(L,2,-1));struct tm* -stm;if(t==(time_t)(-1))t=time(NULL);if(*s=='!'){stm=gmtime(&t);s++;}else stm= -localtime(&t);if(stm==NULL)lua_pushnil(L);else if(strcmp(s,"*t")==0){ -lua_newtable(L);setfield(L,"sec",stm->tm_sec);setfield(L,"min",stm->tm_min); -setfield(L,"hour",stm->tm_hour);setfield(L,"day",stm->tm_mday);setfield(L, -"month",stm->tm_mon+1);setfield(L,"year",stm->tm_year+1900);setfield(L,"wday", -stm->tm_wday+1);setfield(L,"yday",stm->tm_yday+1);setboolfield(L,"isdst",stm-> -tm_isdst);}else{char b[256];if(strftime(b,sizeof(b),s,stm))lua_pushstring(L,b) -;else return luaL_error(L,"`date' format too long");}return 1;}static int -io_time(lua_State*L){if(lua_isnoneornil(L,1))lua_pushnumber(L,time(NULL));else -{time_t t;struct tm ts;luaL_checktype(L,1,LUA_TTABLE);lua_settop(L,1);ts. -tm_sec=getfield(L,"sec",0);ts.tm_min=getfield(L,"min",0);ts.tm_hour=getfield(L -,"hour",12);ts.tm_mday=getfield(L,"day",-2);ts.tm_mon=getfield(L,"month",-2)-1 -;ts.tm_year=getfield(L,"year",-2)-1900;ts.tm_isdst=getboolfield(L,"isdst");t= -mktime(&ts);if(t==(time_t)(-1))lua_pushnil(L);else lua_pushnumber(L,t);}return - 1;}static int io_difftime(lua_State*L){lua_pushnumber(L,difftime((time_t)( -luaL_checknumber(L,1)),(time_t)(luaL_optnumber(L,2,0))));return 1;}static int -io_setloc(lua_State*L){static const int cat[]={LC_ALL,LC_COLLATE,LC_CTYPE, -LC_MONETARY,LC_NUMERIC,LC_TIME};static const char*const catnames[]={"all", -"collate","ctype","monetary","numeric","time",NULL};const char*l=lua_tostring( -L,1);int op=luaL_findstring(luaL_optstring(L,2,"all"),catnames);luaL_argcheck( -L,l||lua_isnoneornil(L,1),1,"string expected");luaL_argcheck(L,op!=-1,2, -"invalid option");lua_pushstring(L,setlocale(cat[op],l));return 1;}static int -io_exit(lua_State*L){exit(luaL_optint(L,1,EXIT_SUCCESS));return 0;}static -const luaL_reg syslib[]={{"clock",io_clock},{"date",io_date},{"difftime", -io_difftime},{"execute",io_execute},{"exit",io_exit},{"getenv",io_getenv},{ -"remove",io_remove},{"rename",io_rename},{"setlocale",io_setloc},{"time", -io_time},{"tmpname",io_tmpname},{NULL,NULL}};LUALIB_API int luaopen_io( -lua_State*L){luaL_openlib(L,LUA_OSLIBNAME,syslib,0);createmeta(L); -lua_pushvalue(L,-1);luaL_openlib(L,LUA_IOLIBNAME,iolib,1);registerfile(L,stdin -,"stdin",IO_INPUT);registerfile(L,stdout,"stdout",IO_OUTPUT);registerfile(L, -stderr,"stderr",NULL);return 1;} -#line 1 "llex.c" -#define llex_c -#define next(LS) (LS->current=zgetc(LS->z)) -static const char*const token2string[]={"and","break","do","else","elseif", -"end","false","for","function","if","in","local","nil","not","or","repeat", -"return","then","true","until","while","*name","..","...","==",">=","<=","~=", -"*number","*string",""};void luaX_init(lua_State*L){int i;for(i=0;i< -NUM_RESERVED;i++){TString*ts=luaS_new(L,token2string[i]);luaS_fix(ts); -lua_assert(strlen(token2string[i])+1<=TOKEN_LEN);ts->tsv.reserved=cast(lu_byte -,i+1);}} -#define MAXSRC 80 -void luaX_checklimit(LexState*ls,int val,int limit,const char*msg){if(val> -limit){msg=luaO_pushfstring(ls->L,"too many %s (limit=%d)",msg,limit); -luaX_syntaxerror(ls,msg);}}void luaX_errorline(LexState*ls,const char*s,const -char*token,int line){lua_State*L=ls->L;char buff[MAXSRC];luaO_chunkid(buff, -getstr(ls->source),MAXSRC);luaO_pushfstring(L,"%s:%d: %s near `%s'",buff,line, -s,token);luaD_throw(L,LUA_ERRSYNTAX);}static void luaX_error(LexState*ls,const - char*s,const char*token){luaX_errorline(ls,s,token,ls->linenumber);}void -luaX_syntaxerror(LexState*ls,const char*msg){const char*lasttoken;switch(ls->t -.token){case TK_NAME:lasttoken=getstr(ls->t.seminfo.ts);break;case TK_STRING: -case TK_NUMBER:lasttoken=luaZ_buffer(ls->buff);break;default:lasttoken= -luaX_token2str(ls,ls->t.token);break;}luaX_error(ls,msg,lasttoken);}const char -*luaX_token2str(LexState*ls,int token){if(tokenL,"%c",token);}else -return token2string[token-FIRST_RESERVED];}static void luaX_lexerror(LexState* -ls,const char*s,int token){if(token==TK_EOS)luaX_error(ls,s,luaX_token2str(ls, -token));else luaX_error(ls,s,luaZ_buffer(ls->buff));}static void inclinenumber -(LexState*LS){next(LS);++LS->linenumber;luaX_checklimit(LS,LS->linenumber, -MAX_INT,"lines in a chunk");}void luaX_setinput(lua_State*L,LexState*LS,ZIO*z, -TString*source){LS->L=L;LS->lookahead.token=TK_EOS;LS->z=z;LS->fs=NULL;LS-> -linenumber=1;LS->lastline=1;LS->source=source;next(LS);if(LS->current=='#'){do -{next(LS);}while(LS->current!='\n'&&LS->current!=EOZ);}} -#define EXTRABUFF 32 -#define MAXNOCHECK 5 -#define checkbuffer(LS, len)if(((len)+MAXNOCHECK)*sizeof(char)>luaZ_sizebuffer\ -((LS)->buff))luaZ_openspace((LS)->L,(LS)->buff,(len)+EXTRABUFF) -#define save(LS, c,l)(luaZ_buffer((LS)->buff)[l++]=cast(char,c)) -#define save_and_next(LS, l)(save(LS,LS->current,l),next(LS)) -static size_t readname(LexState*LS){size_t l=0;checkbuffer(LS,l);do{ -checkbuffer(LS,l);save_and_next(LS,l);}while(isalnum(LS->current)||LS->current -=='_');save(LS,'\0',l);return l-1;}static void read_numeral(LexState*LS,int -comma,SemInfo*seminfo){size_t l=0;checkbuffer(LS,l);if(comma)save(LS,'.',l); -while(isdigit(LS->current)){checkbuffer(LS,l);save_and_next(LS,l);}if(LS-> -current=='.'){save_and_next(LS,l);if(LS->current=='.'){save_and_next(LS,l); -save(LS,'\0',l);luaX_lexerror(LS, -"ambiguous syntax (decimal point x string concatenation)",TK_NUMBER);}}while( -isdigit(LS->current)){checkbuffer(LS,l);save_and_next(LS,l);}if(LS->current== -'e'||LS->current=='E'){save_and_next(LS,l);if(LS->current=='+'||LS->current== -'-')save_and_next(LS,l);while(isdigit(LS->current)){checkbuffer(LS,l); -save_and_next(LS,l);}}save(LS,'\0',l);if(!luaO_str2d(luaZ_buffer(LS->buff),& -seminfo->r))luaX_lexerror(LS,"malformed number",TK_NUMBER);}static void -read_long_string(LexState*LS,SemInfo*seminfo){int cont=0;size_t l=0; -checkbuffer(LS,l);save(LS,'[',l);save_and_next(LS,l);if(LS->current=='\n') -inclinenumber(LS);for(;;){checkbuffer(LS,l);switch(LS->current){case EOZ:save( -LS,'\0',l);luaX_lexerror(LS,(seminfo)?"unfinished long string": -"unfinished long comment",TK_EOS);break;case'[':save_and_next(LS,l);if(LS-> -current=='['){cont++;save_and_next(LS,l);}continue;case']':save_and_next(LS,l) -;if(LS->current==']'){if(cont==0)goto endloop;cont--;save_and_next(LS,l);} -continue;case'\n':save(LS,'\n',l);inclinenumber(LS);if(!seminfo)l=0;continue; -default:save_and_next(LS,l);}}endloop:save_and_next(LS,l);save(LS,'\0',l);if( -seminfo)seminfo->ts=luaS_newlstr(LS->L,luaZ_buffer(LS->buff)+2,l-5);}static -void read_string(LexState*LS,int del,SemInfo*seminfo){size_t l=0;checkbuffer( -LS,l);save_and_next(LS,l);while(LS->current!=del){checkbuffer(LS,l);switch(LS -->current){case EOZ:save(LS,'\0',l);luaX_lexerror(LS,"unfinished string", -TK_EOS);break;case'\n':save(LS,'\0',l);luaX_lexerror(LS,"unfinished string", -TK_STRING);break;case'\\':next(LS);switch(LS->current){case'a':save(LS,'\a',l) -;next(LS);break;case'b':save(LS,'\b',l);next(LS);break;case'f':save(LS,'\f',l) -;next(LS);break;case'n':save(LS,'\n',l);next(LS);break;case'r':save(LS,'\r',l) -;next(LS);break;case't':save(LS,'\t',l);next(LS);break;case'v':save(LS,'\v',l) -;next(LS);break;case'\n':save(LS,'\n',l);inclinenumber(LS);break;case EOZ: -break;default:{if(!isdigit(LS->current))save_and_next(LS,l);else{int c=0;int i -=0;do{c=10*c+(LS->current-'0');next(LS);}while(++i<3&&isdigit(LS->current));if -(c>UCHAR_MAX){save(LS,'\0',l);luaX_lexerror(LS,"escape sequence too large", -TK_STRING);}save(LS,c,l);}}}break;default:save_and_next(LS,l);}}save_and_next( -LS,l);save(LS,'\0',l);seminfo->ts=luaS_newlstr(LS->L,luaZ_buffer(LS->buff)+1,l --3);}int luaX_lex(LexState*LS,SemInfo*seminfo){for(;;){switch(LS->current){ -case'\n':{inclinenumber(LS);continue;}case'-':{next(LS);if(LS->current!='-') -return'-';next(LS);if(LS->current=='['&&(next(LS),LS->current=='[')) -read_long_string(LS,NULL);else while(LS->current!='\n'&&LS->current!=EOZ)next( -LS);continue;}case'[':{next(LS);if(LS->current!='[')return'[';else{ -read_long_string(LS,seminfo);return TK_STRING;}}case'=':{next(LS);if(LS-> -current!='=')return'=';else{next(LS);return TK_EQ;}}case'<':{next(LS);if(LS-> -current!='=')return'<';else{next(LS);return TK_LE;}}case'>':{next(LS);if(LS-> -current!='=')return'>';else{next(LS);return TK_GE;}}case'~':{next(LS);if(LS-> -current!='=')return'~';else{next(LS);return TK_NE;}}case'"':case'\'':{ -read_string(LS,LS->current,seminfo);return TK_STRING;}case'.':{next(LS);if(LS -->current=='.'){next(LS);if(LS->current=='.'){next(LS);return TK_DOTS;}else -return TK_CONCAT;}else if(!isdigit(LS->current))return'.';else{read_numeral(LS -,1,seminfo);return TK_NUMBER;}}case EOZ:{return TK_EOS;}default:{if(isspace(LS -->current)){next(LS);continue;}else if(isdigit(LS->current)){read_numeral(LS,0 -,seminfo);return TK_NUMBER;}else if(isalpha(LS->current)||LS->current=='_'){ -size_t l=readname(LS);TString*ts=luaS_newlstr(LS->L,luaZ_buffer(LS->buff),l); -if(ts->tsv.reserved>0)return ts->tsv.reserved-1+FIRST_RESERVED;seminfo->ts=ts; -return TK_NAME;}else{int c=LS->current;if(iscntrl(c))luaX_error(LS, -"invalid control char",luaO_pushfstring(LS->L,"char(%d)",c));next(LS);return c -;}}}}} -#undef next -#line 1 "lmem.c" -#define lmem_c -#ifndef l_realloc -#define l_realloc(b,os,s) realloc(b,s) -#endif -#ifndef l_free -#define l_free(b,os) free(b) -#endif -#define MINSIZEARRAY 4 -void*luaM_growaux(lua_State*L,void*block,int*size,int size_elems,int limit, -const char*errormsg){void*newblock;int newsize=(*size)*2;if(newsize< -MINSIZEARRAY)newsize=MINSIZEARRAY;else if(*size>=limit/2){if(*size=MAX_SIZET)luaG_runerror(L, -"memory allocation error: block too big");else{block=l_realloc(block,oldsize, -size);if(block==NULL){if(L)luaD_throw(L,LUA_ERRMEM);else return NULL;}}if(L){ -lua_assert(G(L)!=NULL&&G(L)->nblocks>0);G(L)->nblocks-=oldsize;G(L)->nblocks+= -size;}return block;} -#line 1 "loadlib.c" -#undef LOADLIB -#ifdef USE_DLOPEN -#define LOADLIB -#include /* dg: magic anchor comment */ -static int loadlib(lua_State*L){const char*path=luaL_checkstring(L,1);const -char*init=luaL_checkstring(L,2);void*lib=dlopen(path,RTLD_NOW);if(lib!=NULL){ -lua_CFunction f=(lua_CFunction)dlsym(lib,init);if(f!=NULL){ -lua_pushlightuserdata(L,lib);lua_pushcclosure(L,f,1);return 1;}}lua_pushnil(L) -;lua_pushstring(L,dlerror());lua_pushstring(L,(lib!=NULL)?"init":"open");if( -lib!=NULL)dlclose(lib);return 3;} -#endif -#ifndef USE_DLL -#ifdef _WIN32 -#define USE_DLL 1 -#else -#define USE_DLL 0 -#endif -#endif -#if USE_DLL -#define LOADLIB -#include /* dg: magic anchor comment */ -static void pusherror(lua_State*L){int error=GetLastError();char buffer[128]; -if(FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,0, -error,0,buffer,sizeof(buffer),0))lua_pushstring(L,buffer);else lua_pushfstring -(L,"system error %d\n",error);}static int loadlib(lua_State*L){const char*path -=luaL_checkstring(L,1);const char*init=luaL_checkstring(L,2);HINSTANCE lib= -LoadLibrary(path);if(lib!=NULL){lua_CFunction f=(lua_CFunction)GetProcAddress( -lib,init);if(f!=NULL){lua_pushlightuserdata(L,lib);lua_pushcclosure(L,f,1); -return 1;}}lua_pushnil(L);pusherror(L);lua_pushstring(L,(lib!=NULL)?"init": -"open");if(lib!=NULL)FreeLibrary(lib);return 3;} -#endif -#ifndef LOADLIB -#ifdef linux -#define LOADLIB -#endif -#ifdef sun -#define LOADLIB -#endif -#ifdef sgi -#define LOADLIB -#endif -#ifdef BSD -#define LOADLIB -#endif -#ifdef _WIN32 -#define LOADLIB -#endif -#ifdef LOADLIB -#undef LOADLIB -#define LOADLIB "`loadlib' not installed (check your Lua configuration)" -#else -#define LOADLIB "`loadlib' not supported" -#endif -static int loadlib(lua_State*L){lua_pushnil(L);lua_pushliteral(L,LOADLIB); -lua_pushliteral(L,"absent");return 3;} -#endif -LUALIB_API int luaopen_loadlib(lua_State*L){lua_register(L,"loadlib",loadlib); -return 0;} -#line 1 "lobject.c" -#define lobject_c -#ifndef lua_str2number -#define lua_str2number(s,p) strtod((s),(p)) -#endif -const TObject luaO_nilobject={LUA_TNIL,{NULL}};int luaO_int2fb(unsigned int x) -{int m=0;while(x>=(1<<3)){x=(x+1)>>1;m++;}return(m<<3)|cast(int,x);}int -luaO_log2(unsigned int x){static const lu_byte log_8[255]={0,1,1,2,2,2,2,3,3,3 -,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 -,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 -,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 -,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -,7,7,7,7,7,7,7,7,7,7,7};if(x>=0x00010000){if(x>=0x01000000)return log_8[((x>> -24)&0xff)-1]+24;else return log_8[((x>>16)&0xff)-1]+16;}else{if(x>=0x00000100) -return log_8[((x>>8)&0xff)-1]+8;else if(x)return log_8[(x&0xff)-1];return-1;}} -int luaO_rawequalObj(const TObject*t1,const TObject*t2){if(ttype(t1)!=ttype(t2 -))return 0;else switch(ttype(t1)){case LUA_TNIL:return 1;case LUA_TNUMBER: -return nvalue(t1)==nvalue(t2);case LUA_TBOOLEAN:return bvalue(t1)==bvalue(t2); -case LUA_TLIGHTUSERDATA:return pvalue(t1)==pvalue(t2);default:lua_assert( -iscollectable(t1));return gcvalue(t1)==gcvalue(t2);}}int luaO_str2d(const char -*s,lua_Number*result){char*endptr;lua_Number res=lua_str2number(s,&endptr);if( -endptr==s)return 0;while(isspace((unsigned char)(*endptr)))endptr++;if(*endptr -!='\0')return 0;*result=res;return 1;}static void pushstr(lua_State*L,const -char*str){setsvalue2s(L->top,luaS_new(L,str));incr_top(L);}const char* -luaO_pushvfstring(lua_State*L,const char*fmt,va_list argp){int n=1;pushstr(L, -"");for(;;){const char*e=strchr(fmt,'%');if(e==NULL)break;setsvalue2s(L->top, -luaS_newlstr(L,fmt,e-fmt));incr_top(L);switch(*(e+1)){case's':pushstr(L,va_arg -(argp,char*));break;case'c':{char buff[2];buff[0]=cast(char,va_arg(argp,int)); -buff[1]='\0';pushstr(L,buff);break;}case'd':setnvalue(L->top,cast(lua_Number, -va_arg(argp,int)));incr_top(L);break;case'f':setnvalue(L->top,cast(lua_Number, -va_arg(argp,l_uacNumber)));incr_top(L);break;case'%':pushstr(L,"%");break; -default:lua_assert(0);}n+=2;fmt=e+2;}pushstr(L,fmt);luaV_concat(L,n+1,L->top-L -->base-1);L->top-=n;return svalue(L->top-1);}const char*luaO_pushfstring( -lua_State*L,const char*fmt,...){const char*msg;va_list argp;va_start(argp,fmt) -;msg=luaO_pushvfstring(L,fmt,argp);va_end(argp);return msg;}void luaO_chunkid( -char*out,const char*source,int bufflen){if(*source=='='){strncpy(out,source+1, -bufflen);out[bufflen-1]='\0';}else{if(*source=='@'){int l;source++;bufflen-= -sizeof(" `...' ");l=strlen(source);strcpy(out,"");if(l>bufflen){source+=(l- -bufflen);strcat(out,"...");}strcat(out,source);}else{int len=strcspn(source, -"\n");bufflen-=sizeof(" [string \"...\"] ");if(len>bufflen)len=bufflen;strcpy( -out,"[string \"");if(source[len]!='\0'){strncat(out,source,len);strcat(out, -"...");}else strcat(out,source);strcat(out,"\"]");}}} -#line 1 "lopcodes.c" -#define lopcodes_c -#ifdef LUA_OPNAMES -const char*const luaP_opnames[]={"MOVE","LOADK","LOADBOOL","LOADNIL", -"GETUPVAL","GETGLOBAL","GETTABLE","SETGLOBAL","SETUPVAL","SETTABLE","NEWTABLE" -,"SELF","ADD","SUB","MUL","DIV","POW","UNM","NOT","CONCAT","JMP","EQ","LT", -"LE","TEST","CALL","TAILCALL","RETURN","FORLOOP","TFORLOOP","TFORPREP", -"SETLIST","SETLISTO","CLOSE","CLOSURE"}; -#endif -#define opmode(t,b,bk,ck,sa,k,m) (((t)<f->locvars[(fs)->actvar[i]]) -#define enterlevel(ls) if(++(ls)->nestlevel>LUA_MAXPARSERLEVEL)\ -luaX_syntaxerror(ls,"too many syntax levels"); -#define leavelevel(ls) ((ls)->nestlevel--) -typedef struct BlockCnt{struct BlockCnt*previous;int breaklist;int nactvar;int - upval;int isbreakable;}BlockCnt;static void chunk(LexState*ls);static void -expr(LexState*ls,expdesc*v);static void next(LexState*ls){ls->lastline=ls-> -linenumber;if(ls->lookahead.token!=TK_EOS){ls->t=ls->lookahead;ls->lookahead. -token=TK_EOS;}else ls->t.token=luaX_lex(ls,&ls->t.seminfo);}static void -lookahead(LexState*ls){lua_assert(ls->lookahead.token==TK_EOS);ls->lookahead. -token=luaX_lex(ls,&ls->lookahead.seminfo);}static void error_expected(LexState -*ls,int token){luaX_syntaxerror(ls,luaO_pushfstring(ls->L,"`%s' expected", -luaX_token2str(ls,token)));}static int testnext(LexState*ls,int c){if(ls->t. -token==c){next(ls);return 1;}else return 0;}static void check(LexState*ls,int -c){if(!testnext(ls,c))error_expected(ls,c);} -#define check_condition(ls,c,msg) {if(!(c))luaX_syntaxerror(ls,msg);} -static void check_match(LexState*ls,int what,int who,int where){if(!testnext( -ls,what)){if(where==ls->linenumber)error_expected(ls,what);else{ -luaX_syntaxerror(ls,luaO_pushfstring(ls->L, -"`%s' expected (to close `%s' at line %d)",luaX_token2str(ls,what), -luaX_token2str(ls,who),where));}}}static TString*str_checkname(LexState*ls){ -TString*ts;check_condition(ls,(ls->t.token==TK_NAME)," expected");ts=ls -->t.seminfo.ts;next(ls);return ts;}static void init_exp(expdesc*e,expkind k, -int i){e->f=e->t=NO_JUMP;e->k=k;e->info=i;}static void codestring(LexState*ls, -expdesc*e,TString*s){init_exp(e,VK,luaK_stringK(ls->fs,s));}static void -checkname(LexState*ls,expdesc*e){codestring(ls,e,str_checkname(ls));}static -int luaI_registerlocalvar(LexState*ls,TString*varname){FuncState*fs=ls->fs; -Proto*f=fs->f;luaM_growvector(ls->L,f->locvars,fs->nlocvars,f->sizelocvars, -LocVar,MAX_INT,"");f->locvars[fs->nlocvars].varname=varname;return fs-> -nlocvars++;}static void new_localvar(LexState*ls,TString*name,int n){FuncState -*fs=ls->fs;luaX_checklimit(ls,fs->nactvar+n+1,MAXVARS,"local variables");fs-> -actvar[fs->nactvar+n]=luaI_registerlocalvar(ls,name);}static void -adjustlocalvars(LexState*ls,int nvars){FuncState*fs=ls->fs;fs->nactvar+=nvars; -for(;nvars;nvars--){getlocvar(fs,fs->nactvar-nvars).startpc=fs->pc;}}static -void removevars(LexState*ls,int tolevel){FuncState*fs=ls->fs;while(fs->nactvar ->tolevel)getlocvar(fs,--fs->nactvar).endpc=fs->pc;}static void new_localvarstr -(LexState*ls,const char*name,int n){new_localvar(ls,luaS_new(ls->L,name),n);} -static void create_local(LexState*ls,const char*name){new_localvarstr(ls,name, -0);adjustlocalvars(ls,1);}static int indexupvalue(FuncState*fs,TString*name, -expdesc*v){int i;Proto*f=fs->f;for(i=0;inups;i++){if(fs->upvalues[i].k==v -->k&&fs->upvalues[i].info==v->info){lua_assert(fs->f->upvalues[i]==name); -return i;}}luaX_checklimit(fs->ls,f->nups+1,MAXUPVALUES,"upvalues"); -luaM_growvector(fs->L,fs->f->upvalues,f->nups,fs->f->sizeupvalues,TString*, -MAX_INT,"");fs->f->upvalues[f->nups]=name;fs->upvalues[f->nups]=*v;return f-> -nups++;}static int searchvar(FuncState*fs,TString*n){int i;for(i=fs->nactvar-1 -;i>=0;i--){if(n==getlocvar(fs,i).varname)return i;}return-1;}static void -markupval(FuncState*fs,int level){BlockCnt*bl=fs->bl;while(bl&&bl->nactvar> -level)bl=bl->previous;if(bl)bl->upval=1;}static void singlevaraux(FuncState*fs -,TString*n,expdesc*var,int base){if(fs==NULL)init_exp(var,VGLOBAL,NO_REG);else -{int v=searchvar(fs,n);if(v>=0){init_exp(var,VLOCAL,v);if(!base)markupval(fs,v -);}else{singlevaraux(fs->prev,n,var,0);if(var->k==VGLOBAL){if(base)var->info= -luaK_stringK(fs,n);}else{var->info=indexupvalue(fs,n,var);var->k=VUPVAL;}}}} -static TString*singlevar(LexState*ls,expdesc*var,int base){TString*varname= -str_checkname(ls);singlevaraux(ls->fs,varname,var,base);return varname;}static - void adjust_assign(LexState*ls,int nvars,int nexps,expdesc*e){FuncState*fs=ls -->fs;int extra=nvars-nexps;if(e->k==VCALL){extra++;if(extra<=0)extra=0;else -luaK_reserveregs(fs,extra-1);luaK_setcallreturns(fs,e,extra);}else{if(e->k!= -VVOID)luaK_exp2nextreg(fs,e);if(extra>0){int reg=fs->freereg;luaK_reserveregs( -fs,extra);luaK_nil(fs,reg,extra);}}}static void code_params(LexState*ls,int -nparams,int dots){FuncState*fs=ls->fs;adjustlocalvars(ls,nparams); -luaX_checklimit(ls,fs->nactvar,MAXPARAMS,"parameters");fs->f->numparams=cast( -lu_byte,fs->nactvar);fs->f->is_vararg=cast(lu_byte,dots);if(dots)create_local( -ls,"arg");luaK_reserveregs(fs,fs->nactvar);}static void enterblock(FuncState* -fs,BlockCnt*bl,int isbreakable){bl->breaklist=NO_JUMP;bl->isbreakable= -isbreakable;bl->nactvar=fs->nactvar;bl->upval=0;bl->previous=fs->bl;fs->bl=bl; -lua_assert(fs->freereg==fs->nactvar);}static void leaveblock(FuncState*fs){ -BlockCnt*bl=fs->bl;fs->bl=bl->previous;removevars(fs->ls,bl->nactvar);if(bl-> -upval)luaK_codeABC(fs,OP_CLOSE,bl->nactvar,0,0);lua_assert(bl->nactvar==fs-> -nactvar);fs->freereg=fs->nactvar;luaK_patchtohere(fs,bl->breaklist);}static -void pushclosure(LexState*ls,FuncState*func,expdesc*v){FuncState*fs=ls->fs; -Proto*f=fs->f;int i;luaM_growvector(ls->L,f->p,fs->np,f->sizep,Proto*, -MAXARG_Bx,"constant table overflow");f->p[fs->np++]=func->f;init_exp(v, -VRELOCABLE,luaK_codeABx(fs,OP_CLOSURE,0,fs->np-1));for(i=0;if->nups;i++ -){OpCode o=(func->upvalues[i].k==VLOCAL)?OP_MOVE:OP_GETUPVAL;luaK_codeABC(fs,o -,0,func->upvalues[i].info,0);}}static void open_func(LexState*ls,FuncState*fs) -{Proto*f=luaF_newproto(ls->L);fs->f=f;fs->prev=ls->fs;fs->ls=ls;fs->L=ls->L;ls -->fs=fs;fs->pc=0;fs->lasttarget=0;fs->jpc=NO_JUMP;fs->freereg=0;fs->nk=0;fs->h -=luaH_new(ls->L,0,0);fs->np=0;fs->nlocvars=0;fs->nactvar=0;fs->bl=NULL;f-> -source=ls->source;f->maxstacksize=2;}static void close_func(LexState*ls){ -lua_State*L=ls->L;FuncState*fs=ls->fs;Proto*f=fs->f;removevars(ls,0); -luaK_codeABC(fs,OP_RETURN,0,1,0);luaM_reallocvector(L,f->code,f->sizecode,fs-> -pc,Instruction);f->sizecode=fs->pc;luaM_reallocvector(L,f->lineinfo,f-> -sizelineinfo,fs->pc,int);f->sizelineinfo=fs->pc;luaM_reallocvector(L,f->k,f-> -sizek,fs->nk,TObject);f->sizek=fs->nk;luaM_reallocvector(L,f->p,f->sizep,fs-> -np,Proto*);f->sizep=fs->np;luaM_reallocvector(L,f->locvars,f->sizelocvars,fs-> -nlocvars,LocVar);f->sizelocvars=fs->nlocvars;luaM_reallocvector(L,f->upvalues, -f->sizeupvalues,f->nups,TString*);f->sizeupvalues=f->nups;lua_assert( -luaG_checkcode(f));lua_assert(fs->bl==NULL);ls->fs=fs->prev;}Proto*luaY_parser -(lua_State*L,ZIO*z,Mbuffer*buff){struct LexState lexstate;struct FuncState -funcstate;lexstate.buff=buff;lexstate.nestlevel=0;luaX_setinput(L,&lexstate,z, -luaS_new(L,zname(z)));open_func(&lexstate,&funcstate);next(&lexstate);chunk(& -lexstate);check_condition(&lexstate,(lexstate.t.token==TK_EOS), -" expected");close_func(&lexstate);lua_assert(funcstate.prev==NULL); -lua_assert(funcstate.f->nups==0);lua_assert(lexstate.nestlevel==0);return -funcstate.f;}static void luaY_field(LexState*ls,expdesc*v){FuncState*fs=ls->fs -;expdesc key;luaK_exp2anyreg(fs,v);next(ls);checkname(ls,&key);luaK_indexed(fs -,v,&key);}static void luaY_index(LexState*ls,expdesc*v){next(ls);expr(ls,v); -luaK_exp2val(ls->fs,v);check(ls,']');}struct ConsControl{expdesc v;expdesc*t; -int nh;int na;int tostore;};static void recfield(LexState*ls,struct -ConsControl*cc){FuncState*fs=ls->fs;int reg=ls->fs->freereg;expdesc key,val;if -(ls->t.token==TK_NAME){luaX_checklimit(ls,cc->nh,MAX_INT, -"items in a constructor");cc->nh++;checkname(ls,&key);}else luaY_index(ls,&key -);check(ls,'=');luaK_exp2RK(fs,&key);expr(ls,&val);luaK_codeABC(fs,OP_SETTABLE -,cc->t->info,luaK_exp2RK(fs,&key),luaK_exp2RK(fs,&val));fs->freereg=reg;} -static void closelistfield(FuncState*fs,struct ConsControl*cc){if(cc->v.k== -VVOID)return;luaK_exp2nextreg(fs,&cc->v);cc->v.k=VVOID;if(cc->tostore== -LFIELDS_PER_FLUSH){luaK_codeABx(fs,OP_SETLIST,cc->t->info,cc->na-1);cc-> -tostore=0;fs->freereg=cc->t->info+1;}}static void lastlistfield(FuncState*fs, -struct ConsControl*cc){if(cc->tostore==0)return;if(cc->v.k==VCALL){ -luaK_setcallreturns(fs,&cc->v,LUA_MULTRET);luaK_codeABx(fs,OP_SETLISTO,cc->t-> -info,cc->na-1);}else{if(cc->v.k!=VVOID)luaK_exp2nextreg(fs,&cc->v); -luaK_codeABx(fs,OP_SETLIST,cc->t->info,cc->na-1);}fs->freereg=cc->t->info+1;} -static void listfield(LexState*ls,struct ConsControl*cc){expr(ls,&cc->v); -luaX_checklimit(ls,cc->na,MAXARG_Bx,"items in a constructor");cc->na++;cc-> -tostore++;}static void constructor(LexState*ls,expdesc*t){FuncState*fs=ls->fs; -int line=ls->linenumber;int pc=luaK_codeABC(fs,OP_NEWTABLE,0,0,0);struct -ConsControl cc;cc.na=cc.nh=cc.tostore=0;cc.t=t;init_exp(t,VRELOCABLE,pc); -init_exp(&cc.v,VVOID,0);luaK_exp2nextreg(ls->fs,t);check(ls,'{');do{lua_assert -(cc.v.k==VVOID||cc.tostore>0);testnext(ls,';');if(ls->t.token=='}')break; -closelistfield(fs,&cc);switch(ls->t.token){case TK_NAME:{lookahead(ls);if(ls-> -lookahead.token!='=')listfield(ls,&cc);else recfield(ls,&cc);break;}case'[':{ -recfield(ls,&cc);break;}default:{listfield(ls,&cc);break;}}}while(testnext(ls, -',')||testnext(ls,';'));check_match(ls,'}','{',line);lastlistfield(fs,&cc); -SETARG_B(fs->f->code[pc],luaO_int2fb(cc.na));SETARG_C(fs->f->code[pc], -luaO_log2(cc.nh)+1);}static void parlist(LexState*ls){int nparams=0;int dots=0 -;if(ls->t.token!=')'){do{switch(ls->t.token){case TK_DOTS:dots=1;next(ls); -break;case TK_NAME:new_localvar(ls,str_checkname(ls),nparams++);break;default: -luaX_syntaxerror(ls," or `...' expected");}}while(!dots&&testnext(ls,',' -));}code_params(ls,nparams,dots);}static void body(LexState*ls,expdesc*e,int -needself,int line){FuncState new_fs;open_func(ls,&new_fs);new_fs.f-> -lineDefined=line;check(ls,'(');if(needself)create_local(ls,"self");parlist(ls) -;check(ls,')');chunk(ls);check_match(ls,TK_END,TK_FUNCTION,line);close_func(ls -);pushclosure(ls,&new_fs,e);}static int explist1(LexState*ls,expdesc*v){int n= -1;expr(ls,v);while(testnext(ls,',')){luaK_exp2nextreg(ls->fs,v);expr(ls,v);n++ -;}return n;}static void funcargs(LexState*ls,expdesc*f){FuncState*fs=ls->fs; -expdesc args;int base,nparams;int line=ls->linenumber;switch(ls->t.token){case -'(':{if(line!=ls->lastline)luaX_syntaxerror(ls, -"ambiguous syntax (function call x new statement)");next(ls);if(ls->t.token== -')')args.k=VVOID;else{explist1(ls,&args);luaK_setcallreturns(fs,&args, -LUA_MULTRET);}check_match(ls,')','(',line);break;}case'{':{constructor(ls,& -args);break;}case TK_STRING:{codestring(ls,&args,ls->t.seminfo.ts);next(ls); -break;}default:{luaX_syntaxerror(ls,"function arguments expected");return;}} -lua_assert(f->k==VNONRELOC);base=f->info;if(args.k==VCALL)nparams=LUA_MULTRET; -else{if(args.k!=VVOID)luaK_exp2nextreg(fs,&args);nparams=fs->freereg-(base+1); -}init_exp(f,VCALL,luaK_codeABC(fs,OP_CALL,base,nparams+1,2));luaK_fixline(fs, -line);fs->freereg=base+1;}static void prefixexp(LexState*ls,expdesc*v){switch( -ls->t.token){case'(':{int line=ls->linenumber;next(ls);expr(ls,v);check_match( -ls,')','(',line);luaK_dischargevars(ls->fs,v);return;}case TK_NAME:{singlevar( -ls,v,1);return;} -#ifdef LUA_COMPATUPSYNTAX -case'%':{TString*varname;int line=ls->linenumber;next(ls);varname=singlevar(ls -,v,1);if(v->k!=VUPVAL)luaX_errorline(ls,"global upvalues are obsolete",getstr( -varname),line);return;} -#endif -default:{luaX_syntaxerror(ls,"unexpected symbol");return;}}}static void -primaryexp(LexState*ls,expdesc*v){FuncState*fs=ls->fs;prefixexp(ls,v);for(;;){ -switch(ls->t.token){case'.':{luaY_field(ls,v);break;}case'[':{expdesc key; -luaK_exp2anyreg(fs,v);luaY_index(ls,&key);luaK_indexed(fs,v,&key);break;}case -':':{expdesc key;next(ls);checkname(ls,&key);luaK_self(fs,v,&key);funcargs(ls, -v);break;}case'(':case TK_STRING:case'{':{luaK_exp2nextreg(fs,v);funcargs(ls,v -);break;}default:return;}}}static void simpleexp(LexState*ls,expdesc*v){switch -(ls->t.token){case TK_NUMBER:{init_exp(v,VK,luaK_numberK(ls->fs,ls->t.seminfo. -r));next(ls);break;}case TK_STRING:{codestring(ls,v,ls->t.seminfo.ts);next(ls) -;break;}case TK_NIL:{init_exp(v,VNIL,0);next(ls);break;}case TK_TRUE:{init_exp -(v,VTRUE,0);next(ls);break;}case TK_FALSE:{init_exp(v,VFALSE,0);next(ls);break -;}case'{':{constructor(ls,v);break;}case TK_FUNCTION:{next(ls);body(ls,v,0,ls -->linenumber);break;}default:{primaryexp(ls,v);break;}}}static UnOpr getunopr( -int op){switch(op){case TK_NOT:return OPR_NOT;case'-':return OPR_MINUS;default -:return OPR_NOUNOPR;}}static BinOpr getbinopr(int op){switch(op){case'+': -return OPR_ADD;case'-':return OPR_SUB;case'*':return OPR_MULT;case'/':return -OPR_DIV;case'^':return OPR_POW;case TK_CONCAT:return OPR_CONCAT;case TK_NE: -return OPR_NE;case TK_EQ:return OPR_EQ;case'<':return OPR_LT;case TK_LE:return - OPR_LE;case'>':return OPR_GT;case TK_GE:return OPR_GE;case TK_AND:return -OPR_AND;case TK_OR:return OPR_OR;default:return OPR_NOBINOPR;}}static const -struct{lu_byte left;lu_byte right;}priority[]={{6,6},{6,6},{7,7},{7,7},{10,9}, -{5,4},{3,3},{3,3},{3,3},{3,3},{3,3},{3,3},{2,2},{1,1}}; -#define UNARY_PRIORITY 8 -static BinOpr subexpr(LexState*ls,expdesc*v,int limit){BinOpr op;UnOpr uop; -enterlevel(ls);uop=getunopr(ls->t.token);if(uop!=OPR_NOUNOPR){next(ls);subexpr -(ls,v,UNARY_PRIORITY);luaK_prefix(ls->fs,uop,v);}else simpleexp(ls,v);op= -getbinopr(ls->t.token);while(op!=OPR_NOBINOPR&&cast(int,priority[op].left)> -limit){expdesc v2;BinOpr nextop;next(ls);luaK_infix(ls->fs,op,v);nextop= -subexpr(ls,&v2,cast(int,priority[op].right));luaK_posfix(ls->fs,op,v,&v2);op= -nextop;}leavelevel(ls);return op;}static void expr(LexState*ls,expdesc*v){ -subexpr(ls,v,-1);}static int block_follow(int token){switch(token){case -TK_ELSE:case TK_ELSEIF:case TK_END:case TK_UNTIL:case TK_EOS:return 1;default: -return 0;}}static void block(LexState*ls){FuncState*fs=ls->fs;BlockCnt bl; -enterblock(fs,&bl,0);chunk(ls);lua_assert(bl.breaklist==NO_JUMP);leaveblock(fs -);}struct LHS_assign{struct LHS_assign*prev;expdesc v;};static void -check_conflict(LexState*ls,struct LHS_assign*lh,expdesc*v){FuncState*fs=ls->fs -;int extra=fs->freereg;int conflict=0;for(;lh;lh=lh->prev){if(lh->v.k== -VINDEXED){if(lh->v.info==v->info){conflict=1;lh->v.info=extra;}if(lh->v.aux==v -->info){conflict=1;lh->v.aux=extra;}}}if(conflict){luaK_codeABC(fs,OP_MOVE,fs -->freereg,v->info,0);luaK_reserveregs(fs,1);}}static void assignment(LexState* -ls,struct LHS_assign*lh,int nvars){expdesc e;check_condition(ls,VLOCAL<=lh->v. -k&&lh->v.k<=VINDEXED,"syntax error");if(testnext(ls,',')){struct LHS_assign nv -;nv.prev=lh;primaryexp(ls,&nv.v);if(nv.v.k==VLOCAL)check_conflict(ls,lh,&nv.v) -;assignment(ls,&nv,nvars+1);}else{int nexps;check(ls,'=');nexps=explist1(ls,&e -);if(nexps!=nvars){adjust_assign(ls,nvars,nexps,&e);if(nexps>nvars)ls->fs-> -freereg-=nexps-nvars;}else{luaK_setcallreturns(ls->fs,&e,1);luaK_storevar(ls-> -fs,&lh->v,&e);return;}}init_exp(&e,VNONRELOC,ls->fs->freereg-1);luaK_storevar( -ls->fs,&lh->v,&e);}static void cond(LexState*ls,expdesc*v){expr(ls,v);if(v->k -==VNIL)v->k=VFALSE;luaK_goiftrue(ls->fs,v);luaK_patchtohere(ls->fs,v->t);} -#ifndef MAXEXPWHILE -#define MAXEXPWHILE 100 -#endif -#define EXTRAEXP 5 -static void whilestat(LexState*ls,int line){Instruction codeexp[MAXEXPWHILE+ -EXTRAEXP];int lineexp;int i;int sizeexp;FuncState*fs=ls->fs;int whileinit, -blockinit,expinit;expdesc v;BlockCnt bl;next(ls);whileinit=luaK_jump(fs); -expinit=luaK_getlabel(fs);expr(ls,&v);if(v.k==VK)v.k=VTRUE;lineexp=ls-> -linenumber;luaK_goiffalse(fs,&v);luaK_concat(fs,&v.f,fs->jpc);fs->jpc=NO_JUMP; -sizeexp=fs->pc-expinit;if(sizeexp>MAXEXPWHILE)luaX_syntaxerror(ls, -"`while' condition too complex");for(i=0;if->code[ -expinit+i];fs->pc=expinit;enterblock(fs,&bl,1);check(ls,TK_DO);blockinit= -luaK_getlabel(fs);block(ls);luaK_patchtohere(fs,whileinit);if(v.t!=NO_JUMP)v.t -+=fs->pc-expinit;if(v.f!=NO_JUMP)v.f+=fs->pc-expinit;for(i=0;ifs;int -repeat_init=luaK_getlabel(fs);expdesc v;BlockCnt bl;enterblock(fs,&bl,1);next( -ls);block(ls);check_match(ls,TK_UNTIL,TK_REPEAT,line);cond(ls,&v); -luaK_patchlist(fs,v.f,repeat_init);leaveblock(fs);}static int exp1(LexState*ls -){expdesc e;int k;expr(ls,&e);k=e.k;luaK_exp2nextreg(ls->fs,&e);return k;} -static void forbody(LexState*ls,int base,int line,int nvars,int isnum){ -BlockCnt bl;FuncState*fs=ls->fs;int prep,endfor;adjustlocalvars(ls,nvars); -check(ls,TK_DO);enterblock(fs,&bl,1);prep=luaK_getlabel(fs);block(ls); -luaK_patchtohere(fs,prep-1);endfor=(isnum)?luaK_codeAsBx(fs,OP_FORLOOP,base, -NO_JUMP):luaK_codeABC(fs,OP_TFORLOOP,base,0,nvars-3);luaK_fixline(fs,line); -luaK_patchlist(fs,(isnum)?endfor:luaK_jump(fs),prep);leaveblock(fs);}static -void fornum(LexState*ls,TString*varname,int line){FuncState*fs=ls->fs;int base -=fs->freereg;new_localvar(ls,varname,0);new_localvarstr(ls,"(for limit)",1); -new_localvarstr(ls,"(for step)",2);check(ls,'=');exp1(ls);check(ls,',');exp1( -ls);if(testnext(ls,','))exp1(ls);else{luaK_codeABx(fs,OP_LOADK,fs->freereg, -luaK_numberK(fs,1));luaK_reserveregs(fs,1);}luaK_codeABC(fs,OP_SUB,fs->freereg --3,fs->freereg-3,fs->freereg-1);luaK_jump(fs);forbody(ls,base,line,3,1);} -static void forlist(LexState*ls,TString*indexname){FuncState*fs=ls->fs;expdesc - e;int nvars=0;int line;int base=fs->freereg;new_localvarstr(ls, -"(for generator)",nvars++);new_localvarstr(ls,"(for state)",nvars++); -new_localvar(ls,indexname,nvars++);while(testnext(ls,','))new_localvar(ls, -str_checkname(ls),nvars++);check(ls,TK_IN);line=ls->linenumber;adjust_assign( -ls,nvars,explist1(ls,&e),&e);luaK_checkstack(fs,3);luaK_codeAsBx(fs, -OP_TFORPREP,base,NO_JUMP);forbody(ls,base,line,nvars,0);}static void forstat( -LexState*ls,int line){FuncState*fs=ls->fs;TString*varname;BlockCnt bl; -enterblock(fs,&bl,0);next(ls);varname=str_checkname(ls);switch(ls->t.token){ -case'=':fornum(ls,varname,line);break;case',':case TK_IN:forlist(ls,varname); -break;default:luaX_syntaxerror(ls,"`=' or `in' expected");}check_match(ls, -TK_END,TK_FOR,line);leaveblock(fs);}static void test_then_block(LexState*ls, -expdesc*v){next(ls);cond(ls,v);check(ls,TK_THEN);block(ls);}static void ifstat -(LexState*ls,int line){FuncState*fs=ls->fs;expdesc v;int escapelist=NO_JUMP; -test_then_block(ls,&v);while(ls->t.token==TK_ELSEIF){luaK_concat(fs,& -escapelist,luaK_jump(fs));luaK_patchtohere(fs,v.f);test_then_block(ls,&v);}if( -ls->t.token==TK_ELSE){luaK_concat(fs,&escapelist,luaK_jump(fs)); -luaK_patchtohere(fs,v.f);next(ls);block(ls);}else luaK_concat(fs,&escapelist,v -.f);luaK_patchtohere(fs,escapelist);check_match(ls,TK_END,TK_IF,line);}static -void localfunc(LexState*ls){expdesc v,b;FuncState*fs=ls->fs;new_localvar(ls, -str_checkname(ls),0);init_exp(&v,VLOCAL,fs->freereg);luaK_reserveregs(fs,1); -adjustlocalvars(ls,1);body(ls,&b,0,ls->linenumber);luaK_storevar(fs,&v,&b); -getlocvar(fs,fs->nactvar-1).startpc=fs->pc;}static void localstat(LexState*ls) -{int nvars=0;int nexps;expdesc e;do{new_localvar(ls,str_checkname(ls),nvars++) -;}while(testnext(ls,','));if(testnext(ls,'='))nexps=explist1(ls,&e);else{e.k= -VVOID;nexps=0;}adjust_assign(ls,nvars,nexps,&e);adjustlocalvars(ls,nvars);} -static int funcname(LexState*ls,expdesc*v){int needself=0;singlevar(ls,v,1); -while(ls->t.token=='.')luaY_field(ls,v);if(ls->t.token==':'){needself=1; -luaY_field(ls,v);}return needself;}static void funcstat(LexState*ls,int line){ -int needself;expdesc v,b;next(ls);needself=funcname(ls,&v);body(ls,&b,needself -,line);luaK_storevar(ls->fs,&v,&b);luaK_fixline(ls->fs,line);}static void -exprstat(LexState*ls){FuncState*fs=ls->fs;struct LHS_assign v;primaryexp(ls,&v -.v);if(v.v.k==VCALL){luaK_setcallreturns(fs,&v.v,0);}else{v.prev=NULL; -assignment(ls,&v,1);}}static void retstat(LexState*ls){FuncState*fs=ls->fs; -expdesc e;int first,nret;next(ls);if(block_follow(ls->t.token)||ls->t.token== -';')first=nret=0;else{nret=explist1(ls,&e);if(e.k==VCALL){luaK_setcallreturns( -fs,&e,LUA_MULTRET);if(nret==1){SET_OPCODE(getcode(fs,&e),OP_TAILCALL); -lua_assert(GETARG_A(getcode(fs,&e))==fs->nactvar);}first=fs->nactvar;nret= -LUA_MULTRET;}else{if(nret==1)first=luaK_exp2anyreg(fs,&e);else{ -luaK_exp2nextreg(fs,&e);first=fs->nactvar;lua_assert(nret==fs->freereg-first); -}}}luaK_codeABC(fs,OP_RETURN,first,nret+1,0);}static void breakstat(LexState* -ls){FuncState*fs=ls->fs;BlockCnt*bl=fs->bl;int upval=0;next(ls);while(bl&&!bl -->isbreakable){upval|=bl->upval;bl=bl->previous;}if(!bl)luaX_syntaxerror(ls, -"no loop to break");if(upval)luaK_codeABC(fs,OP_CLOSE,bl->nactvar,0,0); -luaK_concat(fs,&bl->breaklist,luaK_jump(fs));}static int statement(LexState*ls -){int line=ls->linenumber;switch(ls->t.token){case TK_IF:{ifstat(ls,line); -return 0;}case TK_WHILE:{whilestat(ls,line);return 0;}case TK_DO:{next(ls); -block(ls);check_match(ls,TK_END,TK_DO,line);return 0;}case TK_FOR:{forstat(ls, -line);return 0;}case TK_REPEAT:{repeatstat(ls,line);return 0;}case TK_FUNCTION -:{funcstat(ls,line);return 0;}case TK_LOCAL:{next(ls);if(testnext(ls, -TK_FUNCTION))localfunc(ls);else localstat(ls);return 0;}case TK_RETURN:{ -retstat(ls);return 1;}case TK_BREAK:{breakstat(ls);return 1;}default:{exprstat -(ls);return 0;}}}static void chunk(LexState*ls){int islast=0;enterlevel(ls); -while(!islast&&!block_follow(ls->t.token)){islast=statement(ls);testnext(ls, -';');lua_assert(ls->fs->freereg>=ls->fs->nactvar);ls->fs->freereg=ls->fs-> -nactvar;}leavelevel(ls);} -#line 1 "lposix.c" -#define MYNAME "posix" -#define MYVERSION MYNAME" library for "LUA_VERSION" / Nov 2003" -#ifndef MYBUFSIZ -#define MYBUFSIZ 512 -#endif -#line 1 "modemuncher.h" -struct modeLookup{char rwx;mode_t bits;};typedef struct modeLookup modeLookup; -static modeLookup modesel[]={{'r',S_IRUSR},{'w',S_IWUSR},{'x',S_IXUSR},{'r', -S_IRGRP},{'w',S_IWGRP},{'x',S_IXGRP},{'r',S_IROTH},{'w',S_IWOTH},{'x',S_IXOTH} -,{(char)NULL,(mode_t)-1}};static int rwxrwxrwx(mode_t*mode,const char*p){int -count;mode_t tmp_mode=*mode;tmp_mode&=~(S_ISUID|S_ISGID);for(count=0;count<9; -count++){if(*p==modesel[count].rwx)tmp_mode|=modesel[count].bits;else if(*p== -'-')tmp_mode&=~modesel[count].bits;else if(*p=='s')switch(count){case 2: -tmp_mode|=S_ISUID|S_IXUSR;break;case 5:tmp_mode|=S_ISGID|S_IXGRP;break;default -:return-4;break;}p++;}*mode=tmp_mode;return 0;}static void modechopper(mode_t -mode,char*p){int count;char*pp;pp=p;for(count=0;count<9;count++){if(mode& -modesel[count].bits)*p=modesel[count].rwx;else*p='-';p++;}*p=0;if(mode&S_ISUID -)pp[2]=(mode&S_IXUSR)?'s':'S';if(mode&S_ISGID)pp[5]=(mode&S_IXGRP)?'s':'S';} -static int mode_munch(mode_t*mode,const char*p){char op=0;mode_t affected_bits -,ch_mode;int doneFlag=0; -#ifdef DEBUG -char tmp[10]; -#endif -#ifdef DEBUG -modechopper(*mode,tmp);printf("modemuncher: got base mode = %s\n",tmp); -#endif -while(!doneFlag){affected_bits=0;ch_mode=0; -#ifdef DEBUG -printf("modemuncher step 1\n"); -#endif -if(*p=='r'||*p=='-')return rwxrwxrwx(mode,p);for(;;p++)switch(*p){case'u': -affected_bits|=04700;break;case'g':affected_bits|=02070;break;case'o': -affected_bits|=01007;break;case'a':affected_bits|=07777;break;case' ':break; -default:goto no_more_affected;}no_more_affected:if(affected_bits==0) -affected_bits=07777; -#ifdef DEBUG -printf("modemuncher step 2 (*p='%c')\n",*p); -#endif -switch(*p){case'+':case'-':case'=':op=*p;break;case' ':break;default:return-1; -} -#ifdef DEBUG -printf("modemuncher step 3\n"); -#endif -for(p++;*p!=0;p++)switch(*p){case'r':ch_mode|=00444;break;case'w':ch_mode|= -00222;break;case'x':ch_mode|=00111;break;case's':ch_mode|=06000;break;case' ': -break;default:goto specs_done;}specs_done: -#ifdef DEBUG -printf("modemuncher step 4\n"); -#endif -if(*p!=',')doneFlag=1;if(*p!=0&&*p!=' '&&*p!=','){ -#ifdef DEBUG -printf("modemuncher: comma error!\n");printf("modemuncher: doneflag = %u\n", -doneFlag); -#endif -return-2;}p++;if(ch_mode)switch(op){case'+':*mode=*mode|=ch_mode&affected_bits -;break;case'-':*mode=*mode&=~(ch_mode&affected_bits);break;case'=':*mode= -ch_mode&affected_bits;break;default:return-3;}} -#ifdef DEBUG -modechopper(*mode,tmp);printf("modemuncher: returning mode = %s\n",tmp); -#endif -return 0;} -#line 38 "lposix.c" -static const char*filetype(mode_t m){if(S_ISREG(m))return"regular";else if( -S_ISLNK(m))return"link";else if(S_ISDIR(m))return"directory";else if(S_ISCHR(m -))return"character device";else if(S_ISBLK(m))return"block device";else if( -S_ISFIFO(m))return"fifo"; -#ifdef S_ISSOCK -else if(S_ISSOCK(m))return"socket"; -#endif -else return"?";}typedef int(*Selector)(lua_State*L,int i,const void*data); -static int doselection(lua_State*L,int i,const char*const S[],Selector F,const - void*data){if(lua_isnone(L,i)){lua_newtable(L);for(i=0;S[i]!=NULL;i++){ -lua_pushstring(L,S[i]);F(L,i,data);lua_settable(L,-3);}return 1;}else{int j= -luaL_findstring(luaL_checkstring(L,i),S);if(j==-1)luaL_argerror(L,i, -"unknown selector");return F(L,j,data);}}static void storeindex(lua_State*L, -int i,const char*value){lua_pushstring(L,value);lua_rawseti(L,-2,i);}static -void storestring(lua_State*L,const char*name,const char*value){lua_pushstring( -L,name);lua_pushstring(L,value);lua_settable(L,-3);}static void storenumber( -lua_State*L,const char*name,lua_Number value){lua_pushstring(L,name); -lua_pushnumber(L,value);lua_settable(L,-3);}static int pusherror(lua_State*L, -const char*info){lua_pushnil(L);if(info==NULL)lua_pushstring(L,strerror(errno) -);else lua_pushfstring(L,"%s: %s",info,strerror(errno));lua_pushnumber(L,errno -);return 3;}static int lposix_pushresult(lua_State*L,int i,const char*info){if -(i!=-1){lua_pushnumber(L,i);return 1;}else return pusherror(L,info);}static -void badoption(lua_State*L,int i,const char*what,int option){luaL_argerror(L,2 -,lua_pushfstring(L,"unknown %s option `%c'",what,option));}static uid_t -mygetuid(lua_State*L,int i){if(lua_isnone(L,i))return-1;else if(lua_isnumber(L -,i))return(uid_t)lua_tonumber(L,i);else if(lua_isstring(L,i)){struct passwd*p= -getpwnam(lua_tostring(L,i));return(p==NULL)?-1:p->pw_uid;}else return -luaL_typerror(L,i,"string or number");}static gid_t mygetgid(lua_State*L,int i -){if(lua_isnone(L,i))return-1;else if(lua_isnumber(L,i))return(gid_t) -lua_tonumber(L,i);else if(lua_isstring(L,i)){struct group*g=getgrnam( -lua_tostring(L,i));return(g==NULL)?-1:g->gr_gid;}else return luaL_typerror(L,i -,"string or number");}static int Perrno(lua_State*L){lua_pushstring(L,strerror -(errno));lua_pushnumber(L,errno);return 2;}static int Pdir(lua_State*L){const -char*path=luaL_optstring(L,1,".");DIR*d=opendir(path);if(d==NULL)return -pusherror(L,path);else{int i;struct dirent*entry;lua_newtable(L);for(i=1;( -entry=readdir(d))!=NULL;i++)storeindex(L,i,entry->d_name);closedir(d);return 1 -;}}static int aux_files(lua_State*L){DIR*d=lua_touserdata(L,lua_upvalueindex(1 -));struct dirent*entry;if(d==NULL)luaL_error(L,"attempt to use closed dir"); -entry=readdir(d);if(entry==NULL){closedir(d);lua_pushnil(L);lua_replace(L, -lua_upvalueindex(1));lua_pushnil(L);}else{lua_pushstring(L,entry->d_name); -#if 0 -#ifdef _DIRENT_HAVE_D_TYPE -lua_pushstring(L,filetype(DTTOIF(entry->d_type)));return 2; -#endif -#endif -}return 1;}static int Pfiles(lua_State*L){const char*path=luaL_optstring(L,1, -".");DIR*d=opendir(path);if(d==NULL)return pusherror(L,path);else{ -lua_pushlightuserdata(L,d);lua_pushcclosure(L,aux_files,1);return 1;}}static -int Pgetcwd(lua_State*L){char buf[MYBUFSIZ];if(getcwd(buf,sizeof(buf))==NULL) -return pusherror(L,".");else{lua_pushstring(L,buf);return 1;}}static int -Pmkdir(lua_State*L){const char*path=luaL_checkstring(L,1);return -lposix_pushresult(L,mkdir(path,0777),path);}static int Pchdir(lua_State*L){ -const char*path=luaL_checkstring(L,1);return lposix_pushresult(L,chdir(path), -path);}static int Prmdir(lua_State*L){const char*path=luaL_checkstring(L,1); -return lposix_pushresult(L,rmdir(path),path);}static int Punlink(lua_State*L){ -const char*path=luaL_checkstring(L,1);return lposix_pushresult(L,unlink(path), -path);}static int Plink(lua_State*L){const char*oldpath=luaL_checkstring(L,1); -const char*newpath=luaL_checkstring(L,2);return lposix_pushresult(L,link( -oldpath,newpath),NULL);}static int Psymlink(lua_State*L){const char*oldpath= -luaL_checkstring(L,1);const char*newpath=luaL_checkstring(L,2);return -lposix_pushresult(L,symlink(oldpath,newpath),NULL);}static int Preadlink( -lua_State*L){char buf[MYBUFSIZ];const char*path=luaL_checkstring(L,1);int n= -readlink(path,buf,sizeof(buf));if(n==-1)return pusherror(L,path); -lua_pushlstring(L,buf,n);return 1;}static int Paccess(lua_State*L){int mode= -F_OK;const char*path=luaL_checkstring(L,1);const char*s;for(s=luaL_optstring(L -,2,"f");*s!=0;s++)switch(*s){case' ':break;case'r':mode|=R_OK;break;case'w': -mode|=W_OK;break;case'x':mode|=X_OK;break;case'f':mode|=F_OK;break;default: -badoption(L,2,"mode",*s);break;}return lposix_pushresult(L,access(path,mode), -path);}static int Pmkfifo(lua_State*L){const char*path=luaL_checkstring(L,1); -return lposix_pushresult(L,mkfifo(path,0777),path);}static int Pexec(lua_State -*L){const char*path=luaL_checkstring(L,1);int i,n=lua_gettop(L);char**argv= -malloc((n+1)*sizeof(char*));if(argv==NULL)luaL_error(L,"not enough memory"); -argv[0]=(char*)path;for(i=1;ipw_name);break;case 1:lua_pushnumber(L,p->pw_uid);break; -case 2:lua_pushnumber(L,p->pw_gid);break;case 3:lua_pushstring(L,p->pw_dir); -break;case 4:lua_pushstring(L,p->pw_shell);break;case 5:lua_pushstring(L,p-> -pw_gecos);break;case 6:lua_pushstring(L,p->pw_passwd);break;}return 1;}static -const char*const Sgetpasswd[]={"name","uid","gid","dir","shell","gecos", -"passwd",NULL};static int Pgetpasswd(lua_State*L){struct passwd*p=NULL;if( -lua_isnoneornil(L,1))p=getpwuid(geteuid());else if(lua_isnumber(L,1))p= -getpwuid((uid_t)lua_tonumber(L,1));else if(lua_isstring(L,1))p=getpwnam( -lua_tostring(L,1));else luaL_typerror(L,1,"string or number");if(p==NULL) -lua_pushnil(L);else doselection(L,2,Sgetpasswd,Fgetpasswd,p);return 1;}static -int Pgetgroup(lua_State*L){struct group*g=NULL;if(lua_isnumber(L,1))g=getgrgid -((gid_t)lua_tonumber(L,1));else if(lua_isstring(L,1))g=getgrnam(lua_tostring(L -,1));else luaL_typerror(L,1,"string or number");if(g==NULL)lua_pushnil(L);else -{int i;lua_newtable(L);storestring(L,"name",g->gr_name);storenumber(L,"gid",g -->gr_gid);for(i=0;g->gr_mem[i]!=NULL;i++)storeindex(L,i+1,g->gr_mem[i]);} -return 1;}static int Psetuid(lua_State*L){return lposix_pushresult(L,setuid( -mygetuid(L,1)),NULL);}static int Psetgid(lua_State*L){return lposix_pushresult -(L,setgid(mygetgid(L,1)),NULL);}struct mytimes{struct tms t;clock_t elapsed;}; -#define pushtime(L,x) lua_pushnumber(L,((lua_Number)x)/CLOCKS_PER_SEC) -static int Ftimes(lua_State*L,int i,const void*data){const struct mytimes*t= -data;switch(i){case 0:pushtime(L,t->t.tms_utime);break;case 1:pushtime(L,t->t. -tms_stime);break;case 2:pushtime(L,t->t.tms_cutime);break;case 3:pushtime(L,t -->t.tms_cstime);break;case 4:pushtime(L,t->elapsed);break;}return 1;}static -const char*const Stimes[]={"utime","stime","cutime","cstime","elapsed",NULL}; -#define storetime(L,name,x) storenumber(L,name,(lua_Number)x/CLK_TCK) -static int Ptimes(lua_State*L){struct mytimes t;t.elapsed=times(&t.t);return -doselection(L,1,Stimes,Ftimes,&t);}struct mystat{struct stat s;char mode[10]; -const char*type;};static int Fstat(lua_State*L,int i,const void*data){const -struct mystat*s=data;switch(i){case 0:lua_pushstring(L,s->mode);break;case 1: -lua_pushnumber(L,s->s.st_ino);break;case 2:lua_pushnumber(L,s->s.st_dev);break -;case 3:lua_pushnumber(L,s->s.st_nlink);break;case 4:lua_pushnumber(L,s->s. -st_uid);break;case 5:lua_pushnumber(L,s->s.st_gid);break;case 6:lua_pushnumber -(L,s->s.st_size);break;case 7:lua_pushnumber(L,s->s.st_atime);break;case 8: -lua_pushnumber(L,s->s.st_mtime);break;case 9:lua_pushnumber(L,s->s.st_ctime); -break;case 10:lua_pushstring(L,s->type);break;case 11:lua_pushnumber(L,s->s. -st_mode);break;}return 1;}static const char*const Sstat[]={"mode","ino","dev", -"nlink","uid","gid","size","atime","mtime","ctime","type","_mode",NULL};static - int Pstat(lua_State*L){struct mystat s;const char*path=luaL_checkstring(L,1); -if(stat(path,&s.s)==-1)return pusherror(L,path);s.type=filetype(s.s.st_mode); -modechopper(s.s.st_mode,s.mode);return doselection(L,2,Sstat,Fstat,&s);}static - int Puname(lua_State*L){struct utsname u;luaL_Buffer b;const char*s;if(uname( -&u)==-1)return pusherror(L,NULL);luaL_buffinit(L,&b);for(s=luaL_optstring(L,1, -"%s %n %r %v %m");*s;s++)if(*s!='%')luaL_putchar(&b,*s);else switch(*++s){case -'%':luaL_putchar(&b,*s);break;case'm':luaL_addstring(&b,u.machine);break;case -'n':luaL_addstring(&b,u.nodename);break;case'r':luaL_addstring(&b,u.release); -break;case's':luaL_addstring(&b,u.sysname);break;case'v':luaL_addstring(&b,u. -version);break;default:badoption(L,2,"format",*s);break;}luaL_pushresult(&b); -return 1;}static const int Kpathconf[]={_PC_LINK_MAX,_PC_MAX_CANON, -_PC_MAX_INPUT,_PC_NAME_MAX,_PC_PATH_MAX,_PC_PIPE_BUF,_PC_CHOWN_RESTRICTED, -_PC_NO_TRUNC,_PC_VDISABLE,-1};static int Fpathconf(lua_State*L,int i,const -void*data){const char*path=data;lua_pushnumber(L,pathconf(path,Kpathconf[i])); -return 1;}static const char*const Spathconf[]={"link_max","max_canon", -"max_input","name_max","path_max","pipe_buf","chown_restricted","no_trunc", -"vdisable",NULL};static int Ppathconf(lua_State*L){const char*path= -luaL_checkstring(L,1);return doselection(L,2,Spathconf,Fpathconf,path);}static - const int Ksysconf[]={_SC_ARG_MAX,_SC_CHILD_MAX,_SC_CLK_TCK,_SC_NGROUPS_MAX, -_SC_STREAM_MAX,_SC_TZNAME_MAX,_SC_OPEN_MAX,_SC_JOB_CONTROL,_SC_SAVED_IDS, -_SC_VERSION,-1};static int Fsysconf(lua_State*L,int i,const void*data){ -lua_pushnumber(L,sysconf(Ksysconf[i]));return 1;}static const char*const -Ssysconf[]={"arg_max","child_max","clk_tck","ngroups_max","stream_max", -"tzname_max","open_max","job_control","saved_ids","version",NULL};static int -Psysconf(lua_State*L){return doselection(L,1,Ssysconf,Fsysconf,NULL);}static -const luaL_reg R[]={{"access",Paccess},{"chdir",Pchdir},{"chmod",Pchmod},{ -"chown",Pchown},{"ctermid",Pctermid},{"dir",Pdir},{"errno",Perrno},{"exec", -Pexec},{"files",Pfiles},{"fork",Pfork},{"getcwd",Pgetcwd},{"getenv",Pgetenv},{ -"getgroup",Pgetgroup},{"getlogin",Pgetlogin},{"getpasswd",Pgetpasswd},{ -"getprocessid",Pgetprocessid},{"kill",Pkill},{"link",Plink},{"mkdir",Pmkdir},{ -"mkfifo",Pmkfifo},{"pathconf",Ppathconf},{"putenv",Pputenv},{"readlink", -Preadlink},{"rmdir",Prmdir},{"setgid",Psetgid},{"setuid",Psetuid},{"sleep", -Psleep},{"stat",Pstat},{"symlink",Psymlink},{"sysconf",Psysconf},{"times", -Ptimes},{"ttyname",Pttyname},{"umask",Pumask},{"uname",Puname},{"unlink", -Punlink},{"utime",Putime},{"wait",Pwait}, -#ifdef linux -{"setenv",Psetenv},{"unsetenv",Punsetenv}, -#endif -{NULL,NULL}};LUALIB_API int luaopen_posix(lua_State*L){luaL_openlib(L,MYNAME,R -,0);lua_pushliteral(L,"version");lua_pushliteral(L,MYVERSION);lua_settable(L,- -3);return 1;} -#line 1 "lstate.c" -#define lstate_c -#ifndef LUA_USERSTATE -#define EXTRASPACE 0 -#else -union UEXTRASPACE{L_Umaxalign a;LUA_USERSTATE b;}; -#define EXTRASPACE (sizeof(union UEXTRASPACE)) -#endif -static int default_panic(lua_State*L){UNUSED(L);return 0;}static lua_State* -mallocstate(lua_State*L){lu_byte*block=(lu_byte*)luaM_malloc(L,sizeof( -lua_State)+EXTRASPACE);if(block==NULL)return NULL;else{block+=EXTRASPACE; -return cast(lua_State*,block);}}static void freestate(lua_State*L,lua_State*L1 -){luaM_free(L,cast(lu_byte*,L1)-EXTRASPACE,sizeof(lua_State)+EXTRASPACE);} -static void stack_init(lua_State*L1,lua_State*L){L1->stack=luaM_newvector(L, -BASIC_STACK_SIZE+EXTRA_STACK,TObject);L1->stacksize=BASIC_STACK_SIZE+ -EXTRA_STACK;L1->top=L1->stack;L1->stack_last=L1->stack+(L1->stacksize- -EXTRA_STACK)-1;L1->base_ci=luaM_newvector(L,BASIC_CI_SIZE,CallInfo);L1->ci=L1 -->base_ci;L1->ci->state=CI_C;setnilvalue(L1->top++);L1->base=L1->ci->base=L1-> -top;L1->ci->top=L1->top+LUA_MINSTACK;L1->size_ci=BASIC_CI_SIZE;L1->end_ci=L1-> -base_ci+L1->size_ci;}static void freestack(lua_State*L,lua_State*L1){ -luaM_freearray(L,L1->base_ci,L1->size_ci,CallInfo);luaM_freearray(L,L1->stack, -L1->stacksize,TObject);}static void f_luaopen(lua_State*L,void*ud){ -global_State*g=luaM_new(NULL,global_State);UNUSED(ud);if(g==NULL)luaD_throw(L, -LUA_ERRMEM);L->l_G=g;g->mainthread=L;g->GCthreshold=0;g->strt.size=0;g->strt. -nuse=0;g->strt.hash=NULL;setnilvalue(defaultmeta(L));setnilvalue(registry(L)); -luaZ_initbuffer(L,&g->buff);g->panic=default_panic;g->rootgc=NULL;g->rootudata -=NULL;g->tmudata=NULL;setnilvalue(gkey(g->dummynode));setnilvalue(gval(g-> -dummynode));g->dummynode->next=NULL;g->nblocks=sizeof(lua_State)+sizeof( -global_State);stack_init(L,L);defaultmeta(L)->tt=LUA_TTABLE;sethvalue( -defaultmeta(L),luaH_new(L,0,0));hvalue(defaultmeta(L))->metatable=hvalue( -defaultmeta(L));sethvalue(gt(L),luaH_new(L,0,4));sethvalue(registry(L), -luaH_new(L,4,4));luaS_resize(L,MINSTRTABSIZE);luaT_init(L);luaX_init(L); -luaS_fix(luaS_newliteral(L,MEMERRMSG));g->GCthreshold=4*G(L)->nblocks;}static -void preinit_state(lua_State*L){L->stack=NULL;L->stacksize=0;L->errorJmp=NULL; -L->hook=NULL;L->hookmask=L->hookinit=0;L->basehookcount=0;L->allowhook=1; -resethookcount(L);L->openupval=NULL;L->size_ci=0;L->nCcalls=0;L->base_ci=L->ci -=NULL;L->errfunc=0;setnilvalue(gt(L));}static void close_state(lua_State*L){ -luaF_close(L,L->stack);if(G(L)){luaC_sweep(L,1);lua_assert(G(L)->rootgc==NULL) -;lua_assert(G(L)->rootudata==NULL);luaS_freeall(L);luaZ_freebuffer(L,&G(L)-> -buff);}freestack(L,L);if(G(L)){lua_assert(G(L)->nblocks==sizeof(lua_State)+ -sizeof(global_State));luaM_freelem(NULL,G(L));}freestate(NULL,L);}lua_State* -luaE_newthread(lua_State*L){lua_State*L1=mallocstate(L);luaC_link(L,valtogco( -L1),LUA_TTHREAD);preinit_state(L1);L1->l_G=L->l_G;stack_init(L1,L);setobj2n(gt -(L1),gt(L));return L1;}void luaE_freethread(lua_State*L,lua_State*L1){ -luaF_close(L1,L1->stack);lua_assert(L1->openupval==NULL);freestack(L,L1); -freestate(L,L1);}LUA_API lua_State*lua_open(void){lua_State*L=mallocstate(NULL -);if(L){L->tt=LUA_TTHREAD;L->marked=0;L->next=L->gclist=NULL;preinit_state(L); -L->l_G=NULL;if(luaD_rawrunprotected(L,f_luaopen,NULL)!=0){close_state(L);L= -NULL;}}lua_userstateopen(L);return L;}static void callallgcTM(lua_State*L,void -*ud){UNUSED(ud);luaC_callGCTM(L);}LUA_API void lua_close(lua_State*L){lua_lock -(L);L=G(L)->mainthread;luaF_close(L,L->stack);luaC_separateudata(L);L->errfunc -=0;do{L->ci=L->base_ci;L->base=L->top=L->ci->base;L->nCcalls=0;}while( -luaD_rawrunprotected(L,callallgcTM,NULL)!=0);lua_assert(G(L)->tmudata==NULL); -close_state(L);} -#line 1 "lstring.c" -#define lstring_c -void luaS_freeall(lua_State*L){lua_assert(G(L)->strt.nuse==0);luaM_freearray(L -,G(L)->strt.hash,G(L)->strt.size,TString*);}void luaS_resize(lua_State*L,int -newsize){GCObject**newhash=luaM_newvector(L,newsize,GCObject*);stringtable*tb= -&G(L)->strt;int i;for(i=0;isize;i++ -){GCObject*p=tb->hash[i];while(p){GCObject*next=p->gch.next;lu_hash h=gcotots( -p)->tsv.hash;int h1=lmod(h,newsize);lua_assert(cast(int,h%newsize)==lmod(h, -newsize));p->gch.next=newhash[h1];newhash[h1]=p;p=next;}}luaM_freearray(L,tb-> -hash,tb->size,TString*);tb->size=newsize;tb->hash=newhash;}static TString* -newlstr(lua_State*L,const char*str,size_t l,lu_hash h){TString*ts=cast(TString -*,luaM_malloc(L,sizestring(l)));stringtable*tb;ts->tsv.len=l;ts->tsv.hash=h;ts -->tsv.marked=0;ts->tsv.tt=LUA_TSTRING;ts->tsv.reserved=0;memcpy(ts+1,str,l* -sizeof(char));((char*)(ts+1))[l]='\0';tb=&G(L)->strt;h=lmod(h,tb->size);ts-> -tsv.next=tb->hash[h];tb->hash[h]=valtogco(ts);tb->nuse++;if(tb->nuse>cast( -ls_nstr,tb->size)&&tb->size<=MAX_INT/2)luaS_resize(L,tb->size*2);return ts;} -TString*luaS_newlstr(lua_State*L,const char*str,size_t l){GCObject*o;lu_hash h -=(lu_hash)l;size_t step=(l>>5)+1;size_t l1;for(l1=l;l1>=step;l1-=step)h=h^((h -<<5)+(h>>2)+(unsigned char)(str[l1-1]));for(o=G(L)->strt.hash[lmod(h,G(L)-> -strt.size)];o!=NULL;o=o->gch.next){TString*ts=gcotots(o);if(ts->tsv.len==l&&( -memcmp(str,getstr(ts),l)==0))return ts;}return newlstr(L,str,l,h);}Udata* -luaS_newudata(lua_State*L,size_t s){Udata*u;u=cast(Udata*,luaM_malloc(L, -sizeudata(s)));u->uv.marked=(1<<1);u->uv.tt=LUA_TUSERDATA;u->uv.len=s;u->uv. -metatable=hvalue(defaultmeta(L));u->uv.next=G(L)->rootudata;G(L)->rootudata= -valtogco(u);return u;} -#line 1 "lstrlib.c" -#define lstrlib_c -#ifndef uchar -#define uchar(c) ((unsigned char)(c)) -#endif -typedef long sint32;static int str_len(lua_State*L){size_t l;luaL_checklstring -(L,1,&l);lua_pushnumber(L,(lua_Number)l);return 1;}static sint32 posrelat( -sint32 pos,size_t len){return(pos>=0)?pos:(sint32)len+pos+1;}static int -str_sub(lua_State*L){size_t l;const char*s=luaL_checklstring(L,1,&l);sint32 -start=posrelat(luaL_checklong(L,2),l);sint32 end=posrelat(luaL_optlong(L,3,-1) -,l);if(start<1)start=1;if(end>(sint32)l)end=(sint32)l;if(start<=end) -lua_pushlstring(L,s+start-1,end-start+1);else lua_pushliteral(L,"");return 1;} -static int str_lower(lua_State*L){size_t l;size_t i;luaL_Buffer b;const char*s -=luaL_checklstring(L,1,&l);luaL_buffinit(L,&b);for(i=0;i0)luaL_addlstring(&b,s,l);luaL_pushresult(&b); -return 1;}static int str_byte(lua_State*L){size_t l;const char*s= -luaL_checklstring(L,1,&l);sint32 pos=posrelat(luaL_optlong(L,2,1),l);if(pos<=0 -||(size_t)(pos)>l)return 0;lua_pushnumber(L,uchar(s[pos-1]));return 1;}static -int str_char(lua_State*L){int n=lua_gettop(L);int i;luaL_Buffer b; -luaL_buffinit(L,&b);for(i=1;i<=n;i++){int c=luaL_checkint(L,i);luaL_argcheck(L -,uchar(c)==c,i,"invalid value");luaL_putchar(&b,uchar(c));}luaL_pushresult(&b) -;return 1;}static int writer(lua_State*L,const void*b,size_t size,void*B){( -void)L;luaL_addlstring((luaL_Buffer*)B,(const char*)b,size);return 1;}static -int str_dump(lua_State*L){luaL_Buffer b;luaL_checktype(L,1,LUA_TFUNCTION); -luaL_buffinit(L,&b);if(!lua_dump(L,writer,&b))luaL_error(L, -"unable to dump given function");luaL_pushresult(&b);return 1;} -#ifndef MAX_CAPTURES -#define MAX_CAPTURES 32 -#endif -#define CAP_UNFINISHED (-1) -#define CAP_POSITION (-2) -typedef struct MatchState{const char*src_init;const char*src_end;lua_State*L; -int level;struct{const char*init;sint32 len;}capture[MAX_CAPTURES];}MatchState -; -#define ESC '%' -#define SPECIALS "^$*+?.([%-" -static int check_capture(MatchState*ms,int l){l-='1';if(l<0||l>=ms->level||ms -->capture[l].len==CAP_UNFINISHED)return luaL_error(ms->L, -"invalid capture index");return l;}static int capture_to_close(MatchState*ms){ -int level=ms->level;for(level--;level>=0;level--)if(ms->capture[level].len== -CAP_UNFINISHED)return level;return luaL_error(ms->L,"invalid pattern capture") -;}static const char*luaI_classend(MatchState*ms,const char*p){switch(*p++){ -case ESC:{if(*p=='\0')luaL_error(ms->L,"malformed pattern (ends with `%')"); -return p+1;}case'[':{if(*p=='^')p++;do{if(*p=='\0')luaL_error(ms->L, -"malformed pattern (missing `]')");if(*(p++)==ESC&&*p!='\0')p++;}while(*p!=']' -);return p+1;}default:{return p;}}}static int match_class(int c,int cl){int -res;switch(tolower(cl)){case'a':res=isalpha(c);break;case'c':res=iscntrl(c); -break;case'd':res=isdigit(c);break;case'l':res=islower(c);break;case'p':res= -ispunct(c);break;case's':res=isspace(c);break;case'u':res=isupper(c);break; -case'w':res=isalnum(c);break;case'x':res=isxdigit(c);break;case'z':res=(c==0); -break;default:return(cl==c);}return(islower(cl)?res:!res);}static int -matchbracketclass(int c,const char*p,const char*ec){int sig=1;if(*(p+1)=='^'){ -sig=0;p++;}while(++pL,"unbalanced pattern");if(*s!=*p) -return NULL;else{int b=*p;int e=*(p+1);int cont=1;while(++ssrc_end){if(*s -==e){if(--cont==0)return s+1;}else if(*s==b)cont++;}}return NULL;}static const - char*max_expand(MatchState*ms,const char*s,const char*p,const char*ep){sint32 - i=0;while((s+i)src_end&&luaI_singlematch(uchar(*(s+i)),p,ep))i++;while(i ->=0){const char*res=match(ms,(s+i),ep+1);if(res)return res;i--;}return NULL;} -static const char*min_expand(MatchState*ms,const char*s,const char*p,const -char*ep){for(;;){const char*res=match(ms,s,ep+1);if(res!=NULL)return res;else -if(ssrc_end&&luaI_singlematch(uchar(*s),p,ep))s++;else return NULL;}} -static const char*start_capture(MatchState*ms,const char*s,const char*p,int -what){const char*res;int level=ms->level;if(level>=MAX_CAPTURES)luaL_error(ms -->L,"too many captures");ms->capture[level].init=s;ms->capture[level].len=what -;ms->level=level+1;if((res=match(ms,s,p))==NULL)ms->level--;return res;}static - const char*end_capture(MatchState*ms,const char*s,const char*p){int l= -capture_to_close(ms);const char*res;ms->capture[l].len=s-ms->capture[l].init; -if((res=match(ms,s,p))==NULL)ms->capture[l].len=CAP_UNFINISHED;return res;} -static const char*match_capture(MatchState*ms,const char*s,int l){size_t len;l -=check_capture(ms,l);len=ms->capture[l].len;if((size_t)(ms->src_end-s)>=len&& -memcmp(ms->capture[l].init,s,len)==0)return s+len;else return NULL;}static -const char*match(MatchState*ms,const char*s,const char*p){init:switch(*p){case -'(':{if(*(p+1)==')')return start_capture(ms,s,p+2,CAP_POSITION);else return -start_capture(ms,s,p+1,CAP_UNFINISHED);}case')':{return end_capture(ms,s,p+1); -}case ESC:{switch(*(p+1)){case'b':{s=matchbalance(ms,s,p+2);if(s==NULL)return -NULL;p+=4;goto init;}case'f':{const char*ep;char previous;p+=2;if(*p!='[') -luaL_error(ms->L,"missing `[' after `%%f' in pattern");ep=luaI_classend(ms,p); -previous=(s==ms->src_init)?'\0':*(s-1);if(matchbracketclass(uchar(previous),p, -ep-1)||!matchbracketclass(uchar(*s),p,ep-1))return NULL;p=ep;goto init;} -default:{if(isdigit(uchar(*(p+1)))){s=match_capture(ms,s,*(p+1));if(s==NULL) -return NULL;p+=2;goto init;}goto dflt;}}}case'\0':{return s;}case'$':{if(*(p+1 -)=='\0')return(s==ms->src_end)?s:NULL;else goto dflt;}default:dflt:{const char -*ep=luaI_classend(ms,p);int m=ssrc_end&&luaI_singlematch(uchar(*s),p,ep); -switch(*ep){case'?':{const char*res;if(m&&((res=match(ms,s+1,ep+1))!=NULL)) -return res;p=ep+1;goto init;}case'*':{return max_expand(ms,s,p,ep);}case'+':{ -return(m?max_expand(ms,s+1,p,ep):NULL);}case'-':{return min_expand(ms,s,p,ep); -}default:{if(!m)return NULL;s++;p=ep;goto init;}}}}}static const char*lmemfind -(const char*s1,size_t l1,const char*s2,size_t l2){if(l2==0)return s1;else if( -l2>l1)return NULL;else{const char*init;l2--;l1=l1-l2;while(l1>0&&(init=(const -char*)memchr(s1,*s2,l1))!=NULL){init++;if(memcmp(init,s2+1,l2)==0)return init- -1;else{l1-=init-s1;s1=init;}}return NULL;}}static void push_onecapture( -MatchState*ms,int i){int l=ms->capture[i].len;if(l==CAP_UNFINISHED)luaL_error( -ms->L,"unfinished capture");if(l==CAP_POSITION)lua_pushnumber(ms->L,( -lua_Number)(ms->capture[i].init-ms->src_init+1));else lua_pushlstring(ms->L,ms -->capture[i].init,l);}static int push_captures(MatchState*ms,const char*s, -const char*e){int i;luaL_checkstack(ms->L,ms->level,"too many captures");if(ms -->level==0&&s){lua_pushlstring(ms->L,s,e-s);return 1;}else{for(i=0;ilevel -;i++)push_onecapture(ms,i);return ms->level;}}static int str_find(lua_State*L) -{size_t l1,l2;const char*s=luaL_checklstring(L,1,&l1);const char*p= -luaL_checklstring(L,2,&l2);sint32 init=posrelat(luaL_optlong(L,3,1),l1)-1;if( -init<0)init=0;else if((size_t)(init)>l1)init=(sint32)l1;if(lua_toboolean(L,4) -||strpbrk(p,SPECIALS)==NULL){const char*s2=lmemfind(s+init,l1-init,p,l2);if(s2 -){lua_pushnumber(L,(lua_Number)(s2-s+1));lua_pushnumber(L,(lua_Number)(s2-s+l2 -));return 2;}}else{MatchState ms;int anchor=(*p=='^')?(p++,1):0;const char*s1= -s+init;ms.L=L;ms.src_init=s;ms.src_end=s+l1;do{const char*res;ms.level=0;if(( -res=match(&ms,s1,p))!=NULL){lua_pushnumber(L,(lua_Number)(s1-s+1)); -lua_pushnumber(L,(lua_Number)(res-s));return push_captures(&ms,NULL,0)+2;}} -while(s1++L -;if(lua_isstring(L,3)){const char*news=lua_tostring(L,3);size_t l=lua_strlen(L -,3);size_t i;for(i=0;i=3&&(lua_isstring(L,3)||lua_isfunction(L,3)),3, -"string or function expected");luaL_buffinit(L,&b);ms.L=L;ms.src_init=src;ms. -src_end=src+srcl;while(nsrc)src=e;else if(srcMAX_FORMAT)luaL_error(L,"invalid format (too long)");form[0]='%'; -strncpy(form+1,strfrmt,p-strfrmt+1);form[p-strfrmt+2]=0;return p;}static int -str_format(lua_State*L){int arg=1;size_t sfl;const char*strfrmt= -luaL_checklstring(L,arg,&sfl);const char*strfrmt_end=strfrmt+sfl;luaL_Buffer b -;luaL_buffinit(L,&b);while(strfrmt=100){lua_pushvalue(L,arg); -luaL_addvalue(&b);continue;}else{sprintf(buff,form,s);break;}}default:{return -luaL_error(L,"invalid option to `format'");}}luaL_addlstring(&b,buff,strlen( -buff));}}luaL_pushresult(&b);return 1;}static const luaL_reg strlib[]={{"len", -str_len},{"sub",str_sub},{"lower",str_lower},{"upper",str_upper},{"char", -str_char},{"rep",str_rep},{"byte",str_byte},{"format",str_format},{"dump", -str_dump},{"find",str_find},{"gfind",gfind},{"gsub",str_gsub},{NULL,NULL}}; -LUALIB_API int luaopen_string(lua_State*L){luaL_openlib(L,LUA_STRLIBNAME, -strlib,0);return 1;} -#line 1 "ltable.c" -#define ltable_c -#if BITS_INT >26 -#define MAXBITS 24 -#else -#define MAXBITS (BITS_INT-2) -#endif -#define toobig(x) ((((x)-1)>>MAXBITS)!=0) -#ifndef lua_number2int -#define lua_number2int(i,n) ((i)=(int)(n)) -#endif -#define hashpow2(t,n) (gnode(t,lmod((n),sizenode(t)))) -#define hashstr(t,str) hashpow2(t,(str)->tsv.hash) -#define hashboolean(t,p) hashpow2(t,p) -#define hashmod(t,n) (gnode(t,((n)%((sizenode(t)-1)|1)))) -#define hashpointer(t,p) hashmod(t,IntPoint(p)) -#define numints cast(int,sizeof(lua_Number)/sizeof(int)) -static Node*hashnum(const Table*t,lua_Number n){unsigned int a[numints];int i; -n+=1;lua_assert(sizeof(a)<=sizeof(n));memcpy(a,&n,sizeof(a));for(i=1;i=1&&!toobig(k))return k;} -return-1;}static int luaH_index(lua_State*L,Table*t,StkId key){int i;if( -ttisnil(key))return-1;i=arrayindex(key);if(0<=i&&i<=t->sizearray){return i-1;} -else{const TObject*v=luaH_get(t,key);if(v==&luaO_nilobject)luaG_runerror(L, -"invalid key for `next'");i=cast(int,(cast(const lu_byte*,v)-cast(const -lu_byte*,gval(gnode(t,0))))/sizeof(Node));return i+t->sizearray;}}int -luaH_next(lua_State*L,Table*t,StkId key){int i=luaH_index(L,t,key);for(i++;isizearray;i++){if(!ttisnil(&t->array[i])){setnvalue(key,cast(lua_Number,i+1) -);setobj2s(key+1,&t->array[i]);return 1;}}for(i-=t->sizearray;i=twoto(i-1);i++){if(nums[i]>0){a+=nums[i];if(a>= -twoto(i-1)){n=i;na=a;}}}lua_assert(na<=*narray&&*narray<=ntotal);*nhash=ntotal --na;*narray=(n==-1)?0:twoto(n);lua_assert(na<=*narray&&na>=*narray/2);}static -void numuse(const Table*t,int*narray,int*nhash){int nums[MAXBITS+1];int i,lg; -int totaluse=0;for(i=0,lg=0;lg<=MAXBITS;lg++){int ttlg=twoto(lg);if(ttlg>t-> -sizearray){ttlg=t->sizearray;if(i>=ttlg)break;}nums[lg]=0;for(;iarray[i])){nums[lg]++;totaluse++;}}}for(;lg<=MAXBITS;lg++)nums[lg -]=0;*narray=totaluse;i=sizenode(t);while(i--){Node*n=&t->node[i];if(!ttisnil( -gval(n))){int k=arrayindex(gkey(n));if(k>=0){nums[luaO_log2(k-1)+1]++;(*narray -)++;}totaluse++;}}computesizes(nums,totaluse,narray,nhash);}static void -setarrayvector(lua_State*L,Table*t,int size){int i;luaM_reallocvector(L,t-> -array,t->sizearray,size,TObject);for(i=t->sizearray;iarray[i]);t->sizearray=size;}static void setnodevector(lua_State*L,Table*t, -int lsize){int i;int size=twoto(lsize);if(lsize>MAXBITS)luaG_runerror(L, -"table overflow");if(lsize==0){t->node=G(L)->dummynode;lua_assert(ttisnil(gkey -(t->node)));lua_assert(ttisnil(gval(t->node)));lua_assert(t->node->next==NULL) -;}else{t->node=luaM_newvector(L,size,Node);for(i=0;inode[i].next -=NULL;setnilvalue(gkey(gnode(t,i)));setnilvalue(gval(gnode(t,i)));}}t-> -lsizenode=cast(lu_byte,lsize);t->firstfree=gnode(t,size-1);}static void resize -(lua_State*L,Table*t,int nasize,int nhsize){int i;int oldasize=t->sizearray; -int oldhsize=t->lsizenode;Node*nold;Node temp[1];if(oldhsize)nold=t->node;else -{lua_assert(t->node==G(L)->dummynode);temp[0]=t->node[0];nold=temp;setnilvalue -(gkey(G(L)->dummynode));setnilvalue(gval(G(L)->dummynode));lua_assert(G(L)-> -dummynode->next==NULL);}if(nasize>oldasize)setarrayvector(L,t,nasize); -setnodevector(L,t,nhsize);if(nasizesizearray=nasize;for(i=nasize -;iarray[i]))setobjt2t(luaH_setnum(L,t,i+1),&t-> -array[i]);}luaM_reallocvector(L,t->array,oldasize,nasize,TObject);}for(i=twoto -(oldhsize)-1;i>=0;i--){Node*old=nold+i;if(!ttisnil(gval(old)))setobjt2t( -luaH_set(L,t,gkey(old)),gval(old));}if(oldhsize)luaM_freearray(L,nold,twoto( -oldhsize),Node);}static void rehash(lua_State*L,Table*t){int nasize,nhsize; -numuse(t,&nasize,&nhsize);resize(L,t,nasize,luaO_log2(nhsize)+1);}Table* -luaH_new(lua_State*L,int narray,int lnhash){Table*t=luaM_new(L,Table); -luaC_link(L,valtogco(t),LUA_TTABLE);t->metatable=hvalue(defaultmeta(L));t-> -flags=cast(lu_byte,~0);t->array=NULL;t->sizearray=0;t->lsizenode=0;t->node= -NULL;setarrayvector(L,t,narray);setnodevector(L,t,lnhash);return t;}void -luaH_free(lua_State*L,Table*t){if(t->lsizenode)luaM_freearray(L,t->node, -sizenode(t),Node);luaM_freearray(L,t->array,t->sizearray,TObject);luaM_freelem -(L,t);} -#if 0 -void luaH_remove(Table*t,Node*e){Node*mp=luaH_mainposition(t,gkey(e));if(e!=mp -){while(mp->next!=e)mp=mp->next;mp->next=e->next;}else{if(e->next!=NULL)??} -lua_assert(ttisnil(gval(node)));setnilvalue(gkey(e));e->next=NULL;} -#endif -static TObject*newkey(lua_State*L,Table*t,const TObject*key){TObject*val;Node* -mp=luaH_mainposition(t,key);if(!ttisnil(gval(mp))){Node*othern= -luaH_mainposition(t,gkey(mp));Node*n=t->firstfree;if(othern!=mp){while(othern -->next!=mp)othern=othern->next;othern->next=n;*n=*mp;mp->next=NULL;setnilvalue -(gval(mp));}else{n->next=mp->next;mp->next=n;mp=n;}}setobj2t(gkey(mp),key); -lua_assert(ttisnil(gval(mp)));for(;;){if(ttisnil(gkey(t->firstfree)))return -gval(mp);else if(t->firstfree==t->node)break;else(t->firstfree)--;}setbvalue( -gval(mp),0);rehash(L,t);val=cast(TObject*,luaH_get(t,key));lua_assert( -ttisboolean(val));setnilvalue(val);return val;}static const TObject* -luaH_getany(Table*t,const TObject*key){if(ttisnil(key))return&luaO_nilobject; -else{Node*n=luaH_mainposition(t,key);do{if(luaO_rawequalObj(gkey(n),key)) -return gval(n);else n=n->next;}while(n);return&luaO_nilobject;}}const TObject* -luaH_getnum(Table*t,int key){if(1<=key&&key<=t->sizearray)return&t->array[key- -1];else{lua_Number nk=cast(lua_Number,key);Node*n=hashnum(t,nk);do{if( -ttisnumber(gkey(n))&&nvalue(gkey(n))==nk)return gval(n);else n=n->next;}while( -n);return&luaO_nilobject;}}const TObject*luaH_getstr(Table*t,TString*key){Node -*n=hashstr(t,key);do{if(ttisstring(gkey(n))&&tsvalue(gkey(n))==key)return gval -(n);else n=n->next;}while(n);return&luaO_nilobject;}const TObject*luaH_get( -Table*t,const TObject*key){switch(ttype(key)){case LUA_TSTRING:return -luaH_getstr(t,tsvalue(key));case LUA_TNUMBER:{int k;lua_number2int(k,(nvalue( -key)));if(cast(lua_Number,k)==nvalue(key))return luaH_getnum(t,k);}default: -return luaH_getany(t,key);}}TObject*luaH_set(lua_State*L,Table*t,const TObject -*key){const TObject*p=luaH_get(t,key);t->flags=0;if(p!=&luaO_nilobject)return -cast(TObject*,p);else{if(ttisnil(key))luaG_runerror(L,"table index is nil"); -else if(ttisnumber(key)&&nvalue(key)!=nvalue(key))luaG_runerror(L, -"table index is NaN");return newkey(L,t,key);}}TObject*luaH_setnum(lua_State*L -,Table*t,int key){const TObject*p=luaH_getnum(t,key);if(p!=&luaO_nilobject) -return cast(TObject*,p);else{TObject k;setnvalue(&k,cast(lua_Number,key)); -return newkey(L,t,&k);}} -#line 1 "ltablib.c" -#define ltablib_c -#define aux_getn(L,n) (luaL_checktype(L,n,LUA_TTABLE),luaL_getn(L,n)) -static int luaB_foreachi(lua_State*L){int i;int n=aux_getn(L,1);luaL_checktype -(L,2,LUA_TFUNCTION);for(i=1;i<=n;i++){lua_pushvalue(L,2);lua_pushnumber(L,( -lua_Number)i);lua_rawgeti(L,1,i);lua_call(L,2,1);if(!lua_isnil(L,-1))return 1; -lua_pop(L,1);}return 0;}static int luaB_foreach(lua_State*L){luaL_checktype(L, -1,LUA_TTABLE);luaL_checktype(L,2,LUA_TFUNCTION);lua_pushnil(L);for(;;){if( -lua_next(L,1)==0)return 0;lua_pushvalue(L,2);lua_pushvalue(L,-3);lua_pushvalue -(L,-3);lua_call(L,2,1);if(!lua_isnil(L,-1))return 1;lua_pop(L,2);}}static int -luaB_getn(lua_State*L){lua_pushnumber(L,(lua_Number)aux_getn(L,1));return 1;} -static int luaB_setn(lua_State*L){luaL_checktype(L,1,LUA_TTABLE);luaL_setn(L,1 -,luaL_checkint(L,2));return 0;}static int luaB_tinsert(lua_State*L){int v= -lua_gettop(L);int n=aux_getn(L,1)+1;int pos;if(v==2)pos=n;else{pos= -luaL_checkint(L,2);if(pos>n)n=pos;v=3;}luaL_setn(L,1,n);while(--n>=pos){ -lua_rawgeti(L,1,n);lua_rawseti(L,1,n+1);}lua_pushvalue(L,v);lua_rawseti(L,1, -pos);return 0;}static int luaB_tremove(lua_State*L){int n=aux_getn(L,1);int -pos=luaL_optint(L,2,n);if(n<=0)return 0;luaL_setn(L,1,n-1);lua_rawgeti(L,1,pos -);for(;posu) -luaL_error(L,"invalid order function for sorting");lua_pop(L,1);}while( -lua_rawgeti(L,1,--j),sort_comp(L,-3,-1)){if(jci->base+(k)-1) -static void setnameval(lua_State*L,const char*name,int val){lua_pushstring(L, -name);lua_pushintegral(L,val);lua_settable(L,-3);} -#define MARK 0x55 -#ifndef EXTERNMEMCHECK -#define HEADER (sizeof(L_Umaxalign)) -#define MARKSIZE 16 -#define blockhead(b) (cast(char*,b)-HEADER) -#define setsize(newblock, size)(*cast(size_t*,newblock)=size) -#define checkblocksize(b, size)(size==(*cast(size_t*,blockhead(b)))) -#define fillmem(mem,size) memset(mem,-MARK,size) -#else -#define HEADER 0 -#define MARKSIZE 0 -#define blockhead(b) (b) -#define setsize(newblock, size) -#define checkblocksize(b,size) (1) -#define fillmem(mem,size) -#endif -unsigned long memdebug_numblocks=0;unsigned long memdebug_total=0;unsigned -long memdebug_maxmem=0;unsigned long memdebug_memlimit=ULONG_MAX;static void* -checkblock(void*block,size_t size){void*b=blockhead(block);int i;for(i=0;i< -MARKSIZE;i++)lua_assert(*(cast(char*,b)+HEADER+size+i)==MARK+i);return b;} -static void freeblock(void*block,size_t size){if(block){lua_assert( -checkblocksize(block,size));block=checkblock(block,size);fillmem(block,size+ -HEADER+MARKSIZE);free(block);memdebug_numblocks--;memdebug_total-=size;}}void* -debug_realloc(void*block,size_t oldsize,size_t size){lua_assert(oldsize==0|| -checkblocksize(block,oldsize));lua_assert(block!=NULL||size>0);if(size==0){ -freeblock(block,oldsize);return NULL;}else if(size>oldsize&&memdebug_total+ -size-oldsize>memdebug_memlimit)return NULL;else{void*newblock;int i;size_t -realsize=HEADER+size+MARKSIZE;size_t commonsize=(oldsizememdebug_maxmem)memdebug_maxmem= -memdebug_total;memdebug_numblocks++;setsize(newblock,size);for(i=0;icode[pc];OpCode o=GET_OPCODE(i);const char*name=luaP_opnames[o];int line= -getline(p,pc);sprintf(buff,"(%4d) %4d - ",line,pc);switch(getOpMode(o)){case -iABC:sprintf(buff+strlen(buff),"%-12s%4d %4d %4d",name,GETARG_A(i),GETARG_B(i) -,GETARG_C(i));break;case iABx:sprintf(buff+strlen(buff),"%-12s%4d %4d",name, -GETARG_A(i),GETARG_Bx(i));break;case iAsBx:sprintf(buff+strlen(buff), -"%-12s%4d %4d",name,GETARG_A(i),GETARG_sBx(i));break;}return buff;} -#if 0 -void luaI_printcode(Proto*pt,int size){int pc;for(pc=0;pcl.p;lua_newtable(L);setnameval(L,"maxstack",p->maxstacksize);setnameval(L, -"numparams",p->numparams);for(pc=0;pcsizecode;pc++){char buff[100]; -lua_pushintegral(L,pc+1);lua_pushstring(L,buildop(p,pc,buff));lua_settable(L,- -3);}return 1;}static int listk(lua_State*L){Proto*p;int i;luaL_argcheck(L, -lua_isfunction(L,1)&&!lua_iscfunction(L,1),1,"Lua function expected");p= -clvalue(func_at(L,1))->l.p;lua_newtable(L);for(i=0;isizek;i++){ -lua_pushintegral(L,i+1);luaA_pushobject(L,p->k+i);lua_settable(L,-3);}return 1 -;}static int listlocals(lua_State*L){Proto*p;int pc=luaL_checkint(L,2)-1;int i -=0;const char*name;luaL_argcheck(L,lua_isfunction(L,1)&&!lua_iscfunction(L,1), -1,"Lua function expected");p=clvalue(func_at(L,1))->l.p;while((name= -luaF_getlocalname(p,++i,pc))!=NULL)lua_pushstring(L,name);return i-1;}static -int get_limits(lua_State*L){lua_newtable(L);setnameval(L,"BITS_INT",BITS_INT); -setnameval(L,"LFPF",LFIELDS_PER_FLUSH);setnameval(L,"MAXVARS",MAXVARS); -setnameval(L,"MAXPARAMS",MAXPARAMS);setnameval(L,"MAXSTACK",MAXSTACK); -setnameval(L,"MAXUPVALUES",MAXUPVALUES);return 1;}static int mem_query( -lua_State*L){if(lua_isnone(L,1)){lua_pushintegral(L,memdebug_total); -lua_pushintegral(L,memdebug_numblocks);lua_pushintegral(L,memdebug_maxmem); -return 3;}else{memdebug_memlimit=luaL_checkint(L,1);return 0;}}static int -hash_query(lua_State*L){if(lua_isnone(L,2)){luaL_argcheck(L,lua_type(L,1)== -LUA_TSTRING,1,"string expected");lua_pushintegral(L,tsvalue(func_at(L,1))->tsv -.hash);}else{TObject*o=func_at(L,1);Table*t;luaL_checktype(L,2,LUA_TTABLE);t= -hvalue(func_at(L,2));lua_pushintegral(L,luaH_mainposition(t,o)-t->node);} -return 1;}static int stacklevel(lua_State*L){unsigned long a=0; -lua_pushintegral(L,(int)(L->top-L->stack));lua_pushintegral(L,(int)(L-> -stack_last-L->stack));lua_pushintegral(L,(int)(L->ci-L->base_ci)); -lua_pushintegral(L,(int)(L->end_ci-L->base_ci));lua_pushintegral(L,(unsigned -long)&a);return 5;}static int table_query(lua_State*L){const Table*t;int i= -luaL_optint(L,2,-1);luaL_checktype(L,1,LUA_TTABLE);t=hvalue(func_at(L,1));if(i -==-1){lua_pushintegral(L,t->sizearray);lua_pushintegral(L,sizenode(t)); -lua_pushintegral(L,t->firstfree-t->node);}else if(isizearray){ -lua_pushintegral(L,i);luaA_pushobject(L,&t->array[i]);lua_pushnil(L);}else if( -(i-=t->sizearray)");luaA_pushobject(L,gval(gnode(t,i)));if(t-> -node[i].next)lua_pushintegral(L,t->node[i].next-t->node);else lua_pushnil(L);} -return 3;}static int string_query(lua_State*L){stringtable*tb=&G(L)->strt;int -s=luaL_optint(L,2,0)-1;if(s==-1){lua_pushintegral(L,tb->nuse);lua_pushintegral -(L,tb->size);return 2;}else if(ssize){GCObject*ts;int n=0;for(ts=tb->hash -[s];ts;ts=ts->gch.next){setsvalue2s(L->top,gcotots(ts));incr_top(L);n++;} -return n;}return 0;}static int tref(lua_State*L){int level=lua_gettop(L);int -lock=luaL_optint(L,2,1);luaL_checkany(L,1);lua_pushvalue(L,1);lua_pushintegral -(L,lua_ref(L,lock));assert(lua_gettop(L)==level+1);return 1;}static int getref -(lua_State*L){int level=lua_gettop(L);lua_getref(L,luaL_checkint(L,1));assert( -lua_gettop(L)==level+1);return 1;}static int unref(lua_State*L){int level= -lua_gettop(L);lua_unref(L,luaL_checkint(L,1));assert(lua_gettop(L)==level); -return 0;}static int metatable(lua_State*L){luaL_checkany(L,1);if(lua_isnone(L -,2)){if(lua_getmetatable(L,1)==0)lua_pushnil(L);}else{lua_settop(L,2); -luaL_checktype(L,2,LUA_TTABLE);lua_setmetatable(L,1);}return 1;}static int -upvalue(lua_State*L){int n=luaL_checkint(L,2);luaL_checktype(L,1,LUA_TFUNCTION -);if(lua_isnone(L,3)){const char*name=lua_getupvalue(L,1,n);if(name==NULL) -return 0;lua_pushstring(L,name);return 2;}else{const char*name=lua_setupvalue( -L,1,n);lua_pushstring(L,name);return 1;}}static int newuserdata(lua_State*L){ -size_t size=luaL_checkint(L,1);char*p=cast(char*,lua_newuserdata(L,size)); -while(size--)*p++='\0';return 1;}static int pushuserdata(lua_State*L){ -lua_pushlightuserdata(L,cast(void*,luaL_checkint(L,1)));return 1;}static int -udataval(lua_State*L){lua_pushintegral(L,cast(int,lua_touserdata(L,1)));return - 1;}static int doonnewstack(lua_State*L){lua_State*L1=lua_newthread(L);size_t -l;const char*s=luaL_checklstring(L,1,&l);int status=luaL_loadbuffer(L1,s,l,s); -if(status==0)status=lua_pcall(L1,0,0,0);lua_pushintegral(L,status);return 1;} -static int s2d(lua_State*L){lua_pushnumber(L,*cast(const double*, -luaL_checkstring(L,1)));return 1;}static int d2s(lua_State*L){double d= -luaL_checknumber(L,1);lua_pushlstring(L,cast(char*,&d),sizeof(d));return 1;} -static int newstate(lua_State*L){lua_State*L1=lua_open();if(L1){ -lua_userstateopen(L1);lua_pushintegral(L,(unsigned long)L1);}else lua_pushnil( -L);return 1;}static int loadlib(lua_State*L){static const luaL_reg libs[]={{ -"mathlibopen",luaopen_math},{"strlibopen",luaopen_string},{"iolibopen", -luaopen_io},{"tablibopen",luaopen_table},{"dblibopen",luaopen_debug},{ -"baselibopen",luaopen_base},{NULL,NULL}};lua_State*L1=cast(lua_State*,cast( -unsigned long,luaL_checknumber(L,1)));lua_pushvalue(L1,LUA_GLOBALSINDEX); -luaL_openlib(L1,NULL,libs,0);return 0;}static int closestate(lua_State*L){ -lua_State*L1=cast(lua_State*,cast(unsigned long,luaL_checknumber(L,1))); -lua_close(L1);lua_unlock(L);return 0;}static int doremote(lua_State*L){ -lua_State*L1=cast(lua_State*,cast(unsigned long,luaL_checknumber(L,1)));size_t - lcode;const char*code=luaL_checklstring(L,2,&lcode);int status;lua_settop(L1, -0);status=luaL_loadbuffer(L1,code,lcode,code);if(status==0)status=lua_pcall(L1 -,0,LUA_MULTRET,0);if(status!=0){lua_pushnil(L);lua_pushintegral(L,status); -lua_pushstring(L,lua_tostring(L1,-1));return 3;}else{int i=0;while(!lua_isnone -(L1,++i))lua_pushstring(L,lua_tostring(L1,i));lua_pop(L1,i-1);return i-1;}} -static int log2_aux(lua_State*L){lua_pushintegral(L,luaO_log2(luaL_checkint(L, -1)));return 1;}static int int2fb_aux(lua_State*L){int b=luaO_int2fb( -luaL_checkint(L,1));lua_pushintegral(L,b);lua_pushintegral(L,fb2int(b));return - 2;}static int test_do(lua_State*L){const char*p=luaL_checkstring(L,1);if(*p== -'@')lua_dofile(L,p+1);else lua_dostring(L,p);return lua_gettop(L);}static -const char*const delimits=" \t\n,;";static void skip(const char**pc){while(** -pc!='\0'&&strchr(delimits,**pc))(*pc)++;}static int getnum_aux(lua_State*L, -const char**pc){int res=0;int sig=1;skip(pc);if(**pc=='.'){res=cast(int, -lua_tonumber(L,-1));lua_pop(L,1);(*pc)++;return res;}else if(**pc=='-'){sig=-1 -;(*pc)++;}while(isdigit(cast(int,**pc)))res=res*10+(*(*pc)++)-'0';return sig* -res;}static const char*getname_aux(char*buff,const char**pc){int i=0;skip(pc); -while(**pc!='\0'&&!strchr(delimits,**pc))buff[i++]=*(*pc)++;buff[i]='\0'; -return buff;} -#define EQ(s1) (strcmp(s1,inst)==0) -#define getnum (getnum_aux(L,&pc)) -#define getname (getname_aux(buff,&pc)) -static int testC(lua_State*L){char buff[30];const char*pc=luaL_checkstring(L,1 -);for(;;){const char*inst=getname;if EQ("")return 0;else if EQ("isnumber"){ -lua_pushintegral(L,lua_isnumber(L,getnum));}else if EQ("isstring"){ -lua_pushintegral(L,lua_isstring(L,getnum));}else if EQ("istable"){ -lua_pushintegral(L,lua_istable(L,getnum));}else if EQ("iscfunction"){ -lua_pushintegral(L,lua_iscfunction(L,getnum));}else if EQ("isfunction"){ -lua_pushintegral(L,lua_isfunction(L,getnum));}else if EQ("isuserdata"){ -lua_pushintegral(L,lua_isuserdata(L,getnum));}else if EQ("isudataval"){ -lua_pushintegral(L,lua_islightuserdata(L,getnum));}else if EQ("isnil"){ -lua_pushintegral(L,lua_isnil(L,getnum));}else if EQ("isnull"){lua_pushintegral -(L,lua_isnone(L,getnum));}else if EQ("tonumber"){lua_pushnumber(L,lua_tonumber -(L,getnum));}else if EQ("tostring"){const char*s=lua_tostring(L,getnum); -lua_pushstring(L,s);}else if EQ("strlen"){lua_pushintegral(L,lua_strlen(L, -getnum));}else if EQ("tocfunction"){lua_pushcfunction(L,lua_tocfunction(L, -getnum));}else if EQ("return"){return getnum;}else if EQ("gettop"){ -lua_pushintegral(L,lua_gettop(L));}else if EQ("settop"){lua_settop(L,getnum);} -else if EQ("pop"){lua_pop(L,getnum);}else if EQ("pushnum"){lua_pushintegral(L, -getnum);}else if EQ("pushnil"){lua_pushnil(L);}else if EQ("pushbool"){ -lua_pushboolean(L,getnum);}else if EQ("tobool"){lua_pushintegral(L, -lua_toboolean(L,getnum));}else if EQ("pushvalue"){lua_pushvalue(L,getnum);} -else if EQ("pushcclosure"){lua_pushcclosure(L,testC,getnum);}else if EQ( -"pushupvalues"){lua_pushupvalues(L);}else if EQ("remove"){lua_remove(L,getnum) -;}else if EQ("insert"){lua_insert(L,getnum);}else if EQ("replace"){lua_replace -(L,getnum);}else if EQ("gettable"){lua_gettable(L,getnum);}else if EQ( -"settable"){lua_settable(L,getnum);}else if EQ("next"){lua_next(L,-2);}else if - EQ("concat"){lua_concat(L,getnum);}else if EQ("lessthan"){int a=getnum; -lua_pushboolean(L,lua_lessthan(L,a,getnum));}else if EQ("equal"){int a=getnum; -lua_pushboolean(L,lua_equal(L,a,getnum));}else if EQ("rawcall"){int narg= -getnum;int nres=getnum;lua_call(L,narg,nres);}else if EQ("call"){int narg= -getnum;int nres=getnum;lua_pcall(L,narg,nres,0);}else if EQ("loadstring"){ -size_t sl;const char*s=luaL_checklstring(L,getnum,&sl);luaL_loadbuffer(L,s,sl, -s);}else if EQ("loadfile"){luaL_loadfile(L,luaL_checkstring(L,getnum));}else -if EQ("setmetatable"){lua_setmetatable(L,getnum);}else if EQ("getmetatable"){ -if(lua_getmetatable(L,getnum)==0)lua_pushnil(L);}else if EQ("type"){ -lua_pushstring(L,lua_typename(L,lua_type(L,getnum)));}else if EQ("getn"){int i -=getnum;lua_pushintegral(L,luaL_getn(L,i));}else if EQ("setn"){int i=getnum; -int n=cast(int,lua_tonumber(L,-1));luaL_setn(L,i,n);lua_pop(L,1);}else -luaL_error(L,"unknown instruction %s",buff);}return 0;}static void yieldf( -lua_State*L,lua_Debug*ar){lua_yield(L,0);}static int setyhook(lua_State*L){if( -lua_isnoneornil(L,1))lua_sethook(L,NULL,0,0);else{const char*smask= -luaL_checkstring(L,1);int count=luaL_optint(L,2,0);int mask=0;if(strchr(smask, -'l'))mask|=LUA_MASKLINE;if(count>0)mask|=LUA_MASKCOUNT;lua_sethook(L,yieldf, -mask,count);}return 0;}static int coresume(lua_State*L){int status;lua_State* -co=lua_tothread(L,1);luaL_argcheck(L,co,1,"coroutine expected");status= -lua_resume(co,0);if(status!=0){lua_pushboolean(L,0);lua_insert(L,-2);return 2; -}else{lua_pushboolean(L,1);return 1;}}static const struct luaL_reg tests_funcs -[]={{"hash",hash_query},{"limits",get_limits},{"listcode",listcode},{"listk", -listk},{"listlocals",listlocals},{"loadlib",loadlib},{"stacklevel",stacklevel} -,{"querystr",string_query},{"querytab",table_query},{"doit",test_do},{"testC", -testC},{"ref",tref},{"getref",getref},{"unref",unref},{"d2s",d2s},{"s2d",s2d}, -{"metatable",metatable},{"upvalue",upvalue},{"newuserdata",newuserdata},{ -"pushuserdata",pushuserdata},{"udataval",udataval},{"doonnewstack", -doonnewstack},{"newstate",newstate},{"closestate",closestate},{"doremote", -doremote},{"log2",log2_aux},{"int2fb",int2fb_aux},{"totalmem",mem_query},{ -"resume",coresume},{"setyhook",setyhook},{NULL,NULL}};static void fim(void){if -(!islocked)lua_close(lua_state);lua_assert(memdebug_numblocks==0);lua_assert( -memdebug_total==0);}static int l_panic(lua_State*L){UNUSED(L);fprintf(stderr, -"unable to recover; exiting\n");return 0;}int luaB_opentests(lua_State*L){ -lua_atpanic(L,l_panic);lua_userstateopen(L);lua_state=L;luaL_openlib(L,"T", -tests_funcs,0);atexit(fim);return 0;} -#undef main -int main(int argc,char*argv[]){char*limit=getenv("MEMLIMIT");if(limit) -memdebug_memlimit=strtoul(limit,NULL,10);l_main(argc,argv);return 0;} -#endif -#line 1 "ltm.c" -#define ltm_c -const char*const luaT_typenames[]={"nil","boolean","userdata","number", -"string","table","function","userdata","thread"};void luaT_init(lua_State*L){ -static const char*const luaT_eventname[]={"__index","__newindex","__gc", -"__mode","__eq","__add","__sub","__mul","__div","__pow","__unm","__lt","__le", -"__concat","__call"};int i;for(i=0;itmname[i]=luaS_new(L, -luaT_eventname[i]);luaS_fix(G(L)->tmname[i]);}}const TObject*luaT_gettm(Table* -events,TMS event,TString*ename){const TObject*tm=luaH_getstr(events,ename); -lua_assert(event<=TM_EQ);if(ttisnil(tm)){events->flags|=cast(lu_byte,1u<tmname[event];switch(ttype(o)){case -LUA_TTABLE:return luaH_getstr(hvalue(o)->metatable,ename);case LUA_TUSERDATA: -return luaH_getstr(uvalue(o)->uv.metatable,ename);default:return& -luaO_nilobject;}} -#line 1 "lua.c" -#define lua_c -#ifdef LUA_USERCONFIG -#include LUA_USERCONFIG -#endif -#ifdef _POSIX_C_SOURCE -#define stdin_is_tty() isatty(0) -#else -#define stdin_is_tty() 1 -#endif -#ifndef PROMPT -#define PROMPT "> " -#endif -#ifndef PROMPT2 -#define PROMPT2 ">> " -#endif -#ifndef PROGNAME -#define PROGNAME "lua" -#endif -#ifndef lua_userinit -#define lua_userinit(L) openstdlibs(L) -#endif -#ifndef LUA_EXTRALIBS -#define LUA_EXTRALIBS -#endif -static lua_State*L=NULL;static const char*progname=PROGNAME;LUALIB_API int -luaopen_posix(lua_State*L);static const luaL_reg lualibs[]={{"base", -luaopen_base},{"table",luaopen_table},{"io",luaopen_io},{"string", -luaopen_string},{"debug",luaopen_debug},{"loadlib",luaopen_loadlib},{"posix", -luaopen_posix},LUA_EXTRALIBS{NULL,NULL}};static void lstop(lua_State*l, -lua_Debug*ar){(void)ar;lua_sethook(l,NULL,0,0);luaL_error(l,"interrupted!");} -static void laction(int i){signal(i,SIG_DFL);lua_sethook(L,lstop,LUA_MASKCALL| -LUA_MASKRET|LUA_MASKCOUNT,1);}static void print_usage(void){fprintf(stderr, -"usage: %s [options] [script [args]].\n""Available options are:\n" -" - execute stdin as a file\n"" -e stat execute string `stat'\n" -" -i enter interactive mode after executing `script'\n" -" -l name load and run library `name'\n" -" -v show version information\n"" -- stop handling options\n", -progname);}static void l_message(const char*pname,const char*msg){if(pname) -fprintf(stderr,"%s: ",pname);fprintf(stderr,"%s\n",msg);}static int report(int - status){const char*msg;if(status){msg=lua_tostring(L,-1);if(msg==NULL)msg= -"(error with no message)";l_message(progname,msg);lua_pop(L,1);}return status; -}static int lcall(int narg,int clear){int status;int base=lua_gettop(L)-narg; -lua_pushliteral(L,"_TRACEBACK");lua_rawget(L,LUA_GLOBALSINDEX);lua_insert(L, -base);signal(SIGINT,laction);status=lua_pcall(L,narg,(clear?0:LUA_MULTRET), -base);signal(SIGINT,SIG_DFL);lua_remove(L,base);return status;}static void -print_version(void){l_message(NULL,LUA_VERSION" "LUA_COPYRIGHT);}static void -getargs(char*argv[],int n){int i;lua_newtable(L);for(i=0;argv[i];i++){ -lua_pushnumber(L,i-n);lua_pushstring(L,argv[i]);lua_rawset(L,-3);} -lua_pushliteral(L,"n");lua_pushnumber(L,i-n-1);lua_rawset(L,-3);}static int -docall(int status){if(status==0)status=lcall(0,1);return report(status);} -static int file_input(const char*name){return docall(luaL_loadfile(L,name));} -static int dostring(const char*s,const char*name){return docall( -luaL_loadbuffer(L,s,strlen(s),name));}static int load_file(const char*name){ -lua_pushliteral(L,"require");lua_rawget(L,LUA_GLOBALSINDEX);if(!lua_isfunction -(L,-1)){lua_pop(L,1);return file_input(name);}else{lua_pushstring(L,name); -return report(lcall(1,1));}} -#ifndef lua_saveline -#define lua_saveline(L,line) -#endif -#ifndef lua_readline -#define lua_readline(L,prompt) readline(L,prompt) -#ifndef MAXINPUT -#define MAXINPUT 512 -#endif -static int readline(lua_State*l,const char*prompt){static char buffer[MAXINPUT -];if(prompt){fputs(prompt,stdout);fflush(stdout);}if(fgets(buffer,sizeof( -buffer),stdin)==NULL)return 0;else{lua_pushstring(l,buffer);return 1;}} -#endif -static const char*get_prompt(int firstline){const char*p=NULL;lua_pushstring(L -,firstline?"_PROMPT":"_PROMPT2");lua_rawget(L,LUA_GLOBALSINDEX);p=lua_tostring -(L,-1);if(p==NULL)p=(firstline?PROMPT:PROMPT2);lua_pop(L,1);return p;}static -int incomplete(int status){if(status==LUA_ERRSYNTAX&&strstr(lua_tostring(L,-1) -,"near `'")!=NULL){lua_pop(L,1);return 1;}else return 0;}static int -load_string(void){int status;lua_settop(L,0);if(lua_readline(L,get_prompt(1)) -==0)return-1;if(lua_tostring(L,-1)[0]=='='){lua_pushfstring(L,"return %s", -lua_tostring(L,-1)+1);lua_remove(L,-2);}for(;;){status=luaL_loadbuffer(L, -lua_tostring(L,1),lua_strlen(L,1),"=stdin");if(!incomplete(status))break;if( -lua_readline(L,get_prompt(0))==0)return-1;lua_concat(L,lua_gettop(L));} -lua_saveline(L,lua_tostring(L,1));lua_remove(L,1);return status;}static void -manual_input(void){int status;const char*oldprogname=progname;progname=NULL; -while((status=load_string())!=-1){if(status==0)status=lcall(0,0);report(status -);if(status==0&&lua_gettop(L)>0){lua_getglobal(L,"print");lua_insert(L,1);if( -lua_pcall(L,lua_gettop(L)-1,0,0)!=0)l_message(progname,lua_pushfstring(L, -"error calling `print' (%s)",lua_tostring(L,-1)));}}lua_settop(L,0);fputs("\n" -,stdout);progname=oldprogname;}static int handle_argv(char*argv[],int* -interactive){if(argv[1]==NULL){if(stdin_is_tty()){print_version();manual_input -();}else file_input(NULL);}else{int i;for(i=1;argv[i]!=NULL;i++){if(argv[i][0] -!='-')break;switch(argv[i][1]){case'-':{if(argv[i][2]!='\0'){print_usage(); -return 1;}i++;goto endloop;}case'\0':{file_input(NULL);break;}case'i':{* -interactive=1;break;}case'v':{print_version();break;}case'e':{const char*chunk -=argv[i]+2;if(*chunk=='\0')chunk=argv[++i];if(chunk==NULL){print_usage(); -return 1;}if(dostring(chunk,"=")!=0)return 1;break;}case'l':{ -const char*filename=argv[i]+2;if(*filename=='\0')filename=argv[++i];if( -filename==NULL){print_usage();return 1;}if(load_file(filename))return 1;break; -}case'c':{l_message(progname,"option `-c' is deprecated");break;}case's':{ -l_message(progname,"option `-s' is deprecated");break;}default:{print_usage(); -return 1;}}}endloop:if(argv[i]!=NULL){const char*filename=argv[i];getargs(argv -,i);lua_setglobal(L,"arg");if(strcmp(filename,"/dev/stdin")==0)filename=NULL; -return file_input(filename);}}return 0;}static void openstdlibs(lua_State*l){ -const luaL_reg*lib=lualibs;for(;lib->func;lib++){lib->func(l);lua_settop(l,0); -}}static int handle_luainit(void){const char*init=getenv("LUA_INIT");if(init== -NULL)return 0;else if(init[0]=='@')return file_input(init+1);else return -dostring(init,"=LUA_INIT");}struct Smain{int argc;char**argv;int status;}; -static int pmain(lua_State*l){struct Smain*s=(struct Smain*)lua_touserdata(l,1 -);int status;int interactive=0;if(s->argv[0]&&s->argv[0][0])progname=s->argv[0 -];L=l;lua_userinit(l);status=handle_luainit();if(status==0){status=handle_argv -(s->argv,&interactive);if(status==0&&interactive)manual_input();}s->status= -status;return 0;}int main(int argc,char*argv[]){int status;struct Smain s; -lua_State*l=lua_open();if(l==NULL){l_message(argv[0], -"cannot create state: not enough memory");return EXIT_FAILURE;}s.argc=argc;s. -argv=argv;status=lua_cpcall(l,&pmain,&s);report(status);lua_close(l);return( -status||s.status)?EXIT_FAILURE:EXIT_SUCCESS;} -#line 1 "lundump.c" -#define lundump_c -#define LoadByte (lu_byte)ezgetc -typedef struct{lua_State*L;ZIO*Z;Mbuffer*b;int swap;const char*name;}LoadState -;static void unexpectedEOZ(LoadState*S){luaG_runerror(S->L, -"unexpected end of file in %s",S->name);}static int ezgetc(LoadState*S){int c= -zgetc(S->Z);if(c==EOZ)unexpectedEOZ(S);return c;}static void ezread(LoadState* -S,void*b,int n){int r=luaZ_read(S->Z,b,n);if(r!=0)unexpectedEOZ(S);}static -void LoadBlock(LoadState*S,void*b,size_t size){if(S->swap){char*p=(char*)b+ -size-1;int n=size;while(n--)*p--=(char)ezgetc(S);}else ezread(S,b,size);} -static void LoadVector(LoadState*S,void*b,int m,size_t size){if(S->swap){char* -q=(char*)b;while(m--){char*p=q+size-1;int n=size;while(n--)*p--=(char)ezgetc(S -);q+=size;}}else ezread(S,b,m*size);}static int LoadInt(LoadState*S){int x; -LoadBlock(S,&x,sizeof(x));if(x<0)luaG_runerror(S->L,"bad integer in %s",S-> -name);return x;}static size_t LoadSize(LoadState*S){size_t x;LoadBlock(S,&x, -sizeof(x));return x;}static lua_Number LoadNumber(LoadState*S){lua_Number x; -LoadBlock(S,&x,sizeof(x));return x;}static TString*LoadString(LoadState*S){ -size_t size=LoadSize(S);if(size==0)return NULL;else{char*s=luaZ_openspace(S->L -,S->b,size);ezread(S,s,size);return luaS_newlstr(S->L,s,size-1);}}static void -LoadCode(LoadState*S,Proto*f){int size=LoadInt(S);f->code=luaM_newvector(S->L, -size,Instruction);f->sizecode=size;LoadVector(S,f->code,size,sizeof(*f->code)) -;}static void LoadLocals(LoadState*S,Proto*f){int i,n;n=LoadInt(S);f->locvars= -luaM_newvector(S->L,n,LocVar);f->sizelocvars=n;for(i=0;ilocvars[i]. -varname=LoadString(S);f->locvars[i].startpc=LoadInt(S);f->locvars[i].endpc= -LoadInt(S);}}static void LoadLines(LoadState*S,Proto*f){int size=LoadInt(S);f -->lineinfo=luaM_newvector(S->L,size,int);f->sizelineinfo=size;LoadVector(S,f-> -lineinfo,size,sizeof(*f->lineinfo));}static void LoadUpvalues(LoadState*S, -Proto*f){int i,n;n=LoadInt(S);if(n!=0&&n!=f->nups)luaG_runerror(S->L, -"bad nupvalues in %s: read %d; expected %d",S->name,n,f->nups);f->upvalues= -luaM_newvector(S->L,n,TString*);f->sizeupvalues=n;for(i=0;iupvalues[ -i]=LoadString(S);}static Proto*LoadFunction(LoadState*S,TString*p);static void - LoadConstants(LoadState*S,Proto*f){int i,n;n=LoadInt(S);f->k=luaM_newvector(S -->L,n,TObject);f->sizek=n;for(i=0;ik[i];int t=LoadByte(S -);switch(t){case LUA_TNUMBER:setnvalue(o,LoadNumber(S));break;case LUA_TSTRING -:setsvalue2n(o,LoadString(S));break;case LUA_TNIL:setnilvalue(o);break;default -:luaG_runerror(S->L,"bad constant type (%d) in %s",t,S->name);break;}}n= -LoadInt(S);f->p=luaM_newvector(S->L,n,Proto*);f->sizep=n;for(i=0;ip[ -i]=LoadFunction(S,f->source);}static Proto*LoadFunction(LoadState*S,TString*p) -{Proto*f=luaF_newproto(S->L);f->source=LoadString(S);if(f->source==NULL)f-> -source=p;f->lineDefined=LoadInt(S);f->nups=LoadByte(S);f->numparams=LoadByte(S -);f->is_vararg=LoadByte(S);f->maxstacksize=LoadByte(S);LoadLines(S,f); -LoadLocals(S,f);LoadUpvalues(S,f);LoadConstants(S,f);LoadCode(S,f); -#ifndef TRUST_BINARIES -if(!luaG_checkcode(f))luaG_runerror(S->L,"bad code in %s",S->name); -#endif -return f;}static void LoadSignature(LoadState*S){const char*s=LUA_SIGNATURE; -while(*s!=0&&ezgetc(S)==*s)++s;if(*s!=0)luaG_runerror(S->L, -"bad signature in %s",S->name);}static void TestSize(LoadState*S,int s,const -char*what){int r=LoadByte(S);if(r!=s)luaG_runerror(S->L, -"virtual machine mismatch in %s: ""size of %s is %d but read %d",S->name,what, -s,r);} -#define TESTSIZE(s,w) TestSize(S,s,w) -#define V(v) v/16,v%16 -static void LoadHeader(LoadState*S){int version;lua_Number x,tx=TEST_NUMBER; -LoadSignature(S);version=LoadByte(S);if(version>VERSION)luaG_runerror(S->L, -"%s too new: ""read version %d.%d; expected at most %d.%d",S->name,V(version), -V(VERSION));if(versionL,"%s too old: " -"read version %d.%d; expected at least %d.%d",S->name,V(version),V(VERSION0)); -S->swap=(luaU_endianness()!=LoadByte(S));TESTSIZE(sizeof(int),"int");TESTSIZE( -sizeof(size_t),"size_t");TESTSIZE(sizeof(Instruction),"Instruction");TESTSIZE( -SIZE_OP,"OP");TESTSIZE(SIZE_A,"A");TESTSIZE(SIZE_B,"B");TESTSIZE(SIZE_C,"C"); -TESTSIZE(sizeof(lua_Number),"number");x=LoadNumber(S);if((long)x!=(long)tx) -luaG_runerror(S->L,"unknown number format in %s",S->name);}static Proto* -LoadChunk(LoadState*S){LoadHeader(S);return LoadFunction(S,NULL);}Proto* -luaU_undump(lua_State*L,ZIO*Z,Mbuffer*buff){LoadState S;const char*s=zname(Z); -if(*s=='@'||*s=='=')S.name=s+1;else if(*s==LUA_SIGNATURE[0])S.name= -"binary string";else S.name=s;S.L=L;S.Z=Z;S.b=buff;return LoadChunk(&S);}int -luaU_endianness(void){int x=1;return*(char*)&x;} -#line 1 "lvm.c" -#define lvm_c -#ifndef lua_number2str -#define lua_number2str(s,n) sprintf((s),LUA_NUMBER_FMT,(n)) -#endif -#define MAXTAGLOOP 100 -const TObject*luaV_tonumber(const TObject*obj,TObject*n){lua_Number num;if( -ttisnumber(obj))return obj;if(ttisstring(obj)&&luaO_str2d(svalue(obj),&num)){ -setnvalue(n,num);return n;}else return NULL;}int luaV_tostring(lua_State*L, -StkId obj){if(!ttisnumber(obj))return 0;else{char s[32];lua_number2str(s, -nvalue(obj));setsvalue2s(obj,luaS_new(L,s));return 1;}}static void traceexec( -lua_State*L){lu_byte mask=L->hookmask;if(mask&LUA_MASKCOUNT){if(L->hookcount== -0){resethookcount(L);luaD_callhook(L,LUA_HOOKCOUNT,-1);return;}}if(mask& -LUA_MASKLINE){CallInfo*ci=L->ci;Proto*p=ci_func(ci)->l.p;int newline=getline(p -,pcRel(*ci->u.l.pc,p));if(!L->hookinit){luaG_inithooks(L);return;}lua_assert( -ci->state&CI_HASFRAME);if(pcRel(*ci->u.l.pc,p)==0)ci->u.l.savedpc=*ci->u.l.pc; -if(*ci->u.l.pc<=ci->u.l.savedpc||newline!=getline(p,pcRel(ci->u.l.savedpc,p))) -{luaD_callhook(L,LUA_HOOKLINE,newline);ci=L->ci;}ci->u.l.savedpc=*ci->u.l.pc;} -}static void callTMres(lua_State*L,const TObject*f,const TObject*p1,const -TObject*p2){setobj2s(L->top,f);setobj2s(L->top+1,p1);setobj2s(L->top+2,p2); -luaD_checkstack(L,3);L->top+=3;luaD_call(L,L->top-3,1);L->top--;}static void -callTM(lua_State*L,const TObject*f,const TObject*p1,const TObject*p2,const -TObject*p3){setobj2s(L->top,f);setobj2s(L->top+1,p1);setobj2s(L->top+2,p2); -setobj2s(L->top+3,p3);luaD_checkstack(L,4);L->top+=4;luaD_call(L,L->top-4,0);} -static const TObject*luaV_index(lua_State*L,const TObject*t,TObject*key,int -loop){const TObject*tm=fasttm(L,hvalue(t)->metatable,TM_INDEX);if(tm==NULL) -return&luaO_nilobject;if(ttisfunction(tm)){callTMres(L,tm,t,key);return L->top -;}else return luaV_gettable(L,tm,key,loop);}static const TObject* -luaV_getnotable(lua_State*L,const TObject*t,TObject*key,int loop){const -TObject*tm=luaT_gettmbyobj(L,t,TM_INDEX);if(ttisnil(tm))luaG_typeerror(L,t, -"index");if(ttisfunction(tm)){callTMres(L,tm,t,key);return L->top;}else return - luaV_gettable(L,tm,key,loop);}const TObject*luaV_gettable(lua_State*L,const -TObject*t,TObject*key,int loop){if(loop>MAXTAGLOOP)luaG_runerror(L, -"loop in gettable");if(ttistable(t)){Table*h=hvalue(t);const TObject*v= -luaH_get(h,key);if(!ttisnil(v))return v;else return luaV_index(L,t,key,loop+1) -;}else return luaV_getnotable(L,t,key,loop+1);}void luaV_settable(lua_State*L, -const TObject*t,TObject*key,StkId val){const TObject*tm;int loop=0;do{if( -ttistable(t)){Table*h=hvalue(t);TObject*oldval=luaH_set(L,h,key);if(!ttisnil( -oldval)||(tm=fasttm(L,h->metatable,TM_NEWINDEX))==NULL){setobj2t(oldval,val); -return;}}else if(ttisnil(tm=luaT_gettmbyobj(L,t,TM_NEWINDEX)))luaG_typeerror(L -,t,"index");if(ttisfunction(tm)){callTM(L,tm,t,key,val);return;}t=tm;}while(++ -loop<=MAXTAGLOOP);luaG_runerror(L,"loop in settable");}static int call_binTM( -lua_State*L,const TObject*p1,const TObject*p2,StkId res,TMS event){ptrdiff_t -result=savestack(L,res);const TObject*tm=luaT_gettmbyobj(L,p1,event);if( -ttisnil(tm))tm=luaT_gettmbyobj(L,p2,event);if(!ttisfunction(tm))return 0; -callTMres(L,tm,p1,p2);res=restorestack(L,result);setobjs2s(res,L->top);return -1;}static const TObject*get_compTM(lua_State*L,Table*mt1,Table*mt2,TMS event){ -const TObject*tm1=fasttm(L,mt1,event);const TObject*tm2;if(tm1==NULL)return -NULL;if(mt1==mt2)return tm1;tm2=fasttm(L,mt2,event);if(tm2==NULL)return NULL; -if(luaO_rawequalObj(tm1,tm2))return tm1;return NULL;}static int call_orderTM( -lua_State*L,const TObject*p1,const TObject*p2,TMS event){const TObject*tm1= -luaT_gettmbyobj(L,p1,event);const TObject*tm2;if(ttisnil(tm1))return-1;tm2= -luaT_gettmbyobj(L,p2,event);if(!luaO_rawequalObj(tm1,tm2))return-1;callTMres(L -,tm1,p1,p2);return!l_isfalse(L->top);}static int luaV_strcmp(const TString*ls, -const TString*rs){const char*l=getstr(ls);size_t ll=ls->tsv.len;const char*r= -getstr(rs);size_t lr=rs->tsv.len;for(;;){int temp=strcoll(l,r);if(temp!=0) -return temp;else{size_t len=strlen(l);if(len==lr)return(len==ll)?0:1;else if( -len==ll)return-1;len++;l+=len;ll-=len;r+=len;lr-=len;}}}int luaV_lessthan( -lua_State*L,const TObject*l,const TObject*r){int res;if(ttype(l)!=ttype(r)) -return luaG_ordererror(L,l,r);else if(ttisnumber(l))return nvalue(l)uv.metatable,uvalue(t2)->uv.metatable,TM_EQ);break;} -case LUA_TTABLE:{if(hvalue(t1)==hvalue(t2))return 1;tm=get_compTM(L,hvalue(t1) -->metatable,hvalue(t2)->metatable,TM_EQ);break;}default:return gcvalue(t1)== -gcvalue(t2);}if(tm==NULL)return 0;callTMres(L,tm,t1,t2);return!l_isfalse(L-> -top);}void luaV_concat(lua_State*L,int total,int last){do{StkId top=L->base+ -last+1;int n=2;if(!tostring(L,top-2)||!tostring(L,top-1)){if(!call_binTM(L,top --2,top-1,top-2,TM_CONCAT))luaG_concaterror(L,top-2,top-1);}else if(tsvalue(top --1)->tsv.len>0){lu_mem tl=cast(lu_mem,tsvalue(top-1)->tsv.len)+cast(lu_mem, -tsvalue(top-2)->tsv.len);char*buffer;int i;while(ntsv.len;n++;}if(tl>MAX_SIZET)luaG_runerror(L, -"string size overflow");buffer=luaZ_openspace(L,&G(L)->buff,tl);tl=0;for(i=n;i ->0;i--){size_t l=tsvalue(top-i)->tsv.len;memcpy(buffer+tl,svalue(top-i),l);tl -+=l;}setsvalue2s(top-n,luaS_newlstr(L,buffer,tl));}total-=n-1;last-=n-1;}while -(total>1);}static void Arith(lua_State*L,StkId ra,const TObject*rb,const -TObject*rc,TMS op){TObject tempb,tempc;const TObject*b,*c;if((b=luaV_tonumber( -rb,&tempb))!=NULL&&(c=luaV_tonumber(rc,&tempc))!=NULL){switch(op){case TM_ADD: -setnvalue(ra,nvalue(b)+nvalue(c));break;case TM_SUB:setnvalue(ra,nvalue(b)- -nvalue(c));break;case TM_MUL:setnvalue(ra,nvalue(b)*nvalue(c));break;case -TM_DIV:setnvalue(ra,nvalue(b)/nvalue(c));break;case TM_POW:{const TObject*f= -luaH_getstr(hvalue(gt(L)),G(L)->tmname[TM_POW]);ptrdiff_t res=savestack(L,ra); -if(!ttisfunction(f))luaG_runerror(L,"`__pow' (`^' operator) is not a function" -);callTMres(L,f,b,c);ra=restorestack(L,res);setobjs2s(ra,L->top);break;} -default:lua_assert(0);break;}}else if(!call_binTM(L,rb,rc,ra,op)) -luaG_aritherror(L,rb,rc);} -#define runtime_check(L, c){if(!(c))return 0;} -#define RA(i) (base+GETARG_A(i)) -#define XRA(i) (L->base+GETARG_A(i)) -#define RB(i) (base+GETARG_B(i)) -#define RKB(i) ((GETARG_B(i)hookmask&LUA_MASKCALL){L->ci->u.l.pc=&pc;luaD_callhook(L, -LUA_HOOKCALL,-1);}retentry:L->ci->u.l.pc=&pc;lua_assert(L->ci->state== -CI_SAVEDPC||L->ci->state==(CI_SAVEDPC|CI_CALLING));L->ci->state=CI_HASFRAME;pc -=L->ci->u.l.savedpc;cl=&clvalue(L->base-1)->l;k=cl->p->k;for(;;){const -Instruction i=*pc++;StkId base,ra;if((L->hookmask&(LUA_MASKLINE|LUA_MASKCOUNT) -)&&(--L->hookcount==0||L->hookmask&LUA_MASKLINE)){traceexec(L);if(L->ci->state -&CI_YIELD){L->ci->u.l.savedpc=pc-1;L->ci->state=CI_YIELD|CI_SAVEDPC;return -NULL;}}base=L->base;ra=RA(i);lua_assert(L->ci->state&CI_HASFRAME);lua_assert( -base==L->ci->base);lua_assert(L->top<=L->stack+L->stacksize&&L->top>=base); -lua_assert(L->top==L->ci->top||GET_OPCODE(i)==OP_CALL||GET_OPCODE(i)== -OP_TAILCALL||GET_OPCODE(i)==OP_RETURN||GET_OPCODE(i)==OP_SETLISTO);switch( -GET_OPCODE(i)){case OP_MOVE:{setobjs2s(ra,RB(i));break;}case OP_LOADK:{ -setobj2s(ra,KBx(i));break;}case OP_LOADBOOL:{setbvalue(ra,GETARG_B(i));if( -GETARG_C(i))pc++;break;}case OP_LOADNIL:{TObject*rb=RB(i);do{setnilvalue(rb--) -;}while(rb>=ra);break;}case OP_GETUPVAL:{int b=GETARG_B(i);setobj2s(ra,cl-> -upvals[b]->v);break;}case OP_GETGLOBAL:{TObject*rb=KBx(i);const TObject*v; -lua_assert(ttisstring(rb)&&ttistable(&cl->g));v=luaH_getstr(hvalue(&cl->g), -tsvalue(rb));if(!ttisnil(v)){setobj2s(ra,v);}else setobj2s(XRA(i),luaV_index(L -,&cl->g,rb,0));break;}case OP_GETTABLE:{StkId rb=RB(i);TObject*rc=RKC(i);if( -ttistable(rb)){const TObject*v=luaH_get(hvalue(rb),rc);if(!ttisnil(v)){ -setobj2s(ra,v);}else setobj2s(XRA(i),luaV_index(L,rb,rc,0));}else setobj2s(XRA -(i),luaV_getnotable(L,rb,rc,0));break;}case OP_SETGLOBAL:{lua_assert( -ttisstring(KBx(i))&&ttistable(&cl->g));luaV_settable(L,&cl->g,KBx(i),ra);break -;}case OP_SETUPVAL:{int b=GETARG_B(i);setobj(cl->upvals[b]->v,ra);break;}case -OP_SETTABLE:{luaV_settable(L,ra,RKB(i),RKC(i));break;}case OP_NEWTABLE:{int b= -GETARG_B(i);b=fb2int(b);sethvalue(ra,luaH_new(L,b,GETARG_C(i)));luaC_checkGC(L -);break;}case OP_SELF:{StkId rb=RB(i);TObject*rc=RKC(i);runtime_check(L, -ttisstring(rc));setobjs2s(ra+1,rb);if(ttistable(rb)){const TObject*v= -luaH_getstr(hvalue(rb),tsvalue(rc));if(!ttisnil(v)){setobj2s(ra,v);}else -setobj2s(XRA(i),luaV_index(L,rb,rc,0));}else setobj2s(XRA(i),luaV_getnotable(L -,rb,rc,0));break;}case OP_ADD:{TObject*rb=RKB(i);TObject*rc=RKC(i);if( -ttisnumber(rb)&&ttisnumber(rc)){setnvalue(ra,nvalue(rb)+nvalue(rc));}else -Arith(L,ra,rb,rc,TM_ADD);break;}case OP_SUB:{TObject*rb=RKB(i);TObject*rc=RKC( -i);if(ttisnumber(rb)&&ttisnumber(rc)){setnvalue(ra,nvalue(rb)-nvalue(rc));} -else Arith(L,ra,rb,rc,TM_SUB);break;}case OP_MUL:{TObject*rb=RKB(i);TObject*rc -=RKC(i);if(ttisnumber(rb)&&ttisnumber(rc)){setnvalue(ra,nvalue(rb)*nvalue(rc)) -;}else Arith(L,ra,rb,rc,TM_MUL);break;}case OP_DIV:{TObject*rb=RKB(i);TObject* -rc=RKC(i);if(ttisnumber(rb)&&ttisnumber(rc)){setnvalue(ra,nvalue(rb)/nvalue(rc -));}else Arith(L,ra,rb,rc,TM_DIV);break;}case OP_POW:{Arith(L,ra,RKB(i),RKC(i) -,TM_POW);break;}case OP_UNM:{const TObject*rb=RB(i);TObject temp;if(tonumber( -rb,&temp)){setnvalue(ra,-nvalue(rb));}else{setnilvalue(&temp);if(!call_binTM(L -,RB(i),&temp,ra,TM_UNM))luaG_aritherror(L,RB(i),&temp);}break;}case OP_NOT:{ -int res=l_isfalse(RB(i));setbvalue(ra,res);break;}case OP_CONCAT:{int b= -GETARG_B(i);int c=GETARG_C(i);luaV_concat(L,c-b+1,c);base=L->base;setobjs2s(RA -(i),base+b);luaC_checkGC(L);break;}case OP_JMP:{dojump(pc,GETARG_sBx(i));break -;}case OP_EQ:{if(equalobj(L,RKB(i),RKC(i))!=GETARG_A(i))pc++;else dojump(pc, -GETARG_sBx(*pc)+1);break;}case OP_LT:{if(luaV_lessthan(L,RKB(i),RKC(i))!= -GETARG_A(i))pc++;else dojump(pc,GETARG_sBx(*pc)+1);break;}case OP_LE:{if( -luaV_lessequal(L,RKB(i),RKC(i))!=GETARG_A(i))pc++;else dojump(pc,GETARG_sBx(* -pc)+1);break;}case OP_TEST:{TObject*rb=RB(i);if(l_isfalse(rb)==GETARG_C(i))pc -++;else{setobjs2s(ra,rb);dojump(pc,GETARG_sBx(*pc)+1);}break;}case OP_CALL: -case OP_TAILCALL:{StkId firstResult;int b=GETARG_B(i);int nresults;if(b!=0)L-> -top=ra+b;nresults=GETARG_C(i)-1;firstResult=luaD_precall(L,ra);if(firstResult) -{if(firstResult>L->top){lua_assert(L->ci->state==(CI_C|CI_YIELD));(L->ci-1)->u -.l.savedpc=pc;(L->ci-1)->state=CI_SAVEDPC;return NULL;}luaD_poscall(L,nresults -,firstResult);if(nresults>=0)L->top=L->ci->top;}else{if(GET_OPCODE(i)==OP_CALL -){(L->ci-1)->u.l.savedpc=pc;(L->ci-1)->state=(CI_SAVEDPC|CI_CALLING);}else{int - aux;base=(L->ci-1)->base;ra=RA(i);if(L->openupval)luaF_close(L,base);for(aux= -0;ra+auxtop;aux++)setobjs2s(base+aux-1,ra+aux);(L->ci-1)->top=L->top=base+ -aux;lua_assert(L->ci->state&CI_SAVEDPC);(L->ci-1)->u.l.savedpc=L->ci->u.l. -savedpc;(L->ci-1)->u.l.tailcalls++;(L->ci-1)->state=CI_SAVEDPC;L->ci--;L->base -=L->ci->base;}goto callentry;}break;}case OP_RETURN:{CallInfo*ci=L->ci-1;int b -=GETARG_B(i);if(b!=0)L->top=ra+b-1;lua_assert(L->ci->state&CI_HASFRAME);if(L-> -openupval)luaF_close(L,base);L->ci->state=CI_SAVEDPC;L->ci->u.l.savedpc=pc;if( -!(ci->state&CI_CALLING)){lua_assert((ci->state&CI_C)||ci->u.l.pc!=&pc);return -ra;}else{int nresults;lua_assert(ttisfunction(ci->base-1)&&(ci->state& -CI_SAVEDPC));lua_assert(GET_OPCODE(*(ci->u.l.savedpc-1))==OP_CALL);nresults= -GETARG_C(*(ci->u.l.savedpc-1))-1;luaD_poscall(L,nresults,ra);if(nresults>=0)L -->top=L->ci->top;goto retentry;}}case OP_FORLOOP:{lua_Number step,idx,limit; -const TObject*plimit=ra+1;const TObject*pstep=ra+2;if(!ttisnumber(ra)) -luaG_runerror(L,"`for' initial value must be a number");if(!tonumber(plimit,ra -+1))luaG_runerror(L,"`for' limit must be a number");if(!tonumber(pstep,ra+2)) -luaG_runerror(L,"`for' step must be a number");step=nvalue(pstep);idx=nvalue( -ra)+step;limit=nvalue(plimit);if(step>0?idx<=limit:idx>=limit){dojump(pc, -GETARG_sBx(i));chgnvalue(ra,idx);}break;}case OP_TFORLOOP:{int nvar=GETARG_C(i -)+1;StkId cb=ra+nvar+2;setobjs2s(cb,ra);setobjs2s(cb+1,ra+1);setobjs2s(cb+2,ra -+2);L->top=cb+3;luaD_call(L,cb,nvar);L->top=L->ci->top;ra=XRA(i)+2;cb=ra+nvar; -do{nvar--;setobjs2s(ra+nvar,cb+nvar);}while(nvar>0);if(ttisnil(ra))pc++;else -dojump(pc,GETARG_sBx(*pc)+1);break;}case OP_TFORPREP:{if(ttistable(ra)){ -setobjs2s(ra+1,ra);setobj2s(ra,luaH_getstr(hvalue(gt(L)),luaS_new(L,"next"))); -}dojump(pc,GETARG_sBx(i));break;}case OP_SETLIST:case OP_SETLISTO:{int bc;int -n;Table*h;runtime_check(L,ttistable(ra));h=hvalue(ra);bc=GETARG_Bx(i);if( -GET_OPCODE(i)==OP_SETLIST)n=(bc&(LFIELDS_PER_FLUSH-1))+1;else{n=L->top-ra-1;L -->top=L->ci->top;}bc&=~(LFIELDS_PER_FLUSH-1);for(;n>0;n--)setobj2t(luaH_setnum -(L,h,bc+n),ra+n);break;}case OP_CLOSE:{luaF_close(L,ra);break;}case OP_CLOSURE -:{Proto*p;Closure*ncl;int nup,j;p=cl->p->p[GETARG_Bx(i)];nup=p->nups;ncl= -luaF_newLclosure(L,nup,&cl->g);ncl->l.p=p;for(j=0;jl.upvals[j]=cl->upvals[GETARG_B(*pc)];else{ -lua_assert(GET_OPCODE(*pc)==OP_MOVE);ncl->l.upvals[j]=luaF_findupval(L,base+ -GETARG_B(*pc));}}setclvalue(ra,ncl);luaC_checkGC(L);break;}}}} -#line 1 "lzio.c" -#define lzio_c -int luaZ_fill(ZIO*z){size_t size;const char*buff=z->reader(NULL,z->data,&size) -;if(buff==NULL||size==0)return EOZ;z->n=size-1;z->p=buff;return char2int(*(z-> -p++));}int luaZ_lookahead(ZIO*z){if(z->n==0){int c=luaZ_fill(z);if(c==EOZ) -return c;z->n++;z->p--;}return char2int(*z->p);}void luaZ_init(ZIO*z, -lua_Chunkreader reader,void*data,const char*name){z->reader=reader;z->data= -data;z->name=name;z->n=0;z->p=NULL;}size_t luaZ_read(ZIO*z,void*b,size_t n){ -while(n){size_t m;if(z->n==0){if(luaZ_fill(z)==EOZ)return n;else{++z->n;--z->p -;}}m=(n<=z->n)?n:z->n;memcpy(b,z->p,m);z->n-=m;z->p+=m;b=(char*)b+m;n-=m;} -return 0;}char*luaZ_openspace(lua_State*L,Mbuffer*buff,size_t n){if(n>buff-> -buffsize){if(nbuffer -,buff->buffsize,n,char);buff->buffsize=n;}return buff->buffer;} - diff --git a/pmfile b/pmfile deleted file mode 100644 index 14b518a53..000000000 --- a/pmfile +++ /dev/null @@ -1,239 +0,0 @@ --- $Id$ --- $Source$ --- $State$ - -include "first/c.pm" -include "first/yacc.pm" -include "first/llgen.pm" -include "config.pm" -include "first/ack.pm" -include "first/ack-custom.pm" - -CINCLUDES = { - ROOTDIR.."h", - ROOTDIR.."modules/h", - HEADERDIR, -} - --- Load the pmfiles for the various modules. - -include "util/data/pmfile" - -include "util/LLgen/pmfile-ack" - -include "modules/src/alloc/pmfile" -include "modules/src/assert/pmfile" -include "modules/src/system/pmfile" -include "modules/src/string/pmfile" -include "modules/src/read_em/pmfile" -include "modules/src/em_code/pmfile" -include "modules/src/em_mes/pmfile" -include "modules/src/print/pmfile" -include "modules/src/object/pmfile" -include "modules/src/idf/pmfile" -include "modules/src/input/pmfile" -include "modules/src/flt_arith/pmfile" - -include "util/amisc/pmfile" -include "util/cmisc/pmfile" -include "util/ack/pmfile" -include "util/arch/pmfile" --- include "util/cpp/pmfile" -include "lang/cem/cpp.ansi/pmfile" -include "util/cgg/pmfile" -include "util/ncgg/pmfile" --- include "util/ceg/pmfile" -include "util/misc/pmfile" -include "util/opt/pmfile" -include "util/ego/pmfile" -include "util/topgen/pmfile" -include "util/led/pmfile" - -include "lang/cem/pmfile" -include "lang/pc/pmfile" -include "lang/m2/pmfile" --- include "lang/occam/pmfile" --- include "lang/basic/pmfile" - -include "mach/proto/pmfile" - ---[[ -include "mach/i386/pmfile" -include "mach/6500/pmfile" -include "mach/6800/pmfile" -include "mach/6805/pmfile" -include "mach/6809/pmfile" -include "mach/arm/pmfile" -include "mach/i80/pmfile" -include "mach/m68020/pmfile" -include "mach/m68k2/pmfile" -include "mach/m68k4/pmfile" -include "mach/ns/pmfile" -include "mach/pdp/pmfile" -include "mach/s2650/pmfile" -include "mach/vax4/pmfile" -include "mach/z80/pmfile" -include "mach/z8000/pmfile" ---]] - --- This is the list of language runtimes that is built for each architecture. - -lang_runtimes = group { --- lang_cem_runtime, -- K&R C (obsolete and useless) - lang_cem_ansi_runtime, -- ANSI C - lang_pc_runtime, -- Pascal - lang_m2_runtime, -- Modula-2 --- lang_occam_runtime, -- Occam 1 (obsolete and useless) --- lang_basic_runtime, -- Basic -} - --- Include the platform descriptions. - -include "mach/i86/pmfile" -- generic i86 -include "plat/pc86/pmfile" -- PC standalone - -include "mach/i386/pmfile" -- generic i386 -include "plat/linux386/pmfile" -- Linux executables - -include "mach/powerpc/pmfile" -- generic PowerPC -include "plat/linuxppc/pmfile" -- Linux executables - -include "mach/m68020/pmfile" -- generic M68k -include "plat/linux68k/pmfile" -- Linux executables - -include "mach/i80/pmfile" -- generic 8080 -include "plat/cpm/pmfile" -- CP/M - -default = group { - -- Lots of things use LLgen, so we need to build it first. - - tool_LLgen, - - -- Some of the dependency management across modules isn't entirely - -- complete, for simplicity; as a result, the order here is important. - -- In particular, referencing a library does not cause the library to - -- be built, hence the reason why the modules must be built first. Also, - -- some of these generate header files... - - module_em_data, - module_system, - module_alloc, - module_assert, - module_string, - module_em_code, - module_read_em, - module_em_mes, - module_print, - module_object, - module_idf, - module_print, - module_input, - module_flt_arith, - - tool_tabgen, - tool_aal, - tool_ack, --- tool_cpp, -- K&R C - tool_cpp_ansi, -- ANSI C - tool_cgg, - tool_ncgg, --- tool_ceg, - tool_em_decode, - tool_em_encode, - tool_esize, - tool_opt, - tool_ego, - tool_topgen, - tool_led, - tool_anm, - tool_ashow, - tool_asize, - tool_astrip, - tool_aslod, - tool_aelflod, - --- lang_cem_compiler, - lang_cem_ansi_compiler, - lang_pc_compiler, - lang_m2_compiler, --- lang_occam_compiler, --- lang_basic_compiler, - - -- Build the code generators and the architecture-independent - -- libraries. - ---[[ - mach_6500, - lang_runtimes { ARCH="6500", OPTIMISATION="-O" }, - - mach_6800, - mach_6805, - mach_6809, - mach_arm, lang_runtimes { ARCH="arm", OPTIMISATION="-O" }, - - mach_m68020, lang_runtimes { ARCH="m68020", OPTIMISATION="-O" }, --- mach_m68k2, lang_runtimes { ARCH="m68k2", OPTIMISATION="-O" }, --- mach_m68k4, lang_runtimes { ARCH="m68k4", OPTIMISATION="-O" }, - mach_ns, lang_runtimes { ARCH="ns", OPTIMISATION="-O" }, --- mach_pdp, lang_runtimes { ARCH="pdp", OPTIMISATION="-O" }, - mach_s2650, --- mach_vax4, lang_runtimes { ARCH="vax4", OPTIMISATION="-O" }, - mach_z80, lang_runtimes { ARCH="z80", OPTIMISATION="-O" }, - mach_z8000, lang_runtimes { ARCH="z8000", OPTIMISATION="-O" }, ---]] - - -- Build the platforms. - - platform_pc86, - platform_linux386, - platform_linuxppc, - platform_linux68k, - platform_cpm, -} - --- Ensure that the work directories exist. - -posix.mkdir(TEMPDIR) -posix.mkdir(HEADERDIR) - --- When doing the build, we want to ensure that the ACK looks in the staging --- area for its files, and not in the final installation directory (because --- we haven't been installed yet). - -posix.putenv("ACKDIR="..BINDIR) - --- Build the configuration headers, rather crudely. FIXME. - -configure = simple { - outputs = {HEADERDIR.."local.h", HEADERDIR.."em_path.h"}, - command = "", - __dobuild = function(self, inputs, outputs) - -- Build 'local.h', rather crudely - - local f = io.open(HEADERDIR.."local.h", "w") - f:write("#define VERSION 3\n") -- EM byte-code version - f:write("#define ACKM \"", DEFAULT_PLATFORM, "\"\n") - f:write("#define BIGMACHINE 1\n") -- No, we don't have a 16-bit architecture - f:write("#define SYS_5\n") - f:close() - - -- Build 'em_path.h', rather crudely - - local f = io.open(HEADERDIR.."em_path.h", "w") - f:write("#define TMP_DIR \"", ACK_TEMP_DIR, "\"\n") - f:write("#define EM_DIR \"", PREFIX, "\"\n") - f:write("#define ACK_PATH \"", PLATIND, "/descr\"\n") - f:close() - end -} - --- Once built, do the installation, rather crudely. FIXME. - -install = simple { - outputs = {"dummy"}, - command = "", - __dobuild = function(self, inputs, outputs) - os.execute("mkdir -p "..PREFIX) - os.execute("(cd "..BINDIR.." && tar chf - .) | (cd "..PREFIX.." && tar xvf -)") - end -} diff --git a/util/.distr b/util/.distr deleted file mode 100644 index c5957f803..000000000 --- a/util/.distr +++ /dev/null @@ -1,20 +0,0 @@ -ack -amisc -arch -ass -cgg -cmisc -cpp -data -ego -led -misc -ncgg -opt -shf -topgen -int -ceg -byacc -flex -grind diff --git a/util/LLgen/.distr b/util/LLgen/.distr deleted file mode 100644 index c8dcea78f..000000000 --- a/util/LLgen/.distr +++ /dev/null @@ -1,26 +0,0 @@ -pmfile-ack -src/main.c -src/gencode.c -src/compute.c -src/check.c -src/reach.c -src/global.c -src/name.c -src/sets.c -src/sets.h -src/alloc.c -src/machdep.c -src/cclass.c -src/cclass.h -src/savegram.c -src/LLgen.c -src/Lpars.c -src/Lpars.h -src/tokens.c -src/types.h -src/io.h -src/extern.h -lib/incl -lib/rec -lib/nc_incl -lib/nc_rec diff --git a/util/LLgen/build.lua b/util/LLgen/build.lua new file mode 100644 index 000000000..44abc871c --- /dev/null +++ b/util/LLgen/build.lua @@ -0,0 +1,43 @@ +cprogram { + name = "llgen", + + -- These use pre-LLgen'd versions of LLgen.c, Lpars.c and tokens.c. If + -- LLgen.g gets updated, they need rebuilding. Use the bootstrap script to + -- do this. + + srcs = { "./src/*.c" }, + vars = { + ["+cflags"] = { + "-DLIBDIR=\\\""..posix.getcwd().."/"..cwd().."/lib\\\"", + "-DNON_CORRECTING" + }, + } +} + +definerule("llgen", + { + srcs = { type="targets" }, + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + local fs = replace(basename(filenamesof(e.srcs)), "%.g$", "") + + return normalrule { + name = e.name, + cwd = e.cwd, + outleaves = { + "Lpars.c", + "Lpars.h", + replace(fs, "$", ".c") + }, + ins = { + "util/LLgen+llgen", + e.srcs, + }, + commands = { + "cd %{dir} && %{abspath(ins)}" + } + } + end +) diff --git a/util/LLgen/pmfile b/util/LLgen/pmfile deleted file mode 100644 index 7b1548845..000000000 --- a/util/LLgen/pmfile +++ /dev/null @@ -1,127 +0,0 @@ --- $Source$ --- $State$ --- --- $Id$ --- --- This is the build file used to compile LLgen. It should be run through --- Prime Mover (copy supplied). See the READ_ME file for more information. - -include "c.pm" - --- Where is LLgen going to be installed eventually? (Needs trailing slash.) - -PREFIX = PREFIX or "/usr/local/" - --- Where's LLgen's staging area? (Don't change. Needs trailing slash.) - -INSTALLPATH = "bin/" - -LLgen = cprogram { - CEXTRAFLAGS = '-DLIBDIR=\\"'..PREFIX..'share/LLgen\\" -DNON_CORRECTING', - - -- This line is needed to work around an OSX bug --- Apple's hacked gcc's - -- preprocessor doesn't find LLgen.c's include files properly. Don't know - -- why. - - CINCLUDES = {PARENT, "-Isrc"}, - - cfile "src/main.c", - cfile "src/gencode.c", - cfile "src/compute.c", - cfile "src/check.c", - cfile "src/reach.c", - cfile "src/global.c", - cfile "src/name.c", - cfile "src/sets.c", - cfile "src/alloc.c", - cfile "src/machdep.c", - cfile "src/cclass.c", - cfile "src/savegram.c", - - -- These use pre-LLgen'd version of the files. If LLgen.g gets updated, - -- they need rebuilding. Use the bootstrap script to do this. - - cfile "src/LLgen.c", - cfile "src/Lpars.c", - cfile "src/tokens.c", - - outputs = {"%U%/LLgen"}, - install = pm.install( INSTALLPATH.."bin/LLgen") -} - -library = group { - install = { - pm.install("lib/rec", INSTALLPATH.."share/LLgen/rec"), - pm.install("lib/incl", INSTALLPATH.."share/LLgen/incl"), - pm.install("lib/nc_incl", INSTALLPATH.."share/LLgen/nc_incl"), - pm.install("lib/nc_rec", INSTALLPATH.."share/LLgen/nc_rec"), - } -} - -manpage = group { - install = { - pm.install("doc/LLgen.1", INSTALLPATH.."man/man1/LLgen.1"), - } -} - -documentation = group { - simple { - outputs = {"%U%-%I%.ps.gz"}, - command = "refer -sA+T -p %in[1]% %in[2]% | groff -Tps -e -t -ms ".. - "| gzip -c9 > %out[1]%", - - file "doc/LLgen.refs", - file "doc/LLgen.n", - - install = { - pm.install(INSTALLPATH.."share/doc/LLgen/LLgen.ps.gz") - } - }, - - simple { - outputs = {"%U%-%I%.ps.gz"}, - command = "groff -Tps -e -t -p -ms %in% | gzip -c9 > %out[1]%", - - file "doc/LLgen_NCER.n", - - install = { - pm.install(INSTALLPATH.."share/doc/LLgen/NCER.ps.gz") - } - }, -} - --- Default rule: builds everything into the staging area, but does nothing --- else. - -default = group { - LLgen, -- build LLgen itself - library, -- copy over the library - manpage, -- copy over the man page - documentation, -- build the two white papers -} - --- This rule will build everything, and then install it to its final location. - -install = group { - default, - - install = { - "mkdir -p %PREFIX%", - "(cd bin && tar chvf - $(find . ! -type d)) | (cd %PREFIX% && tar xUf -)" - } -} - --- Revision history --- $Log$ --- Revision 1.5 2006-07-25 23:29:12 dtrg --- Modified to not try to unlink directories when installing. --- --- Revision 1.4 2006/07/25 23:22:58 dtrg --- Updated to the latest version of pm which installs files with symlinks. --- --- Revision 1.3 2006/07/23 20:33:26 dtrg --- Added a workaround for an OSX compiler bug. --- --- Revision 1.2 2006/07/21 11:15:14 dtrg --- Updated to the latest version of pm. --- diff --git a/util/LLgen/src/compute.c b/util/LLgen/src/compute.c index ef6b28499..c17d99d73 100644 --- a/util/LLgen/src/compute.c +++ b/util/LLgen/src/compute.c @@ -17,6 +17,7 @@ * Also checks the continuation grammar from the specified grammar. */ +# include # include "types.h" # include "extern.h" # include "sets.h" diff --git a/util/LLgen/src/gencode.c b/util/LLgen/src/gencode.c index 20d0d6cb2..94dd312ca 100644 --- a/util/LLgen/src/gencode.c +++ b/util/LLgen/src/gencode.c @@ -18,6 +18,7 @@ * This file is a mess, it should be cleaned up some time. */ +#include # include "types.h" # include "io.h" # include "extern.h" diff --git a/util/LLgen/src/savegram.c b/util/LLgen/src/savegram.c index d1b6a57ec..625dc1bab 100644 --- a/util/LLgen/src/savegram.c +++ b/util/LLgen/src/savegram.c @@ -25,6 +25,7 @@ */ +#include # include "types.h" # include "extern.h" # include "io.h" diff --git a/util/ack/.distr b/util/ack/.distr deleted file mode 100644 index 47ebd56d7..000000000 --- a/util/ack/.distr +++ /dev/null @@ -1,20 +0,0 @@ -pmfile -ack.h -data.c -data.h -dmach.h -files.c -grows.c -grows.h -list.c -list.h -main.c -mktables.c -rmach.c -run.c -scan.c -svars.c -trans.c -trans.h -util.c -ack.1.X diff --git a/util/ack/build.lua b/util/ack/build.lua new file mode 100644 index 000000000..4394484b4 --- /dev/null +++ b/util/ack/build.lua @@ -0,0 +1,38 @@ +cprogram { + name = "mktables", + srcs = { "./mktables.c" }, +} + +normalrule { + name = "tables", + outleaves = { "dmach.c", "intable.c" }, + ins = { + "+mktables", + "lib/descr/fe", + }, + commands = { + "(cd %{dir} && %{abspath(ins[1])} lib)" + } +} + +cprogram { + name = "ack", + srcs = { + "./*.c", + "+tables", + }, + deps = { + "h+emheaders", + "h+local", + } +} + +installable { + name = "pkg", + map = { + ["$(INSDIR)/bin/ack"] = "+ack", + ["$(INSDIR)/share/man/man1/ack.1"] = "./ack.1.X", + ["$(PLATIND)/descr/fe"] = "lib/descr/fe", + } +} + diff --git a/util/ack/files.c b/util/ack/files.c index 0218c80f9..b47376b24 100644 --- a/util/ack/files.c +++ b/util/ack/files.c @@ -4,6 +4,7 @@ * */ +#include #include "ack.h" #include "list.h" #include "trans.h" diff --git a/util/ack/grows.c b/util/ack/grows.c index 4fbc054d9..ca089d48c 100644 --- a/util/ack/grows.c +++ b/util/ack/grows.c @@ -10,6 +10,7 @@ /* */ /**************************************************************************/ +#include #include "ack.h" #include "grows.h" diff --git a/util/ack/list.c b/util/ack/list.c index 7bc62a841..278f55580 100644 --- a/util/ack/list.c +++ b/util/ack/list.c @@ -4,6 +4,7 @@ * */ +#include #include "ack.h" #include "list.h" diff --git a/util/ack/pmfile b/util/ack/pmfile deleted file mode 100644 index 4d4b78c8c..000000000 --- a/util/ack/pmfile +++ /dev/null @@ -1,61 +0,0 @@ --- $Source$ --- $State$ - -local d = "%ROOTDIR%util/ack/" - -local mktable = cprogram { - cfile (d.."mktables.c") -} - -local makeheaders = simple { - outputs= {"%U%/dmach.c", "%U%/intable.c"}, - command = { - "cd %out[1]:dirname% && %in[1]% %BINDIR%lib" - }, - - mktable -} - -tool_ack = cprogram { - cfile (d.."list.c"), - cfile (d.."data.c"), - cfile (d.."main.c"), - cfile (d.."scan.c"), - cfile (d.."svars.c"), - cfile (d.."trans.c"), - cfile (d.."util.c"), - cfile (d.."rmach.c"), - cfile (d.."run.c"), - cfile (d.."grows.c"), - cfile (d.."files.c"), - - cfile { - CINCLUDES = {PARENT, d}, - ith { makeheaders, i = 1 } - }, - cfile { - CINCLUDES = {PARENT, d}, - ith { makeheaders, i = 2 } - }, - - lib_string, - - outputs = {"%U%/ack"}, - install = { - pm.install("%BINDIR%bin/ack"), - pm.install("%ROOTDIR%/lib/descr/fe", "%BINDIR%%PLATIND%/descr/fe"), - pm.install(d.."ack.1.X", "%BINDIR%man/man1/ack.1") - } -} - --- Revision history --- $Log$ --- Revision 1.3 2007-02-25 12:48:06 dtrg --- Now installs the man page. --- --- Revision 1.2 2006/10/15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/util/ack/proto.make b/util/ack/proto.make deleted file mode 100644 index 1c4356059..000000000 --- a/util/ack/proto.make +++ /dev/null @@ -1,187 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ack - -HFILES=\ - $(SRC_DIR)/ack.h \ - $(SRC_DIR)/list.h \ - $(SRC_DIR)/trans.h \ - $(SRC_DIR)/data.h \ - $(SRC_DIR)/dmach.h \ - $(SRC_DIR)/grows.h - -DSRC=\ - $(SRC_DIR)/list.c \ - $(SRC_DIR)/data.c \ - $(SRC_DIR)/main.c \ - $(SRC_DIR)/scan.c \ - $(SRC_DIR)/svars.c \ - $(SRC_DIR)/trans.c \ - $(SRC_DIR)/util.c \ - $(SRC_DIR)/rmach.c \ - $(SRC_DIR)/run.c \ - $(SRC_DIR)/grows.c \ - $(SRC_DIR)/files.c - -ISRC=\ - dmach.c \ - intable.c - -CFILES = $(DSRC) $(ISRC) - -OBJ=\ - list.$(SUF) \ - data.$(SUF) \ - main.$(SUF) \ - scan.$(SUF) \ - svars.$(SUF) \ - trans.$(SUF) \ - util.$(SUF) \ - rmach.$(SUF) \ - run.$(SUF) \ - dmach.$(SUF) \ - intable.$(SUF) \ - grows.$(SUF) \ - files.$(SUF) - -ACKDIR=$(TARGET_HOME)/lib -FE=fe -INTABLES=sun3 -LNTABLES=acc apc abc ocm m2 f2c vax4 i86 i386 m68k2 m68k4 pmds pmds4 mantra \ - m68020 z8000 pdp em22 em24 em44 6500 6800 6805 6809 i80 ns s2650 z80 \ - sun2 xenix3 minix minixST sparc sparc_solaris arm -INCLUDES=-I$(TARGET_HOME)/h -I$(TARGET_HOME)/config -I$(SRC_DIR) -CFLAGS= $(INCLUDES) $(COPTIONS) -UCFLAGS= $(INCLUDES) $(UCOPTIONS) -LINTFLAGS= $(INCLUDES) $(LINTOPTIONS) -LDFLAGS= $(LDOPTIONS) -ULDFLAGS= $(ULDOPTIONS) -BINDIR=$(TARGET_HOME)/bin -HDIR=$(TARGET_HOME)/h -MODDIR=$(TARGET_HOME)/modules/lib - -all: ack ack.1 - -install: ack ack.1 - cp ack $(BINDIR)/ack - -cd $(BINDIR) ; \ - for i in $(INTABLES) $(LNTABLES) ; do rm -f $$i ; ln ack $$i ; done - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage ack.1 $(TARGET_HOME) ; \ - fi - -cmp: ack - -cmp ack $(BINDIR)/ack - -ack.1: $(SRC_DIR)/ack.1.X - -sh -c 'tbl < $(SRC_DIR)/ack.1.X > ack.1' - -sh -c 'if test -s ack.1 ; then : ; else cp $(SRC_DIR)/ack.1.X ack.1 ; fi' - -clean: - -rm -f *.old *.$(SUF) mktables *.$(USUF) ack ack.1 $(ISRC) - -ack: $(OBJ) - $(CC) $(LDFLAGS) -o ack $(OBJ) $(MODDIR)/libstring.$(LIBSUF) - -depend: $(ISRC) - rm_deps Makefile > Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(INCLUDES) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -dmach.c intable.c: mktables $(SRC_DIR)/dmach.h - : mktables $(ACKDIR) # $(FE) $(INTABLES) - mktables $(ACKDIR) - -mktables: mktables.$(USUF) - $(UCC) -o mktables $(ULDFLAGS) mktables.$(USUF) - -mktables.$(USUF): $(SRC_DIR)/mktables.c - $(UCC) -c $(UCFLAGS) $(SRC_DIR)/mktables.c - -pr: - @pr $(SRC_DIR)/proto.make $(HFILES) $(DSRC) - -opr: - make pr | opr - -lint: $(ISRC) - $(LINT) $(LINTFLAGS) $(CFILES) $(UTIL_HOME)/modules/lib/$(LINTPREF)string.$(LINTSUF) - -# do not remove the next line -#DEPENDENCIES -list.$(SUF): $(SRC_DIR)/list.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/list.c -list.$(SUF): $(SRC_DIR)/list.h -list.$(SUF): $(SRC_DIR)/ack.h -data.$(SUF): $(SRC_DIR)/data.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/data.c -data.$(SUF): $(SRC_DIR)/data.h -data.$(SUF): $(SRC_DIR)/trans.h -data.$(SUF): $(SRC_DIR)/list.h -data.$(SUF): $(SRC_DIR)/ack.h -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c -main.$(SUF): $(SRC_DIR)/data.h -main.$(SUF): $(TARGET_HOME)/config/local.h -main.$(SUF): $(SRC_DIR)/trans.h -main.$(SUF): $(SRC_DIR)/list.h -main.$(SUF): $(SRC_DIR)/ack.h -scan.$(SUF): $(SRC_DIR)/scan.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/scan.c -scan.$(SUF): $(SRC_DIR)/data.h -scan.$(SUF): $(SRC_DIR)/trans.h -scan.$(SUF): $(SRC_DIR)/list.h -scan.$(SUF): $(SRC_DIR)/ack.h -svars.$(SUF): $(SRC_DIR)/svars.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/svars.c -svars.$(SUF): $(SRC_DIR)/ack.h -trans.$(SUF): $(SRC_DIR)/trans.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/trans.c -trans.$(SUF): $(SRC_DIR)/data.h -trans.$(SUF): $(SRC_DIR)/grows.h -trans.$(SUF): $(SRC_DIR)/trans.h -trans.$(SUF): $(SRC_DIR)/list.h -trans.$(SUF): $(SRC_DIR)/ack.h -util.$(SUF): $(SRC_DIR)/util.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/util.c -util.$(SUF): $(SRC_DIR)/ack.h -rmach.$(SUF): $(SRC_DIR)/rmach.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/rmach.c -rmach.$(SUF): $(SRC_DIR)/data.h -rmach.$(SUF): $(SRC_DIR)/dmach.h -rmach.$(SUF): $(SRC_DIR)/grows.h -rmach.$(SUF): $(SRC_DIR)/trans.h -rmach.$(SUF): $(SRC_DIR)/list.h -rmach.$(SUF): $(TARGET_HOME)/config/em_path.h -rmach.$(SUF): $(SRC_DIR)/ack.h -run.$(SUF): $(SRC_DIR)/run.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/run.c -run.$(SUF): $(SRC_DIR)/data.h -run.$(SUF): $(SRC_DIR)/grows.h -run.$(SUF): $(SRC_DIR)/trans.h -run.$(SUF): $(SRC_DIR)/list.h -run.$(SUF): $(SRC_DIR)/ack.h -grows.$(SUF): $(SRC_DIR)/grows.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/grows.c -grows.$(SUF): $(SRC_DIR)/grows.h -grows.$(SUF): $(SRC_DIR)/ack.h -files.$(SUF): $(SRC_DIR)/files.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/files.c -files.$(SUF): $(TARGET_HOME)/config/em_path.h -files.$(SUF): $(SRC_DIR)/data.h -files.$(SUF): $(SRC_DIR)/grows.h -files.$(SUF): $(SRC_DIR)/trans.h -files.$(SUF): $(SRC_DIR)/list.h -files.$(SUF): $(SRC_DIR)/ack.h -dmach.$(SUF): dmach.c - $(CC) -c $(CFLAGS) dmach.c -dmach.$(SUF): $(SRC_DIR)/dmach.h -intable.$(SUF): intable.c - $(CC) -c $(CFLAGS) intable.c diff --git a/util/ack/rmach.c b/util/ack/rmach.c index d1ce5d2f7..38b2a54b3 100644 --- a/util/ack/rmach.c +++ b/util/ack/rmach.c @@ -4,6 +4,8 @@ * */ +#include +#include #include "ack.h" #include #include "list.h" @@ -11,7 +13,6 @@ #include "grows.h" #include "dmach.h" #include "data.h" -#include #ifndef NORCSID static char rcs_id[] = "$Id$" ; diff --git a/util/amisc/.distr b/util/amisc/.distr deleted file mode 100644 index 3cbc22a7d..000000000 --- a/util/amisc/.distr +++ /dev/null @@ -1,13 +0,0 @@ -pmfile -ashow.c -ashow.1 -anm.c -anm.1 -asize.c -asize.1 -astrip.c -astrip.1 -aslod.c -aslod.1 -aelflod.c -aelflod.1 \ No newline at end of file diff --git a/util/amisc/aelflod.c b/util/amisc/aelflod.c index d9a2ed6e0..398b223b2 100644 --- a/util/amisc/aelflod.c +++ b/util/amisc/aelflod.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "out.h" #define ASSERT(x) switch (2) { case 0: case (x): ; } @@ -453,11 +454,11 @@ int main(int argc, char* argv[]) { long ss = 0; printf(" address length\n"); - printf(" ehdr : %08lX %08lX\n", outsect[TEXT].os_base & ~0x1FFF, codeoffset); - printf(" text : %08lX %08lX\n", outsect[TEXT].os_base, outsect[TEXT].os_size); - printf(" rom : %08lX %08lX\n", outsect[ROM].os_base, outsect[ROM].os_size); - printf(" data : %08lX %08lX\n", outsect[DATA].os_base, outsect[DATA].os_size); - printf(" bss : %08lX %08lX\n", outsect[BSS].os_base, outsect[BSS].os_size); + printf(" ehdr : %08"PRIx32" %08"PRIx32"\n", outsect[TEXT].os_base & ~0x1FFF, codeoffset); + printf(" text : %08"PRIx32" %08"PRIx32"\n", outsect[TEXT].os_base, outsect[TEXT].os_size); + printf(" rom : %08"PRIx32" %08"PRIx32"\n", outsect[ROM].os_base, outsect[ROM].os_size); + printf(" data : %08"PRIx32" %08"PRIx32"\n", outsect[DATA].os_base, outsect[DATA].os_size); + printf(" bss : %08"PRIx32" %08"PRIx32"\n", outsect[BSS].os_base, outsect[BSS].os_size); ss += outsect[TEXT].os_size; ss += outsect[ROM].os_size; ss += outsect[DATA].os_size; diff --git a/util/amisc/ashow.c b/util/amisc/ashow.c index 5f22827ee..b11e60e76 100644 --- a/util/amisc/ashow.c +++ b/util/amisc/ashow.c @@ -70,7 +70,7 @@ show(headp) /* * We get all struct outname's and the strings in core first. */ - name = (struct outname *) myalloc(headp->oh_nname * SZ_NAME); + name = (struct outname *) myalloc(headp->oh_nname * sizeof(struct outname)); string = myalloc((unsigned) headp->oh_nchar); rd_name(name, headp->oh_nname); for (np = &name[0]; np < &name[headp->oh_nname]; np++) { @@ -143,6 +143,9 @@ showrelo() case RELOH2: printf("\ttop 2 bytes of a 4 byte word\n"); break; + case RELOVC4: + printf("\tVideoCore IV address in 32-bit instruction\n"); + break; default: printf("\tunknown relocation type %d\n", relrec.or_type & RELSZ); break; diff --git a/util/amisc/aslod.c b/util/amisc/aslod.c index b761898d4..307f72cb1 100644 --- a/util/amisc/aslod.c +++ b/util/amisc/aslod.c @@ -23,6 +23,9 @@ #include #include #include +#include +#include +#include #include "out.h" #define ASSERT(x) switch (2) { case 0: case (x): ; } @@ -300,11 +303,11 @@ int main(int argc, char* argv[]) { long ss = 0; - printf(" base : %08lX\n", outsect[TEXT].os_base) ; - printf(" text = %08lX\n", outsect[TEXT].os_size); - printf(" rom = %08lX\n", outsect[ROM].os_size); - printf(" data = %08lX\n", outsect[DATA].os_size); - printf(" bss = %08lX\n", outsect[BSS].os_size); + printf(" base : %08"PRIx32"\n", outsect[TEXT].os_base) ; + printf(" text = %08"PRIx32"\n", outsect[TEXT].os_size); + printf(" rom = %08"PRIx32"\n", outsect[ROM].os_size); + printf(" data = %08"PRIx32"\n", outsect[DATA].os_size); + printf(" bss = %08"PRIx32"\n", outsect[BSS].os_size); ss += outsect[TEXT].os_size; ss += outsect[ROM].os_size; ss += outsect[DATA].os_size; diff --git a/util/amisc/build.lua b/util/amisc/build.lua new file mode 100644 index 000000000..d1b8a3356 --- /dev/null +++ b/util/amisc/build.lua @@ -0,0 +1,38 @@ +local function simpleprogram(name) + cprogram { + name = name, + srcs = { "./"..name..".c" }, + deps = { + "h+emheaders", + "modules/src/object+lib", + } + } + + installable { + name = name.."-pkg", + map = { + ["$(INSDIR)/bin/"..name] = "+"..name, + ["$(PLATIND)/man/man1/"..name..".1"] = "./"..name..".1", + } + } +end + +simpleprogram("aelflod") +simpleprogram("anm") +simpleprogram("ashow") +simpleprogram("asize") +simpleprogram("aslod") +simpleprogram("astrip") + +installable { + name = "pkg", + map = { + "+aelflod-pkg", + "+anm-pkg", + "+ashow-pkg", + "+asize-pkg", + "+aslod-pkg", + "+astrip-pkg", + } +} + diff --git a/util/amisc/pmfile b/util/amisc/pmfile deleted file mode 100644 index 4faa7c6c2..000000000 --- a/util/amisc/pmfile +++ /dev/null @@ -1,35 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/amisc/" - -local simple_tool = cprogram { - class = "simple_tool", - - cfile (d.."%S%.c"), - lib_object, - - outputs = {"%U%/%S%"}, - install = { - pm.install("%U%/%S%", "%BINDIR%bin/%S%"), - pm.install(d.."%S%.1", "%BINDIR%man/man1/%S%.1") - } -} - -tool_anm = simple_tool { S = "anm" } -tool_ashow = simple_tool { S = "ashow" } -tool_asize = simple_tool { S = "asize" } -tool_astrip = simple_tool { S = "astrip" } -tool_aslod = simple_tool { S = "aslod" } -tool_aelflod = simple_tool { S = "aelflod" } - --- Revision history --- $Log$ --- Revision 1.3 2007-04-23 23:40:10 dtrg --- Added the aelflod tool for generating ELF executables. Added documentation for aelflod and ashow. Now installs the documentation when built. --- --- Revision 1.2 2006/10/16 23:25:56 dtrg --- Added support for anm, asize, ashow, astrip and the new aslod tool. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. diff --git a/util/amisc/proto.make b/util/amisc/proto.make deleted file mode 100644 index 64bbcc27e..000000000 --- a/util/amisc/proto.make +++ /dev/null @@ -1,48 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/amisc -BINDIR = $(TARGET_HOME)/bin -LDFLAGS = $(LDOPTIONS) -INCLUDES = -I$(TARGET_HOME)/h -CFLAGS = $(INCLUDES) $(COPTIONS) -LINTFLAGS = $(INCLUDES) $(LINTOPTIONS) - -ALL = anm asize astrip ashow -LIBS = $(TARGET_HOME)/modules/lib/libobject.$(LIBSUF) -LINTLIBS = $(UTIL_HOME)/modules/lib/$(LINTPREF)object.$(LINTSUF) - -all: $(ALL) - -anm: $(SRC_DIR)/anm.c - $(CC) $(CFLAGS) $(LDFLAGS) -o anm $(SRC_DIR)/anm.c $(LIBS) -asize: $(SRC_DIR)/asize.c - $(CC) $(CFLAGS) $(LDFLAGS) -o asize $(SRC_DIR)/asize.c $(LIBS) -astrip: $(SRC_DIR)/astrip.c - $(CC) $(CFLAGS) $(LDFLAGS) -o astrip $(SRC_DIR)/astrip.c $(LIBS) -ashow: $(SRC_DIR)/ashow.c - $(CC) $(CFLAGS) $(LDFLAGS) -o ashow $(SRC_DIR)/ashow.c $(LIBS) - -install: all - for i in $(ALL); do rm -f $(BINDIR)/$$i; cp $$i $(BINDIR)/$$i; done - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then for i in anm.1 asize.1 astrip.1; do mk_manpage $(SRC_DIR)/$$i $(TARGET_HOME) ; done ; \ - fi - -cmp: all - -for i in $(ALL); do cmp $$i $(BINDIR)/$$i; done - -clean: ; rm -f $(ALL) *.$(SUF) - -lint: - $(LINT) $(LINTFLAGS) $(SRC_DIR)/anm.c $(LINTLIBS) - $(LINT) $(LINTFLAGS) $(SRC_DIR)/asize.c $(LINTLIBS) - $(LINT) $(LINTFLAGS) $(SRC_DIR)/astrip.c $(LINTLIBS) - $(LINT) $(LINTFLAGS) $(SRC_DIR)/ashow.c $(LINTLIBS) - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/anm.c $(SRC_DIR)/astrip.c $(SRC_DIR)/asize.c $(SRC_DIR)/ashow.c - -opr: - make pr | opr diff --git a/util/arch/.distr b/util/arch/.distr deleted file mode 100644 index 7a52ea34b..000000000 --- a/util/arch/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -aal.1 -arch.1 -arch.5 -archiver.c diff --git a/util/arch/build.lua b/util/arch/build.lua new file mode 100644 index 000000000..54b05f981 --- /dev/null +++ b/util/arch/build.lua @@ -0,0 +1,22 @@ +cprogram { + name = "aal", + srcs = { "./archiver.c" }, + deps = { + "h+emheaders", + "modules/src/object+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib" + }, + vars = { + ["+cflags"] = "-DAAL" + } +} + +installable { + name = "pkg", + map = { + ["$(INSDIR)/bin/aal"] = "+aal", + ["$(PLATIND)/man/man1/aal.1"] = "./aal.1" + } +} diff --git a/util/arch/pmfile b/util/arch/pmfile deleted file mode 100644 index 9f7c67d0d..000000000 --- a/util/arch/pmfile +++ /dev/null @@ -1,31 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/arch/" - -tool_aal = cprogram { - CDEFINES = {PARENT, "AAL"}, - cfile (d.."archiver.c"), - - lib_print, - lib_string, - lib_system, - lib_object, - - install = { - pm.install("%BINDIR%bin/aal"), - pm.install(d.."aal.1", "%BINDIR%man/man1/aal.1") - } -} - --- Revision history --- $Log$ --- Revision 1.3 2006-10-15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/30 23:45:35 dtrg --- Modified to install aal's manpage. --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/util/arch/proto.make b/util/arch/proto.make deleted file mode 100644 index 3290869ce..000000000 --- a/util/arch/proto.make +++ /dev/null @@ -1,62 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/arch -EMH = $(TARGET_HOME)/h -EMBIN = $(TARGET_HOME)/bin -LIB = $(TARGET_HOME)/modules/lib -ULIB = $(UTIL_HOME)/modules/lib - -LIBS = $(LIB)/libobject.$(LIBSUF) $(LIB)/libprint.$(LIBSUF) \ - $(LIB)/libstring.$(LIBSUF) $(LIB)/libsystem.$(LIBSUF) -LINTLIBS = \ - $(ULIB)/$(LINTPREF)object.$(LINTSUF) \ - $(ULIB)/$(LINTPREF)print.$(LINTSUF) \ - $(ULIB)/$(LINTPREF)string.$(LINTSUF) \ - $(ULIB)/$(LINTPREF)system.$(LINTSUF) - -INCLUDES = -I$(EMH) -CFLAGS= $(INCLUDES) -DDISTRIBUTION $(COPTIONS) -LDFLAGS = $(LDOPTIONS) -LINTFLAGS= $(INCLUDES) -DDISTRIBUTION $(LINTOPTIONS) - -all: arch aal - -arch: arch.$(SUF) - $(CC) $(LDFLAGS) -o arch arch.$(SUF) $(LIBS) - -aal: aal.$(SUF) - $(CC) $(LDFLAGS) -o aal aal.$(SUF) $(LIBS) - -arch.$(SUF): $(EMH)/arch.h $(SRC_DIR)/archiver.c - $(CC) $(CFLAGS) -c $(SRC_DIR)/archiver.c - mv archiver.$(SUF) arch.$(SUF) - -aal.$(SUF): $(EMH)/arch.h $(SRC_DIR)/archiver.c $(EMH)/ranlib.h $(EMH)/out.h - $(CC) -DAAL $(CFLAGS) -c $(SRC_DIR)/archiver.c - mv archiver.$(SUF) aal.$(SUF) - -clean: - rm -f aal arch *.$(SUF) *.old - -lint: - $(LINT) $(LINTFLAGS) -DAAL $(SRC_DIR)/archiver.c $(LINTLIBS) - -install : all - cp aal $(EMBIN)/aal - cp arch $(EMBIN)/arch - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/aal.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/arch.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/arch.5 $(TARGET_HOME) ; \ - fi - -cmp : all - -cmp aal $(EMBIN)/aal - -cmp arch $(EMBIN)/arch - -opr: - make pr ^ opr -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/archiver.c diff --git a/util/ass/.distr b/util/ass/.distr deleted file mode 100644 index 0e3de02c4..000000000 --- a/util/ass/.distr +++ /dev/null @@ -1,17 +0,0 @@ -proto.make -ass00.c -ass00.h -ass30.c -ass40.c -ass50.c -ass60.c -ass70.c -ass80.c -assci.c -asscm.c -assda.c -assex.h -assrl.c -maktab.c -asprint.p -em_ass.6 diff --git a/util/byacc/.distr b/util/byacc/.distr deleted file mode 100644 index 94964ce7e..000000000 --- a/util/byacc/.distr +++ /dev/null @@ -1,19 +0,0 @@ -ACKNOWLEDGEMENTS -proto.make -NEW_FEATURES -NO_WARRANTY -README -closure.c -defs.h -error.c -lalr.c -lr0.c -main.c -manpage -mkpar.c -output.c -reader.c -skeleton.c -symtab.c -verbose.c -warshall.c diff --git a/util/ceg/.distr b/util/ceg/.distr deleted file mode 100644 index cbbd46d31..000000000 --- a/util/ceg/.distr +++ /dev/null @@ -1,7 +0,0 @@ -Action -EM_parser -as_parser -assemble -ce_back -defaults -util diff --git a/util/ceg/EM_parser/.distr b/util/ceg/EM_parser/.distr deleted file mode 100644 index 8168b706b..000000000 --- a/util/ceg/EM_parser/.distr +++ /dev/null @@ -1,3 +0,0 @@ -as_EM_pars -common -obj_EM_pars diff --git a/util/ceg/EM_parser/as_EM_pars/.distr b/util/ceg/EM_parser/as_EM_pars/.distr deleted file mode 100644 index 0e2ec23a0..000000000 --- a/util/ceg/EM_parser/as_EM_pars/.distr +++ /dev/null @@ -1,6 +0,0 @@ -proto.make -arg_type.h -dist.c -em_decl.h -em_parser.h -error.c diff --git a/util/ceg/EM_parser/common/.distr b/util/ceg/EM_parser/common/.distr deleted file mode 100644 index 2c74fd389..000000000 --- a/util/ceg/EM_parser/common/.distr +++ /dev/null @@ -1,12 +0,0 @@ -C_instr2.c -proto.make -action.c -arg_type.h -decl.h -default.c -em_parser.h -eval.c -help.c -mylex.c -pars.g -scan.c diff --git a/util/ceg/EM_parser/obj_EM_pars/.distr b/util/ceg/EM_parser/obj_EM_pars/.distr deleted file mode 100644 index aa442e9e9..000000000 --- a/util/ceg/EM_parser/obj_EM_pars/.distr +++ /dev/null @@ -1,4 +0,0 @@ -proto.make -arg_type.h -dist.c -em_parser.h diff --git a/util/ceg/as_parser/.distr b/util/ceg/as_parser/.distr deleted file mode 100644 index 5e16f6278..000000000 --- a/util/ceg/as_parser/.distr +++ /dev/null @@ -1,9 +0,0 @@ -proto.make -as_parser.h -const.h -conversion.c -decl.h -eval -help.c -pars.g -table.l diff --git a/util/ceg/as_parser/eval/.distr b/util/ceg/as_parser/eval/.distr deleted file mode 100644 index 3c0c6492c..000000000 --- a/util/ceg/as_parser/eval/.distr +++ /dev/null @@ -1,3 +0,0 @@ -proto.make -eval.c -states.h diff --git a/util/ceg/as_parser/pmfile b/util/ceg/as_parser/pmfile deleted file mode 100644 index da3c67023..000000000 --- a/util/ceg/as_parser/pmfile +++ /dev/null @@ -1,59 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ceg/as_parser/" - -local lpars = LLgen { - file (d.."pars.g") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - lpars - } -} - -tool_ceg_as_parser = cprogram { - CDEFINES = {PARENT, "FLEX"}, - CLIBRARIES = {PARENT, "fl"}, - - cfile_with_headers (d.."conversion.c"), - cfile_with_headers (d.."help.c"), - - cfile_with_headers { - flex { - file (d.."table.l") - } - }, - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - lib_alloc, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/as_parser"}, - install = pm.install(BINDIR.."%PLATDEP%/ceg/as_parser/as_parser"), -} - -tool_ceg_as_parser_eval = cprogram { - cfile (d.."eval/eval.c"), - - outputs = {"%U%/eval"}, - install = pm.install(BINDIR.."%PLATDEP%/ceg/as_parser/eval"), -} - --- Revision history --- $Log$ --- Revision 1.2 2006-10-15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.1 2006/07/20 23:18:18 dtrg --- First version in CVS. --- diff --git a/util/ceg/assemble/.distr b/util/ceg/assemble/.distr deleted file mode 100644 index 9fd2c817f..000000000 --- a/util/ceg/assemble/.distr +++ /dev/null @@ -1,3 +0,0 @@ -as_assemble -proto.make -obj_assemble diff --git a/util/ceg/assemble/as_assemble/.distr b/util/ceg/assemble/as_assemble/.distr deleted file mode 100644 index 0247bb1c5..000000000 --- a/util/ceg/assemble/as_assemble/.distr +++ /dev/null @@ -1,3 +0,0 @@ -READ_ME -assemble.c -block_as.c diff --git a/util/ceg/assemble/obj_assemble/.distr b/util/ceg/assemble/obj_assemble/.distr deleted file mode 100644 index 752d5be77..000000000 --- a/util/ceg/assemble/obj_assemble/.distr +++ /dev/null @@ -1,4 +0,0 @@ -READ_ME -assemble.c -block_as.c -const.h diff --git a/util/ceg/assemble/pmfile b/util/ceg/assemble/pmfile deleted file mode 100644 index 05671a71f..000000000 --- a/util/ceg/assemble/pmfile +++ /dev/null @@ -1,20 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ceg/assemble/" - -tool_ceg_assemble = group { - install = { - pm.install(d.."as_assemble/assemble.c", BINDIR..PLATDEP.."/ceg/assemble/as_assemble/assemble.c"), - pm.install(d.."as_assemble/block_as.c", BINDIR..PLATDEP.."/ceg/assemble/as_assemble/block_as.c"), - pm.install(d.."obj_assemble/assemble.c", BINDIR..PLATDEP.."/ceg/assemble/obj_assemble/assemble.c"), - pm.install(d.."obj_assemble/block_as.c", BINDIR..PLATDEP.."/ceg/assemble/obj_assemble/block_as.c"), - pm.install(d.."obj_assemble/const.h", BINDIR..PLATDEP.."/ceg/assemble/obj_assemble/const.h"), - } -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/util/ceg/ce_back/.distr b/util/ceg/ce_back/.distr deleted file mode 100644 index 1625e2ad3..000000000 --- a/util/ceg/ce_back/.distr +++ /dev/null @@ -1,3 +0,0 @@ -as_back -obj_back -proto.make diff --git a/util/ceg/ce_back/as_back/.distr b/util/ceg/ce_back/as_back/.distr deleted file mode 100644 index fbc0bdb4e..000000000 --- a/util/ceg/ce_back/as_back/.distr +++ /dev/null @@ -1,30 +0,0 @@ -proto.make -READ_ME -back.h -bottom.c -bss.c -con1.c -con2.c -con4.c -do_close.c -do_open.c -end_back.c -gen1.c -gen2.c -gen4.c -header.h -init_back.c -reloc1.c -reloc2.c -reloc4.c -rom1.c -rom2.c -rom4.c -set_global.c -set_local.c -switchseg.c -symboldef.c -text1.c -text2.c -text4.c -dbsym.c diff --git a/util/ceg/ce_back/obj_back/.distr b/util/ceg/ce_back/obj_back/.distr deleted file mode 100644 index cd700c6ed..000000000 --- a/util/ceg/ce_back/obj_back/.distr +++ /dev/null @@ -1,36 +0,0 @@ -proto.make -READ_ME -back.h -con2.c -con4.c -data.c -data.h -do_close.c -do_open.c -end_back.c -extnd.c -gen1.c -gen2.c -gen4.c -hash.h -header.h -init_back.c -label.c -memory.c -misc.c -output.c -reloc1.c -reloc2.c -reloc4.c -relocation.c -rom2.c -rom4.c -set_global.c -set_local.c -switchseg.c -symboldef.c -symtable.c -text2.c -text4.c -common.c -dbsym.c diff --git a/util/ceg/ce_back/pmfile b/util/ceg/ce_back/pmfile deleted file mode 100644 index 5710282c8..000000000 --- a/util/ceg/ce_back/pmfile +++ /dev/null @@ -1,89 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ceg/ce_back/" - -local function installmany(srcroot, destroot, list) - local o = {} - - for _, i in ipairs(list) do - table.insert(o, pm.install(srcroot..i, destroot..i)) - end - - return o -end - -tool_ceg_assemble = group { - install = installmany(d, BINDIR.."%PLATDEP%/ceg/ce_back/", - { - "as_back/back.h", - "as_back/bottom.c", - "as_back/bss.c", - "as_back/con1.c", - "as_back/con2.c", - "as_back/con4.c", - "as_back/do_close.c", - "as_back/do_open.c", - "as_back/end_back.c", - "as_back/gen1.c", - "as_back/gen2.c", - "as_back/gen4.c", - "as_back/header.h", - "as_back/init_back.c", - "as_back/reloc1.c", - "as_back/reloc2.c", - "as_back/reloc4.c", - "as_back/rom1.c", - "as_back/rom2.c", - "as_back/rom4.c", - "as_back/set_global.c", - "as_back/set_local.c", - "as_back/switchseg.c", - "as_back/symboldef.c", - "as_back/text1.c", - "as_back/text2.c", - "as_back/text4.c", - "as_back/dbsym.c", - - "obj_back/back.h", - "obj_back/con2.c", - "obj_back/con4.c", - "obj_back/data.c", - "obj_back/data.h", - "obj_back/do_close.c", - "obj_back/do_open.c", - "obj_back/end_back.c", - "obj_back/extnd.c", - "obj_back/gen1.c", - "obj_back/gen2.c", - "obj_back/gen4.c", - "obj_back/hash.h", - "obj_back/header.h", - "obj_back/init_back.c", - "obj_back/label.c", - "obj_back/memory.c", - "obj_back/misc.c", - "obj_back/output.c", - "obj_back/reloc1.c", - "obj_back/reloc2.c", - "obj_back/reloc4.c", - "obj_back/relocation.c", - "obj_back/rom2.c", - "obj_back/rom4.c", - "obj_back/set_global.c", - "obj_back/set_local.c", - "obj_back/switchseg.c", - "obj_back/symboldef.c", - "obj_back/symtable.c", - "obj_back/text2.c", - "obj_back/text4.c", - "obj_back/common.c", - "obj_back/dbsym.c", - }) -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:19 dtrg --- First version in CVS. --- diff --git a/util/ceg/defaults/.distr b/util/ceg/defaults/.distr deleted file mode 100644 index 9145090bf..000000000 --- a/util/ceg/defaults/.distr +++ /dev/null @@ -1,13 +0,0 @@ -proto.make -READ_ME -message -not_impl -pseudo -pseudo_vars.c -storage -m_C_mnem -m_C_mnem_na -argtype -C_out_skel.c -mk_C_out -EM_vars.c diff --git a/util/ceg/defaults/message/.distr b/util/ceg/defaults/message/.distr deleted file mode 100644 index 7b3324c63..000000000 --- a/util/ceg/defaults/message/.distr +++ /dev/null @@ -1,11 +0,0 @@ -C_cst.c -C_dlb.c -C_dnam.c -C_fcon.c -C_icon.c -C_ilb.c -C_mes_begin.c -C_mes_end.c -C_pnam.c -C_scon.c -C_ucon.c diff --git a/util/ceg/defaults/not_impl/.distr b/util/ceg/defaults/not_impl/.distr deleted file mode 100644 index f05c64e52..000000000 --- a/util/ceg/defaults/not_impl/.distr +++ /dev/null @@ -1,2 +0,0 @@ -not_impl.c -not_impl_table diff --git a/util/ceg/defaults/pseudo/.distr b/util/ceg/defaults/pseudo/.distr deleted file mode 100644 index cefb98132..000000000 --- a/util/ceg/defaults/pseudo/.distr +++ /dev/null @@ -1,19 +0,0 @@ -C_busy.c -C_close.c -C_df_dlb.c -C_df_dnam.c -C_df_ilb.c -C_end.c -C_end_narg.c -C_exa_dlb.c -C_exa_dnam.c -C_exp.c -C_ina_dlb.c -C_ina_dnam.c -C_init.c -C_inp.c -C_magic.c -C_open.c -C_pro.c -C_pro_narg.c -C_insertpart.c diff --git a/util/ceg/defaults/storage/.distr b/util/ceg/defaults/storage/.distr deleted file mode 100644 index 011eb5382..000000000 --- a/util/ceg/defaults/storage/.distr +++ /dev/null @@ -1,22 +0,0 @@ -C_bss_cst.c -C_bss_dlb.c -C_bss_dnam.c -C_bss_ilb.c -C_bss_pnam.c -C_con_cst.c -C_con_dlb.c -C_con_dnam.c -C_con_ilb.c -C_con_pnam.c -C_con_scon.c -C_hol_cst.c -C_hol_dlb.c -C_hol_dnam.c -C_hol_ilb.c -C_hol_pnam.c -C_rom_cst.c -C_rom_dlb.c -C_rom_dnam.c -C_rom_ilb.c -C_rom_pnam.c -C_rom_scon.c diff --git a/util/ceg/pmfile b/util/ceg/pmfile deleted file mode 100644 index 8de3fbc6c..000000000 --- a/util/ceg/pmfile +++ /dev/null @@ -1,21 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ceg/" - -include (d.."as_parser/pmfile") -include (d.."assemble/pmfile") -include (d.."ce_back/pmfile") - -tool_ceg = group { - tool_ceg_as_parser, - tool_ceg_as_parser_eval, - tool_ceg_assemble, - tool_ceg_ce_back, -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:18:18 dtrg --- First version in CVS. --- diff --git a/util/ceg/util/.distr b/util/ceg/util/.distr deleted file mode 100644 index 13803edb1..000000000 --- a/util/ceg/util/.distr +++ /dev/null @@ -1,8 +0,0 @@ -proto.make -install_ceg -make_asobj -make_back -make_ce -make_ceg -make_own -update_ceg diff --git a/util/cgg/.distr b/util/cgg/.distr deleted file mode 100644 index 2a2ff68aa..000000000 --- a/util/cgg/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -bootgram.y -bootlex.l -main.c -booth.h diff --git a/util/cgg/main.c b/util/cgg/main.c index fba8e31b5..86375b776 100644 --- a/util/cgg/main.c +++ b/util/cgg/main.c @@ -1009,3 +1009,8 @@ max(a,b) { return(a); return(b); } + +int yywrap(void) { + return 1; +} + diff --git a/util/cgg/pmfile b/util/cgg/pmfile deleted file mode 100644 index cb2e4a369..000000000 --- a/util/cgg/pmfile +++ /dev/null @@ -1,54 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/cgg/" - -local yacc_bootgram = yacc { - file (d.."bootgram.y") - } - -tool_cgg = cprogram { - cfile (d.."main.c"), - - cfile { - CINCLUDES = {PARENT, d}, - yacc_bootgram, - }, - - cfile { - CINCLUDES = {PARENT, d}, - flex { - file (d.."bootlex.l") - }, - - dynamicheaders = yacc_bootgram - }, - - CLIBRARIES = {PARENT, "fl"}, - lib_em_data, - lib_assert, - lib_system, - - install = pm.install(TOOLDIR.."cgg") -} - -cgg = simple { - class = "cgg", - - outputs = {"%U%/tables.c", "%U%/tables.h"}, - command = { - "cd %out[1]:dirname% && (%BINDIR%%PLATDEP%/cpp -P -I%CGGINCLUDEDIR% %in% | %TOOLDIR%cgg)", - }, -} - --- Revision history --- $Log$ --- Revision 1.3 2006-10-15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/22 20:58:27 dtrg --- cpp now gets installed in the right place. --- --- Revision 1.1 2006/07/20 23:21:17 dtrg --- First version in CVS. --- diff --git a/util/cmisc/.distr b/util/cmisc/.distr deleted file mode 100644 index fea42afee..000000000 --- a/util/cmisc/.distr +++ /dev/null @@ -1,12 +0,0 @@ -pmfile -GCIPM.c -cclash.1 -cclash.c -cid.1 -cid.c -mkdep.1 -mkdep.c -prid.1 -prid.c -tabgen.1 -tabgen.c diff --git a/util/cmisc/build.lua b/util/cmisc/build.lua new file mode 100644 index 000000000..b7c2b474a --- /dev/null +++ b/util/cmisc/build.lua @@ -0,0 +1,25 @@ +cprogram { + name = "tabgen", + srcs = { "./tabgen.c" } +} + +definerule("tabgen", + { + srcs = { type="targets" }, + }, + function(e) + local symname = basename(filenamesof(e.srcs)[1]):gsub("%.tab$", "") + + return normalrule { + name = e.name, + ins = { + "util/cmisc+tabgen", + e.srcs + }, + outleaves = { symname..".c" }, + commands = { + "%{ins[1]} -f%{ins[2]} > %{outs} || rm %{outs}" + } + } + end +) diff --git a/util/cmisc/pmfile b/util/cmisc/pmfile deleted file mode 100644 index b67734077..000000000 --- a/util/cmisc/pmfile +++ /dev/null @@ -1,25 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/cmisc/" - -tool_tabgen = cprogram { - cfile (d.."tabgen.c"), - - outputs = {"%U%/tabgen"}, - install = pm.install(TOOLDIR.."tabgen") -} - -tabgen = simple { - class = "tabgen", - outputs = {"%U%-char.c"}, - command = { - "%TOOLDIR%tabgen -f%in[1]% > %out[1]%" - }, -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-20 23:21:17 dtrg --- First version in CVS. --- diff --git a/util/cmisc/proto.make b/util/cmisc/proto.make deleted file mode 100644 index d8ede4483..000000000 --- a/util/cmisc/proto.make +++ /dev/null @@ -1,69 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/cmisc -TARGET_BIN = $(TARGET_HOME)/bin -CFLAGS = $(COPTIONS) -LDFLAGS = $(LDOPTIONS) -LINTFLAGS = $(LINTOPTIONS) - -all: cid cclash prid tabgen - -install: all - cp cid cclash prid tabgen $(TARGET_BIN) - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/cid.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/cclash.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/prid.1 $(TARGET_HOME) ; \ - mk_manpage $(SRC_DIR)/tabgen.1 $(TARGET_HOME) ; \ - fi - -cmp: all - -cmp cid $(TARGET_BIN)/cid - -cmp cclash $(TARGET_BIN)/cclash - -cmp prid $(TARGET_BIN)/prid - -cmp tabgen $(TARGET_BIN)/tabgen - -clean: - rm -f *.$(SUF) cid cclash prid tabgen - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/cclash.c $(SRC_DIR)/cid.c \ - $(SRC_DIR)/prid.c $(SRC_DIR)/GCIPM.c $(SRC_DIR)/tabgen.c - -opr: - make pr | opr - -tabgen: tabgen.$(SUF) - $(CC) $(LDFLAGS) -o tabgen tabgen.$(SUF) - -cid: cid.$(SUF) GCIPM.$(SUF) - $(CC) $(LDFLAGS) -o cid cid.$(SUF) GCIPM.$(SUF) - -cclash: cclash.$(SUF) GCIPM.$(SUF) - $(CC) $(LDFLAGS) -o cclash cclash.$(SUF) GCIPM.$(SUF) - -prid: prid.$(SUF) GCIPM.$(SUF) - $(CC) $(LDFLAGS) -o prid prid.$(SUF) GCIPM.$(SUF) - -lint: - $(LINT) $(LINTFLAGS) $(SRC_DIR)/cid.c $(SRC_DIR)/GCIPM.c - $(LINT) $(LINTFLAGS) $(SRC_DIR)/prid.c $(SRC_DIR)/GCIPM.c - $(LINT) $(LINTFLAGS) $(SRC_DIR)/cclash.c $(SRC_DIR)/GCIPM.c - $(LINT) $(LINTFLAGS) $(SRC_DIR)/tabgen.c - -tabgen.$(SUF): $(SRC_DIR)/tabgen.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/tabgen.c - -cid.$(SUF): $(SRC_DIR)/cid.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cid.c - -prid.$(SUF): $(SRC_DIR)/prid.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/prid.c - -cclash.$(SUF): $(SRC_DIR)/cclash.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cclash.c - -GCIPM.$(SUF): $(SRC_DIR)/GCIPM.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/GCIPM.c diff --git a/util/cpp/.distr b/util/cpp/.distr deleted file mode 100644 index 7b896c676..000000000 --- a/util/cpp/.distr +++ /dev/null @@ -1,34 +0,0 @@ -pmfile -LLlex.c -LLlex.h -LLmessage.c -Parameters -bits.h -ch7bin.c -ch7mon.c -char.tab -class.h -domacro.c -error.c -expr.c -expression.g -file_info.h -idf.c -idf.h -init.c -input.c -input.h -interface.h -macro.h -main.c -make.hfiles -make.tokcase -make.tokfile -next.c -options.c -preprocess.c -replace.c -scan.c -skip.c -tokenname.c -cpp.6 diff --git a/util/cpp/pmfile b/util/cpp/pmfile deleted file mode 100644 index 2f777591c..000000000 --- a/util/cpp/pmfile +++ /dev/null @@ -1,123 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/cpp/" - -local extract_parameters = simple { - outputs = { - "%U%/pathlength.h", - "%U%/errout.h", - "%U%/idfsize.h", - "%U%/numsize.h", - "%U%/nparams.h", - "%U%/ifdepth.h", - "%U%/lapbuf.h", - "%U%/strsize.h", - "%U%/botch_free.h", - "%U%/debug.h", - "%U%/parbufsize.h", - "%U%/textsize.h", - "%U%/inputtype.h", - "%U%/obufsize.h", - "%U%/dobits.h", - "%U%/line_prefix.h", - }, - - command = { - "cd %out[1]:dirname% && %in[1]% %in[2]%" - }, - - file (d.."make.hfiles"), - file (d.."Parameters") -} - -local lpars = LLgen { - simple { - outputs = {"%U%/tokenfile.g"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - file (d.."make.tokfile"), - file (d.."tokenname.c") - }, - file (d.."expression.g") -} - - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - extract_parameters, - lpars - } -} - -tool_cpp = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."LLmessage.c"), - cfile_with_headers (d.."ch7bin.c"), - cfile_with_headers (d.."ch7mon.c"), - cfile_with_headers (d.."domacro.c"), - cfile_with_headers (d.."error.c"), - cfile_with_headers (d.."idf.c"), - cfile_with_headers (d.."init.c"), - cfile_with_headers (d.."input.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."options.c"), - cfile_with_headers (d.."preprocess.c"), - cfile_with_headers (d.."replace.c"), - cfile_with_headers (d.."scan.c"), - cfile_with_headers (d.."skip.c"), - cfile_with_headers (d.."tokenname.c"), - cfile_with_headers (d.."next.c"), - cfile_with_headers (d.."expr.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-symbol2str.c"}, - command = { - "%in[1]% < %in[2]% > %out[1]%" - }, - - file (d.."make.tokcase"), - file (d.."tokenname.c") - } - }, - - cfile_with_headers { - CINCLUDES = {PARENT, d}, - tabgen (d.."char.tab") - }, - - lib_assert, - lib_print, - lib_alloc, - lib_system, - lib_string, - - outputs = {"%U%/cpp"}, - install = { - pm.install("%BINDIR%%PLATDEP%/cpp"), - pm.install(d.."cpp.6", "%BINDIR%man/man6/cpp.6") - } -} - --- Revision history --- $Log$ --- Revision 1.4 2006-10-15 00:28:11 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.3 2006/07/22 20:58:27 dtrg --- cpp now gets installed in the right place. --- --- Revision 1.2 2006/07/22 12:27:31 dtrg --- Removed a huge, ancient comment dating from the genmake days. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. diff --git a/util/cpp/replace.c b/util/cpp/replace.c index 923b2c902..1951e1bda 100644 --- a/util/cpp/replace.c +++ b/util/cpp/replace.c @@ -61,7 +61,7 @@ replace(idef) return 0; } if (++mac->mc_count > 100) { - /* 100 must be some number in Parameters */ + /* 100 must be some number in parameters.h */ warning("macro %s is assumed recursive", idef->id_text); return 0; diff --git a/util/data/.distr b/util/data/.distr deleted file mode 100644 index 238202998..000000000 --- a/util/data/.distr +++ /dev/null @@ -1,3 +0,0 @@ -pmfile -em_ptyp.c -new_table diff --git a/util/data/pmfile b/util/data/pmfile deleted file mode 100644 index df7544415..000000000 --- a/util/data/pmfile +++ /dev/null @@ -1,57 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/data/" - -local datafiles = simple { - outputs = { - "%U%/em_spec.h", - "%U%/em_pseu.h", - "%U%/em_mnem.h", - "%U%/em_flag.c", - "%U%/em_pseu.c", - "%U%/em_mnem.c" - }, - - command = { - "%in[1]% %in[2]% %out[1]:dirname% %out[1]:dirname%" - }, - - install = { - pm.install("%U%/em_spec.h", "%HEADERDIR%em_spec.h"), - pm.install("%U%/em_pseu.h", "%HEADERDIR%em_pseu.h"), - pm.install("%U%/em_mnem.h", "%HEADERDIR%em_mnem.h") - }, - - file (d.."new_table"), - file ("%ROOTDIR%h/em_table"), -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - datafiles, - } -} - -module_em_data = clibrary { - cfile_with_headers (d.."em_ptyp.c"), - foreach { - rule = cfile_with_headers, - ith { datafiles, from=4 } - }, - - outputs = {"%U%/libem_data.a"}, - install = pm.install("%LIBDIR%libem_data.a") -} - -lib_em_data = file "%LIBDIR%libem_data.a" - --- Revision history --- $Log$ --- Revision 1.2 2007-02-25 12:49:04 dtrg --- new_table is now in /util/data, not /etc. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. --- diff --git a/util/data/proto.make b/util/data/proto.make deleted file mode 100644 index 35f0bf8d6..000000000 --- a/util/data/proto.make +++ /dev/null @@ -1,49 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/data -OBJ = em_mnem.$(SUF) em_pseu.$(SUF) em_flag.$(SUF) em_ptyp.$(SUF) - -DATA_PATH = em_data.$(LIBSUF) - -INCLUDES = -I$(TARGET_HOME)/h -CFLAGS = $(COPTIONS) $(INCLUDES) - -$(DATA_PATH): $(OBJ) - $(AR) rv $(DATA_PATH) $(OBJ) - $(RANLIB) $(DATA_PATH) - -install: $(DATA_PATH) - cp $(DATA_PATH) $(TARGET_HOME)/lib.bin/$(DATA_PATH) - $(RANLIB) $(TARGET_HOME)/lib.bin/$(DATA_PATH) - - -cmp: $(DATA_PATH) - -cmp $(DATA_PATH) $(TARGET_HOME)/lib.bin/$(DATA_PATH) - -clean: - rm -f $(OBJ) $(DATA_PATH) *.old - -opr: - make pr ^ opr - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/em_mnem.c $(SRC_DIR)/em_pseu.c $(SRC_DIR)/em_flag.c $(SRC_DIR)/em_ptyp.c - -em_flag.$(SUF): $(SRC_DIR)/em_flag.c $(TARGET_HOME)/h/em_flag.h - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_flag.c - -em_mnem.$(SUF): $(SRC_DIR)/em_mnem.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_mnem.c - -em_pseu.$(SUF): $(SRC_DIR)/em_pseu.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_pseu.c - -em_ptyp.$(SUF): $(SRC_DIR)/em_ptyp.c $(TARGET_HOME)/h/em_spec.h $(TARGET_HOME)/h/em_ptyp.h - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_ptyp.c - -lintlib: - $(MK_LINT_LIB) em_data $(TARGET_HOME)/lib.bin $(INCLUDES) \ - $(SRC_DIR)/em_flag.c $(SRC_DIR)/em_mnem.c \ - $(SRC_DIR)/em_pseu.c $(SRC_DIR)/em_ptyp.c diff --git a/util/ego/.distr b/util/ego/.distr deleted file mode 100644 index 49f46d9aa..000000000 --- a/util/ego/.distr +++ /dev/null @@ -1,16 +0,0 @@ -pmfile -bo -ca -cf -cj -cs -descr -em_ego -ic -il -lv -ra -share -sp -sr -ud diff --git a/util/ego/bo/.distr b/util/ego/bo/.distr deleted file mode 100644 index 717995eb9..000000000 --- a/util/ego/bo/.distr +++ /dev/null @@ -1 +0,0 @@ -bo.c diff --git a/util/ego/bo/proto.make b/util/ego/bo/proto.make deleted file mode 100644 index 214015a99..000000000 --- a/util/ego/bo/proto.make +++ /dev/null @@ -1,77 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/bo -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/bo.c - -OFILES=\ -bo.$(SUF) - -HFILES= - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: bo - -bo: $(OFILES) - $(CC) -o bo $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp bo $(EMLIB)/ego/bo - -cmp: all - -cmp bo $(EMLIB)/ego/bo - -clean: - rm -f *.$(SUF) bo Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -bo.$(SUF): $(SRC_DIR)/bo.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/bo.c -bo.$(SUF): $(SRC_DIR)/../share/go.h -bo.$(SUF): $(SRC_DIR)/../share/def.h -bo.$(SUF): $(SRC_DIR)/../share/aux.h -bo.$(SUF): $(SRC_DIR)/../share/alloc.h -bo.$(SUF): $(SRC_DIR)/../share/map.h -bo.$(SUF): $(SRC_DIR)/../share/lset.h -bo.$(SUF): $(SRC_DIR)/../share/put.h -bo.$(SUF): $(SRC_DIR)/../share/get.h -bo.$(SUF): $(SRC_DIR)/../share/files.h -bo.$(SUF): $(SRC_DIR)/../share/global.h -bo.$(SUF): $(SRC_DIR)/../share/debug.h -bo.$(SUF): $(SRC_DIR)/../share/types.h -bo.$(SUF): $(EMH)/em_flag.h -bo.$(SUF): $(EMH)/em_spec.h -bo.$(SUF): $(EMH)/em_pseu.h -bo.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/build.lua b/util/ego/build.lua new file mode 100644 index 000000000..864447550 --- /dev/null +++ b/util/ego/build.lua @@ -0,0 +1,58 @@ +local function build_ego(name) + cprogram { + name = name, + srcs = { "./"..name.."/*.c" }, + deps = { + "util/ego/share+lib", + "modules/src/em_data+lib", + "h+emheaders", + }, + vars = { + ["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"} + } + } +end + +build_ego("bo") +build_ego("ca") +build_ego("cf") +build_ego("cj") +build_ego("cs") +build_ego("ic") +build_ego("il") +build_ego("lv") +build_ego("sp") +build_ego("sr") +build_ego("ud") + +cprogram { + name = "em_ego", + srcs = { "./em_ego/em_ego.c" }, + deps = { + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + "modules+headers", + "h+emheaders", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_ego"] = "+em_ego", + ["$(PLATDEP)/ego/bo"] = "+bo", + ["$(PLATDEP)/ego/ca"] = "+ca", + ["$(PLATDEP)/ego/cf"] = "+cf", + ["$(PLATDEP)/ego/cj"] = "+cj", + ["$(PLATDEP)/ego/cs"] = "+cs", + ["$(PLATDEP)/ego/ic"] = "+ic", + ["$(PLATDEP)/ego/il"] = "+il", + ["$(PLATDEP)/ego/lv"] = "+lv", + ["$(PLATDEP)/ego/ra"] = "./ra+ra", + ["$(PLATDEP)/ego/sp"] = "+sp", + ["$(PLATDEP)/ego/sr"] = "+sr", + ["$(PLATDEP)/ego/ud"] = "+ud", + "./descr+pkg", + } +} diff --git a/util/ego/ca/.distr b/util/ego/ca/.distr deleted file mode 100644 index 4493273f6..000000000 --- a/util/ego/ca/.distr +++ /dev/null @@ -1,4 +0,0 @@ -ca.c -ca.h -ca_put.c -ca_put.h diff --git a/util/ego/ca/ca.c b/util/ego/ca/ca.c index 9b22599e3..acfba4829 100644 --- a/util/ego/ca/ca.c +++ b/util/ego/ca/ca.c @@ -8,7 +8,6 @@ * */ - #include #include #include @@ -25,26 +24,22 @@ #include "../share/get.h" #include "ca_put.h" - /* This phase transforms the Intermediate Code of the global optimizer * to 'standard' compact assembly language, which will be processed * by the code generator. */ +short dlength; +dblock_p* dmap; -short dlength; -dblock_p *dmap; - -char **dnames, **pnames; /* Dynamically allocated arrays of strings. +char** dnames, **pnames; /* Dynamically allocated arrays of strings. * pnames[i] contains a pointer to the name * of the procedure with proc_id i. */ - - -STATIC line_p get_ca_lines(lf,p_out) - FILE *lf; - proc_p *p_out; +STATIC line_p get_ca_lines(lf, p_out) + FILE* lf; +proc_p* p_out; { /* Read lines of EM text and link them. * Register messages are outputted immediately after the PRO. @@ -57,35 +52,46 @@ STATIC line_p get_ca_lines(lf,p_out) curinp = lf; /* EM input file */ pp = &head; mp = &headm; - headm = (line_p) 0; - while (TRUE) { + headm = (line_p)0; + while (TRUE) + { l = read_line(p_out); - if (feof(curinp)) break; - assert (l != (line_p) 0); - if (INSTR(l) == ps_end && INSTR(head) != ps_pro) { + if (feof(curinp)) + break; + assert(l != (line_p)0); + if (INSTR(l) == ps_end && INSTR(head) != ps_pro) + { /* Delete end pseudo after data-unit */ oldline(l); break; } - if (INSTR(l) == ps_mes && l->l_a.la_arg->a_a.a_offset == ms_reg) { + if (INSTR(l) == ps_mes && l->l_a.la_arg->a_a.a_offset == ms_reg) + { /* l is a register message */ - if (l->l_a.la_arg->a_next == (arg_p) 0) { + if (l->l_a.la_arg->a_next == (arg_p)0) + { /* register message without arguments */ oldline(l); - } else { + } + else + { *mp = l; mp = &l->l_next; } - } else { + } + else + { *pp = l; pp = &l->l_next; } - if (INSTR(l) == ps_end) { + if (INSTR(l) == ps_end) + { break; } } - *pp = (line_p) 0; - if (head != (line_p) 0 && INSTR(head) == ps_pro) { + *pp = (line_p)0; + if (head != (line_p)0 && INSTR(head) == ps_pro) + { /* append register message without arguments to list */ l = newline(OPLIST); l->l_instr = ps_mes; @@ -94,14 +100,16 @@ STATIC line_p get_ca_lines(lf,p_out) *mp = l; l->l_next = head->l_next; head->l_next = headm; - } else { - assert(headm == (line_p) 0); + } + else + { + assert(headm == (line_p)0); } return head; } STATIC int makedmap(dbl) - dblock_p dbl; + dblock_p dbl; { /* construct the dmap table */ @@ -111,76 +119,75 @@ STATIC int makedmap(dbl) /* determine the length of the table */ cnt = 0; - for (d = dbl; d != (dblock_p) 0; d = d->d_next) cnt++; - dmap = (dblock_p *) newmap(cnt); - for (d = dbl; d != (dblock_p) 0; d = d->d_next) { + for (d = dbl; d != (dblock_p)0; d = d->d_next) + cnt++; + dmap = (dblock_p*)newmap(cnt); + for (d = dbl; d != (dblock_p)0; d = d->d_next) + { assert(d->d_id <= cnt); dmap[d->d_id] = d; } return cnt; } - - STATIC getdnames(dumpd) - FILE *dumpd; + FILE* dumpd; { /* Read the names of the datalabels from * the dump file. */ - char str[IDL+1]; + char str[IDL + 1]; int id; - dnames = (char **) newmap(dlength); - for (;;) { - if (fscanf(dumpd,"%d %s",&id,str) == EOF) return; + dnames = (char**)newmap(dlength); + for (;;) + { + if (fscanf(dumpd, "%d %s", &id, str) == EOF) + return; assert(id <= dlength); - dnames[id] = (char *) newcore(strlen(str)+1); + dnames[id] = (char*)newcore(strlen(str) + 1); strcpy(dnames[id], str); } } STATIC getpnames(dumpp) - FILE *dumpp; + FILE* dumpp; { /* Read the names of the procedures from * the dump file. */ - char str[IDL+1]; + char str[IDL + 1]; int id; - pnames = (char **) newmap(plength); - for (;;) { - if (fscanf(dumpp,"%d %s",&id,str) == EOF) return; + pnames = (char**)newmap(plength); + for (;;) + { + if (fscanf(dumpp, "%d %s", &id, str) == EOF) + return; assert(id <= plength); - pnames[id] = (char *) newcore(strlen(str)+1); + pnames[id] = (char*)newcore(strlen(str) + 1); strcpy(pnames[id], str); } } - - -STATIC new_name(s) - char **s; +STATIC new_name(s) char** s; { static int nn = 0; char buf[20]; int len = strlen(*s); - oldcore(*s, len+1); + oldcore(*s, len + 1); buf[0] = '_'; buf[1] = 'I'; buf[2] = 'I'; - sprintf(&buf[3],"%d",nn); + sprintf(&buf[3], "%d", nn); nn++; - *s = (char *) newcore(strlen(buf)+1); + *s = (char*)newcore(strlen(buf) + 1); strcpy(*s, buf); } - - STATIC uniq_names() { /* The names of all internal procedures and data blocks @@ -193,46 +200,75 @@ STATIC uniq_names() proc_p p; dblock_p d; - for (p = fproc; p != (proc_p) 0; p = p->p_next) { - if (!(p->p_flags1 & PF_EXTERNAL)) { + for (p = fproc; p != (proc_p)0; p = p->p_next) + { + if (!(p->p_flags1 & PF_EXTERNAL)) + { new_name(&(pnames[p->p_id])); } } - for (d = fdblock; d != (dblock_p) 0; d = d->d_next) { - if (!(d->d_flags1 & DF_EXTERNAL) && dnames[d->d_id]) { + for (d = fdblock; d != (dblock_p)0; d = d->d_next) + { + if (!(d->d_flags1 & DF_EXTERNAL) && dnames[d->d_id]) + { new_name(&(dnames[d->d_id])); } } } - -main(argc,argv) - int argc; - char *argv[]; +main(argc, argv) int argc; +char* argv[]; { /* CA does not output proctable etc. files. Instead, its - * pname2 and dname2 arguments contain the names of the + * pname_out and dname_out arguments contain the names of the * dump files created by IC. */ - FILE *f, *f2; /* The EM input and output. */ - FILE *df, *pf; /* The dump files */ + struct files* files = findfiles(argc, argv); + + FILE* f, *f2; /* The EM input and output. */ + FILE* df, *pf; /* The dump files */ line_p lnp; - fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + /* The names of the input files of every phase are passed as + * arguments to the phase. First come the input file names, + * then the output file names. We use a one-letter convention + * to denote the type of file: + * p: procedure table file + * d: data table file + * l: EM text file (lines of EM instructions) + * b: basic block file (Control Flow Graph file) + */ + + /* The input file names */ + + char* pname_in = argv[1]; + char* dname_in = argv[2]; + char* lname_in = argv[3]; + char* bname_in = argv[4]; + + /* The output file names */ + + char* pname_out = argv[5]; + char* dname_out = argv[6]; + char* lname_out = argv[7]; + char* bname_out = argv[8]; + + fproc = getptable(pname_in); /* proc table */ + fdblock = getdtable(dname_in); /* data block table */ dlength = makedmap(fdblock); /* allocate dmap table */ - df = openfile(dname2,"r"); + df = openfile(dname_out, "r"); getdnames(df); fclose(df); - pf = openfile(pname2,"r"); + pf = openfile(pname_out, "r"); getpnames(pf); fclose(pf); uniq_names(); - f = openfile(lname,"r"); + f = openfile(lname_in, "r"); f2 = stdout; cputmagic(f2); /* write magic number */ - while ((lnp = get_ca_lines(f,&curproc)) != (line_p) 0) { - cputlines(lnp,f2); + while ((lnp = get_ca_lines(f, &curproc)) != (line_p)0) + { + cputlines(lnp, f2); } fclose(f); fclose(f2); diff --git a/util/ego/ca/proto.make b/util/ego/ca/proto.make deleted file mode 100644 index 49986c9e8..000000000 --- a/util/ego/ca/proto.make +++ /dev/null @@ -1,89 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/ca -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/ca.c \ - $(SRC_DIR)/ca_put.c - -OFILES=\ -ca.$(SUF) ca_put.$(SUF) - -HFILES=\ - $(SRC_DIR)/ca.h \ - $(SRC_DIR)/ca_put.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: ca - -ca: $(OFILES) - $(CC) -o ca $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp ca $(EMLIB)/ego/ca - -cmp: all - -cmp ca $(EMLIB)/ego/ca - -clean: - rm -f *.$(SUF) ca Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -ca.$(SUF): $(SRC_DIR)/ca.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ca.c -ca.$(SUF): $(SRC_DIR)/ca_put.h -ca.$(SUF): $(SRC_DIR)/../share/get.h -ca.$(SUF): $(SRC_DIR)/../share/alloc.h -ca.$(SUF): $(SRC_DIR)/../share/map.h -ca.$(SUF): $(SRC_DIR)/../share/files.h -ca.$(SUF): $(SRC_DIR)/../share/lset.h -ca.$(SUF): $(SRC_DIR)/../share/global.h -ca.$(SUF): $(SRC_DIR)/../share/debug.h -ca.$(SUF): $(SRC_DIR)/ca.h -ca.$(SUF): $(SRC_DIR)/../share/types.h -ca.$(SUF): $(EMH)/em_mes.h -ca.$(SUF): $(EMH)/em_pseu.h -ca_put.$(SUF): $(SRC_DIR)/ca_put.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ca_put.c -ca_put.$(SUF): $(SRC_DIR)/../share/alloc.h -ca_put.$(SUF): $(SRC_DIR)/../share/map.h -ca_put.$(SUF): $(SRC_DIR)/../share/def.h -ca_put.$(SUF): $(SRC_DIR)/../share/debug.h -ca_put.$(SUF): $(SRC_DIR)/ca.h -ca_put.$(SUF): $(SRC_DIR)/../share/types.h -ca_put.$(SUF): $(EMH)/em_mes.h -ca_put.$(SUF): $(EMH)/em_flag.h -ca_put.$(SUF): $(EMH)/em_mnem.h -ca_put.$(SUF): $(EMH)/em_pseu.h -ca_put.$(SUF): $(EMH)/em_spec.h diff --git a/util/ego/cf/.distr b/util/ego/cf/.distr deleted file mode 100644 index ee48a1028..000000000 --- a/util/ego/cf/.distr +++ /dev/null @@ -1,8 +0,0 @@ -cf.c -cf.h -cf_idom.c -cf_idom.h -cf_loop.c -cf_loop.h -cf_succ.c -cf_succ.h diff --git a/util/ego/cf/cf.c b/util/ego/cf/cf.c index fe513ea8d..f695aa237 100644 --- a/util/ego/cf/cf.c +++ b/util/ego/cf/cf.c @@ -31,39 +31,37 @@ #include "cf_idom.h" #include "cf_loop.h" -#define newcfbx() (bext_p) newstruct(bext_cf) -#define oldcfbx(x) oldstruct(bext_cf,x) +#define newcfbx() (bext_p) newstruct(bext_cf) +#define oldcfbx(x) oldstruct(bext_cf, x) extern char em_flag[]; -STATIC cset lpi_set; /* set of procedures used in LPI instruction */ -STATIC cset cai_set; /* set of all procedures doing a CAI */ - +STATIC cset lpi_set; /* set of procedures used in LPI instruction */ +STATIC cset cai_set; /* set of all procedures doing a CAI */ /* The procedure getbblocks reads the EM textfile and * partitions every procedure into a number of basic blocks. */ -#define LABEL0 0 -#define LABEL 1 -#define NORMAL 2 -#define JUMP 3 -#define END 4 -#define AFTERPRO 5 -#define INIT 6 - +#define LABEL0 0 +#define LABEL 1 +#define NORMAL 2 +#define JUMP 3 +#define END 4 +#define AFTERPRO 5 +#define INIT 6 /* These global variables are used by getbblocks and nextblock. */ -STATIC bblock_p b, *bp; /* b is the current basic block, bp is +STATIC bblock_p b, *bp; /* b is the current basic block, bp is * the address where the next block has * to be linked. */ -STATIC line_p lnp, *lp; /* lnp is the current line, lp is +STATIC line_p lnp, *lp; /* lnp is the current line, lp is * the address where the next line * has to be linked. */ -STATIC short state; /* We use a finite state machine with the +STATIC short state; /* We use a finite state machine with the * following states: * LABEL0: after the first (successive) * instruction label. @@ -77,7 +75,6 @@ STATIC short state; /* We use a finite state machine with the * INIT: initial state */ - STATIC nextblock() { /* allocate a new basic block structure and @@ -94,40 +91,44 @@ STATIC nextblock() b->b_extend->bx_cf.bx_semi = 0; lp = &lnp->l_next; #ifdef TRACE - fprintf(stderr,"new basic block, id = %d\n",lastbid); + fprintf(stderr, "new basic block, id = %d\n", lastbid); #endif } - STATIC short kind(lnp) - line_p lnp; + line_p lnp; { /* determine if lnp is a label, branch, end or otherwise */ short instr; - byte flow; + byte flow; - if ((instr = INSTR(lnp)) == op_lab) return (short) LABEL; - if (instr == ps_end) return (short) END; - if (instr > sp_lmnem) return (short) NORMAL; /* pseudo */ - if ((flow = (em_flag[instr-sp_fmnem] & EM_FLO)) == FLO_C || - flow == FLO_T) return (short) JUMP; /* conditional/uncond. jump */ - return (short) NORMAL; + if ((instr = INSTR(lnp)) == op_lab) + return (short)LABEL; + if (instr == ps_end) + return (short)END; + if (instr > sp_lmnem) + return (short)NORMAL; /* pseudo */ + if ((flow = (em_flag[instr - sp_fmnem] & EM_FLO)) == FLO_C || flow == FLO_T) + return (short)JUMP; /* conditional/uncond. jump */ + return (short)NORMAL; } - STATIC line_p doread_line(p_out) - proc_p *p_out; + proc_p* p_out; { /* read a line, and check pseudos for procedure addresses */ register line_p lnp = read_line(p_out); - if (lnp && TYPE(lnp) == OPLIST && INSTR(lnp) != ps_mes) { + if (lnp && TYPE(lnp) == OPLIST && INSTR(lnp) != ps_mes) + { register arg_p arg = ARG(lnp); - - while (arg) { - if (arg->a_type == ARGPROC) { + + while (arg) + { + if (arg->a_type == ARGPROC) + { Cadd(arg->a_a.a_proc->p_id, &lpi_set); arg->a_a.a_proc->p_flags1 |= PF_LPI; } @@ -137,34 +138,36 @@ STATIC line_p doread_line(p_out) return lnp; } -STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) - FILE *fp; - short *kind_out; - short *n_out; - bblock_p *g_out; - line_p *l_out; +STATIC bool getbblocks(fp, kind_out, n_out, g_out, l_out) + FILE* fp; +short* kind_out; +short* n_out; +bblock_p* g_out; +line_p* l_out; { - bblock_p head = (bblock_p) 0; - line_p headl = (line_p) 0; + bblock_p head = (bblock_p)0; + line_p headl = (line_p)0; - curproc = (proc_p) 0; + curproc = (proc_p)0; /* curproc will get a value when we encounter a PRO pseudo. * If there is no such pseudo, we're reading only data * declarations or messages (outside any proc.). */ curinp = fp; - lastbid = (block_id) 0; /* block identier */ - state = INIT; /* initial state */ + lastbid = (block_id)0; /* block identier */ + state = INIT; /* initial state */ bp = &head; - for (;;) { + for (;;) + { #ifdef TRACE - fprintf(stderr,"state = %d\n",state); + fprintf(stderr, "state = %d\n", state); #endif - switch(state) { + switch (state) + { case LABEL0: nextblock(); - /* Fall through !! */ + /* Fall through !! */ case LABEL: lbmap[INSTRLAB(lnp)] = b; /* The lbmap table contains for each @@ -172,21 +175,26 @@ STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) */ lnp = doread_line(&curproc); state = kind(lnp); - if (state != END) { + if (state != END) + { *lp = lnp; lp = &lnp->l_next; } break; case NORMAL: lnp = doread_line(&curproc); - if ( (state = kind(lnp)) == LABEL) { + if ((state = kind(lnp)) == LABEL) + { /* If we come accross a label * here, it must be the beginning * of a new basic block. */ state = LABEL0; - } else { - if (state != END) { + } + else + { + if (state != END) + { *lp = lnp; lp = &lnp->l_next; } @@ -194,9 +202,10 @@ STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) break; case JUMP: lnp = doread_line(&curproc); - /* fall through ... */ + /* fall through ... */ case AFTERPRO: - switch(state = kind(lnp)) { + switch (state = kind(lnp)) + { case LABEL: state = LABEL0; break; @@ -209,24 +218,31 @@ STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) case END: *lp = lnp; #ifdef TRACE - fprintf(stderr,"at end of proc, %d blocks\n",lastbid); + fprintf(stderr, "at end of proc, %d blocks\n", lastbid); #endif - if (head == (bblock_p) 0) { + if (head == (bblock_p)0) + { *kind_out = LDATA; *l_out = headl; - } else { + } + else + { *kind_out = LTEXT; *g_out = head; - *n_out = (short) lastbid; + *n_out = (short)lastbid; /* number of basic blocks */ } return TRUE; case INIT: lnp = doread_line(&curproc); - if (feof(curinp)) return FALSE; - if (INSTR(lnp) == ps_pro) { + if (feof(curinp)) + return FALSE; + if (INSTR(lnp) == ps_pro) + { state = AFTERPRO; - } else { + } + else + { state = NORMAL; headl = lnp; lp = &lnp->l_next; @@ -236,9 +252,8 @@ STATIC bool getbblocks(fp,kind_out,n_out,g_out,l_out) } } - STATIC interproc_analysis(p) - proc_p p; + proc_p p; { /* Interprocedural analysis of a procedure p determines: * - all procedures called by p (the 'call graph') @@ -255,7 +270,7 @@ STATIC interproc_analysis(p) */ bblock_p b; - line_p lnp; + line_p lnp; bool inloop; /* Allocate memory for structs and sets */ @@ -265,85 +280,90 @@ STATIC interproc_analysis(p) p->p_change->c_ext = Cempty_set(olength); p->p_calling = Cempty_set(plength); - for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) { - inloop = (Lnrelems(b->b_loops) > 0); - for (lnp = b->b_start; lnp != (line_p) 0; lnp = lnp->l_next) { - /* for all instructions of p do */ - switch(INSTR(lnp)) { - case op_cal: - Cadd(PROC(lnp)->p_id, &p->p_calling); - /* add called proc to p_calling */ - if (inloop) { - CALLED_IN_LOOP(PROC(lnp)); - } - break; - case op_cai: - Cadd(p->p_id,&cai_set); - break; - case op_lpi: - Cadd(PROC(lnp)->p_id, &lpi_set); - /* All procedures that have their names used + for (b = p->p_start; b != (bblock_p)0; b = b->b_next) + { + inloop = (Lnrelems(b->b_loops) > 0); + for (lnp = b->b_start; lnp != (line_p)0; lnp = lnp->l_next) + { + /* for all instructions of p do */ + switch (INSTR(lnp)) + { + case op_cal: + Cadd(PROC(lnp)->p_id, &p->p_calling); + /* add called proc to p_calling */ + if (inloop) + { + CALLED_IN_LOOP(PROC(lnp)); + } + break; + case op_cai: + Cadd(p->p_id, &cai_set); + break; + case op_lpi: + Cadd(PROC(lnp)->p_id, &lpi_set); + /* All procedures that have their names used * in an lpi instruction, may be called via * a cai instruction. */ - PROC(lnp)->p_flags1 |= PF_LPI; - break; - case op_ste: - case op_sde: - case op_ine: - case op_dee: - case op_zre: - Cadd(OBJ(lnp)->o_id, &p->p_change->c_ext); - /* Add changed object to c_ext */ - break; - case op_lil: - case op_lof: - case op_loi: - case op_los: - case op_lar: - p->p_use->u_flags |= UF_INDIR; - /* p does a load-indirect */ - break; - case op_sil: - case op_stf: - case op_sti: - case op_sts: - case op_sar: - p->p_change->c_flags |= CF_INDIR; - /* p does a store-indirect */ - break; - case op_blm: - case op_bls: - p->p_use->u_flags |= UF_INDIR; - p->p_change->c_flags |= CF_INDIR; - /* p does both */ - break; - case op_mon: - printf("mon not yet implemented\n"); - break; - case op_lxl: - case op_lxa: - curproc->p_flags1 |= PF_ENVIRON; - break; - case op_lor: - case op_str: - if (SHORT(lnp) == 0) { - curproc->p_flags1 |= PF_ENVIRON; + PROC(lnp)->p_flags1 |= PF_LPI; + break; + case op_ste: + case op_sde: + case op_ine: + case op_dee: + case op_zre: + Cadd(OBJ(lnp)->o_id, &p->p_change->c_ext); + /* Add changed object to c_ext */ + break; + case op_lil: + case op_lof: + case op_loi: + case op_los: + case op_lar: + p->p_use->u_flags |= UF_INDIR; + /* p does a load-indirect */ + break; + case op_sil: + case op_stf: + case op_sti: + case op_sts: + case op_sar: + p->p_change->c_flags |= CF_INDIR; + /* p does a store-indirect */ + break; + case op_blm: + case op_bls: + p->p_use->u_flags |= UF_INDIR; + p->p_change->c_flags |= CF_INDIR; + /* p does both */ + break; + case op_mon: + printf("mon not yet implemented\n"); + break; + case op_lxl: + case op_lxa: + curproc->p_flags1 |= PF_ENVIRON; + break; + case op_lor: + case op_str: + if (SHORT(lnp) == 0) + { + curproc->p_flags1 |= PF_ENVIRON; + } + break; + case ps_mes: + if (aoff(ARG(lnp), 0) == ms_gto) + { + ENTERED_WITH_GTO(curproc); + } + break; } - break; - case ps_mes: - if (aoff(ARG(lnp),0) == ms_gto) { - ENTERED_WITH_GTO(curproc); - } - break; } - } } } - STATIC cf_cleanproc(p) - proc_p p; + proc_p p; { /* Remove the extended data structures of p */ @@ -351,26 +371,26 @@ STATIC cf_cleanproc(p) register Lindex pi; loop_p lp; - for (b = p->p_start; b != (bblock_p) 0; b = b->b_next) { + for (b = p->p_start; b != (bblock_p)0; b = b->b_next) + { oldcfbx(b->b_extend); } - for (pi = Lfirst(p->p_loops); pi != (Lindex) 0; pi = Lnext(pi, - p->p_loops)) { - lp = (loop_p) Lelem(pi); + for (pi = Lfirst(p->p_loops); pi != (Lindex)0; pi = Lnext(pi, + p->p_loops)) + { + lp = (loop_p)Lelem(pi); oldcflpx(lp->lp_extend); } } +#define CH_CHANGE_INDIR(ch) ((ch->c_flags & CF_INDIR) != 0) +#define USE_INDIR(us) ((us->u_flags & UF_INDIR) != 0) +#define CALLS_UNKNOWN(p) (p->p_flags1 & (byte)PF_CALUNKNOWN) +#define ENVIRON(p) (p->p_flags1 & (byte)PF_ENVIRON) - -#define CH_CHANGE_INDIR(ch) ((ch->c_flags & CF_INDIR) != 0) -#define USE_INDIR(us) ((us->u_flags & UF_INDIR) != 0) -#define CALLS_UNKNOWN(p) (p->p_flags1 & (byte) PF_CALUNKNOWN) -#define ENVIRON(p) (p->p_flags1 & (byte) PF_ENVIRON) - - -STATIC bool add_info(q,p) - proc_p q,p; +STATIC bool add_info(q, p) + proc_p q, + p; { /* Determine the consequences for used/changed variables info * of the fact that p calls q. If e.g. q changes a variable X @@ -381,40 +401,48 @@ STATIC bool add_info(q,p) */ change_p chp, chq; - use_p usp, usq; - bool diff = FALSE; + use_p usp, usq; + bool diff = FALSE; chp = p->p_change; chq = q->p_change; usp = p->p_use; usq = q->p_use; - if (!BODY_KNOWN(q)) { + if (!BODY_KNOWN(q)) + { /* q is a procedure of which the body is not available * as EM text. */ - if (CALLS_UNKNOWN(p)) { + if (CALLS_UNKNOWN(p)) + { return FALSE; /* p already called an unknown procedure */ - } else { + } + else + { p->p_flags1 |= PF_CALUNKNOWN; return TRUE; } } - if (CALLS_UNKNOWN(q)) { + if (CALLS_UNKNOWN(q)) + { /* q calls a procedure of which the body is not available * as EM text. */ - if (!CALLS_UNKNOWN(p)) { + if (!CALLS_UNKNOWN(p)) + { p->p_flags1 |= PF_CALUNKNOWN; diff = TRUE; } } - if (IS_CALLED_IN_LOOP(p) && !IS_CALLED_IN_LOOP(q)) { + if (IS_CALLED_IN_LOOP(p) && !IS_CALLED_IN_LOOP(q)) + { CALLED_IN_LOOP(q); diff = TRUE; } - if (!Cis_subset(chq->c_ext, chp->c_ext)) { + if (!Cis_subset(chq->c_ext, chp->c_ext)) + { /* q changes global variables (objects) that * p did not (yet) change. Add all variables * changed by q to the c_ext set of p. @@ -422,21 +450,24 @@ STATIC bool add_info(q,p) Cjoin(chq->c_ext, &chp->c_ext); diff = TRUE; } - if (CH_CHANGE_INDIR(chq) && !CH_CHANGE_INDIR(chp)) { + if (CH_CHANGE_INDIR(chq) && !CH_CHANGE_INDIR(chp)) + { /* q does a change-indirect (sil etc.) * and p did not (yet). */ chp->c_flags |= CF_INDIR; diff = TRUE; } - if (USE_INDIR(usq) && !USE_INDIR(usp)) { + if (USE_INDIR(usq) && !USE_INDIR(usp)) + { /* q does a use-indirect (lil etc.) * and p dis not (yet). */ usp->u_flags |= UF_INDIR; diff = TRUE; } - if (ENVIRON(q) && !ENVIRON(p)) { + if (ENVIRON(q) && !ENVIRON(p)) + { /* q uses or changes local variables in its * environment while p does not (yet). */ @@ -446,94 +477,123 @@ STATIC bool add_info(q,p) return diff; } - - STATIC trans_clos(head) - proc_p head; + proc_p head; { /* Compute the transitive closure of the used/changed * variable information. */ - register proc_p p,q; + register proc_p p, q; Cindex i; bool changes = TRUE; - while(changes) { + while (changes) + { changes = FALSE; - for (p = head; p != (proc_p) 0; p = p->p_next) { - if (!BODY_KNOWN(p)) continue; - for (i = Cfirst(p->p_calling); i != (Cindex) 0; - i = Cnext(i,p->p_calling)) { - q = pmap[Celem(i)]; - if (add_info(q,p)) { - changes = TRUE; + for (p = head; p != (proc_p)0; p = p->p_next) + { + if (!BODY_KNOWN(p)) + continue; + for (i = Cfirst(p->p_calling); i != (Cindex)0; + i = Cnext(i, p->p_calling)) + { + q = pmap[Celem(i)]; + if (add_info(q, p)) + { + changes = TRUE; + } } - } } } } - - - indir_calls() { Cindex i; proc_p p; - for (i = Cfirst(cai_set); i != (Cindex) 0; i = Cnext(i,cai_set)) { - p = pmap[Celem(i)]; /* p does a CAI */ + for (i = Cfirst(cai_set); i != (Cindex)0; i = Cnext(i, cai_set)) + { + p = pmap[Celem(i)]; /* p does a CAI */ Cjoin(lpi_set, &p->p_calling); } Cdeleteset(lpi_set); Cdeleteset(cai_set); } - - -main(argc,argv) - int argc; - char *argv[]; +main(argc, argv) int argc; +char* argv[]; { - FILE *f, *f2, *gf2; /* The EM input, EM output, basic block output */ + FILE* f, *f2, *gf2; /* The EM input, EM output, basic block output */ bblock_p g; short n, kind; line_p l; + /* The names of the input files of every phase are passed as + * arguments to the phase. First come the input file names, + * then the output file names. We use a one-letter convention + * to denote the type of file: + * p: procedure table file + * d: data table file + * l: EM text file (lines of EM instructions) + * b: basic block file (Control Flow Graph file) + */ + + /* The input file names */ + + char* pname_in = argv[1]; + char* dname_in = argv[2]; + char* lname_in = argv[3]; + char* bname_in = argv[4]; + + /* The output file names */ + + char* pname_out = argv[5]; + char* dname_out = argv[6]; + char* lname_out = argv[7]; + char* bname_out = argv[8]; + linecount = 0; - fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + fproc = getptable(pname_in); /* proc table */ + fdblock = getdtable(dname_in); /* data block table */ lpi_set = Cempty_set(plength); cai_set = Cempty_set(plength); - if ((f = fopen(lname,"r")) == NULL) { - error("cannot open %s", lname); + if ((f = fopen(lname_in, "r")) == NULL) + { + error("cannot open %s", lname_in); } - if ((f2 = fopen(lname2,"w")) == NULL) { - error("cannot open %s", lname2); + if ((f2 = fopen(lname_out, "w")) == NULL) + { + error("cannot open %s", lname_out); } - if ((gf2 = fopen(bname2,"w")) == NULL) { - error("cannot open %s",bname2); + if ((gf2 = fopen(bname_out, "w")) == NULL) + { + error("cannot open %s", bname_out); } - while (getbblocks(f,&kind,&n,&g,&l)) { + while (getbblocks(f, &kind, &n, &g, &l)) + { /* read EM text of one unit and * (if it is a procedure) * partition it into n basic blocks. */ - if (kind == LDATA) { - putunit(LDATA,(proc_p) 0,l,gf2,f2); - } else { + if (kind == LDATA) + { + putunit(LDATA, (proc_p)0, l, gf2, f2); + } + else + { curproc->p_start = g; /* The global variable curproc points to the * current procedure. It is set by getbblocks */ control_flow(g); /* compute pred and succ */ - dominators(g,n); /* compute immediate dominators */ + dominators(g, n); /* compute immediate dominators */ loop_detection(curproc); /* compute loops */ interproc_analysis(curproc); /* Interprocedural analysis */ cf_cleanproc(curproc); - putunit(LTEXT,curproc,(line_p) 0,gf2,f2); + putunit(LTEXT, curproc, (line_p)0, gf2, f2); /* output control flow graph + text */ } } @@ -545,13 +605,15 @@ main(argc,argv) /* Compute transitive closure of used/changed * variables information for every procedure. */ - if ((f = fopen(dname2,"w")) == NULL) { - error("cannot open %s",dname2); + if ((f = fopen(dname_out, "w")) == NULL) + { + error("cannot open %s", dname_out); } - putdtable(fdblock,f); - if ((f = fopen(pname2,"w")) == NULL) { - error("cannot open %s",pname2); + putdtable(fdblock, f); + if ((f = fopen(pname_out, "w")) == NULL) + { + error("cannot open %s", pname_out); } - putptable(fproc,f,TRUE); + putptable(fproc, f, TRUE); exit(0); } diff --git a/util/ego/cf/cf_loop.c b/util/ego/cf/cf_loop.c index 6f27288ce..c14bdba3f 100644 --- a/util/ego/cf/cf_loop.c +++ b/util/ego/cf/cf_loop.c @@ -9,6 +9,7 @@ */ +#include #include "../share/types.h" #include "../share/debug.h" #include "../share/lset.h" diff --git a/util/ego/cf/proto.make b/util/ego/cf/proto.make deleted file mode 100644 index e8d49eab1..000000000 --- a/util/ego/cf/proto.make +++ /dev/null @@ -1,117 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/cf -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/cf.c \ - $(SRC_DIR)/cf_succ.c \ - $(SRC_DIR)/cf_idom.c \ - $(SRC_DIR)/cf_loop.c - -OFILES=\ -cf.$(SUF) cf_succ.$(SUF) cf_idom.$(SUF) cf_loop.$(SUF) - -HFILES=\ - $(SRC_DIR)/cf.h \ - $(SRC_DIR)/cf_succ.h \ - $(SRC_DIR)/cf_idom.h \ - $(SRC_DIR)/cf_loop.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: cf - -cf: $(OFILES) - $(CC) -o cf $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp cf $(EMLIB)/ego/cf - -cmp: all - -cmp cf $(EMLIB)/ego/cf - -clean: - rm -f *.$(SUF) cf Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -cf.$(SUF): $(SRC_DIR)/cf.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cf.c -cf.$(SUF): $(SRC_DIR)/cf_loop.h -cf.$(SUF): $(SRC_DIR)/cf_idom.h -cf.$(SUF): $(SRC_DIR)/cf_succ.h -cf.$(SUF): $(SRC_DIR)/cf.h -cf.$(SUF): $(SRC_DIR)/../share/def.h -cf.$(SUF): $(SRC_DIR)/../share/put.h -cf.$(SUF): $(SRC_DIR)/../share/get.h -cf.$(SUF): $(SRC_DIR)/../share/cset.h -cf.$(SUF): $(SRC_DIR)/../share/lset.h -cf.$(SUF): $(SRC_DIR)/../share/alloc.h -cf.$(SUF): $(SRC_DIR)/../share/global.h -cf.$(SUF): $(SRC_DIR)/../share/files.h -cf.$(SUF): $(SRC_DIR)/../share/map.h -cf.$(SUF): $(SRC_DIR)/../share/debug.h -cf.$(SUF): $(SRC_DIR)/../share/types.h -cf.$(SUF): $(EMH)/em_mes.h -cf.$(SUF): $(EMH)/em_flag.h -cf.$(SUF): $(EMH)/em_spec.h -cf.$(SUF): $(EMH)/em_pseu.h -cf.$(SUF): $(EMH)/em_mnem.h -cf_succ.$(SUF): $(SRC_DIR)/cf_succ.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cf_succ.c -cf_succ.$(SUF): $(SRC_DIR)/../share/map.h -cf_succ.$(SUF): $(SRC_DIR)/cf.h -cf_succ.$(SUF): $(SRC_DIR)/../share/cset.h -cf_succ.$(SUF): $(SRC_DIR)/../share/lset.h -cf_succ.$(SUF): $(SRC_DIR)/../share/global.h -cf_succ.$(SUF): $(SRC_DIR)/../share/debug.h -cf_succ.$(SUF): $(SRC_DIR)/../share/def.h -cf_succ.$(SUF): $(SRC_DIR)/../share/types.h -cf_succ.$(SUF): $(EMH)/em_mnem.h -cf_succ.$(SUF): $(EMH)/em_flag.h -cf_succ.$(SUF): $(EMH)/em_pseu.h -cf_succ.$(SUF): $(EMH)/em_spec.h -cf_idom.$(SUF): $(SRC_DIR)/cf_idom.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cf_idom.c -cf_idom.$(SUF): $(SRC_DIR)/cf.h -cf_idom.$(SUF): $(SRC_DIR)/../share/alloc.h -cf_idom.$(SUF): $(SRC_DIR)/../share/lset.h -cf_idom.$(SUF): $(SRC_DIR)/../share/debug.h -cf_idom.$(SUF): $(SRC_DIR)/../share/types.h -cf_loop.$(SUF): $(SRC_DIR)/cf_loop.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cf_loop.c -cf_loop.$(SUF): $(SRC_DIR)/cf.h -cf_loop.$(SUF): $(SRC_DIR)/../share/aux.h -cf_loop.$(SUF): $(SRC_DIR)/../share/alloc.h -cf_loop.$(SUF): $(SRC_DIR)/../share/lset.h -cf_loop.$(SUF): $(SRC_DIR)/../share/debug.h -cf_loop.$(SUF): $(SRC_DIR)/../share/types.h diff --git a/util/ego/cj/.distr b/util/ego/cj/.distr deleted file mode 100644 index 9cf50ef85..000000000 --- a/util/ego/cj/.distr +++ /dev/null @@ -1 +0,0 @@ -cj.c diff --git a/util/ego/cj/proto.make b/util/ego/cj/proto.make deleted file mode 100644 index cb8e71bcd..000000000 --- a/util/ego/cj/proto.make +++ /dev/null @@ -1,76 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/cj -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/cj.c - -OFILES=\ -cj.$(SUF) - -HFILES= - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: cj - -cj: $(OFILES) - $(CC) -o cj $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp cj $(EMLIB)/ego/cj - -cmp: all - -cmp cj $(EMLIB)/ego/cj - -clean: - rm -f *.$(SUF) cj Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -cj.$(SUF): $(SRC_DIR)/cj.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cj.c -cj.$(SUF): $(SRC_DIR)/../share/go.h -cj.$(SUF): $(SRC_DIR)/../share/stack_chg.h -cj.$(SUF): $(SRC_DIR)/../share/def.h -cj.$(SUF): $(SRC_DIR)/../share/aux.h -cj.$(SUF): $(SRC_DIR)/../share/alloc.h -cj.$(SUF): $(SRC_DIR)/../share/map.h -cj.$(SUF): $(SRC_DIR)/../share/lset.h -cj.$(SUF): $(SRC_DIR)/../share/put.h -cj.$(SUF): $(SRC_DIR)/../share/get.h -cj.$(SUF): $(SRC_DIR)/../share/files.h -cj.$(SUF): $(SRC_DIR)/../share/global.h -cj.$(SUF): $(SRC_DIR)/../share/debug.h -cj.$(SUF): $(SRC_DIR)/../share/types.h -cj.$(SUF): $(EMH)/em_spec.h -cj.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/cs/.distr b/util/ego/cs/.distr deleted file mode 100644 index a364eaea8..000000000 --- a/util/ego/cs/.distr +++ /dev/null @@ -1,26 +0,0 @@ -cs.c -cs.h -cs_alloc.c -cs_alloc.h -cs_aux.c -cs_aux.h -cs_avail.c -cs_avail.h -cs_debug.c -cs_debug.h -cs_elim.c -cs_elim.h -cs_entity.c -cs_entity.h -cs_getent.c -cs_getent.h -cs_kill.c -cs_kill.h -cs_partit.c -cs_partit.h -cs_profit.c -cs_profit.h -cs_stack.c -cs_stack.h -cs_vnm.c -cs_vnm.h diff --git a/util/ego/cs/cs_alloc.c b/util/ego/cs/cs_alloc.c index f1cfe209d..6a1128286 100644 --- a/util/ego/cs/cs_alloc.c +++ b/util/ego/cs/cs_alloc.c @@ -3,6 +3,7 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ +#include #include "../share/types.h" #include "../share/alloc.h" #include "cs.h" diff --git a/util/ego/cs/proto.make b/util/ego/cs/proto.make deleted file mode 100644 index 0cfb537bc..000000000 --- a/util/ego/cs/proto.make +++ /dev/null @@ -1,251 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/cs -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/cs.c \ - $(SRC_DIR)/cs_alloc.c \ - $(SRC_DIR)/cs_aux.c \ - $(SRC_DIR)/cs_avail.c \ - $(SRC_DIR)/cs_debug.c \ - $(SRC_DIR)/cs_elim.c \ - $(SRC_DIR)/cs_entity.c \ - $(SRC_DIR)/cs_kill.c \ - $(SRC_DIR)/cs_partit.c \ - $(SRC_DIR)/cs_profit.c \ - $(SRC_DIR)/cs_getent.c \ - $(SRC_DIR)/cs_stack.c \ - $(SRC_DIR)/cs_vnm.c - -OFILES=\ - cs.$(SUF) \ - cs_alloc.$(SUF) \ - cs_aux.$(SUF) \ - cs_avail.$(SUF) \ - cs_debug.$(SUF) \ - cs_elim.$(SUF) \ - cs_entity.$(SUF) \ - cs_kill.$(SUF) \ - cs_partit.$(SUF) \ - cs_profit.$(SUF) \ - cs_getent.$(SUF) \ - cs_stack.$(SUF) \ - cs_vnm.$(SUF) - -HFILES=\ - $(SRC_DIR)/cs.h \ - $(SRC_DIR)/cs_alloc.h \ - $(SRC_DIR)/cs_aux.h \ - $(SRC_DIR)/cs_avail.h \ - $(SRC_DIR)/cs_debug.h \ - $(SRC_DIR)/cs_elim.h \ - $(SRC_DIR)/cs_entity.h \ - $(SRC_DIR)/cs_kill.h \ - $(SRC_DIR)/cs_partit.h \ - $(SRC_DIR)/cs_profit.h \ - $(SRC_DIR)/cs_getent.h \ - $(SRC_DIR)/cs_stack.h \ - $(SRC_DIR)/cs_vnm.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: cs - -cs: $(OFILES) - $(CC) -o cs $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp cs $(EMLIB)/ego/cs - -cmp: all - -cmp cs $(EMLIB)/ego/cs - -clean: - rm -f *.$(SUF) cs Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -cs.$(SUF): $(SRC_DIR)/cs.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs.c -cs.$(SUF): $(SRC_DIR)/cs_vnm.h -cs.$(SUF): $(SRC_DIR)/cs_stack.h -cs.$(SUF): $(SRC_DIR)/cs_profit.h -cs.$(SUF): $(SRC_DIR)/cs_entity.h -cs.$(SUF): $(SRC_DIR)/cs_elim.h -cs.$(SUF): $(SRC_DIR)/cs_debug.h -cs.$(SUF): $(SRC_DIR)/cs_avail.h -cs.$(SUF): $(SRC_DIR)/cs_aux.h -cs.$(SUF): $(SRC_DIR)/cs.h -cs.$(SUF): $(SRC_DIR)/../share/go.h -cs.$(SUF): $(SRC_DIR)/../share/debug.h -cs.$(SUF): $(SRC_DIR)/../share/lset.h -cs.$(SUF): $(SRC_DIR)/../share/types.h -cs_alloc.$(SUF): $(SRC_DIR)/cs_alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_alloc.c -cs_alloc.$(SUF): $(SRC_DIR)/cs.h -cs_alloc.$(SUF): $(SRC_DIR)/../share/alloc.h -cs_alloc.$(SUF): $(SRC_DIR)/../share/types.h -cs_aux.$(SUF): $(SRC_DIR)/cs_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_aux.c -cs_aux.$(SUF): $(SRC_DIR)/cs_entity.h -cs_aux.$(SUF): $(SRC_DIR)/cs.h -cs_aux.$(SUF): $(SRC_DIR)/../share/lset.h -cs_aux.$(SUF): $(SRC_DIR)/../share/global.h -cs_aux.$(SUF): $(SRC_DIR)/../share/aux.h -cs_aux.$(SUF): $(SRC_DIR)/../share/debug.h -cs_aux.$(SUF): $(SRC_DIR)/../share/types.h -cs_avail.$(SUF): $(SRC_DIR)/cs_avail.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_avail.c -cs_avail.$(SUF): $(SRC_DIR)/cs_getent.h -cs_avail.$(SUF): $(SRC_DIR)/cs_alloc.h -cs_avail.$(SUF): $(SRC_DIR)/cs_debug.h -cs_avail.$(SUF): $(SRC_DIR)/cs_aux.h -cs_avail.$(SUF): $(SRC_DIR)/cs.h -cs_avail.$(SUF): $(SRC_DIR)/../share/global.h -cs_avail.$(SUF): $(SRC_DIR)/../share/lset.h -cs_avail.$(SUF): $(SRC_DIR)/../share/aux.h -cs_avail.$(SUF): $(SRC_DIR)/../share/debug.h -cs_avail.$(SUF): $(SRC_DIR)/../share/types.h -cs_avail.$(SUF): $(EMH)/em_mnem.h -cs_debug.$(SUF): $(SRC_DIR)/cs_debug.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_debug.c -cs_debug.$(SUF): $(SRC_DIR)/cs_entity.h -cs_debug.$(SUF): $(SRC_DIR)/cs_avail.h -cs_debug.$(SUF): $(SRC_DIR)/cs_aux.h -cs_debug.$(SUF): $(SRC_DIR)/cs.h -cs_debug.$(SUF): $(SRC_DIR)/../share/lset.h -cs_debug.$(SUF): $(SRC_DIR)/../share/debug.h -cs_debug.$(SUF): $(SRC_DIR)/../share/types.h -cs_debug.$(SUF): $(EMH)/em_spec.h -cs_elim.$(SUF): $(SRC_DIR)/cs_elim.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_elim.c -cs_elim.$(SUF): $(SRC_DIR)/cs_partit.h -cs_elim.$(SUF): $(SRC_DIR)/cs_profit.h -cs_elim.$(SUF): $(SRC_DIR)/cs_debug.h -cs_elim.$(SUF): $(SRC_DIR)/cs_aux.h -cs_elim.$(SUF): $(SRC_DIR)/cs_alloc.h -cs_elim.$(SUF): $(SRC_DIR)/cs_avail.h -cs_elim.$(SUF): $(SRC_DIR)/cs.h -cs_elim.$(SUF): $(SRC_DIR)/../share/debug.h -cs_elim.$(SUF): $(SRC_DIR)/../share/global.h -cs_elim.$(SUF): $(SRC_DIR)/../share/aux.h -cs_elim.$(SUF): $(SRC_DIR)/../share/lset.h -cs_elim.$(SUF): $(SRC_DIR)/../share/alloc.h -cs_elim.$(SUF): $(SRC_DIR)/../share/types.h -cs_elim.$(SUF): $(EMH)/em_mnem.h -cs_elim.$(SUF): $(EMH)/em_reg.h -cs_entity.$(SUF): $(SRC_DIR)/cs_entity.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_entity.c -cs_entity.$(SUF): $(SRC_DIR)/cs_aux.h -cs_entity.$(SUF): $(SRC_DIR)/cs_alloc.h -cs_entity.$(SUF): $(SRC_DIR)/cs.h -cs_entity.$(SUF): $(SRC_DIR)/../share/debug.h -cs_entity.$(SUF): $(SRC_DIR)/../share/lset.h -cs_entity.$(SUF): $(SRC_DIR)/../share/global.h -cs_entity.$(SUF): $(SRC_DIR)/../share/types.h -cs_kill.$(SUF): $(SRC_DIR)/cs_kill.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_kill.c -cs_kill.$(SUF): $(SRC_DIR)/cs_entity.h -cs_kill.$(SUF): $(SRC_DIR)/cs_avail.h -cs_kill.$(SUF): $(SRC_DIR)/cs_debug.h -cs_kill.$(SUF): $(SRC_DIR)/cs_aux.h -cs_kill.$(SUF): $(SRC_DIR)/cs.h -cs_kill.$(SUF): $(SRC_DIR)/../share/map.h -cs_kill.$(SUF): $(SRC_DIR)/../share/aux.h -cs_kill.$(SUF): $(SRC_DIR)/../share/cset.h -cs_kill.$(SUF): $(SRC_DIR)/../share/lset.h -cs_kill.$(SUF): $(SRC_DIR)/../share/global.h -cs_kill.$(SUF): $(SRC_DIR)/../share/debug.h -cs_kill.$(SUF): $(SRC_DIR)/../share/types.h -cs_kill.$(SUF): $(EMH)/em_mnem.h -cs_partit.$(SUF): $(SRC_DIR)/cs_partit.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_partit.c -cs_partit.$(SUF): $(SRC_DIR)/cs_stack.h -cs_partit.$(SUF): $(SRC_DIR)/cs.h -cs_partit.$(SUF): $(SRC_DIR)/../share/global.h -cs_partit.$(SUF): $(SRC_DIR)/../share/debug.h -cs_partit.$(SUF): $(SRC_DIR)/../share/aux.h -cs_partit.$(SUF): $(SRC_DIR)/../share/types.h -cs_partit.$(SUF): $(EMH)/em_spec.h -cs_partit.$(SUF): $(EMH)/em_reg.h -cs_partit.$(SUF): $(EMH)/em_pseu.h -cs_partit.$(SUF): $(EMH)/em_mnem.h -cs_profit.$(SUF): $(SRC_DIR)/cs_profit.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_profit.c -cs_profit.$(SUF): $(SRC_DIR)/cs_partit.h -cs_profit.$(SUF): $(SRC_DIR)/cs_avail.h -cs_profit.$(SUF): $(SRC_DIR)/cs_debug.h -cs_profit.$(SUF): $(SRC_DIR)/cs_aux.h -cs_profit.$(SUF): $(SRC_DIR)/cs.h -cs_profit.$(SUF): $(SRC_DIR)/../share/lset.h -cs_profit.$(SUF): $(SRC_DIR)/../share/cset.h -cs_profit.$(SUF): $(SRC_DIR)/../share/aux.h -cs_profit.$(SUF): $(SRC_DIR)/../share/global.h -cs_profit.$(SUF): $(SRC_DIR)/../share/debug.h -cs_profit.$(SUF): $(SRC_DIR)/../share/types.h -cs_profit.$(SUF): $(EMH)/em_spec.h -cs_profit.$(SUF): $(EMH)/em_mnem.h -cs_getent.$(SUF): $(SRC_DIR)/cs_getent.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_getent.c -cs_getent.$(SUF): $(SRC_DIR)/cs_stack.h -cs_getent.$(SUF): $(SRC_DIR)/cs_entity.h -cs_getent.$(SUF): $(SRC_DIR)/cs_aux.h -cs_getent.$(SUF): $(SRC_DIR)/cs.h -cs_getent.$(SUF): $(SRC_DIR)/../share/global.h -cs_getent.$(SUF): $(SRC_DIR)/../share/debug.h -cs_getent.$(SUF): $(SRC_DIR)/../share/aux.h -cs_getent.$(SUF): $(SRC_DIR)/../share/types.h -cs_getent.$(SUF): $(EMH)/em_mnem.h -cs_stack.$(SUF): $(SRC_DIR)/cs_stack.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_stack.c -cs_stack.$(SUF): $(SRC_DIR)/cs_aux.h -cs_stack.$(SUF): $(SRC_DIR)/cs.h -cs_stack.$(SUF): $(SRC_DIR)/../share/aux.h -cs_stack.$(SUF): $(SRC_DIR)/../share/debug.h -cs_stack.$(SUF): $(SRC_DIR)/../share/global.h -cs_stack.$(SUF): $(SRC_DIR)/../share/types.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_vnm.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cs_vnm.c -cs_vnm.$(SUF): $(SRC_DIR)/cs_getent.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_partit.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_kill.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_stack.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_avail.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_entity.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_aux.h -cs_vnm.$(SUF): $(SRC_DIR)/cs_alloc.h -cs_vnm.$(SUF): $(SRC_DIR)/cs.h -cs_vnm.$(SUF): $(SRC_DIR)/../share/aux.h -cs_vnm.$(SUF): $(SRC_DIR)/../share/debug.h -cs_vnm.$(SUF): $(SRC_DIR)/../share/global.h -cs_vnm.$(SUF): $(SRC_DIR)/../share/types.h -cs_vnm.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/descr/.distr b/util/ego/descr/.distr deleted file mode 100644 index f7d566cd5..000000000 --- a/util/ego/descr/.distr +++ /dev/null @@ -1,12 +0,0 @@ -descr.sed -i86.descr -i386.descr -m68020.descr -m68k2.descr -m68k4.descr -pdp.descr -vax4.descr -em22.descr -em24.descr -em44.descr -sparc.descr diff --git a/util/ego/descr/build.lua b/util/ego/descr/build.lua new file mode 100644 index 000000000..034ffa3ce --- /dev/null +++ b/util/ego/descr/build.lua @@ -0,0 +1,30 @@ +local installmap = {} + +local function build_descr(name) + local descr = normalrule { + name = name, + ins = { + "lang/cem/cpp.ansi+cpp", + "./"..name..".descr", + "./descr.sed", + matching(filenamesof("modules/src/em_data+lib"), "em_mnem%.h$"), + }, + outleaves = { name..".descr" }, + commands = { + "%{ins[1]} -P -I%{dirname(ins[4])} %{ins[2]} > %{dir}/temp", + "sed -f %{ins[3]} < %{dir}/temp > %{outs}" + } + } + + installmap["$(PLATIND)/ego/"..name..".descr"] = descr +end + +build_descr("i386") +build_descr("i86") +build_descr("m68020") + +installable { + name = "pkg", + map = installmap +} + diff --git a/util/ego/descr/proto.make b/util/ego/descr/proto.make deleted file mode 100644 index 1a7c6b344..000000000 --- a/util/ego/descr/proto.make +++ /dev/null @@ -1,79 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/descr -CPP = $(UTIL_HOME)/lib.bin/cpp -EMH = $(TARGET_HOME)/h - -SOURCES = \ - $(SRC_DIR)/i86.descr \ - $(SRC_DIR)/i386.descr \ - $(SRC_DIR)/m68k2.descr \ - $(SRC_DIR)/pdp.descr \ - $(SRC_DIR)/vax4.descr \ - $(SRC_DIR)/m68k4.descr \ - $(SRC_DIR)/m68020.descr \ - $(SRC_DIR)/sparc.descr \ - $(SRC_DIR)/em22.descr \ - $(SRC_DIR)/em24.descr \ - $(SRC_DIR)/em44.descr - -TARGETS = i86descr m68k2descr vax4descr pdpdescr m68k4descr m68020descr \ - em22descr em24descr em44descr sparcdescr sparc_solarisdescr i386descr - -PRFILES = $(SRC_DIR)/proto.make $(SRC_DIR)/descr.sed $(SOURCES) - -all: $(TARGETS) - -install: all - for i in $(TARGETS) ; do cp $$i $(TARGET_HOME)/lib.bin/ego/$$i ; done - -cmp: all - -for i in $(TARGETS) ; do cmp $$i $(TARGET_HOME)/lib.bin/ego/$$i ; done - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -clean: - rm -f $(TARGETS) *.o Out out nohup.out - -i86descr: $(SRC_DIR)/i86.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/i86.descr | sed -f $(SRC_DIR)/descr.sed > i86descr - -pdpdescr: $(SRC_DIR)/pdp.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/pdp.descr | sed -f $(SRC_DIR)/descr.sed > pdpdescr - -m68k2descr: $(SRC_DIR)/m68k2.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/m68k2.descr | sed -f $(SRC_DIR)/descr.sed > m68k2descr - -m68k4descr: $(SRC_DIR)/m68k4.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/m68k4.descr | sed -f $(SRC_DIR)/descr.sed > m68k4descr - -m68020descr: $(SRC_DIR)/m68020.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/m68020.descr | sed -f $(SRC_DIR)/descr.sed > m68020descr - -vax4descr: $(SRC_DIR)/vax4.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/vax4.descr | sed -f $(SRC_DIR)/descr.sed > vax4descr - -em22descr: $(SRC_DIR)/em22.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/em22.descr | sed -f $(SRC_DIR)/descr.sed > em22descr - -em24descr: $(SRC_DIR)/em24.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/em24.descr | sed -f $(SRC_DIR)/descr.sed > em24descr - -em44descr: $(SRC_DIR)/em44.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/em44.descr | sed -f $(SRC_DIR)/descr.sed > em44descr - -sparcdescr: $(SRC_DIR)/sparc.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/sparc.descr | sed -f $(SRC_DIR)/descr.sed > sparcdescr - -sparc_solarisdescr: $(SRC_DIR)/sparc.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/sparc.descr | sed -f $(SRC_DIR)/descr.sed > sparc_solarisdescr - -i386descr: $(SRC_DIR)/i386.descr $(SRC_DIR)/descr.sed - $(CPP) -P -I$(EMH) $(SRC_DIR)/i386.descr | sed -f $(SRC_DIR)/descr.sed > i386descr - diff --git a/util/ego/em_ego/.distr b/util/ego/em_ego/.distr deleted file mode 100644 index 3a123f69d..000000000 --- a/util/ego/em_ego/.distr +++ /dev/null @@ -1 +0,0 @@ -em_ego.c diff --git a/util/ego/em_ego/em_ego.c b/util/ego/em_ego/em_ego.c index 9542b41e6..60a99ea5d 100644 --- a/util/ego/em_ego/em_ego.c +++ b/util/ego/em_ego/em_ego.c @@ -4,418 +4,444 @@ optimizer itself one day ... */ -#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include "em_path.h" +#include "system.h" +#include "print.h" -#define IC 1 -#define CF 2 -#define IL 3 -#define CS 4 -#define SR 5 -#define UD 6 -#define LV 7 -#define RA 8 -#define SP 9 -#define BO 10 -#define CJ 11 -#define CA 12 - -static char *phnames[] = { - 0, - "ic", - "cf", - "il", - "cs", - "sr", - "ud", - "lv", - "ra", - "sp", - "bo", - "cj", - "ca", - 0 +enum +{ + NONE = 0, + IC, + CF, + IL, + CS, + SR, + UD, + LV, + RA, + SP, + BO, + CJ, + CA }; -#define MAXUPHASES 64 /* max # of phases to be run */ -#define MAXARGS 1024 /* mar # of args */ -#define NTEMPS 4 /* # of temporary files; not tunable */ +static const struct +{ + const char* name; + bool needsdescr; -extern char *mktemp(); -extern char *strcpy(), *strcat(); -extern char *strrchr(); - -static char ddump[128] = TMP_DIR; /* data label dump file */ -static char pdump[128] = TMP_DIR; /* procedure name dump file */ -static char tmpbufs[NTEMPS*2][128] = { - TMP_DIR +} phase_data[] = { + {}, + { "ic" }, + { "cf" }, + { "il" }, + { "cs", true }, + { "sr" }, + { "ud", true }, + { "lv" }, + { "ra" }, + { "sp" }, + { "bo" }, + { "cj" }, + { "ca" }, }; -static int O2phases[] = { /* Passes for -O2 */ - CJ, BO, SP, 0 +#define MAXUPHASES 64 /* max # of phases to be run */ +#define MAXARGS 1024 /* mar # of args */ +#define NTEMPS 4 /* # of temporary files; not tunable */ + +extern char* mktemp(); +extern char* strcpy(), *strcat(); +extern char* strrchr(); + +static char ddump[128] = TMP_DIR; /* data label dump file */ +static char pdump[128] = TMP_DIR; /* procedure name dump file */ +static char tmpbufs[NTEMPS * 2][128] = { + TMP_DIR }; -static int O3phases[] = { /* Passes for -O3 */ - CS, SR, CJ, BO, SP, UD, LV, RA, 0 +static int O2phases[] = { /* Passes for -O2 */ + CJ, BO, SP, 0 }; -static int O4phases[] = { /* Passes for -O4 */ - IL, CF, CS, SR, CJ, BO, SP, UD, LV, RA, 0 +static int O3phases[] = { /* Passes for -O3 */ + CS, SR, CJ, BO, SP, UD, LV, RA, 0 }; -static int *Ophase = &O2phases[0]; /* default : -O2 */ +static int O4phases[] = { /* Passes for -O4 */ + IL, CF, CS, SR, CJ, BO, SP, UD, LV, RA, 0 +}; -static int nuphases; /* # of phases specified by user */ -static int uphases[MAXUPHASES+1]; /* phases to be run */ +static int* Ophase = &O2phases[0]; /* default : -O2 */ -static int nfiles = NTEMPS*2+1; /* leave space for tempfilenames */ -static char *phargs[MAXARGS+1]; +static int nuphases; /* # of phases specified by user */ +static int uphases[MAXUPHASES + 1]; /* phases to be run */ -static int keeptemps = 0; +static int nfiles = NTEMPS * 2 + 1; /* leave space for tempfilenames */ +static char* phargs[MAXARGS + 1]; -static char **phase_args; -static int nphase_args; +static int keeptemps = 0; -static char *opt_dir; -static char *prog_name; +static char** phase_args; +static int nphase_args; -static int v_flag; +static const char* descr_file; +static const char* opt_dir; +static const char* prog_name; + +static int v_flag; static void cleanup() { - /* Cleanup temporaries */ + /* Cleanup temporaries */ - if (! keeptemps) { - register int i; + if (!keeptemps) + { + register int i; - for (i = NTEMPS*2; i > 0; i--) { - register char *f = phargs[i]; - if (f != 0 && *f != '\0' && *f != '-') (void) unlink(f); + for (i = NTEMPS * 2; i > 0; i--) + { + const char* f = phargs[i]; + if (f != 0 && *f != '\0' && *f != '-') + (void)unlink(f); + } + if (ddump[0] != '\0') + (void)unlink(ddump); + if (pdump[0] != '\0') + (void)unlink(pdump); } - if (ddump[0] != '\0') (void) unlink(ddump); - if (pdump[0] != '\0') (void) unlink(pdump); - } } /*VARARGS1*/ static void -fatal(s, s2) - char *s; - char *s2; + fatal(s, s2) char* s; +char* s2; { - /* A fatal error occurred; exit gracefully */ + /* A fatal error occurred; exit gracefully */ - fprint(STDERR, "%s: ", prog_name); - fprint(STDERR, s, s2); - fprint(STDERR, "\n"); - cleanup(); - sys_stop(S_EXIT); - /*NOTREACHED*/ + fprint(STDERR, "%s: ", prog_name); + fprint(STDERR, s, s2); + fprint(STDERR, "\n"); + cleanup(); + sys_stop(S_EXIT); + /*NOTREACHED*/ } static void -add_file(s) - char *s; + add_file(s) char* s; { - /* Add an input file to the list */ + /* Add an input file to the list */ - if (nfiles >= MAXARGS) fatal("too many files"); - phargs[nfiles++] = s; + if (nfiles >= MAXARGS) + fatal("too many files"); + phargs[nfiles++] = s; } static void -add_uphase(p) - int p; + add_uphase(p) int p; { - /* Add an optimizer phase to the list of phases to run */ + /* Add an optimizer phase to the list of phases to run */ - if (nuphases >= MAXUPHASES) fatal("too many phases"); - uphases[nuphases++] = p; + if (nuphases >= MAXUPHASES) + fatal("too many phases"); + uphases[nuphases++] = p; } -static void -catch() +static void catch () { - /* Catch interrupts and exit gracefully */ + /* Catch interrupts and exit gracefully */ - cleanup(); - sys_stop(S_EXIT); + cleanup(); + sys_stop(S_EXIT); } static void old_infiles() { - /* Remove old input files unless we have to keep them around. */ + /* Remove old input files unless we have to keep them around. */ - register int i; + register int i; - if (phargs[1] == pdump || keeptemps) return; + if (phargs[1] == pdump || keeptemps) + return; - for (i = 1; i <= NTEMPS; i++) (void) unlink(phargs[i]); + for (i = 1; i <= NTEMPS; i++) + (void)unlink(phargs[i]); } static void get_infiles() { - /* Make output temps from previous phase input temps of next phase. */ + /* Make output temps from previous phase input temps of next phase. */ - register int i; - register char **dst = &phargs[1]; - register char **src = &phargs[NTEMPS+1]; + register int i; + char** dst = &phargs[1]; + char** src = &phargs[NTEMPS + 1]; - for (i = 1; i <= NTEMPS; i++) { - *dst++ = *src++; - } + for (i = 1; i <= NTEMPS; i++) + { + *dst++ = *src++; + } } static void new_outfiles() { - static int tmpindex = 0; - static int Bindex = 0; - static char dig1 = '1'; - static char dig2 = '0'; - register int i; - register char **dst = &phargs[NTEMPS+1]; + static int tmpindex = 0; + static int Bindex = 0; + static char dig1 = '1'; + static char dig2 = '0'; + register int i; + char** dst = &phargs[NTEMPS + 1]; - if (! Bindex) { - Bindex = strrchr(tmpbufs[0], 'B') - tmpbufs[0]; - } - for (i = 1; i <= NTEMPS; i++) { - *dst = tmpbufs[tmpindex]; - (*dst)[Bindex-1] = dig2; - (*dst)[Bindex] = dig1; - tmpindex++; - dst++; - } - if (tmpindex >= 2*NTEMPS) tmpindex = 0; - if (++dig1 > '9') { - ++dig2; - dig1 = '0'; - } + if (!Bindex) + { + Bindex = strrchr(tmpbufs[0], 'B') - tmpbufs[0]; + } + for (i = 1; i <= NTEMPS; i++) + { + *dst = tmpbufs[tmpindex]; + (*dst)[Bindex - 1] = dig2; + (*dst)[Bindex] = dig1; + tmpindex++; + dst++; + } + if (tmpindex >= 2 * NTEMPS) + tmpindex = 0; + if (++dig1 > '9') + { + ++dig2; + dig1 = '0'; + } } static void -run_phase(phase) - int phase; + run_phase(phase) int phase; { - /* Run one phase of the global optimizer; special cases are + /* Run one phase of the global optimizer; special cases are IC and CA. */ - static int flags_added; - register int argc; - register int i; - char buf[256]; - int pid, status; + static int flags_added; + register int argc; + register int i; + char buf[256]; + int pid, status; - phargs[0] = buf; - (void) strcpy(buf, opt_dir); - (void) strcat(buf, "/"); - (void) strcat(buf, phnames[phase]); + /* Skip this phase if it requires a descr file and one hasn't been + * provided. */ - switch(phase) { - case IC: - phargs[1] = pdump; - phargs[2] = ddump; - for (i = 3; i <= NTEMPS; i++) phargs[i] = "-"; - new_outfiles(); - argc = nfiles; - phargs[argc] = 0; - break; + if (phase_data[phase].needsdescr && !descr_file) + return; - case CA: - old_infiles(); - get_infiles(); - phargs[NTEMPS+1] = pdump; - phargs[NTEMPS+2] = ddump; - for (i = NTEMPS+3; i <= 2*NTEMPS; i++) phargs[i] = "-"; - argc = 2*NTEMPS+1; - phargs[argc] = 0; - break; + phargs[0] = buf; + (void)strcpy(buf, opt_dir); + (void)strcat(buf, "/"); + (void)strcat(buf, phase_data[phase].name); - default: - old_infiles(); - get_infiles(); - new_outfiles(); - if (! flags_added) { - flags_added = 1; - argc = 2*NTEMPS+1; - while (--nphase_args >= 0) { - phargs[argc++] = *phase_args++; + switch (phase) + { + case IC: + /* always first */ + phargs[1] = pdump; + phargs[2] = ddump; + for (i = 3; i <= NTEMPS; i++) + phargs[i] = "-"; + new_outfiles(); + argc = nfiles; + phargs[argc] = 0; + break; + + case CA: + /* always last */ + old_infiles(); + get_infiles(); + phargs[NTEMPS + 1] = pdump; + phargs[NTEMPS + 2] = ddump; + for (i = NTEMPS + 3; i <= 2 * NTEMPS; i++) + phargs[i] = "-"; + argc = 2 * NTEMPS + 1; + phargs[argc] = 0; + break; + + default: + { + old_infiles(); + get_infiles(); + new_outfiles(); + + argc = 2 * NTEMPS + 1; + if (descr_file) + { + phargs[argc++] = "-M"; + phargs[argc++] = descr_file; + } + + for (i=0; i> 8) & 0377) != 0) { - cleanup(); + (void)execv(phargs[0], phargs); + fatal("Could not exec %s", phargs[0]); sys_stop(S_EXIT); } - } -} - -main(argc, argv) - int argc; - char *argv[]; -{ - register int i = 0; - - if (signal(SIGHUP, catch) == SIG_IGN) (void) signal(SIGHUP, SIG_IGN); - if (signal(SIGQUIT, catch) == SIG_IGN) (void) signal(SIGQUIT, SIG_IGN); - if (signal(SIGINT, catch) == SIG_IGN) (void) signal(SIGINT, SIG_IGN); - prog_name = argv[0]; - phase_args = &argv[1]; - while (--argc > 0) { - argv++; - if (argv[0][0] == '-') { - switch(argv[0][1]) { - case 'P': - if (argv[0][2] == '\0') { - opt_dir = argv[1]; - argc--; - argv++; - continue; - } - break; - case 't': - if (argv[0][2] == '\0') { - keeptemps = 1; - /* no continue; IL also needs this */ - } - break; - case 'v': - v_flag = 1; - break; - case 'O': - if (argv[0][2] == '2' || argv[0][2] == '\0') continue; - if (argv[0][2] == '3') { - Ophase = &O3phases[0]; - continue; - } - Ophase = &O4phases[0]; - continue; - case 'I': - if (! strcmp(&argv[0][1], "IL")) { - add_uphase(IL); - add_uphase(CF); - continue; - } - break; - case 'B': - if (! strcmp(&argv[0][1], "BO")) { - add_uphase(BO); - continue; - } - break; - case 'R': - if (! strcmp(&argv[0][1], "RA")) { - add_uphase(RA); - continue; - } - break; - case 'U': - if (! strcmp(&argv[0][1], "UD")) { - add_uphase(UD); - continue; - } - break; - case 'L': - if (! strcmp(&argv[0][1], "LV")) { - add_uphase(LV); - continue; - } - break; - case 'C': - if (! strcmp(&argv[0][1], "CS")) { - add_uphase(CS); - continue; - } - if (! strcmp(&argv[0][1], "CJ")) { - add_uphase(CJ); - continue; - } - break; - case 'S': - if (! strcmp(&argv[0][1], "SR")) { - add_uphase(SR); - continue; - } - if (! strcmp(&argv[0][1], "SP")) { - add_uphase(SP); - continue; - } - break; + else + { + while (wait(&status) != pid) /* nothing */ + ; + if ((status & 0177) != 0) + { + fatal("%s got a unix signal", phargs[0]); + } + if (((status >> 8) & 0377) != 0) + { + cleanup(); + sys_stop(S_EXIT); } - phase_args[i++] = argv[0]; } - else { - add_file(argv[0]); - } - } - phase_args[i] = 0; - nphase_args = i; - if (nuphases) Ophase = uphases; - - if (nfiles == 2*NTEMPS+1) { - /* 2*NTEMPS+1 was the starting value; nothing to do */ - sys_stop(S_END); - } - - if (! opt_dir) { - fatal("no correct -P flag given"); - } - - if (keeptemps) { - (void) strcpy(ddump, "."); - (void) strcpy(pdump, "."); - (void) strcpy(tmpbufs[0], "."); - } - (void) strcat(ddump, "/ego.dd.XXXXXX"); - (void) mktemp(ddump); - (void) strcat(pdump, "/ego.pd.XXXXXX"); - (void) mktemp(pdump); - - (void) strcat(tmpbufs[0], "/ego.A.BB.XXXXXX"); - (void) mktemp(tmpbufs[0]); - for (i = 2*NTEMPS-1; i >= 1; i--) { - (void) strcpy(tmpbufs[i], tmpbufs[0]); - } - i = strrchr(tmpbufs[0], 'A') - tmpbufs[0]; - tmpbufs[0][i] = 'p'; tmpbufs[NTEMPS+0][i] = 'p'; - tmpbufs[1][i] = 'd'; tmpbufs[NTEMPS+1][i] = 'd'; - tmpbufs[2][i] = 'l'; tmpbufs[NTEMPS+2][i] = 'l'; - tmpbufs[3][i] = 'b'; tmpbufs[NTEMPS+3][i] = 'b'; - run_phase(IC); - run_phase(CF); - while (*Ophase) { - run_phase(*Ophase++); - } - run_phase(CA); - cleanup(); - sys_stop(S_END); - /*NOTREACHED*/ +} + +int main(int argc, char* argv[]) +{ + int opt; + int i; + + if (signal(SIGHUP, catch) == SIG_IGN) + (void)signal(SIGHUP, SIG_IGN); + if (signal(SIGQUIT, catch) == SIG_IGN) + (void)signal(SIGQUIT, SIG_IGN); + if (signal(SIGINT, catch) == SIG_IGN) + (void)signal(SIGINT, SIG_IGN); + prog_name = argv[0]; + + nphase_args = 0; + phase_args = &argv[1]; + + opterr = 0; + for (;;) + { + int opt = getopt(argc, argv, "-M:P:O:vt"); + if (opt == -1) + break; + + switch (opt) + { + case 'M': + descr_file = optarg; + break; + + case 'P': + opt_dir = optarg; + break; + + case 'O': + { + int o = atoi(optarg); + if (o <= 2) + break; + if (o <= 3) + Ophase = &O3phases[0]; + Ophase = &O4phases[0]; + break; + } + + case 1: + add_file(optarg); + break; + + case 't': + keeptemps = 1; + goto addopt; + + case 'v': + v_flag = 1; + goto addopt; + + case '?': + addopt: + phase_args[nphase_args++] = argv[optind - 1]; + break; + } + } + + phase_args[nphase_args] = 0; + if (nuphases) + Ophase = uphases; + + if (nfiles == 2 * NTEMPS + 1) + { + /* 2*NTEMPS+1 was the starting value; nothing to do */ + sys_stop(S_END); + } + + if (!opt_dir) + { + fatal("no correct -P flag given"); + } + + if (keeptemps) + { + (void)strcpy(ddump, "."); + (void)strcpy(pdump, "."); + (void)strcpy(tmpbufs[0], "."); + } + (void)strcat(ddump, "/ego.dd.XXXXXX"); + (void)mktemp(ddump); + (void)strcat(pdump, "/ego.pd.XXXXXX"); + (void)mktemp(pdump); + + (void)strcat(tmpbufs[0], "/ego.XXXXXX"); + (void)mktemp(tmpbufs[0]); + (void)strcat(tmpbufs[0], ".A.BB"); + for (i = 2 * NTEMPS - 1; i >= 1; i--) + { + (void)strcpy(tmpbufs[i], tmpbufs[0]); + } + i = strrchr(tmpbufs[0], 'A') - tmpbufs[0]; + tmpbufs[0][i] = 'p'; + tmpbufs[NTEMPS + 0][i] = 'p'; + tmpbufs[1][i] = 'd'; + tmpbufs[NTEMPS + 1][i] = 'd'; + tmpbufs[2][i] = 'l'; + tmpbufs[NTEMPS + 2][i] = 'l'; + tmpbufs[3][i] = 'b'; + tmpbufs[NTEMPS + 3][i] = 'b'; + run_phase(IC); + run_phase(CF); + while (*Ophase) + { + run_phase(*Ophase++); + } + run_phase(CA); + cleanup(); + sys_stop(S_END); + /*NOTREACHED*/ } diff --git a/util/ego/em_ego/proto.make b/util/ego/em_ego/proto.make deleted file mode 100644 index b1f6d2952..000000000 --- a/util/ego/em_ego/proto.make +++ /dev/null @@ -1,43 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line - -SRC_DIR = $(SRC_HOME)/util/ego/em_ego -EMH=$(TARGET_HOME)/h -EMCONFIG=$(TARGET_HOME)/config -EMLIB=$(TARGET_HOME)/lib.bin -MODLIB=$(TARGET_HOME)/modules/lib -MODH=$(TARGET_HOME)/modules/h -MODS=$(MODLIB)/libprint.$(LIBSUF) $(MODLIB)/libstring.$(LIBSUF) $(MODLIB)/libsystem.$(LIBSUF) - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(EMCONFIG) -I$(MODH) -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -all: em_ego - -em_ego: em_ego.$(SUF) - $(CC) $(LDFLAGS) -o em_ego em_ego.$(SUF) $(MODS) - -em_ego.$(SUF): $(SRC_DIR)/em_ego.c $(EMCONFIG)/em_path.h $(MODH)/system.h - $(CC) -c $(CFLAGS) $(SRC_DIR)/em_ego.c - -install: all - rm -f $(EMLIB)/em_ego - cp em_ego $(EMLIB)/em_ego - -cmp: all - -cmp em_ego $(EMLIB)/em_ego - -pr: - @pr $(SRC_DIR)/proto.make $(SRC_DIR)/em_ego.c - -opr: - make pr | opr - -lint: - $(LINT) $(LINTFLAGS) $(SRC_DIR)/em_ego.c - -clean: - rm -f *.$(SUF) em_ego diff --git a/util/ego/ic/.distr b/util/ego/ic/.distr deleted file mode 100644 index eb09cd319..000000000 --- a/util/ego/ic/.distr +++ /dev/null @@ -1,10 +0,0 @@ -ic.c -ic.h -ic_aux.c -ic_aux.h -ic_io.c -ic_io.h -ic_lib.c -ic_lib.h -ic_lookup.c -ic_lookup.h diff --git a/util/ego/ic/ic.c b/util/ego/ic/ic.c index 00eb717fd..b1d356303 100644 --- a/util/ego/ic/ic.c +++ b/util/ego/ic/ic.c @@ -29,41 +29,36 @@ #include "../share/put.h" #include "../share/aux.h" - /* Global variables */ +dblock_p db; +dblock_p hol0_db; /* dblock for ABS block */ +char* curhol; /* name of hol block in current scope */ +dblock_p ldblock; /* last dblock */ +proc_p lproc; /* last proc */ +short tabval; /* used by table1, table2 and table3 */ +offset tabval2; +char string[IDL + 1]; +line_p firstline; /* first line of current procedure */ +line_p lastline; /* last line read */ +int labelcount; /* # labels in current procedure */ +short fragm_type = DUNKNOWN; /* fragm. type: DCON, DROM or DUNKNOWN */ +short fragm_nr = 0; /* fragment number */ +obj_id lastoid = 0; +proc_id lastpid = 0; +dblock_id lastdid = 0; +lab_id lastlid = 0; -dblock_p db; -dblock_p hol0_db; /* dblock for ABS block */ -char *curhol; /* name of hol block in current scope */ -dblock_p ldblock; /* last dblock */ -proc_p lproc; /* last proc */ -short tabval; /* used by table1, table2 and table3 */ -offset tabval2; -char string[IDL+1]; -line_p firstline; /* first line of current procedure */ -line_p lastline; /* last line read */ -int labelcount; /* # labels in current procedure */ -short fragm_type = DUNKNOWN; /* fragm. type: DCON, DROM or DUNKNOWN */ -short fragm_nr = 0; /* fragment number */ -obj_id lastoid = 0; -proc_id lastpid = 0; -dblock_id lastdid = 0; -lab_id lastlid = 0; +offset mespar = UNKNOWN_SIZE; +/* argumument of ps_par message of current procedure */ -offset mespar = UNKNOWN_SIZE; - /* argumument of ps_par message of current procedure */ +extern process_lines(); +extern int readline(); +extern line_p readoperand(); +extern line_p inpseudo(); - -extern process_lines(); -extern int readline(); -extern line_p readoperand(); -extern line_p inpseudo(); - - -main(argc,argv) - int argc; - char *argv[]; +main(argc, argv) int argc; +char* argv[]; { /* The input files must be legal EM Compact * Assembly Language files, as produced by the EM Peephole @@ -77,25 +72,39 @@ main(argc,argv) * - ddump: the names of all data blocks */ - FILE *lfile, *dfile, *pfile, *pdump, *ddump; + /* The input file names */ - lfile = openfile(lname2,"w"); - pdump = openfile(argv[1],"w"); - ddump = openfile(argv[2],"w"); - hol0_db = block_of_lab((char *) 0); - while (next_file(argc,argv) != NULL) { + const char* pdump_out = argv[1]; + const char* ddump_out = argv[2]; + + /* The output file names */ + + const char* pname_out = argv[5]; + const char* dname_out = argv[6]; + const char* lname_out = argv[7]; + + FILE* lfile = openfile(lname_out, "w"); + FILE* pdump = openfile(pdump_out, "w"); + FILE* ddump = openfile(ddump_out, "w"); + + FILE* dfile; + FILE* pfile; + + hol0_db = block_of_lab((char*)0); + while (next_file(argc-8, argv+8) != NULL) + { /* Read all EM input files, process the code * and concatenate all output. */ - curhol = (char *) 0; + curhol = (char*)0; process_lines(lfile); - dump_procnames(prochash,NPROCHASH,pdump); - dump_dblocknames(symhash,NSYMHASH,ddump); + dump_procnames(prochash, NPROCHASH, pdump); + dump_dblocknames(symhash, NSYMHASH, ddump); /* Save the names of all procedures that were * first come accross in this file. */ - cleanprocs(prochash,NPROCHASH,PF_EXTERNAL); - cleandblocks(symhash,NSYMHASH,DF_EXTERNAL); + cleanprocs(prochash, NPROCHASH, PF_EXTERNAL); + cleandblocks(symhash, NSYMHASH, DF_EXTERNAL); /* Make all procedure names that were internal * in this input file invisible. */ @@ -104,29 +113,25 @@ main(argc,argv) fclose(pdump); fclose(ddump); - /* remove the remainder of the hashing tables */ - cleanprocs(prochash,NPROCHASH,0); - cleandblocks(symhash,NSYMHASH,0); + cleanprocs(prochash, NPROCHASH, 0); + cleandblocks(symhash, NSYMHASH, 0); /* Now write the datablock table and the proctable */ - dfile = openfile(dname2,"w"); + dfile = openfile(dname_out, "w"); putdtable(fdblock, dfile); - pfile = openfile(pname2,"w"); - putptable(fproc, pfile,FALSE); + pfile = openfile(pname_out, "w"); + putptable(fproc, pfile, FALSE); exit(0); } - - /* Value returned by readline */ -#define NORMAL 0 -#define WITH_OPERAND 1 -#define EOFILE 2 -#define PRO_INSTR 3 -#define END_INSTR 4 -#define DELETED_INSTR 5 - +#define NORMAL 0 +#define WITH_OPERAND 1 +#define EOFILE 2 +#define PRO_INSTR 3 +#define END_INSTR 4 +#define DELETED_INSTR 5 STATIC add_end() { @@ -137,13 +142,12 @@ STATIC add_end() lastline->l_instr = ps_end; } - process_lines(fout) - FILE *fout; + FILE* fout; { line_p lnp; - short instr; - bool eof; + short instr; + bool eof; /* Read and process the code contained in the current file, * on a per procedure basis. @@ -162,20 +166,23 @@ process_lines(fout) */ eof = FALSE; - firstline = (line_p) 0; - lastline = (line_p) 0; - while (!eof) { - linecount++; /* for error messages */ - switch(readline(&instr, &lnp)) { + firstline = (line_p)0; + lastline = (line_p)0; + while (!eof) + { + linecount++; /* for error messages */ + switch (readline(&instr, &lnp)) + { /* read one line, see what kind it is */ case WITH_OPERAND: /* instruction with operand, e.g. LOL 10 */ lnp = readoperand(instr); lnp->l_instr = instr; - /* Fall through! */ + /* Fall through! */ case NORMAL: VL(lnp); - if (lastline != (line_p) 0) { + if (lastline != (line_p)0) + { lastline->l_next = lnp; } lastline = lnp; @@ -183,21 +190,23 @@ process_lines(fout) case EOFILE: eof = TRUE; fragm_type = DUNKNOWN; - if (firstline != (line_p) 0) { + if (firstline != (line_p)0) + { add_end(); - putlines(firstline,fout); - firstline = (line_p) 0; + putlines(firstline, fout); + firstline = (line_p)0; } break; case PRO_INSTR: VL(lnp); labelcount = 0; - if (firstline != lnp) { + if (firstline != lnp) + { /* If PRO is not the first * instruction: */ add_end(); - putlines(firstline,fout); + putlines(firstline, fout); firstline = lnp; } lastline = lnp; @@ -205,12 +214,12 @@ process_lines(fout) case END_INSTR: curproc->p_nrformals = mespar; mespar = UNKNOWN_SIZE; - assert(lastline != (line_p) 0); + assert(lastline != (line_p)0); lastline->l_next = lnp; - putlines(firstline,fout); + putlines(firstline, fout); /* write and delete code */ - firstline = (line_p) 0; - lastline = (line_p) 0; + firstline = (line_p)0; + lastline = (line_p)0; cleaninstrlabs(); /* scope of instruction labels ends here, * so forget about them. @@ -226,11 +235,8 @@ process_lines(fout) } } - - -int readline(instr_out, lnp_out) - short *instr_out; - line_p *lnp_out; +int readline(instr_out, lnp_out) short* instr_out; +line_p* lnp_out; { register line_p lnp; short n; @@ -241,9 +247,10 @@ int readline(instr_out, lnp_out) * return the instruction code via instr_out. */ - VA((short *) instr_out); - VA((short *) lnp_out); - switch(table1()) { + VA((short*)instr_out); + VA((short*)lnp_out); + switch (table1()) + { /* table1 sets string, tabval or tabval2 and * returns an indication of what was read. */ @@ -259,10 +266,11 @@ int readline(instr_out, lnp_out) db = block_of_lab(string); /* global variable, used by inpseudo */ lnp = newline(OPSHORT); - SHORT(lnp) = (short) db->d_id; + SHORT(lnp) = (short)db->d_id; lnp->l_instr = ps_sym; *lnp_out = lnp; - if (firstline == (line_p) 0) { + if (firstline == (line_p)0) + { firstline = lnp; /* only a pseudo (e.g. PRO) or data label * can be the first instruction. @@ -280,43 +288,47 @@ int readline(instr_out, lnp_out) case PSEU: n = tabval; lnp = inpseudo(n); /* read a pseudo */ - if (n == ps_hol) n = ps_bss; - if (lnp == (line_p) 0) return DELETED_INSTR; + if (n == ps_hol) + n = ps_bss; + if (lnp == (line_p)0) + return DELETED_INSTR; *lnp_out = lnp; lnp->l_instr = n; - if (firstline == (line_p) 0) { + if (firstline == (line_p)0) + { firstline = lnp; /* only a pseudo (e.g. PRO) or data label * can be the first instruction. */ } - if (n == ps_end) return END_INSTR; - if (n == ps_pro) return PRO_INSTR; + if (n == ps_end) + return END_INSTR; + if (n == ps_pro) + return PRO_INSTR; return NORMAL; } /* NOTREACHED */ } - -line_p readoperand(instr) - short instr; +line_p readoperand(instr) short instr; { /* Read the operand of the given instruction. * Create a line struct and return a pointer to it. */ - register line_p lnp; short flag; VI(instr); - flag = em_flag[ instr - sp_fmnem] & EM_PAR; - if (flag == PAR_NO) { + flag = em_flag[instr - sp_fmnem] & EM_PAR; + if (flag == PAR_NO) + { return (newline(OPNO)); } - switch(table2()) { + switch (table2()) + { case sp_cend: - return(newline(OPNO)); + return (newline(OPNO)); case CSTX1: /* constant */ /* If the instruction has the address @@ -327,31 +339,31 @@ line_p readoperand(instr) * Similarly, the instruction may have * an instruction label as argument. */ - switch(flag) { - case PAR_G: - lnp = newline(OPOBJECT); - OBJ(lnp) = - object(curhol,(offset) tabval, - opr_size(instr)); - break; - case PAR_B: - lnp = newline(OPINSTRLAB); - INSTRLAB(lnp) = instr_lab(tabval); - break; - default: - lnp = newline(OPSHORT); - SHORT(lnp) = tabval; - break; + switch (flag) + { + case PAR_G: + lnp = newline(OPOBJECT); + OBJ(lnp) = object(curhol, (offset)tabval, + opr_size(instr)); + break; + case PAR_B: + lnp = newline(OPINSTRLAB); + INSTRLAB(lnp) = instr_lab(tabval); + break; + default: + lnp = newline(OPSHORT); + SHORT(lnp) = tabval; + break; } break; #ifdef LONGOFF case CSTX2: /* double constant */ - if (flag == PAR_G) { + if (flag == PAR_G) + { lnp = newline(OPOBJECT); - OBJ(lnp) = - object(curhol, tabval2, - opr_size(instr)); + OBJ(lnp) = object(curhol, tabval2, + opr_size(instr)); break; } lnp = newline(OPOFFSET); @@ -366,24 +378,24 @@ line_p readoperand(instr) case DLBX: /* applied occurrence data label */ lnp = newline(OPOBJECT); - OBJ(lnp) = object(string, (offset) 0, - opr_size(instr) ); + OBJ(lnp) = object(string, (offset)0, + opr_size(instr)); break; case VALX1: lnp = newline(OPOBJECT); - OBJ(lnp) = object(string, (offset) tabval, - opr_size(instr) ); + OBJ(lnp) = object(string, (offset)tabval, + opr_size(instr)); break; #ifdef LONGOFF case VALX2: lnp = newline(OPOBJECT); - OBJ(lnp) = object(string,tabval2, - opr_size(instr) ); + OBJ(lnp) = object(string, tabval2, + opr_size(instr)); break; #endif case sp_pnam: lnp = newline(OPPROC); - PROC(lnp) = proclookup(string,OCCURRING); + PROC(lnp) = proclookup(string, OCCURRING); VP(PROC(lnp)); break; default: @@ -392,36 +404,35 @@ line_p readoperand(instr) return lnp; } - -static char *hol_label() +static char* hol_label() { static int holno; line_p lnp; - extern char *lastname; + extern char* lastname; /* Create a label for a hol pseudo, so that it can be converted * into a bss. The label is appended to the list of instructions. */ sprintf(string, "_HH%d", ++holno); - symlookup(string, OCCURRING); /* to make it exa */ + symlookup(string, OCCURRING); /* to make it exa */ db = block_of_lab(string); lnp = newline(OPSHORT); - SHORT(lnp) = (short) db->d_id; + SHORT(lnp) = (short)db->d_id; lnp->l_instr = ps_sym; - if (firstline == (line_p) 0) { + if (firstline == (line_p)0) + { firstline = lnp; } - if (lastline != (line_p) 0) { + if (lastline != (line_p)0) + { lastline->l_next = lnp; } lastline = lnp; return lastname; } - -line_p inpseudo(n) - short n; +line_p inpseudo(n) short n; { int m; line_p lnp; @@ -436,45 +447,50 @@ line_p inpseudo(n) * be recorded in the datablock or procedure table. */ - - switch(n) { + switch (n) + { case ps_hol: /* hol pseudos are carefully converted into bss * pseudos, so that the IL phase will not be * bothered by this. Also, references to the ABS * block will still work when passed through EGO. */ - - if (lastline != (line_p) 0 && is_datalabel(lastline)) { - extern char *lastname; + + if (lastline != (line_p)0 && is_datalabel(lastline)) + { + extern char* lastname; curhol = lastname; } - else { + else + { curhol = hol_label(); } n = ps_bss; - /* fall through */ + /* fall through */ case ps_bss: case ps_rom: case ps_con: - if (lastline == (line_p) 0 || !is_datalabel(lastline)) { - assert(lastline != (line_p) 0); + if (lastline == (line_p)0 || !is_datalabel(lastline)) + { + assert(lastline != (line_p)0); nlast = INSTR(lastline); - if (n == nlast && - (n == ps_rom || n == ps_con)) { + if (n == nlast && (n == ps_rom || n == ps_con)) + { /* Two successive roms/cons are * combined into one data block * if the second is not preceded by * a data label. */ lnp = arglist(0); - pseu = (byte) (n == ps_rom?DROM:DCON); - combine(db,lastline,lnp,pseu); + pseu = (byte)(n == ps_rom ? DROM : DCON); + combine(db, lastline, lnp, pseu); oldline(lnp); - return (line_p) 0; - } else { - error("datablock without label"); + return (line_p)0; + } + else + { + error("datablock without label"); } } VD(db); @@ -483,14 +499,16 @@ line_p inpseudo(n) /* Read the arguments, 3 for hol or bss and a list * of undetermined length for rom and con. */ - dblockdef(db,n,lnp); + dblockdef(db, n, lnp); /* Fill in d_pseudo, d_size and d_values fields of db */ - if (fragm_type != db->d_pseudo) { + if (fragm_type != db->d_pseudo) + { /* Keep track of fragment numbers, * enter a new fragment. */ fragm_nr++; - switch(db->d_pseudo) { + switch (db->d_pseudo) + { case DCON: case DROM: fragm_type = db->d_pseudo; @@ -511,16 +529,16 @@ line_p inpseudo(n) * the EM visibility rules). * The result (a dblock pointer) is voided. */ - return (line_p) 0; + return (line_p)0; case ps_inp: - getproc(DEFINING); /* same idea */ - return (line_p) 0; + getproc(DEFINING); /* same idea */ + return (line_p)0; case ps_exa: getsym(OCCURRING); - return (line_p) 0; + return (line_p)0; case ps_exp: getproc(OCCURRING); - return (line_p) 0; + return (line_p)0; case ps_pro: curproc = getproc(DEFINING); /* This is a real defining occurrence of a proc */ @@ -531,7 +549,7 @@ line_p inpseudo(n) */ lnp = newline(OPPROC); PROC(lnp) = curproc; - lnp->l_instr = (byte) ps_pro; + lnp->l_instr = (byte)ps_pro; return lnp; case ps_end: curproc->p_nrlabels = labelcount; @@ -543,27 +561,28 @@ line_p inpseudo(n) return lnp; case ps_mes: lnp = arglist(0); - switch((int) aoff(ARG(lnp),0)) { - case ms_err: - error("ms_err encountered"); - case ms_opt: - error("ms_opt encountered"); - case ms_emx: - ws = aoff(ARG(lnp),1); - ps = aoff(ARG(lnp),2); - break; - case ms_ext: + switch ((int)aoff(ARG(lnp), 0)) + { + case ms_err: + error("ms_err encountered"); + case ms_opt: + error("ms_opt encountered"); + case ms_emx: + ws = aoff(ARG(lnp), 1); + ps = aoff(ARG(lnp), 2); + break; + case ms_ext: /* this message was already processed * by the lib package */ - case ms_src: - /* Don't bother about linecounts */ - oldline(lnp); - return (line_p) 0; - case ms_par: - mespar = aoff(ARG(lnp),1); - /* #bytes of parameters of current proc */ - break; + case ms_src: + /* Don't bother about linecounts */ + oldline(lnp); + return (line_p)0; + case ms_par: + mespar = aoff(ARG(lnp), 1); + /* #bytes of parameters of current proc */ + break; } return lnp; default: diff --git a/util/ego/ic/ic_lib.c b/util/ego/ic/ic_lib.c index e23bdd5d9..638038afc 100644 --- a/util/ego/ic/ic_lib.c +++ b/util/ego/ic/ic_lib.c @@ -8,7 +8,6 @@ * I C _ L I B . C */ - #include #include #include @@ -23,29 +22,30 @@ #include "../share/files.h" #include "ic_lib.h" - STATIC skip_string(n) - offset n; + offset n; { /* Read a string of length n and void it */ - while (n--) { + while (n--) + { readchar(); } } - STATIC skip_arguments() { /* Skip the arguments of a MES pseudo. The argument * list is terminated by a sp_cend byte. */ - for (;;) { - switch(table2()) { + for (;;) + { + switch (table2()) + { case sp_scon: get_off(); /* void */ - /* fall through !!! */ + /* fall through !!! */ case sp_icon: case sp_ucon: case sp_fcon: @@ -60,10 +60,7 @@ STATIC skip_arguments() } } - - -STATIC bool proc_wanted(name) - char *name; +STATIC bool proc_wanted(name) char* name; { /* See if 'name' is the name of an external procedure * that has been used before, but for which no body @@ -72,18 +69,17 @@ STATIC bool proc_wanted(name) proc_p p; - if (( p = proclookup(name,IMPORTING)) != (proc_p) 0 && - !(p->p_flags1 & PF_BODYSEEN)) { + if ((p = proclookup(name, IMPORTING)) != (proc_p)0 && !(p->p_flags1 & PF_BODYSEEN)) + { return TRUE; - } else { + } + else + { return FALSE; } } - - -STATIC bool data_wanted(name) - char *name; +STATIC bool data_wanted(name) char* name; { /* See if 'name' is the name of an externally visible * data block that has been used before, but for which @@ -92,16 +88,16 @@ STATIC bool data_wanted(name) dblock_p db; - if ((db = symlookup(name,IMPORTING)) != (dblock_p) 0 && - db->d_pseudo == DUNKNOWN) { + if ((db = symlookup(name, IMPORTING)) != (dblock_p)0 && db->d_pseudo == DUNKNOWN) + { return TRUE; - } else { + } + else + { return FALSE; } } - - STATIC bool wanted_names() { /* Read the names of procedures and data labels, @@ -114,10 +110,13 @@ STATIC bool wanted_names() * no defining occurrence has been met. */ - for (;;) { - switch(table2()) { + for (;;) + { + switch (table2()) + { case DLBX: - if (data_wanted(string)) { + if (data_wanted(string)) + { return TRUE; } /* A data entity with the name @@ -125,7 +124,8 @@ STATIC bool wanted_names() */ break; case sp_pnam: - if (proc_wanted(string)) { + if (proc_wanted(string)) + { return TRUE; } break; @@ -137,9 +137,7 @@ STATIC bool wanted_names() } } - - -STATIC FILE *curfile = NULL; +STATIC FILE* curfile = NULL; STATIC bool useful() { /* Determine if any entity imported by the current @@ -150,43 +148,45 @@ STATIC bool useful() * of the entities imported. */ - for (;;) { - if (table1() != PSEU || tabval != ps_mes) { - error("cannot find MES %d in library file",ms_ext); + for (;;) + { + if (table1() != PSEU || tabval != ps_mes) + { + error("cannot find MES %d in library file", ms_ext); } - if (table2() != CSTX1) { + if (table2() != CSTX1) + { error("message number expected"); } - if (tabval == ms_ext) { + if (tabval == ms_ext) + { /* This is the one we searched */ return wanted_names(); /* Read the names of the imported entities * and check if any of them is wanted. */ - } else { + } + else + { skip_arguments(); /* skip remainder of this MES */ } } } - - -STATIC bool is_archive(name) - char *name; +STATIC bool is_archive(name) char* name; { /* See if 'name' is the name of an archive file, i.e. it * should end on ".ma" and should at least be four characters * long (i.e. the name ".ma" is not accepted as an archive name!). */ - register char *p; + register char* p; - for (p = name; *p; p++); - return (p > name+3) && (*--p == 'a') && (*--p == 'm') && (*--p == '.'); + for (p = name; *p; p++) + ; + return (p > name + 3) && (*--p == 'a') && (*--p == 'm') && (*--p == '.'); } - - STATIC struct ar_hdr hdr; STATIC bool read_hdr() @@ -194,39 +194,41 @@ STATIC bool read_hdr() /* Read the header of an archive module */ char buf[AR_TOTAL]; - register char *c = buf; - register char *p = hdr.ar_name; + register char* c = buf; + register char* p = hdr.ar_name; register int i; fread(c, AR_TOTAL, 1, curfile); - if (feof(curfile)) return 0; + if (feof(curfile)) + return 0; i = 14; - while (i--) { + while (i--) + { *p++ = *c++; } -#define get2(c) (((c)[0]&0377) | ((unsigned) ((c)[1]&0377) << 8)) +#define get2(c) (((c)[0] & 0377) | ((unsigned)((c)[1] & 0377) << 8)) - hdr.ar_date = ((long) get2(c)) << 16; c += 2; - hdr.ar_date |= ((long) get2(c)) & 0xffff; c += 2; + hdr.ar_date = ((long)get2(c)) << 16; + c += 2; + hdr.ar_date |= ((long)get2(c)) & 0xffff; + c += 2; hdr.ar_uid = *c++; hdr.ar_gid = *c++; - hdr.ar_mode = get2(c); c += 2; - hdr.ar_size = (long) get2(c) << 16; c += 2; - hdr.ar_size |= (long) get2(c) & 0xffff; + hdr.ar_mode = get2(c); + c += 2; + hdr.ar_size = (long)get2(c) << 16; + c += 2; + hdr.ar_size |= (long)get2(c) & 0xffff; return 1; } - - -STATIC int argcnt = ARGSTART - 1; +STATIC int argcnt = 0; STATIC short arstate = NO_ARCHIVE; - -FILE *next_file(argc,argv) - int argc; - char *argv[]; +FILE* next_file(argc, argv) int argc; +char* argv[]; { /* See if there are more EM input files. The file names * are given via argv. If a file is an archive file @@ -237,61 +239,78 @@ FILE *next_file(argc,argv) * occurrence, although we have seen a used occurrence. */ - long ptr; + long ptr; - for (;;) { + for (;;) + { /* This loop is only exited via a return */ - if (arstate == ARCHIVE) { + if (arstate == ARCHIVE) + { /* We were reading an archive file */ - if (ftell(curfile) & 1) { + if (ftell(curfile) & 1) + { /* modules in an archive file always * begin on a word boundary, i.e. at * an even address. */ - fseek(curfile,1L,1); + fseek(curfile, 1L, 1); } - if (read_hdr()) { /* read header of next module */ + if (read_hdr()) + { /* read header of next module */ ptr = ftell(curfile); /* file position */ - file_init(curfile,ARCHIVE,hdr.ar_size); + file_init(curfile, ARCHIVE, hdr.ar_size); /* tell i/o package that we're reading * an archive module of given length. */ - if (useful()) { + if (useful()) + { /* re-initialize file, because 'useful' * has read some bytes too. */ - fseek(curfile,ptr,0); /* start module */ - file_init(curfile,ARCHIVE,hdr.ar_size); + fseek(curfile, ptr, 0); /* start module */ + file_init(curfile, ARCHIVE, hdr.ar_size); return curfile; - } else { + } + else + { /* skip this module */ fseek(curfile, - ptr+hdr.ar_size,0); + ptr + hdr.ar_size, 0); } - } else { + } + else + { /* done with this archive */ arstate = NO_ARCHIVE; } - } else { + } + else + { /* open next file, close old */ - if (curfile != NULL) { + if (curfile != NULL) + { fclose(curfile); } argcnt++; - if (argcnt >= argc) { + if (argcnt >= argc) + { /* done with all arguments */ return NULL; } filename = argv[argcnt]; - if ((curfile = fopen(filename,"r")) == NULL) { - error("cannot open %s",filename); + if ((curfile = fopen(filename, "r")) == NULL) + { + error("cannot open %s", filename); } - if (is_archive(filename)) { + if (is_archive(filename)) + { /* ends on '.ma' */ arstate = ARCHIVE; arch_init(curfile); /* read magic ar number */ - } else { - file_init(curfile,NO_ARCHIVE,0L); + } + else + { + file_init(curfile, NO_ARCHIVE, 0L); return curfile; } } diff --git a/util/ego/ic/proto.make b/util/ego/ic/proto.make deleted file mode 100644 index aae64cd14..000000000 --- a/util/ego/ic/proto.make +++ /dev/null @@ -1,137 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/ic -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/ic.c \ - $(SRC_DIR)/ic_aux.c \ - $(SRC_DIR)/ic_lib.c \ - $(SRC_DIR)/ic_lookup.c \ - $(SRC_DIR)/ic_io.c - -OFILES=\ -ic.$(SUF) ic_aux.$(SUF) ic_lookup.$(SUF) ic_io.$(SUF) ic_lib.$(SUF) - -HFILES=\ - $(SRC_DIR)/ic.h \ - $(SRC_DIR)/ic_aux.h \ - $(SRC_DIR)/ic_lib.h \ - $(SRC_DIR)/ic_lookup.h \ - $(SRC_DIR)/ic_io.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: ic - -ic: $(OFILES) - $(CC) -o ic $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp ic $(EMLIB)/ego/ic - -cmp: all - -cmp ic $(EMLIB)/ego/ic - -clean: - rm -f *.$(SUF) ic Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -ic.$(SUF): $(SRC_DIR)/ic.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic.c -ic.$(SUF): $(SRC_DIR)/../share/aux.h -ic.$(SUF): $(SRC_DIR)/../share/put.h -ic.$(SUF): $(SRC_DIR)/../share/files.h -ic.$(SUF): $(SRC_DIR)/../share/global.h -ic.$(SUF): $(SRC_DIR)/../share/alloc.h -ic.$(SUF): $(SRC_DIR)/ic_lib.h -ic.$(SUF): $(SRC_DIR)/ic_io.h -ic.$(SUF): $(SRC_DIR)/ic_aux.h -ic.$(SUF): $(SRC_DIR)/ic_lookup.h -ic.$(SUF): $(SRC_DIR)/ic.h -ic.$(SUF): $(SRC_DIR)/../share/map.h -ic.$(SUF): $(SRC_DIR)/../share/def.h -ic.$(SUF): $(SRC_DIR)/../share/debug.h -ic.$(SUF): $(SRC_DIR)/../share/types.h -ic.$(SUF): $(EMH)/em_mes.h -ic.$(SUF): $(EMH)/em_flag.h -ic.$(SUF): $(EMH)/em_pseu.h -ic.$(SUF): $(EMH)/em_spec.h -ic_aux.$(SUF): $(SRC_DIR)/ic_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic_aux.c -ic_aux.$(SUF): $(SRC_DIR)/ic_aux.h -ic_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -ic_aux.$(SUF): $(SRC_DIR)/ic_lookup.h -ic_aux.$(SUF): $(SRC_DIR)/ic_io.h -ic_aux.$(SUF): $(SRC_DIR)/ic.h -ic_aux.$(SUF): $(SRC_DIR)/../share/aux.h -ic_aux.$(SUF): $(SRC_DIR)/../share/def.h -ic_aux.$(SUF): $(SRC_DIR)/../share/debug.h -ic_aux.$(SUF): $(SRC_DIR)/../share/global.h -ic_aux.$(SUF): $(SRC_DIR)/../share/types.h -ic_aux.$(SUF): $(EMH)/em_mnem.h -ic_aux.$(SUF): $(EMH)/em_spec.h -ic_aux.$(SUF): $(EMH)/em_pseu.h -ic_lib.$(SUF): $(SRC_DIR)/ic_lib.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic_lib.c -ic_lib.$(SUF): $(SRC_DIR)/ic_lib.h -ic_lib.$(SUF): $(SRC_DIR)/../share/files.h -ic_lib.$(SUF): $(SRC_DIR)/../share/global.h -ic_lib.$(SUF): $(SRC_DIR)/ic_io.h -ic_lib.$(SUF): $(SRC_DIR)/ic_lookup.h -ic_lib.$(SUF): $(SRC_DIR)/ic.h -ic_lib.$(SUF): $(SRC_DIR)/../share/debug.h -ic_lib.$(SUF): $(SRC_DIR)/../share/types.h -ic_lib.$(SUF): $(EMH)/arch.h -ic_lib.$(SUF): $(EMH)/em_mes.h -ic_lib.$(SUF): $(EMH)/em_pseu.h -ic_lib.$(SUF): $(EMH)/em_spec.h -ic_lookup.$(SUF): $(SRC_DIR)/ic_lookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic_lookup.c -ic_lookup.$(SUF): $(SRC_DIR)/../share/alloc.h -ic_lookup.$(SUF): $(SRC_DIR)/ic_lookup.h -ic_lookup.$(SUF): $(SRC_DIR)/ic.h -ic_lookup.$(SUF): $(SRC_DIR)/../share/map.h -ic_lookup.$(SUF): $(SRC_DIR)/../share/debug.h -ic_lookup.$(SUF): $(SRC_DIR)/../share/types.h -ic_lookup.$(SUF): $(EMH)/em_spec.h -ic_io.$(SUF): $(SRC_DIR)/ic_io.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ic_io.c -ic_io.$(SUF): $(SRC_DIR)/ic_io.h -ic_io.$(SUF): $(SRC_DIR)/../share/alloc.h -ic_io.$(SUF): $(SRC_DIR)/ic_lookup.h -ic_io.$(SUF): $(SRC_DIR)/ic.h -ic_io.$(SUF): $(SRC_DIR)/../share/debug.h -ic_io.$(SUF): $(SRC_DIR)/../share/types.h -ic_io.$(SUF): $(EMH)/arch.h -ic_io.$(SUF): $(EMH)/em_spec.h -ic_io.$(SUF): $(EMH)/em_pseu.h diff --git a/util/ego/il/.distr b/util/ego/il/.distr deleted file mode 100644 index c34e2ee46..000000000 --- a/util/ego/il/.distr +++ /dev/null @@ -1,20 +0,0 @@ -il.c -il.h -il1_anal.c -il1_anal.h -il1_aux.c -il1_aux.h -il1_cal.c -il1_cal.h -il1_formal.c -il1_formal.h -il2_aux.c -il2_aux.h -il3_aux.c -il3_aux.h -il3_change.c -il3_change.h -il3_subst.c -il3_subst.h -il_aux.c -il_aux.h diff --git a/util/ego/il/il.c b/util/ego/il/il.c index 6ec2a8af2..938dfa3cc 100644 --- a/util/ego/il/il.c +++ b/util/ego/il/il.c @@ -29,7 +29,7 @@ int calnr; int complete_program; -calcnt_p cchead; /* call-count info of current proc */ +calcnt_p cchead; /* call-count info of current proc */ STATIC long space = 0; STATIC long total_size = 0; @@ -42,8 +42,8 @@ STATIC int kp_temps = 0; int Ssubst; #ifdef VERBOSE -int Senv,Srecursive,Slocals,Sinstrlab,Sparsefails,Spremoved,Scals; -int Sbig_caller,Sdispensable,Schangedcallee,Sbigcallee,Sspace,Szeroratio; +int Senv, Srecursive, Slocals, Sinstrlab, Sparsefails, Spremoved, Scals; +int Sbig_caller, Sdispensable, Schangedcallee, Sbigcallee, Sspace, Szeroratio; #endif /* P A S S 1 @@ -56,10 +56,9 @@ int Sbig_caller,Sdispensable,Schangedcallee,Sbigcallee,Sspace,Szeroratio; * The call descriptors are put in a file (calfile). */ -pass1(lnam,bnam,cnam) - char *lnam, *bnam, *cnam; +pass1(lnam, bnam, cnam) char* lnam, *bnam, *cnam; { - FILE *f, *gf, *cf, *ccf; /* The EM input, the basic block graph, + FILE* f, *gf, *cf, *ccf; /* The EM input, the basic block graph, * the call-list file and the calcnt file. */ long laddr; @@ -67,26 +66,29 @@ pass1(lnam,bnam,cnam) short kind; line_p l; - f = openfile(lnam,"r"); - gf = openfile(bnam,"r"); - cf = openfile(cnam,"w"); - ccf = openfile(ccname,"w"); + f = openfile(lnam, "r"); + gf = openfile(bnam, "r"); + cf = openfile(cnam, "w"); + ccf = openfile(ccname, "w"); mesregs = Lempty_set(); apriori(fproc); /* use information from the procedure table to * see which calls certainly cannot be expanded. */ - while(TRUE) { + while (TRUE) + { laddr = ftell(f); - if (!getunit(gf,f,&kind,&g,&l,&curproc,TRUE)) break; + if (!getunit(gf, f, &kind, &g, &l, &curproc, TRUE)) + break; /* Read the control flow graph and EM text of * one procedure and analyze it. */ - if (kind == LDATA) { - remunit(LDATA,(proc_p) 0,l); + if (kind == LDATA) + { + remunit(LDATA, (proc_p)0, l); continue; } - OUTTRACE("flow graph of proc %d read",curproc->p_id); + OUTTRACE("flow graph of proc %d read", curproc->p_id); assert(INSTR(g->b_start) == ps_pro); curproc->p_start = g; curproc->P_LADDR = laddr; @@ -94,74 +96,78 @@ pass1(lnam,bnam,cnam) /* address of graph in basic block file */ curproc->P_SIZE = proclength(curproc); /* #instructions */ total_size += curproc->P_SIZE; - if (BIG_PROC(curproc)) { + if (BIG_PROC(curproc)) + { /* curproc is too large to be expanded in line */ UNSUITABLE(curproc); } calnr = 0; - anal_proc(curproc,cf,ccf); - OUTTRACE("proc %d processed",curproc->p_id); - remunit(LTEXT,curproc,(line_p) 0); + anal_proc(curproc, cf, ccf); + OUTTRACE("proc %d processed", curproc->p_id); + remunit(LTEXT, curproc, (line_p)0); /* remove control flow graph + text */ - OUTTRACE("graph of proc %d removed",curproc->p_id); + OUTTRACE("graph of proc %d removed", curproc->p_id); Ldeleteset(mesregs); mesregs = Lempty_set(); } fclose(f); fclose(gf); fclose(cf); - fclose(ccf); + fclose(ccf); } - - /* P A S S 2 * * Pass 2 reads the calfile and determines which calls should * be expanded in line. It does not use the EM text. */ - - STATIC char cname2[128] = TMP_DIR; -pass2(cnam,space) - char *cnam; - long space; +pass2(cnam, space) char* cnam; +long space; { - FILE *cf, *cf2, *ccf; - call_p c,a; + FILE* cf, *cf2, *ccf; + call_p c, a; - cf = openfile(cnam,"r"); - cf2 = openfile(cname2,"w"); - ccf = openfile(ccname,"r"); - while ((c = getcall(cf)) != (call_p) 0) { + cf = openfile(cnam, "r"); + cf2 = openfile(cname2, "w"); + ccf = openfile(ccname, "r"); + while ((c = getcall(cf)) != (call_p)0) + { /* process all calls */ - if (SUITABLE(c->cl_proc) && anal_params(c)) { + if (SUITABLE(c->cl_proc) && anal_params(c)) + { /* called proc. may be put in line */ /* see which parameters may be put in line */ assign_ratio(c); /* assign a rank */ a = abstract(c); /* abstract essential info */ - append_abstract(a,a->cl_caller); + append_abstract(a, a->cl_caller); /* put it in call-list of calling proc. */ - putcall(c,cf2,(short) 0); - } else { + putcall(c, cf2, (short)0); + } + else + { rem_call(c); } } - select_calls(fproc,ccf,space); - fclose(cf); if (! kp_temps) unlink(cnam); + select_calls(fproc, ccf, space); + fclose(cf); + if (!kp_temps) + unlink(cnam); fclose(cf2); - fclose(ccf); if (! kp_temps) unlink(ccname); - cf2 = openfile(cname2,"r"); - add_actuals(fproc,cf2); + fclose(ccf); + if (!kp_temps) + unlink(ccname); + cf2 = openfile(cname2, "r"); + add_actuals(fproc, cf2); cleancals(fproc); /* remove calls that were not selected */ /* add actual parameters to each selected call */ - fclose(cf2); if (! kp_temps) unlink(cname2); + fclose(cf2); + if (!kp_temps) + unlink(cname2); } - - /* P A S S 3 * * pass 3 reads the substitution file and performs all @@ -170,67 +176,76 @@ pass2(cnam,space) * EM textfile. */ - -pass3(lnam,lnam2) - char *lnam,*lnam2; +pass3(lnam, lnam2) char* lnam, *lnam2; { bool verbose = TRUE; - FILE *lfile, *lfilerand, *lfile2, *sfile; - call_p c,next; - line_p l,startscan,cal; + FILE* lfile, *lfilerand, *lfile2, *sfile; + call_p c, next; + line_p l, startscan, cal; short lastcid; /* last call-id seen */ lfile = openfile(lnam, "r"); lfilerand = openfile(lnam, "r"); - lfile2 = openfile(lnam2,"w"); - if (verbose) { - sfile = openfile(sname,"w"); + lfile2 = openfile(lnam2, "w"); + if (verbose) + { + sfile = openfile(sname, "w"); } mesregs = Lempty_set(); - while ((l = get_text(lfile,&curproc)) != (line_p) 0) { - if (curproc == (proc_p) 0) { + while ((l = get_text(lfile, &curproc)) != (line_p)0) + { + if (curproc == (proc_p)0) + { /* Just a data-unit; no real instructions */ - putlines(l->l_next,lfile2); + putlines(l->l_next, lfile2); oldline(l); continue; } - if (IS_DISPENSABLE(curproc)) { - liquidate(curproc,l->l_next); - } else { + if (IS_DISPENSABLE(curproc)) + { + liquidate(curproc, l->l_next); + } + else + { startscan = l->l_next; lastcid = 0; - for (c = curproc->P_CALS; c != (call_p) 0; c = next) { + for (c = curproc->P_CALS; c != (call_p)0; c = next) + { next = c->cl_cdr; - cal = scan_to_cal(startscan,c->cl_id - lastcid); - assert (cal != (line_p) 0); - startscan = scan_to_cal(cal->l_next,1); + cal = scan_to_cal(startscan, c->cl_id - lastcid); + assert(cal != (line_p)0); + startscan = scan_to_cal(cal->l_next, 1); /* next CAL */ lastcid = c->cl_id; /* next CAL after current one */ - substitute(lfilerand,c,cal,l->l_next); - if (verbose) { - putcall(c,sfile,0); - } else { + substitute(lfilerand, c, cal, l->l_next); + if (verbose) + { + putcall(c, sfile, 0); + } + else + { rem_call(c); } } } - putlines(l->l_next,lfile2); + putlines(l->l_next, lfile2); Ldeleteset(mesregs); mesregs = Lempty_set(); oldline(l); } fclose(lfile); fclose(lfile2); - if (verbose) { + if (verbose) + { fclose(sfile); - if (! kp_temps) unlink(sname); + if (!kp_temps) + unlink(sname); } } - STATIC il_extptab(ptab) - proc_p ptab; + proc_p ptab; { /* Allocate space for extension of proctable entries. * Also, initialise some of the fields just allocated. @@ -238,7 +253,8 @@ STATIC il_extptab(ptab) register proc_p p; - for (p = ptab; p != (proc_p) 0; p = p->p_next) { + for (p = ptab; p != (proc_p)0; p = p->p_next) + { p->p_extend = newilpx(); p->P_ORGLABELS = p->p_nrlabels; p->P_ORGLOCALS = p->p_localbytes; @@ -246,13 +262,14 @@ STATIC il_extptab(ptab) } STATIC il_cleanptab(ptab) - proc_p ptab; + proc_p ptab; { /* De-allocate space for extensions */ register proc_p p; - for (p = ptab; p != (proc_p) 0; p = p->p_next) { + for (p = ptab; p != (proc_p)0; p = p->p_next) + { oldilpx(p->p_extend); } } @@ -262,55 +279,56 @@ Sdiagnostics() { /* print statictical information */ - fprintf(stderr,"STATISTICS:\n"); - fprintf(stderr,"Info about procedures:\n"); - fprintf(stderr,"environment accessed: %d\n",Senv); - fprintf(stderr,"recursive: %d\n",Srecursive); - fprintf(stderr,"too many locals: %d\n",Slocals); - fprintf(stderr,"instr. lab in data block: %d\n",Sinstrlab); - fprintf(stderr,"procedures removed: %d\n",Spremoved); - fprintf(stderr,"\nInfo about calls:\n"); - fprintf(stderr,"total number of calls: %d\n",Scals); - fprintf(stderr,"total number of calls substituted: %d\n",Ssubst); - fprintf(stderr,"parser failed: %d\n",Sparsefails); - fprintf(stderr,"caller too big: %d\n",Sbig_caller); - fprintf(stderr,"caller dispensable: %d\n",Sdispensable); - fprintf(stderr,"callee is changed: %d\n",Schangedcallee); - fprintf(stderr,"callee too big: %d\n",Sbigcallee); - fprintf(stderr,"no space available: %d\n",Sspace); - fprintf(stderr,"zero ratio: %d\n",Szeroratio); + fprintf(stderr, "STATISTICS:\n"); + fprintf(stderr, "Info about procedures:\n"); + fprintf(stderr, "environment accessed: %d\n", Senv); + fprintf(stderr, "recursive: %d\n", Srecursive); + fprintf(stderr, "too many locals: %d\n", Slocals); + fprintf(stderr, "instr. lab in data block: %d\n", Sinstrlab); + fprintf(stderr, "procedures removed: %d\n", Spremoved); + fprintf(stderr, "\nInfo about calls:\n"); + fprintf(stderr, "total number of calls: %d\n", Scals); + fprintf(stderr, "total number of calls substituted: %d\n", Ssubst); + fprintf(stderr, "parser failed: %d\n", Sparsefails); + fprintf(stderr, "caller too big: %d\n", Sbig_caller); + fprintf(stderr, "caller dispensable: %d\n", Sdispensable); + fprintf(stderr, "callee is changed: %d\n", Schangedcallee); + fprintf(stderr, "callee too big: %d\n", Sbigcallee); + fprintf(stderr, "no space available: %d\n", Sspace); + fprintf(stderr, "zero ratio: %d\n", Szeroratio); } #endif -il_flags(p) - char *p; +il_flags(p) char* p; { - switch(*p++) { - case 's': - while (*p != '\0') { - space = 10*space +*p++ -'0'; - } - break; - case 'a': - complete_program = 1; - break; - case 't': - strcpy(cname, "."); - strcpy(ccname, "."); - strcpy(sname, "."); - strcpy(cname2, "."); - kp_temps = 1; - break; + switch (*p++) + { + case 's': + while (*p != '\0') + { + space = 10 * space + *p++ - '0'; + } + break; + case 'a': + complete_program = 1; + break; + case 't': + strcpy(cname, "."); + strcpy(ccname, "."); + strcpy(sname, "."); + strcpy(cname2, "."); + kp_temps = 1; + break; } } -main(argc,argv) - int argc; - char *argv[]; +main(argc, argv) int argc; +char* argv[]; { - FILE *f; - - go(argc,argv,no_action,no_action,no_action,il_flags); + struct files* files = findfiles(argc, argv); + FILE* f; + + go(argc, argv, no_action, no_action, no_action, il_flags); il_extptab(fproc); /* add extended data structures */ strcat(cname, "/ego.i1.XXXXXX"); strcat(ccname, "/ego.i2.XXXXXX"); @@ -320,18 +338,19 @@ main(argc,argv) mktemp(ccname); mktemp(sname); mktemp(cname2); - pass1(lname,bname,cname); /* grep calls, analyse procedures */ - space = total_size * space / 100 ; - pass2(cname,space); /* select calls to be expanded */ - pass3(lname,lname2); /* do substitutions */ - f = openfile(dname2,"w"); + pass1(files->lname_in, files->bname_in, cname); /* grep calls, analyse procedures */ + space = total_size * space / 100; + pass2(cname, space); /* select calls to be expanded */ + pass3(files->lname_in, files->lname_out); /* do substitutions */ + f = openfile(files->dname_out, "w"); il_cleanptab(fproc); /* remove extended data structures */ - putdtable(fdblock,f); - f = openfile(pname2,"w"); - putptable(fproc,f,FALSE); - report("inline substitutions",Ssubst); + putdtable(fdblock, f); + f = openfile(files->pname_out, "w"); + putptable(fproc, f, FALSE); + report("inline substitutions", Ssubst); #ifdef VERBOSE - if (verbose_flag) { + if (verbose_flag) + { Sdiagnostics(); } #endif diff --git a/util/ego/il/il1_aux.c b/util/ego/il/il1_aux.c index 8ef4923e2..76e8ae2f3 100644 --- a/util/ego/il/il1_aux.c +++ b/util/ego/il/il1_aux.c @@ -8,6 +8,7 @@ * I L 1 _ A U X . C */ +#include #include #include "../share/types.h" #include "il.h" diff --git a/util/ego/il/il2_aux.c b/util/ego/il/il2_aux.c index 54d950156..01a13f0fc 100644 --- a/util/ego/il/il2_aux.c +++ b/util/ego/il/il2_aux.c @@ -8,6 +8,7 @@ * I L 2 _ A U X . C */ +#include #include #include #include diff --git a/util/ego/il/il3_change.c b/util/ego/il/il3_change.c index 8f8fd393c..6347167c3 100644 --- a/util/ego/il/il3_change.c +++ b/util/ego/il/il3_change.c @@ -9,6 +9,7 @@ */ +#include #include #include #include diff --git a/util/ego/il/il_aux.c b/util/ego/il/il_aux.c index beff6f4dd..2bb5e4564 100644 --- a/util/ego/il/il_aux.c +++ b/util/ego/il/il_aux.c @@ -9,6 +9,7 @@ * I L _ A U X . C */ +#include #include #include #include diff --git a/util/ego/il/proto.make b/util/ego/il/proto.make deleted file mode 100644 index dfeae7ba1..000000000 --- a/util/ego/il/proto.make +++ /dev/null @@ -1,223 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/il -EMH=$(TARGET_HOME)/h -EMCONFIG=$(TARGET_HOME)/config -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(EMCONFIG) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/il.c \ - $(SRC_DIR)/il1_anal.c \ - $(SRC_DIR)/il1_cal.c \ - $(SRC_DIR)/il1_formal.c \ - $(SRC_DIR)/il1_aux.c \ - $(SRC_DIR)/il2_aux.c \ - $(SRC_DIR)/il3_change.c \ - $(SRC_DIR)/il3_subst.c \ - $(SRC_DIR)/il3_aux.c \ - $(SRC_DIR)/il_aux.c - -OFILES=\ - il.$(SUF) il1_anal.$(SUF) il1_cal.$(SUF) il1_formal.$(SUF) \ - il1_aux.$(SUF) il2_aux.$(SUF) il3_change.$(SUF) il3_subst.$(SUF) \ - il3_aux.$(SUF) il_aux.$(SUF) - -HFILES=\ - $(SRC_DIR)/il.h \ - $(SRC_DIR)/il1_anal.h \ - $(SRC_DIR)/il1_cal.h \ - $(SRC_DIR)/il1_formal.h \ - $(SRC_DIR)/il1_aux.h \ - $(SRC_DIR)/il2_aux.h \ - $(SRC_DIR)/il3_change.h \ - $(SRC_DIR)/il3_subst.h \ - $(SRC_DIR)/il3_aux.h \ - $(SRC_DIR)/il_aux.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: il - -il: $(OFILES) - $(CC) -o il $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp il $(EMLIB)/ego/il - -cmp: all - -cmp il $(EMLIB)/ego/il - -clean: - rm -f *.$(SUF) il Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -il.$(SUF): $(SRC_DIR)/il.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il.c -il.$(SUF): $(SRC_DIR)/../share/go.h -il.$(SUF): $(SRC_DIR)/../share/put.h -il.$(SUF): $(SRC_DIR)/../share/get.h -il.$(SUF): $(SRC_DIR)/il3_subst.h -il.$(SUF): $(SRC_DIR)/il2_aux.h -il.$(SUF): $(SRC_DIR)/il1_anal.h -il.$(SUF): $(SRC_DIR)/il_aux.h -il.$(SUF): $(SRC_DIR)/../share/map.h -il.$(SUF): $(SRC_DIR)/../share/files.h -il.$(SUF): $(SRC_DIR)/../share/lset.h -il.$(SUF): $(SRC_DIR)/../share/global.h -il.$(SUF): $(SRC_DIR)/../share/alloc.h -il.$(SUF): $(SRC_DIR)/../share/debug.h -il.$(SUF): $(SRC_DIR)/il.h -il.$(SUF): $(SRC_DIR)/../share/types.h -il.$(SUF): $(EMH)/em_pseu.h -il.$(SUF): $(EMH)/em_mnem.h -il.$(SUF): $(EMCONFIG)/em_path.h -il1_anal.$(SUF): $(SRC_DIR)/il1_anal.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il1_anal.c -il1_anal.$(SUF): $(SRC_DIR)/../share/put.h -il1_anal.$(SUF): $(SRC_DIR)/il_aux.h -il1_anal.$(SUF): $(SRC_DIR)/il1_anal.h -il1_anal.$(SUF): $(SRC_DIR)/il1_cal.h -il1_anal.$(SUF): $(SRC_DIR)/il1_formal.h -il1_anal.$(SUF): $(SRC_DIR)/il1_aux.h -il1_anal.$(SUF): $(SRC_DIR)/../share/aux.h -il1_anal.$(SUF): $(SRC_DIR)/../share/lset.h -il1_anal.$(SUF): $(SRC_DIR)/../share/global.h -il1_anal.$(SUF): $(SRC_DIR)/../share/alloc.h -il1_anal.$(SUF): $(SRC_DIR)/../share/debug.h -il1_anal.$(SUF): $(SRC_DIR)/il.h -il1_anal.$(SUF): $(SRC_DIR)/../share/types.h -il1_anal.$(SUF): $(EMH)/em_pseu.h -il1_anal.$(SUF): $(EMH)/em_mnem.h -il1_cal.$(SUF): $(SRC_DIR)/il1_cal.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il1_cal.c -il1_cal.$(SUF): $(SRC_DIR)/../share/parser.h -il1_cal.$(SUF): $(SRC_DIR)/il1_aux.h -il1_cal.$(SUF): $(SRC_DIR)/../share/lset.h -il1_cal.$(SUF): $(SRC_DIR)/../share/global.h -il1_cal.$(SUF): $(SRC_DIR)/../share/alloc.h -il1_cal.$(SUF): $(SRC_DIR)/../share/debug.h -il1_cal.$(SUF): $(SRC_DIR)/il1_cal.h -il1_cal.$(SUF): $(SRC_DIR)/il.h -il1_cal.$(SUF): $(SRC_DIR)/../share/types.h -il1_cal.$(SUF): $(EMH)/em_mnem.h -il1_cal.$(SUF): $(EMH)/em_spec.h -il1_formal.$(SUF): $(SRC_DIR)/il1_formal.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il1_formal.c -il1_formal.$(SUF): $(SRC_DIR)/il1_formal.h -il1_formal.$(SUF): $(SRC_DIR)/il1_aux.h -il1_formal.$(SUF): $(SRC_DIR)/../share/lset.h -il1_formal.$(SUF): $(SRC_DIR)/../share/global.h -il1_formal.$(SUF): $(SRC_DIR)/../share/alloc.h -il1_formal.$(SUF): $(SRC_DIR)/../share/debug.h -il1_formal.$(SUF): $(SRC_DIR)/il.h -il1_formal.$(SUF): $(SRC_DIR)/../share/types.h -il1_aux.$(SUF): $(SRC_DIR)/il1_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il1_aux.c -il1_aux.$(SUF): $(SRC_DIR)/il1_aux.h -il1_aux.$(SUF): $(SRC_DIR)/il_aux.h -il1_aux.$(SUF): $(SRC_DIR)/../share/lset.h -il1_aux.$(SUF): $(SRC_DIR)/../share/global.h -il1_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -il1_aux.$(SUF): $(SRC_DIR)/../share/debug.h -il1_aux.$(SUF): $(SRC_DIR)/il.h -il1_aux.$(SUF): $(SRC_DIR)/../share/types.h -il1_aux.$(SUF): $(EMH)/em_spec.h -il2_aux.$(SUF): $(SRC_DIR)/il2_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il2_aux.c -il2_aux.$(SUF): $(SRC_DIR)/../share/aux.h -il2_aux.$(SUF): $(SRC_DIR)/../share/get.h -il2_aux.$(SUF): $(SRC_DIR)/il2_aux.h -il2_aux.$(SUF): $(SRC_DIR)/il_aux.h -il2_aux.$(SUF): $(SRC_DIR)/../share/lset.h -il2_aux.$(SUF): $(SRC_DIR)/../share/global.h -il2_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -il2_aux.$(SUF): $(SRC_DIR)/../share/debug.h -il2_aux.$(SUF): $(SRC_DIR)/il.h -il2_aux.$(SUF): $(SRC_DIR)/../share/types.h -il2_aux.$(SUF): $(EMH)/em_mnem.h -il2_aux.$(SUF): $(EMH)/em_spec.h -il3_change.$(SUF): $(SRC_DIR)/il3_change.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il3_change.c -il3_change.$(SUF): $(SRC_DIR)/il3_aux.h -il3_change.$(SUF): $(SRC_DIR)/il3_change.h -il3_change.$(SUF): $(SRC_DIR)/il_aux.h -il3_change.$(SUF): $(SRC_DIR)/../share/put.h -il3_change.$(SUF): $(SRC_DIR)/../share/get.h -il3_change.$(SUF): $(SRC_DIR)/../share/aux.h -il3_change.$(SUF): $(SRC_DIR)/../share/lset.h -il3_change.$(SUF): $(SRC_DIR)/../share/def.h -il3_change.$(SUF): $(SRC_DIR)/../share/global.h -il3_change.$(SUF): $(SRC_DIR)/../share/alloc.h -il3_change.$(SUF): $(SRC_DIR)/../share/debug.h -il3_change.$(SUF): $(SRC_DIR)/il.h -il3_change.$(SUF): $(SRC_DIR)/../share/types.h -il3_change.$(SUF): $(EMH)/em_mes.h -il3_change.$(SUF): $(EMH)/em_spec.h -il3_change.$(SUF): $(EMH)/em_pseu.h -il3_change.$(SUF): $(EMH)/em_mnem.h -il3_subst.$(SUF): $(SRC_DIR)/il3_subst.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il3_subst.c -il3_subst.$(SUF): $(SRC_DIR)/il3_subst.h -il3_subst.$(SUF): $(SRC_DIR)/il3_change.h -il3_subst.$(SUF): $(SRC_DIR)/il3_aux.h -il3_subst.$(SUF): $(SRC_DIR)/il_aux.h -il3_subst.$(SUF): $(SRC_DIR)/../share/get.h -il3_subst.$(SUF): $(SRC_DIR)/../share/lset.h -il3_subst.$(SUF): $(SRC_DIR)/../share/global.h -il3_subst.$(SUF): $(SRC_DIR)/../share/alloc.h -il3_subst.$(SUF): $(SRC_DIR)/../share/debug.h -il3_subst.$(SUF): $(SRC_DIR)/il.h -il3_subst.$(SUF): $(SRC_DIR)/../share/types.h -il3_subst.$(SUF): $(EMH)/em_mnem.h -il3_aux.$(SUF): $(SRC_DIR)/il3_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il3_aux.c -il3_aux.$(SUF): $(SRC_DIR)/il3_aux.h -il3_aux.$(SUF): $(SRC_DIR)/il_aux.h -il3_aux.$(SUF): $(SRC_DIR)/../share/global.h -il3_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -il3_aux.$(SUF): $(SRC_DIR)/../share/debug.h -il3_aux.$(SUF): $(SRC_DIR)/il.h -il3_aux.$(SUF): $(SRC_DIR)/../share/types.h -il_aux.$(SUF): $(SRC_DIR)/il_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/il_aux.c -il_aux.$(SUF): $(SRC_DIR)/il_aux.h -il_aux.$(SUF): $(SRC_DIR)/../share/map.h -il_aux.$(SUF): $(SRC_DIR)/../share/lset.h -il_aux.$(SUF): $(SRC_DIR)/../share/global.h -il_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -il_aux.$(SUF): $(SRC_DIR)/../share/put.h -il_aux.$(SUF): $(SRC_DIR)/../share/get.h -il_aux.$(SUF): $(SRC_DIR)/../share/debug.h -il_aux.$(SUF): $(SRC_DIR)/il.h -il_aux.$(SUF): $(SRC_DIR)/../share/types.h -il_aux.$(SUF): $(EMH)/em_pseu.h -il_aux.$(SUF): $(EMH)/em_mnem.h -il_aux.$(SUF): $(EMH)/em_spec.h diff --git a/util/ego/lv/.distr b/util/ego/lv/.distr deleted file mode 100644 index 634cc49c9..000000000 --- a/util/ego/lv/.distr +++ /dev/null @@ -1,2 +0,0 @@ -lv.c -lv.h diff --git a/util/ego/lv/proto.make b/util/ego/lv/proto.make deleted file mode 100644 index 94e2bc407..000000000 --- a/util/ego/lv/proto.make +++ /dev/null @@ -1,84 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/lv -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/lv.c - -OFILES=\ -lv.$(SUF) - -HFILES=\ - $(SRC_DIR)/lv.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: lv - -lv: $(OFILES) - $(CC) -o lv $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp lv $(EMLIB)/ego/lv - -cmp: all - -cmp lv $(EMLIB)/ego/lv - -clean: - rm -f *.$(SUF) lv Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -lv.$(SUF): $(SRC_DIR)/lv.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lv.c -lv.$(SUF): $(SRC_DIR)/../share/parser.h -lv.$(SUF): $(SRC_DIR)/../share/go.h -lv.$(SUF): $(SRC_DIR)/../share/locals.h -lv.$(SUF): $(SRC_DIR)/../share/init_glob.h -lv.$(SUF): $(SRC_DIR)/../share/aux.h -lv.$(SUF): $(SRC_DIR)/../share/put.h -lv.$(SUF): $(SRC_DIR)/../share/get.h -lv.$(SUF): $(SRC_DIR)/../share/map.h -lv.$(SUF): $(SRC_DIR)/../share/alloc.h -lv.$(SUF): $(SRC_DIR)/../share/files.h -lv.$(SUF): $(SRC_DIR)/../share/def.h -lv.$(SUF): $(SRC_DIR)/../share/cset.h -lv.$(SUF): $(SRC_DIR)/../share/lset.h -lv.$(SUF): $(SRC_DIR)/../share/global.h -lv.$(SUF): $(SRC_DIR)/../share/debug.h -lv.$(SUF): $(SRC_DIR)/lv.h -lv.$(SUF): $(SRC_DIR)/../share/types.h -lv.$(SUF): $(EMH)/em_ego.h -lv.$(SUF): $(EMH)/em_mes.h -lv.$(SUF): $(EMH)/em_spec.h -lv.$(SUF): $(EMH)/em_pseu.h -lv.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/pmfile b/util/ego/pmfile deleted file mode 100644 index 875dd6952..000000000 --- a/util/ego/pmfile +++ /dev/null @@ -1,234 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/ego/" - -local makecldef = cprogram { - cfile (d.."share/makecldef.c") -} - -local classdefs_h = simple { - outputs = {"%U%/classdefs.h"}, - command = { - "%in[1]% %in[2]% %in[3]% > %out[1]%" - }, - - makecldef, - file ("%HEADERDIR%em_mnem.h"), - file (d.."share/cldefs.src") -} - -local pop_push_h = simple { - outputs = {"%U%/pop_push.h"}, - command = { - "awk -f %in[1]% < %in[2]% > %out%" - }, - - file (d.."share/pop_push.awk"), - file ("%ROOTDIR%h/em_table") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - classdefs_h, - pop_push_h - } -} - -local ego_core = cprogram { - CINCLUDES = {PARENT, ("-I"..d.."share")}, - - cfile_with_headers (d.."share/debug.c"), - cfile_with_headers (d.."share/global.c"), - cfile_with_headers (d.."share/files.c"), - cfile_with_headers (d.."share/go.c"), - cfile_with_headers (d.."share/map.c"), - cfile_with_headers (d.."share/aux.c"), - cfile_with_headers (d.."share/get.c"), - cfile_with_headers (d.."share/put.c"), - cfile_with_headers (d.."share/alloc.c"), - cfile_with_headers (d.."share/lset.c"), - cfile_with_headers (d.."share/cset.c"), - cfile_with_headers (d.."share/parser.c"), - cfile_with_headers (d.."share/stack_chg.c"), - cfile_with_headers (d.."share/locals.c"), - cfile_with_headers (d.."share/init_glob.c"), -} - -tool_ego = group { - CDEFINES = {PARENT, "VERBOSE", "NOTCOMPACT"}, - - ego_core { - cfile_with_headers (d.."bo/bo.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/bo") - }, - - ego_core { - cfile_with_headers (d.."ca/ca.c"), - cfile_with_headers (d.."ca/ca_put.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/ca") - }, - - ego_core { - cfile_with_headers (d.."cf/cf.c"), - cfile_with_headers (d.."cf/cf_idom.c"), - cfile_with_headers (d.."cf/cf_loop.c"), - cfile_with_headers (d.."cf/cf_succ.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/cf") - }, - - ego_core { - cfile_with_headers (d.."cj/cj.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/cj") - }, - - ego_core { - cfile_with_headers (d.."cs/cs.c"), - cfile_with_headers (d.."cs/cs_alloc.c"), - cfile_with_headers (d.."cs/cs_aux.c"), - cfile_with_headers (d.."cs/cs_avail.c"), - cfile_with_headers (d.."cs/cs_debug.c"), - cfile_with_headers (d.."cs/cs_elim.c"), - cfile_with_headers (d.."cs/cs_entity.c"), - cfile_with_headers (d.."cs/cs_getent.c"), - cfile_with_headers (d.."cs/cs_kill.c"), - cfile_with_headers (d.."cs/cs_partit.c"), - cfile_with_headers (d.."cs/cs_profit.c"), - cfile_with_headers (d.."cs/cs_stack.c"), - cfile_with_headers (d.."cs/cs_vnm.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/cs") - }, - - ego_core { - cfile_with_headers (d.."ic/ic.c"), - cfile_with_headers (d.."ic/ic_aux.c"), - cfile_with_headers (d.."ic/ic_io.c"), - cfile_with_headers (d.."ic/ic_lib.c"), - cfile_with_headers (d.."ic/ic_lookup.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/ic") - }, - - ego_core { - cfile_with_headers (d.."il/il.c"), - cfile_with_headers (d.."il/il1_anal.c"), - cfile_with_headers (d.."il/il1_aux.c"), - cfile_with_headers (d.."il/il1_cal.c"), - cfile_with_headers (d.."il/il1_formal.c"), - cfile_with_headers (d.."il/il2_aux.c"), - cfile_with_headers (d.."il/il3_aux.c"), - cfile_with_headers (d.."il/il3_change.c"), - cfile_with_headers (d.."il/il3_subst.c"), - cfile_with_headers (d.."il/il_aux.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/il") - }, - - ego_core { - cfile_with_headers (d.."lv/lv.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/lv") - }, - - ego_core { - cfile_with_headers (d.."ra/ra.c"), - cfile_with_headers (d.."ra/ra_allocl.c"), - cfile_with_headers (d.."ra/ra_aux.c"), - cfile_with_headers (d.."ra/ra_interv.c"), - cfile_with_headers (d.."ra/ra_lifet.c"), - cfile_with_headers (d.."ra/ra_pack.c"), - cfile_with_headers (d.."ra/ra_profits.c"), - cfile_with_headers (d.."ra/ra_xform.c"), - cfile { - file (d.."ra/ra_items.c"), - dynamicheaders = { - simple { - outputs = {"%U%/itemtab.h"}, - command = { - "%in[1]% %in[2]% %in[3]% > %out[1]%" - }, - - cprogram { - cfile (d.."ra/makeitems.c"), - }, - file (HEADERDIR.."em_mnem.h"), - file (d.."ra/itemtab.src") - } - } - }, - - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/ra") - }, - - ego_core { - cfile_with_headers (d.."sp/sp.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/sp") - }, - - ego_core { - cfile_with_headers (d.."sr/sr.c"), - cfile_with_headers (d.."sr/sr_aux.c"), - cfile_with_headers (d.."sr/sr_cand.c"), - cfile_with_headers (d.."sr/sr_expr.c"), - cfile_with_headers (d.."sr/sr_iv.c"), - cfile_with_headers (d.."sr/sr_reduce.c"), - cfile_with_headers (d.."sr/sr_xform.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/sr") - }, - - ego_core { - cfile_with_headers (d.."ud/ud.c"), - cfile_with_headers (d.."ud/ud_aux.c"), - cfile_with_headers (d.."ud/ud_const.c"), - cfile_with_headers (d.."ud/ud_copy.c"), - cfile_with_headers (d.."ud/ud_defs.c"), - lib_em_data, - - install = pm.install("%BINDIR%%PLATDEP%/ego/ud") - }, - - cprogram { - cfile (d.."em_ego/em_ego.c"), - - lib_print, - lib_string, - lib_system, - - install = pm.install("%BINDIR%%PLATDEP%/em_ego") - } -} - --- This rule is used by the machine description pmfiles to massage and install --- the ego descr files. - -ego_descr = simple { - outputs = {"%U%-%I%"}, - command = { - "%BINDIR%%PLATDEP%/cpp.ansi -P -I%HEADERDIR% %in[1]% | sed -f %in[2]% > %out[1]%" - }, - - file (d.."descr/%ARCH%.descr"), - file (d.."descr/descr.sed"), - - install = pm.install("%BINDIR%%PLATDEP%/ego/%ARCH%descr") -} diff --git a/util/ego/ra/.distr b/util/ego/ra/.distr deleted file mode 100644 index 7faba06c3..000000000 --- a/util/ego/ra/.distr +++ /dev/null @@ -1,20 +0,0 @@ -itemtab.src -makeitems.c -ra.c -ra.h -ra_allocl.c -ra_allocl.h -ra_aux.c -ra_aux.h -ra_interv.c -ra_interv.h -ra_items.c -ra_items.h -ra_lifet.c -ra_lifet.h -ra_pack.c -ra_pack.h -ra_profits.c -ra_profits.h -ra_xform.c -ra_xform.h diff --git a/util/ego/ra/build.lua b/util/ego/ra/build.lua new file mode 100644 index 000000000..4b934de56 --- /dev/null +++ b/util/ego/ra/build.lua @@ -0,0 +1,32 @@ +cprogram { + name = "makeitems", + srcs = { "./makeitems.c" } +} + +normalrule { + name = "itemtab_h", + ins = { + "+makeitems", + matching(filenamesof("modules/src/em_data+lib"), "em_mnem%.h$"), + "./itemtab.src" + }, + outleaves = { "itemtab.h" }, + commands = { + "%{ins} > %{outs}" + } +} + +cprogram { + name = "ra", + srcs = { "./ra*.c" }, + deps = { + "util/ego/share+lib", + "modules/src/em_data+lib", + "h+emheaders", + "+itemtab_h", + }, + vars = { + ["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"} + } +} + diff --git a/util/ego/ra/proto.make b/util/ego/ra/proto.make deleted file mode 100644 index 24c5576c3..000000000 --- a/util/ego/ra/proto.make +++ /dev/null @@ -1,234 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/ra -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -ULDFLAGS=$(ULDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -I. -CFLAGS=$(CPPFLAGS) $(COPTIONS) -UCFLAGS=$(CPPFLAGS) $(UCOPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/ra.c \ - $(SRC_DIR)/ra_items.c \ - $(SRC_DIR)/ra_lifet.c \ - $(SRC_DIR)/ra_allocl.c \ - $(SRC_DIR)/ra_profits.c \ - $(SRC_DIR)/ra_interv.c \ - $(SRC_DIR)/ra_pack.c \ - $(SRC_DIR)/ra_xform.c \ - $(SRC_DIR)/ra_aux.c - -OFILES=\ - ra.$(SUF) \ - ra_items.$(SUF) \ - ra_lifet.$(SUF) \ - ra_allocl.$(SUF) \ - ra_profits.$(SUF) \ - ra_interv.$(SUF) \ - ra_pack.$(SUF) \ - ra_xform.$(SUF) \ - ra_aux.$(SUF) - -HFILES=\ - $(SRC_DIR)/ra.h \ - $(SRC_DIR)/ra_items.h \ - $(SRC_DIR)/ra_lifet.h \ - $(SRC_DIR)/ra_allocl.h \ - $(SRC_DIR)/ra_profits.h \ - $(SRC_DIR)/ra_interv.h \ - $(SRC_DIR)/ra_pack.h \ - $(SRC_DIR)/ra_xform.h \ - $(SRC_DIR)/ra_aux.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: ra - -ra: $(OFILES) - $(CC) -o ra $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -./itemtab.h: $(SRC_DIR)/itemtab.src $(EMH)/em_mnem.h makeitems - makeitems $(EMH)/em_mnem.h $(SRC_DIR)/itemtab.src > ./itemtab.h - -makeitems: $(SRC_DIR)/makeitems.c - $(UCC) $(UCFLAGS) $(ULDFLAGS) -o makeitems $(SRC_DIR)/makeitems.c - -install: all - cp ra $(EMLIB)/ego/ra - -cmp: all - -cmp ra $(EMLIB)/ego/ra - -clean: - rm -f *.$(SUF) ra Out out nohup.out makeitems ./itemtab.h - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: ./itemtab.h - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -ra.$(SUF): $(SRC_DIR)/ra.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra.c -ra.$(SUF): $(SRC_DIR)/ra_xform.h -ra.$(SUF): $(SRC_DIR)/ra_pack.h -ra.$(SUF): $(SRC_DIR)/ra_profits.h -ra.$(SUF): $(SRC_DIR)/ra_allocl.h -ra.$(SUF): $(SRC_DIR)/ra_items.h -ra.$(SUF): $(SRC_DIR)/ra.h -ra.$(SUF): $(SRC_DIR)/../share/go.h -ra.$(SUF): $(SRC_DIR)/../share/alloc.h -ra.$(SUF): $(SRC_DIR)/../share/map.h -ra.$(SUF): $(SRC_DIR)/../share/lset.h -ra.$(SUF): $(SRC_DIR)/../share/put.h -ra.$(SUF): $(SRC_DIR)/../share/get.h -ra.$(SUF): $(SRC_DIR)/../share/files.h -ra.$(SUF): $(SRC_DIR)/../share/global.h -ra.$(SUF): $(SRC_DIR)/../share/debug.h -ra.$(SUF): $(SRC_DIR)/../share/types.h -ra.$(SUF): $(EMH)/em_reg.h -ra_items.$(SUF): $(SRC_DIR)/ra_items.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_items.c -ra_items.$(SUF): ./itemtab.h -ra_items.$(SUF): $(SRC_DIR)/ra_items.h -ra_items.$(SUF): $(SRC_DIR)/ra_aux.h -ra_items.$(SUF): $(SRC_DIR)/ra.h -ra_items.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_items.$(SUF): $(SRC_DIR)/../share/aux.h -ra_items.$(SUF): $(SRC_DIR)/../share/lset.h -ra_items.$(SUF): $(SRC_DIR)/../share/global.h -ra_items.$(SUF): $(SRC_DIR)/../share/def.h -ra_items.$(SUF): $(SRC_DIR)/../share/debug.h -ra_items.$(SUF): $(SRC_DIR)/../share/types.h -ra_items.$(SUF): $(EMH)/em_reg.h -ra_items.$(SUF): $(EMH)/em_pseu.h -ra_items.$(SUF): $(EMH)/em_spec.h -ra_items.$(SUF): $(EMH)/em_mnem.h -ra_lifet.$(SUF): $(SRC_DIR)/ra_lifet.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_lifet.c -ra_lifet.$(SUF): $(SRC_DIR)/ra_lifet.h -ra_lifet.$(SUF): $(SRC_DIR)/ra_items.h -ra_lifet.$(SUF): $(SRC_DIR)/ra_aux.h -ra_lifet.$(SUF): $(SRC_DIR)/ra.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/aux.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/lset.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/global.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/def.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/debug.h -ra_lifet.$(SUF): $(SRC_DIR)/../share/types.h -ra_lifet.$(SUF): $(EMH)/em_ego.h -ra_lifet.$(SUF): $(EMH)/em_mes.h -ra_lifet.$(SUF): $(EMH)/em_reg.h -ra_lifet.$(SUF): $(EMH)/em_pseu.h -ra_lifet.$(SUF): $(EMH)/em_spec.h -ra_lifet.$(SUF): $(EMH)/em_mnem.h -ra_allocl.$(SUF): $(SRC_DIR)/ra_allocl.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_allocl.c -ra_allocl.$(SUF): $(SRC_DIR)/ra_interv.h -ra_allocl.$(SUF): $(SRC_DIR)/ra_allocl.h -ra_allocl.$(SUF): $(SRC_DIR)/ra_items.h -ra_allocl.$(SUF): $(SRC_DIR)/ra_aux.h -ra_allocl.$(SUF): $(SRC_DIR)/ra.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/map.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/aux.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/cset.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/lset.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/global.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/def.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/debug.h -ra_allocl.$(SUF): $(SRC_DIR)/../share/types.h -ra_allocl.$(SUF): $(EMH)/em_reg.h -ra_allocl.$(SUF): $(EMH)/em_pseu.h -ra_allocl.$(SUF): $(EMH)/em_spec.h -ra_allocl.$(SUF): $(EMH)/em_mnem.h -ra_profits.$(SUF): $(SRC_DIR)/ra_profits.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_profits.c -ra_profits.$(SUF): $(SRC_DIR)/ra_profits.h -ra_profits.$(SUF): $(SRC_DIR)/ra_aux.h -ra_profits.$(SUF): $(SRC_DIR)/ra.h -ra_profits.$(SUF): $(SRC_DIR)/../share/global.h -ra_profits.$(SUF): $(SRC_DIR)/../share/lset.h -ra_profits.$(SUF): $(SRC_DIR)/../share/debug.h -ra_profits.$(SUF): $(SRC_DIR)/../share/types.h -ra_profits.$(SUF): $(EMH)/em_reg.h -ra_interv.$(SUF): $(SRC_DIR)/ra_interv.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_interv.c -ra_interv.$(SUF): $(SRC_DIR)/ra_interv.h -ra_interv.$(SUF): $(SRC_DIR)/ra.h -ra_interv.$(SUF): $(SRC_DIR)/../share/lset.h -ra_interv.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_interv.$(SUF): $(SRC_DIR)/../share/global.h -ra_interv.$(SUF): $(SRC_DIR)/../share/debug.h -ra_interv.$(SUF): $(SRC_DIR)/../share/types.h -ra_interv.$(SUF): $(EMH)/em_reg.h -ra_pack.$(SUF): $(SRC_DIR)/ra_pack.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_pack.c -ra_pack.$(SUF): $(SRC_DIR)/ra_interv.h -ra_pack.$(SUF): $(SRC_DIR)/ra_aux.h -ra_pack.$(SUF): $(SRC_DIR)/ra.h -ra_pack.$(SUF): $(SRC_DIR)/../share/aux.h -ra_pack.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_pack.$(SUF): $(SRC_DIR)/../share/cset.h -ra_pack.$(SUF): $(SRC_DIR)/../share/lset.h -ra_pack.$(SUF): $(SRC_DIR)/../share/global.h -ra_pack.$(SUF): $(SRC_DIR)/../share/def.h -ra_pack.$(SUF): $(SRC_DIR)/../share/debug.h -ra_pack.$(SUF): $(SRC_DIR)/../share/types.h -ra_pack.$(SUF): $(EMH)/em_reg.h -ra_xform.$(SUF): $(SRC_DIR)/ra_xform.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_xform.c -ra_xform.$(SUF): $(SRC_DIR)/ra_items.h -ra_xform.$(SUF): $(SRC_DIR)/ra_xform.h -ra_xform.$(SUF): $(SRC_DIR)/ra_interv.h -ra_xform.$(SUF): $(SRC_DIR)/ra.h -ra_xform.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_xform.$(SUF): $(SRC_DIR)/../share/aux.h -ra_xform.$(SUF): $(SRC_DIR)/../share/lset.h -ra_xform.$(SUF): $(SRC_DIR)/../share/global.h -ra_xform.$(SUF): $(SRC_DIR)/../share/def.h -ra_xform.$(SUF): $(SRC_DIR)/../share/debug.h -ra_xform.$(SUF): $(SRC_DIR)/../share/types.h -ra_xform.$(SUF): $(EMH)/em_reg.h -ra_xform.$(SUF): $(EMH)/em_ego.h -ra_xform.$(SUF): $(EMH)/em_mes.h -ra_xform.$(SUF): $(EMH)/em_pseu.h -ra_xform.$(SUF): $(EMH)/em_spec.h -ra_xform.$(SUF): $(EMH)/em_mnem.h -ra_aux.$(SUF): $(SRC_DIR)/ra_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ra_aux.c -ra_aux.$(SUF): $(SRC_DIR)/ra_aux.h -ra_aux.$(SUF): $(SRC_DIR)/ra.h -ra_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -ra_aux.$(SUF): $(SRC_DIR)/../share/lset.h -ra_aux.$(SUF): $(SRC_DIR)/../share/global.h -ra_aux.$(SUF): $(SRC_DIR)/../share/def.h -ra_aux.$(SUF): $(SRC_DIR)/../share/debug.h -ra_aux.$(SUF): $(SRC_DIR)/../share/types.h -ra_aux.$(SUF): $(EMH)/em_reg.h -ra_aux.$(SUF): $(EMH)/em_pseu.h -ra_aux.$(SUF): $(EMH)/em_spec.h -ra_aux.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/ra/ra_interv.c b/util/ego/ra/ra_interv.c index a6c6b7c1d..b333124ad 100644 --- a/util/ego/ra/ra_interv.c +++ b/util/ego/ra/ra_interv.c @@ -9,6 +9,7 @@ */ +#include #include #include "../share/types.h" #include "../share/debug.h" diff --git a/util/ego/ra/ra_pack.c b/util/ego/ra/ra_pack.c index 3687b44de..373191b90 100644 --- a/util/ego/ra/ra_pack.c +++ b/util/ego/ra/ra_pack.c @@ -8,6 +8,7 @@ * R A _ P A C K . C */ +#include #include #include "../share/types.h" #include "../share/debug.h" diff --git a/util/ego/share/.distr b/util/ego/share/.distr deleted file mode 100644 index 285db26f7..000000000 --- a/util/ego/share/.distr +++ /dev/null @@ -1,36 +0,0 @@ -alloc.c -alloc.h -aux.c -aux.h -cldefs.src -cset.c -cset.h -debug.c -debug.h -def.h -files.c -files.h -get.c -get.h -global.c -global.h -go.c -go.h -init_glob.c -init_glob.h -locals.c -locals.h -lset.c -lset.h -makecldef.c -map.c -map.h -parser.c -parser.h -pop_push.awk -put.c -put.h -show.c -stack_chg.c -stack_chg.h -types.h diff --git a/util/ego/share/build.lua b/util/ego/share/build.lua new file mode 100644 index 000000000..ab1068d2c --- /dev/null +++ b/util/ego/share/build.lua @@ -0,0 +1,61 @@ +cprogram { + name = "makecldef", + srcs = { "./makecldef.c" } +} + +normalrule { + name = "classdefs_h", + ins = { + "+makecldef", + matching(filenamesof("modules/src/em_data+lib"), "em_mnem%.h$"), + "./cldefs.src" + }, + outleaves = { "classdefs.h" }, + commands = { + "%{ins} > %{outs}" + } +} + +normalrule { + name = "pop_push_h", + ins = { + "./pop_push.awk", + "h/em_table", + }, + outleaves = { "pop_push.h" }, + commands = { + "awk -f %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +clibrary { + name = "lib", + srcs = { + "./debug.c", + "./global.c", + "./files.c", + "./go.c", + "./map.c", + "./aux.c", + "./get.c", + "./put.c", + "./alloc.c", + "./lset.c", + "./cset.c", + "./parser.c", + "./stack_chg.c", + "./locals.c", + "./init_glob.c", + }, + deps = { + "+classdefs_h", + "+pop_push_h", + "h+emheaders", + "modules/src/em_data+lib", + }, + vars = { + ["+cflags"] = {"-DVERBOSE", "-DNOTCOMPACT"} + } +} + + diff --git a/util/ego/share/files.c b/util/ego/share/files.c index 8641b353f..644819307 100644 --- a/util/ego/share/files.c +++ b/util/ego/share/files.c @@ -9,9 +9,45 @@ */ #include +#include "files.h" -FILE *openfile(name,mode) - char *name,*mode; +struct files* findfiles(int argc, const char** argv) +{ + static struct files files; + + /* The names of the input files of every phase are passed as + * arguments to the phase. First come the input file names, + * then the output file names. We use a one-letter convention + * to denote the type of file: + * p: procedure table file + * d: data table file + * l: EM text file (lines of EM instructions) + * b: basic block file (Control Flow Graph file) + */ + + /* The input file names */ + + files.pname_in = argv[1]; + files.dname_in = argv[2]; + files.lname_in = argv[3]; + files.bname_in = argv[4]; + + /* The output file names */ + + files.pname_out = argv[5]; + files.dname_out = argv[6]; + files.lname_out = argv[7]; + files.bname_out = argv[8]; + + /* The rest of the arguments. */ + + files.argv = argv + 8; + files.argc = argc - 8; + + return &files; +} + +FILE *openfile(char* name, char* mode) { FILE *f; diff --git a/util/ego/share/files.h b/util/ego/share/files.h index 350bb01ee..72deae081 100644 --- a/util/ego/share/files.h +++ b/util/ego/share/files.h @@ -15,21 +15,29 @@ * b: basic block file (Control Flow Graph file) */ -/* The input file names */ +struct files +{ + /* Input files */ -#define pname argv[1] -#define dname argv[2] -#define lname argv[3] -#define bname argv[4] + const char* pname_in; + const char* dname_in; + const char* lname_in; + const char* bname_in; -/* The output file names */ + /* Output files */ -#define pname2 argv[5] -#define dname2 argv[6] -#define lname2 argv[7] -#define bname2 argv[8] + const char* pname_out; + const char* dname_out; + const char* lname_out; + const char* bname_out; -#define ARGSTART 9 + /* The rest of the arguments. */ + + const char** argv; + int argc; +}; + +extern struct files* findfiles(int argc, const char** argv); extern FILE *openfile(); /* (char *name, *mode) * Open a file with the given name diff --git a/util/ego/share/go.c b/util/ego/share/go.c index 07434e915..53c6bb456 100644 --- a/util/ego/share/go.c +++ b/util/ego/share/go.c @@ -9,120 +9,124 @@ * */ - #include +#include #include "types.h" #include "debug.h" #include "global.h" -#include "files.h" #include "get.h" #include "put.h" #include "lset.h" #include "map.h" #include "alloc.h" #include "go.h" +#include "files.h" - -STATIC bool report_flag = FALSE; /* report #optimizations found? */ +STATIC bool report_flag = FALSE; /* report #optimizations found? */ #ifdef DEBUG -STATIC bool core_flag = FALSE; /* report core usage? */ +STATIC bool core_flag = FALSE; /* report core usage? */ #endif - -STATIC mach_init(machfile,phase_machinit) - char *machfile; - int (*phase_machinit)(); +static mach_init(char* machfile, int (*phase_machinit)()) { /* Read target machine dependent information */ - FILE *f; + FILE* f; - f = openfile(machfile,"r"); - fscanf(f,"%d",&ws); - fscanf(f,"%d",&ps); - if (ws != ps && ps != 2*ws) error("illegal pointer size"); + f = openfile(machfile, "r"); + fscanf(f, "%d", &ws); + fscanf(f, "%d", &ps); + if (ws != ps && ps != 2 * ws) + error("illegal pointer size"); (*phase_machinit)(f); fclose(f); } - - -go(argc,argv,initialize,optimize,phase_machinit,proc_flag) - int argc; - char *argv[]; - int (*initialize)(); - int (*optimize)(); - int (*phase_machinit)(); - int (*proc_flag)(); +void go(int argc, const char** argv, + int (*initialize)(), int (*optimize)(), int (*phase_machinit)(), int (*proc_flag)()) { - FILE *f, *gf, *f2, *gf2; /* The EM input and output and + struct files* files = findfiles(argc, argv); + FILE* f, *gf, *f2, *gf2; /* The EM input and output and * the basic block graphs input and output */ bblock_p g; line_p l; short kind; int i; - char *p; + char* p; bool time_opt = TRUE; linecount = 0; - for (i = ARGSTART; i < argc; i++) { - p = argv[i]; - if (*p++ != '-') error("illegal argument"); - switch(*p) { + opterr = 0; + for (;;) + { + int opt = getopt(files->argc, files->argv, "STM:CQV"); + if (opt == -1) + break; + + switch (opt) + { case 'S': time_opt = FALSE; break; + case 'T': time_opt = TRUE; break; + case 'M': - p++; - mach_init(p,phase_machinit); + mach_init(optarg, phase_machinit); break; + case 'C': #ifdef DEBUG core_flag = TRUE; #endif break; + case 'Q': report_flag = TRUE; break; + case 'V': verbose_flag = TRUE; break; - default: - (*proc_flag)(p); + + case '?': + proc_flag(argv[optind - 1]); break; } } time_space_ratio = (time_opt ? 100 : 0); - fproc = getptable(pname); /* proc table */ - fdblock = getdtable(dname); /* data block table */ + fproc = getptable(files->pname_in); /* proc table */ + fdblock = getdtable(files->dname_in); /* data block table */ (*initialize)(); - if (optimize == no_action) return; - f = openfile(lname,"r"); - gf = openfile(bname,"r"); - f2 = openfile(lname2,"w"); - gf2 = openfile(bname2,"w"); + if (optimize == no_action) + return; + f = openfile(files->lname_in, "r"); + gf = openfile(files->bname_in, "r"); + f2 = openfile(files->lname_out, "w"); + gf2 = openfile(files->bname_out, "w"); mesregs = Lempty_set(); - while (getunit(gf,f,&kind,&g,&l,&curproc,TRUE)) { + while (getunit(gf, f, &kind, &g, &l, &curproc, TRUE)) + { /* Read the control flow graph and EM text of * one procedure and optimize it. */ - if (kind == LDATA) { - putunit(LDATA, (proc_p) 0, l, gf2, f2); + if (kind == LDATA) + { + putunit(LDATA, (proc_p)0, l, gf2, f2); continue; } - OUTTRACE("flow graph of proc %d read",curproc->p_id); + OUTTRACE("flow graph of proc %d read", curproc->p_id); curproc->p_start = g; /* The global variable curproc points to the * current procedure. It is set by getgraph */ (*optimize)(curproc); - putunit(LTEXT,curproc,(line_p) 0,gf2,f2); + putunit(LTEXT, curproc, (line_p)0, gf2, f2); /* output control flow graph + text */ - OUTTRACE("graph of proc %d outputted",curproc->p_id); + OUTTRACE("graph of proc %d outputted", curproc->p_id); Ldeleteset(mesregs); mesregs = Lempty_set(); } @@ -130,34 +134,33 @@ go(argc,argv,initialize,optimize,phase_machinit,proc_flag) fclose(f2); fclose(gf); fclose(gf2); - f = openfile(dname2,"w"); - putdtable(fdblock,f); + f = openfile(files->dname_out, "w"); + putdtable(fdblock, f); /* fclose(f); done by putdtable */ - f = openfile(pname2,"w"); - putptable(fproc,f,TRUE); + f = openfile(files->pname_out, "w"); + putptable(fproc, f, TRUE); /* fclose(f); done by putptable */ core_usage(); } +int no_action() {} -no_action() { } - -core_usage() +void core_usage(void) { #ifdef DEBUG - if (core_flag) { + if (core_flag) + { coreusage(); } #endif } -report(s,n) - char *s; - int n; +void report(char* s, int n) { /* Report number of optimizations found, if report_flag is set */ - if (report_flag) { - fprintf(stderr,"%s: %d\n",s,n); + if (report_flag) + { + fprintf(stderr, "%s: %d\n", s, n); } } diff --git a/util/ego/share/go.h b/util/ego/share/go.h index 86c56f246..8657c0d67 100644 --- a/util/ego/share/go.h +++ b/util/ego/share/go.h @@ -9,31 +9,33 @@ * */ +/* This is the main driving routine of the optimizer. + * It first processes the flags given as argument; + * for every flag it does not recognize itself, it + * calls 'proc_flag'; as soon as the -M flag is seen, + * it opens the machine descriptor file and + * reads phase-independend information (notably the + * wordsize and pointersize of the target machine); + * next it calls 'phase_machinit' with this file as + * parameter. Subsequently it calls 'initialize'. + * Finally, all procedures are read, one at a time, + * and 'optimize' is called with the current procedure + * as parameter. + */ +extern void go(int argc, const char** argv, + int (*initialize)(), int (*optimize)(), + int (*phase_machinit)(), int (*proc_flag)()); -extern go(); /* ( int argc; char *argv[]; - * int (*initialize)(); int (*optimize)(); - * int (*phase_machinit)(); int (*proc_flag)() ) - * This is the main driving routine of the optimizer. - * It first processes the flags given as argument; - * for every flag it does not recognize itself, it - * calls 'proc_flag'; as soon as the -M flag is seen, - * it opens the machine descriptor file and - * reads phase-independend information (notably the - * wordsize and pointersize of the target machine); - * next it calls 'phase_machinit' with this file as - * parameter. Subsequently it calls 'initialize'. - * Finally, all procedures are read, one at a time, - * and 'optimize' is called with the current procedure - * as parameter. - */ -extern no_action(); /* () - * Parameter to be supplied for e.g. 'initialize' if - * no action is required. - */ -extern core_usage(); /* () - * Report core usage, if core_flag is set. - */ -extern report(); /* ( char *s; int n) - * Report number of optimizations found, if - * report_flag is set - */ +/* + * Parameter to be supplied for e.g. 'initialize' if + * no action is required. + */ +extern int no_action(); + +/* Report core usage, if core_flag is set. */ +extern void core_usage(void); + +/* Report number of optimizations found, if + * report_flag is set + */ +extern void report(char* s, int n); diff --git a/util/ego/share/locals.c b/util/ego/share/locals.c index f8d4ba268..b8b92f253 100644 --- a/util/ego/share/locals.c +++ b/util/ego/share/locals.c @@ -7,6 +7,7 @@ * L O C A L S . C */ +#include #include #include #include diff --git a/util/ego/share/lset.c b/util/ego/share/lset.c index d95d256b7..682494a77 100644 --- a/util/ego/share/lset.c +++ b/util/ego/share/lset.c @@ -9,6 +9,7 @@ */ +#include #include "types.h" #include "lset.h" #include "alloc.h" diff --git a/util/ego/share/proto.make b/util/ego/share/proto.make deleted file mode 100644 index 7f67c8bf0..000000000 --- a/util/ego/share/proto.make +++ /dev/null @@ -1,241 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line - -SRC_DIR = $(SRC_HOME)/util/ego/share -EMH=$(TARGET_HOME)/h - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I. -CFLAGS=$(CPPFLAGS) $(COPTIONS) -UCFLAGS=$(CPPFLAGS) $(UCOPTIONS) -ULDFLAGS=$(ULDOPTIONS) - -CFILES=\ - $(SRC_DIR)/debug.c \ - $(SRC_DIR)/global.c \ - $(SRC_DIR)/files.c \ - $(SRC_DIR)/go.c \ - $(SRC_DIR)/map.c \ - $(SRC_DIR)/aux.c \ - $(SRC_DIR)/get.c \ - $(SRC_DIR)/put.c \ - $(SRC_DIR)/alloc.c \ - $(SRC_DIR)/lset.c \ - $(SRC_DIR)/cset.c \ - $(SRC_DIR)/parser.c \ - $(SRC_DIR)/stack_chg.c \ - $(SRC_DIR)/locals.c \ - $(SRC_DIR)/init_glob.c -SRC=\ - $(SRC_DIR)/types.h \ - $(SRC_DIR)/def.h \ - $(SRC_DIR)/debug.h \ - $(SRC_DIR)/global.h \ - $(SRC_DIR)/files.h \ - $(SRC_DIR)/go.h \ - $(SRC_DIR)/map.h \ - $(SRC_DIR)/aux.h \ - $(SRC_DIR)/get.h \ - $(SRC_DIR)/put.h \ - $(SRC_DIR)/alloc.h\ - $(SRC_DIR)/lset.h \ - $(SRC_DIR)/cset.h \ - $(SRC_DIR)/parser.h \ - $(SRC_DIR)/stack_chg.h \ - $(SRC_DIR)/locals.h \ - $(SRC_DIR)/init_glob.h \ - $(CFILES) - -PRFILES=$(SRC) - -OBS = alloc.$(SUF) cset.$(SUF) debug.$(SUF) \ - files.$(SUF) go.$(SUF) global.$(SUF) lset.$(SUF) map.$(SUF) \ - parser.$(SUF) get.$(SUF) put.$(SUF) aux.$(SUF) stack_chg.$(SUF) \ - locals.$(SUF) init_glob.$(SUF) - -all: classdefs.h $(SRC_DIR)/pop_push.h $(OBS) - $(AR) r share.$(LIBSUF) $(OBS) - $(RANLIB) share.$(LIBSUF) - -install: all - -mkdir $(TARGET_HOME)/lib.bin/ego - cp share.$(LIBSUF) $(TARGET_HOME)/lib.bin/ego/share.$(LIBSUF) - $(RANLIB) $(TARGET_HOME)/lib.bin/ego/share.$(LIBSUF) - cp classdefs.h $(TARGET_HOME)/lib.bin/ego/classdefs.h - cp $(SRC_DIR)/pop_push.h $(TARGET_HOME)/lib.bin/ego/pop_push.h - -cmp: all - -cmp share.$(LIBSUF) $(TARGET_HOME)/lib.bin/ego/share.$(LIBSUF) - -cmp classdefs.h $(TARGET_HOME)/lib.bin/ego/classdefs.h - -cmp $(SRC_DIR)/pop_push.h $(TARGET_HOME)/lib.bin/ego/pop_push.h - -classdefs.h: \ - makeclassdef \ - $(SRC_DIR)/cldefs.src - makeclassdef $(EMH)/em_mnem.h $(SRC_DIR)/cldefs.src > classdefs.h - -makeclassdef: \ - $(SRC_DIR)/makecldef.c - $(UCC) $(UCFLAGS) $(ULDFLAGS) -o makeclassdef $(SRC_DIR)/makecldef.c - -$(SRC_DIR)/pop_push.h: \ - $(SRC_HOME)/etc/em_table $(SRC_DIR)/pop_push.awk - awk -f $(SRC_DIR)/pop_push.awk < $(SRC_HOME)/etc/em_table > $(SRC_DIR)/pop_push.h - -show: \ - $(SRC_DIR)/show.c - $(UCC) $(UCFLAGS) $(ULDFLAGS) -o show $(SRC_DIR)/show.c $(UTIL_HOME)/lib.bin/em_data.$(ULIBSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -clean: - rm -f makeclassdef classdefs.h *.$(SUF) Out out nohup.out *.$(LIBSUF) - -lintlib: classdefs.h - -mkdir $(TARGET_HOME)/lib.bin/ego - $(MK_LINT_LIB) share $(TARGET_HOME)/lib.bin/ego $(CPPFLAGS) $(CFILES) - -depend: $(SRC_DIR)/pop_push.h classdefs.h - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line. -#DEPENDENCIES -debug.$(SUF): $(SRC_DIR)/debug.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/debug.c -debug.$(SUF): $(SRC_DIR)/global.h -debug.$(SUF): $(SRC_DIR)/debug.h -debug.$(SUF): $(SRC_DIR)/def.h -debug.$(SUF): $(SRC_DIR)/types.h -debug.$(SUF): $(EMH)/em_spec.h -global.$(SUF): $(SRC_DIR)/global.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/global.c -global.$(SUF): $(SRC_DIR)/types.h -files.$(SUF): $(SRC_DIR)/files.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/files.c -go.$(SUF): $(SRC_DIR)/go.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/go.c -go.$(SUF): $(SRC_DIR)/go.h -go.$(SUF): $(SRC_DIR)/alloc.h -go.$(SUF): $(SRC_DIR)/map.h -go.$(SUF): $(SRC_DIR)/lset.h -go.$(SUF): $(SRC_DIR)/put.h -go.$(SUF): $(SRC_DIR)/get.h -go.$(SUF): $(SRC_DIR)/files.h -go.$(SUF): $(SRC_DIR)/global.h -go.$(SUF): $(SRC_DIR)/debug.h -go.$(SUF): $(SRC_DIR)/types.h -map.$(SUF): $(SRC_DIR)/map.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/map.c -map.$(SUF): $(SRC_DIR)/map.h -map.$(SUF): $(SRC_DIR)/types.h -aux.$(SUF): $(SRC_DIR)/aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/aux.c -aux.$(SUF): $(SRC_DIR)/lset.h -aux.$(SUF): $(SRC_DIR)/map.h -aux.$(SUF): $(SRC_DIR)/aux.h -aux.$(SUF): $(SRC_DIR)/alloc.h -aux.$(SUF): $(SRC_DIR)/global.h -aux.$(SUF): $(SRC_DIR)/debug.h -aux.$(SUF): $(SRC_DIR)/types.h -aux.$(SUF): $(EMH)/em_pseu.h -aux.$(SUF): $(EMH)/em_mes.h -get.$(SUF): $(SRC_DIR)/get.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/get.c -get.$(SUF): $(SRC_DIR)/aux.h -get.$(SUF): $(SRC_DIR)/map.h -get.$(SUF): $(SRC_DIR)/alloc.h -get.$(SUF): $(SRC_DIR)/get.h -get.$(SUF): $(SRC_DIR)/cset.h -get.$(SUF): $(SRC_DIR)/lset.h -get.$(SUF): $(SRC_DIR)/global.h -get.$(SUF): $(SRC_DIR)/debug.h -get.$(SUF): $(SRC_DIR)/def.h -get.$(SUF): $(SRC_DIR)/types.h -get.$(SUF): $(EMH)/em_mes.h -get.$(SUF): $(EMH)/em_pseu.h -get.$(SUF): $(EMH)/em_mnem.h -get.$(SUF): $(EMH)/em_spec.h -put.$(SUF): $(SRC_DIR)/put.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/put.c -put.$(SUF): $(SRC_DIR)/put.h -put.$(SUF): $(SRC_DIR)/alloc.h -put.$(SUF): $(SRC_DIR)/lset.h -put.$(SUF): $(SRC_DIR)/map.h -put.$(SUF): $(SRC_DIR)/def.h -put.$(SUF): $(SRC_DIR)/debug.h -put.$(SUF): $(SRC_DIR)/global.h -put.$(SUF): $(SRC_DIR)/types.h -put.$(SUF): $(EMH)/em_spec.h -put.$(SUF): $(EMH)/em_pseu.h -alloc.$(SUF): $(SRC_DIR)/alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/alloc.c -alloc.$(SUF): $(SRC_DIR)/alloc.h -alloc.$(SUF): $(SRC_DIR)/debug.h -alloc.$(SUF): $(SRC_DIR)/types.h -lset.$(SUF): $(SRC_DIR)/lset.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lset.c -lset.$(SUF): $(SRC_DIR)/debug.h -lset.$(SUF): $(SRC_DIR)/alloc.h -lset.$(SUF): $(SRC_DIR)/lset.h -lset.$(SUF): $(SRC_DIR)/types.h -cset.$(SUF): $(SRC_DIR)/cset.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cset.c -cset.$(SUF): $(SRC_DIR)/global.h -cset.$(SUF): $(SRC_DIR)/debug.h -cset.$(SUF): $(SRC_DIR)/alloc.h -cset.$(SUF): $(SRC_DIR)/cset.h -cset.$(SUF): $(SRC_DIR)/types.h -parser.$(SUF): $(SRC_DIR)/parser.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/parser.c -parser.$(SUF): ./classdefs.h -parser.$(SUF): $(SRC_DIR)/aux.h -parser.$(SUF): $(SRC_DIR)/lset.h -parser.$(SUF): $(SRC_DIR)/global.h -parser.$(SUF): $(SRC_DIR)/alloc.h -parser.$(SUF): $(SRC_DIR)/debug.h -parser.$(SUF): $(SRC_DIR)/types.h -parser.$(SUF): $(EMH)/em_mnem.h -parser.$(SUF): $(EMH)/em_spec.h -stack_chg.$(SUF): $(SRC_DIR)/stack_chg.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/stack_chg.c -stack_chg.$(SUF): $(SRC_DIR)/pop_push.h -stack_chg.$(SUF): $(SRC_DIR)/global.h -stack_chg.$(SUF): $(SRC_DIR)/debug.h -stack_chg.$(SUF): $(SRC_DIR)/types.h -stack_chg.$(SUF): $(EMH)/em_mnem.h -stack_chg.$(SUF): $(EMH)/em_spec.h -locals.$(SUF): $(SRC_DIR)/locals.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/locals.c -locals.$(SUF): $(SRC_DIR)/locals.h -locals.$(SUF): $(SRC_DIR)/alloc.h -locals.$(SUF): $(SRC_DIR)/aux.h -locals.$(SUF): $(SRC_DIR)/get.h -locals.$(SUF): $(SRC_DIR)/def.h -locals.$(SUF): $(SRC_DIR)/cset.h -locals.$(SUF): $(SRC_DIR)/lset.h -locals.$(SUF): $(SRC_DIR)/global.h -locals.$(SUF): $(SRC_DIR)/debug.h -locals.$(SUF): $(SRC_DIR)/types.h -locals.$(SUF): $(EMH)/em_mes.h -locals.$(SUF): $(EMH)/em_pseu.h -locals.$(SUF): $(EMH)/em_spec.h -locals.$(SUF): $(EMH)/em_mnem.h -init_glob.$(SUF): $(SRC_DIR)/init_glob.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/init_glob.c -init_glob.$(SUF): $(SRC_DIR)/map.h -init_glob.$(SUF): $(SRC_DIR)/alloc.h -init_glob.$(SUF): $(SRC_DIR)/global.h -init_glob.$(SUF): $(SRC_DIR)/debug.h -init_glob.$(SUF): $(SRC_DIR)/types.h diff --git a/util/ego/share/put.c b/util/ego/share/put.c index 473443a99..bbb4aedd6 100644 --- a/util/ego/share/put.c +++ b/util/ego/share/put.c @@ -5,6 +5,7 @@ */ /* P U T . C */ +#include #include #include #include diff --git a/util/ego/sp/.distr b/util/ego/sp/.distr deleted file mode 100644 index 583ccc056..000000000 --- a/util/ego/sp/.distr +++ /dev/null @@ -1 +0,0 @@ -sp.c diff --git a/util/ego/sp/proto.make b/util/ego/sp/proto.make deleted file mode 100644 index 358ff7d06..000000000 --- a/util/ego/sp/proto.make +++ /dev/null @@ -1,75 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/sp -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/sp.c - -OFILES=\ -sp.$(SUF) - -HFILES= - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: sp - -sp: $(OFILES) - $(CC) -o sp $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp sp $(EMLIB)/ego/sp - -cmp: all - -cmp sp $(EMLIB)/ego/sp - -clean: - rm -f *.$(SUF) sp Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -sp.$(SUF): $(SRC_DIR)/sp.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sp.c -sp.$(SUF): $(SRC_DIR)/../share/stack_chg.h -sp.$(SUF): $(SRC_DIR)/../share/go.h -sp.$(SUF): $(SRC_DIR)/../share/aux.h -sp.$(SUF): $(SRC_DIR)/../share/alloc.h -sp.$(SUF): $(SRC_DIR)/../share/map.h -sp.$(SUF): $(SRC_DIR)/../share/lset.h -sp.$(SUF): $(SRC_DIR)/../share/put.h -sp.$(SUF): $(SRC_DIR)/../share/get.h -sp.$(SUF): $(SRC_DIR)/../share/files.h -sp.$(SUF): $(SRC_DIR)/../share/global.h -sp.$(SUF): $(SRC_DIR)/../share/debug.h -sp.$(SUF): $(SRC_DIR)/../share/types.h -sp.$(SUF): $(EMH)/em_spec.h -sp.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/sr/.distr b/util/ego/sr/.distr deleted file mode 100644 index f2d3fd886..000000000 --- a/util/ego/sr/.distr +++ /dev/null @@ -1,14 +0,0 @@ -sr.c -sr.h -sr_aux.c -sr_aux.h -sr_cand.c -sr_cand.h -sr_expr.c -sr_expr.h -sr_iv.c -sr_iv.h -sr_reduce.c -sr_reduce.h -sr_xform.c -sr_xform.h diff --git a/util/ego/sr/proto.make b/util/ego/sr/proto.make deleted file mode 100644 index 2c8665c03..000000000 --- a/util/ego/sr/proto.make +++ /dev/null @@ -1,176 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/sr -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/sr.c \ - $(SRC_DIR)/sr_aux.c \ - $(SRC_DIR)/sr_cand.c \ - $(SRC_DIR)/sr_expr.c \ - $(SRC_DIR)/sr_iv.c \ - $(SRC_DIR)/sr_reduce.c \ - $(SRC_DIR)/sr_xform.c - -OFILES=\ - sr.$(SUF) sr_aux.$(SUF) sr_cand.$(SUF) sr_expr.$(SUF) sr_iv.$(SUF) \ - sr_reduce.$(SUF) sr_xform.$(SUF) - -HFILES=\ - $(SRC_DIR)/sr.h \ - $(SRC_DIR)/sr_aux.h \ - $(SRC_DIR)/sr_cand.h \ - $(SRC_DIR)/sr_expr.h \ - $(SRC_DIR)/sr_iv.h \ - $(SRC_DIR)/sr_reduce.h \ - $(SRC_DIR)/sr_xform.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: sr - -sr: $(OFILES) - $(CC) -o sr $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp sr $(EMLIB)/ego/sr - -cmp: all - -cmp sr $(EMLIB)/ego/sr - -clean: - rm -f *.$(SUF) sr Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -sr.$(SUF): $(SRC_DIR)/sr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr.c -sr.$(SUF): $(SRC_DIR)/sr_iv.h -sr.$(SUF): $(SRC_DIR)/sr_aux.h -sr.$(SUF): $(SRC_DIR)/../share/aux.h -sr.$(SUF): $(SRC_DIR)/../share/go.h -sr.$(SUF): $(SRC_DIR)/../share/alloc.h -sr.$(SUF): $(SRC_DIR)/../share/map.h -sr.$(SUF): $(SRC_DIR)/../share/lset.h -sr.$(SUF): $(SRC_DIR)/../share/put.h -sr.$(SUF): $(SRC_DIR)/../share/get.h -sr.$(SUF): $(SRC_DIR)/../share/files.h -sr.$(SUF): $(SRC_DIR)/../share/global.h -sr.$(SUF): $(SRC_DIR)/../share/debug.h -sr.$(SUF): $(SRC_DIR)/sr.h -sr.$(SUF): $(SRC_DIR)/../share/types.h -sr_aux.$(SUF): $(SRC_DIR)/sr_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_aux.c -sr_aux.$(SUF): $(SRC_DIR)/sr_xform.h -sr_aux.$(SUF): $(SRC_DIR)/sr_aux.h -sr_aux.$(SUF): $(SRC_DIR)/../share/aux.h -sr_aux.$(SUF): $(SRC_DIR)/../share/lset.h -sr_aux.$(SUF): $(SRC_DIR)/../share/global.h -sr_aux.$(SUF): $(SRC_DIR)/../share/debug.h -sr_aux.$(SUF): $(SRC_DIR)/sr.h -sr_aux.$(SUF): $(SRC_DIR)/../share/types.h -sr_aux.$(SUF): $(EMH)/em_pseu.h -sr_aux.$(SUF): $(EMH)/em_mnem.h -sr_cand.$(SUF): $(SRC_DIR)/sr_cand.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_cand.c -sr_cand.$(SUF): $(SRC_DIR)/sr_cand.h -sr_cand.$(SUF): $(SRC_DIR)/sr_aux.h -sr_cand.$(SUF): $(SRC_DIR)/sr.h -sr_cand.$(SUF): $(SRC_DIR)/../share/aux.h -sr_cand.$(SUF): $(SRC_DIR)/../share/map.h -sr_cand.$(SUF): $(SRC_DIR)/../share/global.h -sr_cand.$(SUF): $(SRC_DIR)/../share/debug.h -sr_cand.$(SUF): $(SRC_DIR)/../share/cset.h -sr_cand.$(SUF): $(SRC_DIR)/../share/lset.h -sr_cand.$(SUF): $(SRC_DIR)/../share/types.h -sr_cand.$(SUF): $(EMH)/em_pseu.h -sr_cand.$(SUF): $(EMH)/em_mnem.h -sr_expr.$(SUF): $(SRC_DIR)/sr_expr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_expr.c -sr_expr.$(SUF): $(SRC_DIR)/sr_iv.h -sr_expr.$(SUF): $(SRC_DIR)/../share/lset.h -sr_expr.$(SUF): $(SRC_DIR)/sr_aux.h -sr_expr.$(SUF): $(SRC_DIR)/../share/aux.h -sr_expr.$(SUF): $(SRC_DIR)/../share/global.h -sr_expr.$(SUF): $(SRC_DIR)/../share/debug.h -sr_expr.$(SUF): $(SRC_DIR)/sr.h -sr_expr.$(SUF): $(SRC_DIR)/../share/types.h -sr_expr.$(SUF): $(EMH)/em_mnem.h -sr_iv.$(SUF): $(SRC_DIR)/sr_iv.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_iv.c -sr_iv.$(SUF): $(SRC_DIR)/sr_iv.h -sr_iv.$(SUF): $(SRC_DIR)/sr_cand.h -sr_iv.$(SUF): $(SRC_DIR)/sr_aux.h -sr_iv.$(SUF): $(SRC_DIR)/../share/aux.h -sr_iv.$(SUF): $(SRC_DIR)/../share/alloc.h -sr_iv.$(SUF): $(SRC_DIR)/../share/global.h -sr_iv.$(SUF): $(SRC_DIR)/../share/debug.h -sr_iv.$(SUF): $(SRC_DIR)/../share/cset.h -sr_iv.$(SUF): $(SRC_DIR)/../share/lset.h -sr_iv.$(SUF): $(SRC_DIR)/sr.h -sr_iv.$(SUF): $(SRC_DIR)/../share/types.h -sr_iv.$(SUF): $(EMH)/em_pseu.h -sr_iv.$(SUF): $(EMH)/em_mnem.h -sr_reduce.$(SUF): $(SRC_DIR)/sr_reduce.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_reduce.c -sr_reduce.$(SUF): $(SRC_DIR)/sr_expr.h -sr_reduce.$(SUF): $(SRC_DIR)/sr_reduce.h -sr_reduce.$(SUF): $(SRC_DIR)/sr_xform.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/lset.h -sr_reduce.$(SUF): $(SRC_DIR)/sr_aux.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/aux.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/global.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/def.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/alloc.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/debug.h -sr_reduce.$(SUF): $(SRC_DIR)/sr.h -sr_reduce.$(SUF): $(SRC_DIR)/../share/types.h -sr_reduce.$(SUF): $(EMH)/em_spec.h -sr_reduce.$(SUF): $(EMH)/em_mnem.h -sr_reduce.$(SUF): $(EMH)/em_mes.h -sr_reduce.$(SUF): $(EMH)/em_reg.h -sr_reduce.$(SUF): $(EMH)/em_pseu.h -sr_xform.$(SUF): $(SRC_DIR)/sr_xform.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/sr_xform.c -sr_xform.$(SUF): $(SRC_DIR)/sr_xform.h -sr_xform.$(SUF): $(SRC_DIR)/../share/aux.h -sr_xform.$(SUF): $(SRC_DIR)/../share/lset.h -sr_xform.$(SUF): $(SRC_DIR)/sr_aux.h -sr_xform.$(SUF): $(SRC_DIR)/../share/get.h -sr_xform.$(SUF): $(SRC_DIR)/../share/def.h -sr_xform.$(SUF): $(SRC_DIR)/../share/alloc.h -sr_xform.$(SUF): $(SRC_DIR)/../share/global.h -sr_xform.$(SUF): $(SRC_DIR)/../share/debug.h -sr_xform.$(SUF): $(SRC_DIR)/sr.h -sr_xform.$(SUF): $(SRC_DIR)/../share/types.h -sr_xform.$(SUF): $(EMH)/em_spec.h -sr_xform.$(SUF): $(EMH)/em_pseu.h -sr_xform.$(SUF): $(EMH)/em_mnem.h diff --git a/util/ego/sr/sr.h b/util/ego/sr/sr.h index cf301831c..796641587 100644 --- a/util/ego/sr/sr.h +++ b/util/ego/sr/sr.h @@ -57,7 +57,7 @@ struct code_info { #define LP_HEADER lp_extend->lpx_sr.lpx_header #define LP_INSTR lp_extend->lpx_sr.lpx_instr -/* Parameters to be provided by environment: */ +/* parameters.h to be provided by environment: */ extern int ovfl_harmful; /* Does overflow during multiplication * cause a trap ? diff --git a/util/ego/sr/sr_reduce.c b/util/ego/sr/sr_reduce.c index c656dcecb..5b8e78295 100644 --- a/util/ego/sr/sr_reduce.c +++ b/util/ego/sr/sr_reduce.c @@ -10,6 +10,7 @@ */ +#include #include #include #include diff --git a/util/ego/ud/.distr b/util/ego/ud/.distr deleted file mode 100644 index 0d6ef5e95..000000000 --- a/util/ego/ud/.distr +++ /dev/null @@ -1,10 +0,0 @@ -ud.c -ud.h -ud_aux.c -ud_aux.h -ud_const.c -ud_const.h -ud_copy.c -ud_copy.h -ud_defs.c -ud_defs.h diff --git a/util/ego/ud/proto.make b/util/ego/ud/proto.make deleted file mode 100644 index 5beb264da..000000000 --- a/util/ego/ud/proto.make +++ /dev/null @@ -1,158 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/ego/ud -EMH=$(TARGET_HOME)/h -EMLIB=$(TARGET_HOME)/lib.bin - -LDFLAGS=$(LDOPTIONS) -CPPFLAGS=-DVERBOSE -DNOTCOMPACT -I$(EMH) -I$(SRC_DIR) -I$(EMLIB)/ego -CFLAGS=$(CPPFLAGS) $(COPTIONS) -LINTFLAGS=$(CPPFLAGS) $(LINTOPTIONS) - -CFILES=\ - $(SRC_DIR)/ud.c \ - $(SRC_DIR)/ud_defs.c \ - $(SRC_DIR)/ud_const.c \ - $(SRC_DIR)/ud_copy.c \ - $(SRC_DIR)/ud_aux.c - -OFILES=\ - ud.$(SUF) ud_defs.$(SUF) ud_const.$(SUF) ud_copy.$(SUF) \ - ud_aux.$(SUF) - -HFILES=\ - $(SRC_DIR)/ud.h \ - $(SRC_DIR)/ud_defs.h \ - $(SRC_DIR)/ud_const.h \ - $(SRC_DIR)/ud_copy.h \ - $(SRC_DIR)/ud_aux.h - -PRFILES=\ - $(CFILES) $(HFILES) $(SRC_DIR)/proto.make - -all: ud - -ud: $(OFILES) - $(CC) -o ud $(LDFLAGS) $(OFILES) $(EMLIB)/ego/share.$(LIBSUF) $(EMLIB)/em_data.$(LIBSUF) - -install: all - cp ud $(EMLIB)/ego/ud - -cmp: all - -cmp ud $(EMLIB)/ego/ud - -clean: - rm -f *.$(SUF) ud Out out nohup.out - -lint: - $(LINT) $(LINTFLAGS) $(CFILES) $(EMLIB)/ego/$(LINTPREF)share.$(LINTSUF) $(EMLIB)/$(LINTPREF)em_data.$(LINTSUF) - -pr: - @pr $(PRFILES) - -opr: - make pr | opr - -depend: - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(CPPFLAGS) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -# do not remove the next line -#DEPENDENCIES -ud.$(SUF): $(SRC_DIR)/ud.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud.c -ud.$(SUF): $(SRC_DIR)/ud_copy.h -ud.$(SUF): $(SRC_DIR)/ud_const.h -ud.$(SUF): $(SRC_DIR)/ud_defs.h -ud.$(SUF): $(SRC_DIR)/../share/go.h -ud.$(SUF): $(SRC_DIR)/../share/locals.h -ud.$(SUF): $(SRC_DIR)/../share/init_glob.h -ud.$(SUF): $(SRC_DIR)/../share/aux.h -ud.$(SUF): $(SRC_DIR)/../share/alloc.h -ud.$(SUF): $(SRC_DIR)/../share/put.h -ud.$(SUF): $(SRC_DIR)/../share/get.h -ud.$(SUF): $(SRC_DIR)/../share/map.h -ud.$(SUF): $(SRC_DIR)/../share/files.h -ud.$(SUF): $(SRC_DIR)/../share/def.h -ud.$(SUF): $(SRC_DIR)/../share/cset.h -ud.$(SUF): $(SRC_DIR)/../share/lset.h -ud.$(SUF): $(SRC_DIR)/../share/global.h -ud.$(SUF): $(SRC_DIR)/../share/debug.h -ud.$(SUF): $(SRC_DIR)/ud.h -ud.$(SUF): $(SRC_DIR)/../share/types.h -ud.$(SUF): $(EMH)/em_spec.h -ud_defs.$(SUF): $(SRC_DIR)/ud_defs.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud_defs.c -ud_defs.$(SUF): $(SRC_DIR)/../share/aux.h -ud_defs.$(SUF): $(SRC_DIR)/../share/alloc.h -ud_defs.$(SUF): $(SRC_DIR)/ud_defs.h -ud_defs.$(SUF): $(SRC_DIR)/../share/locals.h -ud_defs.$(SUF): $(SRC_DIR)/../share/map.h -ud_defs.$(SUF): $(SRC_DIR)/../share/cset.h -ud_defs.$(SUF): $(SRC_DIR)/../share/lset.h -ud_defs.$(SUF): $(SRC_DIR)/../share/global.h -ud_defs.$(SUF): $(SRC_DIR)/../share/debug.h -ud_defs.$(SUF): $(SRC_DIR)/ud.h -ud_defs.$(SUF): $(SRC_DIR)/../share/types.h -ud_defs.$(SUF): $(EMH)/em_mnem.h -ud_const.$(SUF): $(SRC_DIR)/ud_const.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud_const.c -ud_const.$(SUF): $(SRC_DIR)/ud_aux.h -ud_const.$(SUF): $(SRC_DIR)/ud_const.h -ud_const.$(SUF): $(SRC_DIR)/ud_defs.h -ud_const.$(SUF): $(SRC_DIR)/../share/locals.h -ud_const.$(SUF): $(SRC_DIR)/../share/aux.h -ud_const.$(SUF): $(SRC_DIR)/../share/def.h -ud_const.$(SUF): $(SRC_DIR)/../share/cset.h -ud_const.$(SUF): $(SRC_DIR)/../share/lset.h -ud_const.$(SUF): $(SRC_DIR)/../share/alloc.h -ud_const.$(SUF): $(SRC_DIR)/../share/global.h -ud_const.$(SUF): $(SRC_DIR)/../share/debug.h -ud_const.$(SUF): $(SRC_DIR)/ud.h -ud_const.$(SUF): $(SRC_DIR)/../share/types.h -ud_const.$(SUF): $(EMH)/em_spec.h -ud_const.$(SUF): $(EMH)/em_pseu.h -ud_const.$(SUF): $(EMH)/em_mnem.h -ud_copy.$(SUF): $(SRC_DIR)/ud_copy.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud_copy.c -ud_copy.$(SUF): $(SRC_DIR)/ud_aux.h -ud_copy.$(SUF): $(SRC_DIR)/ud_const.h -ud_copy.$(SUF): $(SRC_DIR)/ud_copy.h -ud_copy.$(SUF): $(SRC_DIR)/../ud/ud_defs.h -ud_copy.$(SUF): $(SRC_DIR)/../share/locals.h -ud_copy.$(SUF): $(SRC_DIR)/../share/aux.h -ud_copy.$(SUF): $(SRC_DIR)/../share/def.h -ud_copy.$(SUF): $(SRC_DIR)/../share/cset.h -ud_copy.$(SUF): $(SRC_DIR)/../share/lset.h -ud_copy.$(SUF): $(SRC_DIR)/../share/alloc.h -ud_copy.$(SUF): $(SRC_DIR)/../share/global.h -ud_copy.$(SUF): $(SRC_DIR)/../share/debug.h -ud_copy.$(SUF): $(SRC_DIR)/ud.h -ud_copy.$(SUF): $(SRC_DIR)/../share/types.h -ud_copy.$(SUF): $(EMH)/em_spec.h -ud_copy.$(SUF): $(EMH)/em_pseu.h -ud_copy.$(SUF): $(EMH)/em_mnem.h -ud_aux.$(SUF): $(SRC_DIR)/ud_aux.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/ud_aux.c -ud_aux.$(SUF): $(SRC_DIR)/ud_defs.h -ud_aux.$(SUF): $(SRC_DIR)/../share/aux.h -ud_aux.$(SUF): $(SRC_DIR)/../share/locals.h -ud_aux.$(SUF): $(SRC_DIR)/../share/def.h -ud_aux.$(SUF): $(SRC_DIR)/../share/cset.h -ud_aux.$(SUF): $(SRC_DIR)/../share/lset.h -ud_aux.$(SUF): $(SRC_DIR)/../share/alloc.h -ud_aux.$(SUF): $(SRC_DIR)/../share/global.h -ud_aux.$(SUF): $(SRC_DIR)/../share/debug.h -ud_aux.$(SUF): $(SRC_DIR)/ud.h -ud_aux.$(SUF): $(SRC_DIR)/../share/types.h -ud_aux.$(SUF): $(EMH)/em_spec.h -ud_aux.$(SUF): $(EMH)/em_pseu.h -ud_aux.$(SUF): $(EMH)/em_mnem.h diff --git a/util/flex/.distr b/util/flex/.distr deleted file mode 100644 index b7fb02916..000000000 --- a/util/flex/.distr +++ /dev/null @@ -1,24 +0,0 @@ -COPYING -Changes -Headers -Makefile -README -ccl.c -dfa.c -ecs.c -flex.1 -flex.skel -flexdef.h -flexdoc.1 -gen.c -initscan.c -libmain.c -main.c -proto.make -misc.c -nfa.c -parse.y -scan.l -sym.c -tblcmp.c -yylex.c diff --git a/util/grind/.distr b/util/grind/.distr deleted file mode 100644 index 097bdb05c..000000000 --- a/util/grind/.distr +++ /dev/null @@ -1,54 +0,0 @@ -Makefile -PROBLEMS -READ_ME -avl.cc -avl.h -c.c -char.ct -class.h -commands.g -db_symtab.g -do_comm.c -expr.c -expr.h -file.hh -grind.1 -idf.c -idf.h -itemlist.cc -langdep.cc -langdep.h -list.c -main.c -make.allocd -make.next -make.ops -make.tokcase -make.tokfile -message.h -misc.h -modula-2.c -operator.h -operators.ot -ops.c -ops.h -pascal.c -position.c -position.h -print.c -proto.main -proto.make -rd.c -rd.h -run.c -scope.cc -scope.h -symbol.c -symbol.hh -token.h -tokenname.c -tokenname.h -tree.c -tree.hh -type.c -type.hh diff --git a/util/grind/run.c b/util/grind/run.c index 0b793ba13..ce19af8e3 100644 --- a/util/grind/run.c +++ b/util/grind/run.c @@ -114,9 +114,7 @@ start_child(p) char *in_redirect = 0; /* standard input redirected */ char *out_redirect = 0; /* standard output redirected */ - signal_child(SIGKILL); /* like families in China, this debugger is only - allowed one child - */ + signal_child(SIGKILL); if (p != run_command) { freenode(run_command); diff --git a/util/int/.distr b/util/int/.distr deleted file mode 100644 index 7b20f911a..000000000 --- a/util/int/.distr +++ /dev/null @@ -1,70 +0,0 @@ -READ_ME -proto.make -M.trap_msg -M.warn_h -M.warn_msg -alloc.h -fra.h -global.h -linfil.h -log.h -mem.h -memdirect.h -monstruct.h -opcode.h -proctab.h -read.h -rsb.h -shadow.h -text.h -trap.h -logging.h -debug.h -nofloat.h -segcheck.h -sysidf.h -v7ioctl.h -e.out.h -alloc.c -core.c -data.c -do_array.c -do_branch.c -do_comp.c -do_conv.c -do_fpar.c -do_incdec.c -do_intar.c -do_load.c -do_logic.c -do_misc.c -do_proc.c -do_ptrar.c -do_sets.c -do_store.c -do_unsar.c -dump.c -disassemble.c -fra.c -global.c -init.c -io.c -log.c -m_ioctl.c -m_sigtrp.c -main.c -moncalls.c -monstruct.c -proctab.c -read.c -rsb.c -segment.c -stack.c -switch.c -tally.c -text.c -trap.c -warn.c -int.1 -switch -test diff --git a/util/int/switch/.distr b/util/int/switch/.distr deleted file mode 100644 index fed3bf61a..000000000 --- a/util/int/switch/.distr +++ /dev/null @@ -1,4 +0,0 @@ -READ_ME -proto.make -mkiswitch.c -mkswitch.c diff --git a/util/int/test/.distr b/util/int/test/.distr deleted file mode 100644 index e66350655..000000000 --- a/util/int/test/.distr +++ /dev/null @@ -1,9 +0,0 @@ -args.c -awa.p -fork2.c -ioc0.c -prtime.c -set.c -sig.c -proto.make -READ_ME diff --git a/util/led/.distr b/util/led/.distr deleted file mode 100644 index 6d4ff4c24..000000000 --- a/util/led/.distr +++ /dev/null @@ -1,25 +0,0 @@ -pmfile -WRONG -ack.out.5 -archive.c -assert.h -const.h -debug.h -defs.h -error.c -extract.c -finish.c -led.6 -mach.c -main.c -memory.c -memory.h -orig.h -output.c -read.c -relocate.c -save.c -scan.c -scan.h -sym.c -write.c diff --git a/util/led/ack.out.5 b/util/led/ack.out.5 index 8e85b3f92..8e34c1a06 100644 --- a/util/led/ack.out.5 +++ b/util/led/ack.out.5 @@ -44,14 +44,14 @@ The header of an object file has the following structure: .PP .nf struct outhead { - unsigned short oh_magic; /* magic number */ - unsigned short oh_stamp; /* version stamp */ - unsigned short oh_flags; /* several format flags */ - unsigned short oh_nsect; /* number of outsect structures */ - unsigned short oh_nrelo; /* number of outrelo structures */ - unsigned short oh_nname; /* number of outname structures */ - long oh_nemit; /* length of sections */ - long oh_nchar; /* size of string area */ + uint16_t oh_magic; /* magic number */ + uint16_t oh_stamp; /* version stamp */ + uint16_t oh_flags; /* several format flags */ + uint16_t oh_nsect; /* number of outsect structures */ + uint16_t oh_nrelo; /* number of outrelo structures */ + uint16_t oh_nname; /* number of outname structures */ + uint32_t oh_nemit; /* length of sections */ + uint32_t oh_nchar; /* size of string area */ }; .fi .PP @@ -92,11 +92,11 @@ An outsect structure has the following layout: .PP .nf struct outsect { - long os_base; /* start address in machine */ - long os_size; /* section size in machine */ - long os_foff; /* start address in file */ - long os_flen; /* section size in file */ - long os_lign; /* section alignment */ + uint32_t os_base; /* start address in machine */ + uint32_t os_size; /* section size in machine */ + uint32_t os_foff; /* start address in file */ + uint32_t os_flen; /* section size in file */ + uint32_t os_lign; /* section alignment */ }; .fi .PP @@ -147,10 +147,10 @@ relocatable datum. The information has the following structure: .PP .nf struct outrelo { - char or_type; /* type of reference */ - char or_sect; /* referencing section */ - unsigned short or_nami; /* referenced symbol index */ - long or_addr; /* referencing address */ + uint16_t or_type; /* type of reference */ + uint16_t or_sect; /* referencing section */ + uint16_t or_nami; /* referenced symbol index */ + uint32_t or_addr; /* referencing address */ }; .fi .PP @@ -158,15 +158,16 @@ struct outrelo { /* * relocation type bits */ -#define RELSZ 0x07 /* relocation length */ +#define RELSZ 0x0fffi /* relocation length */ #define RELO1 0x01 /* 1 byte */ #define RELO2 0x02 /* 2 bytes */ #define RELO4 0x03 /* 4 bytes */ #define RELOPPC 0x04 /* 26-bit PowerPC address */ #define RELOH2 0x05 /* write top 2 bytes of 4 byte word */ -#define RELPC 0x08 /* pc relative */ -#define RELBR 0x10 /* High order byte lowest address. */ -#define RELWR 0x20 /* High order word lowest address. */ +#define RELOVC4 0x06 /* VideoCore IV address in 32-bit insruction */ +#define RELPC 0x2000 /* pc relative */ +#define RELBR 0x4000 /* High order byte lowest address. */ +#define RELWR 0x8000 /* High order word lowest address. */ .fi .PP .nf @@ -231,9 +232,9 @@ struct outname { } on_u; #define on_mptr on_u.on_ptr #define on_foff on_u.on_off - unsigned short on_type; /* symbol type */ - unsigned short on_desc; /* debug info */ - long on_valu; /* symbol value */ + uint16_t on_type; /* symbol type */ + uint16_t on_desc; /* debug info */ + uint32_t on_valu; /* symbol value */ }; .fi .PP @@ -283,15 +284,6 @@ object file. .br The following miscellaneous defines might come in handy when reading object files: -.PP -.nf -/* - * structure format strings - */ -#define SF_HEAD "22222244" -#define SF_SECT "44444" -#define SF_RELO "1124" -#define SF_NAME "4224" .fi .PP .nf @@ -300,7 +292,7 @@ object files: */ #define SZ_HEAD 20 #define SZ_SECT 20 -#define SZ_RELO 8 +#define SZ_RELO 10 #define SZ_NAME 12 .fi .PP diff --git a/util/led/build.lua b/util/led/build.lua new file mode 100644 index 000000000..ed84a79b3 --- /dev/null +++ b/util/led/build.lua @@ -0,0 +1,19 @@ +cprogram { + name = "led", + srcs = { "./*.c" }, + deps = { + "modules/src/string+lib", + "modules/src/object+lib", + "h+emheaders", + } +} + +installable { + name = "pkg", + map = { + ["$(INSDIR)/share/man/man5/ack.out.5"] = "./ack.out.5", + ["$(INSDIR)/share/man/man6/led.6"] = "./led.6", + ["$(PLATDEP)/em_led"] = "+led", + } +} + diff --git a/util/led/mach.c b/util/led/mach.h similarity index 100% rename from util/led/mach.c rename to util/led/mach.h diff --git a/util/led/memory.c b/util/led/memory.c index db5ad72ee..b99447172 100644 --- a/util/led/memory.c +++ b/util/led/memory.c @@ -73,7 +73,7 @@ init_core() register struct memory *mem; extern char *sbrk(); -#include "mach.c" +#include "mach.h" #define ALIGN 8 /* minimum alignment for pieces */ #define AT_LEAST (ind_t)2*ALIGN /* See comment about string areas. */ diff --git a/util/led/pmfile b/util/led/pmfile deleted file mode 100644 index 37aeba090..000000000 --- a/util/led/pmfile +++ /dev/null @@ -1,39 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/led/" - -tool_led = cprogram { - cfile (d.."archive.c"), - cfile (d.."error.c"), - cfile (d.."extract.c"), - cfile (d.."finish.c"), - cfile (d.."main.c"), - cfile (d.."memory.c"), - cfile (d.."output.c"), - cfile (d.."read.c"), - cfile (d.."relocate.c"), - cfile (d.."save.c"), - cfile (d.."scan.c"), - cfile (d.."sym.c"), - cfile (d.."write.c"), - - lib_string, - lib_object, - - outputs = {"%U%/led"}, - install = { - -- FIXME lib.bin in next line needs removing --- pm bug? - pm.install("%BINDIR%%PLATDEP%/em_led"), - pm.install(d.."ack.out.5", "%BINDIR%man/man5/ack.out.5"), - pm.install(d.."led.6", "%BINDIR%man/man6/em_led.6"), - } -} - --- Revision history --- $Log: pmfile,v $ --- Revision 1.2 2006/07/22 20:52:44 dtrg --- led now gets installed into the right place. --- --- Revision 1.1 2006/07/22 20:04:41 dtrg --- Added support for the led link editor. \ No newline at end of file diff --git a/util/led/relocate.c b/util/led/relocate.c index 93b1e9c05..b49e1c549 100644 --- a/util/led/relocate.c +++ b/util/led/relocate.c @@ -8,6 +8,8 @@ static char rcsid[] = "$Id$"; #include #include +#include +#include #include "out.h" #include "const.h" #include "debug.h" @@ -43,14 +45,70 @@ static long read4(char* addr, int type) return ((long)word1 << (2 * WIDTH)) + word0; } +/* VideoCore 4 fixups are complex as we need to patch the instruction in + * one of several different ways (depending on what the instruction is). + */ + +static long get_vc4_valu(char* addr) +{ + uint16_t opcode = read2(addr, 0); + + if ((opcode & 0xff00) == 0xe700) + { + /* ld rd, $+o: [1110 0111 ww 0 d:5] [11111 o:27] + * st rd, $+o: [1110 0111 ww 1 d:5] [11111 o:27] + */ + + int32_t value = read4(addr+2, 0); + value &= 0x07ffffff; + value = value<<5>>5; + return value; + } + + if ((opcode & 0xf080) == 0x9000) + { + /* b $+o*2: [1001 cccc 0ooo oooo] [oooo oooo oooo oooo] + * Yes, big-endian (the first 16 bits is the MSB). + */ + + uint32_t value = read4(addr, RELWR); + value &= 0x007fffff; + value = value<<9>>9; + value *= 2; + return value; + } + + if ((opcode & 0xf080) == 0x9080) + { + /* bl $+o*2: [1001 oooo 1ooo oooo] [oooo oooo oooo oooo] + * Yes, big-endian (the first 16 bits is the MSB). + * (Note that o is split.) + */ + + int32_t value = read4(addr, RELWR); + int32_t lov = value & 0x007fffff; + int32_t hiv = value & 0x0f000000; + value = lov | (hiv>>1); + value = value<<5>>5; + value *= 2; + return value; + } + + if ((opcode & 0xffe0) == 0xe500) + { + /* lea: [1110 0101 000 d:5] [o:32] */ + + return read4(addr+2, 0); + } + + assert(0 && "unrecognised VC4 instruction"); +} + /* * The bits in type indicate how many bytes the value occupies and what * significance should be attributed to each byte. */ -static long -getvalu(addr, type) - char addr[]; - char type; +static long getvalu(char* addr, uint16_t type) { switch (type & RELSZ) { case RELO1: @@ -63,8 +121,10 @@ getvalu(addr, type) return read4(addr, type) & 0x03FFFFFD; case RELOH2: return read2(addr, type) << 16; + case RELOVC4: + return get_vc4_valu(addr); default: - fatal("bad relocation size"); + fatal("bad relocation type %x", type & RELSZ); } /* NOTREACHED */ } @@ -106,16 +166,66 @@ static void write4(long valu, char* addr, int type) } } +/* VideoCore 4 fixups are complex as we need to patch the instruction in + * one of several different ways (depending on what the instruction is). + */ + +static void put_vc4_valu(char* addr, long value) +{ + uint16_t opcode = read2(addr, 0); + + if ((opcode & 0xff00) == 0xe700) + { + /* ld rd, o, (pc): [1110 0111 ww 0 d:5] [11111 o:27] + * st rd, o, (pc): [1110 0111 ww 1 d:5] [11111 o:27] + */ + + uint32_t v = read4(addr+2, 0); + v &= 0xf8000000; + v |= value & 0x07ffffff; + write4(v, addr+2, 0); + } + else if ((opcode & 0xf080) == 0x9000) + { + /* b dest: [1001 cccc 0ooo oooo] [oooo oooo oooo oooo] + * Yes, big-endian (the first 16 bits is the MSB). + */ + + uint32_t v = read4(addr, RELWR); + v &= 0xff800000; + v |= (value/2) & 0x007fffff; + write4(v, addr, RELWR); + } + else if ((opcode & 0xf080) == 0x9080) + { + /* bl dest: [1001 oooo 1ooo oooo] [oooo oooo oooo oooo] + * Yes, big-endian (the first 16 bits is the MSB). + * (Note that o is split.) + */ + + uint32_t v = read4(addr, RELWR); + uint32_t lovalue = (value/2) & 0x007fffff; + uint32_t hivalue = (value/2) & 0x07800000; + v &= 0xf0800000; + v |= lovalue | (hivalue<<1); + write4(v, addr, RELWR); + } + else if ((opcode & 0xffe0) == 0xe500) + { + /* lea: [1110 0101 000 d:5] [o:32] */ + + write4(value, addr+2, 0); + } + else + assert(0 && "unrecognised VC4 instruction"); +} + /* * The bits in type indicate how many bytes the value occupies and what * significance should be attributed to each byte. * We do not check for overflow. */ -static -putvalu(valu, addr, type) - long valu; - char addr[]; - char type; +static putvalu(long valu, char* addr, uint16_t type) { switch (type & RELSZ) { @@ -138,8 +248,11 @@ putvalu(valu, addr, type) case RELOH2: write2(valu>>16, addr, type); break; + case RELOVC4: + put_vc4_valu(addr, valu); + break; default: - fatal("bad relocation size"); + fatal("bad relocation type %x", type & RELSZ); } } diff --git a/util/make/.distr b/util/make/.distr deleted file mode 100644 index 97e95bfb6..000000000 --- a/util/make/.distr +++ /dev/null @@ -1,10 +0,0 @@ -Makefile -README -check.c -h.h -input.c -macro.c -main.c -make.c -reader.c -rules.c diff --git a/util/misc/.distr b/util/misc/.distr deleted file mode 100644 index 85e58eff3..000000000 --- a/util/misc/.distr +++ /dev/null @@ -1,5 +0,0 @@ -pmfile -convert.c -em_decode.6 -esize.1 -esize.c diff --git a/util/misc/build.lua b/util/misc/build.lua new file mode 100644 index 000000000..dd207bbbc --- /dev/null +++ b/util/misc/build.lua @@ -0,0 +1,99 @@ +cprogram { + name = "esize", + srcs = { "./esize.c" }, +} + +cprogram { + name = "encode", + srcs = { "./convert.c" }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_k", + "modules/src/print+lib", + "modules/src/read_em+lib_ev", + "modules/src/string+lib", + "modules/src/system+lib", + "modules/src/em_data+lib", + } +} + +cprogram { + name = "decode", + srcs = { "./convert.c" }, + deps = { + "h+emheaders", + "modules+headers", + "modules/src/alloc+lib", + "modules/src/em_code+lib_e", + "modules/src/print+lib", + "modules/src/read_em+lib_kv", + "modules/src/string+lib", + "modules/src/system+lib", + "modules/src/em_data+lib", + } +} + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_encode"] = "+encode", + ["$(PLATDEP)/em_decode"] = "+decode", + ["$(INSDIR)/bin/esize"] = "+esize", + ["$(PLATIND)/man/man1/esize.1"] = "./esize.1", + ["$(PLATIND)/man/man6/em_decode.6"] = "./em_decode.6" + } +} + +--[[ +D := util/misc + +define build-misc-impl + $(call reset) + $(call cfile, $D/esize.c) + $(call cprogram, $(BINDIR)/esize) + $(call installto, $(INSDIR)/bin/esize) + + $(call reset) + $(eval q := $D/esize.1) + $(call installto, $(INSDIR)/share/man/man1/esize.1) + + $(call reset) + $(eval objdir := encode) + $(call cfile, $D/convert.c) + $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) + $(call rawfile, $(LIBREAD_EMEV)) + $(call rawfile, $(LIBEMK)) + $(call rawfile, $(LIBEM_DATA)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) + $(call cprogram, $(BINDIR)/em_encode) + $(call installto, $(PLATDEP)/em_encode) + $(eval EM_ENCODE := $o) + $(eval ACK_CORE_TOOLS += $o) + + $(call reset) + $(eval objdir := decode) + $(call cfile, $D/convert.c) + $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) + $(call rawfile, $(LIBREAD_EMKV)) + $(call rawfile, $(LIBEME)) + $(call rawfile, $(LIBEM_DATA)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) + $(call cprogram, $(BINDIR)/em_decode) + $(call installto, $(PLATDEP)/em_decode) + $(eval EM_DECODE := $o) + + $(call reset) + $(eval q := $D/em_decode.6) + $(call installto, $(INSDIR)/share/man/man6/em_decode.6) +endef + +$(eval $(build-misc-impl)) +--]] diff --git a/util/misc/pmfile b/util/misc/pmfile deleted file mode 100644 index f82d1ad88..000000000 --- a/util/misc/pmfile +++ /dev/null @@ -1,59 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/misc/" - -tool_em_decode = cprogram { - cfile (d.."convert.c"), - - lib_read_emkV, - lib_eme, - lib_em_data, - lib_alloc, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_decode"}, - install = { - -- FIXME lib.bin in next line needs removing --- pm bug? - pm.install("%BINDIR%lib.bin/em_decode"), - pm.install(d.."em_decode.6", "%BINDIR%man/man6/em_decode.6"), - } -} - -tool_em_encode = cprogram { - cfile (d.."convert.c"), - - lib_read_emeV, - lib_emk, - lib_em_data, - lib_alloc, - lib_print, - lib_string, - lib_system, - - outputs = {"%U%/em_encode"}, - install = { - pm.install("%BINDIR%%PLATDEP%/em_encode"), - pm.install(d.."em_decode.6", "%BINDIR%man/man6/em_decode.6") - } -} - -tool_esize = cprogram { - cfile (d.."esize.c"), - - outputs = {"%U%/esize"}, - install = { - pm.install("%BINDIR%/bin/esize"), - pm.install(d.."esize.1", "%BINDIR%man/man1/esize.1") - } -} - --- Revision history --- $Log$ --- Revision 1.2 2006-07-22 20:10:41 dtrg --- Added support for the esize object inspection tool. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. \ No newline at end of file diff --git a/util/ncgg/.distr b/util/ncgg/.distr deleted file mode 100644 index f90b6e519..000000000 --- a/util/ncgg/.distr +++ /dev/null @@ -1,35 +0,0 @@ -pmfile -assert.h -cgg.y -coerc.c -cost.h -cvtkeywords -emlookup.c -error.c -expr.c -expr.h -extern.h -hall.c -instruct.c -instruct.h -iocc.c -iocc.h -keywords -lookup.c -lookup.h -main.c -output.c -param.h -property.h -pseudo.h -reg.h -regvar.h -scan.l -set.c -set.h -strlookup.c -subr.c -token.h -var.c -varinfo.h -ncgg.6 diff --git a/util/ncgg/build.lua b/util/ncgg/build.lua new file mode 100644 index 000000000..b82f3f340 --- /dev/null +++ b/util/ncgg/build.lua @@ -0,0 +1,76 @@ +include("first/yacc.lua") + +local cggparser = yacc { + name = "cggparser", + srcs = { "./cgg.y" } +} + +local cgglexer = flex { + name = "cgglexer", + srcs = { "./scan.l" } +} + +normalrule { + name = "keywords", + ins = { + "./cvtkeywords", + "./keywords", + matching(filenamesof(cggparser), "%.h$") + }, + outleaves = { "enterkeyw.c" }, + commands = { + "%{ins[1]} %{ins[2]} %{ins[3]} %{outs[1]}" + } +} + +cprogram { + name = "ncgg", + srcs = concat( + "./*.c", + matching(filenamesof(cggparser), "%.c$"), + matching(filenamesof(cgglexer), "%.c$"), + "+keywords" + ), + deps = { + "+cggparser", -- for .h file + "+cgglexer", -- for .h file + "h+emheaders", + "modules/src/em_data+lib", + } +} + +definerule("ncgg", + { + srcs = { type="targets" } + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + if (#e.srcs ~= 1) then + error("you must supply exactly one input file") + end + + local cpptable = cppfile { + name = e.name.."/cpptable", + outleaf = "cpptable", + srcs = e.srcs + } + + return normalrule { + name = e.name, + cwd = e.cwd, + outleaves = { + "tables.c", + "tables.h", + }, + ins = { + "util/ncgg+ncgg", + cpptable + }, + commands = { + "cd %{dir} && %{ins}", + "mv %{dir}/tables.H %{dir}/tables.h" + } + } + end +) diff --git a/util/ncgg/cgg.y b/util/ncgg/cgg.y index f46d2d724..24948abad 100644 --- a/util/ncgg/cgg.y +++ b/util/ncgg/cgg.y @@ -1100,4 +1100,3 @@ optregvartype { $$ = $2; } ; %% -#include "scan.c" diff --git a/util/ncgg/cvtkeywords b/util/ncgg/cvtkeywords index 85b7e035c..a478b3f1a 100755 --- a/util/ncgg/cvtkeywords +++ b/util/ncgg/cvtkeywords @@ -1,8 +1,8 @@ #!/bin/sh : '$Id$' -grep '^#' y.tab.h >tokendefs -ed -s $1 <<'!Funky!Stuff!' +grep '^#' $2 >tokendefs +ed -s $1 > $3 <<'!Funky!Stuff!' g/^#/d 1,$s/\([^ ]*\)[ ][ ]*\(.*\)/ sy_p=lookup("\1",symkeyw,newsymbol);sy_p->sy_value.syv_keywno=\2;/ 1i @@ -18,7 +18,8 @@ enterkeyw() { $a } . -w enterkeyw.c +,p q !Funky!Stuff! rm tokendefs + diff --git a/util/ncgg/emlookup.c b/util/ncgg/emlookup.c index 6d0d9a3f1..6927f9259 100644 --- a/util/ncgg/emlookup.c +++ b/util/ncgg/emlookup.c @@ -10,6 +10,7 @@ static char rcsid[]= "$Id$"; #include #include "param.h" #include "expr.h" +#include "extern.h" #include #include diff --git a/util/ncgg/error.c b/util/ncgg/error.c index 48cac2c00..5d083d577 100644 --- a/util/ncgg/error.c +++ b/util/ncgg/error.c @@ -8,6 +8,8 @@ static char rcsid[]= "$Id$"; #include #include +#include +#include "extern.h" int nerrors=0; @@ -24,24 +26,38 @@ goodbye() { #endif } -/*VARARGS1*/ -fatal(s,a,b,c,d) char *s; { +void errorv(const char* s, va_list ap) +{ + extern int lineno; + extern char *filename; + + fprintf(stderr, "\"%s\", line %d:", filename, lineno); + vfprintf(stderr, s, ap); + fprintf(stderr, "\n"); + nerrors++; +} + +void fatal(const char* s, ...) +{ + + va_list ap; + + va_start(ap, s); + errorv(s, ap); + va_end(ap); - error(s,a,b,c,d); errorexit(); goodbye(); exit(-1); } -/*VARARGS1*/ -error(s,a,b,c,d) char *s; { - extern int lineno; - extern char *filename; +void error(const char* s, ...) +{ + va_list ap; - fprintf(stderr,"\"%s\", line %d:",filename,lineno); - fprintf(stderr,s,a,b,c,d); - fprintf(stderr,"\n"); - nerrors++; + va_start(ap, s); + errorv(s, ap); + va_end(ap); } #ifndef NDEBUG diff --git a/util/ncgg/extern.h b/util/ncgg/extern.h index 8a9604fa7..909e04774 100644 --- a/util/ncgg/extern.h +++ b/util/ncgg/extern.h @@ -41,3 +41,7 @@ extern int use_noframepointer; extern char *mystrcpy(); extern char *myalloc(); + +extern void error(const char* s, ...); +extern void fatal(const char* s, ...); + diff --git a/util/ncgg/hall.c b/util/ncgg/hall.c index b22f03210..f8a5364c7 100644 --- a/util/ncgg/hall.c +++ b/util/ncgg/hall.c @@ -9,6 +9,7 @@ static char rcsid[]= "$Id$"; #include "assert.h" #include "param.h" #include "set.h" +#include "extern.h" #include /* diff --git a/util/ncgg/lookup.c b/util/ncgg/lookup.c index c59610fdd..ab31baebc 100644 --- a/util/ncgg/lookup.c +++ b/util/ncgg/lookup.c @@ -9,6 +9,7 @@ static char rcsid[]= "$Id$"; #include "assert.h" #include "param.h" #include "lookup.h" +#include "extern.h" char *myalloc(); char *mystrcpy(); diff --git a/util/ncgg/main.c b/util/ncgg/main.c index 2c805e7a8..330e08c98 100644 --- a/util/ncgg/main.c +++ b/util/ncgg/main.c @@ -8,6 +8,7 @@ static char rcsid[]= "$Id$"; #include #include +#include "extern.h" char *filename; char *beg_sbrk; diff --git a/util/ncgg/pmfile b/util/ncgg/pmfile deleted file mode 100644 index 21ce2d92c..000000000 --- a/util/ncgg/pmfile +++ /dev/null @@ -1,67 +0,0 @@ --- $Source$ --- $State$ - -local d = "util/ncgg/" - -local ncgg_yacc = yacc { - file (d.."cgg.y") -} - -tool_ncgg = cprogram { - cfile (d.."subr.c"), - cfile (d.."main.c"), - cfile (d.."coerc.c"), - cfile (d.."error.c"), - cfile (d.."emlookup.c"), - cfile (d.."expr.c"), - cfile (d.."instruct.c"), - cfile (d.."iocc.c"), - cfile (d.."lookup.c"), - cfile (d.."output.c"), - cfile (d.."set.c"), - cfile (d.."strlookup.c"), - cfile (d.."var.c"), - cfile (d.."hall.c"), - - cfile { - CEXTRAFLAGS = "-I"..d, - - ncgg_yacc, - dynamicheaders = flex { - file (d.."scan.l") - } - }, - - cfile { - CEXTRAFLAGS = "-I"..d, - simple { - outputs = {"%U%/enterkeyw.c"}, - - command = { - "cp %{return posix.dirname(self['in'][3])}%/y.tab.h %{return posix.dirname(self.out[1])}%", - "cd %{return posix.dirname(self.out[1])}% && "..ROOTDIR..d.."cvtkeywords "..ROOTDIR..d.."keywords", - }, - - file (d.."cvtkeywords"), - file (d.."keywords"), - ncgg_yacc - }, - - dynamicheaders = ncgg_yacc - }, - - lib_em_data, - - outputs = {"%U%-ncgg"}, - install = pm.install(TOOLDIR.."ncgg") -} - -ncgg = simple { - class = "ncgg", - - outputs = {"%U%/tables.c", "%U%/tables.h"}, - command = { - "cd %out[1]:dirname% && (%BINDIR%%PLATDEP%/cpp.ansi -I%NCGGINCLUDEDIR% %in% | %TOOLDIR%ncgg)", - "mv %out[1]:dirname%/tables.H %out[2]%" - }, -} diff --git a/util/ncgg/proto.make b/util/ncgg/proto.make deleted file mode 100644 index 9adc5cd46..000000000 --- a/util/ncgg/proto.make +++ /dev/null @@ -1,255 +0,0 @@ -# Header: Makefile,v 0.8 87/11/16 10:35:32 ceriel Exp $ - -#PARAMS do not remove this line! - -CFILES= cgg.c $(SRC_DIR)/subr.c $(SRC_DIR)/main.c $(SRC_DIR)/coerc.c \ - enterkeyw.c $(SRC_DIR)/error.c $(SRC_DIR)/emlookup.c $(SRC_DIR)/expr.c \ - $(SRC_DIR)/instruct.c $(SRC_DIR)/iocc.c $(SRC_DIR)/lookup.c \ - $(SRC_DIR)/output.c $(SRC_DIR)/set.c $(SRC_DIR)/strlookup.c \ - $(SRC_DIR)/var.c $(SRC_DIR)/hall.c -OFILES= cgg.$(SUF) subr.$(SUF) main.$(SUF) coerc.$(SUF) enterkeyw.$(SUF) \ - error.$(SUF) emlookup.$(SUF) expr.$(SUF) instruct.$(SUF) iocc.$(SUF) \ - lookup.$(SUF) set.$(SUF) strlookup.$(SUF) var.$(SUF) hall.$(SUF) -SOURCES=$(SRC_DIR)/*.h $(SRC_DIR)/cgg.y $(SRC_DIR)/scan.l \ - $(SRC_DIR)/cvtkeywords $(SRC_DIR)/keywords $(SRC_DIR)/coerc.c \ - $(SRC_DIR)/emlookup.c $(SRC_DIR)/error.c $(SRC_DIR)/expr.c \ - $(SRC_DIR)/hall.c $(SRC_DIR)/instruct.c $(SRC_DIR)/iocc.c \ - $(SRC_DIR)/lookup.c $(SRC_DIR)/main.c $(SRC_DIR)/output.c \ - $(SRC_DIR)/set.c $(SRC_DIR)/strlookup.c $(SRC_DIR)/subr.c \ - $(SRC_DIR)/var.c - -SRC_DIR=$(SRC_HOME)/util/ncgg -EMH=$(TARGET_HOME)/h -INCLUDES=-I$(EMH) -I$(TARGET_HOME)/config -I$(SRC_DIR) -I. -CFLAGS=$(INCLUDES) $(COPTIONS) -DNDEBUG -YFLAGS=-d -LDFLAGS=$(LDOPTIONS) -LINTFLAGS=$(INCLUDES) $(LINTOPTIONS) - - -cgg: cgg.$(SUF) $(OFILES) output.$(SUF) - $(CC) $(LDFLAGS) $(OFILES) output.$(SUF) $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) -o cgg - -install: cgg - cp cgg $(TARGET_HOME)/lib.bin/ncgg - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/ncgg.6 $(TARGET_HOME) ; \ - fi - -cmp: cgg - -cmp cgg $(TARGET_HOME)/lib.bin/ncgg - -debugcgg: cgg.$(SUF) $(OFILES) debugoutput.$(SUF) - $(CC) $(LDFLAGS) $(OFILES) debugoutput.$(SUF) $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) -o cgg - -cgg.c: $(SRC_DIR)/cgg.y - yacc $(YFLAGS) $(SRC_DIR)/cgg.y && mv y.tab.c cgg.c - -enterkeyw.c: $(SRC_DIR)/cvtkeywords $(SRC_DIR)/keywords y.tab.h - $(SRC_DIR)/cvtkeywords $(SRC_DIR)/keywords - -debugoutput.$(SUF): debugoutput.c - $(CC) $(CFLAGS) -DCODEDEBUG -c debugoutput.c - -debugoutput.c: $(SRC_DIR)/output.c - cp $(SRC_DIR)/output.c debugoutput.c - -lint: $(CFILES) - $(LINT) $(LINTFLAGS) $(CFILES) - -clean: - rm -f cgg.c scan.c y.output y.tab.h enterkeyw.c debugoutput.c - rm -f $(OFILES) output.$(SUF) debugoutput.$(SUF) cgg lint - -scan.c: $(SRC_DIR)/scan.l - flex -st $(SRC_DIR)/scan.l > scan.c - -pr: - @pr $(SOURCES) - -opr: - -make pr|opr - -depend: $(CFILES) scan.c - rm_deps Makefile >Makefile.new - for i in $(CFILES) ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(INCLUDES) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -#DEPENDENCIES -cgg.$(SUF): cgg.c - $(CC) -c $(CFLAGS) cgg.c -cgg.$(SUF): scan.c -cgg.$(SUF): $(TARGET_HOME)/h/em_reg.h -cgg.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -cgg.$(SUF): $(SRC_DIR)/extern.h -cgg.$(SUF): $(SRC_DIR)/expr.h -cgg.$(SUF): $(SRC_DIR)/cost.h -cgg.$(SUF): $(SRC_DIR)/instruct.h -cgg.$(SUF): $(SRC_DIR)/iocc.h -cgg.$(SUF): $(SRC_DIR)/set.h -cgg.$(SUF): $(SRC_DIR)/lookup.h -cgg.$(SUF): $(SRC_DIR)/varinfo.h -cgg.$(SUF): $(TARGET_HOME)/h/em_spec.h -cgg.$(SUF): $(TARGET_HOME)/config/local.h -cgg.$(SUF): $(SRC_DIR)/param.h -subr.$(SUF): $(SRC_DIR)/subr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/subr.c -subr.$(SUF): $(SRC_DIR)/extern.h -subr.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -subr.$(SUF): $(SRC_DIR)/regvar.h -subr.$(SUF): $(SRC_DIR)/token.h -subr.$(SUF): $(SRC_DIR)/cost.h -subr.$(SUF): $(SRC_DIR)/instruct.h -subr.$(SUF): $(SRC_DIR)/varinfo.h -subr.$(SUF): $(SRC_DIR)/set.h -subr.$(SUF): $(SRC_DIR)/expr.h -subr.$(SUF): $(SRC_DIR)/property.h -subr.$(SUF): $(SRC_DIR)/lookup.h -subr.$(SUF): $(SRC_DIR)/reg.h -subr.$(SUF): $(TARGET_HOME)/h/em_spec.h -subr.$(SUF): $(TARGET_HOME)/config/local.h -subr.$(SUF): $(SRC_DIR)/param.h -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c -coerc.$(SUF): $(SRC_DIR)/coerc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/coerc.c -coerc.$(SUF): $(SRC_DIR)/extern.h -coerc.$(SUF): $(SRC_DIR)/pseudo.h -coerc.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -coerc.$(SUF): $(SRC_DIR)/iocc.h -coerc.$(SUF): $(SRC_DIR)/varinfo.h -coerc.$(SUF): $(SRC_DIR)/cost.h -coerc.$(SUF): $(SRC_DIR)/token.h -coerc.$(SUF): $(SRC_DIR)/reg.h -coerc.$(SUF): $(SRC_DIR)/property.h -coerc.$(SUF): $(SRC_DIR)/set.h -coerc.$(SUF): $(TARGET_HOME)/h/em_spec.h -coerc.$(SUF): $(TARGET_HOME)/config/local.h -coerc.$(SUF): $(SRC_DIR)/param.h -coerc.$(SUF): $(SRC_DIR)/assert.h -enterkeyw.$(SUF): enterkeyw.c - $(CC) -c $(CFLAGS) enterkeyw.c -enterkeyw.$(SUF): $(SRC_DIR)/lookup.h -error.$(SUF): $(SRC_DIR)/error.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/error.c -emlookup.$(SUF): $(SRC_DIR)/emlookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/emlookup.c -emlookup.$(SUF): $(TARGET_HOME)/h/em_flag.h -emlookup.$(SUF): $(SRC_DIR)/expr.h -emlookup.$(SUF): $(TARGET_HOME)/h/em_spec.h -emlookup.$(SUF): $(TARGET_HOME)/config/local.h -emlookup.$(SUF): $(SRC_DIR)/param.h -expr.$(SUF): $(SRC_DIR)/expr.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/expr.c -expr.$(SUF): $(SRC_DIR)/extern.h -expr.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -expr.$(SUF): $(SRC_DIR)/regvar.h -expr.$(SUF): $(SRC_DIR)/expr.h -expr.$(SUF): $(SRC_DIR)/property.h -expr.$(SUF): $(SRC_DIR)/cost.h -expr.$(SUF): $(SRC_DIR)/token.h -expr.$(SUF): $(SRC_DIR)/lookup.h -expr.$(SUF): $(SRC_DIR)/reg.h -expr.$(SUF): $(SRC_DIR)/set.h -expr.$(SUF): $(TARGET_HOME)/h/em_spec.h -expr.$(SUF): $(TARGET_HOME)/config/local.h -expr.$(SUF): $(SRC_DIR)/param.h -expr.$(SUF): $(SRC_DIR)/assert.h -instruct.$(SUF): $(SRC_DIR)/instruct.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/instruct.c -instruct.$(SUF): $(SRC_DIR)/extern.h -instruct.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -instruct.$(SUF): $(SRC_DIR)/iocc.h -instruct.$(SUF): $(SRC_DIR)/expr.h -instruct.$(SUF): $(SRC_DIR)/set.h -instruct.$(SUF): $(SRC_DIR)/varinfo.h -instruct.$(SUF): $(SRC_DIR)/pseudo.h -instruct.$(SUF): $(SRC_DIR)/cost.h -instruct.$(SUF): $(SRC_DIR)/instruct.h -instruct.$(SUF): $(TARGET_HOME)/h/em_spec.h -instruct.$(SUF): $(TARGET_HOME)/config/local.h -instruct.$(SUF): $(SRC_DIR)/param.h -iocc.$(SUF): $(SRC_DIR)/iocc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/iocc.c -iocc.$(SUF): $(SRC_DIR)/extern.h -iocc.$(SUF): $(SRC_DIR)/regvar.h -iocc.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -iocc.$(SUF): $(SRC_DIR)/iocc.h -iocc.$(SUF): $(SRC_DIR)/property.h -iocc.$(SUF): $(SRC_DIR)/cost.h -iocc.$(SUF): $(SRC_DIR)/token.h -iocc.$(SUF): $(SRC_DIR)/lookup.h -iocc.$(SUF): $(SRC_DIR)/expr.h -iocc.$(SUF): $(SRC_DIR)/set.h -iocc.$(SUF): $(TARGET_HOME)/h/em_spec.h -iocc.$(SUF): $(TARGET_HOME)/config/local.h -iocc.$(SUF): $(SRC_DIR)/param.h -iocc.$(SUF): $(SRC_DIR)/assert.h -lookup.$(SUF): $(SRC_DIR)/lookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lookup.c -lookup.$(SUF): $(SRC_DIR)/lookup.h -lookup.$(SUF): $(TARGET_HOME)/h/em_spec.h -lookup.$(SUF): $(TARGET_HOME)/config/local.h -lookup.$(SUF): $(SRC_DIR)/param.h -lookup.$(SUF): $(SRC_DIR)/assert.h -output.$(SUF): $(SRC_DIR)/output.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/output.c -output.$(SUF): $(SRC_DIR)/extern.h -output.$(SUF): $(SRC_DIR)/regvar.h -output.$(SUF): $(SRC_DIR)/pseudo.h -output.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -output.$(SUF): $(SRC_DIR)/lookup.h -output.$(SUF): $(SRC_DIR)/instruct.h -output.$(SUF): $(SRC_DIR)/set.h -output.$(SUF): $(SRC_DIR)/cost.h -output.$(SUF): $(SRC_DIR)/token.h -output.$(SUF): $(SRC_DIR)/property.h -output.$(SUF): $(SRC_DIR)/reg.h -output.$(SUF): $(TARGET_HOME)/h/em_spec.h -output.$(SUF): $(TARGET_HOME)/config/local.h -output.$(SUF): $(SRC_DIR)/param.h -output.$(SUF): $(SRC_DIR)/varinfo.h -output.$(SUF): $(SRC_DIR)/assert.h -set.$(SUF): $(SRC_DIR)/set.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/set.c -set.$(SUF): $(SRC_DIR)/extern.h -set.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -set.$(SUF): $(SRC_DIR)/reg.h -set.$(SUF): $(SRC_DIR)/lookup.h -set.$(SUF): $(SRC_DIR)/cost.h -set.$(SUF): $(SRC_DIR)/token.h -set.$(SUF): $(SRC_DIR)/set.h -set.$(SUF): $(SRC_DIR)/property.h -set.$(SUF): $(TARGET_HOME)/h/em_spec.h -set.$(SUF): $(TARGET_HOME)/config/local.h -set.$(SUF): $(SRC_DIR)/param.h -strlookup.$(SUF): $(SRC_DIR)/strlookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/strlookup.c -strlookup.$(SUF): $(TARGET_HOME)/h/em_spec.h -strlookup.$(SUF): $(TARGET_HOME)/config/local.h -strlookup.$(SUF): $(SRC_DIR)/param.h -var.$(SUF): $(SRC_DIR)/var.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/var.c -var.$(SUF): $(TARGET_HOME)/h/cgg_cg.h -var.$(SUF): $(SRC_DIR)/lookup.h -var.$(SUF): $(SRC_DIR)/instruct.h -var.$(SUF): $(SRC_DIR)/set.h -var.$(SUF): $(SRC_DIR)/cost.h -var.$(SUF): $(SRC_DIR)/token.h -var.$(SUF): $(SRC_DIR)/property.h -var.$(SUF): $(SRC_DIR)/reg.h -var.$(SUF): $(TARGET_HOME)/h/em_spec.h -var.$(SUF): $(TARGET_HOME)/config/local.h -var.$(SUF): $(SRC_DIR)/param.h -hall.$(SUF): $(SRC_DIR)/hall.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/hall.c -hall.$(SUF): $(SRC_DIR)/set.h -hall.$(SUF): $(TARGET_HOME)/h/em_spec.h -hall.$(SUF): $(TARGET_HOME)/config/local.h -hall.$(SUF): $(SRC_DIR)/param.h -hall.$(SUF): $(SRC_DIR)/assert.h diff --git a/util/ncgg/scan.l b/util/ncgg/scan.l index 93552b6bd..46ea6d5e4 100644 --- a/util/ncgg/scan.l +++ b/util/ncgg/scan.l @@ -7,6 +7,20 @@ static char rcsid2[]= "$Id$"; #endif +#include "param.h" +#include "varinfo.h" +#include "lookup.h" +#include "set.h" +#include "iocc.h" +#include "instruct.h" +#include "expr.h" +#include "extern.h" +#include +#include +#include "y.tab.h" + +extern int emhere; + char *mystrcpy(); int myatoi(); diff --git a/util/ncgg/strlookup.c b/util/ncgg/strlookup.c index 5d5877abc..d473341aa 100644 --- a/util/ncgg/strlookup.c +++ b/util/ncgg/strlookup.c @@ -7,6 +7,7 @@ static char rcsid[]= "$Id$"; #endif #include "param.h" +#include "extern.h" int nstrings=0; char *l_strings[MAXSTRINGS]; diff --git a/util/ncgg/var.c b/util/ncgg/var.c index 792b78923..72a3f825d 100644 --- a/util/ncgg/var.c +++ b/util/ncgg/var.c @@ -13,6 +13,7 @@ static char rcsid[]= "$Id$"; #include "set.h" #include "instruct.h" #include "lookup.h" +#include "extern.h" #include int wordsize; diff --git a/util/opt/.distr b/util/opt/.distr deleted file mode 100644 index de2d23cf5..000000000 --- a/util/opt/.distr +++ /dev/null @@ -1,34 +0,0 @@ -pmfile -alloc.c -alloc.h -assert.h -backward.c -cleanup.c -ext.h -flow.c -getline.c -line.h -lookup.c -lookup.h -main.c -mktab.y -optim.h -param.h -pattern.h -patterns -peephole.c -pop_push.awk -pop_push.h -process.c -proinf.h -putline.c -reg.c -scan.l -tes.c -tes.h -special.c -testopt -types.h -util.c -var.c -em_opt.6 diff --git a/util/opt/build.lua b/util/opt/build.lua new file mode 100644 index 000000000..9bcfdcb21 --- /dev/null +++ b/util/opt/build.lua @@ -0,0 +1,85 @@ +include("first/yacc.lua") + +yacc { + name = "yacc", + srcs = { "./mktab.y" } +} + +flex { + name = "flex", + srcs = { "./scan.l" } +} + +cprogram { + name = "mktab", + srcs = { + matching(filenamesof("+yacc"), "%.c$"), + matching(filenamesof("+flex"), "%.c$"), + }, + deps = { + "+flex", + "+yacc", + "modules/src/em_data+lib", + } +} + +normalrule { + name = "pattern_c", + ins = { + "+mktab", + "./patterns", + "lang/cem/cpp.ansi+cpp" + }, + outleaves = { "pattern.c" }, + commands = { + "%{ins[3]} < %{ins[2]} | %{ins[1]} > %{outs}" + } +} + +normalrule { + name = "pop_push_c", + ins = { + "./pop_push.awk", + "h/em_table" + }, + outleaves = { "pop_push.c" }, + commands = { + "awk -f %{ins[1]} < %{ins[2]} > %{outs}" + } +} + +local function variant(name, cflags) + cprogram { + name = name, + srcs = { + "+pattern_c", + "+pop_push_c", + "./*.c", + }, + deps = { + "./*.h", + "h+emheaders", + "modules/src/alloc+lib", + "modules/src/print+lib", + "modules/src/string+lib", + "modules/src/system+lib", + "modules/src/em_data+lib", + }, + vars = { + ["+cflags"] = cflags + } + } +end + +variant("em_opt", {}) +variant("em_opt2", {"-DGLOBAL_OPT"}) + +installable { + name = "pkg", + map = { + ["$(PLATDEP)/em_opt"] = "+em_opt", + ["$(PLATDEP)/em_opt2"] = "+em_opt2", + ["$(INSDIR)/share/man/man6/em_opt.6"] = "./em_opt.6", + } +} + diff --git a/util/opt/mktab.y b/util/opt/mktab.y index a4b5c845c..e2a6c0b1a 100644 --- a/util/opt/mktab.y +++ b/util/opt/mktab.y @@ -294,6 +294,10 @@ main() { return nerrors; } +int yywrap(void) { + return 1; +} + yyerror(s) char *s; { fprintf(stderr,"line %d: %s\n",lino,s); @@ -421,4 +425,3 @@ out(w) { } } -#include "scan.c" diff --git a/util/opt/peephole.c b/util/opt/peephole.c index 236fe1bda..ccce6a9c0 100644 --- a/util/opt/peephole.c +++ b/util/opt/peephole.c @@ -417,14 +417,14 @@ eval_t compute(pexp) register expr_p pexp; { case EX_SFIT: mask = 0; for (i=leaf2.e_v.e_con - 1;i < 8*sizeof(offset); i++) - mask |= 1< %out%" - }, - - file (d.."pop_push.awk"), - file ("%ROOTDIR%h/em_table") - } - }, - - cfile_with_headers { - simple { - outputs = {"%U%-pattern.c"}, - command = { - "%in[1]% < %in[2]% > %out%" - }, - install = pm.install("pattern.c"), - - cprogram { - CLIBRARIES = {PARENT, "fl"}, - - cfile { - yacc { - file (d.."mktab.y") - }, - - dynamicheaders = { - file (d), - flex { - file (d.."scan.l") - } - }, - }, - - lib_em_data, - }, - - preprocess { - file (d.."patterns") - } - } - }, - - lib_em_data, - lib_assert, - lib_print, - lib_alloc, - lib_system, - lib_string, - - outputs = {"%U%/em_opt"}, -} - -tool_opt = group { - group { - local_tool_opt, - install = pm.install(BINDIR.."lib.bin/em_opt") - }, - - group { - CDEFINES = {PARENT, "GLOBAL_OPT"}, - local_tool_opt, - install = pm.install(BINDIR.."lib.bin/em_opt2") - }, -} - --- Revision history --- $Log$ --- Revision 1.5 2007-02-25 12:51:21 dtrg --- em_table is now in /h, not /etc. --- --- Revision 1.4 2007/02/20 00:27:01 dtrg --- Fixed a compilation error that was causing opt to not have its --- peephole optimisation tables, which would make it generate --- duff code. --- --- Revision 1.3 2006/10/15 00:28:12 dtrg --- Updated to the version 0.1 of Prime Mover (which involves some syntax changes). --- --- Revision 1.2 2006/07/20 23:10:07 dtrg --- Fixed revision history. --- diff --git a/util/opt/proto.make b/util/opt/proto.make deleted file mode 100644 index 04107146f..000000000 --- a/util/opt/proto.make +++ /dev/null @@ -1,300 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/opt - -CFILES= $(SRC_DIR)/main.c $(SRC_DIR)/getline.c $(SRC_DIR)/lookup.c \ - $(SRC_DIR)/var.c $(SRC_DIR)/process.c $(SRC_DIR)/backward.c \ - $(SRC_DIR)/util.c $(SRC_DIR)/alloc.c $(SRC_DIR)/putline.c \ - $(SRC_DIR)/cleanup.c $(SRC_DIR)/peephole.c $(SRC_DIR)/flow.c \ - $(SRC_DIR)/reg.c $(SRC_DIR)/tes.c pop_push.c - -OFILES= main.$(SUF) getline.$(SUF) lookup.$(SUF) var.$(SUF) process.$(SUF) backward.$(SUF) util.$(SUF)\ - alloc.$(SUF) putline.$(SUF) cleanup.$(SUF) peephole.$(SUF) flow.$(SUF) tes.$(SUF) pop_push.$(SUF) -ONOGLOB=regnoglob.$(SUF) -OGLOB=regglob.$(SUF) - -LIBS= $(TARGET_HOME)/lib.bin/em_data.$(LIBSUF) -ULIBS= $(UTIL_HOME)/lib.bin/em_data.$(ULIBSUF) -INCLUDES=-I$(TARGET_HOME)/h -I$(SRC_DIR) -I. -UINCLUDES=-I$(TARGET_HOME)/h -I$(SRC_DIR) -I. -CFLAGS= -DNDEBUG $(INCLUDES) $(COPTIONS) -UCFLAGS= -DNDEBUG $(INCLUDES) $(UCOPTIONS) -LDFLAGS=$(LDOPTIONS) -ULDFLAGS=$(ULDOPTIONS) -LINTFLAGS=$(INCLUDES) -DNDEBUG -DNORCSID $(LINTOPTIONS) -CPP=$(UTIL_HOME)/lib.bin/cpp - -all: opt opt2 - -opt: $(OFILES) $(ONOGLOB) pattern.$(SUF) $(LIBS) - $(CC) $(LDFLAGS) $(CFLAGS) $(OFILES) $(ONOGLOB) pattern.$(SUF) $(LIBS) -o opt - -opt2: $(OFILES) $(OGLOB) pattern.$(SUF) $(LIBS) - $(CC) $(LDFLAGS) $(CFLAGS) $(OFILES) $(OGLOB) pattern.$(SUF) $(LIBS) -o opt2 - -test: opt testopt - testopt - -cmp: all - -cmp opt $(TARGET_HOMTARGET_HOME)/lib.bin/em_opt - -cmp opt2 $(TARGET_HOME)/lib.bin/em_opt2 - -install:all - cp opt $(TARGET_HOME)/lib.bin/em_opt - cp opt2 $(TARGET_HOME)/lib.bin/em_opt2 - if [ $(DO_MACHINE_INDEP) = y ] ; \ - then mk_manpage $(SRC_DIR)/em_opt.6 $(TARGET_HOME) ; \ - fi - -pattern.c: $(SRC_DIR)/patterns mktab - $(CPP) $(SRC_DIR)/patterns | mktab > pattern.c - -mktab: mktab.$(USUF) $(ULIBS) - $(UCC) $(ULDFLAGS) mktab.$(USUF) $(ULIBS) -o mktab - -mktab.$(USUF): scan.c $(SRC_DIR)/optim.h $(SRC_DIR)/param.h $(SRC_DIR)/pattern.h $(SRC_DIR)/types.h mktab.c - $(UCC) -c $(UCFLAGS) mktab.c - -mktab.c: $(SRC_DIR)/mktab.y - yacc $(SRC_DIR)/mktab.y && mv y.tab.c mktab.c - -pop_push.c: $(SRC_HOME)/etc/em_table $(SRC_DIR)/pop_push.awk - awk -f $(SRC_DIR)/pop_push.awk < $(SRC_HOME)/etc/em_table > pop_push.c - -regglob.c: $(SRC_DIR)/reg.c - echo '#define GLOBAL_OPT' > regglob.c - cat $(SRC_DIR)/reg.c >> regglob.c - -regnoglob.c: $(SRC_DIR)/reg.c - cp $(SRC_DIR)/reg.c regnoglob.c - -depend: pattern.c pop_push.c regglob.c regnoglob.c - rm_deps Makefile >Makefile.new - for i in $(CFILES) pattern.c regglob.c regnoglob.c ; do \ - echo "`basename $$i .c`.$$(SUF): $$i" >> Makefile.new ; \ - echo ' $$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \ - $(UTIL_HOME)/lib.bin/cpp -d $(INCLUDES) $$i | sed "s/^/`basename $$i .c`.$$(SUF): /" >> Makefile.new ; \ - done - mv Makefile Makefile.old - mv Makefile.new Makefile - -lint: $(CFILES) pattern.c - $(LINT) $(LINTFLAGS) $(CFILES) pattern.c $(UTIL_HOME)/lib.bin/$(LINTPREF)em_data.$(LINTSUF) - -opr: - make pr | opr - -pr: - @pr -n $(SRC_DIR)/proto.make $(SRC_DIR)/*.h $(CFILES) $(SRC_DIR)/mktab.y $(SRC_DIR)/scan.l $(SRC_DIR)/patterns - -clean: - rm -f *.$(SUF) opt mktab mktab.c scan.c pattern.c opt2 Out \ - pop_push.c regglob.c regnoglob.c *.old - -scan.c: $(SRC_DIR)/scan.l - flex -st $(SRC_DIR)/scan.l > scan.c - -# the next lines are generated automatically -#DEPENDENCIES -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c -main.$(SUF): $(SRC_DIR)/ext.h -main.$(SUF): $(TARGET_HOME)/h/em_spec.h -main.$(SUF): $(SRC_DIR)/alloc.h -main.$(SUF): $(SRC_DIR)/tes.h -main.$(SUF): $(SRC_DIR)/types.h -main.$(SUF): $(SRC_DIR)/param.h -getline.$(SUF): $(SRC_DIR)/getline.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/getline.c -getline.$(SUF): $(SRC_DIR)/ext.h -getline.$(SUF): $(TARGET_HOME)/h/em_mes.h -getline.$(SUF): $(TARGET_HOME)/h/em_flag.h -getline.$(SUF): $(TARGET_HOME)/h/em_pseu.h -getline.$(SUF): $(TARGET_HOME)/h/em_spec.h -getline.$(SUF): $(SRC_DIR)/proinf.h -getline.$(SUF): $(SRC_DIR)/alloc.h -getline.$(SUF): $(SRC_DIR)/lookup.h -getline.$(SUF): $(SRC_DIR)/line.h -getline.$(SUF): $(SRC_DIR)/tes.h -getline.$(SUF): $(SRC_DIR)/types.h -getline.$(SUF): $(SRC_DIR)/param.h -lookup.$(SUF): $(SRC_DIR)/lookup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/lookup.c -lookup.$(SUF): $(SRC_DIR)/proinf.h -lookup.$(SUF): $(SRC_DIR)/alloc.h -lookup.$(SUF): $(SRC_DIR)/lookup.h -lookup.$(SUF): $(SRC_DIR)/tes.h -lookup.$(SUF): $(SRC_DIR)/types.h -lookup.$(SUF): $(SRC_DIR)/param.h -var.$(SUF): $(SRC_DIR)/var.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/var.c -var.$(SUF): $(SRC_DIR)/proinf.h -var.$(SUF): $(SRC_DIR)/lookup.h -var.$(SUF): $(SRC_DIR)/tes.h -var.$(SUF): $(SRC_DIR)/types.h -var.$(SUF): $(SRC_DIR)/param.h -process.$(SUF): $(SRC_DIR)/process.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/process.c -process.$(SUF): $(SRC_DIR)/ext.h -process.$(SUF): $(SRC_DIR)/proinf.h -process.$(SUF): $(SRC_DIR)/lookup.h -process.$(SUF): $(SRC_DIR)/line.h -process.$(SUF): $(SRC_DIR)/alloc.h -process.$(SUF): $(TARGET_HOME)/h/em_pseu.h -process.$(SUF): $(TARGET_HOME)/h/em_spec.h -process.$(SUF): $(SRC_DIR)/assert.h -process.$(SUF): $(SRC_DIR)/tes.h -process.$(SUF): $(SRC_DIR)/types.h -process.$(SUF): $(SRC_DIR)/param.h -backward.$(SUF): $(SRC_DIR)/backward.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/backward.c -backward.$(SUF): $(SRC_DIR)/ext.h -backward.$(SUF): $(TARGET_HOME)/h/em_mes.h -backward.$(SUF): $(TARGET_HOME)/h/em_mnem.h -backward.$(SUF): $(TARGET_HOME)/h/em_pseu.h -backward.$(SUF): $(TARGET_HOME)/h/em_spec.h -backward.$(SUF): $(SRC_DIR)/proinf.h -backward.$(SUF): $(SRC_DIR)/alloc.h -backward.$(SUF): $(SRC_DIR)/lookup.h -backward.$(SUF): $(SRC_DIR)/line.h -backward.$(SUF): $(SRC_DIR)/assert.h -backward.$(SUF): $(SRC_DIR)/tes.h -backward.$(SUF): $(SRC_DIR)/types.h -backward.$(SUF): $(SRC_DIR)/param.h -util.$(SUF): $(SRC_DIR)/util.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/util.c -util.$(SUF): $(SRC_DIR)/ext.h -util.$(SUF): $(SRC_DIR)/optim.h -util.$(SUF): $(SRC_DIR)/proinf.h -util.$(SUF): $(SRC_DIR)/lookup.h -util.$(SUF): $(SRC_DIR)/assert.h -util.$(SUF): $(SRC_DIR)/tes.h -util.$(SUF): $(SRC_DIR)/types.h -util.$(SUF): $(SRC_DIR)/param.h -alloc.$(SUF): $(SRC_DIR)/alloc.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/alloc.c -alloc.$(SUF): $(SRC_DIR)/proinf.h -alloc.$(SUF): $(SRC_DIR)/lookup.h -alloc.$(SUF): $(SRC_DIR)/line.h -alloc.$(SUF): $(SRC_DIR)/alloc.h -alloc.$(SUF): $(SRC_DIR)/assert.h -alloc.$(SUF): $(SRC_DIR)/tes.h -alloc.$(SUF): $(SRC_DIR)/types.h -alloc.$(SUF): $(SRC_DIR)/param.h -putline.$(SUF): $(SRC_DIR)/putline.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/putline.c -putline.$(SUF): $(SRC_DIR)/ext.h -putline.$(SUF): $(SRC_DIR)/optim.h -putline.$(SUF): $(SRC_DIR)/proinf.h -putline.$(SUF): $(SRC_DIR)/lookup.h -putline.$(SUF): $(SRC_DIR)/line.h -putline.$(SUF): $(SRC_DIR)/alloc.h -putline.$(SUF): $(TARGET_HOME)/h/em_flag.h -putline.$(SUF): $(TARGET_HOME)/h/em_mnem.h -putline.$(SUF): $(TARGET_HOME)/h/em_pseu.h -putline.$(SUF): $(TARGET_HOME)/h/em_spec.h -putline.$(SUF): $(SRC_DIR)/assert.h -putline.$(SUF): $(SRC_DIR)/tes.h -putline.$(SUF): $(SRC_DIR)/types.h -putline.$(SUF): $(SRC_DIR)/param.h -cleanup.$(SUF): $(SRC_DIR)/cleanup.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/cleanup.c -cleanup.$(SUF): $(SRC_DIR)/ext.h -cleanup.$(SUF): $(SRC_DIR)/lookup.h -cleanup.$(SUF): $(TARGET_HOME)/h/em_mes.h -cleanup.$(SUF): $(TARGET_HOME)/h/em_spec.h -cleanup.$(SUF): $(TARGET_HOME)/h/em_pseu.h -cleanup.$(SUF): $(SRC_DIR)/assert.h -cleanup.$(SUF): $(SRC_DIR)/types.h -cleanup.$(SUF): $(SRC_DIR)/param.h -peephole.$(SUF): $(SRC_DIR)/peephole.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/peephole.c -peephole.$(SUF): $(SRC_DIR)/ext.h -peephole.$(SUF): $(SRC_DIR)/optim.h -peephole.$(SUF): $(TARGET_HOME)/h/em_mnem.h -peephole.$(SUF): $(TARGET_HOME)/h/em_spec.h -peephole.$(SUF): $(SRC_DIR)/pattern.h -peephole.$(SUF): $(SRC_DIR)/alloc.h -peephole.$(SUF): $(SRC_DIR)/proinf.h -peephole.$(SUF): $(SRC_DIR)/lookup.h -peephole.$(SUF): $(SRC_DIR)/line.h -peephole.$(SUF): $(SRC_DIR)/assert.h -peephole.$(SUF): $(SRC_DIR)/tes.h -peephole.$(SUF): $(SRC_DIR)/types.h -peephole.$(SUF): $(SRC_DIR)/param.h -flow.$(SUF): $(SRC_DIR)/flow.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/flow.c -flow.$(SUF): $(SRC_DIR)/ext.h -flow.$(SUF): $(SRC_DIR)/optim.h -flow.$(SUF): $(SRC_DIR)/proinf.h -flow.$(SUF): $(SRC_DIR)/line.h -flow.$(SUF): $(SRC_DIR)/alloc.h -flow.$(SUF): $(TARGET_HOME)/h/em_mnem.h -flow.$(SUF): $(TARGET_HOME)/h/em_spec.h -flow.$(SUF): $(TARGET_HOME)/h/em_flag.h -flow.$(SUF): $(SRC_DIR)/tes.h -flow.$(SUF): $(SRC_DIR)/types.h -flow.$(SUF): $(SRC_DIR)/param.h -reg.$(SUF): $(SRC_DIR)/reg.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/reg.c -reg.$(SUF): $(SRC_DIR)/ext.h -reg.$(SUF): $(TARGET_HOME)/h/em_mes.h -reg.$(SUF): $(TARGET_HOME)/h/em_pseu.h -reg.$(SUF): $(TARGET_HOME)/h/em_spec.h -reg.$(SUF): $(SRC_DIR)/alloc.h -reg.$(SUF): $(SRC_DIR)/proinf.h -reg.$(SUF): $(SRC_DIR)/tes.h -reg.$(SUF): $(SRC_DIR)/line.h -reg.$(SUF): $(SRC_DIR)/types.h -reg.$(SUF): $(SRC_DIR)/param.h -reg.$(SUF): $(SRC_DIR)/assert.h -tes.$(SUF): $(SRC_DIR)/tes.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/tes.c -tes.$(SUF): $(SRC_DIR)/pop_push.h -tes.$(SUF): $(SRC_DIR)/ext.h -tes.$(SUF): $(SRC_DIR)/line.h -tes.$(SUF): $(SRC_DIR)/proinf.h -tes.$(SUF): $(SRC_DIR)/alloc.h -tes.$(SUF): $(SRC_DIR)/tes.h -tes.$(SUF): $(SRC_DIR)/types.h -tes.$(SUF): $(SRC_DIR)/assert.h -tes.$(SUF): $(SRC_DIR)/param.h -tes.$(SUF): $(TARGET_HOME)/h/em_pseu.h -tes.$(SUF): $(TARGET_HOME)/h/em_mnem.h -tes.$(SUF): $(TARGET_HOME)/h/em_spec.h -pop_push.$(SUF): pop_push.c - $(CC) -c $(CFLAGS) pop_push.c -pop_push.$(SUF): $(SRC_DIR)/pop_push.h -pattern.$(SUF): pattern.c - $(CC) -c $(CFLAGS) pattern.c -pattern.$(SUF): $(SRC_DIR)/pattern.h -pattern.$(SUF): $(SRC_DIR)/types.h -pattern.$(SUF): $(SRC_DIR)/param.h -regglob.$(SUF): regglob.c - $(CC) -c $(CFLAGS) regglob.c -regglob.$(SUF): $(SRC_DIR)/ext.h -regglob.$(SUF): $(TARGET_HOME)/h/em_mes.h -regglob.$(SUF): $(TARGET_HOME)/h/em_pseu.h -regglob.$(SUF): $(TARGET_HOME)/h/em_spec.h -regglob.$(SUF): $(SRC_DIR)/alloc.h -regglob.$(SUF): $(SRC_DIR)/proinf.h -regglob.$(SUF): $(SRC_DIR)/tes.h -regglob.$(SUF): $(SRC_DIR)/line.h -regglob.$(SUF): $(SRC_DIR)/types.h -regglob.$(SUF): $(SRC_DIR)/param.h -regglob.$(SUF): $(SRC_DIR)/assert.h -regnoglob.$(SUF): regnoglob.c - $(CC) -c $(CFLAGS) regnoglob.c -regnoglob.$(SUF): $(SRC_DIR)/ext.h -regnoglob.$(SUF): $(TARGET_HOME)/h/em_mes.h -regnoglob.$(SUF): $(TARGET_HOME)/h/em_pseu.h -regnoglob.$(SUF): $(TARGET_HOME)/h/em_spec.h -regnoglob.$(SUF): $(SRC_DIR)/alloc.h -regnoglob.$(SUF): $(SRC_DIR)/proinf.h -regnoglob.$(SUF): $(SRC_DIR)/tes.h -regnoglob.$(SUF): $(SRC_DIR)/line.h -regnoglob.$(SUF): $(SRC_DIR)/types.h -regnoglob.$(SUF): $(SRC_DIR)/param.h -regnoglob.$(SUF): $(SRC_DIR)/assert.h diff --git a/util/opt/scan.l b/util/opt/scan.l index 85d4aeefe..1c26f1857 100644 --- a/util/opt/scan.l +++ b/util/opt/scan.l @@ -11,6 +11,11 @@ static char rcsid2[] = "$Id$"; */ extern long atol(); +extern char patid[128]; +extern int lino; + +#include "y.tab.h" + %} %% \"[^"]*\" { strncpy(patid,yytext,sizeof(patid)); return(STRING); } diff --git a/util/shf/.distr b/util/shf/.distr deleted file mode 100644 index 0282eead8..000000000 --- a/util/shf/.distr +++ /dev/null @@ -1,2 +0,0 @@ -proto.make -march.sh diff --git a/util/topgen/.distr b/util/topgen/.distr deleted file mode 100644 index 52cb94313..000000000 --- a/util/topgen/.distr +++ /dev/null @@ -1,11 +0,0 @@ -pmfile -LLlex.c -hash.c -main.c -misc.h -pattern.c -symtab.c -symtab.h -token.h -topgen.g -tunable.h diff --git a/util/topgen/build.lua b/util/topgen/build.lua new file mode 100644 index 000000000..715632211 --- /dev/null +++ b/util/topgen/build.lua @@ -0,0 +1,43 @@ +include("util/LLgen/build.lua") + +llgen { + name = "llgen", + srcs = { "./*.g" } +} + +cprogram { + name = "topgen", + srcs = { + "./*.c", + matching(filenamesof("+llgen"), "%.c$"), + }, + deps = { + "+llgen", + } +} + +definerule("topgen", + { + srcs = { type="targets" }, + }, + function(e) + -- Remember this is executed from the caller's directory; local + -- target names will resolve there + + return normalrule { + name = e.name, + outleaves = { + "gen.c", + "gen.h", + }, + ins = { + "util/topgen+topgen", + e.srcs, + }, + commands = { + "%{ins[1]} %{ins[2]} %{dir}" + } + } + end +) + diff --git a/util/topgen/main.c b/util/topgen/main.c index dd6c4c8a2..2f211f837 100644 --- a/util/topgen/main.c +++ b/util/topgen/main.c @@ -22,13 +22,17 @@ char *inpfile; main(argc,argv) char *argv[]; { newline = 1; - if (argc != 2) { - fprintf(stderr,"Usage : %s targetoptimizerdescription\n",argv[0]); + if (argc != 3) { + fprintf(stderr,"Usage : %s targetoptimizerdescription outputdir\n",argv[0]); exit(1); } if ((input = fopen(argv[1],"r")) == NULL) { fprintf(stderr,"Fatal error : couldn't open %s\n",argv[1]); exit(1); + } + if (chdir(argv[2]) != 0) { + fprintf(stderr,"Fatal error : couldn't chdir to %s\n",argv[2]); + exit(1); } if ((genc = fopen("gen.c","w")) == NULL) { fputs("Fatal error : couldn't open gen.c\n",stderr); diff --git a/util/topgen/pmfile b/util/topgen/pmfile deleted file mode 100644 index e48383e4d..000000000 --- a/util/topgen/pmfile +++ /dev/null @@ -1,56 +0,0 @@ --- $Source$ --- $State$ - -local d = ROOTDIR.."util/topgen/" - -local lpars = LLgen { - file (d.."topgen.g") -} - -local cfile_with_headers = cfile { - class = "cfile_with_headers", - dynamicheaders = { - file (d), - lpars - } -} - -tool_topgen = cprogram { - cfile_with_headers (d.."LLlex.c"), - cfile_with_headers (d.."hash.c"), - cfile_with_headers (d.."main.c"), - cfile_with_headers (d.."pattern.c"), - cfile_with_headers (d.."symtab.c"), - - foreach { - rule = cfile_with_headers, - ith { lpars, from=2 } - }, - - lib_assert, - lib_print, - lib_alloc, - lib_system, - lib_string, - - outputs = {"%U%/topgen"}, - install = pm.install("%TOOLDIR%topgen") -} - -topgen = simple { - class = "topgen", - - outputs = {"%U%/gen.c"}, - command = { - "mkdir -p %out[1]:dirname%", - "cd %out[1]:dirname% && %TOOLDIR%topgen %in[1]%" - }, -} - --- Revision history --- $Log$ --- Revision 1.1 2006-07-22 12:31:19 dtrg --- Added support for the top target peephole optimiser. --- --- Revision 1.1 2006/07/20 23:24:28 dtrg --- First version in CVS. diff --git a/util/topgen/proto.make b/util/topgen/proto.make deleted file mode 100644 index c06b5e90f..000000000 --- a/util/topgen/proto.make +++ /dev/null @@ -1,60 +0,0 @@ -# $Id$ - -#PARAMS do not remove this line! - -SRC_DIR = $(SRC_HOME)/util/topgen -INCLUDES = -I$(SRC_DIR) -I. -CFLAGS = $(COPTIONS) $(INCLUDES) -LDFLAGS = $(LDOPTIONS) -LINTFLAGS = $(LINTOPTIONS) $(INCLUDES) -SOURCE = $(SRC_DIR)/token.h $(SRC_DIR)/symtab.h $(SRC_DIR)/misc.h \ - $(SRC_DIR)/tunable.h $(SRC_DIR)/main.c $(SRC_DIR)/topgen.g \ - $(SRC_DIR)/LLlex.c $(SRC_DIR)/symtab.c $(SRC_DIR)/pattern.c \ - $(SRC_DIR)/hash.c -CFILES = $(SRC_DIR)/main.c topgen.c Lpars.c $(SRC_DIR)/LLlex.c \ - $(SRC_DIR)/symtab.c $(SRC_DIR)/pattern.c $(SRC_DIR)/hash.c -OFILES = main.$(SUF) topgen.$(SUF) Lpars.$(SUF) LLlex.$(SUF) \ - symtab.$(SUF) pattern.$(SUF) hash.$(SUF) - -all: parser - @make topgen - -cmp: all - cmp topgen $(TARGET_HOME)/lib.bin/topgen - -install: all - cp topgen $(TARGET_HOME)/lib.bin/topgen - -clean: - rm -f topgen *.$(SUF) Lpars.c Lpars.h topgen.c parser - -parser: $(SRC_DIR)/topgen.g - $(UTIL_HOME)/bin/LLgen $(SRC_DIR)/topgen.g - touch parser - -topgen.$(SUF): $(SRC_DIR)/token.h Lpars.h $(SRC_DIR)/symtab.h $(SRC_DIR)/misc.h topgen.c - $(CC) -c $(CFLAGS) topgen.c -Lpars.$(SUF): Lpars.h Lpars.c - $(CC) -c $(CFLAGS) Lpars.c -LLlex.$(SUF): $(SRC_DIR)/token.h Lpars.h $(SRC_DIR)/tunable.h $(SRC_DIR)/LLlex.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/LLlex.c -symtab.$(SUF): $(SRC_DIR)/symtab.h $(SRC_DIR)/symtab.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/symtab.c -hash.$(SUF): $(SRC_DIR)/misc.h $(SRC_DIR)/hash.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/hash.c -pattern.$(SUF): $(SRC_DIR)/misc.h $(SRC_DIR)/symtab.h $(SRC_DIR)/pattern.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/pattern.c -main.$(SUF): $(SRC_DIR)/main.c - $(CC) -c $(CFLAGS) $(SRC_DIR)/main.c - -topgen: $(OFILES) - $(CC) $(LDFLAGS) $(OFILES) -o topgen - -lint: parser - $(LINT) $(LINTFLAGS) $(CFILES) - -pr: - @pr $(SOURCE) $(SRC_DIR)/proto.make - -opr: - make pr ^ opr