@@ -416,24 +416,24 @@ EXTERN volatile clock_t g_system_ticks;
416
416
****************************************************************************/
417
417
418
418
#define clock_timespec_subtract (ts1 , ts2 , ts3 ) \
419
- do \
419
+ do \
420
+ { \
421
+ time_t _sec = (ts1)->tv_sec - (ts2)->tv_sec; \
422
+ long _nsec = (ts1)->tv_nsec - (ts2)->tv_nsec; \
423
+ if (_nsec < 0) \
420
424
{ \
421
- time_t _sec = (ts1)->tv_sec - (ts2)->tv_sec; \
422
- long _nsec = (ts1)->tv_nsec - (ts2)->tv_nsec; \
423
- if (_nsec < 0) \
424
- { \
425
- _nsec += NSEC_PER_SEC; \
426
- _sec--; \
427
- } \
428
- if (_sec < 0) \
429
- { \
430
- _sec = 0; \
431
- _nsec = 0; \
432
- } \
433
- (ts3)->tv_sec = _sec; \
434
- (ts3)->tv_nsec = _nsec; \
435
- }\
436
- while (0)
425
+ _nsec += NSEC_PER_SEC; \
426
+ _sec--; \
427
+ } \
428
+ if ((int64_t)_sec < 0) \
429
+ { \
430
+ _sec = 0; \
431
+ _nsec = 0; \
432
+ } \
433
+ (ts3)->tv_sec = _sec; \
434
+ (ts3)->tv_nsec = _nsec; \
435
+ }\
436
+ while (0)
437
437
438
438
/****************************************************************************
439
439
* Name: clock_timespec_compare
@@ -446,9 +446,9 @@ EXTERN volatile clock_t g_system_ticks;
446
446
****************************************************************************/
447
447
448
448
#define clock_timespec_compare (ts1 , ts2 ) \
449
- (((ts1)->tv_sec < (ts2)->tv_sec) ? -1 : \
450
- ((ts1)->tv_sec > (ts2)->tv_sec) ? 1 : \
451
- (ts1)->tv_nsec - (ts2)->tv_nsec)
449
+ (((ts1)->tv_sec < (ts2)->tv_sec) ? -1 : \
450
+ ((ts1)->tv_sec > (ts2)->tv_sec) ? 1 : \
451
+ (ts1)->tv_nsec - (ts2)->tv_nsec)
452
452
453
453
/****************************************************************************
454
454
* Name: clock_abstime2ticks
0 commit comments