Re: [exim] Quota over 2GB supported?

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Exim User's Mailing List
Date:  
À: Exim User's Mailing List
Sujet: Re: [exim] Quota over 2GB supported?
[ On Thursday, June 9, 2005 at 12:03:39 (+0100), Tony Finch wrote: ]
> Subject: Re: [exim] Quota over 2GB supported?
>
> On Thu, 9 Jun 2005, Philip Hazel wrote:
> >
> > I did discover that gcc has %lld but of course that isn't part of C89,
> > so I suspect that there are C systems out there that don't have it.


Indeed -- that's why I suggested putting the macros in a portability
header so that they can be adapted as necessary for given platforms
during the build configuration phase.

> This is strictly a libc question rather than a purely compiler question.
> Old BSDs spelled %lld %qd (q = quad) though modern ones have supported
> %lld since it became the wider standard. I think I'd be surprised if there
> are systems without long long and %lld any more.


True enough.

> > It would be nice if there was an automatic way of determining what the
> > type of off_t is.
>
> The C99 solution is to cast to intmax_t (the largest integer type which
> may be wider than long long) and use the corresponding %jd format
> specifier. But only a few systems support this at the moment.


IMO that's actually not a very good solution, and as far as I can tell
it's not even recommended by the C99 standard itself. (at least I can't
find any such thing in the draft copy I have -- chapter & verse? :-)

C99 does define macros similar in nature to those I suggested for all
the various standard integer types, including intmax_t (PRIiMAX et al),
in <inttypes.h>, so those should always be used. Many systems already
support thes macros -- C99 compatability is not necessary and libc
printf() support for "%jd" is irrelevant.

While intmax_t is indeed the largest signed integer type, and doing as
you suggest, but with "%" PRIiMAX instead of "%jd", will always work, it
could be a lot more expensive an operation than necessary, especially in
general use (e.g. with in_port_t, usually the minimum-width integer!).

It's always best to cast to the same-width (and same-sign) integer type,
rather than to always extend to intmax_t (or uintmax_t0, though doing
this portably requires running compiler tests during configuration to
discover the width of the various local integer types and system
specific types such as off_t, and then likely defining format specifier
strings in the manner I suggested. Such a configuration script could
also discover and provide appropriate macros and similar if any of the
expected ones are not found in <inttypes.h>.

-- 
                        Greg A. Woods


H:+1 416 218-0098  W:+1 416 489-5852 x122  VE3TCP  RoboHack <woods@???>
Planix, Inc. <woods@???>          Secrets of the Weird <woods@???>