Refactor clock functions to use WASI types (#2666)
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See https://github.com/bytecodealliance/wasm-micro-runtime/pull/2637#discussion_r1362202879 for details.
This commit is contained in:
@ -36,26 +36,6 @@ extern "C" {
|
||||
* 2. To build the app-mgr and app-framework, you must implement it
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get a resolution of the clock
|
||||
*
|
||||
* @param clock_id clock identifier
|
||||
* @param resolution output variable to store the clock resolution
|
||||
* @return BHT_OK if success; otherwise, BHT_ERROR
|
||||
*/
|
||||
int
|
||||
os_clock_res_get(bh_clock_id_t clock_id, uint64 *resolution);
|
||||
|
||||
/**
|
||||
* Get a current time of the clock
|
||||
*
|
||||
* @param clock_id clock identifier
|
||||
* @param time output variable to store the clock time
|
||||
* @return BHT_OK if success; otherwise, BHT_ERROR
|
||||
*/
|
||||
int
|
||||
os_clock_time_get(bh_clock_id_t clock_id, uint64 precision, uint64 *time);
|
||||
|
||||
/**
|
||||
* Creates a thread
|
||||
*
|
||||
|
||||
@ -37,13 +37,6 @@ extern "C" {
|
||||
#define BH_TIME_T_MAX LONG_MAX
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BH_CLOCK_ID_REALTIME,
|
||||
BH_CLOCK_ID_MONOTONIC,
|
||||
BH_CLOCK_ID_PROCESS_CPUTIME_ID,
|
||||
BH_CLOCK_ID_THREAD_CPUTIME_ID
|
||||
} bh_clock_id_t;
|
||||
|
||||
#if defined(_MSC_BUILD)
|
||||
#if defined(COMPILING_WASM_RUNTIME_API)
|
||||
__declspec(dllexport) void *BH_MALLOC(unsigned int size);
|
||||
|
||||
@ -1093,6 +1093,33 @@ os_is_handle_valid(os_file_handle *handle);
|
||||
char *
|
||||
os_realpath(const char *path, char *resolved_path);
|
||||
|
||||
/****************************************************
|
||||
* *
|
||||
* Clock functions *
|
||||
* *
|
||||
****************************************************/
|
||||
|
||||
/**
|
||||
* Get the resolution of the specified clock.
|
||||
*
|
||||
* @param clock_id clock identifier
|
||||
* @param resolution output variable to store the clock resolution
|
||||
*/
|
||||
__wasi_errno_t
|
||||
os_clock_res_get(__wasi_clockid_t clock_id, __wasi_timestamp_t *resolution);
|
||||
|
||||
/**
|
||||
* Get the current time of the specified clock.
|
||||
*
|
||||
* @param clock_id clock identifier
|
||||
* @param precision the maximum lag that the returned time value may have,
|
||||
* compared to its actual value.
|
||||
* @param time output variable to store the clock time
|
||||
*/
|
||||
__wasi_errno_t
|
||||
os_clock_time_get(__wasi_clockid_t clock_id, __wasi_timestamp_t precision,
|
||||
__wasi_timestamp_t *time);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user