httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis Daly <d...@daoine.org>
Subject Re: [PATCH] distinguishing 64-bit vs. 32-bit in httpd -v
Date Wed, 05 Dec 2001 09:48:21 GMT
On Tue, Dec 04, 2001 at 01:36:25PM -0500, Jeff Trawick wrote:
> Francis Daly <deva@daoine.org> writes:
> 
> > 8 is a magic number.  How about
> > 
> >        printf("Pointer size:   %d bits\n", CHAR_BIT*sizeof(void*)); ?
> > 
> > to allow for any machine which has some other number of bits in a
> > (C-)byte.
> 
> So what is more likely?
> 
> a) 8 * sizeof(void *) breaks because there aren't 8 bits in a byte

Possible in C.  I don't know how likely it is in current reality.

This presumes that the point of the question is "how many bits is a
void pointer", of course.

> b) CHAR_BIT * sizeof(void *) breaks because while there may be 8 bits
>    in a byte a char is two bytes

If I understand it correctly, that isn't possible in C.  In C, a char
is one byte, which comprises CHAR_BIT bits (and CHAR_BIT is at least
8).

In common usage in the real world, "byte" is the same as "octet",
which is "8 bits"; but in C, "byte" is defined in terms of "sizeof
(char)", which is 1.

> c) CHAR_BIT * sizeof(void *) breaks because CHAR_BIT isn't defined or
>    <limits.h> doesn't exist

If <limits.h> doesn't exist, or CHAR_BIT isn't defined in it, then
we're not in C any more either.

ISO/ANSI, that is.  Are there other variants of compilers that
currently compile the code?

> :) 
> 
> (I don't mean to say anything bad about your suggestion.)

The only plus points I can come up with, are that it's a compile-time
constant, so has no performance impact.  And it's right ;-)

	f
-- 
Francis Daly        deva@daoine.org

Mime
View raw message