Commit graph

60 commits

Author SHA1 Message Date
David Given 25b6712e63 Rework all the ackbuilder scripts not to use wildcards, because we can't expand
them without luaposix, which isn't available (easily) on OSX or Windows.
2022-07-14 23:57:54 +02: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
carl add131b6f9 ANSI C conversion of code, rename some parameters to better names and adapt man page accordingly. 2019-05-11 00:56:13 +08:00
George Koehler e5e96d5226 Convert 1 to 1.0, not 0.0, for machines with 64-bit long.
This fixes flt_arith2flt() when sizeof(arith) != 4, where arith is
long.  When cemcom.ansi sees an expression like d + 1 (where d is some
double), it calls flt_arith2flt() to convert 1 to floating-point.  On
machines where sizeof(arith) != 4, the code did n >>= 1 when n should
not have been changed.  If n was 1, then n == 0 became true.  This
caused the code to convert 1 or -1 to 0.0.

My fix assumes sizeof(arith) >= 8, so I can use n >> 32.  Machines
with sizeof(arith) of 5 to 7 would need to do (uarith)n >> 32, where
uarith must be an unsigned integer type of same size as arith.

In startrek.c, the Enterprise can now dock with a starbase.  The
compiler no longer translates s1 - 1 to s1 - 0.0 and s1 + 1 to s1 +
0.0, so the game now looks for starbases next to the Enterprise.
2016-11-06 19:34:51 -05:00
George Koehler daeeb5aca3 Simplify flt_arith now that mantissa uses uint32_t.
It seems that someone wanted to build flt_arith with a compiler that
had long but not unsigned long.  This required extra code to
accomplish unsigned right shift, unsigned division, and unsigned
comparison using the signed operations.  Now that we use uint32_t, we
can simply use the unsigned operations and remove the ucmp() function.
We have similar code in mach/proto/fp/ and in
lang/cem/libcc.ansi/stdlib/ext_comp.c where we use the unsigned
operations.

Some long variables become uint32_t, and some masks with 0xFFFFFFFF
disappear because uint32_t has only 32 bits.

Update flt_arith.3 to show that mantissa uses uint32_t.

Provide a target to install modules/src/flt_arith/test.c as flt_test
so I can run the tests.
2016-11-05 21:51:53 -04:00
George Koehler 3bb41d3910 Switch flt_mantissa fields from long to uint32_t.
This seems to fix an error when flt_arith converts a literal
double-precision float to IEEE format.  For example, 0.5 and 0.75 got
converted to slightly below their correct values.

My host gcc for amd64 has 64-bit long, but flt_arith needs only 32
bits.  The code (at least flt_add.c) can make 32-bit overflows.  Such
overflows would set the higher bits of a 64-bit long, which might
cause problems later.

I need to use uint32_t and not int32_t because the code still uses
long, and the sign extension from int32_t to long would cause
problems.  The mantissa represents a value in [0, 2) that can't be
negative, so unsigned type is better.  Also, signed overflow is
undefined behavior in C, so flt_add.c better make overflows with
uint32_t and not int32_t.

This commit doesn't touch lang/cem/libcc.ansi/stdlib/ext_fmt.h which
continues to use unsigned long for its mantissa fields.
2016-11-05 17:00:24 -04:00
George Koehler 5c62ec2d8f Assume ANSI C in modules/src/flt_arith
Remove the #include "ansi.h" and always use the prototypes.
2016-11-05 16:24:18 -04:00
David Given 7f64fe96c7 Properly declare the library headers as dependencies. 2016-11-05 11:47:36 +01: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 0d77cb8279 We can build our first C file. 2016-08-07 21:56:53 +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 88bd7ce126 Remove defunct pmfiles.
--HG--
branch : default-branch
2016-06-03 13:56:50 +02:00
David Given 11377070fd Update distribution files.
--HG--
branch : dtrg-buildsystem
2013-05-15 23:46:15 +01:00
David Given c1aca7dae5 First milestone of replacing the build system.
--HG--
branch : dtrg-buildsystem
rename : lang/cem/cpp.ansi/Parameters => lang/cem/cpp.ansi/parameters.h
2013-05-12 20:45:55 +01:00
George Koehler 0131ca4d46 Delete 689 undead files.
These files "magically reappeared" after the conversion from CVS to
Mercurial.  The old CVS repository deleted these files but did not
record *when* it deleted these files.  The conversion resurrected these
files because they have no history of deletion.  These files were
probably deleted before year 1995.  The CVS repository begins to record
deletions around 1995.

