• R/O
  • SSH

posixpp: Repository summary

The main posixpp library and associated tests.

Recent Commits RSS

Rev. Time Author Message
bb4d09951cda 2020-07-14 00:45:06 Eric Hopper tip More tests, start actually testing file descriptor.
cecefe266947 2020-07-14 00:43:18 Eric Hopper Require posixpp shared object for tests.
c5bdc47d3297 2020-07-13 15:51:13 Eric Hopper Add a whole bunch of tests using Catch2.
7d83a4b7b32b 2020-07-13 15:50:55 Eric Hopper Ignore various IDE droppings.
bfd378be8d50 2020-07-12 15:19:59 Eric Hopper Add a README about what I'm up to and why.
69a0d6b09ed6 2020-07-12 15:02:11 Eric Hopper Create a simple file descriptor object and a test for it.
1b1449f24553 2020-07-12 14:57:46 Eric Hopper Oops, base expected on variant since unions won't work.
87509514f5a6 2020-07-12 13:48:08 Eric Hopper Added LGPL.
ef8242156095 2020-07-12 13:30:24 Eric Hopper A simple C++ only system call interface.
eb5208a2a6b2 2019-05-21 19:10:33 Eric Hopper Initial checkin.

Recently edited Tags

Name Rev. Time Author
tip bb4d09951cda 2020-07-14 00:45:06 Eric Hopper


Name Rev. Time Author Message
default bb4d09951cda 2020-07-14 00:45:06 Eric Hopper More tests, start actually ...


A pure C++ Posix interface

With this project, I intend to implement many parts of Posix in pure C++ without any reliance on libc.

Part of the motivation for this is that glibc and pthreads are very bloated with features that are rarely used in most programs.

Another part of the motivation is that 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.

To this end, a subgoal is to implement the system call interface for many architectures (and potentially many operating systems) as inline assembly inside of inline functions.

A third part of the motivation is to eliminate the horrible hack that is errno. 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.

To this end, 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.

Show on old repository browser