Skip to content

Add Linux's syscalls#2978

Draft
data-man wants to merge 1 commit intoc3lang:masterfrom
data-man:linux_syscalls
Draft

Add Linux's syscalls#2978
data-man wants to merge 1 commit intoc3lang:masterfrom
data-man:linux_syscalls

Conversation

@data-man
Copy link
Contributor

I'll improve it later for more targets if this PoC is OK.

@lerno
Copy link
Collaborator

lerno commented Feb 25, 2026

If I understand correctly it becomes like Syscall.READ.call(a, b, c), why shouldn't we simply have: linux::syscall_read(a, b, c)? linux::syscall_write(a, b c)

@data-man
Copy link
Contributor Author

linux::syscall_read(a, b, c)? linux::syscall_write(a, b c)

Add hundreds of functions?

@data-man
Copy link
Contributor Author

Or just add constdefs?

@lerno
Copy link
Collaborator

lerno commented Feb 25, 2026

I don't see how using constants/enums would be better than macros?

@data-man
Copy link
Contributor Author

Some std modules uses this pattern:

constdef Foo : inline uint
{
    FOO1        = 1,
    FOO2        = 2
}

const uint BAR1 = Foo.FOO1;
const uint BAR2 = Foo.FOO2;

So, what about this:

constdef SysCall : inline uint
{
    <* (unsigned int fd, char *buf, size_t count) *>
    READ         = 0,
    <* (unsigned int fd, const char *buf, size_t count) *>
    WRITE        = 1

    etc.
}

<* (unsigned int fd, char *buf, size_t count) *>
const uint SYS_READ = SysCall.READ;

<* (unsigned int fd, const char *buf, size_t count) *>
const uint SYS_WRITE = SysCall.WRITE;

etc.

@lerno
Copy link
Collaborator

lerno commented Mar 4, 2026

That doesn't answer why it couldn't be macros? Wouldn't that be nicer?

@data-man
Copy link
Contributor Author

That doesn't answer why it couldn't be macros? Wouldn't that be nicer?

How useful are hundreds of macros without ported Linux types to C3 types?

@lerno
Copy link
Collaborator

lerno commented Mar 10, 2026

You are suggesting:

SYS_READ.call(fd, buf, count); 

With everything untyped.

I don't see why one shouldn't do

macro sys_read(uint, char* buf, usz count) { ... }

It seems like a gross misuse of macros and enums?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants