Skip to content

Commit

Permalink
Assume ptrdiff_t
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Sep 6, 2017
1 parent 755bebd commit 7bac4c1
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 75 deletions.
10 changes: 3 additions & 7 deletions build.vc/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */

#if _MSC_VER >= 1600 && !defined( HAVE_STDINT_H )
#if _MSC_VER >= 1600 && !defined( HAVE_STDINT_H )
# define HAVE_STDINT_H 1
#endif

#if _MSC_VER >= 1800
#if _MSC_VER >= 1800
# define HAVE_INTTYPES_H 1
#endif

Expand Down Expand Up @@ -173,9 +173,6 @@ MA 02111-1307, USA. */
/* Define if you have the `processor_info' function. */
#undef HAVE_PROCESSOR_INFO

/* Define if the system has the type `ptrdiff_t'. */
#define HAVE_PTRDIFF_T 1

/* Define if the system has the type `quad_t'. */
#undef HAVE_QUAD_T

Expand Down Expand Up @@ -357,7 +354,6 @@ MA 02111-1307, USA. */
#ifdef HAVE_STDINT_H
#define HAVE_INTMAX_T 1
#define HAVE_UINTMAX_T 1
#define HAVE_PTRDIFF_T 1
#define HAVE_UINT_LEAST32_T 1
#define SIZEOF_UINTMAX_T 8
#endif
Expand All @@ -371,7 +367,7 @@ MA 02111-1307, USA. */
#define alloca _alloca
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define MSC_C_(x) #x
#define MSC_C_(x) #x
#define MSC_CC_(x) MSC_C_(x)
#define MSC_VERSION "Microsoft C++ (Version " MSC_CC_(_MSC_FULL_VER) ")"
#endif
6 changes: 1 addition & 5 deletions config.in
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,6 @@ MA 02110-1301, USA.
/* Define to 1 if you have the `pstat_getprocessor' function. */
#undef HAVE_PSTAT_GETPROCESSOR

/* Define to 1 if the system has the type `ptrdiff_t'. */
#undef HAVE_PTRDIFF_T

/* Define to 1 if the system has the type `quad_t'. */
#undef HAVE_QUAD_T

Expand Down Expand Up @@ -409,8 +406,7 @@ MA 02110-1301, USA.
/* Assembler local label prefix */
#undef LSYM_PREFIX

/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR

/* Name of package */
Expand Down
43 changes: 21 additions & 22 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.

define(GMP_COPYRIGHT,[[
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Expand Down Expand Up @@ -60,7 +60,7 @@ dnl Automake "no-dependencies" is used because include file dependencies
dnl are not useful to us. Pretty much everything depends just on mpir.h,
dnl gmp-impl.h and longlong.h, and yet only rarely does everything need to
dnl be rebuilt for changes to those files.
dnl
dnl
dnl Note that there's a copy of these options in the top-level Makefile.am,
dnl so update there too if changing anything.
dnl
Expand Down Expand Up @@ -390,7 +390,7 @@ case $host in
GMP_INCLUDE_MPN(alpha/alpha-defs.m4)
GMP_INCLUDE_MPN(alpha/default.m4)
SPEED_CYCLECOUNTER_OBJ=alpha.lo
cyclecounter_size=1
cyclecounter_size=1
;;

arm*-*-*)
Expand Down Expand Up @@ -587,7 +587,7 @@ case $host in
powerpc7400 | powerpc7410)
gcc_cflags_asm="-Wa,-maltivec"
gcc_cflags_cpu="-mcpu=7400 -mcpu=750" ;;
powerpc74[45]?)
powerpc74[45]?)
gcc_cflags_asm="-Wa,-maltivec"
gcc_cflags_cpu="-mcpu=7450" ;;
powerpc750) gcc_cflags_cpu="-mcpu=750" ;;
Expand Down Expand Up @@ -938,7 +938,7 @@ case $host in

# Availability of rdtsc is checked at run-time.
SPEED_CYCLECOUNTER_OBJ=pentium.lo

