Subject: Re: Generic Properties
To: None <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 09/29/2001 22:44:25
> I want `opaque_t' to be large enough to hold any scalar type.  Come
> to think about it, I suppose I should just bite the bullet and make
> it an `int64_t'.

Speaking from a C-language-lawyer point of view (and I'm sure someone
like seebs will correct me if I get this stuff wrong!), there is no
portable way to define such a type.  The best you can do is write a
union of all the standard scalar types, pointers to them, and a pointer
to some struct type.  (Because of the incomplete-struct-type rules, I
think it can be deduced that all pointers to structs must be the same
size.)

However, there is no portable way to tell what extention types (such as
long long int) might exist.  And even from a NetBSD perspective, are
you certain it'll never have call to run on a machine with >64bit
pointers?  I'd recommend a union of void * and 64-bit int.  (Besides,
making it an aggregate type will discourage people, somewhat, from
going under the hood and breaking its opacity.)

/~\ 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