Commit graph

1820 commits

Author SHA1 Message Date
George Koehler 51e34acab1 Add a syntax to declare functions in a top table
Use the new syntax in the mips, pdp, powerpc tables to declare
functions before calling them.  These declarations prevent compiler
warnings about implicitly declaring functions.  They also provide
prototypes of the function parameters.

Also fix a warning in the powerpc table: use `bsearch(...) != NULL` to
avoid converting the pointer from bsearch() to an int.

The syntax for topgen is a block `{...}` among the parameters in the
top table.  It looks like the syntax of LLgen, but topgen doesn't
allow nested blocks, so declarations like `struct whatever {...};`
don't work.  The token OPEN_BRACKET that begins a declaration_block
doesn't conflict with the LETTER that begins a parameter_line or the
'%' that begins a separator.

Because a block writes a #line command to gen.h, a parameter line now
also writes a #line command to gen.h, so it doesn't get a wrong line
number from a previous block.
2019-10-30 18:36:55 -04:00
George Koehler 777d0abb00 Add util/int/switch.h to declare do_instr() and Do???()
Use switch.h to reduce warnings from clang about implicit declarations
of functions.  I used `grep ... do_*.c | sed ... | sort`, and some
manual editing, to make the big list of Do???() functions.
2019-10-30 18:36:55 -04:00
George Koehler 36f16b0cb8 Cut down some clang warnings
Edit C code to reduce warnings from clang.  Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().

Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c.  Such changes don't silence warnings; I make
such changes while I silence warnings in the same file.  In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.

Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning.  I wrongly added the `const` in d347207.

For warnings about implicit declarations of functions, the fix is to
declare the function before calling it.  For example, my OpenBSD
system needs <sys/wait.h> to declare wait().

In util/int, add "whatever.h" to declare more functions.  Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-30 18:36:38 -04:00
George Koehler 8bb395b147 LLgen: use size_t, reduce warnings, other small changes
Use C89 size_t for sizes from sizeof() or to malloc() or realloc().
Remove obsolete (unsigned) casts.  Sizes were unsigned int in
traditional C but are size_t in C89.

Silence some clang warnings.  Add the second pair of round brackets in
`while ((ff = ff->ff_next))` to silence -Wparentheses.  Change
`if (nc_first(...))/*nothing*/;` to `(void)nc_first(...);` to silence
-Wempty-body.  The code in compute.c nc_first() had the form
`if (x) if (y) s; else t;`.  The old indentation (before 10717cc)
suggests that the "else" belongs to the 2nd "if", so add braces like
`if (x) { if (y) s; else t; }` to silence -Wdangling-else.

Shuffle extern function declarations.  Add missing declaration for
LLparse().  Stop declaring RENAME(); it doesn't exist.  Move some
declarations from main.c to extern.h, so the C compiler may check that
the declarations are compatible with the function definitions.

Assume that standard C89 remove() is available and doesn't need the
UNLINK() wrapper.

In lib/incl, don't need to include <stdio.h> nor <stdlib.h> to use
assert().

Remove alloc.h.  If you don't clean your build, then an outdated
BUILDDIR/obj/util/LLgen/headers/alloc.h will survive but should not
cause harm, because nothing includes it.  Don't need to remove alloc.h
from util/LLgen/distr.sh, because it isn't there.

Run the bootstrap to rebuild LLgen.c, Lpars.c, tokens.c.
2019-10-22 15:32:23 -04:00
George Koehler eb520a343d Add ACK target util/LLgen+bootstrap
The ACK builds an internal LLgen without installing it.  The new
target would rebuild LLgen's own parser using the ACK's internal
LLgen.  Keep bootstrap.sh, which uses an installed LLgen.  The new
target is more convenient for those who build the ACK but don't build
and install a separate LLgen.
2019-10-21 18:15:52 -04:00
carl 0223069d29 Cleanup of modified code fixing several overflow checking issues. 2019-06-16 01:27:49 +08:00
carl 3133141a08 Interpreter fixes according to EM testsuit. 2019-06-16 01:20:53 +08:00
carl 55eb19acf8 * Fix merge conflict issue. 2019-06-16 01:19:15 +08:00
carl ef246bd8e2 Closes #193 (signed integer shift left does not correctly check overflow in the interpreter when shifting by 0 bits), Closes #192 (integer division overflow is not handled in the interpreter and crashes it) and closes #194 (lar instruction does not accept negative bounds in interpreter when doing array index checking). 2019-06-16 01:03:01 +08:00
carl 08b9482ac7 Merge remote-tracking branch 'upstream/default' into default
Conflicts:
	util/arch/archiver.c
