stsp / libi86

fork of https://gitlab.com/tkchia/libi86

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libi86

AppVeyor build statusGitLab pipeline status

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:

  • either a GCC toolchain for 16-bit x86;[2]

  • or the Amsterdam Compiler Kit[3] with the msdos86 target platform.

A few of this library’s functions are also implemented in my lfanew library which is targeted at more modern platforms.[4]

The current aim of libi86 is to be compatible enough with the Open Watcom[5] runtime — as described in the Open Watcom C Library Reference[6] — to be useful for building existing MS-DOS code.

Defining the macro _BORLANDC_SOURCE will also enable some degree of compatibility with the Borland Turbo C++[7] compiler’s C library, which is described in the Borland C++ 2.0 Library Reference[8] and the Borland C++ 3.1 Library Reference.[9]

Synopsis

Use

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 […​]

Installing from pre-compiled Ubuntu Linux packages, for cross development

When using IA-16 GCC:

  • Grab the gcc-ia16-elf and libi86-ia16-elf packages from my build-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:

Building from sources, installing, and testing, on Linux

License

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.)

Implemented facilities

Legend

Compat. Meaning

C99

Part of the C99 standard[14][15] — enable with a macro _ISOC99_SOURCE if necessary.

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 _BORLANDC_SOURCE.

UB

Undocumented (?) functionality from Borland Turbo C++ — enable with _BORLANDC_SOURCE.

W/B

By default, behaves as in Open Watcom; if _BORLANDC_SOURCE is defined, behaves as in Borland C++.

BSD

From the Berkeley Standard Distribution’s C library (BSD libc) and its derivatives.[17]

IC

From internal interfaces in Cosmopolitan libc by Justine Tunney.[18]

IW

From internal interfaces in Open Watcom’s library code.

X

libi86-specific extension; not in Open Watcom or Borland C++. Enabled even if the macros _BORLANDC_SOURCE and _ISOC99_SOURCE are not defined.

X▵

libi86-specific extension. Also implemented in lfanew.[4]

XB

libi86-specific extension. Behaves slightly differently if _BORLANDC_SOURCE is defined.

(❧)

Additional notes on the implementation.

Avail. Meaning

DOS GCC

Platform: IA-16 GCC targeting MS-DOS (ia16-elf-gcc).

ELKS GCC

Platform: IA-16 GCC targeting ELKS[19] (ia16-elf-gcc -melks).

DOS ACK

Platform: ACK targeting MS-DOS (ack-cc -mmsdos86 or ack -mmsdos86).

=

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, libi86 provides its own definition. For example, _getpid () is an alias of getpid () if the C library already defines the latter.

/

Facility is not applicable to this platform.

Functions

Compat. Avail. Function Notes

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <bios.h> ▞▞▞▞▖

W+

=

/

=

_bios_disk (service, *diskinfo);

As an extension, also accepts service = _DISK_DRIVEPARAMS, which returns drive parameters in *diskinfo.

W

=

/

=

_bios_equiplist ();

B

=

/

=

biosequip ();

W

=

/

=

_bios_memsize ();

B

=

/

=

biosmemory ();

W

=

/

=

_bios_keybrd (service);

B

=

/

=

bioskey (service);

W

=

/

=

_bios_printer (service, port, data);

W

=

/

=

_bios_serialcom (service, port, data);

W

=

/

=

_bios_timeofday (service, *timeval);

X

=

/

=

_bios_joystick (unsigned service, union _joyinfo_t *joyinfo);

Reads joystick status via int 0x15 function 0x84.

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <conio.h> ▞▞▞▞▖

  • If _BORLANDC_SOURCE is defined, <conio.h> switches to an alternate implementation of the console output routines which is based on <graph.h> facilities.

W/B

=

=

*cgets (*buf);

W/B

=

=

cprintf (*fmt, …​);

W/B

=

=

cputs (*buf);

W/B

=

=

cscanf (*fmt, …​);

W

=

=

getch ();

W

=

=

_getch ();

W/B

=

=

getche ();

W

=

=

_getche ();

W

=

=

kbhit ();

W

=

=

_kbhit ();

W

=

=

