Files
json-c/amiga/json-c.readme.template
T
Cameron Armstrong (Nightfox)andClaude Opus 5.5 217808a23d Amiga: build libm881 (FPU) slots for AmigaOS 3
-m68881, -mhard-float and -m68040/-m68060 link from libm020/libm881. With no
json-c there, the linker fell back to the soft-float libm020 build, which
clib2 cannot link: its FPU libm has no soft-float helpers. Add the
libm020/libm881, libb/libm020/libm881 and libb32/libm020/libm881 slots for
newlib, libnix and clib2 (M68K_FPU=hard, from the image's cmake toolchain
file), taking AmigaOS 3 from 15 to 24 libraries.

Allow AMIGA_IMAGE_<OS> to override the compiler image, so the libraries
can be built against a local image before it is published.

Update the link tables. All 8 slots link for every runtime once the
compiler image has the AmigaSDK-gcc cleanup that removed stale toolchain
files. The old clib2 strtoll and newlib gettimeofday gaps came from those
files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 10:34:00 -05:00

116 lines
4.6 KiB
Plaintext

Short: JSON parser and generator library (static libs + headers)
Author: Michael Clark, Eric Hawicz et al.
Uploader: Cameron Armstrong (Nightfox) <cameronscottarmstrong@gmail.com>
Type: dev/lib
Version: VERSION
Architecture: m68k-amigaos >= 2.0; ppc-amigaos; ppc-morphos
Requires: an Amiga gcc compiler
Replaces: dev/lib/json-c.lha
json-c implements a reference-counted object model for JSON, a parser that
builds it from text, and a serialiser that writes it back out. This archive
contains static libraries and public headers for Amiga development.
https://github.com/json-c/json-c
Contents
json-c/json-c.readme this file
json-c/AmigaOS3/... m68k AmigaOS libraries and headers
json-c/AmigaOS4/... ppc-amigaos libraries and headers
json-c/MorphOS/... ppc-morphos libraries and headers
Under each OS directory the trees follow the compiler's own layout, so
they can be copied straight over an existing SDK, e.g.
cp -a json-c/AmigaOS3/* /opt/amiga/m68k-amigaos/
AmigaOS3 ships one set per C runtime -- newlib at the top level, plus
libnix/ and clib2/ -- and within each, one library per multilib:
lib/ 68000, absolute addressing
lib/libm020/ 68020, absolute addressing
lib/libb/ 68000, -fbaserel
lib/libb/libm020/ 68020, -fbaserel
lib/libb32/libm020/ 68020, -fbaserel32
lib/libm020/libm881/ 68020 + FPU (-m68881, -mhard-float,
lib/libb/libm020/libm881/ also -m68040/-m68060), absolute,
lib/libb32/libm020/libm881/ -fbaserel and -fbaserel32
The libm881/ builds use FPU instructions. Without them an FPU program
would fall back to the soft-float libm020/ build, which clib2 cannot link
(its FPU libm has no soft-float helpers such as __adddf3).
On PPC a C runtime is not a separate tree but a multilib slot beneath one
shared lib/, with headers in the single shared include/:
AmigaOS4 lib/ newlib
lib/clib2/ clib2
lib/clib4/ clib4
MorphOS lib/ ixemul
lib/libb32/ ixemul, -mbaserel32
lib/libnix/ native C library (-noixemul)
lib/libb32/libnix/ native C library, -mbaserel32
-mclib=libnix and -noixemul select the same MorphOS multilib. That ABI is
the self-contained one -- an ixemul build needs ixemul.library on the
target -- so prefer lib/libnix/ for new code.
Usage
#include <json-c/json.h>
struct json_object *o = json_tokener_parse("{\"a\":1}");
printf("%s\n", json_object_to_json_string(o));
json_object_put(o);
Link with -ljson-c -lm, after your own objects on the command line. For
clib2 add -lunix as well, since clib2 keeps its POSIX layer there.
Which variants link
Verified by compiling the snippet above against each shipped library.
AmigaOS3 all 8 slots link for newlib, libnix and clib2, provided the
compiler image carries the AmigaSDK-gcc cleanup of 2026-11 that
stopped stale 2023/2024 toolchain files overwriting the newer
newlib and clib2. Older images lack strtoll()/strtoull() in
clib2's 68000 multilib and gettimeofday() in newlib, and fail
-fbaserel clib2 links with a "dangerous relocation".
Known toolchain issue: with clib2, -m68040/-m68060 on their
own compile soft-float code but link the FPU libraries. Add
-m68881.
AmigaOS4 all three (newlib, clib2, clib4) link.
MorphOS all four slots link.
A note on base-relative addressing (AmigaOS3)
A base-relative library addresses its globals through a4, which the
program's startup code sets up once. Only link the libb/ or libb32/
variants into a program that is itself base-relative AND that marks every
function the OS calls back into (BOOPSI/MUI dispatchers, struct Hook
entries, interrupt servers) with __saveds. The m68k SDI_hook.h macros set
up register arguments but do not add __saveds, so this is easy to get
wrong, and the failure mode is intermittent memory corruption rather than
a clean error -- libnix keeps malloc's heap state in a4-relative storage.
Conversely a non-base-relative library built at -O1 or above may use a4 as
a scratch register, which is harmless in a non-base-relative program but
corrupts the base pointer of one that is.
Match the variant to the program. If in doubt, use the plain lib/ or
lib/libm020/ builds.
Licence
MIT; see COPYING in the source distribution.