summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoderick Schertler <roderick@gate.net>1997-01-07 22:55:33 -0500
committerChip Salzenberg <chip@atlantic.net>1997-01-16 07:24:00 +1200
commitb88f04ff2985d0899964b90ae56789d88f6b353e (patch)
tree9bdb498833134c45a8ead2987c13d4b1cbc93c86
parentb2a07c1c241ec86f010fc0ea3bfa54c8ec28be90 (diff)
downloadperl-b88f04ff2985d0899964b90ae56789d88f6b353e.tar.gz
Misc. doc patches missing in _20
Subject: doc patches missing in _20 Here are a couple of the doc patches I sent to the list which didn't get into _20. The first looks like an oversight (a related hunk got in), but perhaps the second was left out intentionally, in anticipation of changes in signal restart handling? These are re-diffed against _20. p5p-msgid: <102.852695733@eeyore.ibcinc.com>
-rw-r--r--pod/perlsub.pod26
-rw-r--r--pod/perlvar.pod16
2 files changed, 42 insertions, 0 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod
index bd3eb18154..2d3e666256 100644
--- a/pod/perlsub.pod
+++ b/pod/perlsub.pod
@@ -754,6 +754,32 @@ starts scribbling on your @_ parameter list.
This is all very powerful, of course, and should be used only in moderation
to make the world a better place.
+=head2 Constant Functions
+
+Functions with a prototype of C<()> are potential candidates for
+inlining. If the result after optimization and constant folding is a
+constant then it will be used in place of calls to the function.
+
+All of the following functions would be inlined.
+
+ sub PI () { 3.14159 }
+ sub ST_DEV () { 0 }
+ sub ST_INO () { 1 }
+
+ sub FLAG_FOO () { 1 << 8 }
+ sub FLAG_BAR () { 1 << 9 }
+ sub FLAG_MASK () { FLAG_FOO | FLAG_BAR }
+
+ sub OPT_BAZ () { 1 }
+ sub BAZ_VAL () {
+ if (OPT_BAZ) {
+ return 23;
+ }
+ else {
+ return 42;
+ }
+ }
+
If you redefine a subroutine which was eligible for inlining you'll get
a mandatory warning. (You can use this warning to tell whether or not a
particular subroutine is considered constant.) The warning is
diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index a049e9d5a1..de9bd22348 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -698,6 +698,22 @@ sometimes it's a string representing the function, and sometimes it's
going to call the subroutine call right then and there! Best to be sure
and quote it or take a reference to it. *Plumber works too. See L<perlsub>.
+If your system has the sigaction() function then signal handlers are
+installed using it. This means you get reliable signal handling. If
+your system has the SA_RESTART flag it is used when signals handlers are
+installed. This means that system calls for which it is supported
+continue rather than returning when a signal arrives. If you want your
+system calls to be interrupted by signal delivery then do something like
+this:
+
+ use POSIX ':signal_h';
+
+ my $alarm = 0;
+ sigaction SIGALRM, new POSIX::SigAction sub { $alarm = 1 }
+ or die "Error setting SIGALRM handler: $!\n";
+
+See L<POSIX>.
+
Certain internal hooks can be also set using the %SIG hash. The
routine indicated by C<$SIG{__WARN__}> is called when a warning message is
about to be printed. The warning message is passed as the first