summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-12 19:27:49 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-12 19:27:49 +0000
commitc75dca4902ad96d90237f6ab49c368ecb1ff3e52 (patch)
tree17933ebe7d8de121ec47c896cf51dd424e7498fd /libgfortran
parent2c91fb39d3dca3aa4300047463649d5b108d28fb (diff)
downloadgcc-c75dca4902ad96d90237f6ab49c368ecb1ff3e52.tar.gz
Cleanup memsize types
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@172340 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog15
-rw-r--r--libgfortran/config.h.in11
-rwxr-xr-xlibgfortran/configure105
-rw-r--r--libgfortran/configure.ac9
-rw-r--r--libgfortran/generated/cshift0_c10.c4
-rw-r--r--libgfortran/generated/cshift0_c16.c4
-rw-r--r--libgfortran/generated/cshift0_c4.c4
-rw-r--r--libgfortran/generated/cshift0_c8.c4
-rw-r--r--libgfortran/generated/cshift0_i1.c4
-rw-r--r--libgfortran/generated/cshift0_i16.c4
-rw-r--r--libgfortran/generated/cshift0_i2.c4
-rw-r--r--libgfortran/generated/cshift0_i4.c4
-rw-r--r--libgfortran/generated/cshift0_i8.c4
-rw-r--r--libgfortran/generated/cshift0_r10.c4
-rw-r--r--libgfortran/generated/cshift0_r16.c4
-rw-r--r--libgfortran/generated/cshift0_r4.c4
-rw-r--r--libgfortran/generated/cshift0_r8.c4
-rw-r--r--libgfortran/intrinsics/cshift0.c4
-rw-r--r--libgfortran/io/io.h11
-rw-r--r--libgfortran/io/list_read.c18
-rw-r--r--libgfortran/io/write.c2
-rw-r--r--libgfortran/libgfortran.h61
-rw-r--r--libgfortran/m4/cshift0.m44
23 files changed, 176 insertions, 116 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index c3307b73209..82c59bcd04f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,5 +1,20 @@
2011-04-12 Janne Blomqvist <jb@gcc.gnu.org>
+ * configure.ac: Use AC_TYPE_* to make sure we have (u)intptr_t,
+ check for ptrdiff_t.
+ * libgfortran.h: Remove (u)intptr_t definitions, use ptrdiff_t for
+ index_type, change cshift0* prototypes.
+ * config.h.in: Regenerated.
+ * configure: Regenerated.
+ * intrinsics/cshift0.c (cshift0): Use ptrdiff_t instead of ssize_t.
+ * io/io.h (array_loop_spec): Use index_type instead of ssize_t.
+ * io/list_read.c (nml_parse_qualifier): Likewise.
+ * io/write.c (nml_write_obj): Likewise.
+ * m4/cshift0.c (cshift0_'rtype_code`): Likewise.
+ * generated/cshift0_*.c: Regenerated.
+
+2011-04-12 Janne Blomqvist <jb@gcc.gnu.org>
+
* Makefile.am: Remove _GNU_SOURCE from AM_CPPFLAGS.
* Makefile.in: Regenerated.
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index a255bdccf30..76f1b2d3d16 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -630,6 +630,9 @@
/* libm includes powl */
#undef HAVE_POWL
+/* Define to 1 if the system has the type `ptrdiff_t'. */
+#undef HAVE_PTRDIFF_T
+
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
@@ -945,5 +948,13 @@
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
+/* Define to the type of a signed integer type wide enough to hold a pointer,
+ if such a type exists, and if the system does not define it. */
+#undef intptr_t
+
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
+
+/* Define to the type of an unsigned integer type wide enough to hold a
+ pointer, if such a type exists, and if the system does not define it. */
+#undef uintptr_t
diff --git a/libgfortran/configure b/libgfortran/configure
index 53df412c89b..393650ad97e 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -15634,6 +15634,8 @@ rm -rf conftest*
fi
fi
+
+# Types
ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
if test "x$ac_cv_type_off_t" = x""yes; then :
@@ -15646,6 +15648,87 @@ _ACEOF
fi
+ ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_intptr_t" = x""yes; then :
+
+$as_echo "#define HAVE_INTPTR_T 1" >>confdefs.h
+
+else
+ for ac_type in 'int' 'long int' 'long long int'; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define intptr_t $ac_type
+_ACEOF
+
+ ac_type=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ test -z "$ac_type" && break
+ done
+fi
+
+
+
+ ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = x""yes; then :
+
+$as_echo "#define HAVE_UINTPTR_T 1" >>confdefs.h
+
+else
+ for ac_type in 'unsigned int' 'unsigned long int' \
+ 'unsigned long long int'; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define uintptr_t $ac_type
+_ACEOF
+
+ ac_type=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ test -z "$ac_type" && break
+ done
+fi
+
+
+ac_fn_c_check_type "$LINENO" "ptrdiff_t" "ac_cv_type_ptrdiff_t" "$ac_includes_default"
+if test "x$ac_cv_type_ptrdiff_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_PTRDIFF_T 1
+_ACEOF
+
+
+fi
+
+
# check header files
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
@@ -16404,28 +16487,6 @@ fi
done
-# Check for types
-ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
-if test "x$ac_cv_type_intptr_t" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_INTPTR_T 1
-_ACEOF
-
-
-fi
-
-ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
-if test "x$ac_cv_type_uintptr_t" = x""yes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_UINTPTR_T 1
-_ACEOF
-
-
-fi
-
-
# Check libc for getgid, getpid, getuid
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for getgid in -lc" >&5
$as_echo_n "checking for getgid in -lc... " >&6; }
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 588f9997e56..8235c883572 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -236,7 +236,12 @@ AC_SUBST(extra_ldflags_libgfortran)
LIBGFOR_WORKING_GFORTRAN
AC_SYS_LARGEFILE
+
+# Types
AC_TYPE_OFF_T
+AC_TYPE_INTPTR_T
+AC_TYPE_UINTPTR_T
+AC_CHECK_TYPES([ptrdiff_t])
# check header files
AC_STDC_HEADERS
@@ -264,10 +269,6 @@ AC_CHECK_FUNCS(clock_gettime strftime)
# Check for glibc backtrace functions
AC_CHECK_FUNCS(backtrace backtrace_symbols)
-# Check for types
-AC_CHECK_TYPES([intptr_t])
-AC_CHECK_TYPES([uintptr_t])
-
# Check libc for getgid, getpid, getuid
AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])])
AC_CHECK_LIB([c],[getpid],[AC_DEFINE([HAVE_GETPID],[1],[libc includes getpid])])
diff --git a/libgfortran/generated/cshift0_c10.c b/libgfortran/generated/cshift0_c10.c
index 16c113deb60..ec4bb8a084d 100644
--- a/libgfortran/generated/cshift0_c10.c
+++ b/libgfortran/generated/cshift0_c10.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_COMPLEX_10)
void
-cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ssize_t shift,
+cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_c10 (gfc_array_c10 *ret, const gfc_array_c10 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_c16.c b/libgfortran/generated/cshift0_c16.c
index df83ccb85f4..ac7e8b762c7 100644
--- a/libgfortran/generated/cshift0_c16.c
+++ b/libgfortran/generated/cshift0_c16.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_COMPLEX_16)
void
-cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ssize_t shift,
+cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_c16 (gfc_array_c16 *ret, const gfc_array_c16 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_c4.c b/libgfortran/generated/cshift0_c4.c
index 52d277f1ce3..482af77f2a8 100644
--- a/libgfortran/generated/cshift0_c4.c
+++ b/libgfortran/generated/cshift0_c4.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_COMPLEX_4)
void
-cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ssize_t shift,
+cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_c4 (gfc_array_c4 *ret, const gfc_array_c4 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_c8.c b/libgfortran/generated/cshift0_c8.c
index 9b9c3b2acce..2b3a69ef495 100644
--- a/libgfortran/generated/cshift0_c8.c
+++ b/libgfortran/generated/cshift0_c8.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_COMPLEX_8)
void
-cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ssize_t shift,
+cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_c8 (gfc_array_c8 *ret, const gfc_array_c8 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_i1.c b/libgfortran/generated/cshift0_i1.c
index 7ed44bddb78..65173e3cc6a 100644
--- a/libgfortran/generated/cshift0_i1.c
+++ b/libgfortran/generated/cshift0_i1.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_INTEGER_1)
void
-cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ssize_t shift,
+cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_i1 (gfc_array_i1 *ret, const gfc_array_i1 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_i16.c b/libgfortran/generated/cshift0_i16.c
index 145724b6e81..4374c45f820 100644
--- a/libgfortran/generated/cshift0_i16.c
+++ b/libgfortran/generated/cshift0_i16.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_INTEGER_16)
void
-cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ssize_t shift,
+cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_i16 (gfc_array_i16 *ret, const gfc_array_i16 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_i2.c b/libgfortran/generated/cshift0_i2.c
index df332817557..1a39632d217 100644
--- a/libgfortran/generated/cshift0_i2.c
+++ b/libgfortran/generated/cshift0_i2.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_INTEGER_2)
void
-cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ssize_t shift,
+cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_i2 (gfc_array_i2 *ret, const gfc_array_i2 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_i4.c b/libgfortran/generated/cshift0_i4.c
index a1e118589c5..9d223634fce 100644
--- a/libgfortran/generated/cshift0_i4.c
+++ b/libgfortran/generated/cshift0_i4.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_INTEGER_4)
void
-cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ssize_t shift,
+cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_i4 (gfc_array_i4 *ret, const gfc_array_i4 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_i8.c b/libgfortran/generated/cshift0_i8.c
index cbe13f153f3..43358aa1224 100644
--- a/libgfortran/generated/cshift0_i8.c
+++ b/libgfortran/generated/cshift0_i8.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_INTEGER_8)
void
-cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ssize_t shift,
+cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_i8 (gfc_array_i8 *ret, const gfc_array_i8 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_r10.c b/libgfortran/generated/cshift0_r10.c
index 8ba544d2d8e..bf469fd1a00 100644
--- a/libgfortran/generated/cshift0_r10.c
+++ b/libgfortran/generated/cshift0_r10.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_REAL_10)
void
-cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ssize_t shift,
+cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_r10 (gfc_array_r10 *ret, const gfc_array_r10 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_r16.c b/libgfortran/generated/cshift0_r16.c
index 0725048c2ab..b9e19ffb6e9 100644
--- a/libgfortran/generated/cshift0_r16.c
+++ b/libgfortran/generated/cshift0_r16.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_REAL_16)
void
-cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ssize_t shift,
+cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_r16 (gfc_array_r16 *ret, const gfc_array_r16 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_r4.c b/libgfortran/generated/cshift0_r4.c
index 515c36b41fc..9bd02142455 100644
--- a/libgfortran/generated/cshift0_r4.c
+++ b/libgfortran/generated/cshift0_r4.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_REAL_4)
void
-cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ssize_t shift,
+cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_r4 (gfc_array_r4 *ret, const gfc_array_r4 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/generated/cshift0_r8.c b/libgfortran/generated/cshift0_r8.c
index 5a721e49589..1f99135eb94 100644
--- a/libgfortran/generated/cshift0_r8.c
+++ b/libgfortran/generated/cshift0_r8.c
@@ -32,7 +32,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#if defined (HAVE_GFC_REAL_8)
void
-cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ssize_t shift,
+cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -97,7 +97,7 @@ cshift0_r8 (gfc_array_r8 *ret, const gfc_array_r8 *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/intrinsics/cshift0.c b/libgfortran/intrinsics/cshift0.c
index 651cd6e1e7c..00a50d5db7c 100644
--- a/libgfortran/intrinsics/cshift0.c
+++ b/libgfortran/intrinsics/cshift0.c
@@ -30,7 +30,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
static void
cshift0 (gfc_array_char * ret, const gfc_array_char * array,
- ssize_t shift, int which, index_type size)
+ ptrdiff_t shift, int which, index_type size)
{
/* r.* indicates the return array. */
index_type rstride[GFC_MAX_DIMENSIONS];
@@ -328,7 +328,7 @@ cshift0 (gfc_array_char * ret, const gfc_array_char * array,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h
index b48582d9781..37353d742e8 100644
--- a/libgfortran/io/io.h
+++ b/libgfortran/io/io.h
@@ -53,22 +53,21 @@ struct gfc_unit;
#define is_char4_unit(dtp) ((dtp)->u.p.unit_is_internal && (dtp)->common.unit)
/* The array_loop_spec contains the variables for the loops over index ranges
- that are encountered. Since the variables can be negative, ssize_t
- is used. */
+ that are encountered. */
typedef struct array_loop_spec
{
/* Index counter for this dimension. */
- ssize_t idx;
+ index_type idx;
/* Start for the index counter. */
- ssize_t start;
+ index_type start;
/* End for the index counter. */
- ssize_t end;
+ index_type end;
/* Step for the index counter. */
- ssize_t step;
+ index_type step;
}
array_loop_spec;
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 6e1cb699ab9..39783bf3c61 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -2172,7 +2172,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
}
/* Now read the index. */
- if (convert_integer (dtp, sizeof(ssize_t), neg))
+ if (convert_integer (dtp, sizeof(index_type), neg))
{
if (is_char)
sprintf (parse_err_msg, "Bad integer substring qualifier");
@@ -2187,11 +2187,11 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
if (!null_flag)
{
if (indx == 0)
- memcpy (&ls[dim].start, dtp->u.p.value, sizeof(ssize_t));
+ memcpy (&ls[dim].start, dtp->u.p.value, sizeof(index_type));
if (indx == 1)
- memcpy (&ls[dim].end, dtp->u.p.value, sizeof(ssize_t));
+ memcpy (&ls[dim].end, dtp->u.p.value, sizeof(index_type));
if (indx == 2)
- memcpy (&ls[dim].step, dtp->u.p.value, sizeof(ssize_t));
+ memcpy (&ls[dim].step, dtp->u.p.value, sizeof(index_type));
}
/* Singlet or doublet indices. */
@@ -2199,7 +2199,7 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
{
if (indx == 0)
{
- memcpy (&ls[dim].start, dtp->u.p.value, sizeof(ssize_t));
+ memcpy (&ls[dim].start, dtp->u.p.value, sizeof(index_type));
/* If -std=f95/2003 or an array section is specified,
do not allow excess data to be processed. */
@@ -2229,10 +2229,10 @@ nml_parse_qualifier (st_parameter_dt *dtp, descriptor_dimension *ad,
}
/* Check the values of the triplet indices. */
- if ((ls[dim].start > (ssize_t) GFC_DIMENSION_UBOUND(ad[dim]))
- || (ls[dim].start < (ssize_t) GFC_DIMENSION_LBOUND(ad[dim]))
- || (ls[dim].end > (ssize_t) GFC_DIMENSION_UBOUND(ad[dim]))
- || (ls[dim].end < (ssize_t) GFC_DIMENSION_LBOUND(ad[dim])))
+ if ((ls[dim].start > GFC_DIMENSION_UBOUND(ad[dim]))
+ || (ls[dim].start < GFC_DIMENSION_LBOUND(ad[dim]))
+ || (ls[dim].end > GFC_DIMENSION_UBOUND(ad[dim]))
+ || (ls[dim].end < GFC_DIMENSION_LBOUND(ad[dim])))
{
if (is_char)
sprintf (parse_err_msg, "Substring out of range");
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 987c3cd88a6..4733d51e882 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1932,7 +1932,7 @@ obj_loop:
{
obj->ls[dim_i].idx += nml_carry ;
nml_carry = 0;
- if (obj->ls[dim_i].idx > (ssize_t) GFC_DESCRIPTOR_UBOUND(obj,dim_i))
+ if (obj->ls[dim_i].idx > GFC_DESCRIPTOR_UBOUND(obj,dim_i))
{
obj->ls[dim_i].idx = GFC_DESCRIPTOR_LBOUND(obj,dim_i);
nml_carry = 1;
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index c9d3f371eab..7d9aca1cb72 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -106,38 +106,11 @@ typedef off_t gfc_offset;
#endif
-/* We use intptr_t and uintptr_t, which may not be always defined in
- system headers. */
-
-#ifndef HAVE_INTPTR_T
-#if __SIZEOF_POINTER__ == __SIZEOF_LONG__
-#define intptr_t long
-#elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
-#define intptr_t long long
-#elif __SIZEOF_POINTER__ == __SIZEOF_INT__
-#define intptr_t int
-#elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
-#define intptr_t short
-#else
-#error "Pointer type with unexpected size"
-#endif
+/* Make sure we have ptrdiff_t. */
+#ifndef HAVE_PTRDIFF_T
+typedef intptr_t ptrdiff_t;
#endif
-#ifndef HAVE_UINTPTR_T
-#if __SIZEOF_POINTER__ == __SIZEOF_LONG__
-#define uintptr_t unsigned long
-#elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
-#define uintptr_t unsigned long long
-#elif __SIZEOF_POINTER__ == __SIZEOF_INT__
-#define uintptr_t unsigned int
-#elif __SIZEOF_POINTER__ == __SIZEOF_SHORT__
-#define uintptr_t unsigned short
-#else
-#error "Pointer type with unexpected size"
-#endif
-#endif
-
-
/* On mingw, work around the buggy Windows snprintf() by using the one
mingw provides, __mingw_snprintf(). We also provide a prototype for
__mingw_snprintf(), because the mingw headers currently don't have one. */
@@ -269,7 +242,7 @@ typedef GFC_INTEGER_4 GFC_IO_INT;
/* The following two definitions must be consistent with the types used
by the compiler. */
/* The type used of array indices, amongst other things. */
-typedef ssize_t index_type;
+typedef ptrdiff_t index_type;
/* The type used for the lengths of character variables. */
typedef GFC_INTEGER_4 gfc_charlen_type;
@@ -1323,52 +1296,52 @@ internal_proto(count_0);
/* Internal auxiliary functions for cshift */
-void cshift0_i1 (gfc_array_i1 *, const gfc_array_i1 *, ssize_t, int);
+void cshift0_i1 (gfc_array_i1 *, const gfc_array_i1 *, ptrdiff_t, int);
internal_proto(cshift0_i1);
-void cshift0_i2 (gfc_array_i2 *, const gfc_array_i2 *, ssize_t, int);
+void cshift0_i2 (gfc_array_i2 *, const gfc_array_i2 *, ptrdiff_t, int);
internal_proto(cshift0_i2);
-void cshift0_i4 (gfc_array_i4 *, const gfc_array_i4 *, ssize_t, int);
+void cshift0_i4 (gfc_array_i4 *, const gfc_array_i4 *, ptrdiff_t, int);
internal_proto(cshift0_i4);
-void cshift0_i8 (gfc_array_i8 *, const gfc_array_i8 *, ssize_t, int);
+void cshift0_i8 (gfc_array_i8 *, const gfc_array_i8 *, ptrdiff_t, int);
internal_proto(cshift0_i8);
#ifdef HAVE_GFC_INTEGER_16
-void cshift0_i16 (gfc_array_i16 *, const gfc_array_i16 *, ssize_t, int);
+void cshift0_i16 (gfc_array_i16 *, const gfc_array_i16 *, ptrdiff_t, int);
internal_proto(cshift0_i16);
#endif
-void cshift0_r4 (gfc_array_r4 *, const gfc_array_r4 *, ssize_t, int);
+void cshift0_r4 (gfc_array_r4 *, const gfc_array_r4 *, ptrdiff_t, int);
internal_proto(cshift0_r4);
-void cshift0_r8 (gfc_array_r8 *, const gfc_array_r8 *, ssize_t, int);
+void cshift0_r8 (gfc_array_r8 *, const gfc_array_r8 *, ptrdiff_t, int);
internal_proto(cshift0_r8);
#ifdef HAVE_GFC_REAL_10
-void cshift0_r10 (gfc_array_r10 *, const gfc_array_r10 *, ssize_t, int);
+void cshift0_r10 (gfc_array_r10 *, const gfc_array_r10 *, ptrdiff_t, int);
internal_proto(cshift0_r10);
#endif
#ifdef HAVE_GFC_REAL_16
-void cshift0_r16 (gfc_array_r16 *, const gfc_array_r16 *, ssize_t, int);
+void cshift0_r16 (gfc_array_r16 *, const gfc_array_r16 *, ptrdiff_t, int);
internal_proto(cshift0_r16);
#endif
-void cshift0_c4 (gfc_array_c4 *, const gfc_array_c4 *, ssize_t, int);
+void cshift0_c4 (gfc_array_c4 *, const gfc_array_c4 *, ptrdiff_t, int);
internal_proto(cshift0_c4);
-void cshift0_c8 (gfc_array_c8 *, const gfc_array_c8 *, ssize_t, int);
+void cshift0_c8 (gfc_array_c8 *, const gfc_array_c8 *, ptrdiff_t, int);
internal_proto(cshift0_c8);
#ifdef HAVE_GFC_COMPLEX_10
-void cshift0_c10 (gfc_array_c10 *, const gfc_array_c10 *, ssize_t, int);
+void cshift0_c10 (gfc_array_c10 *, const gfc_array_c10 *, ptrdiff_t, int);
internal_proto(cshift0_c10);
#endif
#ifdef HAVE_GFC_COMPLEX_16
-void cshift0_c16 (gfc_array_c16 *, const gfc_array_c16 *, ssize_t, int);
+void cshift0_c16 (gfc_array_c16 *, const gfc_array_c16 *, ptrdiff_t, int);
internal_proto(cshift0_c16);
#endif
diff --git a/libgfortran/m4/cshift0.m4 b/libgfortran/m4/cshift0.m4
index 0c5e0158eec..5c0d22e8191 100644
--- a/libgfortran/m4/cshift0.m4
+++ b/libgfortran/m4/cshift0.m4
@@ -33,7 +33,7 @@ include(iparm.m4)dnl
`#if defined (HAVE_'rtype_name`)
void
-cshift0_'rtype_code` ('rtype` *ret, const 'rtype` *array, ssize_t shift,
+cshift0_'rtype_code` ('rtype` *ret, const 'rtype` *array, ptrdiff_t shift,
int which)
{
/* r.* indicates the return array. */
@@ -98,7 +98,7 @@ cshift0_'rtype_code` ('rtype` *ret, const 'rtype` *array, ssize_t shift,
rptr = ret->data;
sptr = array->data;
- shift = len == 0 ? 0 : shift % (ssize_t)len;
+ shift = len == 0 ? 0 : shift % (ptrdiff_t)len;
if (shift < 0)
shift += len;