Annotation of OpenXM_contrib/gmp/tests/t-gmpmax.c, Revision 1.1
1.1 ! ohara 1: /* Check the values of __GMP_UINT_MAX etc.
! 2:
! 3: Copyright 2001 Free Software Foundation, Inc.
! 4:
! 5: This file is part of the GNU MP Library.
! 6:
! 7: The GNU MP Library is free software; you can redistribute it and/or modify
! 8: it under the terms of the GNU Lesser General Public License as published by
! 9: the Free Software Foundation; either version 2.1 of the License, or (at your
! 10: option) any later version.
! 11:
! 12: The GNU MP Library is distributed in the hope that it will be useful, but
! 13: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 14: or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
! 15: License for more details.
! 16:
! 17: You should have received a copy of the GNU Lesser General Public License
! 18: along with the GNU MP Library; see the file COPYING.LIB. If not, write to
! 19: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
! 20: MA 02111-1307, USA. */
! 21:
! 22: #include <stdio.h>
! 23: #include <stdlib.h>
! 24: #include <limits.h>
! 25: #include "gmp.h"
! 26:
! 27:
! 28: /* __GMP_UINT_MAX etc are generated with expressions in gmp.h since we don't
! 29: want to demand <limits.h> or forcibly include it. Check the expressions
! 30: come out the same as <limits.h>. */
! 31:
! 32: int
! 33: main (int argc, char *argv[])
! 34: {
! 35: int error = 0;
! 36:
! 37: #ifdef UINT_MAX
! 38: if (__GMP_UINT_MAX != UINT_MAX)
! 39: {
! 40: printf ("__GMP_UINT_MAX incorrect\n");
! 41: printf (" __GMP_UINT_MAX %u 0x%X\n", __GMP_UINT_MAX, __GMP_UINT_MAX);
! 42: printf (" UINT_MAX %u 0x%X\n", UINT_MAX, UINT_MAX);
! 43: error = 1;
! 44: }
! 45: #endif
! 46:
! 47: /* gcc 2.95.2 limits.h on solaris 2.5.1 incorrectly selects a 64-bit
! 48: LONG_MAX, leading to some integer overflow in ULONG_MAX and a spurious
! 49: __GMP_ULONG_MAX != ULONG_MAX. Casting ULONG_MAX to unsigned long is a
! 50: workaround. */
! 51: #ifdef ULONG_MAX
! 52: if (__GMP_ULONG_MAX != (unsigned long) ULONG_MAX)
! 53: {
! 54: printf ("__GMP_ULONG_MAX incorrect\n");
! 55: printf (" __GMP_ULONG_MAX %lu 0x%lX\n", __GMP_ULONG_MAX, __GMP_ULONG_MAX);
! 56: printf (" ULONG_MAX %lu 0x%lX\n", ULONG_MAX, ULONG_MAX);
! 57: error = 1;
! 58: }
! 59: #endif
! 60:
! 61: #ifdef USHRT_MAX
! 62: if (__GMP_USHRT_MAX != USHRT_MAX)
! 63: {
! 64: printf ("__GMP_USHRT_MAX incorrect\n");
! 65: printf (" __GMP_USHRT_MAX %hu 0x%hX\n", __GMP_USHRT_MAX, __GMP_USHRT_MAX);
! 66: printf (" USHRT_MAX %hu 0x%hX\n", USHRT_MAX, USHRT_MAX);
! 67: error = 1;
! 68: }
! 69: #endif
! 70:
! 71: if (error)
! 72: abort ();
! 73:
! 74: exit (0);
! 75: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>