summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorFlávio Cruz <flaviocruz@gmail.com>2015-09-19 15:09:20 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2015-09-19 15:09:20 +0200
commitafcbeb533b58affc8c063376056cef21449afcec (patch)
treea336e22dc65b89ae75ca0cc76985dec405444cfd /include
parent81747ac6d3e846d1955edaa94dee9065e541b7d8 (diff)
Add macros to convert between time_value_t and timespec
* include/mach/time_value.h (TIME_VALUE_TO_TIMESPEC, TIMESPEC_TO_TIME_VALUE): New macros
Diffstat (limited to 'include')
-rw-r--r--include/mach/time_value.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/mach/time_value.h b/include/mach/time_value.h
index 0dfe382c..3a9c384c 100644
--- a/include/mach/time_value.h
+++ b/include/mach/time_value.h
@@ -96,4 +96,16 @@ typedef struct mapped_time_value {
integer_t check_seconds;
} mapped_time_value_t;
+/* Macros for converting between struct timespec and time_value_t. */
+
+#define TIME_VALUE_TO_TIMESPEC(tv, ts) do { \
+ (ts)->tv_sec = (tv)->seconds; \
+ (ts)->tv_nsec = (tv)->microseconds * 1000; \
+} while(0)
+
+#define TIMESPEC_TO_TIME_VALUE(tv, ts) do { \
+ (tv)->seconds = (ts)->tv_sec; \
+ (tv)->microseconds = (ts)->tv_nsec / 1000; \
+} while(0)
+
#endif /* _MACH_TIME_VALUE_H_ */