From 1ff41ebdc257b45c9f574d8d1f7ee6df4be79645 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Fri, 1 Sep 2023 13:10:54 +0900 Subject: [PATCH] Implement os_usleep for posix (#2517) --- .../platform/common/posix/posix_sleep.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 core/shared/platform/common/posix/posix_sleep.c diff --git a/core/shared/platform/common/posix/posix_sleep.c b/core/shared/platform/common/posix/posix_sleep.c new file mode 100644 index 000000000..fa0645037 --- /dev/null +++ b/core/shared/platform/common/posix/posix_sleep.c @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2023 Midokura Japan KK. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include + +#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; +}