Commit graph

8252 commits

Author SHA1 Message Date
Marius Gerbershagen
d55d31df3b format: print 0 after decimal point with ~e for integer input
Example: (format t "~e" 1.0) used to print 1.e+0, now prints 1.0e+0

Code adapted from SBCL.
2022-09-03 19:38:51 +02:00
Daniel Kochmański
d0a24fe283 Merge branch 'cmp-infinite-loop-circular-structure' into 'develop'
Fix #630

Closes #630

See merge request embeddable-common-lisp/ecl!273
2022-08-16 09:10:24 +00:00
Marius Gerbershagen
3db6ad91ff cmp: fix infinite loop for files containing lists with the same circular structure
Closes #630.
2022-08-14 17:17:57 +02:00
Marius Gerbershagen
3bf98a96e0 tests: fix typo in trap-fpe smoke test
Due to the typo, all floating point exceptions were enabled after the
test had run. This leads to failures in other tests for instance due
to floating-point-inexact errors. Now, the exception flags are
correctly restored again after the test is finished.
2022-08-13 20:58:23 +02:00
Daniel Kochmański
b3d1a3e343 trap-fpe: signal an error when invalid condition is supplied
We've allowed any symbol to be supplied as a condition, when it was not
recognized then we've not changed bits (they remained 0). From now on we signal
an error if the condition can't be signaled.

Since user reported the error with keywords used instead of cl symbols, we also
make the manual more clear regarding the package of condition symbols.
Appropriate smoke tests are added too.

Fixes #681.
2022-07-28 21:08:31 +02:00
Daniel Kochmański
1ce4713804 floats: add operators to convert between floats and bits (integers)
The interface is in the system package (that is - not part of the official api).
2022-07-07 13:24:38 +02:00
Daniel Kochmański
4b83ceb1b6 Merge branch 'ext-program-path-with-environ' into 'develop'
RUN-PROGRAM: Try to use execvp even if :ENVIRON is specified

See merge request embeddable-common-lisp/ecl!272
2022-05-23 07:28:34 +00:00
Eric Timmons
e6b17033b7
RUN-PROGRAM: Try to use execvp even if :ENVIRON is specified
Unfortunately, execvpe is not standard. However, we can replicate its behavior
by pointing **environ to a new array of environment variable assignments before
execvp.

On Darwin, shared libraries do not have direct access to **environ. Instead, we
use the return value of _NSGetEnviron().

Rename all existing uses of environ (as a variable name) to my_environ as
environ now names a macro on both Darwin and Mingw.

If the target does not HAVE_ENVIRON, fall back to execve as before.
2022-05-20 14:38:41 -04:00
Eric Timmons
bad77f4915
Improve PROCESS-ENVIRON tests
(ext:run-program "env" nil :environ '("foo=bar")) actually exits with non-zero
status because 1) PATH is not specified in the child process and even if it
were 2) the use of :ENVIRON prevents ECL from searching the PATH for child
programs.

Rewrite the tests to actually highlight the failure.
2022-05-20 14:11:10 -04:00
Daniel Kochmański
4e9fab94eb ecl_bignum: access the internal object with a macro ecl_bignum
This provides a better data encapsulation and is more portable. Moreover it is
consistent with how we handle other boxed values like ecl_doublefloat.
2022-05-06 10:13:08 +02:00
Daniel Kochmański
e9967ef362 Merge branch 'fix-678' into 'develop'
core: add a new utility 'si_adjust_vector' to arrays.d

Closes #678

See merge request embeddable-common-lisp/ecl!271
2022-04-27 18:16:42 +00:00
Daniel Kochmański
52d0d64f9c ecl_min: don't use ADJUST-ARRAY in the core
The function ADJUST-ARRAY is defined later in Lisp code. Instead of that we use
a newly introduced SI:ADJUST-VECTOR. Fixes #678.
2022-04-27 13:50:19 +02:00
Daniel Kochmański
fe27ab8600 core: add a new utility 'si_adjust_vector' to arrays.d
This function is added to avoid using in the core the f unction CL:ADJUST-ARRAY,
that is not defined during bootstrapping.
2022-04-27 13:50:17 +02:00
Daniel Kochmański
8d90e31ecc Merge branch 'darwin-flat_namespace' into 'develop'
configure: don't use -flat_namespace on Darwin