=

ungetch (ch);

W

=

=

_ungetch (ch);

W/B

=

=

putch (ch);

W/B

=

=

vcprintf (*fmt, ap);

W/B

=

=

vcscanf (*fmt, ap);

B

=

=

clreol ();

B

=

=

clrscr ();

B

=

=

delline ();

B

=

=

*getpass (*prompt);

B

=

=

gettextinfo (*text-info);

If the active video mode is a SuperVGA mode, text-info->currmode may be invalid.

B

=

=

gotoxy (x, y);

B

=

=

highvideo ();

B

=

=

insline ();

B

=

=

lowvideo ();

B

=

=

normvideo ();

B

=

=

textattr (new-attr);

B

=

=

textbackground (new-color);

B

=

=

textcolor (new-color);

B

=

=

textmode (mode);

Does not support mode = LASTMODE yet.

B

=

=

wherex ();

B

=

=

wherey ();

B

=

=

window (left, top, right, bottom);

W

=

=

inp (port);

W

=

=

_inp (port);

B

=

=

inportb (port);

W

=

=

inpw (port);

W

=

=

_inpw (port);

B

=

=

inport (port);

Returns a signed value.

B

=

=

inportw (port);

Returns an unsigned value.

W

=

=

outp (port, value);

W

=

=

_outp (port, value);

B

=

=

outportb (port, value);

W

=

=

outpw (port, value);

W

=

=

_outpw (port, value);

B

=

=

outport (port, value);

Accepts a signed value to write.

B

=

=

outportw (port, value);

Accepts an unsigned value to write.

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <dir.h> ▞▞▞▞▖

B (❧)

=

=

searchpath (file);

X (❧)

=

=

_searchpath (file);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <direct.h> ▞▞▞▞▖

P01, W

(=)

(=)

chdir (*path);

(POSIX places this function in <unistd.h>.)

W

:=

:=

_chdir (*path);

P01, W

(=)

(=)

getcwd (*buffer, size);

(POSIX places this function in <unistd.h>.)

W

:=

:=

_getcwd (*buffer, size);

W

=

=

_getdcwd (drive, *buffer, size);

W

=

=

_getdrive ();

P01 (❧)

(=)

:

(=)

mkdir (*path, mode);

  • In Watcom, both mkdir and _mkdir take only a single path argument.

  • POSIX however says that mkdir (placed in <sys/stat.h>) takes two arguments; the second argument gives Unix-style permission bits.

  • For compatibility with both, libi86 under gcc-ia16 allows both mkdir and _mkdir to be called with either one or two arguments.

  • Under ACK, however, _mkdir will always only take one argument, and mkdir will take two (unless ACK’s C library says otherwise).

X (❧)

=

_mkdir (*path, mode);

W

(=)

mkdir (*path);

W

=

=

_mkdir (*path);

P01, W

(=)

:

(=)

rmdir (*path);

(POSIX places this function in <unistd.h>.)

W

:=

:=

_rmdir (*path);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <dos.h> ▞▞▞▞▖

  • <dos.h> also includes <i86.h>, described below.

  • If _BORLANDC_SOURCE is defined, the union REGS type gets an additional .x.flags field, and <dos.h> switches accordingly to a different version of the intdos and intdosx routines.

W (❧)

=

=

bdos (dos-func, dx, al);

B

=

=

bdosptr (dos-func, *dx, al);

W/B

=

/

=

intdos (*in-regs, *out-regs);

W/B

=

/

=

intdosx (*in-regs, *out-regs, *seg-regs);

W+

=

/

=

_dos_allocmem (size, *segment);

Also works under DPMI; yields a starting protected-mode selector.

W

=

/

=

_dos_close (handle);

W

=

/

=

_dos_commit (handle);

W

=

/

=

_dos_creat (*path, attr, *handle);

W

=

/

=

_dos_creatnew (*path, attr, *handle);

W

=

/

=

_dos_findfirst (*path, attributes, *buffer);

W

=

/

=

_dos_findnext (*buffer);

W

=

/

=

_dos_findclose (*buffer);

W+

=

/

=

_dos_freemem (segment);

