Commit graph

1058 commits

Author SHA1 Message Date
George Koehler 59b3c10563 Use (arith) 1 << ... when getting the sign bit.
This prevents an overflow reported by @hexcoder- in
https://github.com/davidgiven/ack/issues/56

lang/cem/cpp.ansi/LLlex.c used a plain 1 << ... and caused an overflow
on machines where sizeof(int) < sizeof(long).  Using 1L << ... would
work for now but might fail later if arith became long long.

C doesn't specify whether negative integers use 2's complement or some
other format.  Therefore, (arith) 1 << ... has an undefined value.  It
should still work because the value is some integer where the sign bit
is set and all other bits are clear.

(unsigned arith) 1 << ... would also get the sign bit, but casting it
from unsigned back to signed would make the same undefined value.

(arith) -1 << ... would assume 2's complement.
2017-10-29 17:45:10 -04:00
George Koehler d36807b395 Remove UNSIGNED_ARITH from a few more files.
I missed these in commits 649410b and 1ab1306.
2017-10-29 17:03:51 -04:00
George Koehler 1ab1306baa Always use unsigned long in lang/cem
Same reason as commit 649410b.
2017-10-29 17:01:29 -04:00
George Koehler 75ae957c75 Don't check ferror(fp) when reading fp.
If feof(fp) or ferror(fp) was set, then our libc returned EOF for all
later reads without trying to read.  Our libc now behaves like BSD
(and probably Illumos and musl) by checking only feof(fp).  For
difference, glibc doesn't check feof(fp).

I described the difference between our libc and BSD libc in
https://sourceforge.net/p/tack/mailman/message/35430300/
2017-10-28 16:20:48 -04:00
George Koehler 54028e403e Delete unused misc/getpw.c from libc.
@hexcoder- reported in https://github.com/davidgiven/ack/issues/57
that our getpw() has bugs.

I don't fix these bugs, because Illumos and Linux manual pages say
that getpw() is obsolete.  The function can overflow its buffer, so it
is never safe to use.  Our libc did not build getpw().
2017-10-28 14:25:39 -04:00
George Koehler 0a2dfd650d Delete malloc.h and tgmath.h from libc.
This malloc.h might get confused with the private malloc.h in our
libc.  C programs should #include <stdlib.h> for malloc().

This tgmath.h has no useful content, and never worked because
complex.h is missing.

Touch build.lua (by deleting some whitespace) so the *.h globs see
the deletions.
2017-10-28 14:24:35 -04:00
George Koehler b00a2c906d Build fdopen(), hypot(), putenv() in libc.
These functions are in POSIX; hypot() is in C99.  Also build cabs()
because it rides with hypot(), but don't declare cabs() in any header
file, because our compiler can't parse C99 "double complex" type.

Touch build.lua so it sees that .c files moved.
2017-10-28 13:33:57 -04:00
David Given fd10cf7ac2 Merge from trunk. 2017-08-06 10:42:16 +02:00
David Given c569ca15d8 Clean up how the language libraries refer to plat headers; they should be using
the +pkg forms of the rules and getting the headers via the paths in descr,
rather than depending on the +headers version.
2016-12-05 21:05:24 +01:00
David Given 3e69d1185a Fix a whole lot more stray prototypes. 2016-11-24 21:47:40 +01:00
David Given 9481487e3d Implement calloc() (accidentally got dropped with the malloc rewrite). 2016-11-23 22:16:25 +01:00
David Given 4d7c27391f Merge. 2016-11-10 22:06:08 +01:00
David Given fd91851005 Add enough return types to the K&R C that the ACK builds (on Linux) using clang
now.
2016-11-10 22:04:18 +01:00
David Given 57cb99ade1 Remove sys_time in favour of directly calling time(). 2016-11-09 21:52:04 +01:00
George Koehler 08f9869a63 Remove unused defines from lang/cem/libcc.ansi/math/localmath.h
This undoes part of bfeb736, and returns to using DBL_MAX_EXP and
DBL_MIN_EXP from float.h.

