AmigaOS¶
This directory has classic AmigaOS support (Kickstart 1.3 and later, any
68k CPU) for picolibc on the m68k-amigaos target of the
clang-dos LLVM toolchain. It goes into
libc.a itself, with crt0.o, so a program needs nothing else from
picolibc. It uses no Amiga NDK headers: the few library offsets and
structure fields it needs are written out in local-amigaos.h.
Building¶
With clang, llvm-ar and the other LLVM tools on PATH:
meson setup build-amigaos \
--cross-file scripts/cross-clang-m68k-amigaos.txt \
-Dos-amigaos=true -Denable-malloc=false -Dmultilib=false \
-Dpicocrt=false -Dsemihost=false -Dtests=false -Dposix-console=true \
-Dsingle-thread=true -Dthread-local-storage=false -Dspecsdir=none \
--prefix=$PWD/install-amigaos
ninja -C build-amigaos install
Copy include/ to <sysroot>/include and lib/crt0.o and lib/libc.a
to <sysroot>/lib. clang --target=m68k-amigaos --sysroot=<sysroot> then
links them with libclang_rt.builtins.a by default. The cross file builds
for the 68000, so the library runs on every Amiga.
What it does¶
crt0.Skeeps the registers and stack pointer the program was started with, so that_exitcan return to the CLI or Workbench from anywhere. From Workbench it waits for the startup message first.start.copens dos.library (version 33, Kickstart 1.2, or later) and callsmain. From the CLI,argvholds the words of the command line, split the way the CLI does (double quotes,*",*Nand*E), andargv[0]is the command name. From Workbench,argcis 0 andargvis thestruct WBStartupmessage, as with other Amiga compilers, and the program runs in its own directory.malloctakes each block fromAllocMem(), and_exitfrees what is left, since AmigaOS doesn't free a program's memory. Build with-Denable-malloc=false.- File descriptors 0, 1 and 2 are the CLI's input, output and error stream (the output on Kickstart 1.3). A Workbench program opens a console window the first time it uses them.
- Files:
open,read,write,lseek,close,stat,fstat,unlink,rename(which replaces an existing file, as in POSIX),mkdir,rmdir,chdirandgetcwd(Kickstart 2.0 and later),access,isatty. Errors fromIoErr()becomeerrnovalues. - Time comes from
DateStamp(), with local time taken as UTC and a resolution of 1/50 second.nanosleepcallsDelay(). - Signals are those of the fallback library:
raiseworks, Ctrl-C is not checked.
The CLI gives a program the stack size set with Stack (4000 bytes by
default on Kickstart 1.3), which is small for printf with floating
point; set 16000 or more.