Also works under DPMI; accepts a starting protected-mode selector.

W

=

/

=

_dos_getdate (*date);

W

=

/

=

_dos_getdiskfree (drive, *disk-space);

W

=

/

=

_dos_getdrive (*drive);

W

=

/

=

_dos_getfileattr (*path, *attributes);

W

=

/

=

_dos_getftime (handle, *date, *time);

W

=

/

=

_dos_gettime (*time);

W

=

/

=

*_dos_getvect (intr-no);

  • Some versions of gcc-ia16 and ACK may not understand the interrupt function attribute. In that case, this function will return a far data pointer.

  • This function is not yet supported for "dual mode" programs that may run under either 16- or 32-bit DPMI (gcc-ia16 -mdosx32).

W

=

/

=

_dos_keep (status, keep-paras);

B

=

/

=

keep (status, keep-paras);

W

=

/

=

_dos_open (*path, mode, *handle);

W

=

/

=

_dos_read (handle, *buf, count, *bytes);

  • _dos_read always directly invokes the relevant syscall (int 0x21 function 0x3f), without transforming the input bytes.

  • Under ACK — but not gcc-ia16 — the C library’s read function may behave differently from _dos_read: it may translate CRLFs to LFs, and interpret end-of-file indicators (ASCII 26), if handle is open 'd in "text mode".

W

=

/

=

_dos_setblock (size, seg, *max-size);

W

=

/

=

_dos_setdate (*date);

W

=

/

=

_dos_setdrive (drive, *total);

W

=

/

=

_dos_setfileattr (*path, attributes);

W

=

/

=

_dos_setftime (handle, date, time);

W

=

/

=

_dos_settime (*time);

W

=

/

=

_dos_setvect (intr-no, *handler);

  • Some versions of gcc-ia16 and ACK may not understand the interrupt function attribute. In that case, this function will not be supported.

  • This function is not yet supported for "dual mode" programs that may run under either 16- or 32-bit DPMI (gcc-ia16 -mdosx32).

X

=

/

=

_dos_spawn (unsigned char subfunc, const char *path, union _dosspawn_t *params);

int 0x21 function 0x4b (for subfunc ≠ 4) or 0x80 (for subfunc = 4). Returns an error code on error, 0 on success.

X

=

/

=

_dos_wait (unsigned *error-level);

int 0x21 function 0x4d.

W

=

/

=

_dos_write (handle, *buf, count, *bytes);

  • _dos_write always directly invokes the relevant syscall (int 0x21 function 0x40), without transforming the output bytes.

  • Under ACK — but not gcc-ia16 — the C library’s write function may behave differently from _dos_write: it may translate LFs to CRLFs if handle is open 'd in "text mode".

W

=

/

=

dosexterr (*err-info);

B

=

/

=

_getdrive ();

UB

=

/

=

getswitchar ();

Returns the (nominal) character for command line switches — usually '/' — per int 0x21, %ax = 0x3700.

X

=

/

=

_getswitchar ();

B

=

/

=

*getvect (intr-no);

Some versions of gcc-ia16 and ACK may not understand the interrupt function attribute. In that case, this function will return a far data pointer.

X

=

/

=

*_getsysvars ();

int 0x21 function 0x52.

X

=

/

=

_makefcb (*cmd-line, *fcb, opt);

  • Parses cmd-line[] into a DOS 1.x-style File Control Block (FCB) — via int 0x21, %ah = 0x29.

  • Returns a struct _makefcb_t structure (result):

    • result._status is either 0 (parse successful, no wildcards), 1 (parse successful, found wildcards), or -1 (invalid drive);

    • result._tail points to the first unparsed character, or may be NULL if a system error occurred.

  • cmd-line[] should end with either a null character, a carriage return ('\r'), or a new line ('\n').

  • In non-Borland mode, fcb should point to a struct _fcb (with underscore), rather than a struct fcb.

  • This function provides more detailed information on the parse than the more "standardized" parsfnm function below.

X

=

/

=