These files may still appear in older revisions of this Mercurial
repository, when they should already be deleted.  There is no way to fix
this, because the CVS repository provides no dates of deletion.

See http://sourceforge.net/mailarchive/message.php?msg_id=29823032
2012-09-20 22:26:32 -04:00
dtrg b611731ec3 Updated .distr files for the new release. 2007-02-25 12:51:55 +00:00
dtrg 097c640a6c First version in CVS. 2006-07-20 23:24:28 +00:00
dtrg 6073ee934e Rationalised use of #includes to be more standards-compliant. 2006-07-19 14:09:05 +00:00
ceriel 2c66222509 Fixed bug: flt_div should not touch e1 1997-03-13 18:38:24 +00:00
ceriel 7b6d8fbe56 Added copyright notice 1995-07-31 09:10:42 +00:00
ceriel b71c0ca9a3 Added Amake.srclist 1995-03-21 09:39:29 +00:00
ceriel 5c83e7dbb5 Header --> Id 1994-06-24 11:31:16 +00:00
ceriel 11d4fdf6e0 Added prototyping stuff 1993-11-10 11:14:28 +00:00
ceriel ab8dcfa134 ANSI C fixes 1993-10-21 12:50:58 +00:00
ceriel a0acff4f4c minor change: give anonymous struct a name 1992-02-26 15:46:44 +00:00
ceriel 89887ef6b0 made more acceptable for ANSI C 1991-11-26 14:39:52 +00:00
ceriel 4e99d889ff Changed manual page installation mechanism 1991-11-05 15:31:14 +00:00
ceriel 18897487a9 do not do lintlib installation on 'make install', also make sure
that every proto.make has a lintlib entry
1991-10-09 19:02:55 +00:00
ceriel 182c7ebd70 Fixed flt_ar2flt.c 1991-10-02 15:20:22 +00:00
ceriel 7551b8e83a Changes to manual page 1991-10-01 12:18:39 +00:00
ceriel 73177ad913 New installation mechanism 1991-08-26 16:50:25 +00:00
ceriel ea9332362d correction 1991-06-26 17:26:59 +00:00
ceriel 977e1ac25e Removed unused variable 1991-03-11 14:38:28 +00:00
ceriel ee02bfcd82 minor mods 1991-02-26 15:46:18 +00:00
ceriel 9a294d4821 Changed name of include file 1991-02-19 13:53:04 +00:00
ceriel 3660ea15c5 One less significant digit: 20 was too much 1991-02-18 11:43:44 +00:00
ceriel 24a8b613ae Added test program 1990-12-04 16:40:21 +00:00
ceriel 8468609eda improved for numbers that can be represented exactly 1990-12-04 11:33:01 +00:00
ceriel 0c95aa4b86 fixed library order : fix for 2-byte machines 1990-02-23 17:02:06 +00:00
ceriel 531f9b1f77 removed unused variables 1990-01-18 10:59:04 +00:00
ceriel 4b42dcf97f fix: flt_status was not always set properly 1989-12-19 09:27:16 +00:00
ceriel 662c87a579 flt_status maintained for flt_str2flt() 1989-12-18 18:17:17 +00:00
ceriel a0187208a5 fixed: did not compare properly with 0; reduced size 1989-12-13 16:35:19 +00:00
ceriel e891b36895 removed declaration of unused variable 1989-12-13 13:09:10 +00:00
ceriel 862f83571f speeded up a bit for converting 0.0 to string 1989-11-27 17:25:55 +00:00
ceriel c30769327b fixes: ucmp did not quite work right, flt_div had an obscure bug 1989-11-13 12:54:33 +00:00
ceriel 45c90324fd Added some casts for lint 1989-11-08 12:52:41 +00:00
ceriel c246adf1c4 correction 1989-10-24 14:42:49 +00:00
ceriel 35c612b99b some minor improvements 1989-10-19 14:50:52 +00:00