Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/crypto/external/bsd/netpgp/dist/src/lib
In message: <20100626032531.GA14410%britannica.bec.de@localhost>
Joerg Sonnenberger <joerg%britannica.bec.de@localhost> writes:
: On Sat, Jun 26, 2010 at 05:11:39AM +0200, Alistair Crooks wrote:
: > On Sat, Jun 26, 2010 at 01:32:05AM +0200, Joerg Sonnenberger wrote:
: > > On Fri, Jun 25, 2010 at 11:54:32PM +0200, Alistair Crooks wrote:
: > > > Even in C99, the "%lu" method will work unless size_t is bigger
than
: > > > unsigned long *and* the value being printed exceeds ULONG_MAX,
which
: > > > is unlikely to happen in practice.
: >
: > Please get the attributions right - I was quoting that text.
: >
: > > Actually, it doesn't. This method breaks as soon as size_t != u_long and
: > > might only work in a few edge cases like the size_t being the last
: > > argument and the byte order is Little Endian. This is worse because IIRC
: > > Microsoft decided to use IL32LLP64 or something similarly fancy.
: >
: > Can you give us a reference to this, please?
:
: E.g.
:
http://stackoverflow.com/questions/384502/what-is-the-bit-size-of-long-on-64-bit-windows
: and the MSDN reference inside.
:
: > > A more portable approach with autoconf can be found in pkg_install, look
: > > for MISSING_SIZE_T_SUPPORT and the corresponding AC_CHECK_SIZEOF calls
: > > in configure.ac.
: >
: > Hmmm, I see this in configure.ac -
: >
: > AC_CHECK_SIZEOF(int)
: > AC_CHECK_SIZEOF(long)
: > AC_CHECK_SIZEOF(long long)
: > AC_CHECK_SIZEOF(size_t, [#include <stdlib.h>])
:
: ...compute the sizes to not depend on SIZE_MAX (which would simplify the
: logic a lot).
:
: > and
: >
: > case $host in
: > *-*-hpux*)
: > AC_DEFINE(MISSING_SIZE_T_SUPPORT)
: > AH_TEMPLATE([MISSING_SIZE_T_SUPPORT], [
: > Define to 1 if the `z' modifider for printf is missing.
: > ])
: > ;;
: > esac
:
: The only platform for pkgsrc purposes ATM which lacks the %z support.
:
: > and
: >
: > #ifndef MISSING_SIZE_T_SUPPORT
: > # define PRIzu "zu"
: > #elif SIZEOF_SIZE_T == SIZEOF_INT
: > # define PRIzu "u"
: > #elif SIZEOF_SIZE_T == SIZEOF_LONG
: > # define PRIzu "lu"
: > #elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
: > # define PRIzu "llu"
: > #else
: > # errror "Unknown size_t size"
: > #endif
: >
: > Not quite what I'd been expecting, though, from the glowing description
: > above.
:
: It would be simpler if SIZE_MAX support can be assumed. In that case it
: would boil down to
: #if SIZE_MAX == INT_MAX
: #define PRIzu "u"
: #elif SIZE_MAX == LONG_MAX
: #define PRIzu "lu"
: #else SIZE_MAX == LLONG_MAX
: #define PRIzu "llu"
: #endif
You could easily enough have something like the following in autoconf
to generate that:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
size_t foo = ~0;
printf("#ifndef SIZE_MAX\n#define SIZE_MAX %llu\n#endif\n",
(unsigned long long)foo);
return (0);
}
Warner
Home |
Main Index |
Thread Index |
Old Index