re PR fortran/30947 (intrinsic: ALARM)
authorFrancois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Mon, 6 Aug 2007 23:02:38 +0000 (23:02 +0000)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Mon, 6 Aug 2007 23:02:38 +0000 (23:02 +0000)
PR fortran/30947

* iresolve.c (gfc_resolve_alarm_sub): Suffix the subroutine name
with the kind of the STATUS argument.

* intrinsics/signal.c: Create specific versions of alarm_sub and
alarm_sub_int according to the integer kind of the last argument.
* gfortran.map (GFORTRAN_1.0): Remove _gfortran_alarm_sub and
_gfortran_alarm_sub_int, add _gfortran_alarm_sub_i4,
_gfortran_alarm_sub_i8, _gfortran_alarm_sub_int_i4 and
_gfortran_alarm_sub_int_i8.

From-SVN: r127259

gcc/fortran/ChangeLog
gcc/fortran/iresolve.c
libgfortran/ChangeLog
libgfortran/gfortran.map
libgfortran/intrinsics/signal.c

index 7a80bfd5c1c3f2a8e442c5e5e23ac42d1e3085a2..dc5a09e2dc0cf06bb6a4f4248d6bfe498ba97ceb 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-06  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/30947
+       * iresolve.c (gfc_resolve_alarm_sub): Suffix the subroutine name
+       with the kind of the STATUS argument.
+
 2007-08-06  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/30948
index 21ec6058a102ec2c447e7759860c86618568e40f..d0a73bfc8f2951222c4d6d20451824e64d7a9097 100644 (file)
@@ -2385,15 +2385,19 @@ gfc_resolve_alarm_sub (gfc_code *c)
   ts.type = BT_INTEGER;
   ts.kind = gfc_c_int_kind;
 
-  /* handler can be either BT_INTEGER or BT_PROCEDURE  */
+  /* handler can be either BT_INTEGER or BT_PROCEDURE.
+     In all cases, the status argument is of default integer kind
+     (enforced in check.c) so that the function suffix is fixed.  */
   if (handler->ts.type == BT_INTEGER)
     {
       if (handler->ts.kind != gfc_c_int_kind)
        gfc_convert_type (handler, &ts, 2);
-      name = gfc_get_string (PREFIX ("alarm_sub_int"));
+      name = gfc_get_string (PREFIX ("alarm_sub_int_i%d"),
+                            gfc_default_integer_kind);
     }
   else
-    name = gfc_get_string (PREFIX ("alarm_sub"));
+    name = gfc_get_string (PREFIX ("alarm_sub_i%d"),
+                          gfc_default_integer_kind);
 
   if (seconds->ts.kind != gfc_c_int_kind)
     gfc_convert_type (seconds, &ts, 2);
index e205466bb463726ec3a69c8dc4a6e02fab3998c9..c7e57db9a915706e1652f9a7a87ffb97556596f4 100644 (file)
@@ -1,3 +1,13 @@
+2007-08-06  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+       PR fortran/30947
+       * intrinsics/signal.c: Create specific versions of alarm_sub and
+       alarm_sub_int according to the integer kind of the last argument.
+       * gfortran.map (GFORTRAN_1.0): Remove _gfortran_alarm_sub and
+       _gfortran_alarm_sub_int, add _gfortran_alarm_sub_i4,
+       _gfortran_alarm_sub_i8, _gfortran_alarm_sub_int_i4 and
+       _gfortran_alarm_sub_int_i8.
+
 2007-08-06  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/29828
index ed881ebfbccc5a92d6fc2f09ecb66aa8f6d175fd..8cfc23670b7dafd655a0278c31cc9e02744f2ead 100644 (file)
@@ -4,8 +4,10 @@ GFORTRAN_1.0 {
     _gfortran_access_func;
     _gfortran_adjustl;
     _gfortran_adjustr;
-    _gfortran_alarm_sub;
-    _gfortran_alarm_sub_int;
+    _gfortran_alarm_sub_i4;
+    _gfortran_alarm_sub_i8;
+    _gfortran_alarm_sub_int_i4;
+    _gfortran_alarm_sub_int_i8;
     _gfortran_all_l16;
     _gfortran_all_l4;
     _gfortran_all_l8;
index 2c2f38d2969fd3af9ae63c08d5a0e97842bbe3db..c69efac1f185c60fe29f2574c350398ad3c5cc88 100644 (file)
@@ -132,11 +132,11 @@ iexport(signal_func_int);
 
 
 /* ALARM intrinsic with PROCEDURE as handler  */
-extern void alarm_sub (int *, void (*)(int), int *);
-iexport_proto(alarm_sub);
+extern void alarm_sub_i4 (int *, void (*)(int), GFC_INTEGER_4 *);
+iexport_proto(alarm_sub_i4);
 
 void
-alarm_sub (int *seconds, void (*handler)(int), int *status)
+alarm_sub_i4 (int *seconds, void (*handler)(int), GFC_INTEGER_4 *status)
 {
 #if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
   if (status != NULL)
@@ -157,15 +157,71 @@ alarm_sub (int *seconds, void (*handler)(int), int *status)
     *status = -1;
 #endif
 }
-iexport(alarm_sub);
+iexport(alarm_sub_i4);
+
+
+extern void alarm_sub_i8 (int *, void (*)(int), GFC_INTEGER_8 *);
+iexport_proto(alarm_sub_i8);
+
+void
+alarm_sub_i8 (int *seconds, void (*handler)(int), GFC_INTEGER_8 *status)
+{
+#if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
+  if (status != NULL)
+    {
+      if (signal (SIGALRM, handler) == SIG_ERR)
+       *status = -1;
+      else
+       *status = alarm (*seconds);
+    }
+  else
+    {
+      signal (SIGALRM, handler);
+      alarm (*seconds);
+    }
+#else
+  errno = ENOSYS;
+  if (status != NULL)
+    *status = -1;
+#endif
+}
+iexport(alarm_sub_i8);
 
 
 /* ALARM intrinsic with INTEGER as handler  */
-extern void alarm_sub_int (int *, int *, int *);
-iexport_proto(alarm_sub_int);
+extern void alarm_sub_int_i4 (int *, int *, GFC_INTEGER_4 *);
+iexport_proto(alarm_sub_int_i4);
+
+void
+alarm_sub_int_i4 (int *seconds, int *handler, GFC_INTEGER_4 *status)
+{
+#if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
+  if (status != NULL)
+    {
+      if (signal (SIGALRM, (void (*)(int)) *handler) == SIG_ERR)
+       *status = -1;
+      else
+       *status = alarm (*seconds);
+    }
+  else
+    {
+      signal (SIGALRM, (void (*)(int)) *handler);
+      alarm (*seconds);
+    }
+#else
+  errno = ENOSYS;
+  if (status != NULL)
+    *status = -1;
+#endif
+}
+iexport(alarm_sub_int_i4);
+
+
+extern void alarm_sub_int_i8 (int *, int *, GFC_INTEGER_8 *);
+iexport_proto(alarm_sub_int_i8);
 
 void
-alarm_sub_int (int *seconds, int *handler, int *status)
+alarm_sub_int_i8 (int *seconds, int *handler, GFC_INTEGER_8 *status)
 {
 #if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
   if (status != NULL)
@@ -186,5 +242,5 @@ alarm_sub_int (int *seconds, int *handler, int *status)
     *status = -1;
 #endif
 }
-iexport(alarm_sub_int);
+iexport(alarm_sub_int_i8);