Skip to content

netbsd port: round 0#1518

Open
lzcunt wants to merge 8 commits into
managarm:masterfrom
lzcunt:netbsd
Open

netbsd port: round 0#1518
lzcunt wants to merge 8 commits into
managarm:masterfrom
lzcunt:netbsd

Conversation

@lzcunt

@lzcunt lzcunt commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

These are some various patches with the common theme of reducing Linux-isms and GNU-isms that are needed to port to NetBSD.

It turns out, NetBSD does not use these values. It should be safe to not
require them.
NetBSD doesn't follow the common values for these a_types so we should
move them to ABI.
BSDs do not have these errno values, they're Linux-isms.
`fchown` was implemented with `fchownat` using `AT_EMPTY_PATH` which is
sadly a Linux extension. Let's make fchown a sysdep so it can be
implemented separately for the NetBSD port.
CBAUD is not POSIX and NetBSD does not have CBAUD. These functions can
probably be implemented without CBAUD but I do not know how.
This defines _GNU_SOURCE and other macros to expose as much as possible
from the mlibc headers when building mlibc itself.
@lzcunt lzcunt force-pushed the netbsd branch 2 times, most recently from 1aeaa55 to 6400ac9 Compare December 9, 2025 06:43

@no92 no92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave it a first pass.

Comment thread abis/lemon/auxv.h
Comment thread abis/dripos/auxv.h
Comment thread abis/aero/auxv.h
}

int fchown(int fd, uid_t uid, gid_t gid) {
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_fchownat, -1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possibility would be to try to use sys_fchownat and fall back to a sys_fchown.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason would that be preferred?

#include <bits/ensure.h>
#include <mlibc/posix-sysdeps.hpp>

#ifdef CBAUD

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CBAUD is XSI-reserved, technically; the solution here would be to have a sysdep to implement this in the OS-specific way.

Comment thread meson.build
mlibc_c_args = ['-Wno-unused-function', '-D__MLIBC_BUILDING_MLIBC', '-nostdinc', '-fno-builtin', '-ffreestanding']
mlibc_link_args = ['-nostdlib']
add_project_arguments('-Werror=misleading-indentation', language: ['c', 'cpp'])
add_project_arguments('-D_DEFAULT_SOURCE', '-D_GNU_SOURCE', language: ['c', 'cpp'])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All arguments but _GNU_SOURCE are certainly wrong; _DEFAULT_SOURCE should be set by mlibc-config.h, and the rest is set to sane values by default.

The _GNU_SOURCE case is more interesting on BSDs - I assume it is not defined there, even for C++?

Comment thread options/posix/generic/unistd.cpp
@lzcunt

lzcunt commented Dec 10, 2025

Copy link
Copy Markdown
Contributor Author

I have no idea why the dripOS and friends keep reappearing every time I get rid of them

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants