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:
zoraaver
2023-10-25 11:06:04 +01:00
committed by GitHub
parent 75208073c0
commit e7a62d2099
14 changed files with 188 additions and 228 deletions

View File

@ -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
*

View File

@ -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);

View File

@ -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