platforms: clean up various build/linking issues

This makes sure lockstep is only built for SITL builds and fixes the
existing builds.
This commit is contained in:
Julian Oes
2018-12-22 10:32:18 +01:00
parent 23264fe579
commit e41518a08b
10 changed files with 76 additions and 67 deletions
+1
View File
@@ -40,6 +40,7 @@
#pragma once
#include <px4_defines.h>
#include <px4_time.h>
#define GPS_INFO(...) PX4_INFO(__VA_ARGS__)
#define GPS_WARN(...) PX4_WARN(__VA_ARGS__)
+22 -11
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
* Copyright (C) 2012-2018 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -64,10 +64,12 @@
* still needs to be used, thus we remap system_exit to exit.
*/
#define system_exit exit
#ifdef __PX4_POSIX
#include <stdlib.h>
#if defined(__PX4_POSIX_SITL)
#include <stdlib.h>
#include <unistd.h>
#define system_usleep usleep
#pragma GCC poison usleep
#define system_sleep sleep
@@ -81,18 +83,13 @@
// We can't poison pthread_cond_timedwait because it seems to be used in the
// <string> include.
#ifdef __cplusplus
#include <cstdlib>
#endif
#pragma GCC poison exit
#endif
#ifdef __PX4_NUTTX
/* On NuttX we call clearenv() so we cannot use getenv() and others (see px4_task_spawn_cmd() in px4_nuttx_tasks.c).
* We need to include the headers declaring getenv() before the pragma, otherwise it will trigger a poison error.
*/
#include <stdlib.h>
#ifdef __cplusplus
#include <cstdlib>
#endif
@@ -102,11 +99,25 @@
#include <unistd.h>
#include <time.h>
#else // defined(__PX4_POSIX_SITL)
#define system_usleep usleep
#define system_sleep sleep
#define system_clock_gettime clock_gettime
#define system_clock_settime clock_settime
#define system_pthread_cond_timedwait pthread_cond_timedwait
#endif
#if defined(__PX4_NUTTX)
/* On NuttX we call clearenv() so we cannot use getenv() and others (see
* px4_task_spawn_cmd() in px4_nuttx_tasks.c).
* We need to include the headers declaring getenv() before the pragma,
* otherwise it will trigger a poison error. */
#include <stdlib.h>
#ifdef __cplusplus
#include <cstdlib>
#endif
#pragma GCC poison getenv setenv putenv
#endif /* __PX4_NUTTX */
#endif // defined(__PX4_NUTTX)
@@ -42,6 +42,7 @@
#include <px4_defines.h>
#include <px4_posix.h>
#include <px4_tasks.h>
#include <px4_time.h>
#include <stdint.h>
#include <signal.h>
#include <stdio.h>
+19 -7
View File
@@ -50,7 +50,7 @@
#define sem_setprotocol(s,p)
#endif
#if defined(__PX4_DARWIN) || defined(__PX4_CYGWIN) || defined(__PX4_POSIX)
#if (defined(__PX4_DARWIN) || defined(__PX4_CYGWIN) || defined(__PX4_POSIX)) && !defined(__PX4_QURT)
__BEGIN_DECLS
@@ -71,24 +71,36 @@ __EXPORT int px4_sem_destroy(px4_sem_t *s);
__END_DECLS
#else
//#elif defined(__PX4_QURT)
__BEGIN_DECLS
//typedef sem_t px4_sem_t;
//#define px4_sem_init sem_init
//#define px4_sem_setprotocol sem_setprotocol
//#define px4_sem_wait sem_wait
//#define px4_sem_trywait sem_trywait
//#define px4_sem_post sem_post
//#define px4_sem_getvalue sem_getvalue
//#define px4_sem_destroy sem_destroy
#else
typedef sem_t px4_sem_t;
__BEGIN_DECLS
#define px4_sem_init sem_init
#define px4_sem_setprotocol sem_setprotocol
#define px4_sem_setprotocol sem_setprotocol
#define px4_sem_wait sem_wait
#define px4_sem_trywait sem_trywait
#define px4_sem_trywait sem_trywait
#define px4_sem_post sem_post
#define px4_sem_getvalue sem_getvalue
#define px4_sem_destroy sem_destroy
#ifdef __PX4_QURT
#if defined(__PX4_QURT)
__EXPORT int px4_sem_timedwait(px4_sem_t *sem, const struct timespec *abstime);
#else
#define px4_sem_timedwait sem_timedwait
#define px4_sem_timedwait sem_timedwait
#endif
__END_DECLS
+4 -15
View File
@@ -1,5 +1,6 @@
#pragma once
#include <unistd.h>
#include <sys/types.h>
#include <time.h>
#include <pthread.h>
@@ -8,20 +9,7 @@
#define clockid_t unsigned
#endif
#if defined(__PX4_QURT)
#include <sys/timespec.h>
__BEGIN_DECLS
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_POSIX)
#if defined(__PX4_POSIX_SITL) || defined(__PX4_QURT)
__BEGIN_DECLS
__EXPORT int px4_clock_gettime(clockid_t clk_id, struct timespec *tp);
@@ -34,11 +22,12 @@ __EXPORT int px4_pthread_cond_timedwait(pthread_cond_t *cond,
const struct timespec *abstime);
__END_DECLS
#elif defined(__PX4_NUTTX)
#else
#define px4_clock_gettime system_clock_gettime
#define px4_clock_settime system_clock_settime
#define px4_usleep system_usleep
#define px4_sleep system_sleep
#define px4_pthread_cond_timedwait system_pthread_cond_timedwait
#endif