From 501063963d97e9037609fe434ea6e0bb7010b70e Mon Sep 17 00:00:00 2001
From: Atsushi Watanabe <atsushi.w@ieee.org>
Date: Tue, 23 Apr 2024 21:39:29 +0900
Subject: [PATCH] Use nanosleep if available

---
 CMakeLists.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 16e2978..658944b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,6 +68,7 @@ include(CheckFunctionExists)
 check_function_exists(longjmp HAVE_LONGJMP)
 check_function_exists(siglongjmp HAVE_SIGLONGJMP)
 check_function_exists(clock_nanosleep HAVE_CLOCK_NANOSLEEP)
+check_function_exists(nanosleep HAVE_NANOSLEEP)
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.cmake
   ${CMAKE_CURRENT_BINARY_DIR}/include/config.h
@@ -120,6 +121,9 @@ if(CMAKE_VERSION VERSION_LESS "3.12")
   if(HAVE_CLOCK_NANOSLEEP)
     add_definitions(-DHAVE_CLOCK_NANOSLEEP)
   endif()
+  if(HAVE_NANOSLEEP)
+    add_definitions(-DHAVE_NANOSLEEP)
+  endif()
   if(HAVE_SSM)
     add_definitions(-DHAVE_SSM)
   endif()
@@ -133,6 +137,9 @@ else()
   if(HAVE_CLOCK_NANOSLEEP)
     add_compile_definitions(HAVE_CLOCK_NANOSLEEP)
   endif()
+  if(HAVE_NANOSLEEP)
+    add_compile_definitions(HAVE_NANOSLEEP)
+  endif()
   if(HAVE_SSM)
     add_compile_definitions(HAVE_SSM)
   endif()