From 70361dab75dd03c17df24a807859135fc423e766 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 21 Sep 2026 17:41:43 -0700 Subject: change sys-write and sys-read to take file descriptors and also sys-write didn't used to return a result this required a little massaging to make it build, the host evoke needed to not actually pass the file descriptor in evoke.e. for posterity: this was fixed by changing it everywhere else as a one-off, then changing it there and using the intermediate version to build the one being checked in now. this kind of weirdness is a thing we get the freedom to do because of the bootstrapped distribution model, though we still strongly prefer not to do it unless necessary. this breaking change would have had to happen at some point, so it's considered acceptable. the size of the diff to evoke.hex is larger than ideal. this raises the need to have a policy for when to regenerate it. since this is a breaking change, it's mandatory. it also seems important to commit a regenerated copy when a release is tagged. it will probably turn out to be a good idea to not regenerate it excessively, otherwise. it's possible that in the long run it might make sense to add name-mapping functionality to hex, just to make the diffs smaller. Force-Push: yes Change-Id: I2648b2577c5c21b126e46405e9888b5cb59aa0b7 --- transform.e | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'transform.e') diff --git a/transform.e b/transform.e index 279ca72..0a5af3e 100644 --- a/transform.e +++ b/transform.e @@ -525,7 +525,7 @@ allocate-transformation-state s" transformation-state" variable ~ From linux.e. dup s" sys-exit" stringcmp 0 = { drop -1 exit } if dup s" sys-write" stringcmp 0 = { drop -2 exit } if - dup s" sys-read" stringcmp 0 = { drop -1 exit } if + dup s" sys-read" stringcmp 0 = { drop -2 exit } if ~ From output.e. dup s" emitstring" stringcmp 0 = { drop -1 exit } if @@ -4479,15 +4479,20 @@ allocate-transformation-state s" transformation-state" variable ~ want to require that, so we keep all the formatting state in the output ~ metadata header. ~ -~ (length to write, base address --) +~ (length to write, base address, file descriptor -- length written) : hex-sys-write-replacement ~ In intended operation, the code under transformation is a compilation ~ process, and it won't output anything that isn't executable binary. ~ However, while developing, it's common to have crashes, and it's nice to ~ get the crash dump as ASCII rather than hex. - dup is-in-label-loop-buffer not { + over is-in-label-loop-buffer not { sys-write exit } if + drop over 3unroll + ~ The result should be the length written. We just proactively declare + ~ that we'll write the full length we were asked to, threading that through + ~ as the result we'll eventually return. + ~ (result, length to write, base address) postprocess-metadata-entries @@ -4498,9 +4503,10 @@ allocate-transformation-state s" transformation-state" variable transformation-state transformation-state-output-metadata @ hex-output-metadata-first-entry - ~ (length to write, base address, initial metadata scan pointer) + ~ (result, length to write, base address, initial metadata scan pointer) { 2 pick 0 <= } { - ~ (length remaining, current output address, metadata scan pointer) + ~ (result, length remaining, current output address, + ~ metadata scan pointer) ~ Keep inspecting entries as long as the output address is greater than ~ or equal to the entry address. If we're looking at the entries that come @@ -4508,8 +4514,8 @@ allocate-transformation-state s" transformation-state" variable ~ eventually catch up. Since the scan pointer is kept across iterations, ~ it's important we not go beyond that point. { dup @ dup - ~ (length remaining, current output address, metadata scan pointer, - ~ entry's first field, entry's first field) + ~ (result, length remaining, current output address, + ~ metadata scan pointer, entry's first field, entry's first field) { ~ This is an nop, but for clarity's sake it's best to not depend on ~ details of the structure layout that perhaps not everyone has @@ -4521,15 +4527,17 @@ allocate-transformation-state s" transformation-state" variable hex-output-metadata-entry-data-start dup 3 pick - ~ (length remaining, current output address, metadata scan pointer, - ~ entry's data start, entry's data start, current output address) + ~ (result, length remaining, current output address, + ~ metadata scan pointer, entry's data start, entry's data start, + ~ current output address) >= swap drop } if } { dup @ 2 pick = { ~ We found a matching metadata entry. - ~ (length remaining, current output address, metadata scan pointer) + ~ (result, length remaining, current output address, + ~ metadata scan pointer) dup hex-output-metadata-entry-type @ hex-output-metadata-entry-type-line-comment = { @@ -4725,7 +4733,8 @@ allocate-transformation-state s" transformation-state" variable } if hex-output-metadata-next-entry } while - ~ (length remaining, current output address, metadata scan pointer) + ~ (result, length remaining, current output address, + ~ metadata scan pointer) 2 pick { n-bytes-this-line@ 16 = { @@ -4748,7 +4757,8 @@ allocate-transformation-state s" transformation-state" variable increment-bytes-this-line 0 is-fresh-line! } if - ~ (length remaining, current output address, metadata scan pointer) + ~ (result, length remaining, current output address, + ~ metadata scan pointer) 3unroll 1+ swap 1- swap 3roll } while drop ; -- cgit 1.4.1