See merge request embeddable-common-lisp/ecl!268
2022-03-29 09:51:50 +00:00
Daniel Kochmański
a4b593c110 Merge branch 'hashtable-improvements' into 'develop'
hash-tables: performance improvements

See merge request embeddable-common-lisp/ecl!269
2022-03-29 09:50:51 +00:00
Daniel Kochmański
2c1f94cc0d Merge branch 'add-missing-break-statement' into 'develop'
Add missing break statement to cl_hash_table_test

See merge request embeddable-common-lisp/ecl!270
2022-02-28 07:50:31 +00:00
Catherine Tower
88b09a6b60
Add unit test for HASH-TABLE-TEST
The test ensures that there's no error when HASH-TABLE-TEST is called on a hash
table with a custom equality function. The tests pass, with some caveats:

- I'm only about 70% sure that FINISHES is the right test-predicate to use for
  something like this
- The test suite would consistently fail with non-deterministic segfaults while
  testing the MULTIPROCESSING subtest. This could easily be due to the fact that
  I'm using a FreeBSD machine, and don't have access to a Linux machine at the
  moment -- though I'd be happy to re-run the tests when I do. The test suite
  completed when I commented out the MULTIPROCESSING subtest from the ASD
  file. I don't believe this would have any bearing on whether or not the hash
  table tests should pass
2022-02-27 15:19:01 -08:00
Catherine Tower
f0d46570a4
Add missing break statement to cl_hash_table_test
Without the break statement an error is signalled for any hash table with a
custom test function
2022-02-27 14:15:34 -08:00
Caleb Xu
2afa70807e
configure: don't use -flat_namespace on Darwin 2022-02-20 16:36:31 -05:00
Marius Gerbershagen
e3fc760139 Merge branch 'fast-gf' into 'develop'
generic function dispatch changes

See merge request embeddable-common-lisp/ecl!267
2022-02-20 17:11:54 +00:00
Marius Gerbershagen
16faca09b6 hash-tables: performance improvements
Previously, we used the "tombstones" approach for removing entries
from a hash-table, that is buckets were marked as previously occupied
but currently empty. If the hash-table did not grow in size these
tombstones were never cleaned up, only reused for new entries.

For a general purpose hash-table this is a problematic strategy
because there are workloads where this significantly slows down any
attempted lookup or deletion for elements that are not contained in
the hash-table. This happens when new elements are added and deleted
regularly for a long time without the size of the hash-table changing.
Even if the hash-table is never filled above a small fraction of its
size, tombstones will eventually accumulate which an unsuccessfull
search for an element will have to skip over.

In the new implementation, we don't use any tombstones at all but
instead shift elements into more optimal buckets.

In the case where the hash-table in the old approach was free of
tombstones, the new approach is a little slower for the process of
deleting from highly occupied hash-tables itself but inserting into a
hash-table is a little bit faster on the other hand.
2022-02-19 16:02:57 +01:00
Daniel Kochmański
2307259fcd clos: sort-applicable-methods: be specific regarding arguments
The function SORT-APPLICABLE-METHODS accepts as the third argument called
ARGS-SPECIALIZERS however this function assumed that the argument was a list
of argument's classes (i.e not EQL specializers) - see COMPARE-SPECIALIZERS.
This commit doesn't change the function signature but conses a new list that
is ensured to be a list of classes and passes them to COMPARE-METHODS.

(Local) functions COMPARE-METHODS, COMPARE-SPECIALIZERS-LISTS and
COMPARE-SPECIALIZERS have the argument name changed to reflect their true
expectations.

The function COMPARE-SPECIALIZERS takes the CLASS-PRECEDENCE-LIST of the class
of the argument to break ties when there is no direct relationship between
method specializers.
2022-02-05 16:21:23 +01:00
Daniel Kochmański
f37fe9533c clos: compute-applicable-methods: small refactor
Pull a function APPLICABLE-METHOD-LIST into its sole consumer
STD-COMPUTE-APPLICABLE-METHODS.
2022-02-05 16:21:23 +01:00
Daniel Kochmański
86e71d7eb9 clos: add a reference implementation of the legacy discriminator
This implementation is included for the reference and benchmarks.
2022-02-05 16:21:23 +01:00
Daniel Kochmański
74c08fa072 clos: c-a-m-using-classes: don't give up eagerly on EQL specializer
Previously a local function APPLICABLE-METHOD-P returned (values nil nil) when
it found an EQL-specializer where the object was of a matching class. This is
premature because some later specializer may make the method not applicable
based on one of the argument classes, so there is no need to resort to
COMPUTE-APPLICABLE-METHODS in such case.
2022-02-05 16:20:13 +01:00
Daniel Kochmański
9ff049c969 clos: rewrite compute-g-f-spec-list
Previously this function stored a list of elements

  (cons list-or-random-atom argument-position)

