bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] SSIZE_MAX


From: Bruno Haible
Subject: Re: [bug-gnulib] SSIZE_MAX
Date: Fri, 9 Jun 2006 14:51:14 +0200
User-agent: KMail/1.9.1

Paul Eggert wrote:
> I think size_max.h is there only because SIZE_MAX is in different
> headers on different systems.

Rather, size_max.h is there only because the standard says it's defined
in <inttypes.h> but gnulib so far didn't provide a complete <inttypes.h>
replacement. This will change, thanks to Derek's full-header-path.m4 macro
and because I spent a day on that last week-end.

> Is that also true for SSIZE_MAX?

SSIZE_MAX is expected to be defined in <limits.h>, and
   #include <limits.h>
is portable nowadays. So all we need is a
   #define SSIZE_MAX ...
in config.h on those systems that lack it.

Ben Pfaff wrote:

>    # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))

This doesn't work in a preprocessor expression. You can get it this way:

  AC_CHECK_SIZEOF([size_t], , [#include <stddef.h>
#include <stdio.h>
])

will define SIZEOF_SIZE_T in config.h. Then this definition will do:

  #define SSIZE_MAX  (~ (-1L << (SIZEOF_SIZE_T * CHAR_BIT - 1)))
or
  #define SSIZE_MAX  (((1L << (SIZEOF_SIZE_T * CHAR_BIT - 2)) - 1) * 2 + 1)

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]