2019-06-15 23:53:35 +08:00
carl 53d2894ed1 ANSI C conversion. 2019-05-11 01:18:01 +08:00
carl 21e15965cc ANSI C conversion and add procedure declarations. 2019-05-11 01:17:40 +08:00
carl 472654c366 ANSI C conversion and add procedure declarations. 2019-05-11 01:17:24 +08:00
carl 0301827482 ANSI C conversion. 2019-05-11 01:15:51 +08:00
carl 970e7da896 Adapt to new object API 2019-05-11 01:15:18 +08:00
carl 16f89747b1 ANSI C conversion. 2019-05-11 01:14:54 +08:00
carl fa2859df79 ANSI C conversion. 2019-05-11 01:14:01 +08:00
carl dfefbcae86 ANSI C conversion. 2019-05-11 01:13:43 +08:00
carl f9916fb680 Fix call to fwrite with proper parameters. 2019-05-11 01:12:48 +08:00
carl 2330d35ade * Fix compilation warning. 2019-05-11 00:49:10 +08:00
carl 715717a4f6 Read beyond buffer bugfix. 2019-03-31 00:53:09 +08:00
carl 496795f0cf Fix memory overflow error. 2019-03-26 00:59:16 +08:00
carl 415ec163a7 Fix tabs. 2019-03-26 00:58:36 +08:00
carl 97cb247b39 Merge remote-tracking branch 'upstream/default' into default
# Conflicts:
#	util/arch/archiver.c
2019-03-25 00:04:41 +08:00
carl 5ec9de401d * More ANSI C portability fixes. 2019-03-24 23:53:13 +08:00
carl f7e4fac687 Revert "* Adapt to more ANSI C"
This reverts commit da0e0ac257.
2019-03-24 23:39:04 +08:00
carl a58ad2bc31 * Adapt to more ANSI C 2019-03-24 23:36:52 +08:00
carl da0e0ac257 * Adapt to more ANSI C 2019-03-24 23:35:59 +08:00
carl 56e64a1fd0 Merge remote-tracking branch 'upstream/default' into carl-ansi-part1
# Conflicts:
#	util/arch/archiver.c
#	util/led/finish.c
#	util/led/output.c
2019-03-24 21:42:56 +08:00
carl 9b6e1774ea ANSI C version
More portability fixes.
2019-03-24 17:37:49 +08:00
carl 53fa893738 ANSI C version
More portability fixes.
2019-03-24 17:11:56 +08:00
carl 7063301f8c Add additional defines for compilation. 2019-03-24 17:09:29 +08:00
carl 086a2ac9ab Add additional defines for compilation. 2019-03-24 17:09:12 +08:00
carl c5f5bace63 Add additional defines for compilation. 2019-03-24 17:08:45 +08:00
George Koehler bec236c108 Include more headers to declare functions.
This causes clang to give fewer warnings of implicit declarations of
functions.

In mach/pdp/cv/cv.c, rename wr_int2() to cv_int2() because it
conflicts with wr_int2() in <object.h>.

In util/ack, rename F_OK to F_TRANSFORM because it conflicts with F_OK
for access() in <unistd.h>.
2019-03-22 15:59:35 -04:00
George Koehler dd328215d8 Use %zu to print size_t count
This silences a compiler warning.
2019-03-22 14:09:50 -04:00
carl b3814af1ba * Bugfix of "rename" across volumes, now simply copies the file instead. 2019-03-17 23:19:16 +08:00
carl 8b525f59c3 + ANSI C conversion 2019-03-17 22:46:32 +08:00
carl 3ac4504a5a + ANSI C conversion 2019-03-17 22:46:32 +08:00
carl 5a18b85b3f + ANSI C conversion 2019-03-17 22:46:32 +08:00
carl 75909230c9 + ANSI C conversion 2019-03-17 22:46:32 +08:00
carl f7ba3eec50 Remove CMake changes and generic sed scripts so they are move to a separate branch. 2019-02-21 00:43:04 +08:00
carl d825e962ed Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
2019-02-19 00:54:24 +08:00
carl cc27fd471d Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
.
2019-02-19 00:54:23 +08:00
carl e70690c510 + Addition of scripts to generate compiler include files. 2019-02-19 00:54:23 +08:00
carl 910643ccbb Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
2019-02-19 00:54:23 +08:00
carl 10717cc791 Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
- Remove support for generating K&R code.
- Remove mkstemp and replace by tmpnam (more portable but less safe)
2019-02-19 00:54:23 +08:00
carl 42bbdec82d Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
2019-02-19 00:54:23 +08:00
carl f49a5a24f7 * Initial support of CMake 2019-02-19 00:54:23 +08:00
carl 58d0c33784 * Initial support of CMake 2019-02-19 00:54:23 +08:00