There are a few places where error() was called that in practice would never
be returned from, however since it was coded with the possibility of returning
all call sites must be consistent with that.
modified: ../src/car-cdr.c
modified: ../src/gchtfind.c
modified: ../src/hardrtn.c
* Remove F_SETSIG call from Linux on X11 display.
Presumably, this was added to be like the `I_SETSIG` call on Solaris.
But it is the only `F_SETSIG` done on Linux and there isn't an
equivalent on the other platforms that we support as it is a GNU
extension.
Also, `F_SETSIG` with an argument of `0`, as here, means to send
the `SIGIO` signal, which is what is done by default.
From the man page:
F_SETSIG (int)
Set the signal sent when input or output becomes possible
to the value given in arg. A value of zero means to send
the default SIGIO signal. Any other value (including SIGIO)
is the signal to send instead, and in this case additional
info is available to the signal handler if installed with
SA_SIGINFO.
By using F_SETSIG with a nonzero value, and setting
SA_SIGINFO for the signal handler (see sigaction(2)),
extra information about I/O events is passed to the
handler in a siginfo_t structure. If the si_code field
indicates the source is SI_SIGIO, the si_fd field gives
the file descriptor associated with the event. Otherwise,
there is no indication which file descriptors are
pending, and you should use the usual mechanisms
(select(2), poll(2), read(2) with O_NONBLOCK set etc.)
to determine which file descriptors are available for I/O.
We aren't setting a non-zero value and we aren't establishing signal
handlers via `sigaction` with `SA_SIGINFO` set, so this shouldn't
be doing anything important for us.
* Stop setting _GNU_SOURCE for GNU libc extensions.
We were previously doing this to get access to the
`F_SETSIG` flag for `fcntl`, but this isn't being
used any longer.
Previously, we were using SysV pseudo-terminals on Solaris and BSD
pseudo-terminals on other Unix platforms. BSD pseudo-terminals have
been deprecated on Linux and are no longer available in some kernel
configurations.
The POSIX API is basically the same as the SysV API, apart from using
`posix_openpt` instead of `open` with `/dev/ptmx`.
Closesinterlisp/medley#121.
The return value of N_OP_unwind is really of type LispPTR *, however it was
declared as UNSIGNED (effectively uintptr_t) so that the ERROR_EXIT macro
could be used to return an error indication (-1, =UINT_MAX). The call site
checked for the error condition with (int)result < 0, not accounting for the
case where a native pointer may have the high-order bit set.
We correct this problem by declaring the return type as LispPTR *,
and expand the ERROR_EXIT macro in place substituting (LispPTR *)(-1)
as the error return value, and at the single call site check for equality
with that same value.
The test case was executing the opcode tester on a Raspberry Pi or
a BeagleBone Black/Debian 10.3 where the non-error result was > 0xB0000000
modified: inc/inlineC.h
modified: inc/unwinddefs.h
modified: src/unwind.c
* Remove word_swap_longword.
This was the same as `swapx` and not used except in one place which
now uses `swapx` instead.
* Remove assembly versions of swapx, byte_swap_word, word_swap_page.
`swapx` and `byte_swap_word` were defined as:
```
extern inline const unsigned int swapx (unsigned int word)
{
asm("roll $16,%0" : "=g" (word) : "0" (word));
return(word);
}
extern inline const unsigned short byte_swap_word (unsigned short word)
{
asm("rolw $8,%0" : "=r" (word) : "0" (word));
return(word);
}
```
But the generated code from the C version is:
```
(lldb) disassemble -n swapx
ldex`swapx:
ldex[0x10002e0d0] <+0>: pushq %rbp
ldex[0x10002e0d1] <+1>: movq %rsp, %rbp
ldex[0x10002e0d4] <+4>: movl %edi, %eax
ldex[0x10002e0d6] <+6>: roll $0x10, %eax
ldex[0x10002e0d9] <+9>: popq %rbp
ldex[0x10002e0da] <+10>: retq
(lldb) disassemble -n byte_swap_word
ldex`byte_swap_word:
ldex[0x10002e0e0] <+0>: pushq %rbp
ldex[0x10002e0e1] <+1>: movq %rsp, %rbp
ldex[0x10002e0e4] <+4>: rolw $0x8, %di
ldex[0x10002e0e8] <+8>: movzwl %di, %eax
ldex[0x10002e0eb] <+11>: popq %rbp
ldex[0x10002e0ec] <+12>: retq
```
So we don't really stand to gain by re-enabling this old assembler code.
We would gain from switching to C99 or C11 and improving our
inlining.
* Remove 386 asm version of bit_reverse_region.
This is implemented in C and the code isn't actually set up to
allow using the assembler version.
Previously, we used `TIOCNOTTY` on some platforms (FreeBSD, macOS)
and `setsid` on Linux and Solaris. The correct modern way to do
this is to use `setsid` and the BSDs support this, so let's just
do that.
* Update comments describing configuration this makefile fragment supports.
* Remove extra compiler options for suggested gcc build
* Remove unnecessary -m32 option for suggested clang build
* switch default compiler from clang to gcc
This removes some usages of the SYSVONLY flag and lets us assume
the existence of `killpg`. It also updates a bit of code to accurately
populate the `pgrp` variable using `tcgetpgrp` rather than an ioctl.
* Default to NOETHER, only enable on Solaris.
* DOS: NOETHER controlled by inc/version.h
We set NOETHER by default on DOS, so no need for it here in the
build system.
This changes from `FASYNC` to `O_ASYNC`, `FNDELAY` to `O_NONBLOCK`,
and `O_NDELAY` to `O_NONBLOCK`. These are the modern names.
`O_NONBLOCK` is part of the POSIX standard. However, `O_ASYNC` is
specific to Linux and BSD. It is not available on Solaris, where
we still need to use `FASYNC`. Also, the behavior of having I/O
trigger a `SIGIO` signal is not in POSIX, since the `SIGIO` signal
is not in POSIX. Instead, it is only the behavior of having `SIGURG`
being signalled for out of band data that is specified.
We also takes this opportunity to collapse some multi-line calls
to get the flags, store it into a temp, and then set them, to
just doing it in one line, skipping the stored temporary value.
We also change one instance of `65535 - FNDELAY` to `~O_NONBLOCK`.
Closesinterlisp/medley#85.
According to `inc/version.h`, `REGISTER` is for floats which may
or may not be able to be in registers due to the `FPTEST` macro
implementation. We shouldn't be using it here for non-float
data.
In the past, we didn't use `gettimeofday()` on all non-DOS platforms
because it wasn't available, so we had to fall back to `time()`.
Those days are long gone and we have `gettimeofday()` on all non-DOS
platforms.
This also removes some code that used `times()` when it used `time()`.
This leaves us using `getrusage()` on all non-DOS platforms. This,
much like `gettimeofday()`, is now available everywhere. Not all of
the fields used here are guaranteed by POSIX, but the ones used
here shouldn't be an issue for now.
When `RELEASE` is set, then `inc/version.h` configures some
defines appropriately, including `BIGATOMS`, `BIGVM`, and
`NEWCDRCODING`. There's no need to manage it directly on
the compiler command line.
The return value of `fcntl` when passed `F_SETFL` isn't guaranteed
to return the flags passed in as its return value. It will be `-1`
in the event of an error, but no other value is to be relied upon.
Fortunately, we weren't relying upon the value apart from
occasionally checking for an error.
This is as it is specified in https://pubs.opengroup.org/onlinepubs/7908799/xsh/fcntl.htmlClosesinterlisp/medley#87.
* Always follow NEW_STORAGE code paths.
This removes the code paths for the pre-NEW_STORAGE code.
* Remove NEW_STORAGE from build system.
The code no longer refers to `NEW_STORAGE`, so we can remove
this from the build system.
This flag was for SunOS 3 and 4 on sun3 hardware (68k).
It enabled some unsafe optimizations via assembler. This hasn't
actually been built since the DOS port (since the header for this
was renamed, but the code in `xc.c` wasn't updated).
The optimizations here made assumptions that were specific to the
68k hardware and register allocation. They aren't likely to be
of much use moving forward, and we've got plenty of safe performance
improvements from the last 30 years of hardware advances.
* Use the real gethostid on Solaris.
Solaris has this, so we might as well use it like we do on other
platforms. This value is used in response to queries from it from
Lisp.
* Improve undefining of HAS_GETHOSTID.
Enable it on Solaris in `inc/version.h`. This file already
disables it on DOS, so no need to do so again in `src/initsout.c`.
Both sides of this #ifdef were the same, so just collapse it.
This code isn't actually relevant any longer, but this removes
an OS-specific #ifdef, making inspection of platform specific
code a bit easier.
This code was treating the `d_reclen` incorrectly from some of the
original old porting work. It is not the same as `d_namlen` and
`d_namlen` is not widely supported or standard. It should be using
`strlen(d_name)`.
This addresses an issue mentioned in interlisp/medley#103.
* Include <ieeefp.h> for Solaris.
* Remove sections for sparc and Sun i386 for non-Solaris.
* Have Linux use the same code as FreeBSD and macOS.
* Make the FreeBSD / Linux / macOS code path the default, if nothing
special is defined since it is the modern way.
* Remove fpstatus_() usage from the ancient days.
When `FLTINT` is defined (which is currently only on SunOS), if
`OS5` was not defined, then it tried to use `ieee_handler` which
doesn't exist on Linux and friends. If we were to enable `FLTINT`
on more platforms, then we'd want to always be using more modern
signal handling and not `ieee_handler`.