case $host in
*-*-solaris* | *-*-sunos*)
# Note no -g, it disables all optimizations.
Expand Down Expand Up @@ -1131,7 +1131,7 @@ case $host in
[k6[23]]) path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" ;;
k6) path="x86/k6/mmx x86/k6 x86" ;;
athlon | k7 | x86_64 | atom) path="x86/k7/mmx x86/k7 x86" ;;
k102 | k103 | bulldozer | piledriver) path="x86/k7/mmx/k8/k10/k102 x86/k7/mmx/k8/k10 x86/k7/mmx/k8 x86/k7/mmx x86/k7 x86" ;;
k102 | k103 | bulldozer | piledriver) path="x86/k7/mmx/k8/k10/k102 x86/k7/mmx/k8/k10 x86/k7/mmx/k8 x86/k7/mmx x86/k7 x86" ;;
k10) path="x86/k7/mmx/k8/k10 x86/k7/mmx/k8 x86/k7/mmx x86/k7 x86" ;;
k8 | bobcat) path="x86/k7/mmx/k8 x86/k7/mmx x86/k7 x86" ;;
core2 | penryn) path="x86/core2 x86" ;;
Expand Down Expand Up @@ -1167,7 +1167,7 @@ case $host in
x86/core2 x86/nehalem"
fat_functions="add_n addmul_1 add_err1_n add_err2_n copyd copyi
divexact_1 divexact_by3c divexact_byfobm1 divrem_1 divrem_2
divrem_euclidean_qr_1
divrem_euclidean_qr_1
divrem_euclidean_qr_2 gcd_1 lshift
mod_1 mod_34lsub1 modexact_1c_odd mul_1 mul_basecase
mulmid_basecase preinv_divrem_1 preinv_mod_1 redc_1 rshift
Expand All @@ -1190,7 +1190,7 @@ case $host in
gcc_64_cflags_optlist="opt arch cpu"
SPEED_CYCLECOUNTER_OBJ_64=x86_64.lo
CALLING_CONVENTIONS_OBJS_64='x86_64call.lo x86_64check$U.lo'
cyclecounter_size_64=2
cyclecounter_size_64=2
case $host in
*-*-solaris* | *-*-sunos*)
# Note no -g, it disables all optimizations.
Expand Down Expand Up @@ -1268,15 +1268,15 @@ case $host in
path_64="x86_64/bulldozer/piledriver x86_64/bulldozer x86_64/k8/k10/k102 x86_64/k8/k10 x86_64/k8 x86_64" ;;
bobcat-*-*)
path_64="x86_64/bobcat x86_64" ;;
core2-*-*)
core2-*-*)
path_64="x86_64/core2 x86_64" ;;
penryn-*-*)
penryn-*-*)
path_64="x86_64/core2/penryn x86_64/core2 x86_64" ;;
nehalem-*-*)
nehalem-*-*)
path_64="x86_64/nehalem x86_64/core2 x86_64" ;;
westmere-*-*)
westmere-*-*)
path_64="x86_64/nehalem/westmere x86_64/nehalem x86_64/core2 x86_64" ;;
sandybridge-*-*)
sandybridge-*-*)
path_64="x86_64/sandybridge x86_64/nehalem x86_64/core2 x86_64" ;;
ivybridge-*-*)
path_64="x86_64/sandybridge/ivybridge x86_64/sandybridge x86_64/nehalem x86_64/core2 x86_64" ;;
Expand All @@ -1288,9 +1288,9 @@ case $host in
path_64="x86_64/skylake x86_64/sandybridge x86_64" ;;
skylakeavx-*-*)
path_64="x86_64/skylake/avx x86_64/haswell/avx x86_64/skylake x86_64/haswell x86_64/sandybridge x86_64" ;;
atom-*-*)
atom-*-*)
path_64="x86_64/atom x86_64" ;;
nano-*-*)
nano-*-*)
path_64="x86_64/k8/k8only x86_64/k8 x86_64" ;;
esac

Expand Down Expand Up @@ -1632,7 +1632,7 @@ if test $found_compiler = yes; then
else
GMP_CC="/* No __GMP_CC here as --enable-gmpcompat option not selected */"
GMP_CFLAGS=""
fi
fi

