Skip to content

Commit

Permalink
- Time(Linux): always use clock_gettime; cleanup cmake files to remov…
Browse files Browse the repository at this point in the history
…e checks for clock_gettime (mz-automation#162)
  • Loading branch information
mzillgith committed Jan 8, 2025
1 parent 39d6c09 commit 2058323
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 39 deletions.
1 change: 0 additions & 1 deletion lib60870-C/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ endmacro()

# feature checks
include(CheckLibraryExists)
check_library_exists(rt clock_gettime "time.h" CONFIG_SYSTEM_HAS_CLOCK_GETTIME)

# check if we are on a little or a big endian
include (TestBigEndian)
Expand Down
17 changes: 5 additions & 12 deletions lib60870-C/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,11 @@ GENERATE_EXPORT_HEADER(lib60870-shared
add_library (lib60870 STATIC ${library_SRCS})

IF(UNIX)
IF (CONFIG_SYSTEM_HAS_CLOCK_GETTIME)
target_link_libraries (lib60870
-lpthread
-lm
-lrt
)
ELSE ()
target_link_libraries (lib60870
-lpthread
-lm
)
ENDIF (CONFIG_SYSTEM_HAS_CLOCK_GETTIME)
target_link_libraries (lib60870
-lpthread
-lm
-lrt
)

configure_file(
${CMAKE_CURRENT_LIST_DIR}/lib60870.pc.in
Expand Down
15 changes: 4 additions & 11 deletions lib60870-C/src/hal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ set(LIBHAL_VERSION_PATCH "0")

# feature checks
include(CheckLibraryExists)
check_library_exists(rt clock_gettime "time.h" CONFIG_SYSTEM_HAS_CLOCK_GETTIME)

# check if we are on a little or a big endian
include (TestBigEndian)
Expand Down Expand Up @@ -189,16 +188,10 @@ SET_TARGET_PROPERTIES(hal-shared PROPERTIES
)

IF(UNIX)
IF (CONFIG_SYSTEM_HAS_CLOCK_GETTIME)
target_link_libraries (hal
-lpthread
-lrt
)
ELSE ()
target_link_libraries (hal
-lpthread
)
ENDIF (CONFIG_SYSTEM_HAS_CLOCK_GETTIME)
target_link_libraries (hal
-lpthread
-lrt
)
ENDIF(UNIX)

IF(CONFIG_USE_EXTERNAL_MBEDTLS_DYNLIB)
Expand Down
15 changes: 0 additions & 15 deletions lib60870-C/src/hal/time/unix/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@

#include "hal_time.h"
#include <time.h>

#ifdef CONFIG_SYSTEM_HAS_CLOCK_GETTIME
uint64_t
Hal_getTimeInMs()
{
struct timespec tp;

clock_gettime(CLOCK_REALTIME, &tp);

return ((uint64_t) tp.tv_sec) * 1000LL + (tp.tv_nsec / 1000000);
}
#else

#include <sys/time.h>

msSinceEpoch
Expand Down Expand Up @@ -92,5 +79,3 @@ Hal_getMonotonicTimeInNs()

return nsTime;
}

#endif

0 comments on commit 2058323

Please sign in to comment.