Commit graph

1118 commits

Author SHA1 Message Date
Marius Gerbershagen
cb03494a6d ieee_fp: use explicit checks for fpe bits if feenableexcept is not declared
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.
2020-01-11 15:32:52 +01:00
Marius Gerbershagen
d7b2dfb722 Change handling of C stack size
Previously: unconditionally use the size from ECL_OPT_C_STACK_SIZE if
it is larger than the OS provided value and if possible resize the
stack at runtime.

Now: Use ECL_OPT_C_STACK_SIZE if provided. Otherwise, use a) the OS
provided value if we can resize the stack at runtime (for Unix) or b)
the new build option ECL_DEFAULT_C_STACK_SIZE (1 MB) if we can set the
stack size at link time (for Windows).
2019-12-26 19:13:31 +01:00
Marius Gerbershagen
b2f09b4809 ffi: generate abi list from available libffi abis
This is more robust against changes in the abi support in libffi.
We also remove unused struct and enum type definitions (left over from
our own dynamic ffi implementation?).
2019-12-09 19:49:30 +01:00
Marius Gerbershagen
e37fafb335 stacks.d: fix several problems with C stack
ecl_cs_set_org and cs_set_size had several problems:
-the size of the stack was estimated to be 1/2 of the actual value,
 which could lead to wrong stack overflow errors. In particular, we
 cannot assume that the stack pointer will always start at the stack
 origin and increase/decrease linearly (counterexamples could
 include callbacks from other threads).
-despite its name, cs_set_size did not actually set the stack size
 even on systems where this is possible at runtime.
-there were several magic numbers used.
2019-12-08 10:26:52 +01:00
Marius Gerbershagen
a2319d3150 unixsys: check for system() in configure
Don't let a non-available system() function (happens e.g. on iOS)
prevent us from compiling ECL.
2019-12-08 10:26:52 +01:00
Marius Gerbershagen
fbdb0a32a8 cmp: check that number of arguments matches the declaration in symbols_list.h
We also use the *in-all-symbols-functions* variable only for
determining which functions are to be exported during the build of ECL
itself. Otherwise, instead of specifying manually, which Lisp
functions are exported and in the core, we use the information from
symbols_list.h (i.e. we let all_symbols.d initialize all core
functions).
2019-12-08 10:26:52 +01:00
Marius Gerbershagen
846cf3f377 dpp: create correct signature for functions with only required arguments 2019-12-08 10:26:52 +01:00
Marius Gerbershagen
18cb1b3552 fix for calling conventions treating fixed and variadic arguments differently
Previously, we assumed that the fixed and variadic arguments of a
variadic function were passed to the function in the same way. The
arm64 calling convention used by iOS breaks this assumption by passing
fixed arguments in registers or on the stack, depending on the
position, while variadic arguments are always passed on the stack.

Solving this problem while still allowing function redefinition at
runtime requires introducing additional dispatch functions. These
dispatch functions take no fixed arguments and pass all their
arguments to the actual function. This dispatch is enabled by passing
-DECL_C_COMPATIBLE_VARIADIC_DISPATCH to the C compiler.

This problem was originally identified and a solution provided by
thewhimer@gmail.com. This commit based on his work with minor
improvements.
2019-12-08 10:26:52 +01:00
Daniel Kochmański
02038d66da complex-float: move functions to externa.h
si_complex_float_p and si_complex_float are referenced in tests, to
allow clean compilation put them in externa.h.
2019-12-04 18:03:53 +01:00
Daniel Kochmański
0a7056da5f ecl_min: symbols list: fix si::complex-float function name
Symbols must be associated with functions following an uniform naming
scheme because si:mangle-name does not return pre-existing string.
See #534 for details. This is a temporary solution.
2019-12-04 17:52:16 +01:00
Daniel Kochmański
b96d28a4f8 Merge branch 'fix-476' into 'develop'
Fix 476

Closes #476

See merge request embeddable-common-lisp/ecl!161
2019-08-26 06:15:51 +00:00
Marius Gerbershagen
693ce14130 printer: remove redundancies between pretty and ordinary printer 2019-08-18 19:31:58 +02:00
Daniel Kochmański
df339485eb Merge branch 'infinity-NaN-numeric-functions' into 'develop'
Make all numeric functions return sensible values for infinity/NaN

Closes #477

