From: Tobias Burnus <tobias@codesourcery.com>
To: Harald Anlauf <anlauf@gmx.de>,
gcc-patches <gcc-patches@gcc.gnu.org>,
fortran <fortran@gcc.gnu.org>
Subject: [patch] fortran/intrinsic.texi: Improve SIGNAL intrinsic entry (was: [patch] fortran/intrinsic.texi: Add 'passed by value' to signal handler)
Date: Tue, 17 Oct 2023 09:47:38 +0200 [thread overview]
Message-ID: <33a8ad77-3ef6-47e2-a6ad-6b480d21c141@codesourcery.com> (raw)
In-Reply-To: <3f2d2471-dd94-4eb1-86b2-ae7ed439028b@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 849 bytes --]
Hi Harald,
On 16.10.23 20:31, Harald Anlauf wrote:
> Hi Tobias,
>
> Am 16.10.23 um 19:11 schrieb Tobias Burnus:
>> OK for mainline?
>
> I think the patch qualifies as obvious.
>
> While at it, you might consider removing the comment a few lines below
> the place you are changing,
>
> @c TODO: What should the interface of the handler be? Does it take
> arguments?
>
> and enhance the given example by e.g.:
Updated version attached – I will commit it later today, unless anyone
has follow-up suggestions before.
Thanks for the suggestions,
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Attachment #2: signal-doc-v2.diff --]
[-- Type: text/x-patch, Size: 2196 bytes --]
fortran/intrinsic.texi: Improve SIGNAL intrinsic entry
gcc/fortran/ChangeLog:
* intrinsic.texi (signal): Mention that the argument
passed to the signal handler procedure is passed by reference.
Extend example.
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 6c7ad03a02c..fe446fc8a9d 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -13168,10 +13168,10 @@ end program test_sign
@table @asis
@item @emph{Description}:
@code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
-@var{HANDLER} to be executed with a single integer argument when signal
-@var{NUMBER} occurs. If @var{HANDLER} is an integer, it can be used to
-turn off handling of signal @var{NUMBER} or revert to its default
-action. See @code{signal(2)}.
+@var{HANDLER} to be executed with a single integer argument passed by
+value when signal @var{NUMBER} occurs. If @var{HANDLER} is an integer,
+it can be used to turn off handling of signal @var{NUMBER} or revert to
+its default action. See @code{signal(2)}.
If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
is supplied, it is set to the value returned by @code{signal(2)}.
@@ -13197,19 +13197,25 @@ Subroutine, function
@item @var{STATUS} @tab (Optional) @var{STATUS} shall be a scalar
integer. It has @code{INTENT(OUT)}.
@end multitable
-@c TODO: What should the interface of the handler be? Does it take arguments?
@item @emph{Return value}:
The @code{SIGNAL} function returns the value returned by @code{signal(2)}.
@item @emph{Example}:
@smallexample
+module m_handler
+contains
+ ! POSIX.1-2017: void (*func)(int)
+ subroutine handler_print(signum) bind(C)
+ use iso_c_binding, only: c_int
+ integer(c_int), value :: signum
+ print *, 'handler_print invoked with signum =', signum
+ end subroutine
+end module
program test_signal
- intrinsic signal
- external handler_print
-
- call signal (12, handler_print)
- call signal (10, 1)
+ use m_handler
+ call signal (12, handler_print) ! 12 = SIGUSR3 (on some systems)
+ call signal (10, 1) ! 10 = SIGUSR1 and 1 = SIG_IGN (on some systems)
call sleep (30)
end program test_signal
next prev parent reply other threads:[~2023-10-17 7:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-16 17:11 [patch] fortran/intrinsic.texi: Add 'passed by value' to signal handler Tobias Burnus
2023-10-16 18:31 ` Harald Anlauf
2023-10-16 18:37 ` Steve Kargl
2023-10-17 7:47 ` Tobias Burnus [this message]
2023-10-17 17:02 ` [patch] fortran/intrinsic.texi: Improve SIGNAL intrinsic entry Harald Anlauf
2023-10-17 17:36 ` Tobias Burnus
2023-10-17 18:05 ` Harald Anlauf
2023-10-17 11:26 ` [patch] fortran/intrinsic.texi: Add 'passed by value' to signal handler Stanislav Maslovski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=33a8ad77-3ef6-47e2-a6ad-6b480d21c141@codesourcery.com \
--to=tobias@codesourcery.com \
--cc=anlauf@gmx.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).