Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ jobs:
echo "$req"
grep -q 'openkal.stream' <<<"$req" && ! grep -q 'openkal.net' <<<"$req" \
|| { echo "::error::a weak import made the image require its interface"; exit 1; }
# 6 MiB of frames on the main thread, the runner's on Windows (0.5.2).
bash examples/build-image.sh "$arch" "out/$arch/stack.oke" examples/stack/app.c
cp "out/$arch/hello.oke" "out/$arch/signed.oke"
# The library examples/bind binds for a program of each system.
bash examples/build-image.sh "$arch" "out/$arch/libmathlib.okso" examples/bind/mathlib/image/mathlib.c
Expand Down Expand Up @@ -275,6 +277,10 @@ jobs:
n=$("$OKRUN" "out/$a/needed.oke" | tr -d '\r')
echo "$n"
grep -q "twice(21) = 42, next_value() = 41" <<<"$n" || { echo "::error::an image another needs"; exit 1; }
# THE MAIN THREAD HAS A THREAD'S STACK (0.5.2): on Windows the runner's
# reservation, which was the linker's 1 MiB default.
st=$("$OKRUN" "out/$a/stack.oke" | tr -d '\r')
test "$st" = 'stack: 6 MiB on the main thread' || { echo "::error::the image's main thread has less than a thread's stack: $st"; exit 1; }
w=$("$OKRUN" "out/$a/weak.oke" | tr -d '\r')
echo "$w"
grep -q "weak: openkal.net bound" <<<"$w" || { echo "::error::a weak import the implementation provides was not bound"; exit 1; }
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ rules hold sixteen long grants, and states the kernel layer as compatible ranges
(openkal `^0.24.0`, Linux `^0.25.0`, macOS `^0.22.1`, Windows `^0.20.0`). The
format, the loader and the import names are unchanged.

Version 0.5.2 gives an image's main thread a thread's stack on Windows. An image
is entered on okrun's main thread, whose stack there is the executable's
reservation, the linker's 1 MiB; okrun.exe now reserves 8 MiB + 256 KiB, a
thread's default under openkal-windows, as Linux and macOS give the main thread
8 MiB. The `stack` example recurses through 6 MiB on the main thread on every
system.

## An image

```sh
Expand Down
2 changes: 1 addition & 1 deletion bind/mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-bind"
version = "0.5.1"
version = "0.5.2"
# `mcpp::xpkg_request', `mcpp::decision' (protocol 15).
mcpp = ">=2026.10.1.3"
description = "A build plugin: a library published as an ok image (.okso) and a C header is called from a program of any system, through a binding generated from the header and libokrun."
Expand Down
1 change: 1 addition & 0 deletions docs/bind.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ llvm toolchain's clang converts the call.
| 0.3.2 | No change of its own; released with the archive, whose runner is built over openkal 0.22's implementations: a started program is given the system's null device at a position (`KAL_SPAWN_NULL_*`). |
| 0.5.0 | The binding format is unchanged; the runner selects OpenKal 0.24 and binds its four process-unit operations. |
| 0.5.1 | No change of its own; released with the archive, whose runner is built over openkal-macos 0.22.1 (confinement rules sized to their grants). |
| 0.5.2 | No change of its own; released with the archive, whose runner on Windows reserves a thread's stack for the image's main thread. |
| 0.4.0 | No change of its own; released with the archive, whose loader places an image at the base `okld place` chose for it (openkal 0.23, `kal_exec_alloc_at`) and then applies only the relocations that name a symbol. |
| 0.4.1 | No change of its own; released with the archive, whose runner on macOS is built over openkal-macos 0.21.2 (a sleep is no longer a spin of the processor; the granularity is the same at every start). |
| 0.4.2 | No change of its own; released with the archive, whose runner on macOS is built over openkal-macos 0.21.3 (asked before the implementation's initialiser ran, it answers from the loader's record). |
Expand Down
30 changes: 30 additions & 0 deletions examples/stack/app.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* The image's main thread has the stack a thread has (openkal-image 0.5.2): an
* image is entered on the runner's main thread, and on Windows that thread's
* stack is the runner's reservation. This one recurses through 6 MiB of
* frames, each touched page by page (-fstack-clash-protection), where a thread
* of openkal-windows has at least 8 MiB and Linux and macOS give the main
* thread 8 MiB. The entry is `int ok_main(void)' (SPEC 12.2). */
typedef unsigned long kal_uintptr;
typedef long kal_intptr;
struct kal_stream { kal_uintptr h; };

struct kal_stream kal_stdout(void);
kal_intptr kal_stream_write(struct kal_stream, const void*, kal_uintptr);

static void put(const char* s) {
unsigned long n = 0; while (s[n]) ++n;
kal_stream_write(kal_stdout(), s, n);
}

__attribute__((noinline)) static unsigned descend(unsigned depth) {
volatile unsigned char frame[64 * 1024];
for (unsigned i = 0; i < sizeof frame; i += 4096) frame[i] = (unsigned char)depth;
unsigned below = depth ? descend(depth - 1) : 0;
return below + frame[depth % sizeof frame];
}

__attribute__((visibility("default"))) int ok_main(void) {
descend(96); /* 96 frames of 64 KiB: 6 MiB */
put("stack: 6 MiB on the main thread\n");
return 0;
}
2 changes: 1 addition & 1 deletion ld/mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-ld"
version = "0.5.1"
version = "0.5.2"
description = "libokld: the ok format (openkal image format) --- its definition, a reader of bytes, a checker, a signer, and a loader. Freestanding: no C library, no exceptions."
license = "Apache-2.0"
authors = ["mcpplibs"]
Expand Down
2 changes: 1 addition & 1 deletion run/mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-run"
version = "0.5.1"
version = "0.5.2"
description = "libokrun: the runner's core --- an ok image's names bound to this process's one openkal implementation, in the image's calling convention, and its entry entered."
license = "Apache-2.0"
authors = ["mcpplibs"]
Expand Down
17 changes: 16 additions & 1 deletion tools/mcpp.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
namespace = "mcpplibs"
name = "openkal-tools"
version = "0.5.1"
version = "0.5.2"
description = "okrun, which runs an ok image on this system, and okld, the format's tool on a build machine (check, note, sign, inspect)."
license = "Apache-2.0"
authors = ["mcpplibs"]
Expand Down Expand Up @@ -31,3 +31,18 @@ main = "src/okprof.cpp"

[build]
sources = []

# THE IMAGE'S MAIN THREAD IS THE RUNNER'S (0.5.2): an image is entered on okrun's
# main thread, whose stack on Windows is the executable's reservation, 1 MiB by
# the linker's default. openkal-windows gives every other thread at least 8 MiB
# (kal_task_start), and Linux and macOS give the main thread 8 MiB; an image's
# deep recursion on its main thread -- clangd.okb indexing the MSVC headers with
# `--sync` -- ended in STATUS_STACK_OVERFLOW. The reservation is a thread's
# default and openkal-windows' guard slack, 8 MiB + 256 KiB, spelled for each
# linker: lld-link on the MSVC ABI (a Windows host), the MinGW driver on the GNU
# ABI (the hosted arrangement, and a cross build).
[target.'cfg(all(windows, env = "msvc"))'.build]
ldflags = ["-Wl,/STACK:8650752"]

[target.'cfg(all(windows, env = "gnu"))'.build]
ldflags = ["-Wl,--stack,8650752"]
Loading