See merge request embeddable-common-lisp/ecl!160
2019-08-16 18:52:23 +00:00
Marius Gerbershagen
57db4c813c complex-float: use CMPLX for constructing complex floats
Works better for edge cases such as x + I*∞, which otherwise would
lead to a complex with NaN real part.
2019-08-14 20:51:40 +02:00
Marius Gerbershagen
046c6b9f32 number_compare.d: fix number comparison for NaN
All comparisons with NaN should return NIL for consistency with the
IEEE standard.
2019-08-14 20:51:40 +02:00
Marius Gerbershagen
0ff3e27b54 ECL_STACK_FRAME_VARARGS: Use the correct struct 2019-07-23 18:45:49 +02:00
Marius Gerbershagen
912f4e49dc apply_from_stack_frame: use correct frame base
Previously, we assumed that all stack frames were lying at the top of
the lisp stack. This is not always true due to e.g.
multiple-value-prog1 pushing onto the lisp stack.
2019-07-23 18:45:24 +02:00
Daniel Kochmański
f3c6e4ccef cmp: remove unused interface *linking-calls*
Variable is always nil so blocks of code are never executed. Remove
it. TRAMPOLINK was used only in such bodies.
2019-07-19 14:30:53 +02:00
Daniel Kochmański
23e02dbd9d cosmetic: align slot 2019-07-19 14:30:53 +02:00
Daniel Kochmański
5986aee429 ECL_STACK_FRAME_VARARGS_BEGIN: fix off-by-one error
We allocate arguments on a heap when number of them exceeds
ECL_C_ARGUMENTS_LIMIT. Was:

  if (narg <  ECL_C_ARGUMENTS_LIMIT) ... else ..

should be

  if (narg <= ECL_C_ARGUMENTS_LIMIT) ... else ..

It is a partial fix for #513 (solves a segfault).
2019-07-19 14:21:06 +02:00
Daniel Kochmański
db41388791 cleanup: remove unused code
- ECL_ASM_APPLY was never used (apply assembly implementation for x86)
- ECL_USE_VARARG_AS_POINTER was never used
2019-07-16 09:04:46 +02:00
Daniel Kochmański
7a2658fbe3 Merge branch 'file-stream-improvements' into 'develop'
File stream improvements

See merge request embeddable-common-lisp/ecl!153
2019-07-15 22:13:04 +00:00
Marius Gerbershagen
1334eb1765 cmp: prevent deadlock if the C compiler output is too large
The pipe from which we read the output of the C compiler could fill up
when a large number of warnings were printed leading to a deadlock
because we waited for the C compiler to finish before reading the
output.
2019-07-15 21:32:36 +02:00
Marius Gerbershagen
d1718a1f7e ieee-fp: remove old floating point environment workarounds
It is better to let the user disable these features with configure
options than having a bunch of unmaintained workarounds lying around.
2019-06-30 13:04:18 +02:00
Marius Gerbershagen
b891630699 ieee-fp: introduce new macro for toggling between Lisp and C fpe
This is primarly useful for embedding. Lisp code can be safely
executed without leaking the floating point environment into other C
code.
2019-06-30 13:01:06 +02:00
Marius Gerbershagen
8a0e42a93c file.d: improve performance when reading from character streams
External format decoders now operatore on characters buffers instead
of reading input byte by byte from the streams. This allows us to
provide efficient read_vector implementations.
2019-06-15 18:33:50 +02:00
Daniel Kochmański
6e5016dcb8 hash-table: add extension for generic predicates
Added:
- implementation
- test
- documentaiton entries

Additionally:
- remove #if 0 code branches (unused clutter)
- bring up-to-date help.lsp file for hints in slime
- wrap synchronized access in unwind protect
- write_ugly did not carry extensions in the printer
2019-05-25 09:56:08 +02:00
Daniel Kochmański
ea87100a06 long-float: remove conditionalization
Many parts of the source code were bent backward to support builds
without long floats which are always present given we depend expect
c99 compiler.

The corresponding C macros (ECL_LONG_FLOAT) and the *feature*
entry (:long-float) are marked as deprecated in the documentation.
2019-05-24 21:04:59 +00:00
Marius Gerbershagen
9dedfe95e5 complex-float: add inline definitions for si::complex-*-float-p 2019-05-20 21:54:05 +02:00
Marius Gerbershagen
95b02061b8 legacy.h: replace all remaining occurences of type_of with ecl_t_of 2019-05-20 20:31:47 +02:00
Daniel Kochmański
db5e0937b3 complex-float: add a specialized array type for complex floats 2019-05-15 16:35:16 +02:00
Daniel Kochmański
8cc0ae7222 complex float: add compiler optimizations and ffi definitions
- add ffi implementation for long-float
- add ffi implementation for (complex float) types
- add compiler optimizations and definitions for complex float

We do not add c?float common constants (long-float i.e has optimizer
for 0.0 and -0.0), because we don't know if they are common at all and
if we think about it each would have four entries counting signed
zeros).

Also add informative comment about global-entries.
2019-05-15 16:35:16 +02:00
Daniel Kochmański
e1adfd2794 numeric tower: merge <complex float> with <complex>
cl_type_of: give better results for (type-of <complex>)

