#ifndef SWIFT_TIME_TIME_H
#define SWIFT_TIME_TIME_H

#include <swift/stdlib.h>

#include <swift/time/api.h>

typedef struct swift_time_t swift_time_t;

struct swift_time_t {
	time_t s;
	long ns;
};

#define SWIFT_NS_MS(ns) ( (ns / 1000000))
#define SWIFT_MS_NS(ms) ( (ms * 1000000))
#define SWIFT_MIS_NS(ms) ( (ms * 1000))
#define SWIFT_NS_MIS(ms) ( (ms / 1000))
#define SWIFT_TIME(...) ((swift_time_t){__VA_ARGS__})

SWIFT_TIME_API swift_time_t swift_add_time(swift_time_t lhs,
	swift_time_t rhs);
SWIFT_TIME_API swift_time_t swift_sub_time(swift_time_t lhs,
	swift_time_t rhs);
SWIFT_TIME_API int swift_cmp_time(swift_time_t lhs,
	swift_time_t rhs);

SWIFT_TIME_API double swift_tick_count(void);
SWIFT_TIME_API bool swift_has_monotonic_time(void);
SWIFT_TIME_API swift_time_t swift_get_monotonic_res(void);
SWIFT_TIME_API swift_time_t swift_get_monotonic_time(void);
SWIFT_TIME_API swift_time_t swift_get_calendar_res(void);
SWIFT_TIME_API swift_time_t swift_get_calender_time(void);
SWIFT_TIME_API void swift_timed_wait(swift_time_t time);
#endif /* SWIFT_TIME_TIME_H */
