The C standard allows compilers to ignore side effects of floating
point operations unless the STDC FENV_ACCESS pragma is in effect. This
could lead to spurious floating point exceptions being signaled
because the C compiler optimized a calculation that would ordinarily
not set fpe bits to one that did (observed with clang for a cast
double to cl_fixnum).
To solve this, we resurrect the ECL_MATHERR macro which was removed in
commit cb03494a6d. We handle fpe bits
only around calculations which are known to be "unsafe" in the sense
that they can produce floating point exceptions. Before the
calculation, all bits are unset and afterwards, we test for
exceptions.
The disadvantage of this method is that optimizations by the C
compiler resulting in unboxed float arithmetic might lead to
missing exceptions, because our native C compiler does not insert
ECL_MATHERR statements around these calculations.
Due to the fact that the thread local environment is allocated with
mmap, the garbage collector is only aware of it after the thread is
listed in cl_core.processes. Therefore, we have to list the thread
before we allocate any memory in its environment. We were doing this
previously, however a bit earlier than needed which had the
unfortunate side effect that not all threads listed in
cl_core.processes had valid environment associated to them. Now, we
delay the listing until immediately before allocating the contents of
environment, ensuring that all listed threads have valid environments.
I think that the old method is a relic from the past when bytecodes
had a different representation. bytecompiled functions also have
proper annotations so there is no need to attempt to disassemble their
lambda lists manually. Closes#561.
Consistent formatting and capitalization, clickable links to functions
defined in other parts of the manual, better looking css for html
output. Some small errors and typos have been corrected as well.
According to the documentation, we were supposed to return nil, but
instead we signaled a bogus error like
:INPUT argument to RUN-PROGRAM does not have a file handle:
#<output stream "/dev/null" 0x5645a22a5280>
Some of the compiler macros expand into FFI:C-INLINE forms, precluding
the compilation of statements like
(eval-when (:compile-toplevel :load-toplevel :execute)
(print "test")).
Commit b00e62f9d3 (now reverted)
attempted to fix this previously, but introduced other bugs (see #553).
Instead of the naive solution of evaluating everything
in (eval-when (:compile-toplevel)) directly with the bytecodes
compiler, the approach used in this commit is to be more specific and
ignore compiler macros during compile time evaluation (i.e. the output
of the compiler macro is used only in the emitted C code, but not as
input for CMP-EVAL).
Fixes#553.
After the recent refactor of GET-HOST-BY-NAME to use getaddrinfo,
these functions had multiple problems that are fixed in this commit:
- in GET-HOST-BY-NAME, freeaddrinfo was called on an unitialized
struct addrinfo if getaddrinfo failed
- error handling in GET-HOST-BY-NAME wasn't working, we were still
trying to use the error handling for gethostbyname
- GET-HOST-BY-ADDRESS still used the deprecated gethostbyaddr function
The test was failing because it was detecting an output of
"
Hello stdoutHello stderr"
instead of the expected
"
Hello stdout
Hello stderr"
The reason for this is that the buffers of the
streams *standard-output* and *error-output* may be distinct, even if
the ouput send to both streams ends up in the same place. Thus, we
need to explicitely force-output in print-test. The error manifested
itself only in builds without thread support, because otherwise ECL
uses write instead of fwrite, avoiding any buffering.
Make sure that apart from turning on/off signaling for exceptions, we
also clear all exception bits. After the recent changes to how ECL
handles floating point exceptions, not doing that could lead to
spurious exceptions being signaled even when using the
ECL_WITH_LISP_FPE macro because an earlier calculation yielded
infinity/NaN.
Not all processors will signal floating point exceptions even when
told so, for example the Raspberry Pi as Dave Richards pointed out on
the ecl-devel mailing list.
Using isnan and isfinite to check for floating point exceptions
doesn't work when we want floats to be able to have infinity or NaN as
values, thus this option was removed with commit
5f71f728a3. However, we can still use
fetestexcept to explicitly check if floating point exceptions occurred
even when we can't use the feenableexcept/SIGFPE signal delivery
mechanism.
Previously, we had something like this in the
ECL_MATHERR_TEST/ECL_MATHERR_CLEAR macros, but this was not used
consistently in our codebase (the ECL_MATHERR_TEST macro was missing
in many places). Instead of error-prone testing at every point of
computation, we call fetestexcept in DO_DETECT_FPE when creating a new
float/complex float. In order to avoid having to do this twice, the
DO_DETECT_FPE2 macro is introduced.
A minor disadvantage of this strategy is that floating point
exceptions may be signaled later than they occurred.
The gmp manual (https://gmplib.org/manual/Custom-Allocation.html) states
> GMP may use allocated blocks to hold pointers to other allocated
blocks. This will limit the assumptions a conservative garbage
collection scheme can make.
Thus we can't use ecl_alloc_atomic. We could just use ecl_alloc
instead, however our implementation is already structured in such a
way that it is sufficient to use ecl_alloc_uncollectable. The reason
for that is that currently all bignums except those in the bignum
registers in the thread local environment are allocated as compact
objects so that we only need to call mpz_clear for the few non-compact
objects in the bignum registers.
See also commits 7b536161 and bd48b859.
Fixes#485.
Remove flag AI_V4MAPPED which takes effect only for AF_INET6
family. Currently we do not work at all with ipv6, hence this flag is
a no-op. Moreover Android has no definition for this flag. See !172.
Fix contributed by Polos Ruetz. Closes!172.