Instead of simply returning complex we return:

  (complex real)

when code is built without complex float support, and otherwise

  (complex rational)
  (complex single-float)
  (complex double-float)
  (complex long-float)

New functions:
- ecl_to_csfloat
- ecl_to_cdfloat
- ecl_to_clfloat
2019-05-15 16:35:16 +02:00
Daniel Kochmański
fdc40520a2 complex float: extend math_dispatch macros and add appropriate stubs 2019-05-15 16:35:11 +02:00
Daniel Kochmański
a0a92dc2af complex float: add a new types and builtin classes
What has changed:

- new types si:complex-float, si:complex-single-float,
  si:complex-double-float and si:complex-long-float
- new builtin classes long-float (for completness) and
  si:complex-float
- new internal function si:complex-float and si:complex-float-p for
  constructing complex floats (both arguments must be of the same
  float type) and a type predicate
- printer for new types (right now it conses, see below)
- a new feature :complex-float
- a new type is recognized as a type disjoint of complex and real

- cleanup: +built-in-type-list+: remove some redundancy
  For instance instread of saying
    (real (or integer single-float double-float ratio))
  We say
    (real (or integer float ratio))
  etc.

Flaws which will be fixed in upcoming commits:

- complex-float hierarchy is independent of the complex hierarchy
- ecl_make_complex_float could be replaced by _ecl_make_complex_*float
- write_complex_float allocates new objects for printing
- write_complex_float does print unreadable object
- math dispatchers doesn't recognize the object

Testing things out:

> (si:complex-float 0.0d0 0.0d0)
; #<CF(0.0d0 0.0d0)>
> (si:complex-float 0.0d0 0.0s0)       ; signals type error
> (+ (si:complex-float 0.0d0 0.0d0) 1) ; signals type error

lisp runtime: make si_complex-float a subtype of a number.
2019-05-13 19:48:54 +02:00
Daniel Kochmański
f78cb49def complex float: rename cl_lispunion member complex to gencomplex
Complex is a macro specified in complex.h for c99 to simplify using
_Complex type. This file also contains functions to work on complex
floats. To avoid conflicts we rename internal name complex to
gencomplex and update all references to it.
2019-05-06 08:17:33 +02:00
Daniel Kochmański
6ecd2473c4 complex float: add types and structures to core runtime
t_csfloat - ecl_csfloat,
t_cdfloat - ecl_cdfloat,
t_clfloat - ecl_clfloat.
2019-05-06 08:17:33 +02:00
Daniel Kochmański
1533824059 buildsystem: improve checks for floats
We do not check for c99-mandated functions for long float (we only
check for the type). We also check for complex numbers in a separate
function and define ECL_COMPLEX_FLOAT when found.
2019-05-05 10:38:02 +02:00
Marius Gerbershagen
60870ae9b0 use correct unnormalized values for minimum float constants
Fixes #470.
2019-02-13 20:24:26 +01:00
Marius Gerbershagen
19c6635ff0 expt: use pow function for floating point numbers
Improves speed and accurracy.
2019-02-12 22:37:23 +01:00
Daniel Kochmanski
9096514cff extensions: put ext:package-locked-p in core module. 2019-02-07 13:27:12 +01:00
Marius Gerbershagen
24dcb778cf clean up functions creating base strings from C strings
Make functions behave as documented, remove use of legacy names.
    Fixes #462.
2019-01-07 18:43:55 +01:00
Marius Gerbershagen
76941e25dc fix the broken serialization functions for externalizable objects 2018-12-10 18:14:01 +01:00
Exaybachay
5d4069e1fa fix header argument names for C++ compilation
fix the macro body
2018-11-02 17:31:55 +08:00
Exaybachay
bea1413ccf Revert "fix header argument names for C++ compilation"
This reverts commit 878ec343a0.
2018-11-02 17:28:17 +08:00
Exaybachay
878ec343a0 fix header argument names for C++ compilation 2018-11-02 17:16:02 +08:00
Exaybachay
eaea424f7c Revert "fix header argument names for C++ compilation"
This reverts commit 1ab9f00744.
2018-11-02 17:09:56 +08:00
Exaybachay
1ab9f00744 fix header argument names for C++ compilation 2018-11-02 13:32:35 +08:00
Daniel Kochmański
4021fbdcf8 Merge branch 'atomic-ops' into 'develop'
Add support for atomic operations

Closes #278

See merge request embeddable-common-lisp/ecl!122
2018-10-15 19:23:52 +00:00
Marius Gerbershagen
c45098e17a doc: add documentation for atomic operations 2018-10-15 19:55:39 +02:00