summaryrefslogtreecommitdiffstats
path: root/gcc/f/intdoc.in
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/f/intdoc.in')
-rw-r--r--gcc/f/intdoc.in97
1 files changed, 90 insertions, 7 deletions
diff --git a/gcc/f/intdoc.in b/gcc/f/intdoc.in
index eabb2e7e4e6..80046b730c2 100644
--- a/gcc/f/intdoc.in
+++ b/gcc/f/intdoc.in
@@ -2190,12 +2190,13 @@ DEFDOC (SIGNAL_subr, "Muck with signal handling.", "\
If @var{@2@} is a an @code{EXTERNAL} routine, arranges for it to be
invoked with a single integer argument (of system-dependent length)
when signal @var{@1@} occurs.
-If @var{@1@} is an integer, it can be
-used to turn off handling of signal @var{@2@} or revert to its default
+If @var{@2@} is an integer, it can be
+used to turn off handling of signal @var{@1@} or revert to its default
action.
See @code{signal(2)}.
-Note that @var{@2@} will be called using C conventions, so its value in
+Note that @var{@2@} will be called using C conventions,
+so the value of its argument in Fortran terms
Fortran terms is obtained by applying @code{%LOC()} (or @var{LOC()}) to it.
The value returned by @code{signal(2)} is written to @var{@3@}, if
@@ -2205,24 +2206,106 @@ Otherwise the return value is ignored.
Some non-GNU implementations of Fortran provide this intrinsic as
only a function, not as a subroutine, or do not support the
(optional) @var{@3@} argument.
+
+@emph{Warning:} Use of the @code{libf2c} run-time library function
+@samp{signal_} directly
+(such as via @samp{EXTERNAL SIGNAL})
+requires use of the @code{%VAL()} construct
+to pass an @code{INTEGER} value
+(such as @samp{SIG_IGN} or @samp{SIG_DFL})
+for the @var{@2@} argument.
+
+However, while @samp{CALL SIGNAL(@var{signum}, %VAL(SIG_IGN))}
+works when @samp{SIGNAL} is treated as an external procedure
+(and resolves, at link time, to @code{libf2c}'s @samp{signal_} routine),
+this construct is not valid when @samp{SIGNAL} is recognized
+as the intrinsic of that name.
+
+Therefore, for maximum portability and reliability,
+code such references to the @samp{SIGNAL} facility as follows:
+
+@smallexample
+INTRINSIC SIGNAL
+@dots{}
+CALL SIGNAL(@var{signum}, SIG_IGN)
+@end smallexample
+
+@code{g77} will compile such a call correctly,
+while other compilers will generally either do so as well
+or reject the @samp{INTRINSIC SIGNAL} statement via a diagnostic,
+allowing you to take appropriate action.
")
DEFDOC (SIGNAL_func, "Muck with signal handling.", "\
If @var{@2@} is a an @code{EXTERNAL} routine, arranges for it to be
invoked with a single integer argument (of system-dependent length)
when signal @var{@1@} occurs.
-If @var{@1@} is an integer, it can be
-used to turn off handling of signal @var{@2@} or revert to its default
+If @var{@2@} is an integer, it can be
+used to turn off handling of signal @var{@1@} or revert to its default
action.
See @code{signal(2)}.
-Note that @var{@2@} will be called using C conventions, so its value in
-Fortran terms is obtained by applying @code{%LOC()} (or @var{LOC()}) to it.
+Note that @var{@2@} will be called using C conventions,
+so the value of its argument in Fortran terms
+is obtained by applying @code{%LOC()} (or @var{LOC()}) to it.
The value returned by @code{signal(2)} is returned.
Due to the side effects performed by this intrinsic, the function
form is not recommended.
+
+@emph{Warning:} If the returned value is stored in
+an @code{INTEGER(KIND=1)} (default @code{INTEGER}) argument,
+truncation of the original return value occurs on some systems
+(such as Alphas, which have 64-bit pointers but 32-bit default integers),
+with no warning issued by @code{g77} under normal circumstances.
+
+Therefore, the following code fragment might silently fail on
+some systems:
+
+@smallexample
+INTEGER RTN
+EXTERNAL MYHNDL
+RTN = SIGNAL(@var{signum}, MYHNDL)
+@dots{}
+! Restore original handler:
+RTN = SIGNAL(@var{signum}, RTN)
+@end smallexample
+
+The reason for the failure is that @samp{RTN} might not hold
+all the information on the original handler for the signal,
+thus restoring an invalid handler.
+This bug could manifest itself as a spurious run-time failure
+at an arbitrary point later during the program's execution,
+for example.
+
+@emph{Warning:} Use of the @code{libf2c} run-time library function
+@samp{signal_} directly
+(such as via @samp{EXTERNAL SIGNAL})
+requires use of the @code{%VAL()} construct
+to pass an @code{INTEGER} value
+(such as @samp{SIG_IGN} or @samp{SIG_DFL})
+for the @var{@2@} argument.
+
+However, while @samp{RTN = SIGNAL(@var{signum}, %VAL(SIG_IGN))}
+works when @samp{SIGNAL} is treated as an external procedure
+(and resolves, at link time, to @code{libf2c}'s @samp{signal_} routine),
+this construct is not valid when @samp{SIGNAL} is recognized
+as the intrinsic of that name.
+
+Therefore, for maximum portability and reliability,
+code such references to the @samp{SIGNAL} facility as follows:
+
+@smallexample
+INTRINSIC SIGNAL
+@dots{}
+RTN = SIGNAL(@var{signum}, SIG_IGN)
+@end smallexample
+
+@code{g77} will compile such a call correctly,
+while other compilers will generally either do so as well
+or reject the @samp{INTRINSIC SIGNAL} statement via a diagnostic,
+allowing you to take appropriate action.
")
DEFDOC (KILL_func, "Signal a process.", "\
OpenPOWER on IntegriCloud