1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

19998 commits

Author SHA1 Message Date
Mark H Weaver
db78033cc1 SRFI-19: Fix handling of negative years and negative julian days.
Fixes <https://bugs.gnu.org/21906>.
Mitigates <https://bugs.gnu.org/21903> and <https://bugs.gnu.org/21904>.
Reported by: Zefram <zefram@fysh.org>.

* module/srfi/srfi-19.scm (encode-julian-day-number)
(decode-julian-day-number, date-week-number): Use 'floor-quotient'
instead of 'quotient', and 'floor' instead of 'truncate', where
appropriate.
(time-utc->date): Ensure that the 'nanoseconds' field of the returned
date is non-negative.
(leap-year): Handle negative years properly, and reformulate the
computation.
(week-day): Handle negative years properly.  Use 'floor-quotient'
instead of 'quotient' where appropriate.
(directives): In the handler for '~Y' format escapes, improve the
handling of years outside of the range 0-9999.
(read-directives): Add a FIXME comment to fix the '~Y' reader to handle
years outside of the range 0-9999.
* test-suite/tests/srfi-19.test: Import (srfi srfi-1).  Use Guile's
modern keyword notation in the 'define-module' form.  Add more tests.
2019-05-23 17:13:05 +02:00
Mark H Weaver
e00563492a SRFI-19: Fix TAI->UTC conversions, leap second handling, etc.
Fixes <https://bugs.gnu.org/21911>.
Fixes <https://bugs.gnu.org/22034>.
Fixes <https://bugs.gnu.org/21902>.
Partially fixes <https://bugs.gnu.org/21904>.
Reported by Zefram <zefram@fysh.org>.

* doc/ref/srfi-modules.texi (SRFI-19 Introduction): Fix the definitions
of Julian Day and Modified Julian Day.  Give the correct full names of
UTC and TAI.
* module/srfi/srfi-19.scm: Import (srfi srfi-1).  Use modern Guile
keyword syntax in the 'define-module' form.
(leap-second-neg-delta): New procedure, derived from a similar procedure
in the latest upstream SRFI-19 reference implementation.
(priv:time-tai->time-utc!, time-tai->julian-day)
(time-monotonic->julian-day): Use 'leap-second-neg-delta'.
(local-tz-offset): Fix comment.
(leap-second?): Remove.
(tai-before-leap-second?): New procedure, derived from upstream SRFI-19.
(time-utc->date): Use 'define*' to handle the optional argument.  Remove
the leap second handling, following upstream SRFI-19.
(time-tai->date): Rewrite in terms of 'time-utc->date'.  Add special
leap second handling, following upstream SRFI-19.
(time-monotonic->date): Rewrite in terms of 'time-tai->date'.
(date->time-tai, date->time-monotonic): Add special leap second
handling, following upstream SRFI-19.
(directives): In the entry for the "~Y" escape in 'date->string', pad
the year field to 4 characters, following upstream SRFI-19.
* test-suite/tests/srfi-19.test: Add tests.
2019-05-23 17:13:03 +02:00
Mark H Weaver
4e24cca595 scm_seed_to_random_state: Support wide string arguments.
Partially fixes <https://bugs.gnu.org/33044>.
Reported by Tom de Vries <tdevries@suse.de>.

* libguile/random.c (scm_seed_to_random_state): Use 'scm_to_utf8_string'
(or 'scm_to_latin1_string' for a narrow string, for compatibility) to
convert the string into raw bytes for use by 'scm_c_make_rstate'.  Make
sure the length in bytes fits within an 'int'.
2019-05-23 17:11:40 +02:00
Mark H Weaver
dcf8389a5a Fix typo in strings.h.
* libguile/strings.h: In a comment, add the missing "i_" in
"scm_i_is_narrow_string".
2019-05-23 17:11:31 +02:00
Mark H Weaver
0e750990dd Add tests for type inferencing for 'nil?' and 'null?' predicates.
These tests come from a fix for <https://bugs.gnu.org/33036>, which was
fixed already in the 2.9.x branch.