ARGUMENT-POSITION was preasumbly stored because authors anticipated denoting
unspecialized arguments, however all positions were always filled because
unspecializer argument had non-nil specializer #<BUILTIN-CLASS T>.

LIST-OR-RANDOM-ATOM contained either a list of EQL specializers or a random
specializer from all method specializers. The second value was not clear.

This change simplifies the code and the interface, we additionally maintain
additional information. From now on the list stores elements:

  (cons class-specializer-p eql-specializers)

CLASS-SPECIALIZER-P is either NIL or T denoting whether the generic function
has a method specialized on this argument on a class other than T.

EQL-SPECIALIZERS without change, is a list of all EQL specializers.
2022-02-05 16:10:33 +01:00
Daniel Kochmański
84200fd315 clos: rework slightly the dispatch mechanism
- improve set-generic-function-dispatch comments
- add a new file that contains "lisp-defined" dispatchers
- remove unused code
2022-02-05 15:03:52 +01:00
Daniel Kochmański
5cb67471fd clos: finalize-inheritance conformance fix
According to "Reinitialization of Class Metaobjects" reinitialize-instance
must call finalize-inheritance if the class was already finalized.
2022-02-05 15:03:52 +01:00
Daniel Kochmański
2d5da9e8bf clos: add a missing method finalize-inheritance for forward classes
MOP specifies that FINALIZE-INHERITANCE should have a method specialized on
the FORWARD-REFERENCED-CLASS that signals an error.
2022-02-05 15:03:52 +01:00
Daniel Kochmański
acc5162680 clos: add-method: call add-direct-method for specializers
Previously we didn't call it due to bootstrapping issues, but now we convert
functions to methods after early methods are fixed up and their classes are
also updated, so we can. This fix improves conformance.
2022-02-05 15:03:52 +01:00
Daniel Kochmański
653cba539f clos: various bootstrap improvements
The most notable change applies to the file fixup.lsp. Functions destined to
be generic are converted to their final version.

Previously this conversion was done in a few steps in order to avoid issues
with infinite recursion in dispatch. We achieve this by assigning to these new
generic function a simplified discriminating function:

    (lamda (&rest args)
      (unless (or (null *clos-booted*)
                  (specializers-match-p args specializers))
        (apply #'no-applicable-method generic-function args))
      (apply old-function args))

The old function is also seeded as a primary method for the generic
function. This works correctly because functions have only one method so we
may directly call it (it is also a fine optimization strategy we do not
incorporate generally yet), and because the discriminating function will be
recomputed when other methods are added etc.

This way we may use these generic functions without issues directly with newly
redefined versions and the file is now ordered as follows:

- fixup early methods
- redefine functions to their final version
- convert functions to generics
- define missing methods
- implement the dependant maintenance protocol

After this file is loaded it is possible to use generic functions as usual.
2022-02-05 15:03:52 +01:00
Daniel Kochmański
ea92cba4ce defstruct: fix incorrect compatibility checks
Previously we've checked whether the new defstruct is compatible with the old
one like this:

(let ((old-desc (old-descriptions struct)))
  (when (and old-desc (null (compat old-desc new-desc)))
    (error "incompatible")))

This was to allow new definitions. This is incorrect, because allows first
defining a structure without slots and then adding some, like

(defstruct foo)
(defstruct foo xxx)

The new check verifies whether the structure is a structure and then compares
slot, so the verification is not inhibited when the first definition doesn't
have slots.

Moreover we now test for slot names being string= because:
a) initargs and functions ignore the package (so functions will be redefined)
b) we want to match gensymed slot names
This is compatible with what sbcl does.

On top of that check for duplicated names and signal an error if there are
such.
2022-02-05 15:03:22 +01:00
Daniel Kochmański
cc27aadf5f clos: ensure correct class stamps
- we did not distinguish between classes that had no slots and classes that
  had no been iniutialized - that led to incorrect class stamps

