| 1 | KEEP IN SYNC WITH lib/posix.h |
| 2 | |
| 3 | this header makes available commonly used POSIX (Portable Operating System |
| 4 | Interface) definitions, e.g. thread, file I/O and socket APIs. |
| 5 | on Linux and OS X we just include the requisite headers; Win32 doesn't really |
| 6 | support POSIX (+), so we have to implement everything ourselves. |
| 7 | |
| 8 | |
| 9 | rationale: this is preferable to a wrapper for several reasons: |
| 10 | * less code (implementation is only needed on Win32) |
| 11 | * no lock-in (the abstraction may prevent not-designed-for operations that the POSIX interface would have allowed) |
| 12 | * familiarity (many coders already know POSIX) |
| 13 | |
| 14 | |
| 15 | if a useful definition is missing, feel free to add it! |
| 16 | |
| 17 | |
| 18 | implementation reference is the [http://www.unix.org/online.html "Single Unix Specification v3"] - it's similar to the POSIX standard (superset?) and freely available. |
| 19 | |
| 20 | |
| 21 | |
| 22 | + Win32 does have a POSIX subsystem (mandated by a government contract), |
| 23 | but it is crippled. only apps with the PE header 'subsystem' field set to |
| 24 | "POSIX" can use the appendant DLL, and then they can't call the regular |
| 25 | Windows APIs. this is obviously unacceptable - GDI is needed to set up OpenGL. |
| 26 | |
| 27 | we therefore need to emulate POSIX functions using the Win32 API. |
| 28 | fortunately, many POSIX functions are already implemented in the VC CRT and |
| 29 | need only be renamed (e.g. _open, _stat). |