In the old code (prior to b234064d), this was:
```
LispReadFds &= ~(1 << LispWindowFd);
```
This was inadvertently converted to `FD_SET`, but should have
been `FD_CLR`.
* Correct signedness of 2nd parameter of lispcmp().
* Be clear that comparison of characters in bytecmp is unsigned since GETBYTE returns unsigned char.
* Make bytecmp() and lispcmp() helper functions static and removed from mkatomdefs.h.
* If no BYTESWAP we need to include <string.h> for memcmp()
* Use (uint8_t) rather than (unsigned char) in bytecmp when comparing to GETBYTE()
We need to build `.o` files for the executables separately from
their link step. This lets us have the `CFLAGS` only get used
by the compilation step and not the link step (which uses
`LDFLAGS` or a variant).
This is a prerequisite for doing automatic dependency tracking.
Previously, we had a global `optable`, an alias to it, `table`,
and code to initialize it within `dispatch()`. This code would
initialize the whole thing to either `op_ufn` or `native_check`
and then fill in the entries for the individual opcodes.
Now, we have a function-static `optable` which is statically
initialized and placed (by the compiler) into read-only storage.
This eliminates having generated code within `dispatch()` that
initializes it.
Additionally, it was previously 512 elements long with the second
half of it being all `native_check` entries. We index it with a
byte though, so we only need 256 entries, and we can lose the
`native_check` stuff.
Without those, it wasn't including `devif.h`, which is where
we define `min` and `max`. I make an assumption here that any
new display would be using the current display device support
code.
This was checking that neither `DOS` nor `XWINDOW` were defined,
but this needs a more specific flag for this feature so that it
doesn't get enabled when `!DOS && !XWINDOW`.
Convert ERROR_EXIT, TIMER_EXIT, and WARN to "do {} while (0)" style and
fix a few usage points that were missing trailing semi-colons.
Remove unused typedef for CFuncPtr.
This code is all currently set up to be used if `COLOR` is
defined.
If we were to start supporting color under X11, this would
have to change, but so would much of the rest of the file.
This was making sure that the overflow in some our opcode
implementations was visible to the C code so that overflow
detection would work in gcc and clang.
This is now handled on those compilers by using some built-ins
that detect overflow.
The `-fwrapv` should no longer be needed.
ClosesInterlisp/medley#90.
This no longer had anything to do with profiling and was
only doing some defines for the switch case block addresses,
which we no longer need since there's no longer optional
asm generated for them.
This feature was controlled by the compilation flag `OPDISP`
which would enable some bits of assembler on the x86 (ISC or DOS)
or some other specialized code on SPARC. On SPARC hardware, there
was a special compilation process that would preprocess the code
and generate dispatch tables.
We do this now when this feature is enabled using gcc's computed
gotos feature. This is available in clang and some other compilers.
Notably, it isn't present in Visual Studio.
This doesn't decrease our portability at all as this feature is
optional and it replaces specialized assembler code with C using
compiler extensions (making it cross-platform).
In doing this, we've removed a bunch of related code, however,
it is likely that other pieces yet remain and will be removed
in subsequent commits as we clean things up and refine them.
This feature remains disabled by default for now.
In the old build system, `ldeether` is built as follows:
```
$(OSARCHDIR)ldeether : $(SRCDIR)ldeether.c $(DLPIFILES)
$(CC) $(CFLAGS) -I$(INCDIR) $(SRCDIR)ldeether.c $(DLPIFILES) $(LDEETHERLDFLAGS) -o $(OSARCHDIR)ldeether
```
Instead of linking all of Maiko, it just links in the `src/dlpi.c`
object file.
This is the old way that releases were built and isn't relevant
today. It made a variety of assumptions about how things were
linked and allowed for the user to re-link an executable, but
that isn't something we need to do any longer.
This doesn't yet remove the checksum, ldechecksum, and related
scripts.
* Use gcc / clang overflow builtins.
This avoids expensive checks for overflow that employ undefined
behavior.
This is a step along the way towards replacing the old hand-written
assembler that did the same thing in terms of using the CPU's
overflow detection.
* Remove unimplemented SPARC asm for multiplication, divide, and remainder.
This wasn't implemented before, and for multiplication, it is now
implemented for gcc and friends using overflow detection.
* Remove USE_INLINE_ARITH.
Now that we have the compiler built-ins for detecting overflow,
we don't need custom assembly for it for each platform.
For now, we keep, but still don't use, the code that do a hot
path through the dispatch loop for some math. This code isn't
actually running or in use, but it is separate from how the
other inline arithmetic was being performed. These are the
`fast_op_*` functions that are implemented in assembler.
In commit 6f7ec059bc763d49c753adea70d5cc337f9e353c, we removed
some dead stores. This broke compilation when `STACKCHECK` was
enabled.
ClosesInterlisp/medley#162.
We now can handle these via `inc/maiko/platform.h` and the
constants defined there.
This doesn't change `OS5` for Solaris yet as that's a much wider
set of changes.
UNALIGNED_FETCH_OK shouldn't be set for an entire OS, but
based on the CPU architecture.
Some ARM systems don't allow unaligned reads. x86 and x86_64
do, so update how we configure this.
In the SunOS 4 days, the system cc apparently couldn't compile
the lp* files, so there was an arrangement to use an `ANSICC`,
which was just `gcc`, to build those files.
We no longer have this issue.
By adding `0.0` and not `0.0f` and by calling `fmod()` rather than
`fmodf()`, we were unintentionally coercing the value from a
`float` to a `double`.
This resulted in x86_64 assembler like this:
```
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
callq 403340 <fmod@plt>
cvtsd2ss %xmm0,%xmm0
```
which is now:
```
callq 403360 <fmodf@plt>
```
And for the `N_OP_equal` change:
```
cvtss2sd %xmm0,%xmm0
xorpd %xmm2,%xmm2
addsd %xmm2,%xmm0
cvtss2sd %xmm1,%xmm1
addsd %xmm2,%xmm1
xor %ecx,%ecx
ucomisd %xmm1,%xmm0
```
is now:
```
xorps %xmm2,%xmm2
addss %xmm2,%xmm0
addss %xmm2,%xmm1
xor %ecx,%ecx
ucomiss %xmm1,%xmm0
```
(Note `ss` rather than `sd`, along with the missing `cvtss2sd` calls.)