AC_SUBST(GMP_CC)
AC_SUBST(GMP_CFLAGS)
Expand Down Expand Up @@ -1930,7 +1930,7 @@ Use "--disable-static --enable-shared" to build just a DLL.])
# inline isascii (used in gmp). It gives an extern inline for
# __isascii, but for some reason not the plain isascii.
#
# LDFLAGS="$LDFLAGS -Wl,--enable-auto-import" this is too general
# LDFLAGS="$LDFLAGS -Wl,--enable-auto-import" this is too general
if test "$enable_shared" = yes; then
GMP_LDFLAGS="$GMP_LDFLAGS -no-undefined -Wl,--export-all-symbols"
LIBGMP_LDFLAGS="$LIBGMP_LDFLAGS -Wl,--output-def,.libs/libmpir-3.dll.def"
Expand Down Expand Up @@ -2025,13 +2025,12 @@ AC_TYPE_SIGNAL
# intmax_t - C99
# long double - not in the HP bundled K&R cc
# long long - only in reasonably recent compilers
# ptrdiff_t - seems to be everywhere, maybe don't need to check this
# quad_t - BSD specific
# uint_least32_t - C99
#
# the default includes are sufficient for all these types
#
AC_CHECK_TYPES([intmax_t, uintmax_t, long double, long long, ptrdiff_t, quad_t, uint_least32_t])
AC_CHECK_TYPES([intmax_t, uintmax_t, long double, long long, quad_t, uint_least32_t])

AC_C_STRINGIZE

Expand Down Expand Up @@ -2182,7 +2181,7 @@ gmp_mpn_functions="$extra_functions \
mulmod_2expp1_basecase mul_fft \
mul mul_n mul_basecase sqr_basecase random random2 \
pow_1 powlo powm binvert \
urandomb urandomm randomb rrandom invert \
urandomb urandomm randomb rrandom invert \
rootrem sizeinbase sqrtrem get_str set_str scan0 scan1 popcount hamdist cmp perfect_square_p \
bdivmod gcd gcd_1 gcdext tdiv_qr jacobi_base jacobi jacobi_2 get_d \
mullow_n mulhigh_n mullow_n_basecase mullow_basecase \
Expand Down Expand Up @@ -2835,7 +2834,7 @@ if test "$gmp_asm_syntax_testing" != no; then
case $enable_profiling in
prof | gprof) GMP_ASM_X86_MCOUNT ;;
esac
case $host in
case $host in
*-*-darwin*)
OBJECT_FORMAT="-f macho32" ;;
*)
Expand All @@ -2844,7 +2843,7 @@ if test "$gmp_asm_syntax_testing" != no; then
;;

64)
case $host in
case $host in
*-*-darwin*)
# Defined in mpn/x86_64/x86_64-defs.m4, but there currently
# hardcoded just for ELF, so redefine it here for Mach-O:
Expand Down
20 changes: 6 additions & 14 deletions printf/doprnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ MA 02110-1301, USA. */


/* change this to "#define TRACE(x) x" for diagnostics */
#define TRACE(x)
#define TRACE(x)


/* Should be portable, but in any case this is only used under some ASSERTs. */
Expand Down Expand Up @@ -212,7 +212,7 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,

type = '\0';
value = &param.width;

param.base = 10;
param.conv = 0;
param.expfmt = "e%c%02ld";
Expand Down Expand Up @@ -321,11 +321,7 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
gmp_str = mpq_get_str (NULL, param.base, va_arg(ap, mpq_srcptr));
goto gmp_integer;
case 't':
#if HAVE_PTRDIFF_T
(void) va_arg (ap, ptrdiff_t);
#else
ASSERT_FAIL (ptrdiff_t not available);
#endif
break;
case 'z':
(void) va_arg (ap, size_t);
Expand Down Expand Up @@ -425,11 +421,11 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
goto set_type;
type = 'L'; /* "ll" means "L" */
break;

case 'm':
/* glibc strerror(errno), no argument */
goto next;

