• Tom Lane's avatar
    Rationalize snprintf.c's handling of "ll" formats. · 595a0eab
    Tom Lane authored
    Although all known platforms define "long long" as 64 bits, it still feels
    a bit shaky to be using "va_arg(args, int64)" to pull out an argument that
    the caller thought was declared "long long".  The reason it was coded like
    this, way back in commit 3311c766, was to work around the possibility that
    the compiler had no type named "long long" --- and, at the time, that it
    maybe didn't have 64-bit ints at all.  Now that we're requiring compilers
    to support C99, those concerns are moot.  Let's make the code clearer and
    more bulletproof by writing "long long" where we mean "long long".
    
    This does introduce a hazard that we'd inefficiently use 128-bit arithmetic
    to convert plain old integers.  The way to tackle that would be to provide
    two versions of fmtint(), one for "long long" and one for narrower types.
    Since, as of today, no platforms require that, we won't bother with the
    extra code for now.
    
    Discussion: https://postgr.es/m/1680.1538587115@sss.pgh.pa.us
    595a0eab
snprintf.c 31.4 KB