- built-in regex is required only when ${USE_WIDECHAR} == "yes"
- -DUSE_WIDECHAR cpp flag should be determined by ${USE_WIDECHAR},
not ${USE_BUILTIN_REGEX}
- reduce .if -- .endif block for clarity
instead of fixing to 32KB.
Old 32KB limit comes from
(1) all R_68K_PC16 symbols get relocated, and
(2) all values in our relocation table for R_68K_32 symbols fit within
16-bit integer.
(1) is already checked in the code. Assertion for (2) is added, but this
limit is satisfied with sufficient margin at the moment. If it is not the
case in the future, we may need to change format for relocation table.
Writing *(p+1) is needlessly confusing, even though it adds a little
symmetry between *p and *(p+1). Still, one of these expressions has
parentheses, the other doesn't, which breaks the symmetry.
Wrap overly long code line.
It's confusing to refer to the digits after the backslash once with
index 0 to 2, and the other time with index 1 to 3.
Before, '\b' was interpreted as a simple 'b', which is confusing for C
programmers. Same for '\a'. There is absolutely no reason to escape
letters, so fail early in these cases.
The '\h' in the test addchstr was obviously a typo that was easy to
detect, if only the compiler had been strict enough from the very
beginning.
The code is wider than 80 characters, same as the code that parses octal
escape sequences a few lines above it. This code will be refactored to
use less indentation in a follow-up commit.
SPRG[0-3] in the firmware trampoline. Section 7.1 of the OpenFirmware
PowerPC CPU bindings says that firmware "client interface shall not modify"
when in virtual-mode, and "client interface shall preserve" in real-mode.
This is important because in vritual-mode, DSI exceptions will land in
the kernel's DSI exception handler, and that handler depends on the
kernel's SPRG0 value (it contains the pointer to the cpu_info for that
CPU).
Additionally, in the firmware trampoline, point curcpu at an empty
ofw_battable. This ensures that the DSI exception handler won't
load a BAT register with a kernel block translation that clobbers
a segment translation owned by the firmware. Eventually, this ofw_battable
might contain some of the larger translations owned by the firmware.
on anything greater than half the pool pagesize.
this stops 4KiB being used per allocation from the kmem-02048 pool,
and 64KiB per allocation from the buf32k pool.
we're still wasting 1/4 of space for overhead on eg, the buf1k or
kmem-01024 pools. however, including overhead costs, the amount of
useless space (not used by consumer or overhead) reduces from 47%
to 18%, so this is far less bad overall.
there are a couple of ideas on solving this less ugly:
- pool redzones are enabled with DIAGNOSTIC kernels, which is
defined as being "fast, cheap". this is not cheap (though it
is relatively fast if you don't run out of memory) so it does
not really belong here as is, but DEBUG or a special option
would work for it.
- if we increase the "pool page" size for these pools, such that
the overhead over pool page is reduced to 5% or less, we can
have redzones for more allocations without using more space.
also, see this thread:
https://mail-index.netbsd.org/tech-kern/2021/02/23/msg027130.html
For performance reasons, the implementation of the simple rule "cmdline
overrides global" grew into code that is much more complicated than a
straight-forward implementation. This added complexity made it easy for
bugs to sneak in.