Add a dependency on math/localmath.h and other local header files so
libc is rebuilt when those headers change.
2016-11-06 15:49:47 -05:00
George Koehler 19ca28e22f Undo commit bfeb736 for lang/cem/libcc.ansi/headers/float.h
This restores the correct values of DBL_MAX, DBL_MIN_EXP, and related
constants.  This fixes some range checks within libc, causing
atof("-36e90") and atof("1.44e-288") to return the correct values.
2016-11-06 15:01:25 -05:00
David Given f67c98e239 Distributions are a pain --- let's not bother any more. Instead, we just tag
the repository and download a complete snapshot, old and ancient stuff and all.
2016-09-02 23:00:38 +02:00
David Given 612e38f1c6 Remove the old make-based build system, plus some big chunks of horribly
obsolete protomake build system.
2016-09-02 22:17:51 +02:00
David Given 856eb120b3 Add files which got missed in the initial build pass. 2016-08-20 14:04:17 +02:00
David Given 4d24666432 Move util/data into modules/src/em_data, for consistency with the other
modules.
2016-08-14 14:09:38 +02:00
David Given b549980af2 Wasn't exporting the plat headers; refactor to make this a little cleaner. 2016-08-14 11:01:36 +02:00
David Given 262c5fedcf Biggish refactor to break cycles; my build rules were full of them. cpm builds,
which requires top and topgen.
2016-08-14 01:39:40 +02:00
David Given a200a2fb53 Replaced the funky and hard-to-compile ACK malloc with a much smaller
and simpler one stolen from K&R. libc builds now.
2016-08-11 00:30:32 +02:00
David Given 3ce4e53aa9 Most of libc builds now (missing malloc). 2016-08-08 23:55:47 +02:00
David Given 0d77cb8279 We can build our first C file. 2016-08-07 21:56:53 +02:00
David Given b50dc4214a Add check for undefined variables. Find undefined variables. Fix undefined
variables.
2016-08-05 00:01:55 +02:00
David Given 5e84be70fd Massive ackbuilder refactor --- cleaner and more expressive. Lists
are automatically flattened (leading to better build files), and the
list and filename functions are vastly more orthogonal.
2016-08-04 23:51:19 +02:00
David Given b2bb4ce3b2 Builds libend (the simplest library). Becoming obvious I need to rework the way
ackbuilder deals with lists.
2016-07-30 00:39:22 +02:00
David Given 363d13cc2f C preprocessor; tabgen; now the pc86 boot.s builds using the ack
toolchain.
2016-07-29 00:22:49 +02:00
David Given 2770a83837 More programs, more libraries. src/modules build files are now saner. 2016-07-23 00:30:31 +02:00
David Given 1fdc69fb97 cemcom.ansi now builds. 2016-07-19 23:43:14 +02:00
David Given 2d2497c318 ackbuilder rules files now require absolute paths in external variables
(otherwise commands which change directory don't work).
2016-07-18 23:16:27 +02:00
David Given bcf3408e36 More stuff builds; almost the C compiler now. 2016-07-14 23:54:13 +02:00
David Given 88bd7ce126 Remove defunct pmfiles.
--HG--
branch : default-branch
2016-06-03 13:56:50 +02:00
David Given 391cb0f2cd Fix checkin into wrong hg branch.
--HG--
branch : default-branch
2016-03-17 20:53:45 +01:00
David Given 863b610144 Fix use-after-free. 2016-03-17 20:52:27 +01:00
David Given ff0c78cc78 Merge from default.
--HG--
branch : dtrg-videocore-branch-branch
2016-03-13 21:13:09 +01:00
David Given 3d5e72e20b Newer versions of GNU Make have a new function which collides with a
variable we're using; change the name of the variable.
2015-03-22 12:09:46 +01:00
David Given d94c1c8150 Updated distr files.
--HG--
branch : dtrg-videocore
rename : mach/i80/.distr => mach/vc4/.distr
rename : plat/cpm/.distr => plat/rpi/.distr
2013-06-21 23:38:21 +01:00
David Given 55be35a68a Add a stub malloc.h.
--HG--
branch : dtrg-videocore
rename : lang/cem/libcc.ansi/headers/stdlib.h => lang/cem/libcc.ansi/headers/malloc.h
2013-06-20 00:15:14 +01:00
David Given d273497077 Add some missing libc functions: setenv, unsetenv, strdup.
--HG--
rename : lang/cem/libcc.ansi/stdlib/getenv.c => lang/cem/libcc.ansi/stdlib/setenv.c
rename : lang/cem/libcc.ansi/string/strlen.c => lang/cem/libcc.ansi/string/strdup.c
extra : source : 64d6e6eec18d76bf8f3947ec5d171db94acdb282
2013-05-29 21:41:58 +01:00
David Given 074b42aa97 Add some missing libc functions: setenv, unsetenv, strdup.
--HG--
branch : dtrg-videocore
rename : lang/cem/libcc.ansi/stdlib/getenv.c => lang/cem/libcc.ansi/stdlib/setenv.c
rename : lang/cem/libcc.ansi/string/strlen.c => lang/cem/libcc.ansi/string/strdup.c
2013-05-29 21:41:58 +01:00
David Given f522aba4af Add support for snprintf and vsnprintf. Try and make the return value a bit
more standards-compliant.

--HG--
extra : source : a19eb606871f918e3d9e195b487b5276855edc8e
2013-05-29 17:10:58 +01:00
David Given 69953d016c Add support for snprintf and vsnprintf. Try and make the return value a bit
more standards-compliant.

--HG--
branch : dtrg-videocore
2013-05-29 17:10:58 +01:00
David Given d3e3e72860 Update from trunk.
--HG--
branch : dtrg-videocore
2013-05-29 15:03:48 +01:00
David Given 98e745d04c Fix awful bug where uint32_t was sometimes defined as a short.
--HG--
branch : dtrg-videocore
2013-05-25 00:33:01 +01:00
David Given c18a82ec40 Apply build system fixes for OpenBSD contributed by George Koehler. 2013-05-18 12:15:53 +01:00
David Given 11377070fd Update distribution files.
--HG--
branch : dtrg-buildsystem
2013-05-15 23:46:15 +01:00
David Given 07453d184a Top, topgen, aelflod. Moved the libraries back into the platform-specific
directories --- wrangling descr files was too hard. C programs can be built
for cpm, pc86, linux386, linux68k!

--HG--
branch : dtrg-buildsystem
rename : util/ack/build.mk => util/led/build.mk
rename : util/LLgen/build.mk => util/topgen/build.mk
2013-05-13 23:26:15 +01:00
David Given af0dedeb6e Fix typo.
--HG--
branch : dtrg-buildsystem
2013-05-13 11:14:10 +01:00