aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libgfortran/ChangeLog9
-rw-r--r--libgfortran/config.h.in3
-rwxr-xr-xlibgfortran/configure136
-rw-r--r--libgfortran/configure.ac3
-rw-r--r--libgfortran/intrinsics/signal.c26
5 files changed, 165 insertions, 12 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index bb7b7ba..effc06e 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,12 @@
+2006-10-08 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ PR libfortran/26540
+ * intrinsics/signal.c (signal_sub, signal_sub_int): Use intptr_t
+ if available to cast function pointers to int and back.
+ * configure.ac: Check for intptr_t.
+ * config.h.in: Regenerate.
+ * configure: Regenerate.
+
2006-10-01 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR fortran/16580
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index 444cd2b..0be4cf9 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -390,6 +390,9 @@
/* Define to 1 if you have the <ieeefp.h> header file. */
#undef HAVE_IEEEFP_H
+/* Define to 1 if the system has the type `intptr_t'. */
+#undef HAVE_INTPTR_T
+
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
diff --git a/libgfortran/configure b/libgfortran/configure
index 6544f66..8265f5b 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -6898,8 +6898,9 @@ fi
break
done
if test "$acx_cv_header_stdint" = stddef.h; then
- acx_cv_header_stdint_kind="(lacks uintptr_t)"
+ acx_cv_header_stdint_kind="(lacks uintmax_t)"
for i in stdint.h $inttype_headers; do
+ unset ac_cv_type_uintptr_t
unset ac_cv_type_uint32_t
unset ac_cv_type_uint64_t
echo $ECHO_N "looking for an incomplete stdint.h in $i, $ECHO_C" >&6
@@ -7025,11 +7026,65 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_uint64_t" >&5
echo "${ECHO_T}$ac_cv_type_uint64_t" >&6
-if test $ac_cv_type_uint64_t = yes; then
- :
+
+ echo "$as_me:$LINENO: checking for uintptr_t" >&5
+echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6
+if test "${ac_cv_type_uintptr_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
else
- acx_cv_header_stdint_kind="(lacks uintptr_t and uint64_t)"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <$i>
+
+int
+main ()
+{
+if ((uintptr_t *) 0)
+ return 0;
+if (sizeof (uintptr_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_uintptr_t=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_uintptr_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
+echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5
+echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6
break
done
@@ -7162,11 +7217,6 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_u_int64_t" >&5
echo "${ECHO_T}$ac_cv_type_u_int64_t" >&6
-if test $ac_cv_type_u_int64_t = yes; then
- :
-else
- acx_cv_header_stdint_kind="(u_intXX_t style, lacks u_int64_t)"
-fi
break
done
@@ -10037,6 +10087,7 @@ fi
done
+
for ac_func in wait setmode
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -10144,6 +10195,73 @@ fi
done
+# Check for types
+echo "$as_me:$LINENO: checking for intptr_t" >&5
+echo $ECHO_N "checking for intptr_t... $ECHO_C" >&6
+if test "${ac_cv_type_intptr_t+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+if ((intptr_t *) 0)
+ return 0;
+if (sizeof (intptr_t))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_intptr_t=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_type_intptr_t=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_intptr_t" >&5
+echo "${ECHO_T}$ac_cv_type_intptr_t" >&6
+if test $ac_cv_type_intptr_t = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INTPTR_T 1
+_ACEOF
+
+
+fi
+
+
# Check libc for getgid, getpid, getuid
echo "$as_me:$LINENO: checking for getgid in -lc" >&5
echo $ECHO_N "checking for getgid in -lc... $ECHO_C" >&6
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 4784fa5..abdf37a 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -174,6 +174,9 @@ AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime clock access fork execl)
AC_CHECK_FUNCS(wait setmode)
+# Check for types
+AC_CHECK_TYPES([intptr_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/intrinsics/signal.c b/libgfortran/intrinsics/signal.c
index 9e40358..e912c90 100644
--- a/libgfortran/intrinsics/signal.c
+++ b/libgfortran/intrinsics/signal.c
@@ -38,8 +38,18 @@ Boston, MA 02110-1301, USA. */
#include <signal.h>
#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
#include <errno.h>
+#ifdef HAVE_INTPTR_T
+# define INTPTR_T intptr_t
+#else
+# define INTPTR_T int
+#endif
+
/* SIGNAL subroutine with PROCEDURE as handler */
extern void signal_sub (int *, void (*)(int), int *);
iexport_proto(signal_sub);
@@ -48,8 +58,13 @@ void
signal_sub (int *number, void (*handler)(int), int *status)
{
#ifdef HAVE_SIGNAL
+ INTPTR_T ret;
+
if (status != NULL)
- *status = (int) signal (*number, handler);
+ {
+ ret = (INTPTR_T) signal (*number, handler);
+ *status = (int) ret;
+ }
else
signal (*number, handler);
#else
@@ -69,10 +84,15 @@ void
signal_sub_int (int *number, int *handler, int *status)
{
#ifdef HAVE_SIGNAL
+ INTPTR_T ptr = *handler, ret;
+
if (status != NULL)
- *status = (int) signal (*number, (void (*)(int)) *handler);
+ {
+ ret = (INTPTR_T) signal (*number, (void (*)(int)) ptr);
+ *status = (int) ret;
+ }
else
- signal (*number, (void (*)(int)) *handler);
+ signal (*number, (void (*)(int)) ptr);
#else
errno = ENOSYS;
if (status != NULL)