ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/iom.C
(Generate patch)

Comparing gvpe/src/iom.C (file contents):
Revision 1.30 by pcg, Thu Mar 3 16:54:34 2005 UTC vs.
Revision 1.33 by pcg, Wed Jan 11 21:27:05 2006 UTC

14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with gvpe; if not, write to the Free Software 18 along with gvpe; if not, write to the Free Software
19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/ 20*/
21 21
22#include "iom.h" 22#include "iom.h"
23 23
24#include <cstdio> 24#include <cstdio>
42#endif 42#endif
43 43
44// if the BSDs would at least be marginally POSIX-compatible.. *sigh* 44// if the BSDs would at least be marginally POSIX-compatible.. *sigh*
45// until that happens, sys/select.h must come last 45// until that happens, sys/select.h must come last
46#include <sys/select.h> 46#include <sys/select.h>
47
48// TSTAMP_MAX must still fit into a positive struct timeval
49#define TSTAMP_MAX (double)(1UL<<31)
50 47
51#define TIMEVAL timeval 48#define TIMEVAL timeval
52#define TV_FRAC tv_usec 49#define TV_FRAC tv_usec
53#define TV_MULT 1000000L 50#define TV_MULT 1000000L
54 51
138 135
139 tw0.start (TSTAMP_MAX); 136 tw0.start (TSTAMP_MAX);
140#endif 137#endif
141 } 138 }
142 139
140 ~init ()
141 {
142 iom_valid = false;
143 }
144
143 static void required (); 145 static void required ();
144} init; 146} init;
145 147
146void 148void
147init::required () 149init::required ()
217 write (sigpipe[1], &ch, 1); 219 write (sigpipe[1], &ch, 1);
218} 220}
219 221
220void io_manager::reg (sig_watcher &w) 222void io_manager::reg (sig_watcher &w)
221{ 223{
224 init::required ();
225
222 assert (0 < w.signum); 226 assert (0 < w.signum);
223 227
224 sw.reserve (w.signum); 228 sw.reserve (w.signum);
225 229
226 while (sw.size () < w.signum) // pathetic 230 while (sw.size () < w.signum) // pathetic
251 io_manager::reg (w, *sv); 255 io_manager::reg (w, *sv);
252} 256}
253 257
254void io_manager::unreg (sig_watcher &w) 258void io_manager::unreg (sig_watcher &w)
255{ 259{
256 if (!w.active) 260 if (!w.active || !iom_valid)
257 return; 261 return;
258 262
259 assert (0 < w.signum && w.signum <= sw.size ()); 263 assert (0 < w.signum && w.signum <= sw.size ());
260 264
261 io_manager::unreg (w, *sw[w.signum - 1]); 265 io_manager::unreg (w, *sw[w.signum - 1]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines