1 /* Implementation of the SIGNAL and ALARM g77 intrinsics
2 Contributed by François-Xavier Coudert <coudert@clipper.ens.fr>
4 This file is part of the GNU Fortran 95 runtime library (libgfortran).
6 Libgfortran is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file into combinations with other programs,
14 and to distribute those combinations without any restriction coming
15 from the use of this file. (The General Public License restrictions
16 do apply in other respects; for example, they cover modification of
17 the file, and distribution when not linked into a combine
20 Libgfortran is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public
26 License along with libgfortran; see the file COPYING. If not,
27 write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28 Boston, MA 02110-1301, USA. */
31 #include "libgfortran.h"
43 /* SIGNAL subroutine with PROCEDURE as handler */
44 extern void signal_sub (int *, void (*)(int), int *);
45 iexport_proto(signal_sub
);
48 signal_sub (int *number
, void (*handler
)(int), int *status
)
52 *status
= (int) signal (*number
, handler
);
54 signal (*number
, handler
);
64 /* SIGNAL subroutine with INTEGER as handler */
65 extern void signal_sub_int (int *, int *, int *);
66 iexport_proto(signal_sub_int
);
69 signal_sub_int (int *number
, int *handler
, int *status
)
73 *status
= (int) signal (*number
, (void (*)(int)) *handler
);
75 signal (*number
, (void (*)(int)) *handler
);
82 iexport(signal_sub_int
);
85 /* SIGNAL function with PROCEDURE as handler */
86 extern int signal_func (int *, void (*)(int));
87 iexport_proto(signal_func
);
90 signal_func (int *number
, void (*handler
)(int))
93 signal_sub (number
, handler
, &status
);
99 /* SIGNAL function with INTEGER as handler */
100 extern int signal_func_int (int *, int *);
101 iexport_proto(signal_func_int
);
104 signal_func_int (int *number
, int *handler
)
107 signal_sub_int (number
, handler
, &status
);
110 iexport(signal_func_int
);
114 /* ALARM intrinsic with PROCEDURE as handler */
115 extern void alarm_sub (int *, void (*)(int), int *);
116 iexport_proto(alarm_sub
);
119 alarm_sub (int *seconds
, void (*handler
)(int), int *status
)
121 #if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
124 if (signal (SIGALRM
, handler
) == SIG_ERR
)
127 *status
= alarm (*seconds
);
131 signal (SIGALRM
, handler
);
143 /* ALARM intrinsic with INTEGER as handler */
144 extern void alarm_sub_int (int *, int *, int *);
145 iexport_proto(alarm_sub_int
);
148 alarm_sub_int (int *seconds
, int *handler
, int *status
)
150 #if defined (SIGALRM) && defined (HAVE_ALARM) && defined (HAVE_SIGNAL)
153 if (signal (SIGALRM
, (void (*)(int)) handler
) == SIG_ERR
)
156 *status
= alarm (*seconds
);
160 signal (SIGALRM
, (void (*)(int)) handler
);
169 iexport(alarm_sub_int
);