Commit Graph

224 Commits

Author SHA1 Message Date
Jeremiah Orians bc2f0e164d
Starting to prepare for the use of the M2libc standard 2021-01-10 10:02:58 -05:00
Sanne Wouda 09acd6253d Implement simple macro expansion
- no longer generate CONSTANT lines for #defined constants

- "#define FOO 1" turns "return FOO;" into "return 1;"

- Macros expanding into a macro is not supported:
  #define FOO 1
  #define BAR FOO
  will expand BAR to FOO, not to 1

- Expansion inside #if conditions is not supported.

- Function-like macros are not supported.
2021-01-09 17:39:48 +00:00
Sanne Wouda a8551f2fcd Implement --bootstrap-mode for preprocessor
- // and # lines always appear in the result of read_all_tokens

- in bootstrap mode, // tokens (but not the subsequent lines) and #
  lines are stripped. no preprocessing happens.

- in non-bootstrap mode, // lines are stripped and # lines stay for the
  preprocessing phase

- updates tests to pass --bootstrap-mode when necessary
2021-01-09 17:38:50 +00:00
Sanne Wouda 6f2cebc4ca Add a test for supported preprocessor features 2021-01-08 21:32:03 +00:00
Sanne Wouda 4550eec19e Extend macro #define support
- now supports #if defined(FOO)
- translation of #define FOO 1 to CONSTANT FOO 1 is still supported
2021-01-08 21:31:43 +00:00
Jeremiah Orians 3c4c09b95e
Added hacky version of #define support 2021-01-06 19:24:16 -05:00
Jeremiah Orians 25fd5e66c9
Another set of segfaults cleared out 2021-01-05 23:22:26 -05:00
Jeremiah Orians bdd4e65580
Catch some basic segfaults 2021-01-05 23:00:58 -05:00
Jeremiah Orians 0ab7cb78eb
Adjusted cc_macro.c formatting with astyle -A1tSxejz2fpUxV 2021-01-05 22:22:33 -05:00
Sanne Wouda 63bb59404d Improve error reporting for unexpected non-newline 2021-01-05 22:56:30 +00:00
Sanne Wouda 49fbe8942f Add error checking for unexpected #endif 2021-01-05 22:56:30 +00:00
Sanne Wouda 89c6513cd8 Add support for conditional inclusion
- support for #if, #elif, #else, #endif, but no macro expansion just
  yet. Any macro is treated as undefined and expands to 0.

for example:
./bin/M2-Planet -E test.c

 #if 1 == FOO
foo
 #else
bar
 #endif

results in

bar
2021-01-05 22:54:30 +00:00
Sanne Wouda cd96f65a23 Add macro directives to token_list
- change the lexer to not remove preprocessor directives
- preprocess() removes any lines starting with a macro directive that it
  doesn't understand (which is currently all of them)
2021-01-05 22:53:39 +00:00
Sanne Wouda 7b8a99db3c Add a preprocessor-only mode
- Very useful for testing and debugging
- Add preprocess() stub and skip compilation in preprocessor mode
2021-01-05 22:53:04 +00:00
Sanne Wouda a18e0c1782 Add newline tokens to parse stream
- needed to determine start and end of macro directives
- the main parser doesn't need them, so strip out the newline tokens
  before parsing to avoid changing it
2021-01-05 22:23:15 +00:00
Sanne Wouda fa0f135ebb Fix typo 2021-01-03 13:16:55 +00:00
Jeremiah Orians 921cc86ce6
First generation implemention of typedef 2021-01-02 22:00:02 -05:00
Jeremiah Orians 358b6cfb96
Fix modulus behavior that is wrong.
Thank you janneke
2021-01-01 16:39:27 -05:00
Jeremiah Orians e451abd667
Fix e25c1995aa SCM MES regression 2021-01-01 15:55:34 -05:00
Jeremiah Orians cc1a17a040
Revert "file.c: introduce output buffering for x86"
This reverts commit 5afeb0743e.
2021-01-01 15:28:30 -05:00
Jeremiah Orians 07baf02efe
Looks like I got x86/AMD64 signed and unsigned division backwards.
Thanks for finding that janneke
2021-01-01 10:52:23 -05:00
Jeremiah Orians c220d14928
Catching some segfaults 2020-12-31 09:53:05 -05:00
Jeremiah Orians e25c1995aa
Make types more proper 2020-12-27 21:51:46 -05:00
Jeremiah Orians 6a3d3e78e0
expand the known issues list 2020-12-24 14:41:14 -05:00
Jeremiah Orians 44e14bb662
Make known issues public 2020-12-24 12:12:52 -05:00
Jeremiah Orians 0ed81de9e1
Merge remote-tracking branch 'mihi/io-buffering-x86' 2020-12-22 22:19:44 -05:00
Jeremiah Orians 4de11b1bc6
Update checksums to reflect new fclose 2020-12-21 22:26:22 -05:00
Michael Schierl 5afeb0743e file.c: introduce output buffering for x86
Note that this is a backwards incompatible change: Unlike POSIX, exit()
will not flush all open streams, so you are responsible for flushing or
closing all your streams before successful exit.

