D
Dave Thompson
On 6 Aug 2004 18:40:23 GMT said:- Most implementors use all-bits-zero for internal null pointers.
It is usually the easiest thing to do, <snip>
The IBM S/360 architecture has various special stuff in low memory,- Many machines without virtual memory, and even some with, have
ROM or RAM at physical address 0.
like old and new PSW's for various interrupts, although I don't recall
if any of them are at exactly 0. And thus so must its compatible
descendants (370, 390, and "z" series) in real mode, which ISTR IBM as
usual calls by some more officious name like "translation disabled".
And for multiprocessor machines, even with virtual memory off -- or
nonexistent? were there MP 360s? I don't recall -- they have a kludge
where page zero is switched with some other page that can be different
for each processor. Bleah.
Though I don't think there was ever a C on those machines (or at all?)
before 370s and virtual memory.
Or, on "classic" (legacy) Tandem^WCompaq^WHP NonStop, which has- C implementations that use all-bits-zero for all their internal
null pointers *and* that have useable RAM at address 0 must
make sure not to put any C object or function at address zero,
which is typically easily achieved by putting some "non-C"
thing there, such as startup code or a "shim".
separate code and data address spaces, data address 0 is always used
for data internal to the run time library, specifically a pointer to
the "run unit control block", never a user object (variable). On this
implementation if you store through null, or fetch through null and
use it as a pointer to store at or near -- e.g. (mis)use 0 as a struct
foo * * or any_t (* *)[N] -- subsequently various C runtime stuff esp.
stdio which depends on data in or more often pointed to by the RUCB
malfunctions in bizarre and sometimes spectacular ways.
- David.Thompson1 at worldnet.att.net