Eliminate `bootstrappable.c`
bootstrappable.c has a number of functions from the early years of the M2* projects that were helpful at the time. However, we have gradually moved away from these towards more standard C library interfaces (as per this project).
We should eliminate the remaining non-standard functions from bootstrappable.c, first by introducing the new interfaces where they do not already exist, then replacing existing code with the standard interfaces, then removing the old functions.
- [ ]
require->assert- [ ] implemented
- [ ] replaced
- [ ] removed
- [ ]
match->strcmp- [x] implemented
- [ ] replaced
- [ ] removed
- [ ]
in_set->strchr- [x] implemented
- [ ] replaced
- [ ] removed
- [ ]
strtoint->atoi- [ ] implemented
- [ ] replaced
- [ ] removed
-
int2stris probably not removable at this time
Not sure if all of these can be replaced. We can only replace them if replacements are written in cc_* subset.
@fosslinux
As far as I understand the cc_* compilers only include the bootstrappable.* files by manually adding them to the command line (include directives do nothing). With this we would either need to make the entire string parsing files buildable by cc_* or add a define (do the cc_* compilers handle ifdefs?).
IMO match that basically returns a bool also has a better interface than strcmp which can return positive, negative or zero.
assert raising an interrupt rather than exiting would be nice for when using a debugger though.
I just checked in M2-Mesoplanet and it doesn't use any of the boostrappable functions. Should all these just be moved out of M2libc and into M2-Planet instead, possibly into cc_core.c?
Also @fosslinux I implemented atoi in https://github.com/oriansj/M2libc/pull/84.
There is also hex2 and M1. Are they using these functions?
There is also hex2 and M1. Are they using these functions?
Hadn't checked the C versions of those since I forgot they existed. They both use bootstrappable. That complicates things a little.
IMO custom headers/files don't belong in a "libc" since it's a portability nightmare but the unnecessary duplication is also annoying. I guess we'll leave it as it is currently.
Actually, we could port hex2 away, there are no issues there.
There is still M1 and blood-elf though. I think they need bootstrap mode because full M2libc uses lowercase hex immediate numbers and at the moment M0 only supports lowercase. Also initial debugging of M2 on new arches is easier with smaller libc.