- structures had no initial class stamp matching their structure

- structures when slot names chagned had their stamp increased despite not
  really changing
2022-02-04 21:31:53 +01:00
Daniel Kochmański
52bfba7a31 cosmetic: remove unused variable 2022-02-04 21:31:53 +01:00
Daniel Kochmański
0782658ea5 tests: cosmetic: muffle excessive compiler output
cmp.0090.funcall/apply-inline-and-number-of-arguments called compile on a
lambda that caused a call to cmperr - that made the console log when testing
cluttered.
2022-02-04 21:28:44 +01:00
Daniel Kochmański
19112f0c95 Merge branch 'branch-cuts' into 'develop'
numbers: be consistent with branch cuts and signed zero

Closes #661

See merge request embeddable-common-lisp/ecl!266
2022-02-04 20:09:05 +00:00
Marius Gerbershagen
8f51683516 printer: don't pretty print stuff in _ecl_write_list
The pretty printer should handle this and we should not pretty print
objects if *pretty-print* is false.

Closes #673.
2022-01-31 21:05:27 +01:00
Marius Gerbershagen
f873e8e653 cmp: check number of arguments when inlining funcall or apply of lambda expression
Closes #672.
2022-01-29 20:21:00 +01:00
Marius Gerbershagen
1c989247c1 bytecmp: use load time forms when needed in the case macro
Closes #669.
2022-01-23 10:37:06 +01:00
Marius Gerbershagen
f3d4cf4b66 cmp: fix specification of integer suffixes for the C compiler
Fixes #667.
2022-01-15 18:11:26 +01:00
Marius Gerbershagen
8da3475b02 numbers: be consistent with branch cuts and signed zero
Let the sign of zero determine from which side branch cuts are
approached, no matter whether we use C99 complex numbers or not.

Disable the (acosh -∞) test. This test fails with the new code, but
was supposed to be commented out anyway. In general, we don't
guarantee anything about infinity if complex numbers are involved.

Closes #661.
2022-01-09 15:01:04 +01:00
Marius Gerbershagen
ef94137e3d Merge branch 'fix-various' into 'develop'
restart-case: conformance fix: more precise keyword parsing

Closes #666

See merge request embeddable-common-lisp/ecl!265
2022-01-06 14:09:48 +00:00
Marius Gerbershagen
015cc15c08 Merge branch 'semaphore-timeout' into 'develop'
mp: semaphores: add a new function semaphore-wait

See merge request embeddable-common-lisp/ecl!260
2022-01-06 14:06:59 +00:00
Daniel Kochmański
e82d002f90 restart-case: conformance fix: more precise keyword parsing
- don't assume that any keyword is an option
- don't process the same keyword twice

New behavior could be summarized in these two cases:

(restart-case t
  (retry ()
    :retired ; <- form
))

(restart-case t
  (retry ()
    :report report  ; <- expression
    :report "foo"   ; <- form
    :test test      ; <- form
))

Fixes #666.
2022-01-06 09:51:40 +01:00
Daniel Kochmański
0660996c37 mp: semaphores: add tests and the documentation
Functions wait-on-semaphore and try-get-semaphore are deprecated in
favour of the new function.
2022-01-06 09:32:49 +01:00
Daniel Kochmański
bf62cd9d40 mp: semaphores: add a new function semaphore-wait
This function offers a functionality similar to sbcl, namely allows
specifying the timeout and the resource count.
2021-12-23 12:09:57 +01:00
Daniel Kochmański
e83f278f17 doc: fix typos 2021-12-23 10:42:59 +01:00
Daniel Kochmański
0a5a49ab45 Merge branch 'develop' into 'develop'
msvc: set HAVE_WCHAR_H in config.h

See merge request embeddable-common-lisp/ecl!263
2021-12-23 09:39:44 +00:00
Yuguo Zhang
6b0f6faa55 msvc: set HAVE_WCHAR_H in config.h 2021-12-23 09:39:44 +00:00
Daniel Kochmański
8ffe6e8116 Merge branch 'gray-real-column' into 'develop'
Allow real-valued columns in various Gray stream methods

See merge request embeddable-common-lisp/ecl!264
2021-12-23 09:38:51 +00:00