… | |
… | |
73 | apparently considered O.K., even if it breaks your programs). |
73 | apparently considered O.K., even if it breaks your programs). |
74 | |
74 | |
75 | =item much less memory |
75 | =item much less memory |
76 | |
76 | |
77 | Just using all those pragmas together waste <blink>I<< B<776> kilobytes |
77 | Just using all those pragmas together waste <blink>I<< B<776> kilobytes |
|
|
78 | |
78 | >></blink> of precious memory in my perl, for I<every single perl process |
79 | >></blink> of precious memory in my perl, for I<every single perl process |
|
|
80 | |
79 | using our code>, which on our machines, is a lot. |
81 | using our code>, which on our machines, is a lot. In comparison, this |
|
|
82 | module only uses I<< B<four> >> kilobytes (I even had to write it out so |
|
|
83 | it looks like more) of memory on the same platform. |
80 | |
84 | |
81 | The money/time/effort/electricity invested in these gigabytes (probably |
85 | The money/time/effort/electricity invested in these gigabytes (probably |
82 | petabytes globally!) of wasted memory could easily save 42 trees, and a |
86 | petabytes globally!) of wasted memory could easily save 42 trees, and a |
83 | kitten! |
87 | kitten! |
84 | |
88 | |
… | |
… | |
87 | package common::sense; |
91 | package common::sense; |
88 | |
92 | |
89 | our $VERSION = '0.03'; |
93 | our $VERSION = '0.03'; |
90 | |
94 | |
91 | sub import { |
95 | sub import { |
|
|
96 | # no warnings |
92 | ${^WARNING_BITS} ^= ${^WARNING_BITS}; |
97 | ${^WARNING_BITS} ^= ${^WARNING_BITS}; |
|
|
98 | |
|
|
99 | # use strict vars subs |
|
|
100 | $^H |= 0x00000600; |
|
|
101 | |
|
|
102 | # use feature |
|
|
103 | $^H{feature_switch} = |
|
|
104 | $^H{feature_say} = |
|
|
105 | $^H{feature_state} = 1; |
93 | } |
106 | } |
94 | |
107 | |
95 | =cut |
108 | =cut |
96 | |
109 | |
97 | 1; |
110 | 1; |
98 | |
111 | |
99 | =back |
112 | =back |
100 | |
113 | |
101 | =head1 EXAMPLE |
|
|
102 | |
|
|
103 | There really should be a complete C/XS example. Bug me about it. |
|
|
104 | |
|
|
105 | =head1 IMPLEMENTATION DETAILS AND LIMITATIONS |
|
|
106 | |
|
|
107 | This module works by "hijacking" SIGKILL, which is guaranteed to be always |
|
|
108 | available in perl, but also cannot be caught, so is always available. |
|
|
109 | |
|
|
110 | Basically, this module fakes the receive of a SIGKILL signal and |
|
|
111 | then catches it. This makes normal signal handling slower (probably |
|
|
112 | unmeasurably), but has the advantage of not requiring a special runops nor |
|
|
113 | slowing down normal perl execution a bit. |
|
|
114 | |
|
|
115 | It assumes that C<sig_atomic_t> and C<int> are both exception-safe to |
|
|
116 | modify (C<sig_atomic_> is used by this module, and perl itself uses |
|
|
117 | C<int>, so we can assume that this is quite portable, at least w.r.t. |
|
|
118 | signals). |
|
|
119 | |
|
|
120 | =head1 AUTHOR |
114 | =head1 AUTHOR |
121 | |
115 | |
122 | Marc Lehmann <schmorp@schmorp.de> |
116 | Marc Lehmann <schmorp@schmorp.de> |
123 | http://home.schmorp.de/ |
117 | http://home.schmorp.de/ |
124 | |
118 | |