[TUHS] C++ / Kernel

ron at ronnatalie.com ron at ronnatalie.com
Fri Aug 24 00:42:40 AEST 2018


> Has anyone experimented with building Unix using C++, to take
> advantage of strong typing?  My guess is no--it would be a Herculean task
likely to introduce more bugs than it would fix.

I'm not sure what "strong typing" gain you expect to find.   With the
exception of the void* difference, C++ isn't much more "type strong" than C.
A lot of the type issues you can find on the Kernel just by turning up the
compiler warnings (or use lint).

The biggest issue we had was BSD didn't use void* at all.   Had they
converted pointers to void*, which is in implementation necessarily the same
as char*,
C would have done the right thing.   The problem is they did what I call
"Conversion by union."    They would store a char* into one element of a
union and read it out of another typed pointer.
This works fine for a VAX where all pointers are the same format, but fails
on word address machines (notably in our case the HEP where the target size
is encoded in the low order bits of the pointer).
Still, running around and fixing those was only a few hours work.

The DevSwitch is the beginnings of an object oriented philosophy.   Alas,
the original UNIX used it only for mapping major dev numbers to functions.
It got some later use for other things like multi filesystemsupport.

The scary supportability thing in the kernel, isn't so much typing, but the
failuer to "hide" implementation details of one part of the kernel from the
other.




More information about the TUHS mailing list