summaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/signal.c
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-08 14:27:22 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2006-10-08 14:27:22 +0000
commit16af3de20aba6b948f4a479fd172a59352d1d1f5 (patch)
treeffb84f961e1bffef9af13aa03299b35be358889b /libgfortran/intrinsics/signal.c
parentf4b3b5f41e37956297bb1e97ca49294f8c01f05d (diff)
downloadgcc-16af3de20aba6b948f4a479fd172a59352d1d1f5.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117556 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/signal.c')
-rw-r--r--libgfortran/intrinsics/signal.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/libgfortran/intrinsics/signal.c b/libgfortran/intrinsics/signal.c
index 9e403585027..e912c90780e 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)