Subject: Re: NULL return value checking
To: NetBSD Kernel Technical Discussion List <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 04/24/2002 14:24:35
>> (I also have a habit of assuming that the null pointer as the zero
>> bit pattern [...]
> Also the BSS segment in unix exec images is zeroed to contain all
> binary zero values for the same purpose (i.e. so that the compiler
> doesn't have to include runtime code that explicitly initializes
> uninitialized variables to zero, including pointers).
Yes; an implementation that uses a non-zero bit pattern for nil
pointers will not be able to put them in bss, or else will have to have
a special sort of bss for pointers. Structs will be messier; they may
have to be moved out of bss entirely. (This sort of thing is probably
why C is permitted to use the strict def/ref model as well as the
common model.)
> One final note: even lisp "nil" pointers are generally interally
> represented as all zero bits, at least with the lisp interpreters I'm
> familiar with on unix systems,
I should get you to work on mine. :-) It represents nil as a symbol
like any other; the nil at the end of a list is, as far as
representation goes, just like any symbol in the cdr of the last cons.
Not that Lisp engine internals are very tech-kern-relevant....
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B