Skip to content

system calls - #84

Merged
rikvanriel merged 2 commits into
facebookexperimental:mainfrom
rikvanriel:scratch/riel/macro-defined-functions
Aug 29, 2026
Merged

system calls#84
rikvanriel merged 2 commits into
facebookexperimental:mainfrom
rikvanriel:scratch/riel/macro-defined-functions

Conversation

@rikvanriel

Copy link
Copy Markdown
Contributor

These changes allow semcode to expand the macro below into sys_old_readdir, making all the system calls visible.

SYSCALL_DEFINE3(old_readdir, unsigned int, fd, ...)

The loop over a file's functions computes, inline, which of the file's calls
fall inside one function and which of those go through a declared pointer.
A body found any other way needs the same treatment and cannot reach it.

Move it to a method taking a byte range. No behavioural change.

Assisted-by: claw:claude-opus-5
Signed-off-by: Rik van Riel <[email protected]>
    SYSCALL_DEFINE3(old_readdir, unsigned int, fd, ...)
    {
            error = iterate_dir(f, &buf.ctx);
    }

The parser reads the invocation as an expression statement and the block as an
unrelated compound statement, so no function is found. 783 syscalls were
absent from the functions table, and with them every call their bodies make:
`callers iterate_dir` named 17 functions and none of the five syscalls that
reach it.

The names in the table were prototypes from syscalls.h with no body, which is
why counting them showed nothing missing. Counting bodies does: 233 syscall
rows had their calls recorded, 930 after this.

    (semcode) callers iterate_dir
    17 functions directly call 'iterate_dir':
      ... sys_getdents, sys_old_readdir, compat_sys_old_readdir

Both directions come from the same column, so the syscall's own chain works
too.

The shape is a file-scope invocation followed by a block, in the file or
inside a conditional: `SYSCALL_DEFINE3(old_readdir, ...)` sits inside
`#ifdef __ARCH_WANT_OLD_READDIR`, and looking only at the translation unit's
children found 717 of the 930.

A block holding an initializer is not a body. `define_machine(pseries) {
.name = ... }` has the same shape and defines no function.

The name comes from a listed family, since the prefix lives in the macro and
not at the invocation. Return type and parameters are left empty: the macro
states them in pairs the parser reads as errors, and a guess there would be
read as a fact.

Assisted-by: claw:claude-opus-5
Signed-off-by: Rik van Riel <[email protected]>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 29, 2026
@rikvanriel
rikvanriel merged commit 7622f6b into facebookexperimental:main Aug 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant