Files
snark13 c71e249a4e Add full compiler toolchain, libc, examples and reference docs
First substantive commit: the entire Sprinter C compiler tree on top of
the bare README+gitignore initial commit.

What's in here:
  bin/sprinter-cc        — driver script invoking SDCC + linker + mkexe
  libc/                  — Sprinter-specific libc layer over ESTEX/BIOS
                           (conio, gfx, io, mem, stdio + headers)
  runtime/               — crt0 variants (default/small/banked/minimal)
                           + heap + bank trampolines
  toolchain/             — mkexe (SprintEXE packer, C + tests)
  examples/              — 30 demo programs (gfx, file I/O, env, time, …)
  lib/Makefile           — builds the libc archive (sprinter.lib)
  docs/                  — converted Sprinter manuals + asm reference samples
  third_party/           — solid-c reference compiler dump + sdcc setup script
  release_docs/          — packaging / release notes

gitignore overhaul:
  • Drop dangerous blanket patterns: *.asm (would hide docs/samples/*.asm)
    and *.exe (case-insensitive match was hiding third_party/solid-c/*.EXE
    on macOS APFS).  Replaced with examples/*/*.{asm,exe,…} and lib/*.lib.
  • Restore tracking of toolchain/mkexe/tests/{one,big}.bin — those are
    INPUT fixtures, not build outputs.
  • Collapse the duplicated SDCC/C/Sdcc sections into one section per
    concern (build outputs / vendored / OS-junk).
  • Add .sprinter-cc-*/, build/ (catches lib/build/ too), .claude/.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 16:13:21 +03:00

63 lines
2.7 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" */
/* C99 perror / strerror surface. */
const char *strerror(int err);
void perror (const char *prefix);
#endif