*_parsfnm (*cmd-line, *fcb, opt);

  • Parses cmd-line[] into a DOS 1.x-style File Control Block (FCB) — via int 0x21, %ah = 0x29.

  • cmd-line[] should end with either a null character, a carriage return ('\r'), or a new line ('\n').

  • In non-Borland mode, fcb should point to a struct _fcb (with underscore), rather than a struct fcb.

B

=

/

=

*parsfnm (*cmd-line, *fcb, opt);

UB

=

/

=

setswitchar (ch);

Sets the (nominal) character for command line switches, with int 0x21, %ax = 0x3701.

X

=

/

=

_setswitchar (ch);

B

=

/

=

setvect (intr-no, *handler);

Some versions of gcc-ia16 and ACK may not understand the interrupt function attribute. In that case, this function will not be supported.

B

=

=

=

peek (segment, offset);

B

=

=

=

peekb (segment, offset);

B

=

=

=

poke (segment, offset, word-value);

B

=

=

=

pokeb (segment, offset, byte-value);

B

=

=

inportb (port);

B

=

=

inport (port);

Returns a signed value.

B

=

=

inportw (port);

Returns an unsigned value.

B

=

=

outportb (port, value);

B

=

=

outport (port, value);

Accepts a signed value to write.

B

=

=

outportw (port, value);

Accepts an unsigned value to write.

UB

=

=

inp (port);

In non-Borland mode, these functions are declared only in <conio.h>.

UB

=

=

inpw (port);

UB

=

=

outp (port, value);

UB

=

=

outpw (port, value);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <dpmi.h> ▞▞▞▞▖

  • Except for __DPMI_hosted () and _DPMIIdle (), functions in <dpmi.h> should only be called when the caller knows it is running in DPMI mode.

  • <dpmi.h> is not supported for GCC for ELKS, or for ACK for MS-DOS.

IW

=

/

__DPMI_hosted ();

Returns 1 if running in protected mode under DPMI, -1 otherwise. If the underlying C library has an implementation of this function, libi86 will use that instead.

IW

=

/

_DPMIAllocateDOSMemoryBlock (paras);

int 0x31 function 0x0100. Returns a structure giving the real mode segment and protected mode selector for the DOS memory block. On failure, returns { 0, 0 }.

IW

=

/

_DPMIAllocateLDTDescriptors (count);

int 0x31 function 0x0000. Returns a starting protected-mode selector, cast to an int32_t. On failure, returns a negative value.

IW

=

/

_DPMIAllocateMemoryBlock (*blk, bytes);

int 0x31 function 0x0500. On success, returns 0, and fills *blk with the linear address and handle for the new memory block. On failure, returns -1; *blk is undefined.

IW

=

/

_DPMICreateCodeSegmentAliasDescriptor (sel);

int 0x31 function 0x000a. Returns a data selector, cast to an int32_t. On failure, returns a negative value.

IW

=

/

_DPMIFreeDOSMemoryBlock (sel);

int 0x31 function 0x0101. Returns 0 on success, -1 on error.

IW

=

/

_DPMIFreeLDTDescriptor (sel);

int 0x31 function 0x0001. Returns 0 on success, -1 on error.

IW

=

/

_DPMIFreeMemoryBlock (handle);

int 0x31 function 0x0502. Returns 0 on success, -1 on error.

X

=

/

_DPMIGetCapabilities (uint16_t *capabilities-1, uint16_t *reserved-2, uint16_t *reserved-3, dpmi_host_info __far *host-info);

int 0x31 function 0x0401. Returns 0 on success, -1 on error.

IW

=

/

_DPMIGetDescriptor (sel, *desc);

int 0x31 function 0x000b. Returns 0 on success, -1 on error.

IW

=

/

_DPMIGetNextSelectorIncrementValue ();

int 0x31 function 0x0003.

IW

=

/

_DPMIGetSegmentBaseAddress (sel);

int 0x31 function 0x0006. Returns sel's base address on success; return value is undefined on error.

IW

=

/

*_DPMIGetVendorSpecificAPI (*vendor);

int 0x2f function 0x168a. Returns a far null pointer on error.

X

=

/

_DPMIGetVirtualInterruptState ();

int 0x31 function 0x0902. Returns true if virtual interrupts enabled, false otherwise.

IW

=

