Prepare for major change involving multi-arch support

This commit is contained in:
Jeremiah Orians 2019-02-23 15:08:59 -05:00
parent 0eefa0feb2
commit a456bcc21d
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
36 changed files with 156 additions and 68 deletions

View File

@ -24,6 +24,8 @@ Added prototype for Slow_Lisp build test
Added Custom type for mes.h Added Custom type for mes.h
Added support for octal and binary numbers Added support for octal and binary numbers
Added support for \0 Added support for \0
Added support for GET_MACHINE_FLAGS in tests
Added --architecture flag
** Changed ** Changed
Converted M2-Planet to use GNU style error message Converted M2-Planet to use GNU style error message
@ -31,7 +33,9 @@ Seed.M1 when built will now have the same checksum as M2-Planet self-hosted
Harmonized license headers Harmonized license headers
Updated M1 to current version Updated M1 to current version
Updated hex2 to current version Updated hex2 to current version
Updated get_machine to current version
Updated to mescc-tools 0.6.0 syntax Updated to mescc-tools 0.6.0 syntax
Changed default architecture to knight-native
** Fixed ** Fixed
Fixed typo in file headers Fixed typo in file headers

View File

@ -28,7 +28,7 @@ then
{ {
cat <<-EOF cat <<-EOF
## This file was generated by running: ## This file was generated by running:
## cat functions/file.c functions/malloc.c functions/calloc.c functions/exit.c functions/match.c functions/numerate_number.c functions/file_print.c functions/string.c cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc.c >| ../stage0/stage3/M2-Planet_x86.c ## cat functions/file.c functions/malloc.c functions/calloc.c functions/exit.c functions/match.c -f functions/in_set.c functions/numerate_number.c functions/file_print.c functions/string.c cc.h cc_reader.c cc_strings.c cc_types.c cc_core.c cc.c >| ../stage0/stage3/M2-Planet_x86.c
## inside M2-Planet's repo ## inside M2-Planet's repo
EOF EOF
@ -41,6 +41,7 @@ cat header \
functions/calloc.c \ functions/calloc.c \
functions/exit.c \ functions/exit.c \
functions/match.c \ functions/match.c \
functions/in_set.c \
functions/numerate_number.c \ functions/numerate_number.c \
functions/file_print.c \ functions/file_print.c \
functions/string.c \ functions/string.c \

26
cc.c
View File

@ -35,6 +35,9 @@ int main(int argc, char** argv)
int DEBUG = FALSE; int DEBUG = FALSE;
FILE* in = stdin; FILE* in = stdin;
FILE* destination_file = stdout; FILE* destination_file = stdout;
Architecture = 0; /* Assume Knight-native */
char* arch;
int i = 1; int i = 1;
while(i <= argc) while(i <= argc)
{ {
@ -68,6 +71,22 @@ int main(int argc, char** argv)
} }
i = i + 2; i = i + 2;
} }
else if(match(argv[i], "-A") || match(argv[i], "--architecture"))
{
arch = argv[i + 1];
if(match("knight-native", arch)) Architecture = 0;
else if(match("knight-posix", arch)) Architecture = 1;
else if(match("x86", arch)) Architecture = 2;
else if(match("amd64", arch)) Architecture = 3;
else if(match("armv7l", arch)) Architecture = 40;
else
{
file_print("Unknown architecture: ", stderr);
file_print(arch, stderr);
file_print(" know values are: knight-native, knight-posix, x86, amd64 and armv7l", stderr);
}
i = i + 2;
}
else if(match(argv[i], "-g") || match(argv[i], "--debug")) else if(match(argv[i], "-g") || match(argv[i], "--debug"))
{ {
DEBUG = TRUE; DEBUG = TRUE;
@ -90,6 +109,13 @@ int main(int argc, char** argv)
} }
} }
/* Temp solution to aborting when an architecture isn't supported yet but is expected to be fully supported */
if(!in_set(Architecture, "\x02"))
{
file_print("ALL IS FIRE\n\n", stderr);
exit(EXIT_FAILURE);
}
/* Deal with special case of wanting to read from standard input */ /* Deal with special case of wanting to read from standard input */
if(stdin == in) if(stdin == in)
{ {

3
cc.h
View File

@ -79,3 +79,6 @@ struct token_list* globals_list;
/* Make our string collection more efficient */ /* Make our string collection more efficient */
char* hold_string; char* hold_string;
int string_index; int string_index;
/* Our Target Architecture */
int Architecture;

View File

@ -9,7 +9,7 @@ a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/t
f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-binary f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-binary
3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-binary 3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-binary
020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-binary 020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-binary
f3377a4a6122cfa499040c1080626eb6ef60603bf6023b83090812d97857bc8c test/results/test100-binary c84d7ca7668837bade38e6e07e018ded3e587643a0a22d513f9dc314fbf17f31 test/results/test100-binary
3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-binary 3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-binary
f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-binary f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-binary
5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-binary 5051ffca2615144419f8ec1a5d4999486ae81e7781428f59e47e866af97cef92 test/results/test13-binary
@ -23,5 +23,5 @@ cefc5a53513abdb9069dc8bdb7b4529307420d5dd412a10112c3253bdcd29c46 test/results/t
3c7654eb26247e5f0460dad9e539220a68078cd8c56aae8457b5a97dc6eab892 test/results/test21-binary 3c7654eb26247e5f0460dad9e539220a68078cd8c56aae8457b5a97dc6eab892 test/results/test21-binary
3d0a08c9f38b995318f459884880dbcd309930fb9f51de05c83eb1fcc3fa1825 test/results/test22-binary 3d0a08c9f38b995318f459884880dbcd309930fb9f51de05c83eb1fcc3fa1825 test/results/test22-binary
3060147b0d56e30c6d9a36ed4675feed306c398df365d2c1c9e2d1c88b40cf3e test/results/test23-binary 3060147b0d56e30c6d9a36ed4675feed306c398df365d2c1c9e2d1c88b40cf3e test/results/test23-binary
c080413cdb713618896a73b834fb96ce8dd2c2176a226c0713d9a729bd1aa7f9 test/results/test24-binary ff810940f7e8a9df916b20bc95d7d83a7165c57853e343417826a9f5a607c2db test/results/test24-binary
140af7fb3ef89d84b21bd3fe69f0d3260650ec0467c0ffadf9268fad573a397f test/results/test99-binary 140af7fb3ef89d84b21bd3fe69f0d3260650ec0467c0ffadf9268fad573a397f test/results/test99-binary

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f test/test00/return.c \ bin/M2-Planet --architecture x86 -f test/test00/return.c \
-o test/test00/return.M1 || exit 1 -o test/test00/return.M1 || exit 1
# Macro assemble with libc written in M1-Macro # Macro assemble with libc written in M1-Macro
@ -32,7 +32,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test00/return.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test00-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test00/return.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test00-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
./test/results/test00-binary ./test/results/test00-binary

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test01/library_call.c \ -f test/test01/library_call.c \
-o test/test01/library_call.M1 || exit 1 -o test/test01/library_call.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test01/library_call.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test01-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test01/library_call.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test01-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test01-binary 2>&1) out=$(./test/results/test01-binary 2>&1)

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test02/if.c \ -f test/test02/if.c \
-o test/test02/if.M1 || exit 1 -o test/test02/if.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test02/if.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test02-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test02/if.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test02-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test02-binary 2>&1 ) out=$(./test/results/test02-binary 2>&1 )

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test03/constant.c \ -f test/test03/constant.c \
-o test/test03/constant.M1 || exit 1 -o test/test03/constant.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test03/constant.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test03-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test03/constant.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test03-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test03-binary 2>&1 ) out=$(./test/results/test03-binary 2>&1 )

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test04/call.c \ -f test/test04/call.c \
-o test/test04/call.M1 || exit 1 -o test/test04/call.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test04/call.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test04-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test04/call.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test04-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test04-binary 2>&1 ) out=$(./test/results/test04-binary 2>&1 )

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test05/string.c \ -f test/test05/string.c \
-o test/test05/string.M1 || exit 1 -o test/test05/string.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test05/string.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test05-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test05/string.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test05-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test05-binary 2>&1 ) out=$(./test/results/test05-binary 2>&1 )

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f test/test06/for.c \ -f test/test06/for.c \
-o test/test06/for.M1 || exit 1 -o test/test06/for.M1 || exit 1
@ -33,7 +33,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test06/for.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test06-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test06/for.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test06-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test06-binary >| test/test06/proof || exit 4 ./test/results/test06-binary >| test/test06/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test07/do.c \ -f test/test07/do.c \
-o test/test07/do.M1 || exit 1 -o test/test07/do.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test07/do.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test07-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test07/do.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test07-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test07-binary >| test/test07/proof || exit 4 ./test/results/test07-binary >| test/test07/proof || exit 4

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f test/test08/struct.c \ -f test/test08/struct.c \
@ -35,7 +35,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test08/struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test08-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test08/struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test08-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test08-binary 2>&1 ) out=$(./test/results/test08-binary 2>&1 )

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test09/goto.c \ -f test/test09/goto.c \
-o test/test09/goto.M1 || exit 1 -o test/test09/goto.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test09/goto.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test09-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test09/goto.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test09-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test09-binary 2>&1 ) out=$(./test/results/test09-binary 2>&1 )

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f test/test10/nested_struct.c \ -f test/test10/nested_struct.c \
@ -35,7 +35,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test10/nested_struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test10-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test10/nested_struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test10-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test10-binary 2>&1 ) out=$(./test/results/test10-binary 2>&1 )

