skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

alarm_disable.c (720B)


      1 /* ISC license. */
      2 
      3 #include <skalibs/sysdeps.h>
      4 #include <skalibs/alarm.h>
      5 
      6 #ifdef SKALIBS_HASTIMER
      7 
      8 #include <time.h>
      9 #include "alarm-internal.h"
     10 
     11 timer_t timer_here ;
     12 
     13 void alarm_disable ()
     14 {
     15   struct itimerspec stopit = { .it_value = { .tv_sec = 0, .tv_nsec = 0 }, .it_interval = { .tv_sec = 0, .tv_nsec = 0 } } ;
     16   timer_settime(timer_here, 0, &stopit, 0) ;
     17   timer_delete(timer_here) ;
     18 }
     19 
     20 #else
     21 #ifdef SKALIBS_HASITIMER
     22 
     23 #include <sys/time.h>
     24 
     25 void alarm_disable ()
     26 {
     27   struct itimerval stopit = { .it_value = { .tv_sec = 0, .tv_usec = 0 }, .it_interval = { .tv_sec = 0, .tv_usec = 0 } } ;
     28   setitimer(ITIMER_REAL, &stopit, 0) ;
     29 }
     30 
     31 #else
     32 
     33 #include <unistd.h>
     34 
     35 void alarm_disable ()
     36 {
     37   alarm(0) ;
     38 }
     39 
     40 #endif
     41 #endif