[Libevent-users] [Patch] Install autoconf header file as evconfig.h

Dave Gotwisner dgotwisner at rosum.com
Fri Feb 16 19:28:26 EST 2007


William Ahern wrote:

>On Fri, Feb 16, 2007 at 06:24:34PM -0500, Nick Mathewson wrote:
>  
>
>>Hi, all!
>>
>>Now that Libevent 1.3 is out, it's time for Patches Less Obvious.
>>
>>One longstanding problems has been that it's not possible to include
>>event.h unless you first define u_int8_t, u_int32_t, struct timeval,
>>and so on.  It wasn't possible for event.h to do so itself, since the
>>info needed to decide whether to define those existed only in the
>>config.h file created by autoconf.
>>
>>Here is a patch that solves this problem by renaming "config.h" to
>>"evconfig.h", making it get included from "event.h", and installing it
>>as a header file to $PREFIX/include.  This way, people on platforms
>>like mingw and Solaris will be able to build projects that use mingw
>>correctly.
>>    
>>
>
>Wouldn't it be cleaner to either
>
>1) Use (unsigned char) instead of (u_int8_t), (unsigned int) instead of
>(u_int32_t), and include <sys/time.h> or <timeb.h>, conditional on the
>WIN32 macro;
>
>  
>
Actually, you shouldn't use (unsigned int), very unportable.  Use 
(unsigned long) if you must.

I personally hate the proliferation of typedefs.  I have seen u8, U8, 
u_int8, uint8, and many others that all express the same thing. 
(similarly for 16, 32, and 64 bit sizes).  In all cases that I have seen 
(I admit, I haven't looked recently to see how a DEC-10 implements this, 
with it's 10 bit bytes), but, for almost every modern implementation I 
have seen (including MIPS64), char is 8 bits, short is 16, long is 32, 
and long long is 64.  Int is unpredictable and non-portable.  That said, 
the only typedefs I can possibly see of interest are wrappers for 8 bit 
data types, since "char" implies character data not numeric type data.  
Also, I have only seen 2 platforms in the years that treat char as 
unsigned rather than signed, without a specifier, and neither of those 
platforms exist anymore.  Just look in linux/types.h, they define 
u_short, ushort, u_int16_t, and uint26_t.  This is in addition to the 
__u16 defined in asm/types.h.  None of these have platform wrappers 
around them, which implies the base types are VERY portable.  Two header 
files, 5 defines for the same thing.

That said, why not just fix the code for "unsigned" or nothing (you 
shouldn't need to specify everything as "signed"), followed by "char", 
"short", "long", or "long long".  Any programmer that is worth anything 
would know the sizes these apply to.

Note, that this isn't a flame on libevent per se, I take issue with this 
everywhere (including the companies I have worked at).


More information about the Libevent-users mailing list