/

_DPMIIdle ();

int 0x2f function 0x1680. This implementation also returns a byte value saying whether this function call is actually supported (0x00), or not (0x80). It is OK to ignore this value.

IW

=

/

_DPMIModeDetect ();

int 0x2f function 0x1686. Returns 0 if running in protected mode, non-zero otherwise. Unlike __DPMI_hosted (), this function only returns valid results if a DPMI host is known to be present.

IW

=

/

_DPMISegmentToDescriptor (seg-para);

int 0x31 function 0x0002. On success, returns a protected-mode selector value for the real-mode segment seg-para_:0. On failure, returns a negative value.

IW

=

/

_DPMISetDescriptor (sel, *desc);

int 0x31 function 0x000c. Returns 0 on success, -1 on error.

IW

=

/

_DPMISetDescriptorAccessRights (sel, ar);

int 0x31 function 0x0009. Returns 0 on success, -1 on error.

IW

=

/

_DPMISetSegmentBaseAddress (sel, addr);

int 0x31 function 0x0007. Returns 0 on success, -1 on error.

IW

=

/

_DPMISetSegmentLimit (sel, lim);

int 0x31 function 0x0008. Returns 0 on success, -1 on error.

IW

=

/

_DPMISimulateRealModeInterrupt (inter-no, reset, words-to-copy, *call-struct);

int 0x31 function 0x0300. Returns 0 on success, -1 on error. words-to-copy should probably be 0.

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <err.h> ▞▞▞▞▖

BSD

=

=

=

err (error-level, *fmt, …​);

BSD

=

=

=

errx (error-level, *fmt, …​);

BSD

=

=

=

verr (error-level, *fmt, ap);

BSD

=

=

=

verrx (error-level, *fmt, ap);

BSD

=

=

=

vwarn (*fmt, ap);

BSD

=

=

=

vwarnx (*fmt, ap);

BSD

=

=

=

warn (*fmt, …​);

BSD

=

=

=

warnx (*fmt, …​);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <graph.h> ▞▞▞▞▖

  • Unlike in Open Watcom, where all functions in <graph.h> are far, in libi86 the far-ness of functions follows the chosen memory model. Thus, in a small-memory-model program, _setvideomode is a near function. However, pointers to data are still far.

W

=

=

_clearscreen (area);

W

=

=

_displaycursor (curs-mode);

W

=

=

_gettextposition ();

X

=

=

_getvideomode ();

W

=

=

_outmem (*text, length);

W

=

=

_outtext (*text);

W

=

=

_scrolltextwindow (rows);

W

=

=

_setbkcolor (color);

W

=

=

_settextcolor (pix-val);

W

=

=

_settextposition (row, col);

W

=

=

_settextwindow (row1, col1, row2, col2);

W

=

=

_setvideomode (mode);

In the case of SuperVGA screen modes, only works with VESA interface.

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <i86.h> ▞▞▞▞▖

  • If _BORLANDC_SOURCE is defined, the union REGS type gets an additional .x.flags field, and <i86.h> switches accordingly to a different version of the int86, int86x, _int86f, and _int86xf routines.

W

=

=

=

delay (ms);

W

=

=

=

nosound ();

W

=

=

=

sound (freq);

W

=

=

=

segread (*seg-regs);

W

=

=

=

_disable ();

W

=

=

=

_enable ();

W/B

=

=

=

int86 (inter-no, *in-regs, *out-regs);

W/B

=

=

=

int86x (inter-no, *in-regs, *out-regs, *seg-regs);

W

=

=

=

intr (inter-no, *regs);

Clears SZAPC flags to 0 before issuing interrupt. (This follows a documentation change in Open Watcom versions after Oct 2018.)

XB

=

=

=

_int86f (inter-no, *in-regs, *out-regs);

Loads carry flag before issuing interrupt.

XB

=

=

=

_int86xf (inter-no, *in-regs, *out-regs, *seg-regs);

Loads carry flag before issuing interrupt.

W

=

=

=

intrf (inter-no, *regs);

Loads SZAPC flags before issuing interrupt.

X

=

=

=

_intrf (inter-no, *regs);

