bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 1/7] limits-h: define SSIZE_MAX


From: Bruno Haible
Subject: Re: [PATCH 1/7] limits-h: define SSIZE_MAX
Date: Sun, 21 May 2023 14:51:41 +0200

Paul Eggert wrote:
> * doc/posix-headers/limits.texi (limits.h): Document this.
> * lib/limits.in.h (SSIZE_MAX): Define if not already defined.

When I add a unit test for this, I see that the assertion

  static_assert (TYPE_MAXIMUM (ssize_t) == SSIZE_MAX);

fails on 64-bit MSVC 14. That's because on this platform, gnulib
defines ssize_t as 'int', i.e. 32-bit, whereas size_t is 64-bit.
Ouch. And when we used
  # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
that value actually was (int)(-1). Ouch ouch.


2023-05-21  Bruno Haible  <bruno@clisp.org>

        limits-h tests: Check the value of SSIZE_MAX.
        * tests/test-limits-h.c (limits12): New variable.
        Include <sys/types.h> and check the value of SSIZE_MAX.
        * modules/limits-h-tests (Depends-on): Add sys_types.

2023-05-21  Bruno Haible  <bruno@clisp.org>

        ssize_t: Fix replacement on 64-bit Windows.
        * m4/ssize_t.m4 (gt_TYPE_SSIZE_T): Use prefix 'gl_' instead of 'gt_'.
        Define ssize_t to 'long long' or 'long', depending on the width of
        'size_t'.

Attachment: 0001-ssize_t-Fix-replacement-on-64-bit-Windows.patch
Description: Text Data

Attachment: 0002-limits-h-tests-Check-the-value-of-SSIZE_MAX.patch
Description: Text Data


reply via email to

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