Remove dependency of xalloc.h on SIZE_MAX and PTRDIFF_MAX.

This commit is contained in:
Paul Eggert
2003-11-13 07:19:08 +00:00
parent 4ef9d1e814
commit 346d5dc041
6 changed files with 30 additions and 20 deletions
+7 -2
View File
@@ -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>
+14
View File
@@ -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.
+3 -13
View File
@@ -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 @@ 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. */
+5
View File
@@ -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.
+1 -3
View File
@@ -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])
:
])
-2
View File
@@ -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