Re: [PATCH] fix setting of current source file context
> Hi, > > I tried the patch but get an error during compile: > > %%% > > cat chicken-defaults.h >>chicken-config.h > gcc -fno-strict-aliasing -fwrapv -fno-common -DHAVE_CHICKEN_CONFIG_H > -DC_ENABLE_PTABLES -c -Os -fomit-frame-pointer -DC_BUILDING_LIBCHICKEN > library.c -o library-static.o -I. -I./ > chicken eval.scm -optimize-level 2 -include-path . -include-path ./ -inline > -ignore-repository -feature chicken-bootstrap -no-warnings -specialize > -consult-types-file ./types.db -explicit-use -no-trace -output-file eval.c \ > -emit-import-library chicken.eval \ > -emit-import-library chicken.load > > Error: invalid argument type in specialization > (or fixnum char boolean eof bwp null undefined) > ((pair (or fixnum char boolean eof bwp null undefined)) (##sys#setislot #(1) > (quote 0) #(2))) > scheme#set-car! > > Call history: > > (##core#begin (##core#require modules)) > (##core#require modules) > (##core#callunit modules) <-- > make: *** [eval.c] Error 70 This looks like a bootstrapping issue. You may need a newer "chicken" to build from the git sources (see also the bootstrap.sh script in the "scripts" directory. felix
Re: [PATCH] Apply caretize only to the echoed line (5.4.0rc1 / mingw-msys)
> > Hi, > > I was unable to build eggs with chicken scheme 5.4.0rc1 on windows > (mingw-msys). egg-info files were empty. > > I noticed that ">>" was changed to "^>^>" in the code so nothing was > written to egg-info files. > Thanks! Attached a signed-off copy. felix From f6abff5dff027bad4b11fa8bf4e0bb765b755863 Mon Sep 17 00:00:00 2001 From: Jani Hakala Date: Tue, 4 Jun 2024 11:19:08 +0300 Subject: [PATCH] Apply caretize only to the echoed line Signed-off-by: felix --- egg-compile.scm | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/egg-compile.scm b/egg-compile.scm index dd7c429e..7d4c463e 100644 --- a/egg-compile.scm +++ b/egg-compile.scm @@ -1185,14 +1185,16 @@ copy /y nul ~a~a~% ~a EOF mkdir ddir qdir - ddir dest - (string-intersperse (map (lambda (line) - (ensure-line-limit - (caretize (format "echo ~a >>~a~a" - line ddir dest)) - 8191 )) - (string-split infostr "\n")) - "\n")) + ddir dest + (string-intersperse (map (lambda (line) + (ensure-line-limit +(format "echo ~a >>~a~a" +(caretize line) +ddir +dest) +8191)) +(string-split infostr "\n")) + "\n")) ;;; some utilities for mangling + quoting -- 2.42.0
[PATCH] fix setting of current source file context
This patch addresses the problem reported by Christian Himpe weith "include-relative". The patch also adds tests for the problem that was addressed earlier with relative includes. felix From f8c34b36dc365e40de77dd5f9d8265898d9b62b8 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 4 Jun 2024 12:12:48 +0200 Subject: [PATCH] Ensure current source filename is set correctly ##sys#current-source-filename must be set during read-time (to update line-info) and during expansion time (so include-relative works). But body-canonicalization still requires the old context or included let bodies will incorrectly refer to the new one. --- core.scm | 23 --- eval.scm | 21 +++-- tests/runtests.sh | 9 + 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/core.scm b/core.scm index 2e2fa3ed..0a9b301e 100644 --- a/core.scm +++ b/core.scm @@ -989,17 +989,18 @@ bs) ) ) ) ) ((##core#include) - (##sys#include-forms-from-file -(cadr x) -(caddr x) -(lambda (forms) - (walk (if (pair? (cdddr x)) ; body? -(canonicalize-body/ln - ln - (append forms (cadddr x)) - compiler-syntax-enabled) -`(##core#begin ,@forms)) -e dest ldest h ln tl? + (##sys#include-forms-from-file + (cadr x) + (caddr x) + (lambda (forms path) +(let ((code (if (pair? (cdddr x)) ; body? +(canonicalize-body/ln + ln + (append forms (cadddr x)) + compiler-syntax-enabled) +`(##core#begin ,@forms + (fluid-let ((##sys#current-source-filename path)) +(walk code e dest ldest h ln tl?)) ((##core#let-module-alias) (##sys#with-module-aliases diff --git a/eval.scm b/eval.scm index 92244301..b8e59ae5 100644 --- a/eval.scm +++ b/eval.scm @@ -523,7 +523,7 @@ (compile '(##core#undefined) e #f tf cntr #f)) ((##core#let-compiler-syntax) - (compile + (compile (##sys#canonicalize-body (cddr x) (##sys#current-environment) #f) e #f tf cntr #f)) @@ -531,14 +531,14 @@ (##sys#include-forms-from-file (cadr x) (caddr x) - (lambda (forms) -(compile - (if (pair? (cdddr x)) ; body? - (##sys#canonicalize-body - (append forms (cadddr x)) - (##sys#current-environment)) - `(##core#begin ,@forms)) - e #f tf cntr tl? + (lambda (forms path) +(let ((code (if (pair? (cdddr x)) ; body? +(##sys#canonicalize-body + (append forms (cadddr x)) + (##sys#current-environment)) +`(##core#begin ,@forms + (fluid-let ((##sys#current-source-filename path)) +(compile code e #f tf cntr tl?)) ((##core#let-module-alias) (##sys#with-module-aliases @@ -1184,7 +1184,8 @@ (do ((x (read-with-source-info in) (read-with-source-info in)) (xs '() (cons x xs))) ((eof-object? x) - (reverse xs))) + (reverse xs + path))) ;;; Extensions: diff --git a/tests/runtests.sh b/tests/runtests.sh index 185db284..43cd2ada 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -494,6 +494,15 @@ echo '(include-relative "b/ok.scm")' > a/include.scm $compile -analyze-only a/include.scm echo '(include-relative "b/ok.scm")' > a/b/include.scm $compile -analyze-only a/b/include.scm -include-path a +echo > a/b/other.scm +# make sure first include doesn't change state for second: +echo '(include-relative "b/ok.scm") (
Re: [PATCH] Fix compiler warning about zero-sized memset
> Hi all, > > Here's a fix which gets rid of the annoying warning in tcp.c > which Claude Marinier reported: > > gcc -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H > -DC_ENABLE_PTABLES -c -Os -fomit-frame-pointer > -DC_BUILDING_LIBCHICKEN tcp.c -o tcp-static.o -I. -I./ > In function stub398, > inlined from f_1381 at tcp.c:1466:8: > tcp.c:190:1: warning: memset writing 12 bytes into a region of size > 0 overflows the destination [-Wstringop-overflow=] > 190 | memset(addr, 0, sizeof(struct sockaddr_in)); > | ^~~ > > gcc -fno-strict-aliasing -fwrapv -DHAVE_CHICKEN_CONFIG_H > -DC_ENABLE_PTABLES -c -Os -fomit-frame-pointer -fPIC -DPIC > -DC_BUILDING_LIBCHICKEN tcp.c -o tcp.o -I. -I./ > In function stub398, > inlined from f_1381 at tcp.c:1466:8: > tcp.c:190:1: warning: memset writing 12 bytes into a region of size > 0 overflows the destination [-Wstringop-overflow=] > 190 | memset(addr, 0, sizeof(struct sockaddr_in)); > | ^~~ > > NOTE: I've only seen this warning on Debian (with gcc 12.2). > On NixOS, even with GCC 12, it doesn't give this warning. > Pushed - thanks! felix
[PATCH] fix timeout argument type for file-select
As reported by Anton Idukov. Note that the documented and implemented behaviour still works, only the scrutinizer will report a type error without this fix. felix From 59ce16b53cf01eee8ff819b0ceba7d9598b0f700 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Wed, 22 May 2024 13:58:11 +0200 Subject: [PATCH] The optional timeout argument to "file-select" may be a float (Reported by Anton Idukov) --- types.db | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types.db b/types.db index c7c6e2b2..ed2f9628 100644 --- a/types.db +++ b/types.db @@ -1994,7 +1994,7 @@ (chicken.file.posix#file-permissions (#(procedure #:clean #:enforce) chicken.file.posix#file-permissions ((or string fixnum port)) fixnum)) (chicken.file.posix#file-position (#(procedure #:clean #:enforce) chicken.file.posix#file-position ((or port fixnum)) integer)) (chicken.file.posix#file-read (#(procedure #:clean #:enforce) chicken.file.posix#file-read (fixnum fixnum #!optional *) list)) -(chicken.file.posix#file-select (#(procedure #:clean #:enforce) chicken.file.posix#file-select ((or (list-of fixnum) fixnum false) (or (list-of fixnum) fixnum false) #!optional fixnum) * *)) +(chicken.file.posix#file-select (#(procedure #:clean #:enforce) chicken.file.posix#file-select ((or (list-of fixnum) fixnum false) (or (list-of fixnum) fixnum false) #!optional number) * *)) (chicken.file.posix#file-size (#(procedure #:clean #:enforce) chicken.file.posix#file-size ((or string fixnum port)) integer)) (chicken.file.posix#file-stat (#(procedure #:clean #:enforce) chicken.file.posix#file-stat ((or string fixnum port) #!optional *) (vector-of integer))) (chicken.file.posix#file-test-lock (#(procedure #:clean #:enforce) chicken.file.posix#file-test-lock (port #!optional fixnum *) boolean)) -- 2.42.0
Re: Patch for CHICKEN 6 uri-generic
> On Fri, May 24, 2024 at 3:31 AM Peter Bex wrote: > > - It encodes how many bytes to use in the first byte's leading bit, > > > leading three bits, leading four bits or leading five bits depending > > on the length. > > > > This latter property is extra annoying because you can't just extract > > the length from the first byte - you have to scan the first bit to > > decide what to do next. Then, you scan the second and third bit etc. > > > > That's not actually true. You can use a table of 128 entries with one > single-byte entry for each possible value of the first byte, specifyfing > the length of the UTF-8 value. So table entries 0 to 127 have value 1, > etc. Entries that aren't valid UTF-8 leading bytes, such as 255, have 0 in > the table. > See also "C_utf_expect" in utf.c (or "C_utf_bytes_needed" in chicken.h, which can be called via "##core#inline"). felix
Re: Improve "busy" numeric code's performance [was: Re: Big Integers]
> On Wed, May 22, 2024 at 02:42:38PM +0200, Peter Bex wrote: > > Attached are two patches, one which has this bigger improvement, and > > another which is a minor improvement which translates to shaving about > > a second of runtime off your program (at least on my machine). > > The minor patch was incorrect. I copied some code from C_s_a_i_remainder > into C_s_a_i_modulo inline, but that code had an early return for the > case where both numbers are flonums. This code needs to be adjusted to > handle the case when the arguments aren't of the same sign, just like we > do after returning from integer_divrem(). > > I'm sending both patches again for your convenience. The second patch > has a fix for the aforementioned issue. > Appled - thanks! felix
Re: [PATCH] Fix bounds check in substring[-ci]
> Another attempt at fixing #1835, hopefully this time for good. > > Adds a +1 to each paramter string's length, to permit starting to compare at > end of string, and corresponding tests. > > The errors I experienced in csi were caused by a bug in the breadline egg. > Will share a patch with wasamasa. Attached a signed off copy. Thanks! cheers, felix From 4eaa1bc47ba9a28d96e338e552bbb19b30cc5a32 Mon Sep 17 00:00:00 2001 From: siiky Date: Sat, 27 Apr 2024 01:41:18 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20bounds=20check=20in=20substring[-ci]=3D?= =?UTF-8?q?=3F?= It should be permitted to start comparing at the end of a string. Signed-off-by: felix --- data-structures.scm | 8 tests/data-structures-tests.scm | 8 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/data-structures.scm b/data-structures.scm index ad09d26b..1c3f063d 100644 --- a/data-structures.scm +++ b/data-structures.scm @@ -155,8 +155,8 @@ (define (##sys#substring=? s1 s2 start1 start2 n) (##sys#check-string s1 'substring=?) (##sys#check-string s2 'substring=?) - (##sys#check-range start1 0 (##sys#size s1) 'substring=?) - (##sys#check-range start2 0 (##sys#size s2) 'substring=?) + (##sys#check-range start1 0 (fx+ (##sys#size s1) 1) 'substring=?) + (##sys#check-range start2 0 (fx+ (##sys#size s2) 1) 'substring=?) (let* ((maxlen (fxmin (fx- (##sys#size s1) start1) (fx- (##sys#size s2) start2))) (len (if n @@ -170,8 +170,8 @@ (define (##sys#substring-ci=? s1 s2 start1 start2 n) (##sys#check-string s1 'substring-ci=?) (##sys#check-string s2 'substring-ci=?) - (##sys#check-range start1 0 (##sys#size s1) 'substring-ci=?) - (##sys#check-range start2 0 (##sys#size s2) 'substring-ci=?) + (##sys#check-range start1 0 (fx+ (##sys#size s1) 1) 'substring-ci=?) + (##sys#check-range start2 0 (fx+ (##sys#size s2) 1) 'substring-ci=?) (let* ((maxlen (fxmin (fx- (##sys#size s1) start1) (fx- (##sys#size s2) start2))) (len (if n diff --git a/tests/data-structures-tests.scm b/tests/data-structures-tests.scm index eb779531..a81b87b6 100644 --- a/tests/data-structures-tests.scm +++ b/tests/data-structures-tests.scm @@ -46,6 +46,14 @@ (assert (= 2 (substring-index-ci "o\x00bar" "foo\x00BAR"))) (assert (not (substring=? "foo\x00a" "foo\x00b" 1 1))) (assert (not (substring-ci=? "foo\x00a" "foo\x00b" 1 1))) +(assert (substring=? "" "" 0 0 0)) +(assert (substring-ci=? "" "" 0 0 0)) +(assert (substring=? "" "abc")) +(assert (substring-ci=? "" "abc")) +(assert (substring=? "abc" "")) +(assert (substring-ci=? "abc" "")) +(assert-error (substring=? "" "" 0 0 1)) +(assert-error (substring-ci=? "" "" 0 0 1)) (assert (substring=? "foo" "foo" 0 0 3)) (assert (substring-ci=? "foo" "foo" 0 0 3)) (assert (not (substring-index "o\x00bar" "foo\x00baz"))) -- 2.42.0
Re: [PATCH] Update irregex to 0.9.11
> Hi all, > > Here's a patch to bring irregex in line with upstream 0.9.11 (plus one > more commit that fixes a bug in sre->string). It would be nice to have > that for 5.4.0. > > Not that much changed in this release, but a lot of code was > restructured, so it would make it easier to port future changes once > this has been applied. > > Also, there are a few fixes related to utf8-mode, so maybe these help > with the UTF-8 branch. Thanks! Pushed. I will apply this to the utf+r7rs branch shortly. felix
Re: [PATCH] fix off-by-one in substring
> Hi, > > On Mon, 15 Apr 2024 12:50:44 +0200 felix.winkelm...@bevuta.com wrote: > > > This patch addresses #1823, which was caused by an off-by-one error > > in the check of the end-index, which is exclusive. Thanks to "siiky" for > > reporting this. > > Thanks siiky and Felix. I've pushed the patch. Thanks, Mario! > > I think it actually fixes #1835, not #1823, right? At least I tested it > against the utf8 issue and it does fix the problem (I've also been able > to reproduce the problem _without_ the patch). :-) Ugh, sorry, yes. felix
Re: [PATCH] fix off-by-one in substring
> *facepalm* fixed a bug, created another... Ran the utf8 egg's tests, all > passed. > > Thanks felix, and sorry about that. There is no need to be sorry - I had the same situation myself in a different context. Also, R7RS is not very explicit about inclusiveness of bounds (R5RS is, but R7RS moved that bit of information into the introductory section). Finally, tests for exactly this case were missing from the test suite. So, all is well, thank you for your help. felix
[PATCH] fix off-by-one in substring
This patch addresses #1823, which was caused by an off-by-one error in the check of the end-index, which is exclusive. Thanks to "siiky" for reporting this. felix From 8e29a4332873ea4cbb98c8847bd5648033b79ae9 Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 15 Apr 2024 12:48:23 +0200 Subject: [PATCH] =?UTF-8?q?Fixed=20off-by-one-errors=20in=20end-limit=20of?= =?UTF-8?q?=20substring[-ci]=3D=3F?= --- data-structures.scm | 4 ++-- tests/data-structures-tests.scm | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/data-structures.scm b/data-structures.scm index 642d2a59..ad09d26b 100644 --- a/data-structures.scm +++ b/data-structures.scm @@ -160,7 +160,7 @@ (let* ((maxlen (fxmin (fx- (##sys#size s1) start1) (fx- (##sys#size s2) start2))) (len (if n - (begin (##sys#check-range n 0 maxlen 'substring=?) n) + (begin (##sys#check-range n 0 (fx+ maxlen 1) 'substring=?) n) maxlen))) (##core#inline "C_substring_compare" s1 s2 start1 start2 len) ) ) @@ -175,7 +175,7 @@ (let* ((maxlen (fxmin (fx- (##sys#size s1) start1) (fx- (##sys#size s2) start2))) (len (if n - (begin (##sys#check-range n 0 maxlen 'substring-ci=?) n) + (begin (##sys#check-range n 0 (fx+ maxlen 1) 'substring-ci=?) n) maxlen))) (##core#inline "C_substring_compare_case_insensitive" s1 s2 start1 start2 len) ) ) diff --git a/tests/data-structures-tests.scm b/tests/data-structures-tests.scm index 17a3dd58..eb779531 100644 --- a/tests/data-structures-tests.scm +++ b/tests/data-structures-tests.scm @@ -46,6 +46,8 @@ (assert (= 2 (substring-index-ci "o\x00bar" "foo\x00BAR"))) (assert (not (substring=? "foo\x00a" "foo\x00b" 1 1))) (assert (not (substring-ci=? "foo\x00a" "foo\x00b" 1 1))) +(assert (substring=? "foo" "foo" 0 0 3)) +(assert (substring-ci=? "foo" "foo" 0 0 3)) (assert (not (substring-index "o\x00bar" "foo\x00baz"))) (assert (not (substring-index-ci "o\x00bar" "foo\x00baz"))) (assert (= 0 (substring-index "" ""))) @@ -62,6 +64,7 @@ (assert-error (substring-ci=? "a" "a" 0 -2)) (assert-error (substring-ci=? "a" "a" 0 0 2)) (assert-error (substring-ci=? "a" "a" 0 0 -2)) +(assert-error (substring-ci=? "a" "a" 0 0 2)) (assert-error (substring-index "" "a" 2)) (assert-error (substring-index "a" "b" 2)) (assert (not (substring-index "a" "b" 1))) -- 2.40.0
Re: [PATCH] Add bounds-checks to substring
Thanks! A signed off copy is attached (waiting for another chicken-hacker to approve). cheers, felix From 7c4e7e84ddcc20e262b1aa15eef25c8133f63a7e Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 11 Mar 2024 12:15:44 +0100 Subject: [PATCH] Because the `start1`/`start2`/`n` parameters were not checked to be within bounds, it was possible to access arbitrary memory outside of the given strings. This could lead to wrong results (returning #t/#f when the opposite was true), or possibly crashing the program. (Patch contributed by "siiky") Signed-off-by: felix --- data-structures.scm | 24 ++-- tests/data-structures-tests.scm | 12 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/data-structures.scm b/data-structures.scm index 8563fba2..642d2a59 100644 --- a/data-structures.scm +++ b/data-structures.scm @@ -155,11 +155,13 @@ (define (##sys#substring=? s1 s2 start1 start2 n) (##sys#check-string s1 'substring=?) (##sys#check-string s2 'substring=?) - (let ((len (or n -(fxmin (fx- (##sys#size s1) start1) - (fx- (##sys#size s2) start2) ) ) ) ) -(##sys#check-fixnum start1 'substring=?) -(##sys#check-fixnum start2 'substring=?) + (##sys#check-range start1 0 (##sys#size s1) 'substring=?) + (##sys#check-range start2 0 (##sys#size s2) 'substring=?) + (let* ((maxlen (fxmin (fx- (##sys#size s1) start1) +(fx- (##sys#size s2) start2))) + (len (if n + (begin (##sys#check-range n 0 maxlen 'substring=?) n) + maxlen))) (##core#inline "C_substring_compare" s1 s2 start1 start2 len) ) ) (define (substring=? s1 s2 #!optional (start1 0) (start2 0) len) @@ -168,11 +170,13 @@ (define (##sys#substring-ci=? s1 s2 start1 start2 n) (##sys#check-string s1 'substring-ci=?) (##sys#check-string s2 'substring-ci=?) - (let ((len (or n -(fxmin (fx- (##sys#size s1) start1) - (fx- (##sys#size s2) start2) ) ) ) ) -(##sys#check-fixnum start1 'substring-ci=?) -(##sys#check-fixnum start2 'substring-ci=?) + (##sys#check-range start1 0 (##sys#size s1) 'substring-ci=?) + (##sys#check-range start2 0 (##sys#size s2) 'substring-ci=?) + (let* ((maxlen (fxmin (fx- (##sys#size s1) start1) +(fx- (##sys#size s2) start2))) + (len (if n + (begin (##sys#check-range n 0 maxlen 'substring-ci=?) n) + maxlen))) (##core#inline "C_substring_compare_case_insensitive" s1 s2 start1 start2 len) ) ) diff --git a/tests/data-structures-tests.scm b/tests/data-structures-tests.scm index 1d7820df..17a3dd58 100644 --- a/tests/data-structures-tests.scm +++ b/tests/data-structures-tests.scm @@ -50,6 +50,18 @@ (assert (not (substring-index-ci "o\x00bar" "foo\x00baz"))) (assert (= 0 (substring-index "" ""))) (assert (= 1 (substring-index "" "a" 1))) +(assert-error (substring=? "a" "a" 2)) +(assert-error (substring=? "a" "a" -2)) +(assert-error (substring=? "a" "a" 0 2)) +(assert-error (substring=? "a" "a" 0 -2)) +(assert-error (substring=? "a" "a" 0 0 2)) +(assert-error (substring=? "a" "a" 0 0 -2)) +(assert-error (substring-ci=? "a" "a" 2)) +(assert-error (substring-ci=? "a" "a" -2)) +(assert-error (substring-ci=? "a" "a" 0 2)) +(assert-error (substring-ci=? "a" "a" 0 -2)) +(assert-error (substring-ci=? "a" "a" 0 0 2)) +(assert-error (substring-ci=? "a" "a" 0 0 -2)) (assert-error (substring-index "" "a" 2)) (assert-error (substring-index "a" "b" 2)) (assert (not (substring-index "a" "b" 1))) -- 2.40.0
Re: [patch] update matchable egg
> Hi, > > here's a patch (against ^/release/5/matchable/trunk) to update the > matchable egg to the upstream version at > https://synthcode.com/scheme/match.scm > > The upstream match.scm requires (keyword?) which is where the diff to > matchable.scm comes from. > > chicken-install -test is fine here. I don't know if we perhaps want to > try and run a custom salmonella against this to see if it breaks any > other eggs. > Works fine, there is no need to set up a separate salmonella, the normal one will tell us if something's wrong. Thanks! cheers, felix
[PATCH] fix include-relative
Hi! See commit message. Reported by "Reid" on IRC. felix From 7d5ff4dec308236c54f188689ed0d5e74de82a6b Mon Sep 17 00:00:00 2001 From: felix Date: Sat, 27 Jan 2024 23:36:35 +0100 Subject: [PATCH] Including forms must preserve ##sys#current-source-filename Found by "Reid": invocation of "k" in ##sys#include-forms-from-file must be outside the fluid-binding of ##sys#current-source-filename or later inclusions while expanding a body will not see the original, outer binding of the var and "include-relative" will refer to the wrong original source --- eval.scm | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/eval.scm b/eval.scm index e760aad0..f67aa847 100644 --- a/eval.scm +++ b/eval.scm @@ -1170,21 +1170,21 @@ (define ##sys#include-forms-from-file (let ((call-with-input-file call-with-input-file) - (reverse reverse)) +(reverse reverse)) (lambda (filename source k) (let ((path (##sys#resolve-include-filename filename #t #f source)) - (read-with-source-info chicken.syntax#read-with-source-info)) ; OBSOLETE - after bootstrapping we can get rid of this explicit namespacing - (when (not path) - (##sys#signal-hook #:file-error 'include "cannot open file" filename)) - (when (load-verbose) - (print "; including " path " ...")) - (call-with-input-file path - (lambda (in) - (fluid-let ((##sys#current-source-filename path)) - (do ((x (read-with-source-info in) (read-with-source-info in)) - (xs '() (cons x xs))) - ((eof-object? x) - (k (reverse xs))) +(read-with-source-info chicken.syntax#read-with-source-info)) ; OBSOLETE - after bootstrapping we can get rid of this explicit namespacing +(when (not path) + (##sys#signal-hook #:file-error 'include "cannot open file" filename)) +(when (load-verbose) + (print "; including " path " ...")) +(call-with-input-file path + (lambda (in) +(k (fluid-let ((##sys#current-source-filename path)) + (do ((x (read-with-source-info in) (read-with-source-info in)) + (xs '() (cons x xs))) + ((eof-object? x) + (reverse xs))) ;;; Extensions: -- 2.40.0
[PATCH] fix file-select
Attached a patch fixing a wrong timeout-calculation/check, discovered by "dzoe". felix From c581a08e3b1781840f39e63c2d2b986496912a50 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 23 Jan 2024 13:36:59 +0100 Subject: [PATCH] make file-select actually reflect what it is supposed to do (thanks to "dzoe" for reporting this) --- manual/Module (chicken file posix) | 4 ++-- posixunix.scm | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/manual/Module (chicken file posix) b/manual/Module (chicken file posix) index 28fb6b76..95574f78 100644 --- a/manual/Module (chicken file posix) +++ b/manual/Module (chicken file posix) @@ -528,8 +528,8 @@ the buffer containing the data and the number of bytes read. Waits until any of the file-descriptors given in the lists {{READFDLIST}} and {{WRITEFDLIST}} is ready for input or output, respectively. If the optional argument {{TIMEOUT}} is -given and not false, then it should specify the number of milliseconds after -which the wait is to be aborted. This procedure returns two values: +given and not false, then it should specify the number of seconds after +which the wait is to be aborted (the value may be a float). This procedure returns two values: the lists of file-descriptors ready for input and output, respectively. {{READFDLIST}} and {{WRITEFDLIST}} may also be file-descriptors instead of lists. In this case the returned values are booleans diff --git a/posixunix.scm b/posixunix.scm index bad9b4c0..665c89e0 100644 --- a/posixunix.scm +++ b/posixunix.scm @@ -409,7 +409,6 @@ static int set_file_mtime(char *filename, C_word atime, C_word mtime) (nfds (fx+ nfdsr nfdsw)) (fds-blob (##sys#make-blob (fx* nfds (foreign-value "sizeof(struct pollfd)" int) - (when tm (##sys#check-exact-integer tm)) (do ((i 0 (fx+ i 1)) (fdsrl fdsrl (cdr fdsrl))) ((null? fdsrl)) @@ -423,7 +422,7 @@ static int set_file_mtime(char *filename, C_word atime, C_word mtime) "struct pollfd *fds = p;" "fds[i].fd = fd; fds[i].events = POLLOUT;") i (car fdswl) fds-blob)) (let ((n ((foreign-lambda int "poll" scheme-pointer int int) - fds-blob nfds (if tm (* (max 0 tm) 1000) -1 + fds-blob nfds (if tm (inexact->exact (truncate (* (max 0 tm) 1000))) -1 (cond ((fx< n 0) (posix-error #:file-error 'file-select "failed" fdsr fdsw) ) ((fx= n 0) (values (if (pair? fdsr) '() #f) (if (pair? fdsw) '() #f))) -- 2.40.0
[PATCH] deprecate chicken-home
Currently "chicken-home" can be used to obtain the location for sundry "data" files installed by eggs and usually required at runtime. This location may need to be changed when installing eggs into custom locations or when a CHICKEN installation via package manager uses a non-writable directory. The attached patch deprecates "chicken-home" in favor of using the include-path, which is already changable (via environment variable) and also can hold several locations which makes it possible to have a set of possible locations, probably in addition to the default system directory (usually $PREFIX/share/chicken), quite similar to the repository-path. This patch addes "include-path" as a quasi-replacement for "chicken-home" (also chicken.platform module). Eggs that want to operate on installed data files at run-time should use "include-path" from now on to locate any files, or, if they wish to be backwards compatible, can access the variable "##sys#include-pathnames" as a temporary workaround. felix From 40f033956a85859cc1c653da4a5d2dccc4740320 Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 22 Jan 2024 21:46:21 +0100 Subject: [PATCH] Deprecate chicken-home, add include-path init ##sys#include-pathnames in library.scm and populate with contents of CHICKEN_INCLUDE_PATH directly, instead of doing this in csi/chicken. Also move chop-separator from support.scm to batch-driver since it is only used there. --- DEPRECATED | 4 NEWS | 2 ++ batch-driver.scm | 21 - csi.scm | 12 eval.scm | 2 -- library.scm | 20 +++- manual/Module (chicken platform) | 16 ++-- support.scm | 13 ++--- types.db | 3 ++- 9 files changed, 55 insertions(+), 38 deletions(-) diff --git a/DEPRECATED b/DEPRECATED index c8d19bd1..716a148b 100644 --- a/DEPRECATED +++ b/DEPRECATED @@ -8,6 +8,10 @@ Deprecated functions and variables - "set-signal-handler!" and "signal-handler" have been deprecated in favor of "make-signal-handler" and "ignore-signal" which are better suited in a multithreaded environment. +- "chicken-home" is deprecated as it is not possible to override + when installing eggs into a custom location. Use "include-path" instead + (or "##sys#include-pathnames" for code that is intended to be + backwards compatible) when accessing the data location. 5.2.1 - current-milliseconds and its C implementations C_milliseconds and diff --git a/NEWS b/NEWS index 46c5d423..6b09db47 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,8 @@ longer memoized (fixes #1830). - Condition objects produced by procedures that change errno now have an `errno' property. + - Deprecated "chicken-home" and added "include-path" in the +chicken.platform module. - Tools - The -R option for csi and csc now accepts list-notation like diff --git a/batch-driver.scm b/batch-driver.scm index 8f0a4f35..b9cbe674 100644 --- a/batch-driver.scm +++ b/batch-driver.scm @@ -219,7 +219,7 @@ '() `((import-syntax ,@default-imports) (cleanup-forms '(((chicken.base#implicit-exit-handler - (outfile (cond ((memq 'output-file options) + (outfile (cond ((memq 'output-file options) => (lambda (node) (let ((oname (option-arg node))) (if (symbol? oname) @@ -227,18 +227,15 @@ oname) ) ) ) ((memq 'to-stdout options) #f) (else (make-pathname #f (if filename (pathname-file filename) "out") "c")) ) ) - (ipath (map chop-separator - (##sys#split-path -(or (get-environment-variable "CHICKEN_INCLUDE_PATH") "" (opasses (default-optimization-passes)) (time0 #f) (time-breakdown #f) (forms '()) (inline-output-file #f) (profile (or (memq 'profile options) -(memq 'accumulate-profile options) +(memq 'accumulate-profile options) (memq 'profile-name options))) - (profile-name + (profile-name (and-let* ((pn (memq 'profile-name options))) (cadr pn))) (hsize (memq 'heap-size options)) (kwstyle (memq 'keyword-style options)) @@ -339,6 +336,13 @@ no contf) ) db) ) ) +(define (chop-separator str) + (let ((len (sub1 (string-length str +(if (and (> len 0) + (memq (string-ref str len) '(#\\ #\/))) +(su
[PATCH] fix compiler-syntax handling of ##sys#override
This patch addresses the problem reported recently my Mario, regarding failing compilation of http-client. The problem was that compiler-syntax definitions changed the "override" status and disabled the existing value binding. felix From d11d8636218104fa4a6d92bc21b5bc1e7b91f2b0 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 16 Jan 2024 18:06:03 +0100 Subject: [PATCH] compile-syntax may not change ##sys#override status, as original value definition still applies --- core.scm | 75 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/core.scm b/core.scm index 8f6b85bc..2e2fa3ed 100644 --- a/core.scm +++ b/core.scm @@ -796,14 +796,14 @@ vars tmps) (##core#let () ,@body) ) ) e dest ldest h ln #f))) - + ((##core#with-forbidden-refs) (let* ((loc (caddr x)) (vars (map (lambda (v) (cons (resolve-variable v e dest ldest h outer-ln) loc)) (cadr x - (fluid-let ((forbidden-refs + (fluid-let ((forbidden-refs (append vars forbidden-refs))) (walk (cadddr x) e dest ldest h ln #f @@ -921,38 +921,37 @@ '(##core#undefined) ) e dest ldest h ln #f)) ) - ((##core#define-compiler-syntax) - (let* ((var (cadr x)) - (body (caddr x)) - (name (lookup var))) - (##sys#put/restore! name '##sys#override 'syntax) - (when body - (set! compiler-syntax - (alist-cons - name - (##sys#get name '##compiler#compiler-syntax) - compiler-syntax))) - (##sys#put! - name '##compiler#compiler-syntax - (and body - (##sys#cons -(##sys#ensure-transformer - (##sys#eval/meta body) - var) -(##sys#current-environment - (walk - (if ##sys#enable-runtime-macros - `(##sys#put! - (##core#syntax ,name) - '##compiler#compiler-syntax - ,(and body - `(##sys#cons - (##sys#ensure-transformer -,body -(##core#quote ,var)) - (##sys#current-environment - '(##core#undefined) ) - e dest ldest h ln #f))) + ((##core#define-compiler-syntax) +(let* ((var (cadr x)) + (body (caddr x)) + (name (lookup var))) + (when body +(set! compiler-syntax + (alist-cons + name + (##sys#get name '##compiler#compiler-syntax) + compiler-syntax))) + (##sys#put! + name '##compiler#compiler-syntax + (and body +(##sys#cons + (##sys#ensure-transformer + (##sys#eval/meta body) + var) + (##sys#current-environment + (walk + (if ##sys#enable-runtime-macros + `(##sys#put! +(##core#syntax ,name) +'##compiler#compiler-syntax +,(and body + `(##sys#cons +(##sys#ensure-transformer + ,body + (##core#quote ,var)) +(##sys#current-environment + '(##core#undefined) ) + e dest ldest h ln #f))) ((##core#let-compi
Re: [PATCH] Add errno property to condition objects
> Hi, > > The attached patch adds errno to condition objects produced by > procedures that change it. > Pushed! felix
Re: [PATCH] chicken-install: Store cache metadata out of the C includepath
> Hi, > > The attached patch is a follow-up to the fix for > http://bugs.call-cc.org/ticket/1753 > > 2f6a72211e37 works around the problem by adding an underscore as a > prefix to the cache metadata files (VERSION, TIMESTAMP and STATUS). > While the new names tend to be a bit more unusual than the original > ones, they are still valid filenames to be included into C/C++ code > via #include. > > The attached patch avoids the problem of unintended inclusion altogether > by storing the cache metadata files into a directory which is not in the > include path of the C compiler (/.cache-metadata/). > > .cache-metadata is not a valid egg name, so it can be in > together with egg directories. Pushed - thanks! felix
Re: [PATCH] Drop memoization of envvars used bycreate-temporary-{file,directory}
> Hi, > > Attached is a patch to fix an issue (#1830) affecting > create-temporary-{file,directory} in cases where the environment > variables they use to determine the directory where temporary > files/directories are created get changed. > > Please see the commit message and https://bugs.call-cc.org/ticket/1830 > for more details. > > The patch also contains some updates to the documentation and a couple > of simple tests. The tests will be called by "make check" on Windows, > but I haven't run them there as I don't have a Windows system. Thanks! Pushed. felix
Re: Proposed alternative encoding for stray UTF-8 bytes in strings
> Yes, this is precisely my point - 'one or more'. The string-length with > invalid embedded sequences is not guaranteed to be consistent, which seems > like a problem. Doing a decode to ensure all points are valid - even if in > the undefined sequences - seems to be a good idea to prevent secondary issues. The validation is done in "utf8->string". Once a string from some other, unknown source has been created as an internal string object, any subsequent modifications will use valid UTF-8 sequences, unless you explicitly inject U+DCxx characters (the latter should probably be disallowed). felix
Re: Proposed alternative encoding for stray UTF-8 bytes in strings
> Question: if there is no translation at all, won't the invalid chars cause > issues with things like string-length and string-copy procs? That is, since > the number of octets can't be correctly translated to a number of glyphs, > there will be some unpleasant side effects. Converting a octet-sequence to a string involves a decoding step to compute the length. Any invalid embedded UTF-8 sequence is taken as one ore more "illegal" code-points, counting for one ore more characters in the final string length. Note that the length of the "backing store" bytevector for the string is retained together with the number of code-points that the string holds (the former is stored in the header of the string's bytevector buffer, the latter in a slot of the string). felix
Re: Proposed alternative encoding for stray UTF-8 bytes in strings
> From the unicode-transition page: > > The strategy that I favor in the moment is to handle all string data > > injected into the system transparently, the actual bytes are unchanged and > > unexpected UTF-8 bytes are decoded and marked as a U+DC80 - U+DCFF (low, > > trailing) UTF-16 surrogate pair half. > > > The trouble with this is that it means the internal representation is no > longer valid UTF-8, which may cause problems down the line, since it is > exposed to anyone dealing with bytevectors. > > There is an alternative based on the little-known "noncharacter" range. > Despite the name, these really are perfectly valid characters, but Unicode > guarantees that they will never be assigned to anything in the Real World > and are reserved for internal use.[1] I propose using them instead of the > surrogate space. Unfortunately there aren't enough of them to assign one > to each possible stray byte, but we can assign one to each high and low > nybble of each stray byte, analogously to the way Planes 1 to 1F are > handled in UTF-16. > > Specifically, given a stray byte whose hex representation is xy, we decode > it as the UTF-8 equivalent of U+FDDx U+FDEy, which is EF B7 9x EF B7 Ay in > the internal encoding, which is now valid UTF-8. If any of these > noncharacters (coming from a UTF-8 or UTF-16 source) is to be decoded, we > escape it with the UTF-8 representation of U+FFFE, which is EF BF BE, so > that (say) external U+FDDA is decoded as EF BF BE EF B7 AA. U+FFFE is also > used to escape itself, so it becomes EF BF BE EF BF BE internally. This is indeed a clever idea, thanks for pointing this out. I thought about this and it seems that it might not be necessary to worry about the internal encoding, as the current approach tries to handle strings received from the OS in a transparent manner. There is no translation step, as all strings are by default assumed to be UTF-8, with the exception of strings read from ports that have an explicit binary/latin-1 encoding. The U+DCxx only is relevant at the point of decoding, when we extract characters from the underlying bytevector, it never appears in the internal representation of a string itself. So, if we receive a string (say a filename from a directory-read operation), it may or may not be valid UTF-8, but it will be kept as the same sequence of bytes. This also applies to "string->utf8", which just produces a copy of the internal bytevector, regardless of whether the string contains invalid sequences or not. R7RS doesn't state (to my knowledge) any requirements regarding the result of this procedure. It says "it is an error" for a string to contain any "forbidden" characters, but, as I understand it, what is or is not forbidden, is up to the implementation. This may be insufficient (I'm not a UNICODE-lawyer), but appears to me compatible to the standard, has a low overhead and has the advantage that we don't have to worry about what encoding OS-sources of strings (other than ports) may have. Perhaps you can clarify what you mean when you say that this can cause problems when dealing with bytevectors? cheers, felix
Re: [PATCH] allow overriding value/syntax toplevel bindings (#1166)
> On Sun, Nov 12, 2023 at 01:45:06PM +0100, felix.winkelm...@bevuta.com wrote: > > See commit message. > > Nice to make some progress on this! > > However, I tested the example given in the ticket: > > (define begin -) > (begin 0 1) => 1 ;; expected: -1 > > This still evaluates to 1. > Yes, this is admittedly all a bit ugly. Please find attached 2 patches: the first addresses the endless expansion loop caused by our recent change in ##sys#canonicalize-body. The second patch is a new version of the "override" patch, with some additional changes to address the example above and a followup problem that came up during testing. I post the two patches together, because the latter includes the change for the former. Please apply at least the former, if you still have doubts about the override changes. felix From c30be664a4492db70d06edd17baffc3950ec6d45 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 14 Nov 2023 13:14:46 +0100 Subject: [PATCH] Fix hygienic comparison for "begin" forms when expanding body --- expand.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expand.scm b/expand.scm index ec94086a..f18838b3 100644 --- a/expand.scm +++ b/expand.scm @@ -462,7 +462,7 @@ (define (comp s id) (let ((f (or (lookup id se) (lookup id (##sys#macro-environment) -(or (eq? f id) (eq? s id +(or (eq? f s) (eq? s id (define (comp-def def) (lambda (id) (let repeat ((id id)) -- 2.40.0 From f98af2c34a59d885738c2f1ce5c3977d8f2abd6c Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 14 Nov 2023 13:16:38 +0100 Subject: [PATCH] Retain current identifier status as syntax or value binding Currently, toplevel value- and macro-bindings for an identifier are distinctly stored in separate places, resulting in the effect that a macro definition will shadow a value-binding (see also #1166). One way to address this would be to remove syntax-bindings when a toplevel identifier is "define"d and vice versa, but this will require a lot of searching and re-consing of (possibly large) environment a-lists. The approach chosen here is to store a global property on the symbol that names the identifier which specifies whether a value-binding should override any existing syntax binding (and the other way around). Some attempt is made to properly restore the "override" status when processing modules. Patch updated to address definition-binding lookup loop in bodies and ensure toplevel identifiers are correctly checked for the override property. Also clear override-status for all imports. --- core.scm | 21 - eval.scm | 2 ++ expand.scm | 31 --- modules.scm| 36 +--- tests/module-tests.scm | 13 + tests/syntax-tests.scm | 24 6 files changed, 96 insertions(+), 31 deletions(-) diff --git a/core.scm b/core.scm index a551204f..8f6b85bc 100644 --- a/core.scm +++ b/core.scm @@ -907,6 +907,7 @@ `(##core#lambda ,(cdadr x) ,@(cddr x)) (caddr x))) (name (lookup var))) + (##sys#put/restore! name '##sys#override 'syntax) (##sys#register-syntax-export name (##sys#current-module) body) (##sys#extend-macro-environment name @@ -924,6 +925,7 @@ (let* ((var (cadr x)) (body (caddr x)) (name (lookup var))) + (##sys#put/restore! name '##sys#override 'syntax) (when body (set! compiler-syntax (alist-cons @@ -1109,15 +,16 @@ `(##core#lambda ,aliases ,body) ) ) ((##core#ensure-toplevel-definition) - (unless tl? - (let* ((var0 (cadr x)) -(var (lookup var0)) -(ln (get-line-number x))) - (quit-compiling - "~atoplevel definition of `~s' in non-toplevel context" - (if ln (sprintf "(~a) - " ln) "") - var))) - '(##core#undefined)) + (let* ((var0 (cadr x)) +(var (lookup var0))) + (unless tl? + (let ((ln (get-line-number x))) + (quit-compiling + "~atoplevel definition of `~s' in non-topl
[PATCH] allow overriding value/syntax toplevel bindings (#1166)
See commit message. cheers, felix From 5f98b32ec8103c5b6efed4da3301c1d02e29b202 Mon Sep 17 00:00:00 2001 From: felix Date: Sun, 12 Nov 2023 13:39:10 +0100 Subject: [PATCH] Retain current identifier status as syntax or value binding Currently, toplevel value- and macro-bindings for an identifier are distinctly stored in separate places, resulting in the effect that a macro definition will shadow a value-binding (see also #1166). One way to address this would be to remove syntax-bindings when a toplevel identifier is "define"d and vice versa, but this will require a lot of searching and re-consing of (possibly large) environment a-lists. The approach chosen here is to store a global property on the symbol that names the identifier which specifies whether a value-binding should override any existing syntax binding (and the other way around). Some attempt is made to properly restore the "override" status when processing modules. --- core.scm | 21 - eval.scm | 2 ++ expand.scm | 25 - modules.scm| 17 ++--- tests/syntax-tests.scm | 21 + 5 files changed, 65 insertions(+), 21 deletions(-) diff --git a/core.scm b/core.scm index a551204f..8f6b85bc 100644 --- a/core.scm +++ b/core.scm @@ -907,6 +907,7 @@ `(##core#lambda ,(cdadr x) ,@(cddr x)) (caddr x))) (name (lookup var))) + (##sys#put/restore! name '##sys#override 'syntax) (##sys#register-syntax-export name (##sys#current-module) body) (##sys#extend-macro-environment name @@ -924,6 +925,7 @@ (let* ((var (cadr x)) (body (caddr x)) (name (lookup var))) + (##sys#put/restore! name '##sys#override 'syntax) (when body (set! compiler-syntax (alist-cons @@ -1109,15 +,16 @@ `(##core#lambda ,aliases ,body) ) ) ((##core#ensure-toplevel-definition) - (unless tl? - (let* ((var0 (cadr x)) -(var (lookup var0)) -(ln (get-line-number x))) - (quit-compiling - "~atoplevel definition of `~s' in non-toplevel context" - (if ln (sprintf "(~a) - " ln) "") - var))) - '(##core#undefined)) + (let* ((var0 (cadr x)) +(var (lookup var0))) + (unless tl? + (let ((ln (get-line-number x))) + (quit-compiling + "~atoplevel definition of `~s' in non-toplevel context" +(if ln (sprintf "(~a) - " ln) "") +var))) + (##sys#put/restore! var '##sys#override 'value) + '(##core#undefined))) ((##core#set!) (let* ((var0 (cadr x)) diff --git a/eval.scm b/eval.scm index 68fba6ff..e760aad0 100644 --- a/eval.scm +++ b/eval.scm @@ -265,6 +265,7 @@ ((##core#ensure-toplevel-definition) (unless tl? (##sys#error "toplevel definition in non-toplevel context for variable" (cadr x))) + (##sys#put/restore! (cadr x) '##sys#override 'value) (compile '(##core#undefined) e #f tf cntr #f)) @@ -508,6 +509,7 @@ (name (rename var))) (when (and static (not (assq var (##sys#current-environment (##sys#error 'eval "environment is not mutable" evalenv var)) +(##sys#put/restore! name '##sys#override 'syntax) (##sys#register-syntax-export name (##sys#current-module) body) ; not really necessary, it only shouldn't be #f diff --git a/expand.scm b/expand.scm index 67ddf228..a646e316 100644 --- a/expand.scm +++ b/expand.scm @@ -261,10 +261,13 @@ (let ((head2 (or (lookup head dse) head))) (unless (pair? head2) (set! head2 (or (lookup head2 (##sys#macro-environment)) head2)) ) - (cond [(eq? head2 '##core#let) + (cond ((and (eq? head head2) +
Re: [PATCH] Minimize the risks of corruption of chicken-install's cache
> Hi, > > The attached patches minimize the risk of reusing object files in the > chicken-install cache by different, possibly incompatible, CHICKEN > versions/builds. > > The first patch ("chicken-install: Reset egg cache when status file does > not exist") deals with renaming of the so-called status file, which > happened in 2f6a7221. chicken-install uses the status file to determine > when to invalidate the cache. One problem with the renaming is: if > chicken-install doesn't find the status file, it will reuse the object > files in the cache. This might be problematic in case the object files > are used by incompatible CHICKENs (e.g., incompatible CHICKEN versions, > CHICKENs compiled with different C compilers). > > That patch solves the problem of CHICKENs newer than 2f6a7221 reusing > possibly incompatible cached object files produced by CHICKENs older > than 2f6a7221. It doesn't solve the problem of older CHICKENs (i.e., > the ones compiled with the submitted patch) reusing possibly > incompatible cached object files produced by CHICKENs newer than > 2f6a7221. In those cases, the older CHICKEN will NOT recognize the new > status file name (_STATUS) and will proceed to reuse the possibly > incompatible object files. Thanks, Mario. I'll push it in a few moments. > > To address _that_ problem, a second patch is attached ("egg-environment: > Add chicken version to the path to chicken-install's cache"). It simply > adds the CHICKEN version to the path to the chicken-install cache, so > that older CHICKENs won't look for cached objects in the cache produced > by newer CHICKENs. > I would suggest to use the binary version instead of the full CHICKEN version. It is specifically meant to handle such issues and reduces the amount of wasted space that will be the result when one frequently updates ones CHICKEN installation. On the other hand, the whole cache validation logic was implemented to specifically address this problem. The renaming of the status file was probably a mistake (or at least short sighted) and results in the headaches that you are now kindly trying to fix, but apart from that, we already try very hard to keep the cache's contents only when really needed. Just duplicating the cache somehow appears like a crude measure. It's just a cache, we can, after all, just purge it. felix
[PATCH] avoid loop in lookup (fix Salmonella hang with transducers)
The attached patch addresses an endless expander loop while compiling the transducers egg. The egg uses unconvential (and only slightly legal) alias identifiers that confuse the expander, combined with a recent change in how it resolves macros in bodies. The problem was reported by Mario and wasamasa. felix From 544ad8292b319289536033a452480169381654e1 Mon Sep 17 00:00:00 2001 From: felix Date: Sun, 12 Nov 2023 12:42:54 +0100 Subject: [PATCH] Avoid loop when looking up alias when canonicalizing body --- expand.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/expand.scm b/expand.scm index 67ddf228..ec94086a 100644 --- a/expand.scm +++ b/expand.scm @@ -469,7 +469,9 @@ (let ((f (or (lookup id se) (lookup id (##sys#macro-environment) (or (eq? f def) -(and (symbol? f) (repeat f))) +(and (symbol? f) + (not (eq? f id)) + (repeat f))) (define comp-define (comp-def define-definition)) (define comp-define-syntax (comp-def define-syntax-definition)) (define comp-define-values (comp-def define-values-definition)) -- 2.40.0
Re: [PATCH] warn on unexpected egg-properties
> On Wed, Nov 08, 2023 at 02:59:17PM +0100, felix.winkelm...@bevuta.com wrote: > > Attached is a patch to address #1492. > > Applied. Do we want to turn this into an error for CHICKEN 6? > Warnings have a tendency of just scrolling by and getting lost in the > noise of compiler output. Thanks. > OTOH, making it an error would make it harder to add new properties and > be backward compatible in an egg (though cond-expand would help). Indeed, that was what I thought as well. It seems we should stay with warnings for the time being, as the effects are likely to be benign or will fail to build an egg altogether. felix
[PATCH] bugfix for #1295
See commit message. felix From 9429d011b690372254bfc35ac6095c8a2dcd8c61 Mon Sep 17 00:00:00 2001 From: felix Date: Fri, 10 Nov 2023 11:21:51 +0100 Subject: [PATCH] Resolve macro-aliases for static evaluation environments (#1295) When evaluating forms in a "static" environment, identifiers are not resolved using our old friend ##sys#alias-global-hook, but identifiers introduced by macros must still be replaced by their "##sys#macro-alias", which is correctly returned when looking up the identifier in the environment, but not used. --- eval.scm| 5 +++-- tests/environment-tests.scm | 12 +++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/eval.scm b/eval.scm index 4562a506..68fba6ff 100644 --- a/eval.scm +++ b/eval.scm @@ -145,8 +145,9 @@ (let ((var (cond ((not (symbol? j)) x) ; syntax? ((assq x (##sys#current-environment)) j) ((not static) - (##sys#alias-global-hook j #f cntr)) -(else #f + (##sys#alias-global-hook j #f cntr)) + ((not (eq? x j)) j) ; has macro-alias + (else #f (when (and ##sys#unbound-in-eval (or (not var) (not (##sys#symbol-has-toplevel-binding? var diff --git a/tests/environment-tests.scm b/tests/environment-tests.scm index b4143a52..c9d22d46 100644 --- a/tests/environment-tests.scm +++ b/tests/environment-tests.scm @@ -1,6 +1,6 @@ environment-tests.scm -(import (chicken load)) +(import (chicken load) (chicken eval)) (load-relative "test.scm") @@ -53,6 +53,16 @@ (test-equal (eval '(format "~a" 1) format-env) "1") (test-error (eval 'baz format-env)) +;; #1295 +(module example * + (import scheme) + (define (add a b) (+ a b)) + (define-syntax double +(syntax-rules () + ((_ x) (add x x) + +(test-equal (eval '(double 10) (module-environment 'example)) 20) + (test-end) (test-exit) -- 2.40.0
[PATCH] warn on unexpected egg-properties
Attached is a patch to address #1492. felix From 37b8de2f956c36a311c5162dbdbc8af631a9bc59 Mon Sep 17 00:00:00 2001 From: felix Date: Wed, 8 Nov 2023 14:52:15 +0100 Subject: [PATCH] Warn if processing egg property in wrong context (#1492) --- egg-compile.scm | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/egg-compile.scm b/egg-compile.scm index c9a5565e..dd7c429e 100644 --- a/egg-compile.scm +++ b/egg-compile.scm @@ -379,7 +379,7 @@ link-objects: lobjs eggfile: eggfile) prgs) -(else (compile-common info compile-component +(else (compile-common info compile-component 'component (define (compile-extension/program info) (case (car info) ((linkage) @@ -416,8 +416,8 @@ (set! cdeps (append cdeps (map ->dep (cdr info) ((source-dependencies) (set! sdeps (append sdeps (map ->dep (cdr info) -(else (compile-common info compile-extension/program -(define (compile-common info walk) +(else (compile-common info compile-extension/program 'extension/program +(define (compile-common info walk context) (case (car info) ((target) (when (eq? mode 'target) @@ -428,14 +428,16 @@ ((error) (apply error (cdr info))) ((cond-expand) - (compile-cond-expand info walk + (compile-cond-expand info walk)) +(else + (fprintf (current-error-port) "\nWarning (~a): property `~a' invalid or in wrong context (~a)\n\n" eggfile (car info) context (define (compile-data/include info) (case (car info) ((destination) (set! dest (->string (arg info 1 name? ((files) (set! files (append files (map ->string (cdr info) -(else (compile-common info compile-data/include +(else (compile-common info compile-data/include 'data/include (define (compile-options info) (case (car info) ((csc-options) (set! opts (append opts (cdr info @@ -457,10 +459,13 @@ (error "invalid dependency" x))) (define (compile info) (case (car info) +((synopsis dependencies test-dependencies category version author maintainer + license build-dependencies foreign-dependencies platform + distribution-files) #f) ((components) (for-each compile-component (cdr info))) ((component-options) (for-each compile-options (cdr info))) -(else (compile-common info compile +(else (compile-common info compile 'toplevel (define (arg info n #!optional (pred (constantly #t))) (when (< (length info) n) (error "missing argument" info n)) -- 2.40.0
Re: [PATCH] fix for #1132
> On Wed, Nov 08, 2023 at 12:34:23PM +0100, felix.winkelm...@bevuta.com wrote: > > See commit message. > > Shouldn't we modify the test instead of dropping it? > > Something like this: > > (module m3 () > (import (rename scheme (define s:define))) > (import (only (chicken base) assert)) > (define-syntax define > (syntax-rules () > ((_) (display 'oink)) > ((_ var value) (s:define var (+ value 1) > (define) > (let () > (define a 1) > (assert (= a 2))) > (define) > (newline)) > > Not sure it's useful to have that final define and newline there. > Perhaps we can drop that, or change it do something more meaningful. > We could simply change it to (define b 5) followed by (assert (= b 6)). Sure, if you think this is useful. I care more about the bugfix, to be honest. :-) felix
[PATCH] fix for #1132
See commit message. felix From bd0f5bc81207a3ec82995e13c8a470fc3ab9e1a0 Mon Sep 17 00:00:00 2001 From: felix Date: Wed, 8 Nov 2023 12:26:38 +0100 Subject: [PATCH] Detect redefinitions of defining forms correctly (#1132) The scanning for local definitions in ##sys#canonicalize-body used what I think is incorrect logic to detect whether references to local "define-*" forms need to be expanded. The two problems where: ##sys#macro-environment was not consulted, so the global (default) definition would never be found to be compared with the stored meaning in "define-definition", etc., resulting in the fallback mode of merely testing for eq? to be used in all cases. Second, after looking up the entry in the syntactic environment, the value could result in a reference to another definition, so the lookup operation needs to be repeated. I have added test cases, as given in #1132 and removed an existing test that seems to be wrong. --- expand.scm | 42 +++- tests/module-tests-2.scm | 16 --- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/expand.scm b/expand.scm index ba4737b5..67ddf228 100644 --- a/expand.scm +++ b/expand.scm @@ -460,14 +460,20 @@ (define ##sys#canonicalize-body (lambda (body #!optional (se (##sys#current-environment)) cs?) (define (comp s id) - (let ((f (lookup id se))) - (or (eq? s f) - (case s - ((define) (if f (eq? f define-definition) (eq? s id))) - ((define-syntax) (if f (eq? f define-syntax-definition) (eq? s id))) - ((define-values) (if f (eq? f define-values-definition) (eq? s id))) - ((import) (if f (eq? f import-definition) (eq? s id))) - (else (eq? s id)) + (let ((f (or (lookup id se) + (lookup id (##sys#macro-environment) +(or (eq? f id) (eq? s id +(define (comp-def def) + (lambda (id) +(let repeat ((id id)) + (let ((f (or (lookup id se) + (lookup id (##sys#macro-environment) +(or (eq? f def) +(and (symbol? f) (repeat f))) +(define comp-define (comp-def define-definition)) +(define comp-define-syntax (comp-def define-syntax-definition)) +(define comp-define-values (comp-def define-values-definition)) +(define comp-import (comp-def import-definition)) (define (fini vars vals mvars body) (if (and (null? vars) (null? mvars)) ;; Macro-expand body, and restart when defines are found. @@ -482,13 +488,13 @@ (if (and (pair? x) (let ((d (car x))) (and (symbol? d) - (or (comp 'define d) - (comp 'define-values d) - (comp 'define-syntax d) - (comp '##core#begin d) - (comp 'import d) + (or (comp '##core#begin d) +(comp-define d) + (comp-define-values d) + (comp-define-syntax d) + (comp-import d) ;; Stupid hack to avoid expanding imports - (if (comp 'import (car x)) + (if (comp-import (car x)) (loop rest (cons x exps)) (cons '##core#begin @@ -547,7 +553,7 @@ ((and (list? (car body)) (>= 3 (length (car body))) (symbol? (caar body)) -(comp 'define-syntax (caar body))) +(comp-define-syntax (caar body))) (let ((def (car body))) ;; This check is insufficient, if introduced by ;; different expansions, but better than nothing: @@ -570,7 +576,7 @@ (if (not (symbol? head)) (fini vars vals mvars body) (cond - ((comp 'define head) + ((comp-define head) (##sys#check-syntax 'define x '(_ _ . #(_ 0)) #f se) (let loop2 ((x x)) (let ((head (cadr x))) @@ -597,10 +603,10 @@ (cons (list (car head)) vars) (cons `(##core#lambda ,(cdr head) ,@(cddr x)) vals) (cons #f mvars))) - ((comp 'define-syntax head) + ((comp-define-syntax head) (##sys#check-syntax 'define-syntax x '(_ _ . #(_ 1)) se) (fini/syntax vars vals mvars body)) - ((c
Re: CHICKEN 6 "preview"
> Howdy, > > Thanks for all the work! > > Is it safe to install under the same prefix next to the regular C5 > install (using a "6" suffix or something)? E.g. will eggs be installed > under $PREFIX/lib/chicken/12/ (rather than 11)? > That should be the case, yes. Note that this all is very much work in progress. felix
CHICKEN 6 "preview"
Hi! I have recently put some effort into working towards support of full unicode and R7RS compliance, as preparatory work for the next major release of CHICKEN. See http://wiki.call-cc.org/chicken-6-roadmap for details and the current status, in particular with respect to incompatibilities with CHICKEN 5 that are to be expected. I also plan to clean up some obsolete C macros and move the "feathers" debugger into an egg. cheers, felix
Re: [patch] initial support for functors in csm
Hi, Pietro! Very nice. I'm on the road right now, but will take a deeper look at this in the next days. Thanks! cheers, felix
Re: [PATCH] export/rename
> I'd prefer if we could develop this a bit further to make the rename > form accessible to module as well. Sure. I personally never felt the need for rename on export and wanted to add this just as a base to build R7RS support on. Bindings and aliases are so easily done in Scheme that it doesn't seem necessary to complicate existing forms further. > Not sure if that would be useful in functors. I've never used them, > but it seems to me that the functor's implementation is in a better > position to determine whether to rename on export or not, not the > functor definition itself. I agree. The functor is an _external_ interface, how the implementation names stuff inside is of no concern. > If you agree that it makes little sense to support it in functors, > perhaps it's better to call ##sys#syntax-error when the functor > definition includes renamed exports? Personally I prefer a separate form, but this makes sense of course. > I had a quick look and the main obstacle seems to be that > ##core#module is not very extendable, because it assumes the first two > "arguments" are special, and the rest is the body (IIUC). Correct, that#s why I began with a separate export form. > Would it perhaps be possible to simply expand (module FOO (exps) BODY) to > something like the following? > > (##core#module FOO (non-renamed-exps) > (export (rename: name1 renamed1) ...) > BODY) It's all the same. Let's keep ##core#module as it is (and perhaps "module" itself) I wonder whether we should expend so much thought about this, to be honest. The export/rename localizes the functionality and doesn't require changes to existing code. The precedent of the syntax: and interface: never was a particularly good one (we should have used separate export forms for those right from the start), so adding funny markers or possibly ambiguous special cases is not my favorite approach. cheers, felix
Re: [PATCH] export/rename
> Maybe this already works with the current patch, but can we support: > > (export (rename foo bar)) > > As well as the version with the colon (suffix keyword notation) on the end of > export? > Seems like that would be best for symmetry with the import form. > > (Sorry, it’s just aesthetics, I know.) Well, aesthetics is important. There are a couple of points, though: - import "rename" has a different syntax, as it combines an import spec with a rename list, here we effectively have a special case (3 argument list). - exports go through ##sys#validate-exports, so originally "export", "define-interface" and the export spec of the "module" form supported the same export notation, but now we have a special case for export, since we try to shoehorn renaming into the existing "export", but renaming is not allowed in "module" and "define-interface". The "(rename OLD NEW)" would be ambiguous with the old interpretation, of course. - having "rename" + "rename:" adds another special case where both keyword and normal symbol is allowed, I don't think we have this anywhere else. - My original intention was to provide a low-impact renaming export in the core in anticipation of re-using it for R7RS support. It still seems useful for CHICKEN 5, but since rename-on-export appears to me a seldom used feature I thought a separate form is sufficient. felix
Re: [PATCH] export/rename
> On Mon, Oct 02, 2023 at 06:31:44PM +0200, felix.winkelm...@bevuta.com wrote: > > This patch adds a new special form to explicitly export renamed bindings > > from a module: > > > > (export/rename (OLD NEW) ...) > > Why not add it to the regular "export" form? It's already extendable, > as it has syntax: and interface:. So for example we could have: > > (export (rename: OLD NEW) ...) > > Saves having yet another top-level special-case form. Ok, I find attached a variant, both more ugly in interface and implementation, since ##core#module and functor do not yet allow renamings to be handled. Also, "define-interface" has no notion of this, so "(rename: OLD NEW)" is purely applicable in "export". I prefer the first variant, but feel free to push which one you like more. felix From 93c8e56092b4cb462f0669ab9892213fa8090b71 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 3 Oct 2023 12:50:53 +0200 Subject: [PATCH] allow renaming exports in "export" form --- expand.scm | 44 +--- manual/Modules | 7 +++ modules.scm| 112 + tests/module-tests.scm | 22 4 files changed, 126 insertions(+), 59 deletions(-) diff --git a/expand.scm b/expand.scm index 13a7f553..a88ddda9 100644 --- a/expand.scm +++ b/expand.scm @@ -1175,7 +1175,10 @@ (cdr app)) ; functor arguments (else ;;XXX use module name in "loc" argument? -(let ((exports (##sys#validate-exports (strip-syntax (caddr x)) 'module))) +(let-values (((exports _) (##sys#validate-exports (strip-syntax (caddr x)) + 'module))) + ;;XXX we currently ignore renames here, to support this, we need to + ;; extend ##core#module `(##core#module ,name ,(if (eq? '* exports) @@ -1192,11 +1195,11 @@ 'export '() (##sys#er-transformer (lambda (x r c) -(let ((exps (##sys#validate-exports (strip-syntax (cdr x)) 'export)) - (mod (##sys#current-module))) - (when mod - (##sys#add-to-export-list mod exps)) - '(##core#undefined) +(let-values (((exps ren) (##sys#validate-exports (strip-syntax (cdr x)) 'export))) + (let ((mod (##sys#current-module))) +(when mod + (##sys#add-to-export-list mod exps ren)) +'(##core#undefined)) (##sys#extend-macro-environment 'reexport '() @@ -1223,17 +1226,20 @@ (##core#quote ,(library-id name)) (##core#quote ,(map (lambda (arg) - (let ((argname (car arg)) -(exps (##sys#validate-exports (cadr arg) 'functor))) -(unless (or (symbol? argname) -(and (list? argname) - (= 2 (length argname)) - (symbol? (car argname)) - (valid-library-specifier? (cadr argname - (##sys#syntax-error-hook "invalid functor argument" name arg)) -(cons argname exps))) + (let ((argname (car arg))) + (let-values (((exps _) (##sys#validate-exports (cadr arg) + 'functor))) + ;;XXX renames currently ignored + (unless (or (symbol? argname) + (and (list? argname) + (= 2 (length argname)) + (symbol? (car argname)) + (valid-library-specifier? (cadr argname +(##sys#syntax-error-hook "invalid functor argument" name arg)) + (cons argname exps args)) - (##core#quote ,(##sys#validate-exports exps 'functor)) + (##core#quote ,(let-values (((exps _) (##sys#validate-exports exps 'functor))) + exps)) (##core#quote ,body `(##core#module ,(library-id name) #t @@ -1260,7 +1266,11 @@ (cond ((eq? '* exps) '*) ((symbol? exps) `(#:interface ,exps)) ((list? exps) - (##sys#validate-exports exps 'define-interface)) + (let-values (((exps ren) (##sys#validate-exports exps 'define-interface))) + (unless (null? ren) +(syntax-error-hook 'define-interface + "renaming exports may n
[PATCH] export/rename
This patch adds a new special form to explicitly export renamed bindings from a module: (export/rename (OLD NEW) ...) This is mainly useful for supporting R7RS renaming export specifiers (not done yet). I wanted first to apply the renamings when creating the module structure, but it turned out to be easier at the import stage, as renaming is done there anyway (for renamed import) and taking care of all the cross-references and indirect imports is rather hairy. My basic test cases seem to work as intended. There may of course be more corner cases that I have overlooked. felix From 68c938512c2f29078a4f499396956e9f09ead57f Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 2 Oct 2023 18:25:29 +0200 Subject: [PATCH] add "export/rename" for renaming identifiers on export Module structures get an additional rename a-list, and renaming of value/syntax bindings is done on import. This patch also renames some loop variables to make the code less confusing and drops a redundant check. --- eval.scm | 1 + expand.scm | 19 ++ manual/Modules | 11 ++ modules.scm| 84 ++ tests/module-tests.scm | 22 +++ 5 files changed, 106 insertions(+), 31 deletions(-) diff --git a/eval.scm b/eval.scm index 929acc38..4562a506 100644 --- a/eval.scm +++ b/eval.scm @@ -851,6 +851,7 @@ define-interface delay-force export + export/rename functor import import-for-syntax diff --git a/expand.scm b/expand.scm index 13a7f553..ba4737b5 100644 --- a/expand.scm +++ b/expand.scm @@ -1198,6 +1198,25 @@ (##sys#add-to-export-list mod exps)) '(##core#undefined) +(##sys#extend-macro-environment + 'export/rename '() + (##sys#er-transformer + (lambda (x r c) +(let ((exps (map (lambda (ren) + (if (and (pair? ren) +(symbol? (car ren)) +(pair? (cdr ren)) +(symbol? (cadr ren)) +(null? (cddr ren))) + (cons (car ren) (cadr ren)) + (##sys#syntax-error-hook "invalid item in export rename list" +ren))) + (strip-syntax (cdr x + (mod (##sys#current-module))) + (when mod + (##sys#add-to-export/rename-list mod exps)) + '(##core#undefined) + (##sys#extend-macro-environment 'reexport '() (##sys#er-transformer diff --git a/manual/Modules b/manual/Modules index e562f460..3f327aa5 100644 --- a/manual/Modules +++ b/manual/Modules @@ -121,6 +121,17 @@ Allows augmenting module-exports from inside the module-body. If used outside of a module, then this form does nothing. + export/rename + +(export/rename (NAME EXPORT) ...) + +Allows augmenting module-exports from inside the module-body. +Each argument should be a two-element list containing the name +of the local value- or syntax-definition (NAME) and the name under which the +definition should be exported (EXPORT). + +If used outside of a module, then this form does nothing. + import (import IMPORT ...) diff --git a/modules.scm b/modules.scm index 61556fef..c6b77acd 100644 --- a/modules.scm +++ b/modules.scm @@ -90,12 +90,13 @@ module-meta-expressions set-module-meta-expressions! module-defined-syntax-list set-module-defined-syntax-list! module-saved-environments set-module-saved-environments! - module-iexports set-module-iexports!)) + module-iexports set-module-iexports! +module-rename-list set-module-rename-list!)) (define-record-type module (%make-module name library export-list defined-list exist-list defined-syntax-list undefined-list import-forms meta-import-forms meta-expressions - vexports sexports iexports saved-environments) + vexports sexports iexports saved-environments rename-list) module? (name module-name) ; SYMBOL (library module-library) ; SYMBOL @@ -111,7 +112,8 @@ (sexports module-sexports set-module-sexports!); ((SYMBOL SE TRANSFORMER) ...) (iexports module-iexports set-module-iexports!); ((SYMBOL . SYMBOL) ...) ;; for csi's ",m" command, holds ( . ) - (saved-environments module-saved-environments set-module-saved-environments!)) + (saved-environments module-saved-environments set-module-saved-environments!) + (rename-list module-rename-list set-module-rename-list!)) (define ##sys#module-name module-name) @@ -121,8 +123,9 @@ (module-vexports m) (module-sexports m))) -(define (make-module name lib explist vexports sexports iexports) - (%make-module name lib explist '() '() '() '() '() '() '
Re: CHICKEN 6 + R7RS
> Yes, that's what I mean. It would be fine if foo/bar.sld and foo.bar.scm > would accept either `library` or `define-library`. > You mean "module" or "define-library", I guess? One could make the latter available by default. Depending on how we decide on default semantics for syntax-rules, there might be nothing else to do. felix
Re: [PATCH] Disallow empty "or" type specifier
> Hi all, > > the attached patch makes the `(or)` type specifier invalid, as opposed > to being simplified to `*`. > This is more consistent with the mathematical interpretation of an empty > (sum) type being the bottom type having no inhabitants. > This is very explicit in OCaml, for example, where the empty type is > literally a sum (variant) of 0 types: `type t = |`. Thanks a lot! I've taken the freedom to push this directly, as the change is trivial and only affects validation of user-supplied type signatures. felix
Re: [PATCH] Disallow empty "or" type specifier
> It certainly shouldn't be *, nor should it be an error... technically an > empty union should be a null set, which would correspond to either a > non-extant type or to no return/value at all... Well, the problem is: there is no non-extant type, no "bottom": we simply use the Scheme type system (slightly extended) that clearly describes what types values can have and in Scheme every value has a type, there are no programs that are unsound on the type level - they may break at run-time, but are still valid Scheme code. There are meta-types like "undefined", which is the same as the union of all possible types, but explicitly declared as undefined by the standard. CHICKEN uses other meta types like "*" for convenience, and "or" and "forall" for limiting the possible set of types a value can have, but there are still very much concrete types for concrete values. The number of return values on the other hand is not a type-related concept, it is an operational thing (the number of arguments to pass to the continuation), so I would not mix these two issues. There can be no "(or)"-typed value in a Scheme system, there can be the absence of a return (like calling a continuation), but that is, I believe, the area of effect systems. felix
Re: CHICKEN 6 + R7RS
> I think making r7 syntax by default makes sense as does define- library. > Using sld would be good if (foo bar) imported from foo/bar.sld and not > foo.bar.scm. > How is supposed to be coded? Would that mean foo/bar.sld holds a library definition of this sort: (define-library (foo bar) ...) Note that source files are not imported, they are loaded or compiled. Importing would take place via some import library named (say) "foo.bar.import.so", the source file origin of which could be arbitrary. felix
CHICKEN 6 + R7RS
Hello! John Cowan suggested to add R7RS support to the CHICKEN core in the forthcoming version 6. It certainly is about time to commit a bit more to R7RS (small), since it is, as a standard, reasonably established now. The current mode of support as an egg works quite well, but still feels a somewhat clunky (passing "-X r7rs -R r7rs" to the compiler, for example). The UTF support to appear in C6 already introduces R7RS bytevectors to the core system and it seems to me that core support promises a smoother and more efficient integration of these features when maintained in combination with the base system. So, I think it might not be a bad idea to make the jump, and I would be very interested in getting feedback and to hear what others think of this. The base system should be as compatible to existing CHICKEN code as possible, the UTF transtion will already introduce some pain (but hopefully in an obvious way, so that code can be adapted quickly). So I suggest to add the R7RS modules that the egg currently provides, and compiler options ("-r7rs") and perhaps parameters to switch behaviour to full R7RS compliance, for example enabling R7RS specific syntax-rules behaviour or to make "define-library" available by default. We may then examine whether completely switching semantics to full R7RS for certain parts makes sense, depending on how much code still relies on R5RS semantics. I would also be interested in the ergonomics. An option to csc and csi ("-r7rs") sounds simple, but perhaps a different file extension (".sld") could also be used to assume R7RS code? I'm not quite sure, I haven't thought this through, yet. Ideas and suggestions would be _very_ welcome. cheers, felix
Re: [PATCH] recover CHICKEN_INSTALL_PREFIX
> On Wed, Aug 16, 2023 at 05:25:45PM +0200, felix.winkelm...@bevuta.com wrote: > > > Why are install-path and repo-path in chicken-install.scm still using > > > destination-repository instead of effective-destination-repository? > > > Those are the only places that still use it, aside from one in > > > chicken-status and chicken-uninstall. > > > > The prefix variable is only used for designating where the build > > artifacts are to be stored, not where extensions are located or > > where .egg-info files are to be stored. It also makes sense to set > > CHICKEN_REPOSITORY_PATH in addition to CHICKEN_INSTALL_PREFIX when > > dependency extensions installed and used during the build of another > > extension are needed to be located. This _is_ confusing, no doubt > > about that, but we need a way to override install target locations, > > especially for include-files and binaries and has been requested > > several times by users, IIRC. > > It's extremely confusing and hard to use correctly, but it seems to work > as intended, so I've pushed the patch. > Thanks. As I said, I agree completely that it is not a shining example of software design. The problem is that there is a certain build/install/deployment situation that we can't cover without such a device (unless using horrible workarounds). felix
Re: [PATCH] recover CHICKEN_INSTALL_PREFIX
> Why are install-path and repo-path in chicken-install.scm still using > destination-repository instead of effective-destination-repository? > Those are the only places that still use it, aside from one in > chicken-status and chicken-uninstall. The prefix variable is only used for designating where the build artifacts are to be stored, not where extensions are located or where .egg-info files are to be stored. It also makes sense to set CHICKEN_REPOSITORY_PATH in addition to CHICKEN_INSTALL_PREFIX when dependency extensions installed and used during the build of another extension are needed to be located. This _is_ confusing, no doubt about that, but we need a way to override install target locations, especially for include-files and binaries and has been requested several times by users, IIRC. > > I checked, but if I call chicken-uninstall with CHICKEN_EGG_PREFIX, > it uninstalls (or attempts to uninstall) the egg in the "standard" > location. That means chicken-uninstall doesn't work if you're using > CHICKEN_EGG_PREFIX. You probably mean CHICKEN_INSTALL_PREFIX. But the patch had a bug: the location for .egg-info files needs to be the main repository, only the place of the target files have to be changed and stored in the ..egg-info. The attached new variant of the patch fixes that so that -status and -uninstall work regardless of the prefix setting during -install. > > So why not simply replace the definition of destination-repository > with the new code? Because we have two locations: the normal repository where meta-data is stored and the location where artifacts are stored. felix From b4d82b032491136e35af45a215336c14c2bb70dc Mon Sep 17 00:00:00 2001 From: felix Date: Fri, 21 Jul 2023 15:38:41 +0200 Subject: [PATCH] Allow overriding general installation prefix in "chicken-install" When determining the destination location for extensions, programs, include files and data files, respect CHICKEN_INSTALL_PREFIX (CHICKEN_INSTALL_REPOSITORY still takes precedence for extensions). This variable was actually still existing and used by "chicken-home" and in some places in the "chicken-install" program. This patch removes the former use and makes this variable exclusively a utility for "chicken-install" to override the CHICKEN installation prefix and applies it consistently. --- chicken-install.mdoc | 5 + egg-compile.scm| 32 egg-environment.scm| 9 ++--- library.scm| 5 + manual/Extension tools | 15 ++- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/chicken-install.mdoc b/chicken-install.mdoc index d075a692..4b5d19ff 100644 --- a/chicken-install.mdoc +++ b/chicken-install.mdoc @@ -115,10 +115,15 @@ Following environment variables change the behaviour of .Bl -tag -width CHICKEN_INSTALL_REPOSITORY .It Ev CHICKEN_EGG_CACHE Location where eggs are retrieved and built. +.It Ev CHICKEN_INSTALL_PREFIX +The path prefix for all target files, as given when building the system. +Use this variable to override where programs, include files and additional +data files shall be intalled. .It Ev CHICKEN_INSTALL_REPOSITORY The path where extension libraries are installed. Defaults to the package library path selected during configuration .Pq usually $prefix/lib/chicken/ . +Note that this variable takes precedence to CHICKEN_INSTALL_PREFIX. .It Ev SUDO The command to execute when using .Fl s diff --git a/egg-compile.scm b/egg-compile.scm index 99a94fe8..c9a5565e 100644 --- a/egg-compile.scm +++ b/egg-compile.scm @@ -118,6 +118,14 @@ (define (uses-compiled-import-library? mode) (not (and (eq? mode 'host) staticbuild))) +;; this one overrides "destination-repository" in egg-environment to allow use of +;; CHICKEN_INSTALL_PREFIX (via "override-prefix") +(define (effective-destination-repository mode #!optional run) + (if (eq? 'target mode) + (if run target-run-repo target-repo) + (or (get-environment-variable "CHICKEN_INSTALL_REPOSITORY") + (override-prefix (string-append "/lib/chicken/" (number->string binary-version)) +host-repo ;;; topological sort with cycle check @@ -148,7 +156,7 @@ (error "destination must be relative to CHICKEN install prefix" dest) (normalize-pathname (make-pathname (if (eq? mode 'target) -default-prefix; XXX wrong! +default-prefix (override-prefix "/" host-prefix)) dest*) @@ -228,7 +236,7 @@ (mods #f) (opts opts)) (for-each compile-extension/program (cddr info)) -(let ((dest (destination-repository mode #t)) +(let ((
Re: How should we deal with weak refs to finalizableobjects?_(was:_Re:__[PATCH]_Bugfix_and_drop_weak_references_to_finalizable_objects_(was:_Re:_[PATCH]_thread-safe_handling_of_asynchronous_events))_
> I think here we're struggling with the atomicity of the garbage collector > because the finaliser is special user code that executes inside the garbage > collector's "transaction" and that code has all the power and capabilities > of any other scheme code. Finalizer code is in no way special, and there is no specific GC "transaction" visible from user space. It is just a signal to the user that designates that an object is about to be dropped from automatic memory management . > What happens if there are a circular list of objects all of which have > finalisers? > > The CHICKEN GC usually handles circular lists well, but when this one is > collected (i.e. there are no external strong references to the list > anymore) all its members come up for finalisation at the same time. > > Which order are the finalisers called in? This is undefined. > > ...and which of the other objects can be seen from the object that is > finalised first? I needed to think about this for a moment and you are right in that it is a special case: an object is subject to reclamation (and finalization), if it is "about to be dropped". For circular constructs that have no outside (strong) references pointing to them, they become subject to finalization in "bulk". In between these objects strong refs may still exist, so we must relax our mental model a bit: it's not purely dependent on whether the number of references becomes zero, but a finalizer runs when an object is about to be reclaimed, i.e. when the collector can "prove" this object will be dead if no measures are taken (e.g. medical or spiritual assistance), regardless of references to other soon-to-be dead objects. > When the managed memory for the circular list is freed it does not matter > precisely which order it is freed in because there are no side effects of > freeing it and it all happens in a single GC cycle. > > But when the finalisers are run the user's code will see these objects in > various different states depending on the order. The structural state will be identical for all finalizers - a finalizer does _not_ represent a special execution state, it is ordinary user code, invoked by an oracle (so to speak) that knows that the object will soon be reclaimed. What _may_ happen is that a finalizer is called for an object which another finalizer has already "resurrected", at least that is how I understand it (Peter: correct me if I'm wrong). There is indeed an inconsistency here, but one I consider acceptable, and which has been the case since finalizers were introduced. Weak refs have no relation to that, and clearing them before finalization removes any additional inconsistencies that might arise. cheers felix
Re: [PATCH] recover CHICKEN_INSTALL_PREFIX
> On Fri, Jul 21, 2023 at 03:54:41PM +0200, felix.winkelm...@bevuta.com wrote: > > diff --git a/egg-compile.scm b/egg-compile.scm > > index 99a94fe8..b14535da 100644 > > --- a/egg-compile.scm > > +++ b/egg-compile.scm > > @@ -412,7 +420,7 @@ > > (define (compile-common info walk) > >(case (car info) > > ((target) > > - (when (eq? mode 'target) > > + (when (eq? mode =) > > (for-each walk (cdr info > > ((host) > > (when (eq? mode 'host) > > This hunk looks incorrect. What did you intend to change this to? > Indeed - sorry about that, here an improved version. felix From b0c04962c55b4709fd53ad98a94dd764b41d2639 Mon Sep 17 00:00:00 2001 From: felix Date: Fri, 21 Jul 2023 15:38:41 +0200 Subject: [PATCH] Allow overriding general installation prefix in "chicken-install" When determining the destination location for extensions, programs, include files and data files, respect CHICKEN_INSTALL_PREFIX (CHICKEN_INSTALL_REPOSITORY still takes precedence for extensions). This variable was actually still existing and used by "chicken-home" and in some places in the "chicken-install" program. This patch removes the former use and makes this variable exclusively a utility for "chicken-install" to override the CHICKEN installation prefix and applies it consistently. --- chicken-install.mdoc | 5 + egg-compile.scm| 34 +- egg-environment.scm| 9 ++--- library.scm| 5 + manual/Extension tools | 15 ++- 5 files changed, 47 insertions(+), 21 deletions(-) diff --git a/chicken-install.mdoc b/chicken-install.mdoc index d075a692..4b5d19ff 100644 --- a/chicken-install.mdoc +++ b/chicken-install.mdoc @@ -115,10 +115,15 @@ Following environment variables change the behaviour of .Bl -tag -width CHICKEN_INSTALL_REPOSITORY .It Ev CHICKEN_EGG_CACHE Location where eggs are retrieved and built. +.It Ev CHICKEN_INSTALL_PREFIX +The path prefix for all target files, as given when building the system. +Use this variable to override where programs, include files and additional +data files shall be intalled. .It Ev CHICKEN_INSTALL_REPOSITORY The path where extension libraries are installed. Defaults to the package library path selected during configuration .Pq usually $prefix/lib/chicken/ . +Note that this variable takes precedence to CHICKEN_INSTALL_PREFIX. .It Ev SUDO The command to execute when using .Fl s diff --git a/egg-compile.scm b/egg-compile.scm index 99a94fe8..fd1ac852 100644 --- a/egg-compile.scm +++ b/egg-compile.scm @@ -118,6 +118,14 @@ (define (uses-compiled-import-library? mode) (not (and (eq? mode 'host) staticbuild))) +;; this one overrides "destination-repository" in egg-environment to allow use of +;; CHICKEN_INSTALL_PREFIX (via "override-prefix") +(define (effective-destination-repository mode #!optional run) + (if (eq? 'target mode) + (if run target-run-repo target-repo) + (or (get-environment-variable "CHICKEN_INSTALL_REPOSITORY") + (override-prefix (string-append "/lib/chicken/" (number->string binary-version)) +host-repo ;;; topological sort with cycle check @@ -148,7 +156,7 @@ (error "destination must be relative to CHICKEN install prefix" dest) (normalize-pathname (make-pathname (if (eq? mode 'target) -default-prefix; XXX wrong! +default-prefix (override-prefix "/" host-prefix)) dest*) @@ -228,7 +236,7 @@ (mods #f) (opts opts)) (for-each compile-extension/program (cddr info)) -(let ((dest (destination-repository mode #t)) +(let ((dest (effective-destination-repository mode #t)) ;; Respect install-name if specified (rtarget (or oname target))) (when (eq? #t tfile) (set! tfile rtarget)) @@ -272,7 +280,7 @@ (mods #f) (opts opts)) (for-each compile-extension/program (cddr info)) -(let ((dest (destination-repository mode #t)) +(let ((dest (effective-destination-repository mode #t)) ;; Respect install-name if specified (rtarget (or oname target))) (set! objs @@ -291,7 +299,7 @@ (for-each compile-data/include (cddr info)) (let* ((dest (or (and dest (normalize-destination dest mode)) (if (eq? mode 'target) - default-sharedir; XXX wrong! + default-sharedir
[PATCH] recover CHICKEN_INSTALL_PREFIX
Hi! In complex build environments it is sometimes desirable to overriding where "chicken-install" places programs, include- and data files, for example when packaging. Currently it is possible to set CHICKEN_INSTALL_REPOSITORY to set where extensions are placed and in combination with CHICKEN_REPOSITORY_PATH it allows to have alternative additional egg repositories. But for programs and other files that are not extension .so's and import libs such an override is not possible, yet may still be desirable, for example when packaging eggs or applications that use eggs and contain such "other" types of build artifacts. I'm completely aware that this is not a perfect solution (dependency eggs may produce programs that we need during the build of eggs higher up in the depedency graph), so combination of setting CHICKEN_REPOSITORY_PATH and PATH may still be required. This is a last resort utility, IMHO preferrable to even uglier hacks packages may need in the absence of an alternative. CHICKEN_INSTALL_PREFIX, which this patch uses, was actually already existing previously, some remnants were inadvertendly not removed, most notably in "(chicken-home)". Originally, the variable could be used to override the install prefix at runtime, something that clearly leads to madness, if used wrong. I removed this use and dedicate the variable solely to "chicken-install" now, using it consistently for all installation destinations. felix From 92dbbc049350f2f7f5a60e021221f8b661c96aa5 Mon Sep 17 00:00:00 2001 From: felix Date: Fri, 21 Jul 2023 15:38:41 +0200 Subject: [PATCH] Allow overriding general installation prefix in "chicken-install" When determining the destination location for extensions, programs, include files and data files, respect CHICKEN_INSTALL_PREFIX (CHICKEN_INSTALL_REPOSITORY still takes precedence for extensions). This variable was actually still existing and used by "chicken-home" and in some places in the "chicken-install" program. This patch removes the former use and makes this variable exclusively a utility for "chicken-install" to override the CHICKEN installation prefix and applies it consistently. --- chicken-install.mdoc | 5 + egg-compile.scm| 36 ++-- egg-environment.scm| 9 ++--- library.scm| 5 + manual/Extension tools | 15 ++- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/chicken-install.mdoc b/chicken-install.mdoc index d075a692..4b5d19ff 100644 --- a/chicken-install.mdoc +++ b/chicken-install.mdoc @@ -115,10 +115,15 @@ Following environment variables change the behaviour of .Bl -tag -width CHICKEN_INSTALL_REPOSITORY .It Ev CHICKEN_EGG_CACHE Location where eggs are retrieved and built. +.It Ev CHICKEN_INSTALL_PREFIX +The path prefix for all target files, as given when building the system. +Use this variable to override where programs, include files and additional +data files shall be intalled. .It Ev CHICKEN_INSTALL_REPOSITORY The path where extension libraries are installed. Defaults to the package library path selected during configuration .Pq usually $prefix/lib/chicken/ . +Note that this variable takes precedence to CHICKEN_INSTALL_PREFIX. .It Ev SUDO The command to execute when using .Fl s diff --git a/egg-compile.scm b/egg-compile.scm index 99a94fe8..b14535da 100644 --- a/egg-compile.scm +++ b/egg-compile.scm @@ -118,6 +118,14 @@ (define (uses-compiled-import-library? mode) (not (and (eq? mode 'host) staticbuild))) +;; this one overrides "destination-repository" in egg-environment to allow use of +;; CHICKEN_INSTALL_PREFIX (via "override-prefix") +(define (effective-destination-repository mode #!optional run) + (if (eq? 'target mode) + (if run target-run-repo target-repo) + (or (get-environment-variable "CHICKEN_INSTALL_REPOSITORY") + (override-prefix (string-append "/lib/chicken/" (number->string binary-version)) +host-repo ;;; topological sort with cycle check @@ -148,7 +156,7 @@ (error "destination must be relative to CHICKEN install prefix" dest) (normalize-pathname (make-pathname (if (eq? mode 'target) -default-prefix; XXX wrong! +default-prefix (override-prefix "/" host-prefix)) dest*) @@ -228,7 +236,7 @@ (mods #f) (opts opts)) (for-each compile-extension/program (cddr info)) -(let ((dest (destination-repository mode #t)) +(let ((dest (effective-destination-repository mode #t)) ;; Respect install-name if specified (rtarget (or oname target))) (when (eq? #t tfile
Re: [PATCH] finalizer API (was: thread-safe handling of asynchronousevents)
> On Fri, Jul 07, 2023 at 10:43:29AM +0200, felix.winkelm...@bevuta.com wrote: > > Here another attempt at a finalizer API, allowing adding > > finalized objects to an existing finalizer after it was > > created. > > Thanks, I've pushed both this and the srfi 18 changes. > Should we tag a new srfi-18 release? Indeed - thanks for the hint, I'll do that. felix
Re: [PATCH] fix chicken-install http download bug
> Regarding the situation of the infrastructure: > > * call-cc.org's cache has been fixed (i.e., monocypher 4.0.1-0 has been > removed, and 4.0.1 has been cached -- contents should be identical). > monocypher can be installed from there. > > * kitten-techs' cache at the time of this writing still has monocypher > 4.0.1-0, so chicken-install without the attached patch will fail to > install it from there. I've requested Alaric to remove 4.0.1-0, as > that breaks the installation of monocypher with the current CHICKEN > release. > > * The eggs-5-latest git repository has been manually updated to ship > 4.0.1. > Excellent - much obliged, Mario! felix
[PATCH] fix chicken-install http download bug
The attached patch fixes a problem with chicken-install that caused eggs transmitted via HTTP to be rejected due to a malformed version number. Specifically, "-" was not allowed inside version numbers, and the monocypher egg seemed to be the first one using such a versioning scheme. The patch allows anything bug space and vertical bar and is slightly more strict regarding the format. Thanks to "kniffy" for reporting this and Mario for investigating. felix From eb8c66c36c00371a609d18714ce15fa8478270a8 Mon Sep 17 00:00:00 2001 From: felix Date: Sun, 16 Jul 2023 12:22:07 +0200 Subject: [PATCH] accept dashes in file-version information transmitted via http in chicken-install --- egg-download.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egg-download.scm b/egg-download.scm index b568b3c3..388fa35f 100644 --- a/egg-download.scm +++ b/egg-download.scm @@ -149,7 +149,7 @@ (cond ((or (eof-object? ln) (irregex-match " *#!eof *" ln)) (open-input-string "")) - ((irregex-match " *#\\|[- ]*([^- ]*) *\\|#.*" ln) => + ((irregex-match " *#\\|-+ +([^| ]*) *\\|#.*" ln) => (lambda (m) (let ((v (irregex-match-substring m 1))) (cond ((or (string=? "" v) (string=? "#f" v))) -- 2.40.0
[PATCH] Bugfix and drop weak references to finalizable objects (was: Re: [PATCH] thread-safe handling of asynchronous events)
Pushed. I pushed another commit to handle bwp immediates introduced during compilation, without this compiling the weak-pointer-test failed for me. felix
How should we deal with weak refs to finalizable objects? (was: Re: [PATCH] Bugfix and drop weak references to finalizable objects (was: Re: [PATCH] thread-safe handling of asynchronous events))
After thinking some more about this, I realize that your approach (clearing weak ref's to finalized data) is the right thing, since any other behaviour in the presence of multithreading leads to disaster. Let me elaborate. Finalization is a time of reckoning, a purgatory where an object undergoes a final cleansing of possibly sinful state, of references to things foreign and alien, the dirty underbelly of an objects existence that must be brought to order in ways only the user can truly know about. Since the object is in this state, all its wordly connections have already ceased to exist, its identity forgotten (or it wouldn't be ready for reclamation). But what if other threads access a weakly remembered object while it is in purgatory? They would deal with an empty husk, a ghost, likely to be devoid of the things (external pointers and other resources) that define its true self, a mere shadow, with consequences that do not have to be explicitly mentioned here and are better left unsaid. Should the user (for reasons we can and must never know) decide that the object is not ready yet to go to the other world and should stay for another cycle of suffering in this earthly existence and store the value in some external location, then the object will internally be the same and have the same true identity, but external pointers will have ceased to exist. Strong references are already ensured to be gone and weak references are cleared using the incantations that sjamaan (in his wisdom) proposed (certain enlightened objects that have a sufficiently advanced self conciousness may know their true identity, i.e. keep circular references to itself, but these must necessarily be internal and are irrelevant when seem from outside). So reincarnation means the object _is_ identical, but the nature of its identity is invisible to the outside world. Enlightened objects may know about their true identity but trying to communicate that beyond its inner self is meaningless when seen from the outside. I think this clears things sufficiently up. felix
How should we deal with weak refs to finalizable objects? (was: Re: [PATCH] Bugfix and drop weak references to finalizable objects (was: Re: [PATCH] thread-safe handling of asynchronous events))
> However, there's one more concern: > > > The potential use-after-free scenario can still happen if the object is > > kept alive, regardless of how we handle weak refs, this is unavoidable > > if we allow finalizers and keep the possibility of resurrection. > > I have thought about this a bit more but I came to the conclusion that > from an abstraction point of view it's better to clear weak refs to > finalized data. The reason is that when a module exposes an object, the > *user* should not need to know or care exactly how that object is > implemented and that it happens to use a finalizer. > I concur - it indeed breaks the abstraction. IHMO both behaviours (clearing weak refs or not) have potential to confuse the user, but merely adding a finalizer should not semantically change the behaviour of weak refs. Let me think a bit more about this, please. felix
[PATCH] Bugfix and drop weak references to finalizable objects (was: Re: [PATCH] thread-safe handling of asynchronous events)
> On Thu, Jul 06, 2023 at 09:05:03PM +0200, felix.winkelm...@bevuta.com wrote: > > > This would be problematic if the finalizer has run and deleted the > > > foreign object, while there are still weak references that hold onto > > > the object. This has then become invalid/inconsistent. > > > > I don't understand this, I'm afraid. Finalizers can always "revive" > > objects, this can't be avoided and may sometimes even be required. > > If weak refs suddenly make our memory model unsound, then the whole idea > > of weak references stands to discussion. > > I don't think they make the memory model unsound per say. But it is > an issue, and one avoided by MIT Scheme by simply making it impossible > to revive collected objects. This thread made me consider what to do > with such weak references and I decided that we should clear references > to finalizable (which may already be finalized) objects. > > Attached is a patch to ensure that "live" weak references don't hold > onto objects that may have been processed by a finalizer. I think this > removes the worst potential use-after-free footguns. > I'm not very comfortable with this change. This feels like trading in one inconsistency (weak refs being cleared for a potentially non-dead object) for another (potentially inconsistent ties of GC-controlled memory to non-GC'd resources). Weak pairs and finalization already undermine the strict regime that automatic memory management normally provides, both intended to give the user more control, effectively allowing "manual" management of external resources or limiting the "liveness" of an object. The potential use-after-free scenario can still happen if the object is kept alive, regardless of how we handle weak refs, this is unavoidable if we allow finalizers and keep the possibility of resurrection. Clearing weak refs to objects that may not be dead after all seems to me as the more confusing behaviour, an intendedly kept inconsistency the user has no way to avoid without truly letting go of the object. cheers felix
[PATCH] Bugfix and drop weak references to finalizable objects (was: Re: [PATCH] thread-safe handling of asynchronous events)
> While working on this, I also noticed a remaining bug in the weak locative > handling: when a locative has already been cleared, it contains a NULL > pointer, and we need to avoid dereferencing it on the next GC. Thanks, pushed. felix
[PATCH] finalizer API (was: thread-safe handling of asynchronous events)
Here another attempt at a finalizer API, allowing adding finalized objects to an existing finalizer after it was created. felix From 89b181be98685943425aae646ee724e9d59a2bec Mon Sep 17 00:00:00 2001 From: felix Date: Fri, 7 Jul 2023 10:40:58 +0200 Subject: [PATCH] Added thread-safe finalization method ("make-finalizer") --- NEWS| 2 ++ library.scm | 35 -- manual/Module (chicken gc) | 38 ++--- srfi-4.scm | 18 +- tests/test-finalizers-2.scm | 18 ++ types.db| 2 ++ 6 files changed, 99 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 68940ef5..40866cb5 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ the first non-runtime option or after "-:", whichever comes first. - Core libraries + - Added "make-finalizer" to execute finalizers in a thread-safe +manner. - Added weak pairs to (chicken base), with similar behaviour to Chez Scheme. - Added "locative-index", kindly contributed by John Croisant. - Added "fp*+" (fused multiply-add) to "chicken.flonum" module diff --git a/library.scm b/library.scm index 989f421f..67520e36 100644 --- a/library.scm +++ b/library.scm @@ -6152,7 +6152,8 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { (module chicken.gc -(current-gc-milliseconds gc memory-statistics set-finalizer! +(current-gc-milliseconds gc memory-statistics + set-finalizer! make-finalizer add-to-finalizer set-gc-report! force-finalizers) (import scheme) @@ -6186,7 +6187,7 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { (define ##sys#set-finalizer! (##core#primitive "C_register_finalizer")) -(define set-finalizer! +(define ##sys#init-finalizer (let ((string-append string-append)) (lambda (x y) (when (fx>= (##core#inline "C_i_live_finalizer_count") _max_pending_finalizers) @@ -6216,6 +6217,36 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { (##sys#force-finalizers) ) ) ) (##sys#set-finalizer! x y) ) ) ) +(define set-finalizer! ##sys#init-finalizer) + +(define finalizer-tag (vector 'finalizer)) + +(define (finalizer? x) + (and (pair? x) (eq? finalizer-tag (##sys#slot x 0))) ) + +(define (make-finalizer . objects) + (let ((q (##sys#make-event-queue))) +(define (handler o) (##sys#add-event-to-queue! q o)) +(define (handle o) (##sys#init-finalizer o handler)) +(for-each handle objects) +(##sys#decorate-lambda + (lambda (#!optional mode) + (if mode + (##sys#wait-for-next-event q) + (##sys#get-next-event q))) + finalizer? + (lambda (proc i) + (##sys#setslot proc i (cons finalizer-tag handle)) + proc + +(define (add-to-finalizer f . objects) + (let ((af (and (procedure? f) + (##sys#lambda-decoration f finalizer? +(unless af + (error 'add-to-finalizer "bad argument type - not a finalizer procedure" + f)) +(for-each (cdr af) objects))) + (define ##sys#run-pending-finalizers (let ((vector-fill! vector-fill!) (string-append string-append) diff --git a/manual/Module (chicken gc) b/manual/Module (chicken gc) index 48653e3a..ed3a077e 100644 --- a/manual/Module (chicken gc) +++ b/manual/Module (chicken gc) @@ -40,11 +40,11 @@ because CHICKEN uses a copying semi-space collector. Registers a procedure of one argument {{PROC}}, that will be called as soon as the non-immediate data object {{X}} is about to be garbage-collected (with that object as its argument). Note that -the finalizer will '''not''' be called while interrupts are disabled. This procedure returns {{X}}. -Finalizers are invoked asynchronously, in the thread that happens -to be currently running. Finalizers for data that has become garbage +Finalizers installed using {{set-finalizer!}} are invoked asynchronously, +in the thread that happens to be currently running. +Finalizers for data that has become garbage are called on normal program exit. Finalizers are not run on abnormal program exit. A normal program exit does not run finalizers that are still reachable from global data. @@ -53,6 +53,38 @@ Multiple finalizers can be registered for the same object. The order in which the finalizers run is undefined. Execution of finalizers may be nested. +Note that +the finalizer will '''not''' be called while interrupts are disabled. + +=== make-finalizer + +(make-finalizer OBJECT ...) + +Registers the set of non-immediate argument objects for finalization and +returns a procedure of zero or one arguments. Invoking this procedure +will return the first object from the set that +is not referenced from any other globally reachable data and can be +garbage collected. +Non-immediate objects are anything t
Re: [PATCH] thread-safe handling of asynchronous events
> On Wed, Jul 05, 2023 at 03:28:54PM +0200, felix.winkelm...@bevuta.com wrote: > > The first patch provides the event-queue mechanism and cleans up the > > scheduler a bit (hiding internal variables while also exposing ##sys#... > > procedures to access them). This also defines hooks that a threading > > API should override to allow suspension/resumption on events. > > I'm not super happy with exposing ##sys#fd-list and ##sys#timeout-list as > a procedure under the exact same name that originally held a list. > If there's any code that uses it, that would lead to strange errors. > Might be better to either not expose it at all, or use a completely > different name. > Here new patches for the scheduler and srfi-18 changes, with the exposed accessors having now lame but concistent names. felix From ae180fc08f8a63edb823c5cbf94de682c10ef602 Mon Sep 17 00:00:00 2001 From: felix Date: Thu, 6 Jul 2023 21:22:18 +0200 Subject: [PATCH] add internal event-queue mechanism and hooks for threading API, expose accessors to internal task lists. --- library.scm | 71 - scheduler.scm | 88 +++ 2 files changed, 116 insertions(+), 43 deletions(-) diff --git a/library.scm b/library.scm index b04b330a..989f421f 100644 --- a/library.scm +++ b/library.scm @@ -44,6 +44,7 @@ ##sys#default-read-info-hook ##sys#infix-list-hook ##sys#sharp-number-hook ##sys#user-print-hook ##sys#user-interrupt-hook ##sys#windows-platform + ##sys#resume-thread-on-event ##sys#suspend-thread-on-event ##sys#schedule ##sys#features) (foreign-declare #< @@ -152,7 +153,13 @@ signal_debug_event(C_word mode, C_word msg, C_word args) C_debugger(, 3, av); return C_SCHEME_UNDEFINED; } - + +static C_word C_i_sleep_until_interrupt(C_word secs) +{ + while(C_i_process_sleep(secs) == C_fix(-1) && errno == EINTR); + return C_SCHEME_UNDEFINED; +} + #ifdef NO_DLOAD2 # define HAVE_DLOAD 0 #else @@ -5738,6 +5745,68 @@ EOF (define (##sys#kill-other-threads thunk) (thunk)) ; does nothing, will be modified by scheduler.scm +;; these two procedures should redefined in thread APIs (e.g. srfi-18): +(define (##sys#resume-thread-on-event t) #f) + +(define (##sys#suspend-thread-on-event t) + ;; wait until signal handler fires. If we are only waiting for a finalizer, + ;; then this will wait forever: + (##sys#sleep-until-interrupt)) + +(define (##sys#sleep-until-interrupt) + (##core#inline "C_i_sleep_until_interrupt" 100) + (##sys#dispatch-interrupt (lambda _ #f))) + + +;;; event queues (for signals and finalizers) + +(define (##sys#make-event-queue) + (##sys#make-structure 'event-queue +'() ; head +'() ; tail +#f)) ; suspended thread + +(define (##sys#add-event-to-queue! q e) + (let ((h (##sys#slot q 1)) +(t (##sys#slot q 2)) +(item (cons e '( +(if (null? h) +(##sys#setslot q 1 item) +(##sys#setslot t 1 item)) +(##sys#setslot q 2 item) +(let ((st (##sys#slot q 3))) ; thread suspended? + (when st +(##sys#setslot q 3 #f) +(##sys#resume-thread-on-event st) + +(define (##sys#get-next-event q) + (let ((st (##sys#slot q 3))) +(and (not st) + (let ((h (##sys#slot q 1))) + (and (not (null? h)) +(let ((x (##sys#slot h 0)) + (n (##sys#slot h 1))) + (##sys#setslot q 1 n) + (when (null? n) (##sys#setslot q 2 '())) + x)) + +(define (##sys#wait-for-next-event q) + (let ((st (##sys#slot q 3))) +(when st + (##sys#signal-hook #:runtime-error #f "event queue blocked" q)) +(let again () + (let ((h (##sys#slot q 1))) +(cond ((null? h) + (##sys#setslot q 3 ##sys#current-thread) + (##sys#suspend-thread-on-event ##sys#current-thread) + (again)) + (else +(let ((x (##sys#slot h 0)) + (n (##sys#slot h 1))) + (##sys#setslot q 1 n) + (when (null? n) (##sys#setslot q 2 '())) + x))) + ;;; Sleeping: diff --git a/scheduler.scm b/scheduler.scm index cbada6fb..759db957 100644 --- a/scheduler.scm +++ b/scheduler.scm @@ -29,7 +29,7 @@ (unit scheduler) (uses extras) ; for sprintf (disable-interrupts) - (hide ready-queue-head ready-queue-tail ##sys#timeout-list + (hide ready-queue-head ready-queue-tail timeout-list fd-list ##sys#update-thread-state-buffer ##sys#restore-thread-state-buffer ##sys#unblock-threads-for-i/o ;; This isn't hidden ATM to allow set!ing it as a hook/workaround @@ -105,7 +105,7 @@ static int C_fdset_nfds; static struct pollfd *C_fdset_set = NULL; inline
Re: [PATCH] thread-safe handling of asynchronous events
> Perhaps simply we can just return two values? The first a polling > procedure and the second a procedure to add new objects to the > finalizer? You can just receive the polling procedure in a > single-value context and ignore the object-adder if you don't want > to use it. That was also my thought. The problem here is that having a single finalizer proc makes it possible to finalize on that procedure as well. Splitting it into consumer/adder now has two procs holding on to the queue and both must be released. > > Alternatively, make-finalizer could return a new structure type that > represents the finalizer. It could just be a wrapper for the queue > internally. We'd have to add a getter and an adder procedure that > accepts this new object type (and perhaps a predicate). Also an idea. Currently I prefer the following approach. I somehow like the elegance of having a single procedure instead of creating yet another data type and the usual bunch of operators. (make-finalizer OBJ ...) as before, but returns a "decorated" proc. (add-to-finalizer FPROC OBJ ...) extract the decoration and add finalizers to the objects finalizable via the already existing FPROC. > > > Separating the collectable object from the context prevents the > > > collected object from re-entering the live system through the > > > finalization procedure (it may set! some variable to it, for example > > > and that's not desirable). Apparently, this makes ephemerons easier to > > > implement. > > > I found this through Taylor Campbell's comment on Andy Wingo's blog post: > > > https://wingolog.org/archives/2022/10/31/ephemerons-and-finalizers > > > > I don't quite understand why many APIs are so afraid of retaining > > the finalized object. The point is becoming aware of the object > > being reclaimable. If it survives yet another GC cycle, so what? > > This would be problematic if the finalizer has run and deleted the > foreign object, while there are still weak references that hold onto > the object. This has then become invalid/inconsistent. I don't understand this, I'm afraid. Finalizers can always "revive" objects, this can't be avoided and may sometimes even be required. If weak refs suddenly make our memory model unsound, then the whole idea of weak references stands to discussion. > > And vice versa, if there are weak references which are now broken, and > the finalizer restores the object, this might cause different kinds of > inconsistencies to arise. The user is already fiddling with the consistency of the pointer universe when using weak refs. I see no way to address this here without removing weak refs or finalization. felix
Re: [PATCH] thread-safe handling of asynchronous events
now if it can be > done easily, but it would allow GUI libraries to hook into this too > by having an event loop provide events into a queue that a Scheme > thread waits for. That sounds good, and I understand the motivation but I don't want to touch the scheduler, to be honest. The UTF transition is already enough work as it is. The original subject is merely a question of API choice, let's not try to fix everything right now. I will try to come up with something better, to allow adding objects to an existing finalizer. felix
[PATCH] fix corner case in chicken-install
Reported by "siiky": numeric egg versions could result in failed calls to "make-pathname". felix From d078a4249fb29cb981b5ea4771de1cbf151c8aed Mon Sep 17 00:00:00 2001 From: felix Date: Wed, 5 Jul 2023 19:26:19 +0200 Subject: [PATCH] handle numeric version properly when constructing egg paths in chicken-install (reported by "siiky") --- chicken-install.scm | 9 ++--- manual/Acknowledgements | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/chicken-install.scm b/chicken-install.scm index 4a6eb9b1..75f20b9c 100644 --- a/chicken-install.scm +++ b/chicken-install.scm @@ -486,12 +486,14 @@ (else ;; ///.egg (if version - (values (probe-dir (make-pathname egg-dir version)) version) + (values (probe-dir (make-pathname egg-dir (->string version))) + version) (let ((versions (directory egg-dir))) (if (null? versions) (values #f #f) (let ((latest (car (sort versions version>=? - (values (make-pathname egg-dir latest) latest) + (values (make-pathname egg-dir (->string latest)) + latest) (define (write-cache-metadata egg-cache-dir egg-version) (when egg-version @@ -576,7 +578,8 @@ (loop (cdr srvs))) ;; The order of probe-dir's here is important. First try ;; the path with version, then the path without version. - ((or (probe-dir (make-pathname (list (car locs) name) lversion)) + ((or (probe-dir (make-pathname (list (car locs) name) + (->string lversion))) (probe-dir (make-pathname (car locs) name))) => (lambda (dir) ;; for locally available eggs, check set of files and diff --git a/manual/Acknowledgements b/manual/Acknowledgements index b9e81398..433103ea 100644 --- a/manual/Acknowledgements +++ b/manual/Acknowledgements @@ -45,7 +45,7 @@ Andreas Rottman, David Rush, Lars Rustemeier, Daniel Sadilek, Otavio Salvador, Burton Samograd, "Sandro", "satori", Aleksej Saushev, Oskar Schirmer, Vasilij Schneidermann, Reed Sheridan, Ronald Schröder, Spencer Schumann, Ivan Shcheklein, Alexander Shendi, Alex Shinn, Ivan -Shmakov, "Shmul", Tony Sidaway, Jeffrey B. Siegal, Andrey Sidorenko, +Shmakov, "Shmul", "siiky", Tony Sidaway, Jeffrey B. Siegal, Andrey Sidorenko, Michele Simionato, Iruata Souza, Volker Stolz, Jon Strait, Dorai Sitaram, Robert Skeels, Sandra Snan, Jason Songhurst, Clifford Stein, David Steiner, "Sunnan", Zbigniew Szadkowski, Rick Taube, Nathan Thern, Mike Thomas, Minh -- 2.33.0
[PATCH] fix "tail?"
Reported by "acdw": make "tail?" more robust. Also generalizes it to accept all types of data, remove unneeded fast path expecting proper list argument. felix From dfffba54fb25bec0faa80127ed43fa3fd7cd4541 Mon Sep 17 00:00:00 2001 From: felix Date: Wed, 5 Jul 2023 19:25:04 +0200 Subject: [PATCH] make "tail?" more general and avoid segfault when passed an improper list (reported by "acdw") --- library.scm | 11 ++- manual/Acknowledgements | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/library.scm b/library.scm index b04b330a..ef7cefea 100644 --- a/library.scm +++ b/library.scm @@ -821,11 +821,12 @@ EOF (define (tail? x y) (##sys#check-list y 'tail?) - (or (##core#inline "C_eqp" x '()) - (let loop ((y y)) - (cond ((##core#inline "C_eqp" y '()) #f) - ((##core#inline "C_eqp" x y) #t) - (else (loop (##sys#slot y 1))) ) ) ) ) + (let loop ((y y)) +(cond ((##core#inline "C_eqp" x y) #t) + ((and (##core#inline "C_blockp" y) +(##core#inline "C_pairp" y)) + (loop (##sys#slot y 1))) + (else #f (define intersperse (lambda (lst x) diff --git a/manual/Acknowledgements b/manual/Acknowledgements index b9e81398..5923d4c7 100644 --- a/manual/Acknowledgements +++ b/manual/Acknowledgements @@ -2,7 +2,7 @@ == Acknowledgements -Many thanks to "alicemaz", Jules Altfas, Nico Amtsberg, Alonso Andres, William +Many thanks to "alicemaz", "acdw", Jules Altfas, Nico Amtsberg, Alonso Andres, William Annis, Jason E. Aten, Marc Baily, Peter Barabas, Andrei Barbu, Jonah Beckford, Arto Bendiken, Andy Bennett, Kevin Beranek, Peter Bex, Jean-Francois Bignolles, Oivind Binde, Alaric Blagrave Snell-Pym, Dave -- 2.33.0
[PATCH] thread-safe handling of asynchronous events
Hello! Currently we have no thread-safe way of handling asynchronous events like POSIX signals and finalization. In both situations, the signal handler and finalization procedures are called in whatever thread is currently executing, which is a source of potential deadlocks in a multithreaded environment. One approach would be to have a dedicated thread for these events, but after studying existing APIs like Chez' "guardians" (for finalization) and the Racket signal interface, a "pull" interface that lets the user ask explicitly for such events appears to provide maximum control and still can be integrated into a threaded environment with relative ease. Therefore I provide 4 patches that implement an internal "event-queue" mechanism and revised finalization and signal API based on these queues. The basic principle is to associate a handler procedure with a queue of asynchronous events. Calling the handler retrieves events from the queue, either non-blocking or blocking. These events are not associated with a thread, but with a procedure, allowing the separation of the points in time when the event is triggered and the moment it is handled. The first patch provides the event-queue mechanism and cleans up the scheduler a bit (hiding internal variables while also exposing ##sys#... procedures to access them). This also defines hooks that a threading API should override to allow suspension/resumption on events. The second patch provides a new signal API: "make-signal-handler", which creates a handler for one or more signals and "signal-ignore" and "signal-default" (to ignore a signal or set the default disposition). This is roughly modelled after the Racket API. The old "signal-handler" and "set-signal-handler!" procedures have been deprecated. The third patch provides "make-finalizer", inspired by Chez' guardians, but slightly different to allow blocking/non-blocking tests for finalizations. The old API is still available, as often finalization performs only very basic operations independent of the currently executing context. Finalization procedures can be composed, as a finalizer itself becomes subject to finalization once all associated objects have been collected. Building guardians on top of this should be straightforward, but the latter does not (to my knowledge) allow blocking a thread until a finalizer triggers so I chose not to implement this interface. The fourth patch extends srfi-18 to set the hooks defined in the first patch. This patch uses some definitions from the scheduler.scm changes but does not directly depend on them (the hooks will never be invoked). Note that the basic C/Scheme glue for finalizers and signals has not been touched, these changes merely provide a different interface. The scheduler cleanup is only superficial and mostly for exposing whether threads are ready or waiting and to provide some syntactic consistency. I tried my best to split these changes into meaningful patches, but my relation to git is a troubled one, and the changes to NEWS are likely to result in conflicts anyway, so expect some fiddling. cheers, felix From 2374d7653f6aca7b3d28e84a6338899a424ff2ed Mon Sep 17 00:00:00 2001 From: felix Date: Wed, 5 Jul 2023 14:58:24 +0200 Subject: [PATCH] add internal event-queue mechanism and hooks for threading API --- library.scm | 73 -- scheduler.scm | 88 +++ 2 files changed, 117 insertions(+), 44 deletions(-) diff --git a/library.scm b/library.scm index b04b330a..a5a01853 100644 --- a/library.scm +++ b/library.scm @@ -31,7 +31,7 @@ (disable-interrupts) (hide ##sys#dynamic-unwind ##sys#vector-resize ##sys#default-parameter-vector - current-print-length setter-tag + current-print-length setter-tag ##sys#print-exit ##sys#format-here-doc-warning exit-in-progress cleanup-before-exit chicken.base#cleanup-tasks @@ -44,6 +44,7 @@ ##sys#default-read-info-hook ##sys#infix-list-hook ##sys#sharp-number-hook ##sys#user-print-hook ##sys#user-interrupt-hook ##sys#windows-platform + ##sys#resume-thread-on-event ##sys#suspend-thread-on-event ##sys#schedule ##sys#features) (foreign-declare #< @@ -152,7 +153,13 @@ signal_debug_event(C_word mode, C_word msg, C_word args) C_debugger(, 3, av); return C_SCHEME_UNDEFINED; } - + +static C_word C_i_sleep_until_interrupt(C_word secs) +{ + while(C_i_process_sleep(secs) == C_fix(-1) && errno == EINTR); + return C_SCHEME_UNDEFINED; +} + #ifdef NO_DLOAD2 # define HAVE_DLOAD 0 #else @@ -5738,6 +5745,68 @@ EOF (define (##sys#kill-other-threads thunk) (thunk)) ; does nothing, will be modified by scheduler.scm +;; these two procedures should redefined in thread APIs (e.g. srfi-18): +(define (##sys#resume-thread-on-event t) #f
Re: [PATCH] Fix get-call-chain thread filtering
> Hi there, > > The attached patch fixes a small but important oversight in > get-call-chain. With this patch, the "trace" egg's tests pass again. > Pushed. felix
[PATCH] Restore read/source-info in support.scm and export it officially from (chicken syntax)
> Hi all, > > I was checking the Salmonella results and it seems a good number of eggs > are actually relying on chicken.compiler.support#read/source-info and > therefore break with the current master: > http://salmonella-linux-x86.call-cc.org/master/clang/linux/x86/2023/06/28/yesterday-diff/ > > The attached patch restores the procedure in support.scm, but keeps the > implementation itself in chicken.syntax, where it makes more sense. > Since these eggs are using it, that TODO above ##sys#read/source-info > is settled - it's useful enough for those eggs, so let's just expose > it publically and document it. > Thanks, pushed. felix
Re: [PATCH] Use weak chain approach for locatives, too
> Hi all, > > Here's a patch to replace the locative table with the same approach we > use for weak pair tracking. Not much to say, the idea is simple, the > patch a bit bigger (because it rips out the locative table). Thanks a lot, Peter! Signed off and pushed. felix
Re: [PATCH] Add line number tracking to the interpreter
Merged and pushed. Excellent work, as usual. Please let me point out how extremely well structured and documented these changes are. Well done, Peter. cheers, felix
Re: [PATCH] fix some problems with the SRFI-4 syntax extensions added recently
> > As Peter remarks, this code is too hairy. I added a comment trying > > to explain the reason for this. > > Thanks for adding a bit of explanation. Are the lists really that long > though? I'd expect this syntax to be used only in user-typed literals, > not in data to be read in. I was thinking of source code, holding large tables of data, for which this syntax may be useful, perhaps loaded on demand. But it is just a guess, if you think the hairyness is not warranted, I can simplify it. felix
Re: [PATCH] Add line number tracking to the interpreter
> Hi all, > > I noticed that the interpreter got quite a bit slower due to fetching > the line number information for an expression when emitting info into > the trace buffer. Attached is an additional patch to bring things back > to our original performance by pre-fetching the line number info and > passing it as an additional argument to emit-trace-info. > > Patch has also been pushed to the line-numbers-in-csi branch. > Thanks, Peter. I will review and test and merge this, unless there is some unexpected problem. felix
[PATCH] fix some problems with the SRFI-4 syntax extensions added recently
Hi! Attached a patch to fix some problems with the newly introduced extension to SRFI-4 vector read syntax. "Siiky" pointed out a bogus empty string comparison and further testing showed that empty strings were not handled properly in certain situations. As Peter remarks, this code is too hairy. I added a comment trying to explain the reason for this. felix From ae6b2a23b3fa219315acc9aea9ec4f43d320b9a8 Mon Sep 17 00:00:00 2001 From: felix Date: Sat, 24 Jun 2023 22:49:55 +0200 Subject: [PATCH] fix empty-string check when reading extended number vectors (reported by siiky) --- srfi-4.scm | 11 +-- tests/srfi-4-tests.scm | 4 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/srfi-4.scm b/srfi-4.scm index 8b990779..0d908f0c 100644 --- a/srfi-4.scm +++ b/srfi-4.scm @@ -612,6 +612,11 @@ EOF ;;; Read syntax: +;; This code is too complicated. We try to avoid mapping over +;; a potentially large list anc creating lots of garbage in the +;; process, therefore the final result list is constructed +;; via destructive updates and thus rather inelegant yet avoids +;; any re-consing unless elements are non-numeric. (define (canonicalize-number-list! lst1) (let loop ((lst lst1) (prev #f)) (if (and (##core#inline "C_blockp" lst) @@ -619,7 +624,7 @@ EOF (let retry ((x (##sys#slot lst 0))) (cond ((char? x) (retry (##sys#char->utf8-string x))) ((string? x) - (if (eq? x "") + (if (zero? (string-length x)) (loop (##sys#slot lst 1) prev) (let loop2 ((ns (string->list x)) (prev prev)) (let ((n (cons (char->integer (##sys#slot ns 0)) @@ -632,7 +637,9 @@ EOF (loop (##sys#slot lst 1) n) (loop2 (##sys#slot ns 1) n))) (else (loop (##sys#slot lst 1) lst -lst1))) +(cond (prev (##sys#setslot prev 1 '()) +lst1) + (else '()) (set! ##sys#user-read-hook (let ([old-hook ##sys#user-read-hook] diff --git a/tests/srfi-4-tests.scm b/tests/srfi-4-tests.scm index 7e0548cb..9fa498fc 100644 --- a/tests/srfi-4-tests.scm +++ b/tests/srfi-4-tests.scm @@ -163,6 +163,10 @@ (let ((cases '(("#u8(1 2 #\\A)" #u8(1 2 65)) ("#u8(\"abc\")" #u8(97 98 99)) ("#u8\"abc\"" #u8(97 98 99)) + ("#u8(\"\")" #u8()) + ("#u8(\"\" \"a\")" #u8(97)) + ("#u8(\"a\" \"\")" #u8(97)) + ("#u8\"\"" #u8()) ("#s8\"\"" #s8()) ("#u64(\" \" #\\! 1 \"A\")" #u64(32 33 1 65)) ("#u64(\" \" #\\! \"A\" 1)" #u64(32 33 65 1) -- 2.33.0
Re: [PATCH] Extend SRFI-4 vector syntax
> On Wed, Jun 07, 2023 at 09:12:51PM +0200, felix.winkelm...@bevuta.com wrote: > > This patch allows strings and chars in homogenous number vectors, > > as suggested by klm at the meetup. > > Code is a bit hairy, but seems to work. Pushed! > Actually, too Hairy. As pointed out by "siiky", the (eq? x "") is bogus and I discovered a few corner cases that produce an error when empty strings are used. I will provide a fix. felix
Re: [PATCH] Add user-facing weak pair API
> Attached are 5 patches to add the weak pair support. I've also pushed > this to the git repo under the "user-facing-weak-pairs" branch. This branch has been merged into master. Thanks a lot for this excellent piece of work, Peter! cheers, felix
[PATCH] fix segfault in csi's ",d"
Attached patch fixes a segfault when trying to describe a brokwn weak ptr. I also added a clause in the case construct to dispatch on a described value to catch unknown immediate values instead of crashing in the locative test (which expects block values). felix From 9b104e139f8dda862a3a78876b832514b0b1a76b Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 19 Jun 2023 13:35:55 +0200 Subject: [PATCH] handle #!bwp in csi's "describe" function properly also adds guard clause to avoid segfault for newly introduced immediate types. --- csi.scm | 6 ++ 1 file changed, 6 insertions(+) diff --git a/csi.scm b/csi.scm index ea618521..b3db4521 100644 --- a/csi.scm +++ b/csi.scm @@ -592,6 +592,9 @@ EOF ((eq? x #t) (fprintf out "boolean true~%")) ((eq? x #f) (fprintf out "boolean false~%")) ((null? x) (fprintf out "empty list~%")) +((##core#inline "C_bwpp" x) + ;; TODO: replace with bwp-object? later + (fprintf out "broken weak pointer~%")) ((eof-object? x) (fprintf out "end-of-file object~%")) ((eq? (##sys#void) x) (fprintf out "unspecified object~%")) ((fixnum? x) @@ -657,6 +660,9 @@ EOF (##sys#slot x 7) (##sys#slot x 3) (##sys#peek-unsigned-integer x 0) ) ) +((not (##core#inline "C_blockp" x)) + ;; catch immediates here, as ##sys#locative? crashes on non-block + (fprintf out "unknown immediate object~%")) ((##sys#locative? x) (fprintf out "locative~% pointer ~X~% index ~A~% type ~A~%" (##sys#peek-unsigned-integer x 0) -- 2.33.0
[PATCH] Allow collecting weak pairs in minor GC (was: Re: [PATCH] Add user-facing weak pair API)
Well done, Peter! I will review the patches and do some tests and then we can decide when to integrate this. felix
[PATCH] Extend SRFI-4 vector syntax
This patch allows strings and chars in homogenous number vectors, as suggested by klm at the meetup. felix From ce2026c3d7cb08d5f88d006cc13dfec3b1f3e4bd Mon Sep 17 00:00:00 2001 From: felix Date: Wed, 7 Jun 2023 20:20:08 +0200 Subject: [PATCH] Allow string and character literals in SRFI-4 vector literals --- NEWS | 2 ++ manual/Module srfi-4 | 17 + srfi-4.scm | 36 tests/srfi-4-tests.scm | 14 ++ 4 files changed, 65 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index c181866f..66c141a3 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ (suggested by Christian Himpe). - The `process-execute` procedure now sets argv[0] to the unmodified filename. Previously, the directory part would be stripped. + - Added support for embedded strings and characters in SRFI-4 vector +literals. - Tools - The -R option for csi and csc now accepts list-notation like diff --git a/manual/Module srfi-4 b/manual/Module srfi-4 index 9eb2..2f72ac0b 100644 --- a/manual/Module srfi-4 +++ b/manual/Module srfi-4 @@ -191,6 +191,23 @@ will set {{x}} to the object {{#u8(1 2 3)}}. Since CHICKEN 4.9.0, literal homoge `(,x #u8(1 2)); legal `#u8(1 ,x 2) ; illegal +Elements may also be characters or strings, in that case they are interpreted +as a sequence of numerical character codes. For example, + + '#u8(#\x7f "EL" #\F 2 1) + +is equivalent to + + '#u8(#\x7f #\x45 #\x4c #\x46 2 1) + +Character literals inside numeric vectors expand into the UTF-8 sequence of +the characters they represent, for strings the contained characters +are interpreted in whatever encoding is used for the text file or stream +in which the literal appears. + +Note that {{#u8"..."}} can be used as an abbreviation for the special case +{{#u8("...")}}. + === Predicates (u8vector? OBJ) diff --git a/srfi-4.scm b/srfi-4.scm index e8bddec5..8b990779 100644 --- a/srfi-4.scm +++ b/srfi-4.scm @@ -434,7 +434,7 @@ EOF ((##core#inline "C_eqp" p '()) v) (if (and (##core#inline "C_blockp" p) (##core#inline "C_pairp" p)) (,set v i (##core#inline "C_slot" p 0)) - (##sys#error-not-a-proper-list lst) ) ) ) ))) + (##sys#error-not-a-proper-list lst ',name) ) ) ) ))) (list->NNNvector u8vector) (list->NNNvector s8vector) @@ -612,6 +612,28 @@ EOF ;;; Read syntax: +(define (canonicalize-number-list! lst1) + (let loop ((lst lst1) (prev #f)) +(if (and (##core#inline "C_blockp" lst) + (##core#inline "C_pairp" lst)) +(let retry ((x (##sys#slot lst 0))) + (cond ((char? x) (retry (##sys#char->utf8-string x))) +((string? x) + (if (eq? x "") + (loop (##sys#slot lst 1) prev) + (let loop2 ((ns (string->list x)) (prev prev)) + (let ((n (cons (char->integer (##sys#slot ns 0)) + (##sys#slot lst 1 + (if prev + (##sys#setslot prev 1 n) + (set! lst1 n)) + (let ((ns2 (##sys#slot ns 1))) + (if (null? ns2) + (loop (##sys#slot lst 1) n) + (loop2 (##sys#slot ns 1) n))) +(else (loop (##sys#slot lst 1) lst +lst1))) + (set! ##sys#user-read-hook (let ([old-hook ##sys#user-read-hook] [read read] @@ -629,9 +651,15 @@ EOF (if (memq char '(#\u #\s #\f #\U #\S #\F)) (let* ([x (read port)] [tag (and (symbol? x) x)] ) - (cond [(or (eq? tag 'f) (eq? tag 'F)) #f] - [(memq tag consers) => (lambda (c) ((##sys#slot (##sys#slot c 1) 0) (read port)))] - [else (##sys#read-error port "illegal bytevector syntax" tag)] ) ) + (cond ((or (eq? tag 'f) (eq? tag 'F)) #f) + ((memq tag consers) => +(lambda (c) + (let ((val (read port))) +(if (string? val) +(set! val (map char->integer (string->list val))) +(set! val (canonicalize-number-list! val))) +((##sys#slot (##sys#slot c 1) 0) val + (else (##sys#read-error port "illegal bytevector syntax" tag)) ) ) (old-hook char port) ) ) ) ) diff --git a/tests/srfi-4-tests.scm b/tests/srfi-4-tests.scm index 10f3ce7c..7e0548cb 100644 --- a/tests/srfi-4-tests.scm +++ b/tests/srfi-4-tests.scm @@ -157,3 +157,17 @@ (assert (handle-exceptions exn #t (make-f64vector mos
Re: [PATCH] Add user-facing weak pair API
> On Tue, Jun 06, 2023 at 07:46:10PM +0200, felix.winkelm...@bevuta.com wrote: > > > Do we even want to make a 5.4 release at all? > > > > I would suggest to add this for 5.4, for the reasons you > > state. I also would be for making at least one minor release > > before C6, as I doubt that we will get UTF support with > > all the eggs into a robust state that soon. Code that > > wants to test for this feature could cond-expand on 5.4 > > (and later versions). > > Sure, that's probably the better way to go. Perhaps the feature > name should simply be "weak-pairs". WDYT? I wasn't actually thinking of a specific feature name (just the version), but we can do it that way, it seems like that makes it more convenient for the user. felix
Re: [PATCH] Add user-facing weak pair API
> On Sat, Jun 03, 2023 at 11:12:40PM +0200, Peter Bex wrote: > > Dear hackers, > > > > At the Village CHICKENs event, I gave a presentation about how we could > > add "proper" support for weak pairs, so that they can be exposed to the > > user. Right now we have half-baked support for weak pairs as a hidden > > implementation detail of the symbol table. > > PS: I'm not sure if this should go into 5.4 or 6.0. On the one hand, > it's a relatively minor addition to the API. On the other hand, if > anyone wants to rely on it we might need to provide a feature for it > whereas in 6.0 it would be trivial. > > Do we even want to make a 5.4 release at all? I would suggest to add this for 5.4, for the reasons you state. I also would be for making at least one minor release before C6, as I doubt that we will get UTF support with all the eggs into a robust state that soon. Code that wants to test for this feature could cond-expand on 5.4 (and later versions). felix
Extending the #u8(...) notation
Hi! Kristian Lein-Mathisen suggested an extension to the bytevector syntax for SRFI-4 and R7RS bytevectors (which becomes more relevant in the forthcoming UTF-aware CHICKEN) which seems quite practical. I'd be eager to know how useful other users consider this feature before I submit a patch. Basically, it just means to allow strings and character literals as elements of byte vectors written as "#u8(...)". Strings would then designate UTF-8 byte sequences, with characters being the same (equivalent to a 1-length string), so you could write: #u8(0x7f "EL" #\F ...) being the same as: #u8(0x7f 0x45 0x4c 0x46 ...) This is incompatible to SRFI-4 but similar to SRFI-207. #u8("foo") would effectively be identical to the SRFI-207 notation #u8"foo". Seems quite orthogonal to me. Any thoughts? felix
Re: Hyperbolic Functions Patch Set
> Dear Maintainers, > Attached you find a change-set adding the hyperbolic functions (sinh, cosh, > tanh) and inverse hyperbolic functions (asking, cosh, atanh) to the included > (chicken flonum) module. This implementations follows the trigonometric > function using the math library calls. I also added some basic domain tests > for each of these function. > > IMHO this is a useful addition, first, because these functions are part of > the standard C math library and second, even though there are closed forms, > the cmath functions are tuned to use different computations depending on the > magnitude of the input argument to counteract floating point inaccuracies. > Thanks a lot, Christian, much obliged. I have combined the two patches and amended the result slightly (wrappers in runtime.c for all trigonometric functions were not calling the aliases from chicken.h, something we forgot and which I change here, while we're at it. I also added a few lines of documentation). We now just need some other -hacker to sign off push this. felix From eba5f2e01b705e6a47250189cce01a868834f067 Mon Sep 17 00:00:00 2001 From: Christian Himpe Date: Mon, 5 Jun 2023 20:05:21 +0200 Subject: [PATCH] Added hyperbolic and inverse hyperbolic functions in c-std lib: sinh, cosh, tanh, asinh, acosh, atanh Also modified old r/t C_a_i_... trigonometric functions to actually use aliases for libc math functions introduced in chicken.h. Signed-off-by: felix --- chicken.h | 18 + lfa2.scm | 12 ++ library.scm| 24 +++ manual/Module (chicken flonum) | 6 +++ runtime.c | 74 +- tests/library-tests.scm| 26 6 files changed, 150 insertions(+), 10 deletions(-) diff --git a/chicken.h b/chicken.h index 928066ed..6461241d 100644 --- a/chicken.h +++ b/chicken.h @@ -966,6 +966,12 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret; # define C_asin asin # define C_acos acos # define C_atan atan +# define C_sinh sinh +# define C_cosh cosh +# define C_tanh tanh +# define C_asinhasinh +# define C_acoshacosh +# define C_atanhatanh # define C_atan2atan2 # define C_log log # define C_exp exp @@ -1629,6 +1635,12 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret; #define C_a_i_flonum_acos(ptr, c, x)C_flonum(ptr, C_acos(C_flonum_magnitude(x))) #define C_a_i_flonum_atan(ptr, c, x)C_flonum(ptr, C_atan(C_flonum_magnitude(x))) #define C_a_i_flonum_atan2(ptr, c, x, y) C_flonum(ptr, C_atan2(C_flonum_magnitude(x), C_flonum_magnitude(y))) +#define C_a_i_flonum_sinh(ptr, c, x) C_flonum(ptr, C_sinh(C_flonum_magnitude(x))) +#define C_a_i_flonum_cosh(ptr, c, x) C_flonum(ptr, C_cosh(C_flonum_magnitude(x))) +#define C_a_i_flonum_tanh(ptr, c, x) C_flonum(ptr, C_tanh(C_flonum_magnitude(x))) +#define C_a_i_flonum_asinh(ptr, c, x)C_flonum(ptr, C_asinh(C_flonum_magnitude(x))) +#define C_a_i_flonum_acosh(ptr, c, x)C_flonum(ptr, C_acosh(C_flonum_magnitude(x))) +#define C_a_i_flonum_atanh(ptr, c, x)C_flonum(ptr, C_atanh(C_flonum_magnitude(x))) #define C_a_i_flonum_exp(ptr, c, x) C_flonum(ptr, C_exp(C_flonum_magnitude(x))) #define C_a_i_flonum_expt(ptr, c, x, y) C_flonum(ptr, C_pow(C_flonum_magnitude(x), C_flonum_magnitude(y))) #define C_a_i_flonum_log(ptr, c, x) C_flonum(ptr, C_log(C_flonum_magnitude(x))) @@ -2074,6 +2086,12 @@ C_fctexport C_word C_fcall C_a_i_asin(C_word **a, int c, C_word n) C_regparm; C_fctexport C_word C_fcall C_a_i_acos(C_word **a, int c, C_word n) C_regparm; C_fctexport C_word C_fcall C_a_i_atan(C_word **a, int c, C_word n) C_regparm; C_fctexport C_word C_fcall C_a_i_atan2(C_word **a, int c, C_word n1, C_word n2) C_regparm; +C_fctexport C_word C_fcall C_a_i_sinh(C_word **a, int c, C_word n) C_regparm; +C_fctexport C_word C_fcall C_a_i_cosh(C_word **a, int c, C_word n) C_regparm; +C_fctexport C_word C_fcall C_a_i_tanh(C_word **a, int c, C_word n) C_regparm; +C_fctexport C_word C_fcall C_a_i_asinh(C_word **a, int c, C_word n) C_regparm; +C_fctexport C_word C_fcall C_a_i_acosh(C_word **a, int c, C_word n) C_regparm; +C_fctexport C_word C_fcall C_a_i_atanh(C_word **a, int c, C_word n) C_regparm; C_fctexport C_word C_fcall C_a_i_sqrt(C_word **a, int c, C_word n) C_regparm; C_fctexport C_word C_fcall C_i_o_fixnum_plus(C_word x, C_word y) C_regparm; C_fctexport C_word C_fcall C_i_o_fixnum_difference(C_word x, C_word y) C_regparm; diff --git a/lfa2.scm b/lfa2.scm index 38ed4da2..e47f1a23 100644 --- a/lfa2.scm +++ b/lfa2.scm @@ -167,12 +167,16 @@ ("C_a_i_bignum2" bignum) ("C_a_i_flonum_abs" float) (&qu
Re: [PATCH] Pass executed filename to execv[pe] unmodified when calling process-execute
> Hi there, > > Earlier today I went in circles trying to figure out why a child process > was only getting the basename of the executable in argv[0], rather than > the pathname I was passing. > > Turns out we do that when building the arguments to execvp, but I don't > think it's ideal, so here's a patch to leave that pathname alone. Thanks! pushed. felix
Re: [PATCH] Add .gitignore file
> Here's a patch that adds a .gitignore file at the root of the > chicken-core repo, so that `git status` doesn't show generated files > that are not supposed to be committed to the repo. > > It doesn't seem possible to ignore *.import.scm wholesale since a few of > those files are committed: > > $ git ls-files | grep -F .import.scm > chicken.base.import.scm > chicken.condition.import.scm > chicken.csi.import.scm > chicken.foreign.import.scm > chicken.syntax.import.scm > chicken.time.import.scm > > Likewise, *.c cannot be ignored wholesale since some hand-written C > source files are present in the same directory as the C files output by csc. Thanks, Lassi! Here is a signed-off version. I first considered this straightforward, but after some discussion on IRC it seems that this may change the workflow in subtle or unexpected ways, so I leave this open for the moment. felix From 8399702cea161f1cf01059e7ac7bba361cf107c0 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Tue, 25 Apr 2023 15:19:52 +0300 Subject: [PATCH] Add .gitignore file Signed-off-by: felix --- .gitignore | 124 + 1 file changed, 124 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index ..6ebadf62 --- /dev/null +++ b/.gitignore @@ -0,0 +1,124 @@ +# Wildcards + +*.a +*.dylib +*.import.c +*.o +*.so + +# Generated text files + +/buildbranch +/buildid +/chicken-config.h +/chicken-defaults.h +/feathers + +# Compiled binary executables + +/chicken +/chicken-boot +/chicken-boot-stage1 +/chicken-do +/chicken-install +/chicken-profile +/chicken-status +/chicken-uninstall +/csc +/csi + +# Compiled Scheme modules' C code + +/batch-driver.c +/build-version.c +/build.c +/c-backend.c +/c-platform.c +/chicken-ffi-syntax.c +/chicken-install.c +/chicken-profile.c +/chicken-status.c +/chicken-syntax.c +/chicken-uninstall.c +/chicken.c +/compiler-syntax.c +/continuation.c +/core.c +/csc.c +/csi.c +/data-structures.c +/debugger-client.c +/eval-modules.c +/eval.c +/expand.c +/extras.c +/file.c +/internal.c +/irregex.c +/lfa2.c +/library.c +/lolevel.c +/modules.c +/optimizer.c +/pathname.c +/port.c +/posixunix.c +/profiler.c +/read-syntax.c +/repl.c +/scheduler.c +/scrutinizer.c +/srfi-4.c +/stub.c +/support.c +/tcp.c +/user-pass.c + +# Compiled Scheme modules' imports + +/chicken.bitwise.import.scm +/chicken.blob.import.scm +/chicken.compiler.batch-driver.import.scm +/chicken.compiler.c-backend.import.scm +/chicken.compiler.c-platform.import.scm +/chicken.compiler.chicken.import.scm +/chicken.compiler.compiler-syntax.import.scm +/chicken.compiler.core.import.scm +/chicken.compiler.lfa2.import.scm +/chicken.compiler.optimizer.import.scm +/chicken.compiler.scrutinizer.import.scm +/chicken.compiler.support.import.scm +/chicken.compiler.user-pass.import.scm +/chicken.continuation.import.scm +/chicken.errno.import.scm +/chicken.eval.import.scm +/chicken.file.import.scm +/chicken.file.posix.import.scm +/chicken.fixnum.import.scm +/chicken.flonum.import.scm +/chicken.format.import.scm +/chicken.gc.import.scm +/chicken.internal.import.scm +/chicken.io.import.scm +/chicken.irregex.import.scm +/chicken.keyword.import.scm +/chicken.load.import.scm +/chicken.locative.import.scm +/chicken.memory.import.scm +/chicken.memory.representation.import.scm +/chicken.pathname.import.scm +/chicken.platform.import.scm +/chicken.plist.import.scm +/chicken.port.import.scm +/chicken.pretty-print.import.scm +/chicken.process-context.import.scm +/chicken.process-context.posix.import.scm +/chicken.process.import.scm +/chicken.process.signal.import.scm +/chicken.random.import.scm +/chicken.read-syntax.import.scm +/chicken.repl.import.scm +/chicken.sort.import.scm +/chicken.string.import.scm +/chicken.tcp.import.scm +/chicken.time.posix.import.scm -- 2.33.0
[PATCH] Stop run-time option processing after first "-:" or non-runtime option (was: Re: [PATCH] stop run-time option processing after "--")
> On Tue, Mar 14, 2023 at 08:43:52AM +0100, Peter Bex wrote: > > On Tue, Mar 14, 2023 at 08:40:18AM +0100, felix.winkelm...@bevuta.com wrote: > > > Backwards compatibility is from now on fucked anyway, so let's > > > try to find somethin simple and sensible. > > > > Then we should do both. I.e., have -: to explicitly tell it to stop > > parsing (and have that dropped from the command-line-options) and > > stop at the first argument. The -: would be in situations where > > a script just passes on all its arguments, like > > > > ./my-program -: "$@" > > Here's a patch that implements this proposal. > All right then... I'm not happy with this solution, but since we must go on and I can't think of a better way: signed off and pushed. felix
Re: [PATCH] stop run-time option processing after "--"
> Of course. In fact, I think it would make more sense to simply tell the > runtime options parser to stop after the first non-"-:"-prefixed > argument. That makes runtime argument stuffing harder and allows it > to play nice with _any_ option parser, and makes the "--" behaviour > automatically work if the program already handles getopt-style options. That's another idea. Backwards compatibility is from now on fucked anyway, so let's try to find somethin simple and sensible. felix
Re: [PATCH] stop run-time option processing after "--"
> Perhaps the safest here is to stop processing after reading ":-" > or some such (and discard it!) - that would be guaranteed to never > pass through to the program anyway, because it might be a runtime > option and already gets intercepted by the option parser. > As an afterthought: I find that a single well known marker to disable _all_ option processing (whether r/t or application-specific) seems more intuitive to me than adding yet another special case, which will only result in uglyness, like "my-program ... :- -- ...". felix
Re: [PATCH] stop run-time option processing after "--"
> On Mon, Mar 13, 2023 at 10:37:30AM +0100, felix.winkelm...@bevuta.com wrote: > > Another problem with run-time option processing pointed out by > > florz. This allows passing arguments that look like run-time > > options, when preceded by "--". > > This needs more thought - simply adding "--" to stop it from processing > options leaves us with ("--") as the first command-line argument. > In other words, "./my-program -:a100 -- foo" is seen as '("--" "foo") > when you ask for (command-line-arguments), while the intention probably > was '("foo"). Actually not. Currently "--" is not specially handled, so it makes no difference whether r/t options are passed or not ("command-line-arguments") returns exactly the same. With or without this patch, "--" will be seen by user code. If the program does not parse the command line, having a "--" has no effect. If it does, it is probably a good idea (and good style) to be aware of it and handle the case appropriately. For "my-program" above, the "--" in the example invocation is immaterial. But if "my-program" does process the command-line, it may be appropriate to handle "--" anyway (mostly to distinguish its own options from non-option arguments). felix
[PATCH] stop run-time option processing after "--"
Another problem with run-time option processing pointed out by florz. This allows passing arguments that look like run-time options, when preceded by "--". felix From fae3f9ddeabccae4851ff451fb2aaf05a02e44e3 Mon Sep 17 00:00:00 2001 From: felix Date: Mon, 13 Mar 2023 10:35:32 +0100 Subject: [PATCH] stop run-time option processing after "--" --- library.scm | 21 +++-- manual/Module (chicken process-context) | 4 ++-- manual/Using the compiler | 3 ++- runtime.c | 6 -- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/library.scm b/library.scm index 9fc663e0..451f1d4f 100644 --- a/library.scm +++ b/library.scm @@ -6031,17 +6031,18 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { (define command-line-arguments (make-parameter - (let ([args (argv)]) + (let ((args (argv))) (if (pair? args) -(let loop ([args (##sys#slot args 1)]) - (if (null? args) - '() - (let ([arg (##sys#slot args 0)] -[r (##sys#slot args 1)] ) -(if (and (fx>= (##sys#size arg) 3) - (string=? "-:" (##sys#substring arg 0 2))) -(loop r) -(cons arg (loop r)) ) ) ) ) +(let loop ((args (##sys#slot args 1))) + (cond ((null? args) '()) + ((string=? "--" (car args)) args) +(else + (let ((arg (##sys#slot args 0)) +(r (##sys#slot args 1)) ) + (if (and (fx>= (##sys#size arg) 3) + (string=? "-:" (##sys#substring arg 0 2))) + (loop r) + (cons arg (loop r)) ) ) ) )) args) ) (lambda (x) (##sys#check-list x 'command-line-arguments) diff --git a/manual/Module (chicken process-context) b/manual/Module (chicken process-context) index 5299905e..6b8f8c48 100644 --- a/manual/Module (chicken process-context) +++ b/manual/Module (chicken process-context) @@ -29,8 +29,8 @@ the host-shell whether arguments are expanded ('globbed') or not. (command-line-arguments) Contains the list of arguments passed to this program, with the name of -the program and any runtime options (all options starting with {{-:}}) -removed. +the program and any runtime options (options starting with {{-:}}) +removed. Note that the latter will still be included when following {{--}}. executable-pathname diff --git a/manual/Using the compiler b/manual/Using the compiler index 51cd9ffc..fd9e14c1 100644 --- a/manual/Using the compiler +++ b/manual/Using the compiler @@ -223,7 +223,8 @@ After successful compilation a C source file is generated and can be compiled with a C compiler. Executables generated with CHICKEN (and the compiler itself) accept a small set of runtime options. These are filtered out by the startup code and will not be contained in the result of -{{(command-line-arguments)}}. +{{(command-line-arguments)}}. An occurrence of {{--}} will prevent any +further run-time option processing. ; {{-:?}} : Shows a list of the available runtime options and exits the program. diff --git a/runtime.c b/runtime.c index 76f0e12c..5d097ddb 100644 --- a/runtime.c +++ b/runtime.c @@ -1349,8 +1349,9 @@ void CHICKEN_parse_command_line(int argc, char *argv[], C_word *heap, C_word *st *stack = DEFAULT_STACK_SIZE; *symbols = DEFAULT_SYMBOL_TABLE_SIZE; - for(i = 1; i < C_main_argc; ++i) -if(!strncmp(C_main_argv[ i ], C_text("-:"), 2)) { + for(i = 1; i < C_main_argc; ++i) { +if(!C_strcmp(C_main_argv[ i ], C_text("--"))) break; +else if(!C_strncmp(C_main_argv[ i ], C_text("-:"), 2)) { for(ptr = _main_argv[ i ][ 2 ]; *ptr != '\0';) { switch(*(ptr++)) { case '?': @@ -1504,6 +1505,7 @@ void CHICKEN_parse_command_line(int argc, char *argv[], C_word *heap, C_word *st next:; } + } } -- 2.33.0
[PATCH] drop "b" runtime option
As rightly pointed out by florz and others, the "b" (break on repl) offers a potential security vulnerability by allowing code from stdin to be interpreted. This patch simply removes the option, as it doesn't seem to be widely used, anyway. felix From 2b34dfb2708b04bfdce0831afd2ec4c4d1eca0ff Mon Sep 17 00:00:00 2001 From: felix Date: Sun, 12 Mar 2023 18:02:47 +0100 Subject: [PATCH] drop "b" runtime option --- chicken.h | 1 - csi.scm | 2 -- library.scm | 7 --- manual/Using the compiler | 2 -- runtime.c | 6 -- 5 files changed, 18 deletions(-) diff --git a/chicken.h b/chicken.h index 9d15ab74..928066ed 100644 --- a/chicken.h +++ b/chicken.h @@ -1696,7 +1696,6 @@ C_varextern C_TLS jmp_buf C_restart; C_varextern C_TLS void *C_restart_address; C_varextern C_TLS int C_entry_point_status; C_varextern C_TLS int C_gui_mode; -C_varextern C_TLS int C_enable_repl; C_varextern C_TLS void *C_restart_trampoline; C_varextern C_TLS void (*C_pre_gc_hook)(int mode); diff --git a/csi.scm b/csi.scm index 765d8c40..ea618521 100644 --- a/csi.scm +++ b/csi.scm @@ -260,8 +260,6 @@ EOF (or (##core#inline "C_i_tty_forcedp") (##sys#tty-port? ##sys#standard-input))) -(set! ##sys#break-on-error #f) - (set! ##sys#read-prompt-hook (let ([old ##sys#read-prompt-hook]) (lambda () diff --git a/library.scm b/library.scm index 9fc663e0..827666d5 100644 --- a/library.scm +++ b/library.scm @@ -5135,8 +5135,6 @@ EOF (define (signal x) (##sys#current-exception-handler x) ) -(define ##sys#break-on-error (foreign-value "C_enable_repl" bool)) - (define ##sys#error-handler (make-parameter (let ([string-append string-append]) @@ -5161,11 +5159,6 @@ EOF args)]))) (##sys#print #\newline #f ##sys#standard-error) (print-call-chain ##sys#standard-error) - (when (and ##sys#break-on-error (##sys#symbol-has-toplevel-binding? 'chicken.repl#repl)) - ;; Hack to avoid hard / cyclic dependency - ((##sys#slot 'chicken.repl#repl 0)) - (##sys#print #\newline #f ##sys#standard-error) - (##core#inline "C_exit_runtime" _ex_software)) (##core#inline "C_halt" #f)) (else (let ((out (open-output-string))) diff --git a/manual/Using the compiler b/manual/Using the compiler index 51cd9ffc..30e5ed2a 100644 --- a/manual/Using the compiler +++ b/manual/Using the compiler @@ -231,8 +231,6 @@ by the startup code and will not be contained in the result of ; {{-:ANUMBER}} : Specifies fixed ''temporary stack'' size. This is used mostly for {{apply}}. If you supply a zero size (the default), the temporary stack will be dynamically reallocated as needed. -; {{-:b}} : Enter a read-eval-print-loop when an error is encountered. - ; {{-:B}} : Sounds a bell (by writing ASCII 7 to stdout) on every major garbage collection. ; {{-:c}} : Forces console mode. Currently this is only used in the interpreter ({{csi}}) to force output of the {{#;N>}} prompt even if stdin is not a terminal (for example if running in an {{emacs}} buffer under Windows). diff --git a/runtime.c b/runtime.c index 76f0e12c..aa64092b 100644 --- a/runtime.c +++ b/runtime.c @@ -337,7 +337,6 @@ C_TLS C_word (*C_debugger_hook)(C_DEBUG_INFO *cell, C_word c, C_word *av, C_char C_TLS int C_gui_mode = 0, C_abort_on_thread_exceptions, - C_enable_repl, C_interrupts_enabled, C_disable_overflow_check, C_heap_size_is_fixed, @@ -1376,7 +1375,6 @@ void CHICKEN_parse_command_line(int argc, char *argv[], C_word *heap, C_word *st " -:tSIZE set symbol-table size\n" " -:fSIZE set maximal number of pending finalizers\n" " -:x deliver uncaught exceptions of other threads to primordial one\n" -" -:b enter REPL on error\n" " -:B sound bell on major GC\n" " -:G force GUI mode\n" " -:aSIZE set trace-buffer/call-chain size\n" @@ -1494,10 +1492,6 @@ void CHICKEN_parse_command_line(int argc, char *argv[], C_word *heap, C_word *st C_abort_on_thread_exceptions = 1; break; - case 'b': - C_enable_repl = 1; - break; - default: panic(C_text("illegal runtime option")); } } -- 2.33.0
Re: [PATCH] chicken-install: cache local eggs + -location option
> Hi, > > Please find attached patches to [hopefully] improve the usability of > chicken-install. > Pushed, thanks! felix
[PATCH] add option to csc to disable runtime options
See attached patch. felix From fc4b142bfd889e4c1b7157a7691836eeed344f7f Mon Sep 17 00:00:00 2001 From: Felix Winkelmann Date: Fri, 3 Mar 2023 00:07:19 +0100 Subject: [PATCH] Added option to csc to disable runtime option processing --- NEWS | 2 ++ chicken.h | 9 + csc.mdoc | 4 csc.scm | 9 +++-- library.scm | 3 ++- manual/Using the compiler | 7 +++ runtime.c | 3 +++ 7 files changed, 34 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 23661fc2..1e29004b 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,8 @@ - chicken-install now accepts the -location command line option (short: -l) to specify local directories where to get egg sources from. + - csc accepts the -disable-runtime-options flag now to disable +all processing of runtime options for compiled programs. - Compiler - When emitting types files, the output list is now sorted, to ensure diff --git a/chicken.h b/chicken.h index 9d15ab74..fa6a5ce9 100644 --- a/chicken.h +++ b/chicken.h @@ -1564,6 +1564,12 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret; # define C_set_gui_mode #endif +#ifdef C_DISABLE_RUNTIME_OPTIONS +# define C_set_runtime_options C_runtime_options = 0 +#else +# define C_set_runtime_options +#endif + /** * SEARCH_EXE_PATH is defined on platforms on which we must search for * the current executable. Because this search is sensitive to things @@ -1588,6 +1594,7 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret; C_gui_mode = 1; \ C_set_main_exe(argv[0]); \ C_private_repository();\ +C_set_runtime_options; \ return CHICKEN_main(0, NULL, (void *)C_toplevel); \ } # else @@ -1597,6 +1604,7 @@ typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret; C_set_gui_mode; \ C_set_main_exe(argv[0]); \ C_private_repository();\ +C_set_runtime_options; \ return CHICKEN_main(argc, argv, (void*)C_toplevel); \ } # endif @@ -1696,6 +1704,7 @@ C_varextern C_TLS jmp_buf C_restart; C_varextern C_TLS void *C_restart_address; C_varextern C_TLS int C_entry_point_status; C_varextern C_TLS int C_gui_mode; +C_varextern C_TLS int C_runtime_options; C_varextern C_TLS int C_enable_repl; C_varextern C_TLS void *C_restart_trampoline; diff --git a/csc.mdoc b/csc.mdoc index a930a3f9..c5ad06db 100644 --- a/csc.mdoc +++ b/csc.mdoc @@ -232,6 +232,10 @@ Compile as embedded .Pc . .It Fl gui Compile as GUI application. +.It Fl disable-runtime-options +Disable any handling of "-:..." runtime command line options +for executables. When compiling libraries, this option has +no effect. .It Fl link Ar NAME Link extension with compiled executable .Po implies Sq Fl uses diff --git a/csc.scm b/csc.scm index 1fe896b7..8ab8960f 100644 --- a/csc.scm +++ b/csc.scm @@ -431,7 +431,7 @@ Usage: #{csc} [OPTION ...] [FILENAME ...] -clusteringcombine groups of local procedures into dispatch loop -lfa2 perform additional lightweight flow-analysis pass --unroll-limit LIMIT specifies inlining limit for self-recursive calls +-unroll-limit LIMITspecifies inlining limit for self-recursive calls Configuration options: @@ -449,7 +449,10 @@ Usage: #{csc} [OPTION ...] [FILENAME ...] -e -embedded compile as embedded (don't generate `main()') --gui compile as GUI application +-gui compile as GUI application +-disable-runtime-options disable any handling of "-:..." runtime command +line options for programs (ineffective for +libraries) -link NAME link extension with compiled executable (implies -uses) -R -require-extension NAMErequire extension and import in compiled @@ -707,6 +710,8 @@ EOF (set! link-options (cons* "-lkernel32" "-luser32" "-lgdi32" "-mwindows" link-options)))] + ((-disable-runtime-options) + (set! compile-options (cons "-DC_DISABLE_RUNTIME_OPTIONS" compile-options))) ((-deployed) (set! deployed #t)) [(-framework) diff --git a/library.scm b/library.scm index 9fc663e0..7079ac72 100644 --- a/library.scm +++ b/library.scm @@ -6032,7 +6032,8 @@ static C_word C_fcall C_setenv(C_word x, C_word y) { (define command-line-arguments (make-parameter (let ([args (argv)]) - (if (pair? args) + (if (and (pa
[PATCH] component dependencies in eggs should be reflected in build rules
Hi! Originally reported by Mario, recently also noticed on #chicken. See commit message, fixes #1684. felix From 9ce41a3a5601d3564c0aaa0c2fcf1a1c2a0e9066 Mon Sep 17 00:00:00 2001 From: felix Date: Thu, 22 Dec 2022 22:05:01 +0100 Subject: [PATCH] Respect component-dependencies in build rules. Component-dependencies determine order of build but do not yet actually force a rebuild of the depending component. This patch adds the output of a component to the build dependencies of depending components. Fixes #1684 --- egg-compile.scm | 69 +++-- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/egg-compile.scm b/egg-compile.scm index 9ba45681..3aee23d5 100644 --- a/egg-compile.scm +++ b/egg-compile.scm @@ -49,6 +49,7 @@ (define +link-file-extension+ ".link") (define keep-generated-files #f) +(define dependency-targets '()) ;;; some utilities @@ -588,7 +589,7 @@ ;;; shell code generation - build operations -(define ((compile-static-extension name #!key mode +(define ((compile-static-extension name #!key mode dependencies source-dependencies source (options '()) predefined-types eggfile @@ -620,18 +621,20 @@ (target-file (conc out1 (archive-extension platform)) mode))) + (imps (map (lambda (m) + (prefix srcdir (conc m ".import.scm"))) + (or modules '( (targets (append (list out3 lfile) (maybe types-file tfile) (maybe inline-file ifile) - (map (lambda (m) - (prefix srcdir (conc m ".import.scm"))) - (or modules '() + imps)) (src (or source (conc name ".scm" (when custom (prepare-custom-command cmd platform)) (print-build-command targets `(,@(filelist srcdir source-dependencies) ,src ,eggfile - ,@(if custom (list cmd) '())) + ,@(if custom (list cmd) '()) + ,@(get-dependency-targets dependencies)) `(,cmd ,@(if keep-generated-files '("-k") '()) "-regenerate-import-libraries" ,@(if modules '("-J") '()) "-M" @@ -654,7 +657,7 @@ platform))) (print-end-command platform))) -(define ((compile-dynamic-extension name #!key mode mode +(define ((compile-dynamic-extension name #!key mode mode dependencies source (options '()) (link-options '()) predefined-types eggfile @@ -684,18 +687,21 @@ (object-extension platform)) mode)) link-objects)) + (imps (map (lambda (m) + (prefix srcdir (conc m ".import.scm"))) + modules)) (targets (append (list out) (maybe inline-file ifile) (maybe types-file tfile) - (map (lambda (m) - (prefix srcdir (conc m ".import.scm"))) -modules + imps))) +(add-dependency-target name out) (when custom (prepare-custom-command cmd platform)) (print-build-command targets `(,src ,eggfile ,@(if custom (list cmd) '()) ,@(filelist srcdir lobjs) - ,@(filelist srcdir source-dependencies)) + ,@(filelist srcdir source-dependencies) + ,@(get-dependency-targets dependencies)) `(,cmd ,@(if keep-generated-files '("-k") '()) ,@(if (eq? mode 'host) '("-host") '()) "-D" "compiling-extension" @@ -734,7 +740,7 @@ platform) (print-end-command platform))) -(define ((compile-static-object name #!key mode +(define ((compile-static-object name #!key mode dependencies source-dependencies source (options '()) eggfile custom) @@ -755,7 +761,8 @@ (prepare-custom-command cmd platform)) (print-build-command (list out) `(,@(filelist srcdir source-dependencies) ,src ,eggfile - ,@(if custom
Re: [PATCH] chicken-install: Consider two location layouts
> Attached is a patch that hopefully improves the usability of > chicken-install in "offline" mode (i.e., fetching eggs from a local > directory instead of egg servers). > Pushed, thanks! felix
[SECURITY] Potential OS command execution during egg install
Hello! Vasilij found a security issue with the way egg-information files are created during installation of an extension package. Currently, escape characters in the .egg file may be used to perform arbitrary OS command injection due to the method the egg metadata is created and installed in the local egg repository during the install-stage of an egg. The issue is fixed in commit a08f8f548d772ef410c672ba33a27108d8d434f3 and has been assigned the CVE identifier CVE-2022-45145, see here for the patch: https://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=commitdiff;h=a08f8f548d772ef410c672ba33a27108d8d434f3;hp=9c6fb001c25de4390f46ffd7c3c94237f4df92a9 All CHICKEN versions from 5.0.0 and later are vulnerable. Many thanks to Vasilij for reporting the issue and suggesting the necessary changes to mitigate the problem. Since all egg-downloads go through our centralized egg-locations file in SVN, it is highly recommended to verify *.egg files for possible shell escape characters before including their access information there. Future Salmonella runs should point out problematic eggs but it may be prudent to not rely on this, as Salmonella runs and additions to the egg-locations file are not synchronized. felix
[PATCH] try to make generation of egg-info file on Windows more robust
The attached patch was contributed by Vassilij. See #1800. felix From f48e2f68037d36abd2628605dd8c906c5b106556 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Tue, 1 Nov 2022 20:23:59 +0100 Subject: [PATCH] Split up potentially long echo invocation on win32 Eggs with a very long infostr may trigger the maximum command line invocation length of 8191 chars. To avoid running into this limitation, the generated install script now creates an empty file, then echoes each line into it. Closes #1800 Signed-off-by: felix --- egg-compile.scm | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/egg-compile.scm b/egg-compile.scm index c1f2ceb0..f37b7a9f 100644 --- a/egg-compile.scm +++ b/egg-compile.scm @@ -1139,11 +1139,16 @@ EOF (printf #<~a~a~% +copy /y nul ~a~a~% +~a EOF mkdir ddir qdir - (string-intersperse (string-split infostr "\n") "^\n\n") - ddir dest) + ddir dest + (string-intersperse (map (lambda (line) + (format "echo ~a >>~a~a" + line ddir dest)) + (string-split infostr "\n")) + "\n")) ;;; some utilities for mangling + quoting -- 2.28.0
Re: [PATCH] handle misquoting of target in build-scripts
> On Mon, Oct 31, 2022 at 05:46:55PM +0100, felix.winkelm...@bevuta.com wrote: > > Thanks, pushed. I had to hand-apply the patch as git-am didn't like it. I > > also > > fixed a scrutinizer warning. > > I suppose the warning was about target-librarian-options not being a > list? Unfortunately, splicing in these options wouldn't work properly - > they're taken from a baked in foreign value which may contain spaces. > > We'll have to figure out a way to keep certain arguments "as-is". > Attached is a pretty straightforward proposal to make this work. Thanks - pushed. > > PS: I noticed two more mistakes that have nothing to do with this - just > the platform was still being passed in to "filelist" and was *not* being > passed in to print-build-command. I've fixed these already and pushed > them as trivial patches. Excellent. cheers, felix
Re: [PATCH] handle misquoting of target in build-scripts
> On Sun, Oct 30, 2022 at 02:46:49PM +0100, felix.winkelm...@bevuta.com wrote: > > Another follow-up patch on the recent change of quoting in chicken-install, > > which causes > > chicken-do to always fire (and thus rebuilding any egg, regardless of > > status). > > I noticed there were still inconsistencies here. > How about the attached patch instead? It may be a little bit > trickier to read (but not by much), but should eliminate the > problem entirely for chicken-do calls. > Thanks, pushed. I had to hand-apply the patch as git-am didn't like it. I also fixed a scrutinizer warning. felix
Re: [PATCH] Fix double normalize-destination call
> > It looks like that's actually a bug in the egg though - contrast to the > srfi-19 egg which *does* work, it has (data srf-29-bundles (files ...)) > instead. This has been fixed in the latest amb release (3.0.7). > > The attached patch fixes the double call to normalize-destination on the > directory for "share" files (data files) > Thanks, pushed. felix
[PATCH] simplification/refactoring
in egg-compile.scm, as suggested by Peter. felix From bdf4990636d34bedfd3980f0c7cfdfbfdb0c1bcc Mon Sep 17 00:00:00 2001 From: felix Date: Sun, 30 Oct 2022 14:44:09 +0100 Subject: [PATCH] replace redundant function, as suggested by sjamaan --- egg-compile.scm | 46 +- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/egg-compile.scm b/egg-compile.scm index 14c93be0..23af8b4e 100644 --- a/egg-compile.scm +++ b/egg-compile.scm @@ -646,7 +646,7 @@ (if (eq? mode 'host) " -host" "") " -D compiling-extension -c -unit " name " -D compiling-static-extension" - " -C -I" srcdir (arglist opts platform) + " -C -I" srcdir " " (joins opts platform) " " src " -o " out2) (when (pair? link-objects) (let ((lobjs (filelist srcdir @@ -714,9 +714,9 @@ " -D compiling-extension -J -s" " -regenerate-import-libraries" " -setup-mode -I " srcdir - " -C -I" srcdir - (arglist opts platform) - (arglist link-options platform) " " + " -C -I" srcdir " " + (joins opts platform) " " + (joins link-options platform) " " src " " (filelist srcdir lobjs platform) " -o " out) @@ -737,16 +737,16 @@ (print "\n" (qs* default-builder platform #t) " " out " : " - src + src " " (filelist srcdir source-dependencies platform) " : " cmd (if keep-generated-files " -k" "") " -setup-mode -s" (if (eq? mode 'host) " -host" "") - " -I " srcdir " -C -I" srcdir - (arglist opts platform) - (arglist link-options platform) " " + " -I " srcdir " -C -I" srcdir " " + (joins opts platform) " " + (joins link-options platform) " " src " -o " out) (print-end-command platform))) @@ -784,8 +784,8 @@ cmd " -setup-mode -static -I " srcdir (if (eq? mode 'host) " -host" "") - " -c -C -I" srcdir - (arglist opts platform) + " -c -C -I" srcdir " " + (joins opts platform) " " src " -o " out) (print-end-command platform))) @@ -822,8 +822,8 @@ cmd (if (eq? mode 'host) " -host" "") " -setup-mode -I " srcdir - " -s -c -C -I" srcdir - (arglist opts platform) + " -s -c -C -I" srcdir " " + (joins opts platform) " " src " -o " out) (print-end-command platform))) @@ -866,9 +866,9 @@ " -setup-mode" (if (eq? mode 'host) " -host" "") " -I " srcdir - " -C -I" srcdir - (arglist opts platform) - (arglist link-options platform) " " + " -C -I" srcdir " " + (joins opts platform) " " + (joins link-options platform) " " src " " (filelist srcdir lobjs platform) " -o " out) @@ -911,10 +911,9 @@ (if keep-generated-files " -k" "") (if (eq? mode 'host) " -host" "") " -static -setup-mode -I " srcdir - " -C -I" - srcdir - (arglist opts platform) - (arglist link-options platform) " " + " -C -I" srcdir " " + (joins opts platform) " " + (joins link-options platform) " " src " " (filelist srcdir lobjs platform) " -o " out) @@ -1236,11 +1235,11 @@ EOF (define (target-file fname mode) (if (eq? mode 'target) (string-append fname ".target") fname)) -(define (arglist lst platform) - (apply conc (map (lambda (x) (conc " " (qs* x platform))) lst))) +(define (joins strs platform) + (string-intersperse (map (cut qs* <> platform) strs) " ")) (define (filelist dir lst platform) - (arglist (map (cut prefix dir <>) lst) platform)) + (joins (map (cut prefix dir <>) lst) platform)) (define (shell-variable var platform) (case platform @@ -1268,7 +1267,4 @@ EOF (assert (string=? prefix p1) "wrong prefix") (substring fname (add1 plen -(define (joins strs platform) - (string-intersperse (map (cut qs* <> platform) strs) " ")) - (define (maybe f x) (if f (list x) '())) -- 2.28.0
[PATCH] rename egg status files
See #1753, as reported by Kon. This will bust egg caches, but should otherwise not cause any incompatibilities. felix From df1335eab5f8e317cb05b0f15595cf61cf0ff14e Mon Sep 17 00:00:00 2001 From: felix Date: Sun, 30 Oct 2022 14:39:42 +0100 Subject: [PATCH] rename egg status files to avoid name clashes See #1753 --- egg-environment.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/egg-environment.scm b/egg-environment.scm index b7998132..f429e214 100644 --- a/egg-environment.scm +++ b/egg-environment.scm @@ -99,9 +99,9 @@ EOF (string-append default-runlibdir "/chicken/" (number->string binary-version))) (define +egg-info-extension+ "egg-info") -(define +version-file+ "VERSION") -(define +timestamp-file+ "TIMESTAMP") -(define +status-file+ "STATUS") +(define +version-file+ "_VERSION") +(define +timestamp-file+ "_TIMESTAMP") +(define +status-file+ "_STATUS") (define +egg-extension+ "egg") (define (validate-environment) -- 2.28.0