View File

@ -19,7 +19,7 @@ set -ex
# Build the test # Build the test
if [ -f bin/M2-Planet ] if [ -f bin/M2-Planet ]
then then
./bin/M2-Planet -f functions/file.c \ ./bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f functions/exit.c \ -f functions/exit.c \
@ -39,7 +39,7 @@ then
elif [ -f bin/M2-Planet-seed ] elif [ -f bin/M2-Planet-seed ]
then then
[ ! -f test/results ] && mkdir test/results [ ! -f test/results ] && mkdir test/results
./bin/M2-Planet-seed -f functions/file.c \ ./bin/M2-Planet-seed --architecture x86 -f functions/file.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f functions/exit.c \ -f functions/exit.c \
@ -75,7 +75,7 @@ ${CC} ${CFLAGS} \
gcc_req.h \ gcc_req.h \
-o bin/M2-Planet-gcc -o bin/M2-Planet-gcc
./bin/M2-Planet-gcc -f functions/file.c \ ./bin/M2-Planet-gcc --architecture x86 -f functions/file.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f functions/exit.c \ -f functions/exit.c \
@ -116,10 +116,10 @@ hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-o test/results/test100-binary --exec_enable || exit 4 -o test/results/test100-binary --exec_enable || exit 4
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test100-binary -f functions/file.c \ ./test/results/test100-binary --architecture x86 -f functions/file.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f functions/exit.c \ -f functions/exit.c \
@ -140,6 +140,9 @@ then
[ "$out" = "test/test100/proof: OK" ] || exit 6 [ "$out" = "test/test100/proof: OK" ] || exit 6
[ ! -e bin/M2-Planet ] && mv test/results/test100-binary bin/M2-Planet [ ! -e bin/M2-Planet ] && mv test/results/test100-binary bin/M2-Planet
else else
cp bin/M2-Planet-gcc bin/M2-Planet [ -e bin/M2-Planet-gcc ] && cp bin/M2-Planet-gcc bin/M2-Planet
# Seeds only exist if you can build natively
[ -e bin/M2-Planet-seed ] && cp test/results/test100-binary bin/M2-Planet
fi fi
exit 0 exit 0

