From: Paul Eggert Date: Fri, 20 May 2011 02:15:19 +0000 (-0700) Subject: intprops-tests: revert unsigned part of previous change X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55abd3179923a7ec9cde845b8c37fc678c31dd5c;p=pspp intprops-tests: revert unsigned part of previous change * tests/test-intprops.c (UINT_MAX, ULONG_MAX, UINTMAX_MAX, U0, U1): Remove; they weren't actually needed. All uses of U0 and U1 removed, and other casts to 'unsigned int' reverted to 'u' suffixes. See . --- diff --git a/ChangeLog b/ChangeLog index e9da0044d1..5065b4b497 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-05-19 Paul Eggert + + intprops-tests: revert unsigned part of previous change + * tests/test-intprops.c (UINT_MAX, ULONG_MAX, UINTMAX_MAX, U0, U1): + Remove; they weren't actually needed. All uses of U0 and U1 removed, + and other casts to 'unsigned int' reverted to 'u' suffixes. See + . + 2011-05-19 Bruno Haible strerror_r: Work around strerror_r() change in Cygwin 1.7.8. diff --git a/tests/test-intprops.c b/tests/test-intprops.c index 9c2fe07564..eec35dd933 100644 --- a/tests/test-intprops.c +++ b/tests/test-intprops.c @@ -26,18 +26,6 @@ #include "macros.h" -/* Work around compiler bugs in HP-UX 11.23 cc, IRIX 6.5 cc, OSF/1 5.1 - cc, and Solaris 9 cc. See - . */ -#undef UINT_MAX -#undef ULONG_MAX -#undef UINTMAX_MAX -#define UINT_MAX ((unsigned int) -1) -#define ULONG_MAX ((unsigned long int) -1) -#define UINTMAX_MAX ((uintmax_t) -1) -#define U0 ((unsigned int) 0) -#define U1 ((unsigned int) 1) - /* Integer representation. */ verify (INT_MIN + INT_MAX < 0 ? (TYPE_TWOS_COMPLEMENT (int) @@ -112,23 +100,23 @@ verify (check_binop (ADD, INT_MAX, 1, INT_MIN, INT_MAX, true)); verify (check_binop (ADD, INT_MAX, -1, INT_MIN, INT_MAX, false)); verify (check_binop (ADD, INT_MIN, 1, INT_MIN, INT_MAX, false)); verify (check_binop (ADD, INT_MIN, -1, INT_MIN, INT_MAX, true)); -verify (check_binop (ADD, UINT_MAX, U1, U0, UINT_MAX, true)); -verify (check_binop (ADD, U0, U1, U0, UINT_MAX, false)); +verify (check_binop (ADD, UINT_MAX, 1u, 0u, UINT_MAX, true)); +verify (check_binop (ADD, 0u, 1u, 0u, UINT_MAX, false)); verify (check_binop (SUBTRACT, INT_MAX, 1, INT_MIN, INT_MAX, false)); verify (check_binop (SUBTRACT, INT_MAX, -1, INT_MIN, INT_MAX, true)); verify (check_binop (SUBTRACT, INT_MIN, 1, INT_MIN, INT_MAX, true)); verify (check_binop (SUBTRACT, INT_MIN, -1, INT_MIN, INT_MAX, false)); -verify (check_binop (SUBTRACT, UINT_MAX, U1, U0, UINT_MAX, false)); -verify (check_binop (SUBTRACT, U0, U1, U0, UINT_MAX, true)); +verify (check_binop (SUBTRACT, UINT_MAX, 1u, 0u, UINT_MAX, false)); +verify (check_binop (SUBTRACT, 0u, 1u, 0u, UINT_MAX, true)); verify (check_unop (NEGATE, INT_MIN, INT_MIN, INT_MAX, TYPE_TWOS_COMPLEMENT (int))); verify (check_unop (NEGATE, 0, INT_MIN, INT_MAX, false)); verify (check_unop (NEGATE, INT_MAX, INT_MIN, INT_MAX, false)); -verify (check_unop (NEGATE, U0, U0, UINT_MAX, false)); -verify (check_unop (NEGATE, U1, U0, UINT_MAX, true)); -verify (check_unop (NEGATE, UINT_MAX, U0, UINT_MAX, true)); +verify (check_unop (NEGATE, 0u, 0u, UINT_MAX, false)); +verify (check_unop (NEGATE, 1u, 0u, UINT_MAX, true)); +verify (check_unop (NEGATE, UINT_MAX, 0u, UINT_MAX, true)); verify (check_binop (MULTIPLY, INT_MAX, INT_MAX, INT_MIN, INT_MAX, true)); verify (check_binop (MULTIPLY, INT_MAX, INT_MIN, INT_MIN, INT_MAX, true)); @@ -143,17 +131,17 @@ verify (check_binop (DIVIDE, INT_MIN, -1, INT_MIN, INT_MAX, INT_NEGATE_OVERFLOW (INT_MIN))); verify (check_binop (DIVIDE, INT_MAX, 1, INT_MIN, INT_MAX, false)); verify (check_binop (DIVIDE, (unsigned int) INT_MIN, - -U1, U0, UINT_MAX, false)); + -1u, 0u, UINT_MAX, false)); verify (check_binop (REMAINDER, INT_MIN, -1, INT_MIN, INT_MAX, INT_NEGATE_OVERFLOW (INT_MIN))); verify (check_binop (REMAINDER, INT_MAX, 1, INT_MIN, INT_MAX, false)); verify (check_binop (REMAINDER, (unsigned int) INT_MIN, - -U1, U0, UINT_MAX, false)); + -1u, 0u, UINT_MAX, false)); -verify (check_binop (LEFT_SHIFT, UINT_MAX, 1, U0, UINT_MAX, true)); -verify (check_binop (LEFT_SHIFT, UINT_MAX / 2 + 1, 1, U0, UINT_MAX, true)); -verify (check_binop (LEFT_SHIFT, UINT_MAX / 2, 1, U0, UINT_MAX, false)); +verify (check_binop (LEFT_SHIFT, UINT_MAX, 1, 0u, UINT_MAX, true)); +verify (check_binop (LEFT_SHIFT, UINT_MAX / 2 + 1, 1, 0u, UINT_MAX, true)); +verify (check_binop (LEFT_SHIFT, UINT_MAX / 2, 1, 0u, UINT_MAX, false)); /* INT__OVERFLOW with mixed types. */ #define check_sum(a, b, overflow) \ @@ -161,51 +149,51 @@ verify (check_binop (LEFT_SHIFT, UINT_MAX / 2, 1, U0, UINT_MAX, false)); verify (INT_ADD_OVERFLOW (b, a) == (overflow)) check_sum (-1, LONG_MIN, true); check_sum (-1, UINT_MAX, false); -check_sum (- (long) 1, INT_MIN, INT_MIN == LONG_MIN); -check_sum (U0, -1, true); -check_sum (U0, 0, false); -check_sum (U0, 1, false); +check_sum (-1L, INT_MIN, INT_MIN == LONG_MIN); +check_sum (0u, -1, true); +check_sum (0u, 0, false); +check_sum (0u, 1, false); check_sum (1, LONG_MAX, true); check_sum (1, UINT_MAX, true); -check_sum ((long) 1, INT_MAX, INT_MAX == LONG_MAX); -check_sum (U1, INT_MAX, INT_MAX == UINT_MAX); -check_sum (U1, INT_MIN, true); +check_sum (1L, INT_MAX, INT_MAX == LONG_MAX); +check_sum (1u, INT_MAX, INT_MAX == UINT_MAX); +check_sum (1u, INT_MIN, true); -verify (! INT_SUBTRACT_OVERFLOW (INT_MAX, U1)); +verify (! INT_SUBTRACT_OVERFLOW (INT_MAX, 1u)); verify (! INT_SUBTRACT_OVERFLOW (UINT_MAX, 1)); -verify (! INT_SUBTRACT_OVERFLOW (U0, -1)); +verify (! INT_SUBTRACT_OVERFLOW (0u, -1)); verify (INT_SUBTRACT_OVERFLOW (UINT_MAX, -1)); -verify (INT_SUBTRACT_OVERFLOW (INT_MIN, U1)); -verify (INT_SUBTRACT_OVERFLOW (-1, U0)); +verify (INT_SUBTRACT_OVERFLOW (INT_MIN, 1u)); +verify (INT_SUBTRACT_OVERFLOW (-1, 0u)); #define check_product(a, b, overflow) \ verify (INT_MULTIPLY_OVERFLOW (a, b) == (overflow)); \ verify (INT_MULTIPLY_OVERFLOW (b, a) == (overflow)) -check_product (-1, U1, true); +check_product (-1, 1u, true); check_product (-1, INT_MIN, INT_NEGATE_OVERFLOW (INT_MIN)); check_product (-1, UINT_MAX, true); check_product (-12345, LONG_MAX / -12345 - 1, true); check_product (-12345, LONG_MAX / -12345, false); check_product (0, -1, false); check_product (0, 0, false); -check_product (0, U0, false); +check_product (0, 0u, false); check_product (0, 1, false); check_product (0, INT_MAX, false); check_product (0, INT_MIN, false); check_product (0, UINT_MAX, false); -check_product (U0, -1, false); -check_product (U0, 0, false); -check_product (U0, U0, false); -check_product (U0, 1, false); -check_product (U0, INT_MAX, false); -check_product (U0, INT_MIN, false); -check_product (U0, UINT_MAX, false); +check_product (0u, -1, false); +check_product (0u, 0, false); +check_product (0u, 0u, false); +check_product (0u, 1, false); +check_product (0u, INT_MAX, false); +check_product (0u, INT_MIN, false); +check_product (0u, UINT_MAX, false); check_product (1, INT_MAX, false); check_product (1, INT_MIN, false); check_product (1, UINT_MAX, false); -check_product (U1, INT_MIN, true); -check_product (U1, INT_MAX, UINT_MAX < INT_MAX); +check_product (1u, INT_MIN, true); +check_product (1u, INT_MAX, UINT_MAX < INT_MAX); check_product (INT_MAX, UINT_MAX, true); check_product (INT_MAX, ULONG_MAX, true); check_product (INT_MIN, LONG_MAX / INT_MIN - 1, true); @@ -213,19 +201,19 @@ check_product (INT_MIN, LONG_MAX / INT_MIN, false); check_product (INT_MIN, UINT_MAX, true); check_product (INT_MIN, ULONG_MAX, true); -verify (INT_DIVIDE_OVERFLOW (INT_MIN, - (long) 1) +verify (INT_DIVIDE_OVERFLOW (INT_MIN, -1L) == (TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN)); verify (! INT_DIVIDE_OVERFLOW (INT_MIN, UINT_MAX)); verify (! INT_DIVIDE_OVERFLOW (INTMAX_MIN, UINTMAX_MAX)); verify (! INT_DIVIDE_OVERFLOW (INTMAX_MIN, UINT_MAX)); -verify (INT_DIVIDE_OVERFLOW (-11, (unsigned int) 10)); -verify (INT_DIVIDE_OVERFLOW (-10, (unsigned int) 10)); -verify (! INT_DIVIDE_OVERFLOW (-9, (unsigned int) 10)); -verify (INT_DIVIDE_OVERFLOW ((unsigned int) 11, -10)); -verify (INT_DIVIDE_OVERFLOW ((unsigned int) 10, -10)); +verify (INT_DIVIDE_OVERFLOW (-11, 10u)); +verify (INT_DIVIDE_OVERFLOW (-10, 10u)); +verify (! INT_DIVIDE_OVERFLOW (-9, 10u)); +verify (INT_DIVIDE_OVERFLOW (11u, -10)); +verify (INT_DIVIDE_OVERFLOW (10u, -10)); verify (! INT_DIVIDE_OVERFLOW (9u, -10)); -verify (INT_REMAINDER_OVERFLOW (INT_MIN, - (long) 1) +verify (INT_REMAINDER_OVERFLOW (INT_MIN, -1L) == (TYPE_TWOS_COMPLEMENT (long int) && INT_MIN == LONG_MIN)); verify (INT_REMAINDER_OVERFLOW (-1, UINT_MAX)); verify (INT_REMAINDER_OVERFLOW ((intmax_t) -1, UINTMAX_MAX)); @@ -234,10 +222,10 @@ verify (INT_REMAINDER_OVERFLOW (INTMAX_MIN, UINT_MAX) && - (unsigned int) INTMAX_MIN % UINT_MAX != 0)); verify (INT_REMAINDER_OVERFLOW (INT_MIN, ULONG_MAX) == (INT_MIN % ULONG_MAX != 1)); -verify (! INT_REMAINDER_OVERFLOW (U1, -1)); -verify (! INT_REMAINDER_OVERFLOW (37 * (unsigned int) 39, -39)); -verify (INT_REMAINDER_OVERFLOW (37 * (unsigned int) 39 + 1, -39)); -verify (INT_REMAINDER_OVERFLOW (37 * (unsigned int) 39 - 1, -39)); +verify (! INT_REMAINDER_OVERFLOW (1u, -1)); +verify (! INT_REMAINDER_OVERFLOW (37*39u, -39)); +verify (INT_REMAINDER_OVERFLOW (37*39u + 1, -39)); +verify (INT_REMAINDER_OVERFLOW (37*39u - 1, -39)); verify (! INT_REMAINDER_OVERFLOW (LONG_MAX, -INT_MAX)); int