Loads SZAPC flags before issuing interrupt.

W

=

=

=

FP_OFF (*ptr);

Macro.

W

=

=

=

_FP_OFF (*ptr);

Macro.

W

=

=

=

FP_SEG (*ptr);

Macro.

W

=

=

=

_FP_SEG (*ptr);

Macro.

W

=

=

=

*MK_FP (seg, off);

Macro.

W

=

=

=

*_MK_FP (seg, off);

Macro.

X

=

=

=

*_CV_FP ([const volatile void *]ptr);

Convert a default-sized pointer to a far pointer. This is mainly useful for ACK, which lacks built-in far pointer support.

X

=

=

=

_FP_EQ ([const volatile void __far *]ptr1, [const volatile void __far *]ptr2);

Test whether two far pointers are exactly equal. This is mainly useful for ACK, which lacks built-in far pointer support.

X

=

=

=

_FP_EQ_NULL ([const volatile void __far *]ptr);

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

▗▚▚▚▚ <io.h> ▞▞▞▞▖

  • <io.h> also includes the underlying C library’s <unistd.h>.

X▵

=

=

=

_binmode (handle);

  • Sets the POSIX-style file handle to do untranslated (binary) I/O — so that read and write calls with the handle will not translate between LF and CRLF, nor specially interpret bytes that look like end-of-file indicators.

  • Upon an error, this function returns -1 and sets errno.

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <process.h> ▞▞▞▞▖

P01, W

(=)

:

(=)

getpid ();

(POSIX places this function in <unistd.h>.)

W

:=

:=

_getpid ();

W+ (❧)

=

=

_spawnl (mode, *path, *arg, …​ /* NULL */);

  • For these functions, libi86 purposely deviates from Open Watcom’s documented behaviour in a few ways.

  • libi86 currently only implements the P_WAIT spawning mode (and a special P_WAIT | _P_RESTRICT_EXT submode).

  • See the implementation notes for details.

W+ (❧)

=

=

_spawnle (mode, *path, *arg, …​ /* NULL, *envp */);

W+ (❧)

=

=

_spawnlp (mode, *path, *arg, …​ /* NULL */);

W+ (❧)

=

=

_spawnlpe (mode, *path, *arg, …​ /* NULL, *envp */);

W+ (❧)

=

=

spawnv (mode, *path, *argv);

W+ (❧)

=

=

_spawnv (mode, *path, *argv);

W+ (❧)

=

=

spawnve (mode, *path, *argv, *envp);

W+ (❧)

=

=

_spawnve (mode, *path, *argv, *envp);

W+ (❧)

=

=

spawnvp (mode, *path, *argv);

W+ (❧)

=

=

_spawnvp (mode, *path, *argv);

W+ (❧)

=

=

spawnvpe (mode, *path, *argv, *envp);

W+ (❧)

=

=

_spawnvpe (mode, *path, *argv, *envp);

P01

(=)

(=)

system (*command);

(POSIX and C89 (ISO/IEC 9899:1990) place this function in <stdlib.h>.)

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <libi86/malloc.h> ▞▞▞▞▖

  • <libi86/malloc.h> also includes the underlying C library’s <malloc.h>.

  • Under newer versions of gcc-ia16, <malloc.h> will also automatically include <libi86/malloc.h>, unless GCC is in "strict ANSI" mode.

W (❧)

=

=

*_ffree (*ptr);

W (❧)

=

=

*_fmalloc (size);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <libi86/stdio.h> ▞▞▞▞▖

  • <libi86/stdio.h> also includes the underlying C library’s <stdio.h>.

  • Under newer versions of gcc-ia16, <stdio.h> will also automatically include <libi86/stdio.h>, unless GCC is in "strict ANSI" mode.

C99, W

(=)

:

vsscanf (*s, *fmt, ap);

(C99 places this function in <stdio.h>.)

X

:=

_vsscanf (*s, *fmt, ap);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <libi86/stdlib.h> ▞▞▞▞▖

  • <libi86/stdlib.h> also includes the underlying C library’s <stdlib.h>.

  • Under newer versions of gcc-ia16, <stdlib.h> will also automatically include <libi86/stdlib.h>, unless GCC is in "strict ANSI" mode.

