@@ -38,8 +38,8 @@ Interrupt and signal handling for Cython
38
38
#if HAVE_SYS_TYPES_H
39
39
#include <sys/types.h>
40
40
#endif
41
- #if HAVE_SYS_TIME_H
42
- #include <sys/ time.h>
41
+ #if HAVE_TIME_H
42
+ #include <time.h>
43
43
#endif
44
44
#if HAVE_SYS_WAIT_H
45
45
#include <sys/wait.h>
@@ -71,7 +71,7 @@ static int PARI_SIGINT_pending = 0;
71
71
72
72
73
73
#if ENABLE_DEBUG_CYSIGNALS
74
- static struct timeval sigtime ; /* Time of signal */
74
+ static struct timespec sigtime ; /* Time of signal */
75
75
#endif
76
76
77
77
/* The cysigs object (there is a unique copy of this, shared by all
@@ -258,7 +258,7 @@ static void cysigs_interrupt_handler(int sig)
258
258
if (cysigs .debug_level >= 3 ) print_backtrace ();
259
259
/* Store time of this signal, unless there is already a
260
260
* pending signal. */
261
- if (!cysigs .interrupt_received ) gettimeofday ( & sigtime , NULL );
261
+ if (!cysigs .interrupt_received ) clock_gettime ( CLOCK_MONOTONIC , & sigtime );
262
262
}
263
263
#endif
264
264
@@ -310,7 +310,7 @@ static void cysigs_signal_handler(int sig)
310
310
print_stderr_long (sig );
311
311
print_stderr (" *** inside sig_on\n" );
312
312
if (cysigs .debug_level >= 3 ) print_backtrace ();
313
- gettimeofday ( & sigtime , NULL );
313
+ clock_gettime ( CLOCK_MONOTONIC , & sigtime );
314
314
}
315
315
#endif
316
316
@@ -420,10 +420,10 @@ static void setup_trampoline(void)
420
420
static void do_raise_exception (int sig )
421
421
{
422
422
#if ENABLE_DEBUG_CYSIGNALS
423
- struct timeval raisetime ;
423
+ struct timespec raisetime ;
424
424
if (cysigs .debug_level >= 2 ) {
425
- gettimeofday ( & raisetime , NULL );
426
- long delta_ms = (raisetime .tv_sec - sigtime .tv_sec )* 1000L + (( long ) raisetime .tv_usec - ( long ) sigtime .tv_usec )/ 1000 ;
425
+ clock_gettime ( CLOCK_MONOTONIC , & raisetime );
426
+ long delta_ms = (raisetime .tv_sec - sigtime .tv_sec )* 1000L + (raisetime .tv_nsec - sigtime .tv_nsec )/ 1000000L ;
427
427
PyGILState_STATE gilstate = PyGILState_Ensure ();
428
428
print_stderr ("do_raise_exception(sig=" );
429
429
print_stderr_long (sig );
0 commit comments