Commit graph

8083 commits

Author SHA1 Message Date
Marius Gerbershagen
e65e23ee8a configure: check if feenableexcept is actually working
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.
2020-01-11 15:37:15 +01:00
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
Daniel Kochmański
2cf975416a Merge branch 'gmp-alloc-fix' into 'develop'
Fix gmp allocation functions and #485

Closes #485

See merge request embeddable-common-lisp/ecl!176
2020-01-06 20:02:20 +00:00
Marius Gerbershagen
c2a577d609 bignums: prevent bignum registers from growing too big
We had this code before, but it made non-functional in commit
20f4c8931e and got removed with commit
749b97d06c.
2020-01-04 18:07:41 +01:00
Marius Gerbershagen
c301b108a7 bignums: don't use ecl_alloc_atomic for gmp
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.
2020-01-04 17:49:08 +01:00
Marius Gerbershagen
f5dfc145d0 Merge branch 'fix-547' into 'develop'
Fix 547

Closes #547

See merge request embeddable-common-lisp/ecl!174
2020-01-02 15:25:36 +00:00
Marius Gerbershagen
8ff5d8b60c Merge branch 'fix-546' into 'develop'
dffi: define ffi_type_complex_* types only when available

Closes #546

See merge request embeddable-common-lisp/ecl!175
2020-01-02 14:45:58 +00:00
Daniel Kochmański
1ccf7db8f8 dffi: define ffi_type_complex_* types only when available
In ecl_type_to_libffi_types we have definitions for complex float
types when appropriate define is present. Fixes #546.
2019-12-31 10:16:38 +01:00
Daniel Kochmański
bbd3c2d6d0 expt: add a case for complex-float ^ integer.
Lack of this switch branch lead to unrecoverable error. Fixes #547.
2019-12-30 22:04:11 +01:00
Daniel Kochmański
78138b65dc tests: add regression test for 547
Also add complex tests to the make-check test suite. that was a clear omission.
2019-12-30 22:04:07 +01:00
Daniel Kochmański
ef450d9070 contrib: sockets: fix get-host-by-name
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.
2019-12-30 10:39:13 +01:00
Daniel Kochmański
d6b577233b Merge branch 'c-stack-size' into 'develop'
Change handling of C stack resizing

See merge request embeddable-common-lisp/ecl!173
2019-12-30 09:37:40 +00:00
Marius Gerbershagen
d908394007 cmp: don't return nil in compile if compilation failed
The ansi standard states that compile has to return a compiled
function. Fixes various errors in the ansi-test suite.
2019-12-29 23:02:40 +01:00
Marius Gerbershagen
cb2cc7a81a tests: Add stack overflow test 2019-12-26 19:14:21 +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
Daniel Kochmański
87a1c5faed doc: be less ambigous in man page about lisp-stack and frame-stack
More specific information is provided in the complete
documentation. Closes #543.
2019-12-23 14:10:35 +01:00
Marius Gerbershagen
a4e93f7b61 cmp: fix compiler macro for sequence functions with :end argument
The :end argument was ignored previously.
2019-12-22 20:31:48 +01:00
Marius Gerbershagen
35e4a9160f cmp: fix proclamations for formatter functions
Some of the argument type proclamations were wrong.
2019-12-22 15:08:26 +01:00
Marius Gerbershagen
93e9c3b4ad cmp: add missing proclamations for formatter functions
All functions declared with si::c-export-fname must be either in
symbols_list.h or have a proclamation so that the compiler knows the
number of arguments that the function takes.
2019-12-22 00:14:19 +01:00
Marius Gerbershagen
7e381828f1 cmp: fix segmentation faults from coerce compiler macro
si::coerce-to-vector assumed that the to be coerced object had the
same length as that specified by the type. This lead to segmentation
faults even in safe code, for example in

(coerce '(a b c) '(vector * 4))

(coerce.error.3 test in ansi-tests)

Actually, si::coerce-to-vector had some checks for a correct length
previously, but they did not work correctly and were removed in commit
baaab01841.
2019-12-21 23:03:07 +01:00
Marius Gerbershagen
00934b358b format: don't signal an error if ~T and ~<...~> are mixed
Only ~:T is forbidden inside ~<...~> or in conjunction with
~<...~:;...~>.
Fixes #540.
2019-12-20 13:37:25 +01:00
Marius Gerbershagen
dbe43c09e6 libffi: disable building the documentation 2019-12-18 21:38:59 +01:00
Marius Gerbershagen
a7a18707b8 Merge branch 'refactor-compiler' into 'develop'
Minor compiler improvements

See merge request embeddable-common-lisp/ecl!170
2019-12-16 18:02:36 +00:00
Marius Gerbershagen
b68ba39ee8 Merge branch 'libffi-update' into 'develop'
Update libffi to version 3.3

See merge request embeddable-common-lisp/ecl!171
2019-12-16 18:00:08 +00:00
Daniel Kochmański
b8dfd2784c tests: ffi: add a smoke test for complex float handling 2019-12-16 11:47:36 +01:00
Daniel Kochmański
ad5fe834bb ffi: enable complex floats for ffi
See
https://gitlab.com/embeddable-common-lisp/ecl/merge_requests/149#note_169658319
https://github.com/libffi/libffi/issues/489

