Files
Sprinter-SDCC/libc/include/errno.h
T
snark13 60373930fb libc: Solid-C совместимость (П3) + rename/isatty (П4); scanf-семейство
- <dos.h>: getdate/gettime/setdate/settime (структуры Turbo-C, обёртки
  над getdatetime), getdisk/setdisk (ESTEX $02/$01), absread/abswrite
  (BIOS $55/$56, rst 8 — номера найдены в solid-c DOS.ASM; сектор 0 =
  boot логического диска)
- scanf/fscanf/sscanf: своё C-ядро _scanf_core (%d %u %x %o %c %s,
  модификатор l, ширина, подавление '*', %%); в SDCC z80 scanf нет,
  asm solid-c не портируем из-за чужого ABI; 22 хост-теста ядра
- хвост П2: fdopen/freopen/fclosall/fgetpos/fsetpos поверх таблицы
  FILE; парсер режима и выдача слота вынесены в _file_mode/_file_slot
- rename() — ESTEX RENAME $10; isatty(fd) = fd <= 0 (tty только
  псевдо-fd 0/-1/-2: из CLI DSS манипуляторы идут с 1 — verified,
  fd 1 не резерв, под Flex Navigator его держит навигатор)
- errno.h: Solid-C имена ошибок (EZERO/EINVFNC/ENOFILE/...) как алиасы
- <sprinter_solid.h> — зонтичный заголовок для портирования;
  ltell/_setargv в sprinter_compat.h; div/ldiv — из SDCC (проверено)
- tests/solidt — smoke всех П3/П4 API, зелёный в MAME (вкл. absread
  boot-сектора с сигнатурой 55AA)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-06 16:35:58 +03:00

84 lines
3.4 KiB
C

/*
* errno.h — ESTEX error codes + global errno + strerror / perror.
*
* ESTEX functions report errors by setting CF=1 and returning the error
* code in A. Our libc wrappers stash that code into `errno` and return
* -1 (or 0 / NULL where the C type calls for it).
*
* Error numbers match ESTEX (so they round-trip through OS/BIOS calls
* untouched). Where the meaning lines up cleanly with POSIX we also
* expose the POSIX-style name as an alias.
*/
#ifndef ERRNO_H
#define ERRNO_H
/* Process-wide error state. Reset to 0 only by user code — libc never
* clears it. */
extern int errno;
/* Error numbers — direct ESTEX codes. */
#define EOK 0 /* No error */
#define EINVFN 1 /* Invalid function */
#define ENODRV 2 /* Invalid drive number */
#define ENOENT 3 /* File not found — POSIX */
#define ENOPATH 4 /* Path not found */
#define EBADF 5 /* Invalid handle — POSIX */
#define EMFILE 6 /* Too many open files — POSIX */
#define EEXIST 7 /* File already exists — POSIX */
#define EROFS 8 /* File is read-only — POSIX */
#define EROOTFULL 9 /* Root directory overflow */
#define ENOSPC 10 /* No free space — POSIX */
#define ENOTEMPTY 11 /* Directory not empty — POSIX */
#define EBUSY 12 /* Can't delete current directory — POSIX-ish */
#define EMEDIA 13 /* Invalid media */
#define EUNKOP 14 /* Unknown operation */
#define EISDIR 15 /* Directory exists — POSIX */
#define EINAME 16 /* Invalid filename */
#define EINVEXE 17 /* Invalid EXE file */
#define ENOEXEC 18 /* Not supported EXE — POSIX */
#define EACCES 19 /* Permission denied — POSIX */
#define ENOTREADY 20 /* Device not ready */
#define ESEEK 21 /* Seek error — POSIX (ESPIPE) */
#define ENOSECT 22 /* Sector not found */
#define ECRC 23 /* CRC error */
#define EWRPROT 24 /* Write protect */
#define EREAD 25 /* Read error */
#define EWRITE 26 /* Write error */
#define EDRVFAIL 27 /* Drive failure */
#define ENOMEM 30 /* Out of memory — POSIX */
#define EINVMEM 31 /* Invalid memory block */
#define EUNKERR 32 /* Unknown error */
/* POSIX aliases for codes ESTEX doesn't have a direct equivalent for.
* Folded onto the closest existing code so error strings stay sane. */
#define EINVAL EUNKOP /* "Invalid argument" → "Unknown operation" */
/* ---- Solid-C aliases (ERRNO.H из Solid-C v2004) -------------------
* Те же числовые коды DSS, только имена другие — портируемые
* программы работают без правок. */
#define EZERO EOK
#define EINVFNC EINVFN
#define EINVDRV ENODRV
#define ENOFILE ENOENT
#define EINVHND EBADF
#define EROFILE EROFS
#define EROOT EROOTFULL
#define ENOSPACE ENOSPC
#define ENOEMPTY ENOTEMPTY
#define ECURDIR EBUSY
#define EINVMED EMEDIA
#define EOPER EUNKOP
#define EEXISDIR EISDIR
#define EINVFNAM EINAME
#define ENSUPEXE ENOEXEC
#define ENORDY ENOTREADY
#define EWRTPRT EWRPROT
/* C99 perror / strerror surface. */
const char *strerror(int err);
void perror (const char *prefix);
#endif