aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>2005-10-28 23:16:17 +0200
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-10-28 21:16:17 +0000
commit185d7d97506315bcf48bae38d410f68af50eba4a (patch)
treefc0a4e0d2fc0100ea5d8070de286cf8217cb2dc9 /libgfortran
parent7f0dbff3607628e68395992ac86e3e659c7e1b09 (diff)
downloadgcc-185d7d97506315bcf48bae38d410f68af50eba4a.zip
gcc-185d7d97506315bcf48bae38d410f68af50eba4a.tar.gz
gcc-185d7d97506315bcf48bae38d410f68af50eba4a.tar.bz2
check.c (gfc_check_alarm_sub, [...]): New functions.
* check.c (gfc_check_alarm_sub, gfc_check_signal, gfc_check_signal_sub): New functions. * gfortran.h (gfc_generic_isym_id): Add GFC_ISYM_SIGNAL. * intrinsic.c (add_functions): Add signal intrinsic. (add_subroutines): Add signal and alarm intrinsics. * intrinsic.texi: Document the new intrinsics. * iresolve.c (gfc_resolve_signal, gfc_resolve_alarm_sub, gfc_resolve_signal_sub): New functions. * trans-intrinsic.c (gfc_conv_intrinsic_function): Add case for GFC_ISYM_SIGNAL. * intrinsic.h: Add prototypes for gfc_check_alarm_sub, gfc_check_signal, gfc_check_signal_sub, gfc_resolve_signal, gfc_resolve_alarm_sub, gfc_resolve_signal_sub. * Makefile.am (intrinsics): Add signal.c. * Makefile.in: Regenerate. * configure.ac: Checks for signal and alarm. * config.h.in: Regenerate. * configure: Regenerate. * intrinsics/signal.c: New file for SIGNAL and ALARM intrinsics. From-SVN: r105967
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog11
-rw-r--r--libgfortran/Makefile.am1
-rw-r--r--libgfortran/Makefile.in19
-rw-r--r--libgfortran/config.h.in6
-rwxr-xr-xlibgfortran/configure4
-rw-r--r--libgfortran/configure.ac2
-rw-r--r--libgfortran/intrinsics/signal.c170
7 files changed, 203 insertions, 10 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 6d47929..6311d64 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,4 +1,13 @@
-2005-10-20 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+2005-10-28 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ * Makefile.am (intrinsics): Add signal.c.
+ * Makefile.in: Regenerate.
+ * configure.ac: Checks for signal and alarm.
+ * config.h.in: Regenerate.
+ * configure: Regenerate.
+ * intrinsics/signal.c: New file for SIGNAL and ALARM intrinsics.
+
+2005-10-28 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* acinclude.m4 (LIBGFOR_CHECK_FPSETMASK): New check.
* configure.ac: Check for floatingpoint.h, fptrap.h and float.h
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
index f5a1869..b47b768 100644
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -66,6 +66,7 @@ intrinsics/link.c \
intrinsics/mvbits.c \
intrinsics/pack_generic.c \
intrinsics/perror.c \
+intrinsics/signal.c \
intrinsics/size.c \
intrinsics/sleep.c \
intrinsics/spread_generic.c \
diff --git a/libgfortran/Makefile.in b/libgfortran/Makefile.in
index 5ed436f..256fe1d 100644
--- a/libgfortran/Makefile.in
+++ b/libgfortran/Makefile.in
@@ -169,13 +169,14 @@ am__objects_33 = associated.lo abort.lo args.lo bessel.lo \
date_and_time.lo env.lo erf.lo eoshift0.lo eoshift2.lo \
etime.lo exit.lo flush.lo fnum.lo gerror.lo getcwd.lo \
getlog.lo getXid.lo hyper.lo hostnm.lo kill.lo ierrno.lo \
- ishftc.lo link.lo mvbits.lo pack_generic.lo perror.lo size.lo \
- sleep.lo spread_generic.lo string_intrinsics.lo system.lo \
- rand.lo random.lo rename.lo reshape_generic.lo \
- reshape_packed.lo selected_int_kind.lo selected_real_kind.lo \
- stat.lo symlnk.lo system_clock.lo time.lo transpose_generic.lo \
- tty.lo umask.lo unlink.lo unpack_generic.lo in_pack_generic.lo \
- in_unpack_generic.lo normalize.lo
+ ishftc.lo link.lo mvbits.lo pack_generic.lo perror.lo \
+ signal.lo size.lo sleep.lo spread_generic.lo \
+ string_intrinsics.lo system.lo rand.lo random.lo rename.lo \
+ reshape_generic.lo reshape_packed.lo selected_int_kind.lo \
+ selected_real_kind.lo stat.lo symlnk.lo system_clock.lo \
+ time.lo transpose_generic.lo tty.lo umask.lo unlink.lo \
+ unpack_generic.lo in_pack_generic.lo in_unpack_generic.lo \
+ normalize.lo
am__objects_34 =
am__objects_35 = _abs_c4.lo _abs_c8.lo _abs_c10.lo _abs_c16.lo \
_abs_i4.lo _abs_i8.lo _abs_i16.lo _abs_r4.lo _abs_r8.lo \
@@ -406,6 +407,7 @@ intrinsics/link.c \
intrinsics/mvbits.c \
intrinsics/pack_generic.c \
intrinsics/perror.c \
+intrinsics/signal.c \
intrinsics/size.c \
intrinsics/sleep.c \
intrinsics/spread_generic.c \
@@ -2298,6 +2300,9 @@ pack_generic.lo: intrinsics/pack_generic.c
perror.lo: intrinsics/perror.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o perror.lo `test -f 'intrinsics/perror.c' || echo '$(srcdir)/'`intrinsics/perror.c
+signal.lo: intrinsics/signal.c
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o signal.lo `test -f 'intrinsics/signal.c' || echo '$(srcdir)/'`intrinsics/signal.c
+
size.lo: intrinsics/size.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o size.lo `test -f 'intrinsics/size.c' || echo '$(srcdir)/'`intrinsics/size.c
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index 13fc81f..6dc11a1 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -21,6 +21,9 @@
/* libm includes acosl */
#undef HAVE_ACOSL
+/* Define to 1 if you have the `alarm' function. */
+#undef HAVE_ALARM
+
/* libm includes asin */
#undef HAVE_ASIN
@@ -474,6 +477,9 @@
/* libm includes scalbnl */
#undef HAVE_SCALBNL
+/* Define to 1 if you have the `signal' function. */
+#undef HAVE_SIGNAL
+
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
diff --git a/libgfortran/configure b/libgfortran/configure
index fd7ee1f..b5bcafaf 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -7519,7 +7519,9 @@ done
-for ac_func in sleep time ttyname
+
+
+for ac_func in sleep time ttyname signal alarm
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index 73b34c0..1808455 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -169,7 +169,7 @@ AC_CHECK_MEMBERS([struct stat.st_rdev])
# Check for library functions.
AC_CHECK_FUNCS(getrusage times mkstemp strtof strtold snprintf ftruncate chsize)
AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
-AC_CHECK_FUNCS(sleep time ttyname)
+AC_CHECK_FUNCS(sleep time ttyname signal alarm)
# Check libc for getgid, getpid, getuid
AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])])
diff --git a/libgfortran/intrinsics/signal.c b/libgfortran/intrinsics/signal.c
new file mode 100644
index 0000000..9e40358
--- /dev/null
+++ b/libgfortran/intrinsics/signal.c
@@ -0,0 +1,170 @@
+/* Implementation of the SIGNAL and ALARM g77 intrinsics
+ Contributed by François-Xavier Coudert <coudert@clipper.ens.fr>
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file. (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with libgfortran; see the file COPYING. If not,
+write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+#include "config.h"
+#include "libgfortran.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#include <errno.h>
+
+/* SIGNAL subroutine with PROCEDURE as handler */
+extern void signal_sub (int *, void (*)(int), int *);
+iexport_proto(signal_sub);
+
+void
+signal_sub (int *number, void (*handler)(int), int *status)
+{
+#ifdef HAVE_SIGNAL
+ if (status != NULL)
+ *status = (int) signal (*number, handler);
+ else
+ signal (*number, handler);
+#else
+ errno = ENOSYS;
+ if (status != NULL)
+ *status = -1;
+#endif
+}
+iexport(signal_sub);
+
+
+/* SIGNAL subroutine with INTEGER as handler */
+extern void signal_sub_int (int *, int *, int *);
+iexport_proto(signal_sub_int);
+
+void
+signal_sub_int (int *number, int *handler, int *status)
+{
+#ifdef HAVE_SIGNAL
+ if (status != NULL)
+ *status = (int) signal (*number, (void (*)(int)) *handler);
+ else
+ signal (*number, (void (*)(int)) *handler);
+#else
+ errno = ENOSYS;
+ if (status != NULL)
+ *status = -1;
+#endif
+}
+iexport(signal_sub_int);
+
+
+/* SIGNAL function with PROCEDURE as handler */
+extern int signal_func (int *, void (*)(int));
+iexport_proto(signal_func);
+
+int
+signal_func (int *number, void (*handler)(int))
+{
+ int status;
+ signal_sub (number, handler, &status);
+ return status;
+}
+iexport(signal_func);
+
+
+/* SIGNAL function with INTEGER as handler */
+extern int signal_func_int (int *, int *);
+iexport_proto(signal_func_int);
+
+int
+signal_func_int (int *number, int *handler)
+{
+ int status;
+ signal_sub_int (number, handler, &status);
+ return status;
+}
+iexport(signal_func_int);
+
+
+
+/* ALARM intrinsic with PROCEDURE as handler */
+extern void alarm_sub (int *, void (*)(int), int *);
+iexport_proto(alarm_sub);
+
+void
+alarm_sub (int *seconds, void (*handler)(int), int *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);
+
+
+/* ALARM intrinsic with INTEGER as handler */
+extern void alarm_sub_int (int *, int *, int *);
+iexport_proto(alarm_sub_int);
+
+void
+alarm_sub_int (int *seconds, int *handler, int *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);
+