mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-02 20:28:37 +08:00
platforms/posix: cleanup macos legacy
This commit is contained in:
@@ -5,10 +5,6 @@
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#if defined(__PX4_APPLE_LEGACY)
|
||||
#define clockid_t int
|
||||
#endif
|
||||
|
||||
#if defined(__PX4_POSIX) || defined(__PX4_QURT)
|
||||
__BEGIN_DECLS
|
||||
__EXPORT int px4_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
||||
|
||||
@@ -225,21 +225,6 @@ function(px4_os_add_flags)
|
||||
if(UNIX AND APPLE)
|
||||
add_definitions(-D__PX4_DARWIN)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
|
||||
message(FATAL_ERROR "PX4 Firmware requires XCode 8 or newer on Mac OS. Version installed on this system: ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND uname -v OUTPUT_VARIABLE DARWIN_VERSION)
|
||||
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
|
||||
# message(STATUS "PX4 Darwin Version: ${DARWIN_VERSION}")
|
||||
if (DARWIN_VERSION LESS 16)
|
||||
add_definitions(
|
||||
-DCLOCK_MONOTONIC=1
|
||||
-DCLOCK_REALTIME=0
|
||||
-D__PX4_APPLE_LEGACY
|
||||
)
|
||||
endif()
|
||||
|
||||
elseif(CYGWIN)
|
||||
add_definitions(
|
||||
-D__PX4_CYGWIN
|
||||
|
||||
@@ -95,31 +95,6 @@ static void hrt_unlock()
|
||||
px4_sem_post(&_hrt_lock);
|
||||
}
|
||||
|
||||
#if defined(__PX4_APPLE_LEGACY)
|
||||
#include <sys/time.h>
|
||||
|
||||
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
struct timeval now;
|
||||
int rv = gettimeofday(&now, nullptr);
|
||||
|
||||
if (rv) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
tp->tv_sec = now.tv_sec;
|
||||
tp->tv_nsec = now.tv_usec * 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int px4_clock_settime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
/* do nothing right now */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get absolute time.
|
||||
*/
|
||||
@@ -465,23 +440,15 @@ hrt_call_invoke()
|
||||
|
||||
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
if (clk_id == CLOCK_MONOTONIC) {
|
||||
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||
|
||||
if (clk_id == CLOCK_MONOTONIC) {
|
||||
abstime_to_ts(tp, lockstep_scheduler.get_absolute_time());
|
||||
return 0;
|
||||
#else // defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||
#if defined(__PX4_DARWIN)
|
||||
// We don't have CLOCK_MONOTONIC on macOS, so we just have to
|
||||
// resort back to CLOCK_REALTIME here.
|
||||
return system_clock_gettime(CLOCK_REALTIME, tp);
|
||||
#else // defined(__PX4_DARWIN)
|
||||
return system_clock_gettime(clk_id, tp);
|
||||
#endif // defined(__PX4_DARWIN)
|
||||
#endif // defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||
|
||||
} else {
|
||||
return system_clock_gettime(clk_id, tp);
|
||||
}
|
||||
|
||||
#endif // defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||
return system_clock_gettime(clk_id, tp);
|
||||
}
|
||||
|
||||
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
|
||||
|
||||
Reference in New Issue
Block a user