W (❧)

=

=

*_fullpath (*out-path, *path, size);

W

=

*lltoa (value, *buffer, radix);

Not yet supported on ACK — it lacks long long support for IA-16.

W

=

*_lltoa (value, *buffer, radix);

Not yet supported on ACK — it lacks long long support for IA-16.

W

=

=

*ltoa (value, *buffer, radix);

W

=

=

*_ltoa (value, *buffer, radix);

W+ (❧)

=

=

_makepath (*path, *drive, *dir, *fname, *ext);

  • As extensions, this function

    • checks for buffer overflow, and

    • gives a return value.

  • Upon an error, the return value is non-zero, errno is set, and path[] holds either an empty string or a truncated path.

  • Network drive[] values starting with two backslashes (\\) are not supported.

W (❧)

=

=

_splitpath (*path, *drive, *dir, *fname, *ext);

Long filenames, and network paths starting with two backslashes (\\), are not supported.

W (❧)

=

=

_searchenv (*name, *env-var, *buf);

P01

(=)

(=)

system (*command);

W

=

*ulltoa (value, *buffer, radix);

Not yet supported on ACK — it lacks long long support for IA-16.

W

=

*_ulltoa (value, *buffer, radix);

Not yet supported on ACK — it lacks long long support for IA-16.

W

=

=

*ultoa (value, *buffer, radix);

W

=

=

*_ultoa (value, *buffer, radix);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <libi86/string.h> ▞▞▞▞▖

  • <libi86/string.h> also includes the underlying C library’s <string.h>.

  • Under newer versions of gcc-ia16, <string.h> will also automatically include <libi86/string.h>, unless GCC is in "strict ANSI" mode.

W

=

=

*_fmemchr (*s, c, n);

W

=

=

_fmemcmp (*s1, *s2, n);

W

=

=

*_fmemcpy (*dest, *src, n);

W

=

=

*_fmemmove (*dest, *src, n);

X

=

=

*_fmempcpy (*dest, *src, n);

Like _fmemcpy, but returns dest + n.

W

=

=

*_fmemset (*s, c, n);

X

=

=

*_fstpcpy (*dest, *src);

Like _fstrcpy, but returns dest + _fstrlen (src).

W

=

*_fstrcat (*dest, *src);

W

=

=

*_fstrcpy (*dest, *src);

W

=

=

=

_fstricmp (*s1, *s2);

W

=

=

_fstrlen (*s);

W

=

=

=

stricmp (*s1, *s2);

Calls strcasecmp (s1, s2) if the C library defines it.

W

=

=

=

_stricmp (*s1, *s2);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <nexgen/kompress.h> ▞▞▞▞▖

IC

=

=

=

*lz4cpy (*dest, *blk-src, blk-size);

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

=

=

=

*_lz4cpy (*dest, *blk-src, blk-size);

IC

=

=

=

lz4len (*blk-src, blk-size);

Parses an LZ4-compressed block and returns its uncompressed size, without actually unpacking it. Returns 0 if the uncompressed length cannot fit into a size_t. It is best to use this function only on trusted input.

X

=

=

=

_lz4len (*blk-src, blk-size);

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <nexgen/mzendian.h> ▞▞▞▞▖

  • Routines for accessing unaligned little endian binary data in a type-checked manner.

  • <nexgen/mzendian.h> also includes <stdint.h>.

X▵

=

=

=

_hle16 (x);

X▵

=

=

=

_hle32 (x);

X▵

=

=

_hle64 (x);

X▵

=

=

=

_leh16 (x);

X▵

=

=

=

_leh32 (x);

X▵

=

=

=

_leh32hi (x);

X▵

=

=

=

_leh32lo (x);

X▵

=

=

_leh64 (x);

X▵

=

=

=

_leh64hi (x);

X▵

=

=

=

_leh64lo (x);

Variables

Compat. Avail. Variable Notes

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <libi86/stdlib.h> ▞▞▞▞▖

W

(=)

/

(=)

_osmajor

Implemented as a function call on ACK.

W

(=)

/

(=)

_osminor

