+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.
+
2003-11-04 Bruno Haible <bruno@clisp.org>
* modules/xsize: New file.
+2003-11-11 Bruno Haible <bruno@clisp.org>
+
+ * xsize.h (SIZE_MAX): Remove fallback definition.
+ * xalloc.h: Include limits.h. Assume SIZE_MAX and PTRDIFF_MAX are
+ defined.
+
2003-11-10 Paul Eggert <eggert@twinsun.com>
* xalloc.h (xalloc_oversized): [! (defined PTRDIFF_MAX &&
Reject sizes of exactly SIZE_MAX bytes.
* xreadlink.c: Include "xalloc.h" before checking whether SIZE_MAX
is defined, since "xalloc.h" now defines SIZE_MAX on modern hosts.
-
+
2003-11-05 Bruno Haible <bruno@clisp.org>
* xsize.h: Include limits.h, to avoid a possible collision with
#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
PTRDIFF_MAX < SIZE_MAX, 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 defined PTRDIFF_MAX && PTRDIFF_MAX < SIZE_MAX
+# if PTRDIFF_MAX < SIZE_MAX
# define xalloc_oversized(n, s) (SIZE_MAX / (s) < (n))
-# else /* SIZE_MAX might not be defined, so avoid (SIZE_MAX - 1). */
-# define xalloc_oversized(n, s) ((size_t) -2 / (s) < (n))
+# else
+# define xalloc_oversized(n, s) ((SIZE_MAX - 1) / (s) < (n))
# endif
/* These macros are deprecated; they will go away soon, and are retained
#if HAVE_STDINT_H
# include <stdint.h>
#endif
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
/* The size of memory objects is often computed through expressions of
type size_t. Example:
+2003-11-11 Bruno Haible <bruno@clisp.org>
+
+ * size_max.m4: New file.
+ * ptrdiff_max.m4: New file.
+ * xsize,m4 (gl_XSIZE): Require gl_SIZE_MAX.
+ * xalloc.m4 (gl_PREREQ_XALLOC): New file.
+ (gl_XALLOC): Invoke it.
+
2003-11-04 Bruno Haible <bruno@clisp.org>
* xsize.m4: New file.
-# xalloc.m4 serial 6
+# xalloc.m4 serial 7
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
AC_DEFUN([gl_XALLOC],
[
+ gl_PREREQ_XALLOC
gl_PREREQ_XMALLOC
gl_PREREQ_XSTRDUP
])
+# Prerequisites of lib/xalloc.h.
+AC_DEFUN([gl_PREREQ_XALLOC], [
+ AC_REQUIRE([gl_SIZE_MAX])
+ AC_REQUIRE([gl_PTRDIFF_MAX])
+ :
+])
+
# Prerequisites of lib/xmalloc.c.
AC_DEFUN([gl_PREREQ_XMALLOC], [
AC_REQUIRE([AC_C_INLINE])
-# xsize.m4 serial 1
+# xsize.m4 serial 2
dnl Copyright (C) 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
AC_DEFUN([gl_XSIZE],
[
dnl Prerequisites of lib/xsize.h.
+ AC_REQUIRE([gl_SIZE_MAX])
AC_CHECK_HEADERS(stdint.h)
])
lib/xmalloc.c
lib/xstrdup.c
m4/xalloc.m4
+m4/size_max.m4
+m4/ptrdiff_max.m4
Depends-on:
malloc
Files:
lib/xsize.h
m4/xsize.m4
+m4/size_max.m4
Depends-on: