+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.
/* 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
/* 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
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 :
#define off_t long int
_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
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; }
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
# 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])])
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
#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. */
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;
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];
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;
#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;
}
/* 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");
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. */
{
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. */
}
/* 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");
{
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;
#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. */
/* 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;
/* 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
`#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. */
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;