• R/O
  • SSH

posixpp: Repository summary

The main posixpp library and associated tests.

Recent Commits RSS

Rev. Time Author Message
7188050a1ebe 2021-02-21 12:28:11 Eric Hopper tip Revert CMake version since LGTM doesn't support C++20.
322a7a67473e 2021-02-21 12:16:59 Eric Hopper Configure git submodules like hg submodules is configured.
f08563246236 2021-02-21 12:00:44 Eric Hopper Lower required revision of CMake so LGTM can work.
a0e636a57e56 2021-02-19 16:18:19 Eric Hopper Touchups on fd class. Documentation, moving stuff around,...
c017ac4845af 2021-02-17 11:51:25 Eric Hopper Several small changes. 1. Use noexcept in more places. 2...
0bdb02fe5844 2021-02-17 08:07:26 Eric Hopper Fix warning about discard return value by adding error ha...
02855f3edde6 2021-02-17 04:59:29 Eric Hopper Explanatory comment.
e38807a6aaf9 2021-02-17 04:59:28 Eric Hopper Add permbits for use for the 'mode' argument.
a3ea6857c2f8 2021-01-21 06:57:12 Eric Hopper Update interface for tests.
a206782e27d7 2021-01-21 05:16:45 Eric Hopper Add fdflags.h for flags associated with a file descriptor.

Recently edited Tags

Name Rev. Time Author
tip 7188050a1ebe 2021-02-21 12:28:11 Eric Hopper


Name Rev. Time Author Message
default 7188050a1ebe 2021-02-21 12:28:11 Eric Hopper Revert CMake version since ...


A pure C++ Posix interface

With this project, I intend to implement many parts of Posix in pure C++ without any reliance on libc. There are several motivations for this:

  1. glibc and pthreads are very bloated with features that are rarely used in most programs.
  2. System calls are not exposed to the C++ optimizer in a useful way. The register stores and loads required to make them work can often be combined with the calculations a program is already doing so that the values mysteriously appear in the registers when needed instead of having to be moved there just before the system call.
  3. errno is a horrible hack that is a throwback to a single threaded era and a language that could not sensibly return both error conditions and proper return values from the same function. errno is the bane of clean error handling, and it requires expensive to access thread local storage to implement. Error returns should not be global variables.

For motivation 2 I intend to implement the system call interface for many architectures (and potentially many operating systems) as inline assembly inside of inline functions.

For motivation 3, a simple expected type is used for error handling at every level of the interface. This also causes default error handling (if you just assume the expected object always contains the expected value) to throw an exception whenever errors are ignored. And if you purposely check for errors, all code relating to exceptions will be optimized out of existence.

Ideally, parts of the C++ standard library that rely on operating system facilities would also be implemented in this library.

For example, pthreads is a terrible interface, designed when threading was mysterious, strange, complex, and rare. And it was designed for old ideas about how threads should synchronize. It's far more expensive to use than it should be for simple mutexes and condition variables.

IOstreams isn't the best part of C++. But, being able to implement it while ignoring C's stdio might make things easier.

Lastly, it would be really nice to have a preprocessor namespace that isn't chock full macro definitions (most of which are just using the preprocessor to implement constants in a throwback to the days before C90). And it would be nice to have names and types for various flags passed to various system calls that made it easier to write correct programs.

As a side note, I really like Mercurial, and so the canonical repo is at OSDN: https://osdn.net/projects/posixpp/scm/hg/posixpp

Show on old repository browser