libc11
is a public domain implementation of the C11 (ISO/IEC 9899:2011)
standard library.
- Supports the Linux, FreeBSD, OpenBSD, NetBSD, Solaris, and Mac OS X platforms.
- Currently targets the System V ABI for x86 and x86-64, and the EABI for ARM.
- Clean and modular design, most features can be omitted when building.
- No build prerequisites beyond a GNU-compatible toolchain and a C99 compiler.
- 100% free and unencumbered public domain software, usable in any context and for any purpose.
This table summarizes which C11 features are implemented at present:
Header | Spec | Description | Status |
---|---|---|---|
<assert.h> | C11 7.2 | Diagnostics. | WIP |
<complex.h> | C11 7.3 | Complex arithmetic. | |
<ctype.h> | C11 7.4 | Character handling. | Implemented. |
<errno.h> | C11 7.5 | Errors. | Implemented. [1] |
<fenv.h> | C11 7.6 | Floating-point environment. | |
<float.h> | C11 7.7 | Characteristics of floating types. | Implemented. |
<inttypes.h> | C11 7.8 | Format conversion of integer types. | WIP |
<iso646.h> | C11 7.9 | Alternative spellings. | Implemented. |
<limits.h> | C11 7.10 | Sizes of integer types. | Implemented. |
<locale.h> | C11 7.11 | Localization. | Stubbed. |
<math.h> | C11 7.12 | Mathematics. | WIP |
<setjmp.h> | C11 7.13 | Nonlocal jumps. | |
<signal.h> | C11 7.14 | Signal handling. | WIP |
<stdalign.h> | C11 7.15 | Alignment. | Implemented. |
<stdarg.h> | C11 7.16 | Variable arguments. | Implemented. [2] |
<stdatomic.h> | C11 7.17 | Atomics. | WIP |
<stdbool.h> | C11 7.18 | Boolean type and values. | Implemented. |
<stddef.h> | C11 7.19 | Common definitions. | Implemented. |
<stdint.h> | C11 7.20 | Integer types. | WIP |
<stdio.h> | C11 7.21 | Input/output. | WIP |
<stdlib.h> | C11 7.22 | General utilities. | WIP |
<stdnoreturn.h> | C11 7.23 | _Noreturn . |
Implemented. |
<string.h> | C11 7.24 | String handling. | WIP |
<tgmath.h> | C11 7.25 | Type-generic math. | |
<threads.h> | C11 7.26 | Threads. | |
<time.h> | C11 7.27 | Date and time. | |
<uchar.h> | C11 7.28 | Unicode utilities. | |
<wchar.h> | C11 7.29 | Wide character utilities. | Omitted. [3] |
<wctype.h> | C11 7.30 | Wide character utilities. | Omitted. [3] |
Footnotes
[1] | Thread-local storage not supported as yet. |
[2] | Currently implemented only for the Clang and GCC compilers. |
[3] | (1, 2) Legacy wide-character support purposely omitted from the library. |
Platform | Architecture | Binary Interface | Compilers |
---|---|---|---|
Bare metal | any | N/A | Clang, GCC |
Linux | ARMv6+ [4] | ARM EABI | Clang, GCC |
Linux | x86 | i386 SysV ABI | Clang, GCC |
Linux | x86-64 | AMD64 SysV ABI | Clang, GCC |
FreeBSD | x86-64 | AMD64 SysV ABI | Clang, GCC |
OpenBSD | x86-64 | AMD64 SysV ABI | Clang, GCC |
NetBSD | x86-64 | AMD64 SysV ABI | Clang, GCC |
Solaris | x86-64 | AMD64 SysV ABI | Clang, GCC |
Mac OS X | x86-64 | AMD64 SysV ABI | Clang, GCC |
Footnotes
[4] | The armhf architecture providing a hardware floating-point unit (FPU). |
See http://build.libc11.org for the current build status on all supported platforms.
Configuring, building, and installing the library (by default, into
/usr/local
) are all performed with the standard incantations:
$ ./autogen.sh # for a development checkout only $ ./configure $ make $ sudo make install
By default on most platforms that support both, the library will be built
both as a static library (libc.a
) as well as a dynamic shared library
(libc.so
on most Unix systems, though libc.dylib
on Darwin).
If you don't require a shared library, configure the build accordingly:
$ ./configure --disable-shared
The library is thoroughly modular. Specific header files and their
underlying function implementations can be omitted using the familiar
./configure --disable-FEATURE
facility provided by Autoconf.
For example, if you don't require any numerics support, you might as well disable the floating-point routines and the mathematics library, as follows:
$ ./configure --disable-complex --disable-fenv --disable-float --disable-math
To review the list of features, see the output of ./configure --help
.
The special none target operating system builds the library with a
system-call interface where all system operations are simply no-op stubs.
See the sys/syscall.h
header file and the sys/posix/none/
directory
for the syscall stubs that a bare-metal user of libc11 must implement.
The following example shows how one might configure a cross-compilation build on an x86-64 Linux system, targeting an x86-64 bare-metal system:
$ ./configure --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-none
Provided your linker supports weak symbols, you can configure the libc11
build as per the aforementioned example, and then when linking libc11 into
your kernel provide your own syscall implementations as strong symbols that
override the default no-op stubs from sys/posix/none/
.
Find this project at: GitHub, Bitbucket, Open Hub, SourceForge, Travis CI, Coverity Scan, Twitter, Tumblr, and COD5. See also the project's Buildbot.
Many other open-source implementations of the C standard library exist, though most of them are licensed more restrictively than this implementation:
Project | License | Status | x86 | x86-64 | ARM | ARM64 | MIPS | MIPS64 | Miscellaneous |
---|---|---|---|---|---|---|---|---|---|
PDCLib | PD/CC0 | Active | Yes | Yes | ? | ? | ? | ? | incomplete |
PDPCLIB | PD | Active? | Yes | No | No | No | No | No | S/3x0 |
Bionic | BSD | Active | Yes | Yes | Yes | Yes | Yes | Yes | for Android |
dietlibc | GPL | Active? | Yes | Yes | Yes | No | Yes | Yes | many targets |
EGLIBC | LGPL | Inactive | Yes | Yes | Yes | Yes | Yes | Yes | discontinued |
glibc | LGPL | Active | Yes | Yes | Yes | Yes | Yes | Yes | many targets |
klibc | GPL/BSD | Active | Yes | Yes | Yes | No | Yes | Yes | many targets |
musl | MIT | Active | Yes | Yes | Yes | No | Yes | No | PPC, MicroBlaze |
Newlib | LGPL/BSD/etc | Active | Yes | Yes | Yes | Yes | Yes | Yes | many targets |
olibc | BSD | Active? | Yes | Yes | Yes | Yes | Yes | Yes | fork of Bionic |
OSv | MIT/BSD | Active | No | Yes | No | Yes | No | No | written in C++ |
uClibc | LGPL | Active | Yes | Yes | Yes | No | Yes | Yes | many targets |
This project is part of the DRY initiative.
If you found this software useful and would like to encourage its maintenance and further development, please consider making a $5 donation to the author(s) via Gratipay or Bitcoin.
This is free and unencumbered public domain software. For more information,
see http://unlicense.org/ or the accompanying UNLICENSE
file.