tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: aligned_alloc c11 function



>>> (On all real platforms, MIN_ALIGNMENT == sizeof(void *)  
>> Only for strange values of "real".  [...]
> Looking at the cpu architectures that NetBSD supports[1] I would I
> draw the conclusion that on all of them sizeof(void*) is either 4 or
> 8.

I haven't gone through the list myself, but probably.

> Or am I wrong?  So I think that using Terry's suggestion is fine.

Sure - if portability to the currently-supported set of CPU
architectures is all you care about.

Personally, I would not be willing to cripple potential future
portability that much.  (For example, there was, relatively recently,
some talk about a PDP-10 port.)  If anyone ever tries for a port to a
60-bit machine, for example, the most plausible value for
sizeof(void *) would, I would guess, be 12.

"Nobody would be crazy enough to do that!"  No, today that would be
crazy.  But the history of computing is littered with things which were
crazy at one time and were done relatively soon afterwards.  I consider
assuming things like "sizeof(void *) is a power of two" to be on a par
with assuming things like "the hardware is little-endian" or "address
zero is valid and contains zero" or "machine code written into memory
can be subsequently executed with no particular precautions".  (Each of
those was commonly assumed to be true, once upon a time.)

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index