forked from Archive/PX4-Autopilot
Support 10.11 and 10.12 in parallel in PX4
This commit is contained in:
parent
f49eabdb9d
commit
af8cbee6d5
|
@ -200,6 +200,16 @@ if(UNIX AND APPLE)
|
|||
message(FATAL_ERROR "PX4 Firmware requires XCode 8 or newer on Mac OS. Version installed on this system: ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
|
||||
EXEC_PROGRAM(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
|
||||
STRING(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
|
||||
message(STATUS "DARWIN_VERSION: ${DARWIN_VERSION}")
|
||||
if (DARWIN_VERSION LESS 16)
|
||||
list(APPEND added_definitions
|
||||
-DCLOCK_MONOTONIC=1
|
||||
-D__PX4_APPLE_LEGACY
|
||||
)
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
set(added_definitions
|
||||
|
|
|
@ -93,7 +93,32 @@ static void hrt_unlock(void)
|
|||
px4_sem_post(&_hrt_lock);
|
||||
}
|
||||
|
||||
#if defined(__QURT)
|
||||
#if defined(__PX4_APPLE_LEGACY)
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
struct timeval now;
|
||||
int rv = gettimeofday(&now, NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#elif defined(__QURT)
|
||||
|
||||
#include "dspal_time.h"
|
||||
|
||||
|
|
|
@ -3,7 +3,20 @@
|
|||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#if defined(__PX4_LINUX) || defined(__PX4_NUTTX) || defined(__PX4_DARWIN)
|
||||
#if defined(__PX4_APPLE_LEGACY)
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define clockid_t unsigned
|
||||
|
||||
int px4_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
||||
int px4_clock_settime(clockid_t clk_id, struct timespec *tp);
|
||||
|
||||
__EXPORT unsigned int sleep(unsigned int sec);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#elif defined(__PX4_LINUX) || defined(__PX4_NUTTX) || defined(__PX4_DARWIN)
|
||||
|
||||
#define px4_clock_gettime clock_gettime
|
||||
#define px4_clock_settime clock_settime
|
||||
|
|
Loading…
Reference in New Issue