Implemented as a function call on ACK.

W

(=)

/

(=)

_psp

Implemented as a function call on ACK.

Types

Compat. Avail. Type Notes

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <bios.h> ▞▞▞▞▖

W

=

/

=

struct diskinfo_t

X

=

/

=

union _joyinfo_t

Used by _bios_joystick.

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <conio.h> ▞▞▞▞▖

B

=

=

enum COLORS

B

=

=

struct text_info

B

=

=

enum text_modes

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <dos.h> ▞▞▞▞▖

W

=

/

=

struct diskfree_t

W

=

/

=

struct dosdate_t

X

=

/

=

union _dosspawn_t

Used by _dos_spawn.

W

=

/

=

struct dostime_t

B

=

/

=

struct fcb

X

=

/

=

struct _fcb

Used by _makefcb and _parsfnm.

W

=

/

=

struct find_t

X

=

/

=

struct _makefcb_t

Returned by _makefcb.

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <dpmi.h> ▞▞▞▞▖

IW

=

descriptor

Structure of a GDT or LDT entry, used by _DPMIGetDescriptor and _DPMISetDescriptor.

IW

=

/

dpmi_dos_block

Returned by _DPMIAllocateDOSMemoryBlock.

X

=

/

dpmi_host_info

Used by _DPMIGetCapabilities.

IW

=

/

rm_call_struct

Used by _DPMISimulateRealModeInterrupt.

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <graph.h> ▞▞▞▞▖

W

=

=

grcolor

W

=

=

struct rccoord

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <i86.h> ▞▞▞▞▖

X

=

=

=

_fptr_t

"Generic" far pointer type.

  • For target platforms with far pointer support, _fptr_t is equivalent to void __far *.

  • For targets which lack far pointer support (e.g. ACK), _fptr_t is an opaque structure type.

W

=

=

=

union REGPACK

W/B

=

=

=

union REGS

In _BORLANDC_SOURCE mode, gets an additional .x.flags field.

W

=

=

=

struct SREGS

DOS GCC

ELKS GCC

DOS ACK

▗▚▚▚▚ <nexgen/mzendian.h> ▞▞▞▞▖

X▵

=

=

=

uint_le16_t

Unaligned 16-, 32-, or 64-bit little endian binary numeral. These types can be used directly inside a struct or union corresponding to a binary file structure, but should otherwise be treated as opaque.

X▵

=

=

=

uint_le32_t

X▵

=

=

uint_le64_t


1. Yann Collet, et al. LZ4 1.9.4 Manual, 2022. LZ4 block format description. https://github.com/lz4/lz4/blob/dev/doc/lz4_Frame_format.md.
6. Open Watcom Contributors, et al. Open Watcom C Library Reference, 2022. https://github.com/open-watcom/open-watcom-v2-wikidocs/blob/master/docs/clib.pdf. Retrieved on 6 Jan 2022.
8. Borland International. Borland C++ 2.0 Library Reference, 1991. https://archive.org/details/bitsavers_borlandborn2.0LibraryReference1991_17218611.
9. Borland International. Borland C++ 3.1 Library Reference, 1991—​1992. https://archive.org/details/bitsavers_borlandborn3.1LibraryReference1992_19008612.
14. International Organization for Standardization, and International Electrotechnical Commission. ISO/IEC 9899:1999: Programming Languages: C, 1999.
15. International Organization for Standardization, and International Electrotechnical Commission. ISO/IEC 9899:TC3: Committee Draft — September 7, 2007. WG14/N1256, 2007. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf.
16. Institute of Electrical and Electronics Engineers, and The Open Group. IEEE Std 1003.1, 2004 Edition, 2004. https://pubs.opengroup.org/onlinepubs/009695399/.
17. See e.g.: FreeBSD Project. FreeBSD Manual Pages, 2023. https://man.freebsd.org/cgi/man.cgi.

About

fork of https://gitlab.com/tkchia/libi86

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:C 51.8%Language:Assembly 38.2%Language:Shell 4.5%Language:Makefile 3.2%Language:M4 1.9%Language:C++ 0.4%Language:DIGITAL Command Language 0.0%