Repository navigation
amiga: names in the system's character set, from codesets.library - #58
Merged
Merged
Conversation
odfs_utf8_to_latin1() turns names into ISO 8859-1, the character set most Amiga systems use. A system set up for another language uses another 8-bit set, ISO 8859-2 for Polish, and every letter of a name that Latin-1 does not have comes out as a question mark there. Rename the function to odfs_utf8_to_8bit() and let it take a map: the Unicode code point of each byte from 0xA0 to 0xFF. A NULL map still means Latin-1. Bytes 0x80 to 0x9F are never produced, as before: the Amiga console takes them as control codes whatever the character set says is there. A combining accent merges as before, into the Latin-1 letter, and that letter is then looked up in the map: it merges only into a letter the set has. The map code is under ODFS_FEATURE_CHARSET_EXTERNAL, which the ROM profile has off. Nothing passes a map yet.
A mount could ask for names in UTF-8 or in Latin-1. Add a third choice, ODFS_NAMES_MAPPED: the mount options carry a map as odfs_utf8_to_8bit() takes it, and node names, symbolic link targets and the volume name are converted with it. The backends learn the character set from the cache they are handed, which held its number. Put the number and the map into a struct, odfs_names_t, and hand that to odfs_namefix_init() and odfs_name_to_charset() in place of the number. The map belongs to whoever mounts and has to stay valid until the unmount.
Names are converted to Latin-1. That is wrong on a system set up for a language with another 8-bit character set: a Polish name on a Polish system shows an underscore for every letter Latin-1 does not have. If codesets.library is installed, ask it for the system's default character set and convert names to that. Without the library, and in the ROM build, names stay Latin-1. The library is told to leave memory again once the table is copied; it and its tables take some 300 KB. The handler asks when the first packet that concerns the disc comes in, not when it starts. Mount starts a handler from DEVS:DOSDrivers before IPrefs has loaded the locale preferences, and codesets.library works out its default when it is first opened and keeps it: asked that early it answers with the English default, and gives that answer to every program that opens it later. This must not cost anything per packet. A test in the packet loop shows in CDBench as one timer tick per packet, and any other change to that function, or to one inlined into it, makes the compiler arrange the whole loop differently. So the loop is left alone: - mount_volume() calls odfs_amiga_system_charset(). The first call makes the packet port run a software interrupt. - The interrupt runs for each packet until one is not ACTION_IS_FILESYSTEM, which Workbench sends first and with the DOS list locked. It then turns the port back into a signalling one and marks the change count as unknown, so that handle_media_change() sets out to mount the disc again before the packet is taken. - unmount_volume() calls odfs_amiga_system_charset() as well, and that call asks the library. A disc that is in the drive by then was mounted for Latin-1, but none of its names has been handed out. If the disc is still the same and its volume name is plain ASCII, the character set of the mount is switched and unmount_volume() returns without doing anything. The same if names stay Latin-1. Only a disc whose volume name has other characters is mounted again. The backend is asked for the name as it is on the disc: in the mount's copy an underscore may be one from the disc or stand for a letter Latin-1 does not have. The library is loaded from disk while the handler waits. The process that loads it, ramlib or LDDemon on AROS, serves one request at a time, so it must not need this handler meanwhile. Names stay Latin-1 - if a packet of the loader's own is waiting, or - if the boot volume, LIBS: or DEVS: has a directory on this handler's volume, does not exist, or is a late or non-binding assign, which shows where it leads only when it is used. The DOS list is locked for reading with LockDosList(), as the loader does. AttemptLockDosList() fails whenever another task has the list, even for reading as Workbench does around its first packet. What is left is a program that opens a library or device by a path on the disc at the very moment of that one lookup, or one that holds the DOS list for writing while it sends the handler its first packet. The code is in a file of its own, listed first among the handler's sources: the linker places handler_main.o in front of the core, so code added to it moves every routine of the core and the backends. AmigaOS 4 keeps Latin-1 here. Requests reach the handler as calls there, not as packets, and need a trigger of their own.
reinauer
force-pushed
the
amiga/codesets-names
branch
from
November 25, 2026 23:32
e90280c to
cffe672
Compare
On AmigaOS 4 requests reach the handler as calls into its vector port, made in the caller's context, so there is no packet for a software interrupt to catch. The first call that concerns the disc does what the interrupt does elsewhere: it marks the change count as unknown and signals a media change. Then it waits, with the filesystem semaphore released, until the handler process has been through that pass, where the library is asked as on AmigaOS 3. FSFileSystemAttr does not count as such a call. DOS makes it from the startup script's process at boot, before the locale is loaded. Every other call during a boot of AmigaOS 4.1 FE comes from Workbench. A handler does not shut down while a caller is waiting like this. The checks of the assigns and of who is waiting need no code of their own: dos/obsolete.h maps the names of the AmigaOS 3 DOS list to this one, and the loader is a process called ramlib here too.
reinauer
force-pushed
the
amiga/codesets-names
branch
from
November 25, 2026 23:35
cffe672 to
0a4a41f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
amiga: names in the system's character set, from codesets.library
#56 converts names to Latin-1. On a system set up for another language that is the wrong 8-bit set: a Polish name on a Polish system shows
_for every letter Latin-1 lacks. With this series the handler asks codesets.library, if it is installed, for the system's default character set and converts to that. Without the library nothing changes.Four commits on main. The branch was rebased after #56 and #52 were merged.
What changes
odfs_utf8_to_latin1()becomesodfs_utf8_to_8bit()and takes a map, the Unicode code point of each byte from 0xA0 to 0xFF. A mount hands the map in withODFS_NAMES_MAPPED. A NULL map is Latin-1 as before._.UTF-8entry, is refused.When the handler asks
At the first request that concerns the disc, not at startup. Two things measured on OS 3.2 rule startup out:
DEVS:DOSDriversbeforeIPrefs, and the shippedCD0hasActivate = 1. Asked at that point, codesets.library reportsISO-8859-1 + Euroon a system whose locale is Polish.A disc that is already in the drive was mounted for Latin-1 by then, but none of its names has been handed out:
_may be one from the disc or stand for a letter Latin-1 lacks.?. On a Polish system a disc namedŁĘŻ, mounted from theDEVS:DOSDriversposition, kept the volume name___.AmigaOS 3 and AROS: nothing added to the packet loop
On the benchmark rig, two instructions per packet cost one timer tick (about 1.4 µs) on every per-packet metric. Any other source change to
handler_main_startup(), or to a function inlined into it, makes the compiler arrange the whole packet loop differently; one such variant gave the streaming-read loop an extra taken branch and cost 1.6% in sequential read. So that function is untouched:mount_volume()calls into the new code. The first call turns the packet port into one that runs a software interrupt.ACTION_IS_FILESYSTEM. It turns the port back and marks the media change count as unknown, which sends the handler through its existing media-change path before the packet is taken.unmount_volume()calls into the new code too. That call asks the library, and returns early if the disc can stay mounted.The new code is in
platform/amiga/system_charset.c, listed first among the handler's sources. The linker placeshandler_main.oin front of the core, so code added to it moves every routine of the core and the backends.AmigaOS 4
Requests are calls into the vector port, made in the caller's context. The first one that concerns the disc marks the change count as unknown, signals the handler process and waits for it; the handler process then asks the library as above.
FSFileSystemAttrdoes not count: DOS calls it from the startup script's process at boot, before the locale is loaded. Every other call during a boot of OS 4.1 FE comes from Workbench.Not waiting on ourselves
The library comes from disk while the handler waits, and the loader process (ramlib; LDDemon on AROS) serves one request at a time. Names stay Latin-1 rather than risk the loader needing this handler:
LIBS:orDEVS:on this handler's volume, or missing, or a late or non-binding assign, which only shows where it leads when it is used.The DOS list is locked for reading with
LockDosList(), as the loader does.AttemptLockDosList()fails on OS 3.2 whenever another task has the list, even for reading, and Workbench holds it for reading around its first packet.What remains: a program that opens a library or device by a path on the disc at the moment of that one lookup, or one that holds the DOS list for writing while it sends the handler its first request.
Testing
Test discs carry
Żółć.txt,Čeština/Šárka.txt,Grüße.txt,Señor.txtandPreis 5€.txt. They are namedŁódźandŁĘŻ, which have to be mounted again, andPOLTESTandMY_DISC, which can be switched in place.Everything below was run on the final tip, after the rebase, unless it says otherwise.
make checkpasses on every commit, with new tests for the map conversion, accents through a map, namefix and a mount with a map.golden-check,malformed-checkandfuzz-checkpass.tests/aros/check_abi.sh. The AROS i386 handler builds from the tip; CI builds the x86-64 one.List,InfoandTypeoutput byte-identical to mainPreis 5€.txtgets byte 0xA4, the Euro sign ofISO-8859-1 + Euro, and opens by that nameŻółć.txt,Čeština/Šárka.txtand the volume name are right and open by their 8859-2 names;Señor.txtbecomesSe_or.txtDEVS:DOSDriverspositionŁĘŻ, mounted early and lateMY_DISC, mounted early and lateŁĘŻ___:ISO-8859-1 + Eurohas none of the three lettersENV:CHARSETset toISO-8859-2LIBS:made a non-binding assignOpenLibrary("CD0:..."))Soak: 70 boots over these setups on builds from before the rebase, all with the expected listing.
ŁĘŻin the drive at boot: names in ISO 8859-1, the system's set; volume name___. Files open by those names.codeset_defaultset toISO-8859-2, then that disc inserted: names and the volume name in ISO 8859-2, files open by those names.List,DiskChange, eject, a second disc, the first one again: as on main, no traps in the serial log.ISO-8859-1 + Euro, files open by name.codeset_defaultset toISO-8859-2: the discs give ISO 8859-2 names; the volume namesŁódź,ŁĘŻandMY_DISCare right.LIBS:assign that has a directory on the CD was tested with an earlier version of the same check, through a debug build; in the final design that state cannot be reached from a script.Speed
CDBench, OS 3.2, 68020 build, same rig, same session, three runs each.
Same offset is 51, stride 160 and seeded 153 in every row.
odfs_iso_readdir()fetches the character set once instead of twice.handler_main_startup()and the packet functions are unchanged.RAM:and every other one deleted before the mount, measures 9,711 to 9,737 and 12,792 to 12,826, and an open from a lock takes 5 to 10 µs longer. Reads do not change.CDBENCH_FIXTURE. A first version of the fix mounted every disc with a_in its name again; after that second mount sequential read was 207,211 KiB/s and the lock figures 142, 162 and 306. That is why the check asks the backend.Size
Built with the 20261103 toolchain.
Not in this series
c+ caron staysc_on a Latin-2 system.