mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-11 17:35:13 +00:00
Implement os_usleep for posix (#2517)
This commit is contained in:
parent
382d52fc05
commit
1ff41ebdc2
20
core/shared/platform/common/posix/posix_sleep.c
Normal file
20
core/shared/platform/common/posix/posix_sleep.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright (C) 2023 Midokura Japan KK. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "platform_api_extension.h"
|
||||
|
||||
int
|
||||
os_usleep(uint32 usec)
|
||||
{
|
||||
struct timespec ts;
|
||||
int ret;
|
||||
|
||||
ts.tv_sec = usec / 1000000;
|
||||
ts.tv_nsec = (usec % 1000000) * 1000;
|
||||
ret = nanosleep(&ts, NULL);
|
||||
return ret == 0 ? 0 : -1;
|
||||
}
|
Loading…
Reference in New Issue
Block a user