* test-suite/tests/compiler.test: Add tests.
2019-05-23 16:59:54 +02:00
Mark H Weaver
3ae69f3063 Use 'scm_from_utf8_{string,symbol,keyword}' for C string literals.
Partial fix for <https://bugs.gnu.org/33044>.
Reported by Tom de Vries <tdevries@suse.de>.

Fix several instances of the mistake of using 'scm_from_locale_*' for C
strings that originally came from a C string literal.  Change several
uses of 'scm_from_latin1_*' as well, to promote the practice of writing
code that works for arbitrary C string literals.

Also add missing years to the copyright notices of changed files, based
on the git history.

* libguile/debug-malloc.c, libguile/deprecation.c, libguile/error.c,
libguile/eval.c, libguile/expand.c, libguile/extensions.c,
libguile/filesys.c, libguile/init.c, libguile/load.c,
libguile/modules.c, libguile/pairs.c, libguile/posix.c,
libguile/print.c, libguile/random.c, libguile/read.c,
libguile/regex-posix.c, libguile/snarf.h, libguile/srfi-13.c,
libguile/stacks.c, libguile/stime.c, libguile/strports.c,
libguile/values.c: Use 'scm_from_utf8_*' where appropriate.
2019-05-23 16:41:53 +02:00
Mark H Weaver
a47a5e6828 Fix typos, indentation and error reporting in SRFI-19.
* module/srfi/srfi-19.scm: Fix typos in comments, indentation, and pass
the correct 'caller' name to 'time-error' in several places.
2019-05-23 16:09:53 +02:00
Mark H Weaver
d61da427e1 Update SRFI-19 leap second table.
* module/srfi/srfi-19.scm (leap-second-table): Update to include the
leap second on 1 January 2017.
2019-05-23 16:09:51 +02:00
Chris Marusich
3c87313628 Clarify the manual's "Processes" section.
* doc/ref/posix.texi (Processes): Use the phrase "integer status value"
consistently, and add a cross-reference to the section of the glibc
manual that explains what it is.
2019-05-23 16:09:49 +02:00
Mark H Weaver
00973cbd2e In 'ash' and 'round-ash', handle right shift count of LONG_MIN.
Fixes <https://bugs.gnu.org/21901>.
Reported by Zefram <zefram@fysh.org>.

* libguile/numbers.c: Add another top-level 'verify' to ensure that
LONG_MIN is not a fixnum.
(scm_ash, scm_round_ash): Ensure that when the shift count is LONG_MIN,
it is not handled via the normal code path, to avoid signed overflow
when the shift count is negated.
* test-suite/tests/numbers.test: Add tests.
2019-05-23 16:09:45 +02:00
Mark H Weaver
e6100f64bb Fix 'round-ash' of negative integers by huge right shift counts.
This is a followup to commit 011aec7e24.

When rounding, right shifting a negative integer by a huge shift count
results in 0, not -1.

* libguile/numbers.c: Add top-level 'verify' to ensure that the
assumptions in 'scm_ash' and 'scm_round_ash' are valid.
(scm_round_ash): In the case that handles huge right shifts, require
that the shift count _exceeds_ the integer length, and return 0 instead
of -1.
* test-suite/tests/numbers.test: Adjust tests accordingly.
2019-05-23 16:09:41 +02:00
Mark H Weaver
e4c5f73f94 Gracefully handle huge shift counts in 'ash' and 'round-ash'.
Fixes <https://bugs.gnu.org/32644>.
Reported by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.

The need for this arose because the type inferrer for 'ursh' sometimes
passes (- 1 (expt 2 64)) as the second argument to 'ash'.

* libguile/numbers.c (scm_ash, scm_round_ash): Gracefully handle several
cases where the shift count does not fit in a C 'long'.
* test-suite/tests/numbers.test: Add tests.
2019-05-23 16:08:12 +02:00
Mark H Weaver
5dcad70d99 Fix list validation of *list->bytevector procedures.
Fixes <https://bugs.gnu.org/32938>.
Reported by Josh Datko <jbd@cryptotronix.com>.

