|From: Guy Harris
|
|On Tue, Feb 17, 2004 at 11:26:13PM +0100, Michael Tuexen wrote:
|> is there a reason why FT_UINT64 does not work with bitmasks?
|
|Because the code used for shorter integers isn't used for 64-bit
|integers, to avoid requiring 64-bit integer support in the
|compiler, and
|the code to handle 64-bit integers wasn't given bitfield support.
|
|We currently require 64-bit integer support anyway, so it's not clear
|that we should continue to avoid using 64-bit integers for FT_{U}INT64;
|however, note that we *CANNOT* rely on "%ll{d,o,x}" to format 64-bit
|integers, as other modifiers (%L, %q, etc.) are used on some
|platforms.
|(Ethereal currently *does* rely on "%ll" working, but it won't work on
|some platforms....)
As far as I know the only 64-bit integer support we require is displaying
and occasional comparisons (less, greater, equal and the likes). As such, I
think the simplest way of working with 64-bit integers is by splitting the
integer in 2 32-bit integers in situations where there is no native 64-bit
support in the OS/compiler. There are lots of 32-bit emulations of 64 bit
integers available; we probably only need a subset of their implementation.
Note that we probably need some convenience macros for writing 64-bit
integer constants.
We can get rid of the 64-bit integer printf format specifier issues by
defining macros for signed and unsigned 64-bit integers, and maybe also for
the cases where we specify extra format specifiers. E.g.:
#if defined(__GNUC__)
#define FMT_UINT64 "%llu"
#define FMT_UINT64_prefix(x) "%" ## x ## "llu"
#define FMT_INT64 "%lld"
#define FMT_INT64_prefix(x) "%" ## x ## "lld"
#endif
Maybe the autotools already provide a set of macros for this.
Regards,
Olivier