case 'M': /* mp_limb_t */
/* mung format string to l or ll and let plain printf handle it */
#if _LONG_LONG_LIMB
Expand Down Expand Up @@ -485,11 +481,7 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
}
break;
case 'Q': mpq_set_si ((mpq_ptr) p, (long) retval, 1L); break;
#if HAVE_PTRDIFF_T
case 't': * (ptrdiff_t *) p = retval; break;
#else
case 't': ASSERT_FAIL (ptrdiff_t not available); break;
#endif
case 'z': * (size_t *) p = retval; break;
case 'Z': mpz_set_si ((mpz_ptr) p, (long) retval); break;
}
Expand All @@ -508,7 +500,7 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
need for separate code. */
(void) va_arg (ap, const void *);
goto next;

case 'x':
param.base = 16;
goto integer;
Expand Down Expand Up @@ -561,7 +553,7 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
/* don't allow negative precision */
param.prec = MAX (0, n);
}
}
}
break;

case '0':
Expand Down
16 changes: 6 additions & 10 deletions printf/repl-vsnprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ __gmp_replacement_vsnprintf (char *buf, size_t buf_size,
#ifdef DBL_MAX_10_EXP
/* but in any case prefer a value the compiler says */
double_digits = DBL_MAX_10_EXP;
#endif
#endif

/* IEEE 128-bit quad, Intel 80-bit temporary, or VAX H floats all have 15
bit exponents, so the default is a maximum 4932 decimal digits. */
Expand All @@ -143,7 +143,7 @@ __gmp_replacement_vsnprintf (char *buf, size_t buf_size,
#ifdef LDBL_MAX_10_EXP
/* but in any case prefer a value the compiler says */
long_double_digits = LDBL_MAX_10_EXP;
#endif
#endif

for (;;)
{
Expand All @@ -166,7 +166,7 @@ __gmp_replacement_vsnprintf (char *buf, size_t buf_size,
case 'c':
/* char, already accounted for by strlen(fmt) */
goto next;

case 'd':
case 'i':
case 'o':
Expand Down Expand Up @@ -206,11 +206,7 @@ __gmp_replacement_vsnprintf (char *buf, size_t buf_size,
#endif
break;
case 't':
#if HAVE_PTRDIFF_T
(void) va_arg (ap, ptrdiff_t);
#else
ASSERT_FAIL (ptrdiff_t not available);
#endif
break;
case 'z':
(void) va_arg (ap, size_t);
Expand Down Expand Up @@ -272,7 +268,7 @@ __gmp_replacement_vsnprintf (char *buf, size_t buf_size,
set_type:
type = fchar;
break;

case 'l':
/* long or long long */
if (type != 'l')
Expand All @@ -296,7 +292,7 @@ __gmp_replacement_vsnprintf (char *buf, size_t buf_size,
prec = (seen_prec ? strnlen (s, prec) : strlen (s));
}
goto next;

case 'p':
/* pointer, let's assume at worst it's octal with some padding */
(void) va_arg (ap, const void *);
Expand All @@ -320,7 +316,7 @@ __gmp_replacement_vsnprintf (char *buf, size_t buf_size,
case '-':
/* left justify, no effect on total width */
break;

case '.':
seen_prec = 1;
value = ≺
Expand Down
4 changes: 0 additions & 4 deletions scanf/doscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,11 +717,7 @@ __gmp_doscan (const struct gmp_doscan_funs_t *funs, void *data,
case 'L': ASSERT_FAIL (long long not available); break;
#endif
case 'Q': mpq_set_si ((mpq_ptr) p, (long) chars, 1L); break;
#if HAVE_PTRDIFF_T
case 't': * (ptrdiff_t *) p = chars; break;
#else
case 't': ASSERT_FAIL (ptrdiff_t not available); break;
#endif
case 'z': * (size_t *) p = chars; break;
case 'Z': mpz_set_si ((mpz_ptr) p, (long) chars); break;
default: ASSERT (0); break;
Expand Down
Loading

0 comments on commit 7bac4c1

Please sign in to comment.