View File

@ -1 +1 @@
f1e74d13abdb3c60e531daf18b2a8d6d728c8014ed77a354ec87bf00c5cd0abd test/test100/proof 0a88d978a2e46b571d0633c09453fb8c622718b06b91ebe89b52735b68cea97d test/test100/proof

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test11/break-do.c \ -f test/test11/break-do.c \
-o test/test11/break-do.M1 || exit 1 -o test/test11/break-do.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test11/break-do.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test11-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test11/break-do.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test11-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test11-binary >| test/test11/proof || exit 4 ./test/results/test11-binary >| test/test11/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test12/break-for.c \ -f test/test12/break-for.c \
-o test/test12/break-for.M1 || exit 1 -o test/test12/break-for.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test12/break-for.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test12-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test12/break-for.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test12-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test12-binary >| test/test12/proof || exit 4 ./test/results/test12-binary >| test/test12/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f test/test13/break-while.c \ -f test/test13/break-while.c \
-o test/test13/break-while.M1 || exit 1 -o test/test13/break-while.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test13/break-while.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test13-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test13/break-while.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test13-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test13-binary >| test/test13/proof || exit 4 ./test/results/test13-binary >| test/test13/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f test/test14/basic_args.c \ -f test/test14/basic_args.c \
-o test/test14/basic_args.M1 || exit 1 -o test/test14/basic_args.M1 || exit 1
@ -33,7 +33,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test14/basic_args.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test14-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test14/basic_args.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test14-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test14-binary 314 1 5926 5 35897 932384626 43 383279 50288 419 71693 99375105 820974944 >| test/test14/proof || exit 4 ./test/results/test14-binary 314 1 5926 5 35897 932384626 43 383279 50288 419 71693 99375105 820974944 >| test/test14/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/file.c \ bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/putchar.c \ -f functions/putchar.c \
-f test/test15/file_read.c \ -f test/test15/file_read.c \
-o test/test15/file_read.M1 || exit 1 -o test/test15/file_read.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test15/file_read.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test15-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test15/file_read.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test15-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test15-binary test/test15/file_read.c >| test/test15/proof || exit 4 ./test/results/test15-binary test/test15/file_read.c >| test/test15/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/file.c \ bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/putchar.c \ -f functions/putchar.c \
-f test/test16/file_write.c \ -f test/test16/file_write.c \
-o test/test16/file_write.M1 || exit 1 -o test/test16/file_write.M1 || exit 1
@ -34,7 +34,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test16/file_write.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test16-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test16/file_write.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test16-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test16-binary test/test16/proof || exit 4 ./test/results/test16-binary test/test16/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/malloc.c \ bin/M2-Planet --architecture x86 -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f functions/putchar.c \ -f functions/putchar.c \
-f test/test17/memset.c \ -f test/test17/memset.c \
@ -35,7 +35,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test17/memset.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test17-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test17/memset.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test17-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test17-binary >| test/test17/proof || exit 4 ./test/results/test17-binary >| test/test17/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/file.c \ bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f test/test18/math.c \ -f test/test18/math.c \
@ -35,7 +35,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test18/math.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test18-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test18/math.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test18-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test18-binary >| test/test18/proof || exit 4 ./test/results/test18-binary >| test/test18/proof || exit 4

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/file.c \ bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f functions/exit.c \ -f functions/exit.c \
@ -39,7 +39,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test19/getopt.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test19-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test19/getopt.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test19-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the resulting file works # Verify that the resulting file works
./test/results/test19-binary -f test/test19/input -o test/test19/proof || exit 4 ./test/results/test19-binary -f test/test19/input -o test/test19/proof || exit 4

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f test/test20/struct.c \ -f test/test20/struct.c \
@ -35,7 +35,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test20/struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test20-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test20/struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test20-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test20-binary 2>&1 ) out=$(./test/results/test20-binary 2>&1 )

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
./bin/M2-Planet -f functions/exit.c \ ./bin/M2-Planet --architecture x86 -f functions/exit.c \
-f functions/file.c \ -f functions/file.c \
-f functions/file_print.c \ -f functions/file_print.c \
-f functions/malloc.c \ -f functions/malloc.c \
@ -50,7 +50,7 @@ hex2 -f test/common_x86/ELF-i386-debug.hex2 \
--exec_enable || exit 4 --exec_enable || exit 4
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test21-binary --version 2>&1 ) out=$(./test/results/test21-binary --version 2>&1 )

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
./bin/M2-Planet -f functions/exit.c \ ./bin/M2-Planet --architecture x86 -f functions/exit.c \
-f functions/file.c \ -f functions/file.c \
-f functions/file_print.c \ -f functions/file_print.c \
-f functions/malloc.c \ -f functions/malloc.c \
@ -53,7 +53,7 @@ hex2 -f test/common_x86/ELF-i386-debug.hex2 \
--exec_enable || exit 4 --exec_enable || exit 4
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test22-binary --version 2>&1 ) out=$(./test/results/test22-binary --version 2>&1 )

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
./bin/M2-Planet -f functions/exit.c \ ./bin/M2-Planet --architecture x86 -f functions/exit.c \
-f functions/file.c \ -f functions/file.c \
-f functions/file_print.c \ -f functions/file_print.c \
-f functions/malloc.c \ -f functions/malloc.c \
@ -53,7 +53,7 @@ hex2 -f test/common_x86/ELF-i386-debug.hex2 \
--exec_enable || exit 4 --exec_enable || exit 4
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test23-binary --version 2>&1 ) out=$(./test/results/test23-binary --version 2>&1 )

View File

@ -21,13 +21,63 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/utsname.h> #include <sys/utsname.h>
void file_print(char* s, FILE* f); void file_print(char* s, FILE* f);
int match(char* a, char* b);
#define TRUE 1
//CONSTANT TRUE 1
#define FALSE 0
//CONSTANT FALSE 0
/* Standard C main program */ /* Standard C main program */
int main() int main(int argc, char **argv)
{ {
int exact = FALSE;
int override = FALSE;
char* override_string;
int option_index = 1;
while(option_index <= argc)
{
if(NULL == argv[option_index])
{
option_index = option_index + 1;
}
else if(match(argv[option_index], "--exact"))
{
exact = TRUE;
option_index = option_index + 1;
}
else if(match(argv[option_index], "--override"))
{
override = TRUE;
override_string = argv[option_index + 1];
option_index = option_index + 2;
}
else if(match(argv[option_index], "-V") || match(argv[option_index], "--version"))
{
file_print("get_machine 0.1\n", stdout);
exit(EXIT_SUCCESS);
}
else
{
file_print("Unknown option\n", stderr);
exit(EXIT_FAILURE);
}
}
struct utsname* unameData = calloc(1, sizeof(struct utsname)); struct utsname* unameData = calloc(1, sizeof(struct utsname));
uname(unameData); uname(unameData);
file_print(unameData->machine, stdout); if(override) file_print(override_string, stdout);
else if(!exact)
{
if(match("i386", unameData->machine) ||
match("i486", unameData->machine) ||
match("i586", unameData->machine) ||
match("i686", unameData->machine) ||
match("i686-pae", unameData->machine)) file_print("x86", stdout);
else if(match("x86_64", unameData->machine)) file_print("amd64", stdout);
else file_print(unameData->machine, stdout);
}
else file_print(unameData->machine, stdout);
file_print("\n", stdout); file_print("\n", stdout);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -17,12 +17,13 @@
set -x set -x
# Build the test # Build the test
./bin/M2-Planet -f functions/exit.c \ ./bin/M2-Planet --architecture x86 -f functions/exit.c \
-f functions/file.c \ -f functions/file.c \
-f functions/file_print.c \ -f functions/file_print.c \
-f functions/malloc.c \ -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f functions/uname.c \ -f functions/uname.c \
-f functions/match.c \
-f test/test24/get_machine.c \ -f test/test24/get_machine.c \
--debug \ --debug \
-o test/test24/get_machine.M1 || exit 1 -o test/test24/get_machine.M1 || exit 1
@ -50,11 +51,11 @@ hex2 -f test/common_x86/ELF-i386-debug.hex2 \
--exec_enable || exit 4 --exec_enable || exit 4
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program returns the correct result # Verify that the compiled program returns the correct result
out=$(./test/results/test24-binary 2>&1 ) out=$(./test/results/test24-binary ${GET_MACHINE_FLAGS} 2>&1 )
[ 0 = $? ] || exit 5 [ 0 = $? ] || exit 5
[ "$out" = "x86_64" ] || exit 6 [ "$out" = "x86" ] || exit 6
fi fi
exit 0 exit 0

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
./bin/M2-Planet -f functions/exit.c \ ./bin/M2-Planet --architecture x86 -f functions/exit.c \
-f functions/file.c \ -f functions/file.c \
-f functions/file_print.c \ -f functions/file_print.c \
-f functions/malloc.c \ -f functions/malloc.c \

View File

@ -17,7 +17,7 @@
set -x set -x
# Build the test # Build the test
./bin/M2-Planet -f test/test26/lisp.h \ ./bin/M2-Planet --architecture x86 -f test/test26/lisp.h \
-f functions/malloc.c \ -f functions/malloc.c \
-f functions/calloc.c \ -f functions/calloc.c \
-f functions/in_set.c \ -f functions/in_set.c \

View File

@ -17,7 +17,7 @@
set -ex set -ex
# Build the test # Build the test
bin/M2-Planet -f functions/putchar.c \ bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/getchar.c \ -f functions/getchar.c \
-f functions/exit.c \ -f functions/exit.c \
-f functions/malloc.c \ -f functions/malloc.c \
@ -36,7 +36,7 @@ M1 -f test/common_x86/x86_defs.M1 \
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test99/cc0.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test99-binary --exec_enable || exit 3 hex2 -f test/common_x86/ELF-i386.hex2 -f test/test99/cc0.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test99-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test # Ensure binary works if host machine supports test
if [ "$(get_machine)" = "x86_64" ] if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then then
# Verify that the compiled program can compile itself # Verify that the compiled program can compile itself
./test/results/test99-binary < test/test99/cc500.c >| test/test99/cc1 || exit 4 ./test/results/test99-binary < test/test99/cc500.c >| test/test99/cc1 || exit 4