* libguile/validate.h (SCM_VALIDATE_LIST_COPYLEN)
(SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Use '!=' instead of '>=' to
validate the result of 'scm_ilength' after it has been stored in
the user variable 'cvar'.
* test-suite/tests/bytevectors.test: Add tests.  Use '#:use-module'
instead of ':use-module' in 'define-module' form.
2019-05-23 16:01:13 +02:00
Mark H Weaver
0c0a658c56 Improve the documentation for 'nil?'.
* libguile/boolean.c (scm_nil_p): Improve docstring.
* doc/ref/api-languages.texi (Nil): Add documentation for 'nil?', along
with a description of how Elisp interprets Scheme booleans and
end-of-list.
2019-05-23 15:53:55 +02:00
Daniel Llorens
e4da1b456a Fix 32/64 bit bug in INTEGER_ACCESSOR_PROLOGUE 2019-05-23 15:53:28 +02:00
Mark H Weaver
f65ccc6afe Fix 'atomic-box-compare-and-swap!'.
Fixes <https://bugs.gnu.org/32786>.

'scm_atomic_compare_and_swap_scm' is a thin wrapper around
'atomic_compare_exchange_weak' (where available), and therefore it may
spuriously fail on some platforms, leaving the atomic object unchanged
even when the observed value is equal to the expected value.  Since
'scm_atomic_compare_and_swap_scm' returns both a boolean result and the
observed value, the caller is able to detect spurious failures when
using that API.

'atomic-box-compare-and-swap!' presents a simpler API, returning only
the observed value.  The documentation advises callers to assume that
the exchange succeeded if the observed value is 'eq?' to the expected
value.  It's therefore not possible to report spurious failures with
this API.

'atomic-box-compare-and-swap!' uses 'scm_atomic_compare_and_swap_scm',
and prior to this commit would simply ignore the boolean result and
return the observed value.  In case of spurious failures, the caller
would legitimately conclude that the exchange had succeeded.

With this commit, 'atomic-box-compare-and-swap!' now retries in case of
spurious failures.

* libguile/atomic.c (scm_atomic_box_compare_and_swap_x): If
'scm_atomic_compare_and_swap_scm' returns false and the observed value
is equal to 'expected', then try again.
* libguile/intrinsics.c (atomic_compare_and_swap_scm): Ditto.
2019-05-23 15:52:32 +02:00
Ludovic Courtès
827e88b4b7 Define AT_SYMLINK_NOFOLLOW et al.
* libguile/posix.c (scm_init_posix): Define AT_SYMLINK_NOFOLLOW,
AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, and AT_EMPTY_PATH when available.
(scm_utime): Mention AT_SYMLINK_NOFOLLOW.
* doc/ref/posix.texi (File System): Update accordingly.
* test-suite/tests/posix.test ("utime")["AT_SYMLINK_NOFOLLOW"]: New test.
2019-05-23 15:43:28 +02:00
Ludovic Courtès
176bfd0bce time: Use #: for 'define-module' clauses.
* module/ice-9/time.scm: Use #: instead of : in 'define-module' form.
2019-05-23 15:41:32 +02:00
Ludovic Courtès
24f45332b0 time: Support expressions that return any number of values.
* module/ice-9/time.scm (time-proc): Call PROC with 'call-with-values';
return all its values.
2019-05-23 15:41:29 +02:00
Ludovic Courtès
53c3d27bfc time: Use 'syntax-rules' instead of 'define-macro'.
* module/ice-9/time.scm (time): Rewrite using 'define-syntax-rule'.
2019-05-23 15:41:27 +02:00
Andy Wingo
63de1893c3 Merge remote-tracking branch 'lightening/master' 2019-05-23 10:04:52 +02:00
Andy Wingo
7c73f5f949 Add includable automake file 2019-05-23 10:02:00 +02:00
Andy Wingo
9ffda1ce61 Update NEWS
* NEWS: Add 2.9.2 information.
2019-05-23 09:34:54 +02:00
Andy Wingo
e9e52b6ab9 Mark a couple functions as maybe-unused.
* libguile/jit.c (fp_scm_operand, sp_slot_operand): Maybe unused.
2019-05-23 09:34:08 +02:00
Andy Wingo
be8ac3589e Merge remote-tracking branch 'lightening/master' 2019-05-22 23:05:06 +02:00
Andy Wingo
ff6ab1d2b1 Silence "unused" warnings 2019-05-22 23:04:30 +02:00
Andy Wingo
5c700ae832 Enable JIT on aarch64 and armv7
* acinclude.m4 (GUILE_ENABLE_JIT): For MIPS, PPC, sparc, ia64, hppa,
  s390, and alpha: mark JIT as unavailable.  Only architectures left are
  x86-64, i686, aarch64, and armv7.  If JIT is available, enable it by
  default; previously only x86-64 and i686 were supported.
2019-05-22 17:36:02 +02:00
Andy Wingo
3b707bb43d Merge remote-tracking branch 'lightening/master' 2019-05-22 17:30:25 +02:00
Andy Wingo
0b3393415e Allow add_pending_literal to return false
This avoids invalidating offsets for the reloc.
2019-05-22 17:29:10 +02:00
Andy Wingo
9b4870cad3 Merge remote-tracking branch 'lightening/master' 2019-05-21 16:06:11 +02:00
Andy Wingo
b67c4ed1e1 Avoid recursive pool emit for aarch64; add another overflow check 2019-05-21 16:05:03 +02:00
Andy Wingo
ec9fa9561b Merge remote-tracking branch 'lightening/master' 2019-05-21 15:35:15 +02:00
Andy Wingo
33754ba8c7 AArch64 fix 2019-05-21 15:34:40 +02:00
Andy Wingo
7bc95fde98 Merge remote-tracking branch 'lightening/master' 2019-05-21 15:30:56 +02:00
Andy Wingo
b7f367165f Various fixes for as-needed emission of literal pool 2019-05-21 15:25:08 +02:00
Andy Wingo
12e0063022 Merge remote-tracking branch 'lightening/master' 2019-05-21 14:21:42 +02:00
Andy Wingo
568fdecc86 Fix literal pool emission on armv7 2019-05-21 14:19:48 +02:00
Andy Wingo
da0cc5d3e6 Bless enter_mcode as a function pointer
* libguile/jit.c (initialize_jit): Bless enter_mcode, to allow ARMv7
  interworking.
2019-05-21 14:02:27 +02:00
Andy Wingo
2feb4cf419 Merge remote-tracking branch 'lightening/master' 2019-05-21 14:00:55 +02:00
Andy Wingo
0518651bfd Expose API to bless function pointers
On ARMv7, we need to set the low bit to indicate that we're in
thumb-land.
2019-05-21 14:00:04 +02:00
Andy Wingo
e00936d46b Allow jit_end to fail
* libguile/jit.c (emit_code): Emitting a constant table might cause us
  to fail.
2019-05-21 13:36:37 +02:00
Andy Wingo
2876f054e8 Merge remote-tracking branch 'lightening/master' 2019-05-21 12:44:23 +02:00
Andy Wingo
ef7abb568a Fix typo in previous commit, doh 2019-05-21 12:44:00 +02:00
Andy Wingo
107926f8dd Fix allocator passed to lightening
* libguile/jit.c (jit_alloc_fn): On targets that need a dynamically
  allocated literal pool, we will need to trace that pool, so pass a
  pointerful malloc.  Fixes JIT on AArch64.
2019-05-21 12:39:55 +02:00
Andy Wingo
a4875baa4e Merge remote-tracking branch 'lightening/master' 2019-05-21 12:39:34 +02:00
Andy Wingo
d2c15dd6cd Clear literal pool more thoroughly 2019-05-21 12:38:53 +02:00
Andy Wingo
03ceca9a2b Merge remote-tracking branch 'lightening/master' 2019-05-21 12:25:14 +02:00
Andy Wingo
723f70ee11 Clear missing bit from literal pool 2019-05-21 12:24:20 +02:00
Andy Wingo
f81f43591f Merge remote-tracking branch 'lightening/master' 2019-05-21 12:14:50 +02:00
Andy Wingo
f49752eac0 Avoid using x18 on AArch64 2019-05-21 12:02:40 +02:00