# mlibc is a C standard library
![Continuous Integration](https://github.com/managarm/mlibc/workflows/Continuous%20Integration/badge.svg)
**Official Discord server:** https://discord.gg/7WB6Ur3
**AUR package** (provides `mlibc-gcc`): https://aur.archlinux.org/packages/mlibc
## Design of the library
| Directory | Purpose |
| --- | --- |
| `options/` | (More or less) OS-independent headers and code.<br>`options/` is divided into subdirectories that can be enabled or disabled by ports.|
| `sysdeps/` | OS-specific headers and code.<br>`sysdeps/` is divded into per-port subdirectories. Exactly one of those subdirectories is enabled in each build.|
| `abis/` | OS-specific interface headers ("ABI headers"). Those contain the constants and structs of the OS interface. For example, the numerical values of `SEEK_SET` or `O_CREAT` live here, as well as structs like `struct stat`. ABI headers are _only_ allowed to contain constants, structs and unions but _no_ function declarations or logic.<br>`abis/` is divided into per-OS subdirectories but this division is for organizational purposes only. Ports can still mix headers from different `abis/` subdirectories.|
## Porting mlibc to a new OS
Ports to new OSes are welcome. To port mlibc to another OS, the following changes need to be made:
1. Add new `sysdeps/` subdirectory `sysdeps/some-new-os/` and a `meson.build` to compile it. Integreate `sysdeps/some-new-os/meson.build` into the toplevel `meson.build`.
2. Create ABI headers in `abis/some-new-os/`. Add symlinks in `sysdeps/some-new-os/include/abi-bits` to your ABI headers. Look at existing ports to figure out the ABI headers required for the options enabled by `sysdeps/some-new-os/meson.build`.
3. In `sysdeps/some-new-os/`, add code to implement (a subset of) the functions from `options/internal/include/mlibc/internal-sysdeps.hpp`. Which subset you need depends on the options that `sysdeps/some-new-os/meson.build` enables.
We recommend that new ports do not build from `master` as we occasionally make internal changes that cause out-of-tree sysdeps to break. Instead we recommend you pin a specific release (or commit), or to upstream your changes to this repository so that we can build them on our CI and thus any breakages will be fixed by us in-tree.
## Build Configuration
The following custom meson options are accepted, in addition to the [built-in options](https://mesonbuild.com/Builtin-options.html). The options below are booleans which default to false (see `meson_options.txt`).
- `headers_only`: Only install headers; don't build `libc.so` or `ld.so`.
- `mlibc_no_headers`: Don't install headers; only build `libc.so` and `ld.so`.
- `build_tests`: Build the test suite (see below).
- `disable_x_option`: Disable `x` component of mlibc functionality. See `meson_options.txt` for a full list of possible values for `x`. This may be used to e.g disable POSIX and glibc extensions.
- `linux_kernel_headers`: Allows for directing mlibc to installed linux headers. [These can be obtained easily](https://docs.kernel.org/kbuild/headers_install.html), placed in a directory and this option set to the corresponding path. This is required if the linux option is enabled, i.e. when the linux option is not disabled.
The type of library to be built (static, shared, or both) is controlled by meson's `default_library` option. Passing `-Ddefault_library=static` effectively disables the dynamic linker.
We also support building with `-Db_sanitize=undefined` to use UBSan inside mlibc. Note that this does not enable UBSan for external applications which link against `libc.so`, but it can be useful during development to detect internal bugs (e.g when adding new sysdeps).
## Running Tests
The `mlibc` test suite can be run under a Linux host. To do this, first run from the project root:
```
meson -Dbuild_tests=true build
```
This will create a `build` directory. Then, `cd build` and run the tests (showing output) with:
```
meson test -v
```
没有合适的资源?快使用搜索试试~ 我知道了~
Portable C standard library.zip
共1530个文件
h:719个
c:407个
cpp:215个
需积分: 5 0 下载量 121 浏览量
2023-12-31
11:01:18
上传
评论
收藏 1.03MB ZIP 举报
温馨提示
Portable C standard library
资源推荐
资源详情
资源评论
收起资源包目录
Portable C standard library.zip (1530个子文件)
meson.build 17KB
meson.build 9KB
meson.build 6KB
meson.build 4KB
meson.build 4KB
meson.build 3KB
meson.build 3KB
meson.build 3KB
meson.build 2KB
meson.build 2KB
meson.build 2KB
meson.build 2KB
meson.build 2KB
meson.build 2KB
meson.build 2KB
meson.build 761B
meson.build 641B
meson.build 641B
meson.build 584B
meson.build 582B
meson.build 546B
meson.build 526B
meson.build 409B
meson.build 409B
meson.build 318B
meson.build 181B
meson.build 177B
meson.build 177B
meson.build 177B
meson.build 168B
meson.build 166B
meson.build 165B
meson.build 155B
regcomp.c 74KB
regexec.c 28KB
exp2l.c 20KB
__rem_pio2_large.c 16KB
exp2.c 14KB
j0.c 14KB
j1.c 13KB
powl.c 12KB
erfl.c 12KB
lgammal.c 12KB
lgamma_r.c 10KB
pow.c 10KB
erf.c 10KB
j0f.c 9KB
j1f.c 8KB
fmal.c 8KB
glob.c 8KB
powf.c 7KB
fnmatch.c 7KB
jn.c 7KB
expm1.c 7KB
tgammal.c 6KB
lgammaf_r.c 6KB
getopt.c 6KB
tgamma.c 5KB
atanl.c 5KB
sqrt.c 5KB
__tanl.c 5KB
erff.c 5KB
sprintf.c 5KB
time.c 5KB
log10l.c 5KB
logl.c 5KB
log2l.c 4KB
pthread_attr.c 4KB
jnf.c 4KB
__rem_pio2l.c 4KB
__rem_pio2.c 4KB
log1pl.c 4KB
strtol.c 4KB
exp.c 4KB
casin.c 4KB
tre-mem.c 4KB
log.c 4KB
exp2f.c 4KB
log2.c 4KB
fma.c 4KB
__tan.c 4KB
atan.c 4KB
wordexp.c 4KB
log1p.c 4KB
__cosl.c 4KB
cbrt.c 4KB
catan.c 4KB
expm1l.c 4KB
expl.c 3KB
csqrt.c 3KB
asin.c 3KB
cproj.c 3KB
casinh.c 3KB
cacos.c 3KB
atan2.c 3KB
cbrtl.c 3KB
fmaf.c 3KB
cpow.c 3KB
cacosh.c 3KB
clog.c 3KB
共 1530 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
资源评论
暮苍梧~
- 粉丝: 41
- 资源: 258
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功