The header scan (Captain Bob, 2026-11-10): 788 source files -- 351 with the
SL-1.0 header, 12 with the old name (docs/working/experiments, kept by
ruling), 31 under someone else's licence (tools/kconfig, Linux's, GPL-2.0:
kept), and 394 with none. Ruled: the SPDX form; capsules (.4th, .f18) and
proofs (.thy) left for a ruling of their own (mkcapsule's 64x16 block format,
content-addressed capsules).
253 files now begin
SPDX-License-Identifier: LicenseRef-Starship-1.0
Copyright (c) 2023-2026 Robert A. James
as a /* */ block (C, headers, assembly, linker scripts) or # lines (scripts,
Makefiles, Kconfig; below a shebang or a coding line); tools/mkcapsule.c,
which had the copyright line, gets the SPDX line only.
Not touched: docs/working/ (archive and old campaign material, as the
ruling kept the experiments); v4/system/post_cases.c (generated by
v4/tools/mkpost.py, "do not edit" -- the generator has the header).
Comments only: the kernel builds on amd64, aarch64, riscv64; make -C v4
test-32: 39 programs, 0 failures; every changed script parses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
48 lines
1.5 KiB
C
48 lines
1.5 KiB
C
/* SPDX-License-Identifier: LicenseRef-Starship-1.0
|
|
* Copyright (c) 2023-2026 Robert A. James
|
|
*/
|
|
/* message.c -- a message, as it is written to a port and read from one.
|
|
* See message.h. Nothing here uses the C library.
|
|
*/
|
|
#include "v4/message.h"
|
|
|
|
unsigned v4_message_text(v4_message *m, v4_cell to, v4_cell from, v4_cell type, const char *chars, unsigned len)
|
|
{
|
|
unsigned i, words;
|
|
|
|
if (len > V4_MSG_MAX_CHARS) return 0;
|
|
words = (len + 3u) / 4u;
|
|
m->word[0] = to;
|
|
m->word[1] = from;
|
|
m->word[2] = type;
|
|
m->word[3] = 0;
|
|
m->word[4] = 0;
|
|
m->word[5] = 0;
|
|
m->word[6] = (v4_cell)len;
|
|
for (i = 0; i < words; i++) m->word[V4_MSG_HEADER + i] = 0;
|
|
for (i = 0; i < len; i++)
|
|
m->word[V4_MSG_HEADER + i / 4u] = (v4_cell)((v4_ucell)m->word[V4_MSG_HEADER + i / 4u]
|
|
| ((v4_ucell)(unsigned char)chars[i] << (8u * (i % 4u))));
|
|
m->count = V4_MSG_HEADER + words;
|
|
return m->count;
|
|
}
|
|
|
|
unsigned v4_message_length(const v4_message *m)
|
|
{
|
|
v4_cell len = m->word[6];
|
|
return (len < 0 || len > (v4_cell)V4_MSG_MAX_CHARS) ? 0u : (unsigned)len;
|
|
}
|
|
|
|
char v4_message_char(const v4_message *m, unsigned i)
|
|
{
|
|
return (char)(((v4_ucell)m->word[V4_MSG_HEADER + i / 4u] >> (8u * (i % 4u))) & 0xFFu);
|
|
}
|
|
|
|
int v4_message_word(v4_message *m, v4_cell word)
|
|
{
|
|
if (m->count < V4_MSG_MAX_WORDS) m->word[m->count] = word;
|
|
m->count++;
|
|
if (m->count < V4_MSG_HEADER) return 0;
|
|
return m->count >= V4_MSG_HEADER + (v4_message_length(m) + 3u) / 4u;
|
|
}
|