From: Paul Eggert Date: Sun, 22 May 2011 21:02:48 +0000 (-0700) Subject: Merge from gnulib. X-Git-Tag: emacs-pretest-24.0.90~104^2~618^2~207 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f518ae90a612e83f8b5148211f54e1f6de445b81;p=emacs.git Merge from gnulib. --- diff --git a/ChangeLog b/ChangeLog index ead1709e5dc..a3c17418bd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-05-22 Paul Eggert + + * lib/intprops.h, lib/stdint.in.h, m4/mktime.m4, m4/readlink.m4: + Merge from gnulib. + 2011-05-21 Andreas Schwab * Makefile.in (AUTOMAKE_INPUTS): Add $(srcdir)/lib/gnulib.mk. diff --git a/lib/intprops.h b/lib/intprops.h index a84bd6af531..293204ab43a 100644 --- a/lib/intprops.h +++ b/lib/intprops.h @@ -27,6 +27,10 @@ E should not have side effects. */ #define _GL_INT_CONVERT(e, v) ((e) - (e) + (v)) +/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see + . */ +#define _GL_INT_NEGATE_CONVERT(e, v) ((e) - (e) - (v)) + /* The extra casts in the following macros work around compiler bugs, e.g., in Cray C 5.0.3.0. */ @@ -50,7 +54,7 @@ /* Return 1 if the integer expression E, after integer promotion, has a signed type. E should not have side effects. */ -#define _GL_INT_SIGNED(e) (_GL_INT_CONVERT (e, -1) < 0) +#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0) /* Minimum and maximum values for integer types and expressions. These @@ -79,7 +83,7 @@ #define _GL_INT_MAXIMUM(e) \ (_GL_INT_SIGNED (e) \ ? _GL_SIGNED_INT_MAXIMUM (e) \ - : _GL_INT_CONVERT (e, -1)) + : _GL_INT_NEGATE_CONVERT (e, 1)) #define _GL_SIGNED_INT_MAXIMUM(e) \ (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1) @@ -179,16 +183,21 @@ : 0 < (a)) /* Return 1 if A * B would overflow in [MIN,MAX] arithmetic. - See above for restrictions. */ + See above for restrictions. Avoid && and || as they tickle + bugs in Sun C 5.11 2010/08/13 and other compilers; see + . */ #define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \ ((b) < 0 \ ? ((a) < 0 \ ? (a) < (max) / (b) \ - : (b) < -1 && (min) / (b) < (a)) \ - : (0 < (b) \ - && ((a) < 0 \ - ? (a) < (min) / (b) \ - : (max) / (b) < (a)))) + : (b) == -1 \ + ? 0 \ + : (min) / (b) < (a)) \ + : (b) == 0 \ + ? 0 \ + : ((a) < 0 \ + ? (a) < (min) / (b) \ + : (max) / (b) < (a))) /* Return 1 if A / B would overflow in [MIN,MAX] arithmetic. See above for restrictions. Do not check for division by zero. */ @@ -234,11 +243,11 @@ (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \ || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max)) #define _GL_DIVIDE_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? (b) == _GL_INT_CONVERT (min, -1) && (a) < - (max) \ + ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ : (a) < 0 ? (b) <= (a) + (b) - 1 \ : (b) < 0 && (a) + (b) <= (a)) #define _GL_REMAINDER_OVERFLOW(a, b, min, max) \ - ((min) < 0 ? (b) == _GL_INT_CONVERT (min, -1) && (a) < - (max) \ + ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \ : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \ : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max)) @@ -302,13 +311,10 @@ /* Return 1 if the expression A B would overflow, where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test, assuming MIN and MAX are the minimum and maximum for the result type. - - This macro assumes that A | B is a valid integer if both A and B are, - which is true of all known practical hosts. If this is a problem - for you, please let us know how to fix it for your host. */ + Arguments should be free of side effects. */ #define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \ op_result_overflow (a, b, \ - _GL_INT_MINIMUM ((a) | (b)), \ - _GL_INT_MAXIMUM ((a) | (b))) + _GL_INT_MINIMUM ((b) - (b) + (a)), \ + _GL_INT_MAXIMUM ((b) - (b) + (a))) #endif /* _GL_INTPROPS_H */ diff --git a/lib/stdint.in.h b/lib/stdint.in.h index b32227bb04c..376b96a785d 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -93,7 +93,7 @@ #undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H -/* Minimum and maximum values for a integer type under the usual assumption. +/* Minimum and maximum values for an integer type under the usual assumption. Return an unspecified value if BITS == 0, adding a check to pacify picky compilers. */ diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 56b2416d619..01167a1ec0e 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,4 +1,4 @@ -# serial 19 +# serial 20 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -234,6 +234,23 @@ AC_DEFUN([gl_FUNC_MKTIME], fi ]) +AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [ + AC_REQUIRE([gl_FUNC_MKTIME]) + if test $REPLACE_MKTIME = 0; then + dnl BeOS has __mktime_internal in libc, but other platforms don't. + AC_CHECK_FUNC([__mktime_internal], + [AC_DEFINE([mktime_internal], [__mktime_internal], + [Define to the real name of the mktime_internal function.]) + ], + [dnl mktime works but it doesn't export __mktime_internal, + dnl so we need to substitute our own mktime implementation. + REPLACE_MKTIME=1 + AC_LIBOBJ([mktime]) + gl_PREREQ_MKTIME + ]) + fi +]) + # Prerequisites of lib/mktime.c. AC_DEFUN([gl_PREREQ_MKTIME], [ diff --git a/m4/readlink.m4 b/m4/readlink.m4 index a502ca560fe..ec737d3f408 100644 --- a/m4/readlink.m4 +++ b/m4/readlink.m4 @@ -1,4 +1,4 @@ -# readlink.m4 serial 9 +# readlink.m4 serial 10 dnl Copyright (C) 2003, 2007, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -48,7 +48,8 @@ AC_DEFUN([gl_FUNC_READLINK], fi ]) -# Like gl_FUNC_READLINK, except prepare for separate compilation (no AC_LIBOBJ). +# Like gl_FUNC_READLINK, except prepare for separate compilation +# (no REPLACE_READLINK, no AC_LIBOBJ). AC_DEFUN([gl_FUNC_READLINK_SEPARATE], [ AC_CHECK_FUNCS_ONCE([readlink])