This is a code library which attempts to reimplement non-standard C library facilities (e.g. <conio.h>
) commonly used in classical MS-DOS programs. The library also implements
-
a few standard facilities which are part of newer C language standards, where the underlying C library lacks them;
-
and extra routines for LZ4[1] data decompression.
For now, the library is meant to be used with the following compilers and targets:
A few of this library’s functions are also implemented in my lfanew
library which is targeted at more modern platforms.[4]
When using IA-16 GCC:
-
ia16-elf-gcc
[…gcc-options… …input-files…]-li86
[…] -
On a MS-DOS host:
i16gcc
[…gcc-options… …input-files…]-li86
[…]
When using ACK:
-
ack-cc -mmsdos86 -.c
[…ack-options… …input-files…]-li86.a
[…] -
Or (if compiler is installed as
ack
):ack -mmsdos86 -.c
[…ack-options… …input-files…]-li86.a
[…]
When using IA-16 GCC:
-
Grab the
gcc-ia16-elf
andlibi86-ia16-elf
packages from mybuild-ia16
PPA.[10] -
You can now (June 2022) also install and run
libi86
's self-test suite. Instructions for doing so are available.
When using ACK:
-
Grab the
ack-compiler
andlibi86-ack
packages from myde-rebus
PPA.[11]
-
Detailed instructions for building the code are available.
-
You can download the
libi86
source code from GitLab[12] or Codeberg.[13]
libi86
as a whole is now distributed under the 3-clause BSD License.
(A few files are distributed under other licenses, but in ways that are ultimately compatible with the BSD License.)
Compat. | Meaning |
---|---|
C99 |
Part of the C99 standard[14][15] — enable with a macro |
P01 |
Part of the POSIX.1-2001[16] standard. |
W |
Behaves like the corresponding function in Open Watcom. |
W+ |
Behaves like the corresponding function in Open Watcom, but with some extended behaviours. |
B |
From Borland Turbo C++ — enable with |
UB |
Undocumented (?) functionality from Borland Turbo C++ — enable with |
W/B |
By default, behaves as in Open Watcom; if |
BSD |
From the Berkeley Standard Distribution’s C library (BSD |
IC |
From internal interfaces in Cosmopolitan |
IW |
From internal interfaces in Open Watcom’s library code. |
X |
|
X▵ |
|
XB |
|
(❧) |
Additional notes on the implementation. |
Avail. | Meaning |
---|---|
DOS GCC |
Platform: IA-16 GCC targeting MS-DOS ( |
ELKS GCC |
Platform: IA-16 GCC targeting ELKS[19] ( |
DOS ACK |
Platform: ACK targeting MS-DOS ( |
= |
Facility is available for this platform. |
(=) |
Facility is available if this platform does not already define this facility itself. |
: |
This platform already defines this facility. |
:= |
Facility is available for this platform. If the C library already defines the corresponding standard library function — usually without a leading underscore — then this function is defined as an alias of the standard function; otherwise, |
/ |
Facility is not applicable to this platform. |
Compat. | Avail. | Function | Notes | ||
---|---|---|---|---|---|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W+ |
= |
/ |
= |
|
As an extension, also accepts service = |
W |
= |
/ |
= |
|
|
B |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
B |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
B |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
X |
= |
/ |
= |
|
Reads joystick status via |
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W/B |
= |
= |
* |
||
W/B |
= |
= |
|
||
W/B |
= |
= |
|
||
W/B |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W/B |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
= |
|
|
W |
= |
= |
|
||
W/B |
= |
= |
|
||
W/B |
= |
= |
|
||
W/B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
* |
||
B |
= |
= |
|
If the active video mode is a SuperVGA mode, text-info |
|
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
Does not support mode = |
|
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
B |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
B |
= |
= |
|
Returns a signed value. |
|
B |
= |
= |
|
Returns an unsigned value. |
|
W |
= |
= |
|
||
W |
= |
= |
|
||
B |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
B |
= |
= |
|
Accepts a signed value to write. |
|
B |
= |
= |
|
Accepts an unsigned value to write. |
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
B (❧) |
= |
= |
|
||
X (❧) |
= |
= |
|
||
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
P01, W |
(=) |
(=) |
|
(POSIX places this function in |
|
W |
:= |
:= |
|
||
P01, W |
(=) |
(=) |
|
(POSIX places this function in |
|
W |
:= |
:= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
P01 (❧) |
(=) |
: |
(=) |
|
|
X (❧) |
= |
|
|||
W |
(=) |
|
|||
W |
= |
= |
|
||
P01, W |
(=) |
: |
(=) |
|
(POSIX places this function in |
W |
:= |
:= |
|
||
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W (❧) |
= |
= |
|
||
B |
= |
= |
|
||
W/B |
= |
/ |
= |
|
|
W/B |
= |
/ |
= |
|
|
W+ |
= |
/ |
= |
|
Also works under DPMI; yields a starting protected-mode selector. |
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W+ |
= |
/ |
= |
|
Also works under DPMI; accepts a starting protected-mode selector. |
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
* |
|
W |
= |
/ |
= |
|
|
B |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
X |
= |
/ |
= |
|
|
X |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
B |
= |
/ |
= |
|
|
UB |
= |
/ |
= |
|
Returns the (nominal) character for command line switches — usually |
X |
= |
/ |
= |
|
|
B |
= |
/ |
= |
* |
Some versions of |
X |
= |
/ |
= |
* |
|
X |
= |
/ |
= |
|
|
X |
= |
/ |
= |
* |
|
B |
= |
/ |
= |
* |
|
UB |
= |
/ |
= |
|
Sets the (nominal) character for command line switches, with |
X |
= |
/ |
= |
|
|
B |
= |
/ |
= |
|
Some versions of |
B |
= |
= |
= |
|
|
B |
= |
= |
= |
|
|
B |
= |
= |
= |
|
|
B |
= |
= |
= |
|
|
B |
= |
= |
|
||
B |
= |
= |
|
Returns a signed value. |
|
B |
= |
= |
|
Returns an unsigned value. |
|
B |
= |
= |
|
||
B |
= |
= |
|
Accepts a signed value to write. |
|
B |
= |
= |
|
Accepts an unsigned value to write. |
|
UB |
= |
= |
|
In non-Borland mode, these functions are declared only in |
|
UB |
= |
= |
|
||
UB |
= |
= |
|
||
UB |
= |
= |
|
||
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
IW |
= |
/ |
|
Returns 1 if running in protected mode under DPMI, -1 otherwise. If the underlying C library has an implementation of this function, |
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
X |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
* |
|
|
X |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
IW |
= |
/ |
|
|
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
BSD |
= |
= |
= |
|
|
BSD |
= |
= |
= |
|
|
BSD |
= |
= |
= |
|
|
BSD |
= |
= |
= |
|
|
BSD |
= |
= |
= |
|
|
BSD |
= |
= |
= |
|
|
BSD |
= |
= |
= |
|
|
BSD |
= |
= |
= |
|
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
X |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
In the case of SuperVGA screen modes, only works with VESA interface. |
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W |
= |
= |
= |
|
|
W |
= |
= |
= |
|
|
W |
= |
= |
= |
|
|
W |
= |
= |
= |
|
|
W |
= |
= |
= |
|
|
W |
= |
= |
= |
|
|
W/B |
= |
= |
= |
|
|
W/B |
= |
= |
= |
|
|
W |
= |
= |
= |
|
Clears |
XB |
= |
= |
= |
|
Loads carry flag before issuing interrupt. |
XB |
= |
= |
= |
|
Loads carry flag before issuing interrupt. |
W |
= |
= |
= |
|
Loads |
X |
= |
= |
= |
|
Loads |
W |
= |
= |
= |
|
Macro. |
W |
= |
= |
= |
|
Macro. |
W |
= |
= |
= |
|
Macro. |
W |
= |
= |
= |
|
Macro. |
W |
= |
= |
= |
* |
Macro. |
W |
= |
= |
= |
* |
Macro. |
X |
= |
= |
= |
* |
Convert a default-sized pointer to a far pointer. This is mainly useful for ACK, which lacks built-in far pointer support. |
X |
= |
= |
= |
|
Test whether two far pointers are exactly equal. This is mainly useful for ACK, which lacks built-in far pointer support. |
X |
= |
= |
= |
|
Test whether a far pointer is null. This is mainly useful for ACK, which lacks built-in far pointer support. |
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
X▵ |
= |
= |
= |
|
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
P01, W |
(=) |
: |
(=) |
|
(POSIX places this function in |
W |
:= |
:= |
|
||
W+ (❧) |
= |
= |
|
|
|
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
W+ (❧) |
= |
= |
|
||
P01 |
(=) |
(=) |
|
(POSIX and C89 (ISO/IEC 9899:1990) place this function in |
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W (❧) |
= |
= |
* |
||
W (❧) |
= |
= |
* |
||
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
C99, W |
(=) |
: |
|
(C99 places this function in |
|
X |
:= |
|
|||
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W (❧) |
= |
= |
* |
||
W |
= |
* |
Not yet supported on ACK — it lacks |
||
W |
= |
* |
Not yet supported on ACK — it lacks |
||
W |
= |
= |
* |
||
W |
= |
= |
* |
||
W+ (❧) |
= |
= |
|
|
|
W (❧) |
= |
= |
|
Long filenames, and network paths starting with two backslashes ( |
|
W (❧) |
= |
= |
|
||
P01 |
(=) |
(=) |
|
||
W |
= |
* |
Not yet supported on ACK — it lacks |
||
W |
= |
* |
Not yet supported on ACK — it lacks |
||
W |
= |
= |
* |
||
W |
= |
= |
* |
||
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W |
= |
= |
* |
||
W |
= |
= |
|
||
W |
= |
= |
* |
||
W |
= |
= |
* |
||
X |
= |
= |
* |
Like |
|
W |
= |
= |
* |
||
X |
= |
= |
* |
Like |
|
W |
= |
* |
|||
W |
= |
= |
* |
||
W |
= |
= |
= |
|
|
W |
= |
= |
|
||
W |
= |
= |
= |
|
Calls |
W |
= |
= |
= |
|
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
IC |
= |
= |
= |
* |
Unpacks an LZ4-compressed block. Returns the address of the byte after the unpacked data. It is best to use this function only on trusted input. |
X |
= |
= |
= |
* |
|
IC |
= |
= |
= |
|
Parses an LZ4-compressed block and returns its uncompressed size, without actually unpacking it. Returns 0 if the uncompressed length cannot fit into a |
X |
= |
= |
= |
|
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
X▵ |
= |
= |
= |
|
|
X▵ |
= |
= |
= |
|
|
X▵ |
= |
= |
|
||
X▵ |
= |
= |
= |
|
|
X▵ |
= |
= |
= |
|
|
X▵ |
= |
= |
= |
|
|
X▵ |
= |
= |
= |
|
|
X▵ |
= |
= |
|
||
X▵ |
= |
= |
= |
|
|
X▵ |
= |
= |
= |
|
Compat. | Avail. | Variable | Notes | ||
---|---|---|---|---|---|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W |
(=) |
/ |
(=) |
|
Implemented as a function call on ACK. |
W |
(=) |
/ |
(=) |
|
Implemented as a function call on ACK. |
W |
(=) |
/ |
(=) |
|
Implemented as a function call on ACK. |
Compat. | Avail. | Type | Notes | ||
---|---|---|---|---|---|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W |
= |
/ |
= |
|
|
X |
= |
/ |
= |
|
Used by |
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
B |
= |
= |
|
||
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W |
= |
/ |
= |
|
|
W |
= |
/ |
= |
|
|
X |
= |
/ |
= |
|
Used by |
W |
= |
/ |
= |
|
|
B |
= |
/ |
= |
|
|
X |
= |
/ |
= |
|
Used by |
W |
= |
/ |
= |
|
|
X |
= |
/ |
= |
|
Returned by |
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
IW |
= |
|
Structure of a GDT or LDT entry, used by |
||
IW |
= |
/ |
|
Returned by |
|
X |
= |
/ |
|
Used by |
|
IW |
= |
/ |
|
Used by |
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
W |
= |
= |
|
||
W |
= |
= |
|
||
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
X |
= |
= |
= |
|
"Generic" far pointer type.
|
W |
= |
= |
= |
|
|
W/B |
= |
= |
= |
|
In |
W |
= |
= |
= |
|
|
DOS GCC |
ELKS GCC |
DOS ACK |
|
||
X▵ |
= |
= |
= |
|
Unaligned 16-, 32-, or 64-bit little endian binary numeral. These types can be used directly inside a |
X▵ |
= |
= |
= |
|
|
X▵ |
= |
= |
|