]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
include/arch: Make time constants signed
authorAndrei Tatar <andrei@unikraft.io>
Tue, 7 Nov 2023 13:59:41 +0000 (14:59 +0100)
committerSimon Kuenzer <simon@unikraft.io>
Tue, 28 Nov 2023 00:17:49 +0000 (01:17 +0100)
This change removes the unsigned marker on integer literals that define
time-related constants, as there is no logical reason for time to always
be positive. This also alleviates mixed-signedness warnings when doing
arithmetic on time values, as well as assigning to __snsec.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1157

include/uk/arch/time.h

index e815e790f4acbeb3b4b0999adfd163e205de5f6c..dd79ff8d8e1eddadec239e265ed5e66ed7bb2bd2 100644 (file)
@@ -55,15 +55,15 @@ typedef __s64 __snsec;
 #define __SNSEC_MAX (__S64_MAX)
 #define __SNSEC_MIN (__S64_MIN)
 
-#define UKARCH_NSEC_PER_SEC ((__nsec)1000000000ULL)
+#define UKARCH_NSEC_PER_SEC ((__snsec)1000000000LL)
 
 #define ukarch_time_nsec_to_sec(ns)      ((ns) / UKARCH_NSEC_PER_SEC)
-#define ukarch_time_nsec_to_msec(ns)     ((ns) / 1000000UL)
-#define ukarch_time_nsec_to_usec(ns)     ((ns) / 1000UL)
-#define ukarch_time_subsec(ns)           ((ns) % ((__nsec)1000000000ULL))
+#define ukarch_time_nsec_to_msec(ns)     ((ns) / 1000000L)
+#define ukarch_time_nsec_to_usec(ns)     ((ns) / 1000L)
+#define ukarch_time_subsec(ns)           ((ns) % UKARCH_NSEC_PER_SEC)
 
 #define ukarch_time_sec_to_nsec(sec)     ((sec)  * UKARCH_NSEC_PER_SEC)
-#define ukarch_time_msec_to_nsec(msec)   ((msec) * 1000000UL)
-#define ukarch_time_usec_to_nsec(usec)   ((usec) * 1000UL)
+#define ukarch_time_msec_to_nsec(msec)   ((msec) * 1000000L)
+#define ukarch_time_usec_to_nsec(usec)   ((usec) * 1000L)
 
 #endif /* __UKARCH_TIME_H__ */