# HG changeset patch # User John "Elwin" Edwards # Date 1453508388 18000 # Node ID 12e070d1a7806796a4472bbc849c0e2ae23fee8f # Parent 382ff498acdd28042d04bb8b5acae27d422807c1 rogue3: replace alarm() calls with a portable function. Calls to alarm() in main.c are replaced with md_start_checkout_timer(), so the #ifdefs around nonportable code can be confined to mdport.c. diff -r 382ff498acdd -r 12e070d1a780 rogue3/main.c --- a/rogue3/main.c Thu Jan 21 21:10:23 2016 -0500 +++ b/rogue3/main.c Fri Jan 22 19:19:48 2016 -0500 @@ -374,10 +374,7 @@ if (!author()) { -#ifdef SIGALRM - signal(SIGALRM, checkout); - alarm(CHECKTIME * 60); -#endif + md_start_checkout_timer(CHECKTIME * 60); num_checks = 0; } @@ -464,9 +461,6 @@ "Last warning. You have %d minutes to leave", }; int checktime; -#ifdef SIGALRM - signal(SIGALRM, checkout); -#endif if (too_much()) { if (num_checks >= 3) @@ -474,9 +468,7 @@ checktime = CHECKTIME / (num_checks + 1); if (num_checks < 3) chmsg(msgs[num_checks++], checktime); -#ifdef SIGALRM - alarm(checktime * 60); -#endif + md_start_checkout_timer(checktime * 60); } else { @@ -485,9 +477,7 @@ chmsg("The load has dropped back down. You have a reprieve."); num_checks = 0; } -#ifdef SIGALRM - alarm(CHECKTIME * 60); -#endif + md_start_checkout_timer(CHECKTIME * 60); } } diff -r 382ff498acdd -r 12e070d1a780 rogue3/mdport.c --- a/rogue3/mdport.c Thu Jan 21 21:10:23 2016 -0500 +++ b/rogue3/mdport.c Fri Jan 22 19:19:48 2016 -0500 @@ -1510,11 +1510,10 @@ #endif } -#if defined(CHECKTIME) void md_start_checkout_timer(int time) { - int checkout(); + void checkout(); #if defined(HAVE_ALARM) && defined(SIGALRM) signal(SIGALRM, checkout); @@ -1529,7 +1528,6 @@ signal(SIGALRM, SIG_IGN); #endif } -#endif long md_memused() diff -r 382ff498acdd -r 12e070d1a780 rogue3/mdport.h --- a/rogue3/mdport.h Thu Jan 21 21:10:23 2016 -0500 +++ b/rogue3/mdport.h Fri Jan 22 19:19:48 2016 -0500 @@ -187,6 +187,8 @@ void md_onsignal_default(void); int md_issymlink(char *sp); int md_loadav(double *avg); +void md_start_checkout_timer(int time); +void md_stop_checkout_timer(void); long md_memused(void); int md_ucount(void); int md_unlockfile(FILE *fp);