• R/O
  • SSH

posixpp: Source Tree

The main posixpp library and associated tests.


名称 大小 Rev. 时间 作者 Log Message
.gitmodules 82 322a7a67473e 2021-02-21 12:16:59 Eric Hopper <hopper@omnifarious.org> Configure git submodules like hg subm...
.hgignore 96 510383d3b583 2021-04-28 00:28:07 Eric Hopper <hopper@omnifarious.org> Ignore a directory full of saved expe...
.hgsub 53 f764ab0708ed 2020-10-25 16:58:24 Eric Hopper <hopper@omnifarious.org> Use Catch2 as a sub-module rather tha...
.hgsubstate 48 24a7c6e1a249 2021-04-28 21:39:34 Eric Hopper <hopper@omnifarious.org> Update to latest version of Catch2 fo...
CMakeLists.txt 2.4 k 845b89885277 2021-05-03 15:30:36 Eric Hopper <hopper@omnifarious.org> Make read, write, and open be 'free' ...
LICENSE 7.47 k 87509514f5a6 2020-07-12 13:48:08 Eric Hopper <hopper@omnifarious.org> Added LGPL.
README.md 2.51 k 66c686689061 2021-01-16 16:41:49 Eric Hopper <hopper@omnifarious.org> Update README.md to make location of ...
buildtools e38807a6aaf9 2021-02-17 04:59:28 Eric Hopper <hopper@omnifarious.org> Add permbits for use for the 'mode' a...
empty.cpp 54 69a0d6b09ed6 2020-07-12 15:02:11 Eric Hopper <hopper@omnifarious.org> Create a simple file descriptor objec...
examples 901261d5fd16 2022-01-12 01:03:33 Eric Hopper <hopper@omnifarious.org> Add sample compile command so I don't...
pubincludes 5f78080a2b88 2022-12-08 23:28:42 Eric Hopper <hopper@omnifarious.org> Add some comments inspired by a ChatG...
tempdevjunk.cpp 54 7d104087c5a4 2021-04-25 07:46:38 Eric Hopper <hopper@omnifarious.org> Add target to use for temporary devel...
tests 857a394ad592 2022-01-11 04:19:25 Eric Hopper <hopper@omnifarious.org> Fix various random clang-tidy complai...

README.md

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