From: Paul Eggert Date: Thu, 13 Nov 2003 07:19:08 +0000 (+0000) Subject: Remove dependency of xalloc.h on SIZE_MAX and PTRDIFF_MAX. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=346d5dc0410331c94de5d3f469bd32884ec9a1a0;p=pspp Remove dependency of xalloc.h on SIZE_MAX and PTRDIFF_MAX. --- diff --git a/ChangeLog b/ChangeLog index 37219b077e..b733dd0fb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,12 @@ +2003-11-12 Paul Eggert + + * modules/xalloc (Files): Undo latest change, since xalloc.h + no longer needs SIZE_MAX or PTRDIFF_MAX. + 2003-11-11 Bruno Haible * modules/xsize (Files): Add m4/size_max.m4. - * modules/xalloc (Files): Add m4/size_max.m4, m4_ptrdiff_max.m4. + * modules/xalloc (Files): Add m4/size_max.m4, m4/ptrdiff_max.m4. 2003-11-04 Bruno Haible @@ -175,7 +180,7 @@ 2003-08-18 Paul Eggert * modules/stdbool: Add BUILT_SOURCES. Prefer $@ to target name - in makefile rules. + in makefile rules. 2003-08-17 Simon Josefsson diff --git a/lib/ChangeLog b/lib/ChangeLog index 6163b5d5d0..29fc9b9a2c 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,17 @@ +2003-11-12 Paul Eggert + + * xalloc.h: Do not include or . + (xalloc_oversized): Use sizeof (ptrdiff_t) and sizeof (size_t) for + the heuristic, rather than PTRDIFF_MAX and SIZE_MAX. This + heuristic is just as accurate as far as we know, and it removes a + dependency on size_max.m4 and ptrdiff_max.m4. + +2003-11-12 Paul Eggert + + * xstrtol.c (__xstrtol): Remove "break" immediately after + "return", to pacify some unknown compiler. Problem reported + by Joerg Schilling. + 2003-11-11 Bruno Haible * xsize.h (SIZE_MAX): Remove fallback definition. diff --git a/lib/xalloc.h b/lib/xalloc.h index 8faf316013..4b6585811b 100644 --- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -20,15 +20,8 @@ #ifndef XALLOC_H_ # define XALLOC_H_ -/* Get size_t. */ # include -/* Get SIZE_MAX, PTRDIFF_MAX. */ -# include -# if HAVE_STDINT_H -# include -# endif - # ifndef __attribute__ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ # define __attribute__(x) @@ -75,14 +68,11 @@ char *xstrdup (const char *str); calculations, so the conservative dividend to use here is SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. However, malloc (SIZE_MAX) fails on all known hosts where - PTRDIFF_MAX < SIZE_MAX, so do not bother to test for + sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for exactly-SIZE_MAX allocations on such hosts; this avoids a test and branch when S is known to be 1. */ -# if PTRDIFF_MAX < SIZE_MAX -# define xalloc_oversized(n, s) (SIZE_MAX / (s) < (n)) -# else -# define xalloc_oversized(n, s) ((SIZE_MAX - 1) / (s) < (n)) -# endif +# define xalloc_oversized(n, s) \ + ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) /* These macros are deprecated; they will go away soon, and are retained temporarily only to ease conversion to the functions described above. */ diff --git a/m4/ChangeLog b/m4/ChangeLog index 418503bd0c..2f2b32fabc 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,8 @@ +2003-11-12 Paul Eggert + + * xalloc.m4 (gl_PREREQ_XALLOC): Do not require gl_SIZE_MAX or + gl_PTRDIFF_MAX. + 2003-11-11 Bruno Haible * size_max.m4: New file. diff --git a/m4/xalloc.m4 b/m4/xalloc.m4 index 07efb2f7f7..dec84177c7 100644 --- a/m4/xalloc.m4 +++ b/m4/xalloc.m4 @@ -1,4 +1,4 @@ -# xalloc.m4 serial 7 +# xalloc.m4 serial 8 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. dnl This file is free software, distributed under the terms of the GNU dnl General Public License. As a special exception to the GNU General @@ -15,8 +15,6 @@ AC_DEFUN([gl_XALLOC], # Prerequisites of lib/xalloc.h. AC_DEFUN([gl_PREREQ_XALLOC], [ - AC_REQUIRE([gl_SIZE_MAX]) - AC_REQUIRE([gl_PTRDIFF_MAX]) : ]) diff --git a/modules/xalloc b/modules/xalloc index 2e7b89bba2..46482cc88e 100644 --- a/modules/xalloc +++ b/modules/xalloc @@ -6,8 +6,6 @@ lib/xalloc.h lib/xmalloc.c lib/xstrdup.c m4/xalloc.m4 -m4/size_max.m4 -m4/ptrdiff_max.m4 Depends-on: malloc