Follow OpenBSD's KNF programming style when writing C. Follow Meson's documentation when writing Meson.
Here's a checklist:
- Add your name and (optionally) a mail address to the copyright of every file you modify.
- Put the name of every function you added in CHANGELOG.md. Create the file it if it doesn't exist.
- Run this:
meson setup -Dtest_system=true build && meson test -C build
. Did it fail? Don't break the build.
Headers are generated with a simple DSL by
src/header_generator.c. It's essentially our own
#pragma
for the C language. The purpose of the DSL is to ship clean headers
without an #ifdef
forest.
Every subdirectory under src/ is named after a header. stdlib/ for
stdlib.h and err/ for err.h and so on. All the functions inside each
subdirectory belong to that header. Instead of piling up #ifdef
s, I've chosen
to split each "backend" that implements a function into its own file.
Feature detection is used unless something is impossible to detect.
I don't intend to implement deprecated functions like rindex()
, or silly
functions like getbsize()
. I trust the underlying platform, if it is buggy, fix
the bug at the source instead of working around it.
It's very easy to support all the systems in this category because we have working CI for them.
Download the latest stable and check out the include/ subdirectory.
Look at the emscripten headers at system/include/, and musl headers at system/lib/libc/musl/include/.
They have a nice man.freebsd.org website with all the man pages.
The wiki explains a little, Linux man-pages is good but unofficial, and the official documentation is the ultimate authority on it.
Browse the headers at headers/.
"These manual pages are a subset of the Mac OS X manual pages". keith/xcode-man-pages.
Mingw conveniently provides some useful functions on top of Microsoft's C
system API and runtimes, for instance neither ucrt nor msvcrt implement
getopt()
, but Mingw provides it for you. Mingw's headers also require less
kludging than Windows' and the project provides export libraries Microsoft
doesn't like advapi32.def. Thus, Microsoft's documentation is not strictly
correct when used for understanding Mingw. For instance, Microsoft's
RtlGenRandom documentation tells us to use the runtime loader to access the
function, but Mingw's advapi32.def allows us to link against the library that
contains it at compile time.
Browse the C runtime headers at mingw-w64-headers/crt/ and Windows system headers at mingw-w64-headers/include/.
Browse the headers at newlib/libc/include.
Browse the headers at include/.
See man.netbsd.org.
Microsoft has a UCRT alphabetical function reference. MSVC compiler options. I can't find MSVCRT documentation. It's best to browse MinGW headers and then trial and error the build in that case.
Using __declspec(dllimport).
CRT functions not supported in Universal Windows Platform apps.
It seems some functions like RtlGenRandom()
have UWP availability listed in the
function's page, while others like chdir()
have it in that page.
The oldest supported Windows version is Windows 7 for a variety of reasons.
When making Windows syscalls, check that they're supported by Windows 7, and
that they're available both in "Desktop apps" and "UWP apps". The Microsoft
documentation can be wrong here, for instance, SecureZeroMemory()
is allowed
in "UWP apps," but the documentation doesn't state this.
I was unable to get working CI for these systems, but libobsd intends to work with them.
Browse the man pages.
Browse the headers at include/.