Also, file.c will now also require calloc.c (and malloc.c).

Updated the test cases accordingly.

Only implemented and tested for x86.
2020-12-21 16:57:17 +01:00
Michael Schierl 608fba306f Fix x86 close syscall and test 0104
The close syscall was missing an indirection and therefore closed random
file descriptors (very visible in strace output).

Test 0104 did not properly null terminate the envp, resulting in -EFAULT
on execve syscall in case the next value in memory does not happen to be
0 (which it seems to be right now).
2020-12-21 16:57:17 +01:00
Michael Schierl 91bab2ef98 Close files that were fopen:ed 2020-12-21 16:57:17 +01:00
Jeremiah Orians 6fe6f44a29
Make type information localized to the inside of statements 2020-12-19 16:35:33 -05:00
Jeremiah Orians e7a0ecd244
Cleared out non-essential string primitives and added support for --max-string 2020-12-19 09:46:22 -05:00
Jeremiah Orians d9504e3872
Allow M2-Planet to support larger outputs without hitting a segfault 2020-12-19 06:50:11 -05:00
Sanne Wouda 968fdfea65 AArch64 support for unsigned comparison 2020-12-17 00:01:17 +00:00
Jeremiah Orians e5befc4fee
armv7l support for unsigned comparisons 2020-12-15 21:09:26 -05:00
Jeremiah Orians f2cae3d501
AMD64 support for unsigned comparisons 2020-12-15 20:28:04 -05:00
Jeremiah Orians eaf3861954
Fix failing tests on x86 2020-12-15 19:02:32 -05:00
Jeremiah Orians 132e685f97
Fix x86 behavior on unsigned compares 2020-12-15 17:46:45 -05:00
Jeremiah Orians 9da48c5ece
match gcc behavior in regards to if(-1 > 0) 2020-12-15 07:24:07 -05:00
Jeremiah Orians 5c22aac02d
Change knight-posix HEAP behavior and leverage better relational choices for knight-posix 2020-12-15 06:02:38 -05:00
Jeremiah 196c66d19e
Merge pull request #7 from snnw/aarch64-fix
[AArch64] Use arithmetic right shift for signed
2020-12-05 10:09:50 -05:00
Sanne Wouda a63b8837c0 [AArch64] Use arithmetic right shift for signed
- as discussed with deesix, this is the proper fix
- the test1000 checksum changes as it uses the M2-Planet source as input
2020-12-05 14:59:16 +00:00
Jeremiah d34ea502cc
Merge pull request #6 from snnw/aarch64-fix
[AArch64] Fix LSEEK syscall number
2020-12-04 21:29:02 -05:00
Sanne Wouda 58b563435b [AArch64] Use arithmetic right shift
- fixes a test failure if hex2 was compiled with M2-Planet
2020-12-04 19:37:29 +00:00
Sanne Wouda 624a5ac92d [AArch64] Fix LSEEK syscall number 2020-12-04 15:45:06 +00:00
Jeremiah Orians 0615223052
Broke tests into processor specific sets and updated the M1 test 2020-12-01 22:24:36 -05:00
Jeremiah Orians 93e8b0c0a4
Removed obsolete reference to bootstrap directory 2020-11-20 05:34:11 -05:00
Jeremiah Orians e3ca15c731
Preparing for next release 2020-11-15 20:46:26 -05:00
Jeremiah Orians a5bc08b23f
Release 1.7.0 2020-11-15 20:43:58 -05:00
Jeremiah Orians 1975d88581
Fix GCC 10 compatibility issue 2020-11-15 20:28:33 -05:00