mlibc is a C standard library

Overview

mlibc is a C standard library

Continuous Integration

Official Discord server: https://discord.gg/7WB6Ur3

Design of the library

Directory Purpose
options/ (More or less) OS-independent headers and code.
options/ is divided into subdirectories that can be enabled or disabled by ports.
sysdeps/ OS-specific headers and code.
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.
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/sysdeps.hpp. Which subset you need depends on the options that sysdeps/some-new-os/meson.build enables.

Local Development

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
Comments
  • sysdeps/linux: Include unistd.h in sys/syscall.h

    sysdeps/linux: Include unistd.h in sys/syscall.h

    I got compilation failures if this header is not included, I'm unsure about whether this is correct, so feedback is appreciated.

    Part of the mlibc LFS project.

    opened by Dennisbonke 7
  • options/posix: use rwlock to protect global key array

    options/posix: use rwlock to protect global key array

    As per the discussion on Discord.

    This allows pthread_getspecific to call itself recursively, which may happen under ASan (which hooks __tls_get_addr and calls pthread_getspecific). It also allows keys to be created and destroyed inside a key destructor.

    opened by 64 7
  • tests: run test suite under host libc too

    tests: run test suite under host libc too

    This PR adds support for running the test suite with the host libc, which should serve as a useful sanity check that the tests are functioning correctly. We have already found a few bugs in our implementation from this.

    opened by 64 7
  • options/posix: Overhaul glob.h

    options/posix: Overhaul glob.h

    The definitions in glob.h (GLOB_APPEND and friends) now match glibc and musl. Some missing definitions were added. Struct glob_t was updated to match glibc.

    opened by Dennisbonke 6
  • Implement strptime().

    Implement strptime().

    This PR partially implements strptime() and adds tests for the parts which are implemented. Most of the unimplemented parts depend on locale functionality. Issue #276 is related to this.

    opened by ikbenlike 6
  • Start work on systemd compilation support

    Start work on systemd compilation support

    This PR adds initial work to get systemd compiling on Managarm. For now, this PR is a draft, but currently it adds a bunch of constants and missing headers, 1 new struct and 1 function definition. As more is coming, this PR remains in draft, but can at any moment in time be merged, should fixes in this PR be requested in master.

    opened by Dennisbonke 6
  • Various additions and fixes

    Various additions and fixes

    This PR adds the following functions:

    • pselect(), stubbed in to make bc happy
    • dprintf(), stubbed in to satisfy a test program in weston

    Furthermore, the following changes have been made:

    • The macro FD_SETSIZE has been moved to bits/posix/fd_set.h. This change allows git to compile, but may not be ideal.
    • The macro SCNuMAX has been defined, again, this makes git happy

    ~~This PR is blocked pending inclusion of pr managarm/managarm#178~~(Has been merged) ~~This PR is blocked pending inclusion of pr managarm/managarm#180~~(Has been merged)

    opened by Dennisbonke 6
  • options/linux: Include certain linux specific headers in sys/syscall.h if we're linux

    options/linux: Include certain linux specific headers in sys/syscall.h if we're linux

    After #525 was merged, programs still refused to use the syscall macro, claiming it couldn't be found. This fixes that problem.

    Part of mlibc LFS project.

    opened by Dennisbonke 5
  • linux-headers: add linux/fuse.h file

    linux-headers: add linux/fuse.h file

    This PR adds a linux kernel header necessary for supporting FUSE. As far as I can tell, no other changes would need occur in mlibc to implement FUSE in managarm later on.

    opened by ikbenlike 0
  • Various header additions for systemd part 2

    Various header additions for systemd part 2

    HARD BLOCKED ON #766

    This PR is my internal staging area for systemd. I will cherry-pick commits into smaller chunks, that are actually reviewable, as this is of course not doable.

    opened by Dennisbonke 0
  • Various header additions for systemd

    Various header additions for systemd

    No code changes in this one, only defines and the like. It is just a handful of changes, and will help us compile systemd one day.

    Part of the systemd on Managarm project.

    opened by Dennisbonke 0
  • options/internal: fix compilation on clang

    options/internal: fix compilation on clang

    Previously, guarding the different operator deletes was done in the name of different mangling, which according to c++filt is not the case. To rectify this, both operator deletes will now get compiled in, as they do take different arguments.

    opened by no92 3
  • Several fixes for claws to work

    Several fixes for claws to work

    While working on claws, we hit a few problems which I fixed. This PR includes an implementation of fgets_unlocked, strxfrm, a bunch of the mntent family of functions and two missing strftime specifiers. I also included tests for the missing specifiers and fixed a failing posix_spawn test under debian (no, not everyone has /bin symlinked to /usr/bin, debian unstable apparently doesn't).

    opened by Dennisbonke 1
  • options/rtdl: Load scope fix

    options/rtdl: Load scope fix

    If the local load scope is requested at object load, but said local scope is null, we happily pass a nullptr down which later blows up in our face. To avoid this, I introduced a simple check to see if the local scope is requested, and if so, if the local scope to be used is set to something that's not a nullptr. This fixes hexchat on Managarm once more.

    opened by Dennisbonke 0
Owner
The Managarm Project
The Managarm Project
Thrust is a C++ parallel programming library which resembles the C++ Standard Library.

Thrust: Code at the speed of light Thrust is a C++ parallel programming library which resembles the C++ Standard Library. Thrust's high-level interfac

NVIDIA Corporation 4.3k Nov 19, 2022
jkds is a modern header-only C++20 library that complements the standard library.

jkds is a modern header-only C++20 library that complements the standard library. It provides generic atypical data structures, ergonomic functional programming abstractions, and then some.

Alberto Schiabel 6 Nov 16, 2022
Bionic BSD-3-ClauseBionic - Google's standard library, developed for Android. BSD-3-Clause

bionic bionic is Android's C library, math library, and dynamic linker. Using bionic as an app developer See the user documentation. Working on bionic

Android Open Source Project 561 Nov 24, 2022
CloudABI's standard C library

NOTE: This project is unmaintained CloudABI is no longer being maintained. It was an awesome experiment, but it never got enough traction to be sustai

Nuxi 275 Oct 30, 2022
libcu++: The C++ Standard Library for Your Entire System

libcu++, the NVIDIA C++ Standard Library, is the C++ Standard Library for your entire system. It provides a heterogeneous implementation of the C++ Standard Library that can be used in and between CPU and GPU code.

NVIDIA Corporation 2.1k Nov 20, 2022
EASTL stands for Electronic Arts Standard C++ Template Library

EASTL stands for Electronic Arts Standard Template Library. It is an extensive and robust implementation that has an emphasis on high performance.

Electronic Arts 6.8k Nov 23, 2022
An open source standard C library that includes useful functions && (Reimplementation of libc functions + own functions).

?? LIBFT-42 : Artistic view of LIBC: ?? HOW DOES IT FEEL HAVING YOUR OWN LIB: SUBJECT : ENGLISH PDF ℹ️ What is LIBFT : This project aims to code a C l

Abdessamad Laamimi 10 Nov 4, 2022
Your standard library for metaprogramming

Boost.Hana Your standard library for metaprogramming Overview #include <boost/hana.hpp> #include <cassert> #include <string> namespace hana = boost::h

Boost.org 1.4k Nov 26, 2022
Reimplementation of some of the Standard C Library functions.

42-libft Reimplementation of some of the Standard C Library functions. This repository contains some of the standard library C functions. List of avai

Lavrenova Maria 6 Sep 29, 2022
STXXL: Standard Template Library for Extra Large Data Sets

STXXL is an implementation of the C++ standard template library STL for external memory (out-of-core) computations

STXXL 436 Nov 1, 2022
MSVC's implementation of the C++ Standard Library.

Microsoft's C++ Standard Library This is the official repository for Microsoft's implementation of the C++ Standard Library (also known as the STL), w

Microsoft 8.3k Nov 24, 2022
A standard conforming C++20 implementation of std::optional.

A standard conforming C++20 implementation of std::optional.

null 31 Aug 24, 2022
Library that simplify to find header for class from STL library.

Library that simplify to find header for class from STL library. Instead of searching header for some class you can just include header with the class name.

null 6 Jun 7, 2022
D++ Extremely Lightweight C++ Discord Library

D++ An incredibly lightweight C++ Discord library This project is in alpha stages of development. Completed so far: Websocket connection with heartbea

brainbox.cc 547 Nov 22, 2022
Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags.

Single-header header-only C++11 / C++14 / C++17 library for easily managing set of auto-generated type-safe flags. Quick start #include <bitflags/bitf

Marin Peko 76 Nov 22, 2022
expected lite - Expected objects in C++11 and later in a single-file header-only library

expected lite: expected objects for C++11 and later expected lite is a single-file header-only library for objects that either represent a valid value

Martin Moene 240 Nov 22, 2022
Guidelines Support Library

GSL: Guidelines Support Library The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the C++ Core Guideline

Microsoft 5.2k Nov 21, 2022
gsl-lite – A single-file header-only version of ISO C++ Guidelines Support Library (GSL) for C++98, C++11, and later

gsl-lite: Guidelines Support Library for C++98, C++11 up metadata build packages try online gsl-lite is an implementation of the C++ Core Guidelines S

gsl-lite 765 Nov 28, 2022
C++11 metaprogramming library

Mp11, a C++11 metaprogramming library Mp11 is a C++11 metaprogramming library based on template aliases and variadic templates. It implements the appr

Boost.org 180 Nov 25, 2022