Mercurial > hg > octave-nkf > gnulib-hg
changeset 4865:8690f8e0e0bf
Remove dependency of xalloc.h on SIZE_MAX and PTRDIFF_MAX.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 13 Nov 2003 07:19:08 +0000 |
parents | 0a11347be2e2 |
children | b0a2e9b92a80 |
files | ChangeLog lib/ChangeLog lib/xalloc.h m4/ChangeLog m4/xalloc.m4 modules/xalloc |
diffstat | 6 files changed, 30 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,12 @@ +2003-11-12 Paul Eggert <eggert@twinsun.com> + + * modules/xalloc (Files): Undo latest change, since xalloc.h + no longer needs SIZE_MAX or PTRDIFF_MAX. + 2003-11-11 Bruno Haible <bruno@clisp.org> * 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 <bruno@clisp.org> @@ -175,7 +180,7 @@ 2003-08-18 Paul Eggert <eggert@twinsun.com> * modules/stdbool: Add BUILT_SOURCES. Prefer $@ to target name - in makefile rules. + in makefile rules. 2003-08-17 Simon Josefsson <jas@extundo.com>
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,17 @@ +2003-11-12 Paul Eggert <eggert@twinsun.com> + + * xalloc.h: Do not include <limits.h> or <stdint.h>. + (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 <eggert@twinsun.com> + + * xstrtol.c (__xstrtol): Remove "break" immediately after + "return", to pacify some unknown compiler. Problem reported + by Joerg Schilling. + 2003-11-11 Bruno Haible <bruno@clisp.org> * xsize.h (SIZE_MAX): Remove fallback definition.
--- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -20,15 +20,8 @@ #ifndef XALLOC_H_ # define XALLOC_H_ -/* Get size_t. */ # include <stddef.h> -/* Get SIZE_MAX, PTRDIFF_MAX. */ -# include <limits.h> -# if HAVE_STDINT_H -# include <stdint.h> -# endif - # ifndef __attribute__ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ # define __attribute__(x) @@ -75,14 +68,11 @@ 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. */
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,8 @@ +2003-11-12 Paul Eggert <eggert@twinsun.com> + + * xalloc.m4 (gl_PREREQ_XALLOC): Do not require gl_SIZE_MAX or + gl_PTRDIFF_MAX. + 2003-11-11 Bruno Haible <bruno@clisp.org> * size_max.m4: New file.
--- 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 @@ # Prerequisites of lib/xalloc.h. AC_DEFUN([gl_PREREQ_XALLOC], [ - AC_REQUIRE([gl_SIZE_MAX]) - AC_REQUIRE([gl_PTRDIFF_MAX]) : ])