Commit graph

49 commits

Author SHA1 Message Date
Alex Shinn
3716d99a02 fast-path vector-map on two vectors 2024-11-13 17:42:36 +09:00
Alex Shinn
f1df493c32 Upgrading to Unicode 15.1.0. 2024-05-31 23:57:18 +09:00
Alex Shinn
c200ecb21c
Merge pull request #940 from raviqqe/chore/unwind-on-exit
Unwind on exit
2024-05-26 21:51:17 +09:00
Yota Toyama
0673eae46d Fix 2024-05-26 13:06:58 +09:00
Vasilij Schneidermann
0fd351e0b5 Fix read-bytevector logic 2024-03-18 03:15:39 +01:00
Vasilij Schneidermann
c837c7110f Correct let to let* 2024-03-18 02:48:48 +01:00
Vasilij Schneidermann
1b1e8b311b Correct read-bytevector logic for small reads 2024-03-18 02:06:27 +01:00
Vasilij Schneidermann
d0e6dc7556 Avoid needless allocation in read-bytevector!
This change switches the implementation strategy to basing
read-bytevector on top of read-bytevector! rather than the other way
around.
2024-03-18 01:13:57 +01:00
Yota Toyama
f41a61f748 Fix windows import 2023-10-13 17:21:11 +11:00
Yota Toyama
77dc8c3524 Refactor 2023-10-13 17:19:36 +11:00
Yota Toyama
70e5aa14a3 Unwind before exit 2023-10-13 16:37:43 +11:00
Alex Shinn
1ba5df1fdf Adding missing length<=? (closes #909). 2023-04-02 22:48:51 +09:00
Alexei Lozovsky
266a188ce2
More tests for unaligned bytevector access
Make sure that we don't miss anything and cover the rest of bytevector
accessors with tests for unaligned memory access. Include both integers
and floats, in little and big endian flavors.
2020-11-30 17:15:57 +09:00
Alexei Lozovsky
af60b8d937
Fix unaligned access in bytevector-{u,s}{16,32,64}-{ref,set!}
Native code implementing bytevector accessors uses the following access
pattern:

    *(intNN_t*)(base+offset)

This can result in so called "unaligned memory access" if the offset is
not a multiple of 2, 4, 8, or if the base address has not been allocated
at an aligned address (unlikely).

Most popular modern architectures--x86 and ARMs--allow unaligned memory
accesses on the instruction level but they are typically performed a bit
slower than properly aligned accesses.

On the other hand, there are architectures which do not allow unaligned
memory accesses. Each load or store of a value longer than 1 byte should
use properly aligned address on those architectures. That is, u16 should
be loaded from even addresses, s32 should only be stored at an address
which is a multiple of 4, and f64 (aka double) can be located only at
addresses which are multiple of 8. If the address is not aligned, CPU
raises an exception which typically results in the process being killed
by the operating system with a SIGBUS signal.

SPARC is one of those architectures which are strict with alignment. The
current access pattern in bytevector native code can result in unaligned
accesses, which in turn results in crashes. This issue has been found in
this way: Chibi test suite includes some tests for unaligned accesses
and it failed on SPARC.

In order to avoid unaligned accesses, loads and stores need to be
performed a bit differently, doing 'type punning' in a safe way, not
just casting pointers which breaks strict aliasing rules.

The most portable and efficient way to do this is to use memcpy().
Compilers know about this trick and generate very efficient code here,
avoiding the function call and using the most efficient instructions.
(Obviously, only when optimizations are enabled.)

That is, given

    static inline uint32_t ref_u32(const void* p) {
      uint32_t v;
      memcpy(&v, p, sizeof(v));
      return v;
    }

on x86 this will be compiled into a single "movl" instruction because
x86 allows unaligned accesses, similar with ARM where this becomes
a single "ldr" instruction. However, on RISC-V--another platform with
strict alignment rules--this code compiles into 4 "lbu" instructions
fetching 4 bytes, then some more arithmetic to stitch those bytes into
a single 32-bit value.
2020-11-30 16:46:44 +09:00
Alex Shinn
23e62275df fixing scheme bytevector for 32bit arch 2020-07-28 15:09:40 +09:00
Alex Shinn
06cef55723 guard should use raise-continuable (issue #661) 2020-06-19 17:48:29 +09:00
Alex Shinn
e8f1233e18 cleaning up test names 2020-06-19 17:37:55 +09:00
Alex Shinn
278bb48b00 error on recursive includes (issue #557) 2020-06-16 11:44:10 +09:00
Alex Shinn
d42d4d5600 replace define-library-alias with define-library + alias-for 2020-06-04 23:55:37 +09:00
Alex Shinn
c245d6cee8 fix case folding, update to unicode 13 2020-06-04 22:08:07 +09:00
Alex Shinn
6caca77426 adding (scheme bytevector) 2020-05-31 23:24:51 +09:00
Alex Shinn
9901a67b20 adding define-library-alias (issue #650) 2020-05-26 22:20:35 +09:00
Alex Shinn
0957b54f51 adding tangerine names for srfi 160 libs 2020-05-26 17:18:50 +09:00
Alex Shinn
11e0328fef adding (srfi 146 hash) 2020-05-26 17:05:07 +09:00
Alex Shinn
f74c34b99b make-promise is idempotent (issue #625) 2020-04-10 17:17:29 +09:00
Nguyễn Thái Ngọc Duy
a3eda041a3 Add Tangerine library names
Chibi supports quite a few SRFIs that have been part of Tangerine
edition. These .sld are the same as their counterpart .sld, except the
rename.
2020-02-20 19:12:03 +07:00
Alex Shinn
58e10b2a7d assert types in boolean=? and symbol=? (fixes issue #579) 2019-10-06 22:29:58 +08:00
Vasilij Schneidermann
ab39f12904 Consider unterminated strings as read-error 2019-05-17 10:55:22 +02:00
Alex Shinn
479efcdc33 don't start thread checking for leap seconds if env var is unspecified 2018-12-28 23:40:55 +08:00
Alex Shinn
eb38a5836a extending (scheme red) 2018-01-24 23:54:09 +09:00
Göran Weinholt
49e9f0e532
Update leap second list 2017-12-24 20:03:37 +01:00
okuoku
e46bd03239 (chibi win32 process-win32): New library
Implement Win32 specific process library. Currently the library only
provides `exit` procedure.
2017-12-13 19:04:04 +09:00
Alex Shinn
8d51cf053c Merge branch 'master' of https://github.com/ashinn/chibi-scheme 2017-11-08 23:00:02 +09:00
Alex Shinn
bc3fa73ec4 adding unambiguous promise? to core 2017-11-08 22:56:02 +09:00
okuoku
735719d9d6 Win32: Port/Stub-out libraries
- (scheme time): Win32 stub impl
 - (chibi filesystem): Win32 stubbing
 - (chibi process): ditto
 - (chibi time): ditto
 - SRFI-144: lgamma is not in C99 standard
 - SRFI-27: Win32 INSECURE rand
2017-11-06 04:10:28 +09:00
Alex Shinn
cc92ecf2bc adding (scheme red) and associated srfi aliases 2017-10-06 23:53:22 +09:00
Alex Shinn
4a7a809c8d distinguishing lowercase and foldcase (fixes issue #420) 2017-08-27 14:10:05 +09:00
Alex Shinn
975dc690a1 renaming centered/ balanced/ 2017-04-01 22:14:29 +09:00
Alex Shinn
6e2013153a updating to Unicode 9 and adding SRFI 129 2017-03-28 23:42:47 +09:00
Alex Shinn
fad7662d83 s/display/write-string 2017-03-26 22:54:21 +09:00
Alex Shinn
30486cb6b6 fixing bug in char-up/downcase bsearch 2017-03-26 22:52:34 +09:00
Alex Shinn
28148e52b7 guard should raise, not raise-continuable, as the default
Fixes issue #346.
2016-06-04 21:49:12 +09:00
Marc Nieper-Wißkirchen
578f205eff Update r5rs.sld
Add missing identifiers from erratum 22 of http://trac.sacrideo.us/wg/wiki/R7RSSmallErrata.
2016-04-07 16:36:19 +02:00
Alex Shinn
1f5d816f59 let[rec]-syntax should not splice 2016-02-22 23:05:12 +09:00
Chris Walsh
2005c19ea0 Added full support for packed images, both for static and dynamic libraries. 2016-02-15 21:12:58 -05:00
Alex Shinn
557b31e1dd allow internal defines in guard 2016-01-20 07:03:41 +09:00
Alex Shinn
a01ca4bad6 Adding (scheme process-context) to (scheme small).
Fixes issue #300.
2016-01-13 21:59:59 +09:00
Alex Shinn
7f7a75d4f5 Exporting syntax-rules from (scheme r5rs). 2015-04-27 11:42:00 +09:00
Alex Shinn
2922ed591d Forgot to install regexp (patch from Lorenzo) 2015-01-26 08:06:59 +09:00