Commit graph

7134 commits

Author SHA1 Message Date
David Given e7eb563ee9 Disable gethostid() in the build system Lua; it's unused and doesn't work on
Haiku.
2016-11-11 20:16:43 +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 0d0495e818 Install only 1 copy, not 2 copies, of osx headers.
Before this commit, the headers in plat/osx/include got installed
twice into PLATIND/osx386/include and PLATIND/osxppc/include.  This
commit installs them once into PLATIND/osx/include and changes both
descr files to find them.

Several rules in lang/ depend on plat/osx386/include+headers or
plat/osxppc/include+headers.  They each become a simplerule that
depends on plat/osx/include+headers.
2016-11-08 17:13:51 -05:00
George Koehler ed7fb69f79 Add the missing return in plat/osx/libsys/creat.c
Before now, it might have worked by accident if the return value from
open() stayed in the function return area.
2016-11-08 15:35:02 -05:00
George Koehler 7f94e971fd Remove trailing whitespace in plat/osx*
Also fix a comment.
2016-11-08 15:22:09 -05:00
George Koehler cd3cf5b10f Merge branch 'default' into kernigh-osx
This brings improvements to PowerPC code generation.
2016-11-08 13:49:16 -05:00
David Given 07113c069b Merge pull request #9 from kernigh/fix-flt-trek
fixes for floating point and startrek
2016-11-07 20:15:48 +01:00
George Koehler 82c2d18482 Edit startrek.c so I can compile it with gcc and OpenBSD libc.
Rename our getline() to get_line() to prevent a conflict with POSIX
getline() declared in stdio.h.

Remove dangerous call to gets().  OpenBSD does not have gets(), C99
deprecated it and C11 removed it.

Also change spelling "sheild" to "shield".
2016-11-06 20:21:48 -05: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 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
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 4ba409eb74 Ensure the modules properly depend on their headers. 2016-11-05 11:52:54 +01:00
David Given fee47b25c3 Merge from default. 2016-11-05 11:47:53 +01:00
David Given 7f64fe96c7 Properly declare the library headers as dependencies. 2016-11-05 11:47:36 +01:00
David Given 4fa2c94a4a Correctly mangle labels used in initialisers. 2016-10-31 23:21:33 +01:00
David Given 9261cd978d Typo fix. 2016-10-31 23:16:02 +01:00
David Given 941072e0d7 Add, I hope, patterns for fmsub, fnmadd, and fnmsub (also float versions). 2016-10-31 22:36:54 +01:00
David Given 44f0cea6ca Also use fmadd for single-precision floats. 2016-10-31 19:55:16 +01:00
David Given 064d1a5d5d Use fmadd for multiply-and-add instructions. 2016-10-31 19:52:17 +01:00
David Given e19850b114 Fix a few c11isms. 2016-10-30 16:51:06 +01:00
David Given 694d1e2deb Merge from default. 2016-10-30 15:59:44 +01:00
David Given db03785109 Merge pull request #7 from davidgiven/travis
Use built-in Lua rather than relying on a system one
2016-10-30 15:59:04 +01:00
David Given 9b6a5e3ae7 Merge from default. 2016-10-30 15:53:26 +01:00
David Given a5990289a9 Don't allow parallel builds in the top-level makefile. 2016-10-30 15:49:39 +01:00
David Given 613821d771 Old versions of make don't support -r. 2016-10-30 14:28:08 +01:00
David Given ca5b6e07bb Properly export symbols. 2016-10-29 23:52:17 +02:00
David Given 8c3670483f Get top working with the PowerPC; use it to eliminate useless branches and
moves.
2016-10-29 23:37:11 +02:00
David Given a8c4dac67c Merge from default (merging in George Koehler's PowerPC changes). 2016-10-29 22:40:40 +02:00
David Given a311e61360 Add support for preserved registers. 2016-10-29 20:22:44 +02:00
David Given e3ebf986e9 More opcodes. 2016-10-29 13:32:09 +02:00
David Given 1ae8b90238 More opcodes. 2016-10-29 12:55:34 +02:00
David Given acaae765af Emit negative constants correctly. 2016-10-29 12:55:21 +02:00
David Given 61349389fb More opcodes. sti can now cope with non-standard sizes (really need a better
fix for this). Hack in crude support for mismatched stack pushes and pops (ints
vs longs).
2016-10-29 12:48:05 +02:00
David Given 68419da235 Actually, the locals need to go above the spills and saved regs, so fp == lb. 2016-10-29 12:00:33 +02:00
David Given 2cc2c0ae98 Lots more opcodes. Rearrange the stack layout so that fp->ab is a fixed value
(needed for CHAINFP and FPTOAB). Wire up lfrs to calls via a phi when
necessary, to allow call-bra-lfr chains.
2016-10-29 11:57:56 +02:00
David Given bfa65168e2 Don't generate phis if unnecessary (because this breaks the
critical-edge-splitting guarantee and causes insertion of phi copies to fail).
2016-10-29 10:55:48 +02:00
David Given 658db4ba71 Mangle label names (turns out that the ACK assembler can't really cope with
labels that are the same name as instructions...).
2016-10-27 23:17:16 +02:00
David Given 81525c0f2c Swaps work (at least for registers). More opcodes. Rearrange the stack layout
so we can always trivially find fp, which lets CHAINFP work.
2016-10-27 21:50:58 +02:00
David Given be3dece5af Allow emission of strings containing ". 2016-10-27 21:48:46 +02:00
David Given 51bd3ee4dd Fix bug where some phis weren't being inserted when a given variable definition
needed more than one phi (due to the dominance frontier containing more than
one basic block).
2016-10-27 21:40:25 +02:00
David Given 9977ce841a Remove the bytes1, bytes2, bytes4, bytes8 attributes; remove the concept of a
register 'type'; now use int/float/long/double throughout to identify
registers. Lots of register allocator tweaks and table bugfixes --- we now get
through the dreading Mathlib.mod!
2016-10-25 23:04:20 +02:00
David Given 45a7f2e993 Phi copies are now inserted as part of type inference. More opcodes. 2016-10-24 22:14:08 +02:00
David Given 111c13e253 More opcodes. 2016-10-24 20:15:22 +02:00
David Given a4644dee4d More opcodes. 2016-10-24 12:08:40 +02:00
David Given b22780c075 More opcodes, including the difficult and fairly stupid los/sts. 2016-10-23 22:24:08 +02:00