From: Roderick Schertler Date: Wed, 8 Jan 1997 03:55:33 +0000 (-0500) Subject: Misc. doc patches missing in _20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b88f04ff2985d0899964b90ae56789d88f6b353e;p=p5sagit%2Fp5-mst-13.2.git 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> --- diff --git a/pod/perlsub.pod b/pod/perlsub.pod index bd3eb18..2d3e666 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 a049e9d..de9bd22 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. +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. + 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