complex float support in libffi shipped with my Ubuntu still have
these problems, but when I've built the libffi myself all works fine.

> (ffi:def-function "catanhf" ((x :csfloat)) :returning :csfloat :module :default)
 CATANHF
> (catanhf #C(10.0s0 0.5s0))
 #C(0.10008093 1.5657587)
>
2019-12-16 11:17:47 +01:00
Daniel Kochmański
69af894224 cmp: remove dynamic variable *compiler-input*
*compiler-input* was only passed to the first-pass, there is no need
for a dynamic binding.
2019-12-16 10:20:47 +01:00
Daniel Kochmański
05cc54a75e cmp: remove global entries machinery
This is a dead code which is not used in the compiler. It was meant
for providing entry points from Common Lisp code to ECL functions
written in C, but it was replaced by more robust machinery.
2019-12-16 10:20:47 +01:00
Daniel Kochmański
01e49c845a cmp: cmpc-machine: cosmetic: put tables in columns
It is easier to read this code this way. It goes well beyond 80
character limit but the alternative is not readable for human.
2019-12-16 10:20:47 +01:00
Daniel Kochmański
7dbde99b7c ffi: defcallback: unify behavior of dffi and compiled versions
- normalize return-type from NIL to :void, ARRAY and '* in interpreted
  dffi implementation -- it is already normalized in sffi

- remove invalid path where argument type was not a valid elementary
  FFI type

  when it was not c1-defcallback pushed result of add-object to
  arg-type-constants and tried to pass the data as opaque
  pointers. That said it could never work, because:

  1. add-object could return a string (i.e for known symbols expanding
     to ECL_SYM) and they were fed as elementary FFI type leading to
     errors during compilation by C compiler (invalid enum type)

  2. when ecl_make_foreign_data was called to pass opaque objects a
     function FFI:SIZE-OF-FOREIGN-TYPE was called which resulted in
     error (because return type is not a valid elementary FFI type
     what this code path was meant to be)

Moreover we validate both return type and argument types during the
first compiler to fail as early as possible (previously only argument
types were validated early).

- some cosmetic fixes like indentation or redundant PROGN
2019-12-16 10:20:42 +01:00
Daniel Kochmański
83ec2c86c7 cmpcbk: improve +foreign-elt-type-codes+
- move the constant and a function foreign-elt-type-code to the top
- re-align the constant data
- fix the feature reader conditionals (they were misplaced)
- add reader conditionals for complex floats
2019-12-11 16:13:34 +01:00
Daniel Kochmański
241f3ed172 cmp: remove unused variables: *compile-time-too*, *not-compile-time*
First one is never bound to T and second one is not referenced at
all. *compilation-time-too* when T was interpreted to evaluate forms
before compiling them (independent of eval-when).
2019-12-11 16:13:34 +01:00
Daniel Kochmański
57e09c89b1 cmp: t1expr*: expand symbol macros
They were silently ignored before in compiled files. The were not
ignored in files which were just loaded.

  (define-symbol-macro foo (error "HI"))
  foo ; ignored
2019-12-11 16:13:34 +01:00
Daniel Kochmański
cab4917d86 cmp: cmpmain first pass: put the pass in a separate function
Function behaves differently for streams and for other objects. This
makes the code more consistent.
2019-12-11 16:13:31 +01:00
Marius Gerbershagen
5860f42f88 ffi: Update libffi to version 3.3 2019-12-09 19:49:30 +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
Daniel Kochmański
02f30c68b7 cmp: improve notes 2019-12-08 11:05:15 +01:00
Daniel Kochmański
f4aa1aa857 Merge branch 'arm64' into 'develop'
Fix #224

Closes #224

See merge request embeddable-common-lisp/ecl!164
2019-12-08 10:01:54 +00:00
Marius Gerbershagen
4f8b4fab8b update CHANGELOG, INSTALL and cross config for iOS 2019-12-08 10:26:52 +01:00
Marius Gerbershagen
0b33cdf6f6 doc: better explanation of ECL_OPT_C_STACK_SIZE boot option 2019-12-08 10:26:52 +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
bc9f75871e cmp: complain when the number of arguments of an exported function is not known
When we don't know how many arguments an exported function takes, we
can't create a correct declaration for the C function in the .eclh
file. To avoid having too many proclamations, we extract this
information from symbols_list.h for ECL core functions defined in
Lisp.
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
8a0b9cf8b9 prevent proclamations from influencing setf-expansions, deftypes, ...
Various macros created lambda-blocks with names that could be equal to
names of unrelated functions. The compiler would then try to apply
proclamations for these functions to the lambda-block. Prevent this by
expanding to a (lambda (...) (block name ...)) instead
of (lambda-block name (...) ...).
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
68ee6fa228 add some missing ecl_va_end statements 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
32b6f02157 dpp: check if declared and actual number of arguments match 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
Marius Gerbershagen
234a1084d5 contrib: sockets: fix mingw build 2019-12-08 00:22:52 +01:00