On 28 March 2014 09:47, Bernd Oppolzer <[email protected]> wrote: > I just realized that "NULL returning 0xFF000000" was designed when we > still had 24 bit addressing, so there must have been other reasons > for this design decision.
I remember heated discussions on this matter at my university computer centre in the early 1970s, long before 31-bit addressing on S/370. At the time it was very common for assembler code to use the high byte of a fullword address to hold flags of various kinds, and the notion of indicating a NULL pointer "out of band" is attractive. Some people even then had a longer view, and understood well that 24-bit addressing would not do forever, and that something would have to be done. One can see the evolution of this thinking in (IBM and others') assembler coding style as flags were moved out of high address bytes. Another thing to consider is that pointers in C and PL/I are, in their different ways, both opaque objects with only certain defined external properties, and various implementation details. For example, in the PL/I Checkout Compiler, pointers were, iirc, 128-bits, and carried various information far beyond the address that allowed the production of useful run-time debugging messages. In C, pointers are very clearly not addresses at all. Look at the semantics of adding an integer to a pointer (which is defined in the language, and is not just an implementation detail): if your pointer is to an array of, say, ints, if you add 1 to it it will point to the next int in the array, not to the next byte within the current int. PL/I has its Unspec Built In Function, and C has its cast, but both when applied to pointers have implementation defined results. Perhaps your solution lies not in the C language, but in the compiler-defined external linkage conventions, some of which can be chosen by various pragmas. Tony H. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
