• review use of k32/K32
‣ the type is guaranteed to be of at least unsigned int rank
so it will not default-promote to a signed type
‣ append U suffix to arith other-arguments
‣ use mbiMKror ipv old BAFHror (now gone)
‣ review uses of K32 macro (truncating cast to k32=u_int)
vs. cast (to u_int) or mask
• (while here) streamline BAFHFinish macro structure
• introduce K32_HM and K32_FM and use in KUA_HM/KUA_FM for !lksh
and stop adding casts to the mask definitions, mbi macros do that anyway
• space before tab, that is crap
• optimise build time: run mbi ctasserts only for some compiles
• but do check it explicitly in Build.sh, abort early if failing
• Build.sh: fix wording; check idstring in “final link succeeds?” as well
• mbsdint.h: fix masked rotation macros: take mask bitwidth, not type’s
if uintptr_t is present (intptr_t is useless), check it as well
just like ptrdiff_t (and ssize_t), we check mutual same-sizedness with
size_t, to provide for code using a really common Unix standard assumption
including for portability to C89 which doesn’t have this type
another mbsdint.h overhaul making things even less readable and more safer
• more casts
• write all unsigned constants with a trailing U (macros’ users, too)
• more checks, even some more things that C guarantees
‣ this ensures that char has at least eight bits as a side effect
though the rest of this should be fine with 7
• add 0UL to all unsigned arithmetic operands so ut==u_char no longer
promotes to int (0U might have been enough plus this is inconsistent
but we cannot just write 0ULL either, let’s just hope compilers DTRT)
• some signed definitions for symmetry (that mostly just cast, but for
arith ops also add 0, to ensure not being abused as lvalue with += etc.)
• very lengthy and too verbose rewrite of the other macros using these
new arithmetic ops primitives… I’m shy of making something generate these
• restructuring of comments and macro ordering, hopefully makes more sense
• rename existing mbiCASadd, mbiCASsub, mbiCASmul to mbiCAP* where the
right-hand operand is positive or 0
• fix overflow checks in mbiCAUmul and mbiCAPmul
• readd mbiCAS{add,sub,mul} with more contrived checks to allow negatives
• redo rotate and shift to read more easily (and new arith ops ofc)
[8 lines not shown]
• implement divrem for unsigned variable manual 2’s complement values
and use that in mksh’s nōn-lksh arithmetics
• implement comparison operaters (and use it), so we get that much closer
to the necessary goal of signed-less (except lksh temporarily) operation
• shorten the macro names and make sure all have a masking pendant and
all masker do that for input as well
• overhaul rotation/shift to get expressions, not statement blocks, expanded
• mksh: deprecate kul (before it’s really used much) and ksl (will be used
by lksh only, and only in as little arith code as possible, everything
else can and will be done in unsigned, also for one’s complement and
sign-and-magnitude safety), we shall only have an unsigned arithmetic
type, which will be ulong at first but may later be uint if exactly
32 bits, for mksh nōn-lksh only, for simplicity (rid of masking)
• recheck and improve masking
• split VZU2U off VZM2U; the former takes a fullmask unsigned type on
input, the latter applies halfmask to magnitude value, for consistency
and reusability (mbiMA_VZM2U pretty much stays the same, mbiA_VZM2U
is renamed mbiA_VZU2U and mbiA_VZM2U is added and mbiMA_VZU2U can now
just mbiMM-wrap mbiA_VZU2U)
[7 lines not shown]
• safer ways to check lim_MIN
• sign-and-magnitude and one’s-complement warning comments when appropriate
‣ add VZM2U/U2VZ/U2M which are safe if using o̲n̲l̲y̲ unsigned variables
‣ note mbiVASdivrem isn’t (we’d need mbiVAUdivrem, which can only now be
constructed from VZM2U/U2VZ/U2M)
• don’t inline S2VZ/U2VZ into the other macros, keeps structure better
• explicitly cast SM/HM/FM into (ut) where necessary (or (st), but we
only ever mask unsigned (as it should be))
• fix mbiMA_S2M to cast to unsigned before masking (ouch! we need to cast
after basically all ops as integer promotions could kick in otherwise!)
• note that SM (semantically, say SHRT_MAX) == HM (USHRT_MAX >> 1)
(which CTAs check, btw)
• cast between ops for mbiVAU{sh,ro}{l,r} (as necessary and perhaps one
too much, but never not enough!)
• rename bool/true/false/tobool to Wahr/Ja/Nee/isWahr¹
cf. <Pine.BSM.4.64L.2202191951440.13654 at herc.mirbsd.org> on both
miros-discuss@ and miros-mksh@ for the backgrounds (tl;dr: ISO C… again)
• give matching advice in style(9)
• remove useless (void) casts, as style(9) says (nōn-useless ones are
spelt SHIKATANAI these days anyway)
• drop MKSH_A_PURE; I’m not sure I knœw where it applies, plus there’s
a __const__ attribute, too, one invites that the other is also applied
• correct an ord() MKC_DEBG=cpp assert
① C99 reserves 'is'+lowercase-letter, even if <ctype.h> is not included…
cannot use mbiTYPE_ISF in a CTA, but introduce mbiCTA_TYPE_NOTF:
we *can* CTA that a type isn’t floating point (by adding a test
that either uses the -1 array size as in CTA(!ISF) or fails to
compile (like ISF e.g. in newer GCCs)); use that instead, it’ll
be sufficient, for this anyway
add new <syskern/mbsdint.h>, symlinked to mksh/mbsdint.h
this draws out all of the recent work in both mksh and mirtime for UB-free
number arithmetics: type and limit and bitmask checks (extending to 279 bits)
and compile-time assertions for many types; checking arithmetics, completed;
manual-twos-complement arithmetics both full-width and (new!) masking;
mbiHUGE_* to offer whatever integer is widest; etc.
changes nothing for mirtime, but mksh gets to advance the old→new arithmetics
move (shift/rotate and divrem already, mostly, done)
• cpu.c: add comments about SPARC versions supported by the implementations
on these IU chips (hope I’ve got all right)
• conf/GENERIC: disable sun4c as well as (already had) sun4, they all come
with v7 CPUs
• while here, disable Sun 4/100-only SCSI controller, enable com(4) on PCMCIA
• disable sun4c-specific devices
exclude .{,u}{mul,div,rem} and their v8 fixup if building for v8 anyway:
GCC should not generate calls to them (tested), if it does fix your CFLAGS
⇒ no need to carry around even the fixed v8 versions at all…
• ensure sparc mgcc passes -Av8 if building with -mcpu=v8
(gas currently defaults to sparclite due to a bug in older porting)
• rearrange one .h block (cosmetic/diffy)
• delete deprecated sparc -mv8/… (use -mcpu=v8/…) which should have
been deleted in GCC 2.9, according to the comments… (this makes
the spec much easier, plus it’s more reliable)
add _SPARCV7COMPAT (default no, set to yes if changing default CFLAGS)
this will be used to exclude v7-only SRCS on make level;
use __sparc_v8__ on cpp level (.c, .S; nothing for .s?)
• factor out _{,u}{mul,div,rem}replace from kernel and ld.so (identical)
to kern/c/sparc/ as v8muldivrem.S (KkSRCS)
• add v8muldivrem.S to libmdsup (for ld.so)
• remove mul and umul from sparc locore.s as identicals are in ckern
• harmonise .{,u}{mul,div,rem} entry point handling
• .text and .p2align, not .section ".text"[sic!] or .align[sic!]
(.align can be .p2align or .balign depending on the assembler)
• RCSID into .section .comment