Commit graph

3509 commits

Author SHA1 Message Date
Alex Shinn
9f0ed1a869
Revert "Implement SRFI 193: Command lines" 2021-01-24 19:57:55 +09:00
Alex Shinn
751675c6b2
Merge pull request #619 from lassik/command-lines
Implement SRFI 193: Command lines
2021-01-24 16:44:35 +09:00
Alex Shinn
e53d79adfd
Merge pull request #723 from lassik/typo
Fix typo
2021-01-18 09:44:53 +09:00
Lassi Kortela
0be78ed7e6 Fix typo 2021-01-17 14:10:41 +02:00
Alex Shinn
1828ef068e fix env size (issue #453) 2020-12-28 12:07:54 +09:00
Alex Shinn
b4dd757e3f more consistently setting renames (issue #453) 2020-12-28 11:55:10 +09:00
Alex Shinn
4edf3344f8
Merge pull request #721 from ilammy/aliasing-issues
Fix unaligned access in bytevector-{u,s}{16,32,64}-{ref,set!}
2020-11-30 20:11:54 +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
3f228ce731
Merge pull request #716 from amirouche/fix/emscripten-build
Makefile: js: fix build for emscripten 2.0.8.
2020-11-30 13:51:43 +09:00
Alex Shinn
a3afe4e804 don't change dir when generating images (issue #707) 2020-11-25 23:26:18 +09:00
Alex Shinn
56a31f9cb0 don't declare image loading operations if not enabled (issue #714) 2020-11-25 23:16:12 +09:00
Alex Shinn
f9c00e0c21
Merge pull request #713 from mnieper/and-let
Fix and-let* so that it allows bodies according to SRFI 2.
2020-11-25 14:40:16 +09:00
Alex Shinn
0597ea68a5
save a char and a beta reduction 2020-11-25 14:39:49 +09:00
Alex Shinn
54f55569e2 document sexp_lookup_type (issue #718) 2020-11-25 14:36:54 +09:00
Alex Shinn
79e76b295f Merge branch 'master' of github.com:ashinn/chibi-scheme 2020-11-19 13:14:17 +09:00
Alex Shinn
181b7fe7e4 preserve exactness in sqrt of ratios where possible 2020-11-19 13:13:37 +09:00
Alex Shinn
841a8a3167
Merge pull request #717 from bjoli/patch-1
Fix bug in accumulating in (chibi loop)
2020-11-04 21:12:42 +09:00
Linus Björnstam
c896bf90c5
Fix bug in accumulating in (chibi loop)
Accumulating has a bug that makes only lists supported, due to it ignoring the init value and always use the empty list. This fixes that.
2020-11-04 11:56:41 +01:00
Amirouche
f13c826da0 Makefile: js: fix build for emscripten 2.0.8.
$ emcc --version
emcc (Emscripten gcc/clang-like replacement) 2.0.8 (d059fd603d0b45b584f634dc2365bc9e9a6ec1dd)
2020-11-02 11:20:35 +01:00
Marc Nieper-Wißkirchen
306dbd470a Fix and-let* so that it allows bodies according to SRFI 2. 2020-10-22 15:13:04 +02:00
Alex Shinn
12636f4b19
Merge pull request #711 from woodfinisc/patch-1
Fix a typo in README.md
2020-10-17 06:57:39 +09:00
Alex Shinn
b6186d1272
Merge pull request #710 from gahr/freebsd-versioned-so
Produce a versioned so on FreeBSD
2020-10-17 06:41:17 +09:00
Tom Woodfin
0f5f9e3117
Fix a typo in README.md
seemless => seamless
2020-10-16 15:09:29 -04:00
Pietro Cerutti
f48312fad3 Produce a versioned so on FreeBSD 2020-10-16 13:10:58 +00:00
Alex Shinn
30b575debe
Merge pull request #709 from gahr/doc-depends-on-so
Building docs depends on having the shared libraries available
2020-10-14 22:10:09 +09:00
Pietro Cerutti
f85c1a3545 Building docs depends on having the shared libraries available
This unbreaks compiling with multiple make jobs.
2020-10-14 10:06:56 +00:00
Alex Shinn
568206041a Merge branch 'master' of github.com:ashinn/chibi-scheme 2020-10-11 21:31:57 +09:00
Alex Shinn
4e1ff91cbb patch for plan9 build from raingloom 2020-10-11 21:31:42 +09:00
Alex Shinn
3334957956
Merge pull request #708 from pclouds/document-getenv
chibi-scheme.1: document CHIBI_IGNORE_SYSTEM_PATH
2020-10-02 23:00:34 +09:00
Nguyễn Thái Ngọc Duy
78e381ae7d chibi-scheme.1: document CHIBI_IGNORE_SYSTEM_PATH
while at there, spell out the empty CHIBI_MODULE_PATH case. It's obvious
if you really think about it, but it's even better if I don't have to
read between the lines.

I did grep getenv to find if anything was missing. There is
CHIBI_MAX_ALLOC, but I think that one is more about debugging
out-of-memory than to be customized by the user.
2020-09-30 16:15:54 +07:00
Alex Shinn
77aab98784 Merge branch 'master' of github.com:ashinn/chibi-scheme 2020-09-22 17:37:33 +09:00
Alex Shinn
4ef6c57d3e propagating #i prefix across radix prefixes (issue #706) 2020-09-22 17:37:22 +09:00
Alex Shinn
7448c22466
Merge pull request #705 from laserswald/fix-arithmetic-exception-filenos
Prevent arithmetic exception when spawning lots of commands
2020-09-19 13:20:39 +09:00
Ben Davenport-Ray
9278222396 Prevent crashing from arithmetic exception when spawning lots of commands
This fix is rather dumb, but it prevents things from crashing when
forking a lot and creating file handles. I assume that this is where
the filehandles go, but I don't have a good guess.
2020-09-18 17:08:25 -04:00
Alex Shinn
993a6469fe fix a ... match pattern when a is already bound 2020-09-06 22:59:42 +09:00
Alex Shinn
9c6020e22d
Merge pull request #702 from pclouds/snow-confirm-before-upload
snow: confirm before uploading packages
2020-09-05 13:21:34 +09:00
Nguyễn Thái Ngọc Duy
f4008c92cf snow: add TODO regarding summary before upload 2020-09-05 09:31:29 +07:00
Nguyễn Thái Ngọc Duy
711c89cd97 snow: confirm before uploading packages
Uploading a package is an irreversible operation. It's not even about
accidentally leaking your secret sauce to the internet. You could upload
a package to snow-fort.org by accident and pullute the package name
space [1].

So let's ask the user first before going ahead uploading stuff. We only
ask once even if we're going to upload a dozen packages, so it's not
that annoying. The target repo is also shown in case you want to upload
to a custom repo and want to make sure it does so.

[1] I did (while attempting to uploading to a local snow-fort instance
    during testing). I guess `(chibi snow commands)` is forever mine
    now.
2020-09-04 19:25:29 +07:00
Alex Shinn
645bf03749 change match names to SRFI 204 2020-09-04 18:33:25 +09:00
Alex Shinn
c82baa3aa9 ignore snow package meta files whose installed files have been removed 2020-09-04 14:04:53 +09:00
Alex Shinn
64ff69e99b include chibi.repl in images 2020-09-03 21:51:04 +09:00
Alex Shinn
d0bd93822e specify encoding meta for docs, include doctype 2020-09-02 15:52:20 +09:00
Alex Shinn
8597c3eda5 better error handling in http-server request parsing 2020-09-02 11:53:49 +09:00
Alex Shinn
24d1f6a8a5 fix not+and combo (issue #701) 2020-09-02 10:01:28 +09:00
Alex Shinn
24b1e5024c
Merge pull request #700 from pclouds/tests-without-chibi-test
make optional-test and diff-test run without (chibi test)
2020-09-01 23:00:19 +09:00
Nguyễn Thái Ngọc Duy
65a1eba878 make optional-test and diff-test run without (chibi test)
Tested with gauche. It's mostly about not importing (chibi test)
unconditionally, and importing (scheme write). And in one case I need to
exclude some tests because gauche catches invalid call forms at compile
time. I'm not sure if that can be caught...
2020-09-01 20:55:03 +07:00
Alex Shinn
e5cf364360 forgot to wrap inline cond-expand defs in begin 2020-09-01 22:27:59 +09:00
Alex Shinn
e7e034dea0 fix previous fix, fk needs to be made cheap, not sk (issue #698) 2020-09-01 17:01:27 +09:00
Alex Shinn
717aeb9e8b fix combinatorial explosion in match-not (issue #698) 2020-09-01 16:38:42 +09:00