mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 01:53:34 +08:00
Cygwin: Enable build of SITL jMAVsim under Windows using the Cygwin Unix-like environment
Most of the incompatitbilities are luckily similar to the darwin build. - New target OS __PX4_CYGWIN added because in other build environments on Windows defines will very likely be completely different - added all necessary exeptions to the defines - disabled priorities completely because on Windows they are defined 1-32 and with all the arbitrary +40 -40 priority settings there were a lot of problems not only did some threads/"virtual tasks" not start because of out of bound priorities but also the resulting scheduling was totally random and inadequate with default priorities it ran toally fine during my first tests, should be rethought when windows is used onboard in the future
This commit is contained in:
committed by
Daniel Agar
parent
02c4ec9b2a
commit
70de169f15
@@ -1,7 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <px4_log.h>
|
||||
#ifdef __PX4_POSIX
|
||||
#if defined(__PX4_POSIX) && !defined(__PX4_CYGWIN)
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
#include <uORB/uORB.h>
|
||||
@@ -34,7 +34,7 @@ void px4_log_initialize(void)
|
||||
|
||||
void px4_backtrace()
|
||||
{
|
||||
#ifdef __PX4_POSIX
|
||||
#if defined(__PX4_POSIX) && !defined(__PX4_CYGWIN)
|
||||
void *buffer[10];
|
||||
char **callstack;
|
||||
int bt_size;
|
||||
|
||||
@@ -212,6 +212,11 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
||||
return (rv < 0) ? rv : -rv;
|
||||
}
|
||||
|
||||
#ifdef __PX4_CYGWIN
|
||||
/* Priorities on Windows are defined a lot differently */
|
||||
priority = SCHED_PRIORITY_DEFAULT;
|
||||
#endif
|
||||
|
||||
param.sched_priority = priority;
|
||||
|
||||
rv = pthread_attr_setschedparam(&attr, ¶m);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __PX4_DARWIN
|
||||
#if defined(__PX4_DARWIN) || defined(__PX4_CYGWIN)
|
||||
|
||||
#include <px4_posix.h>
|
||||
|
||||
|
||||
@@ -152,7 +152,9 @@ using ::isfinite;
|
||||
****************************************************************************/
|
||||
|
||||
// Flag is meaningless on Linux
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
// mode for open with O_CREAT
|
||||
#define PX4_O_MODE_777 (S_IRWXU | S_IRWXG | S_IRWXO)
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#define sem_setprotocol(s,p)
|
||||
#endif
|
||||
|
||||
#ifdef __PX4_DARWIN
|
||||
#if defined(__PX4_DARWIN) || defined(__PX4_CYGWIN)
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
||||
@@ -69,11 +69,7 @@ typedef int px4_task_t;
|
||||
|
||||
/** Default scheduler type */
|
||||
#define SCHED_DEFAULT SCHED_FIFO
|
||||
#ifdef __PX4_LINUX
|
||||
#define SCHED_PRIORITY_MAX sched_get_priority_max(SCHED_FIFO)
|
||||
#define SCHED_PRIORITY_MIN sched_get_priority_min(SCHED_FIFO)
|
||||
#define SCHED_PRIORITY_DEFAULT (((sched_get_priority_max(SCHED_FIFO) - sched_get_priority_min(SCHED_FIFO)) / 2) + sched_get_priority_min(SCHED_FIFO))
|
||||
#elif defined(__PX4_DARWIN)
|
||||
#if defined(__PX4_LINUX) || defined(__PX4_DARWIN) || defined(__PX4_CYGWIN)
|
||||
#define SCHED_PRIORITY_MAX sched_get_priority_max(SCHED_FIFO)
|
||||
#define SCHED_PRIORITY_MIN sched_get_priority_min(SCHED_FIFO)
|
||||
#define SCHED_PRIORITY_DEFAULT (((sched_get_priority_max(SCHED_FIFO) - sched_get_priority_min(SCHED_FIFO)) / 2) + sched_get_priority_min(SCHED_FIFO))
|
||||
|
||||
@@ -16,7 +16,7 @@ __EXPORT unsigned int sleep(unsigned int sec);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#elif defined(__PX4_LINUX) || defined(__PX4_NUTTX) || defined(__PX4_DARWIN)
|
||||
#elif defined(__PX4_LINUX) || defined(__PX4_NUTTX) || defined(__PX4_DARWIN) || defined(__PX4_CYGWIN)
|
||||
|
||||
#define px4_clock_gettime clock_gettime
|
||||
#define px4_clock_settime clock_settime
|
||||
|
||||
Reference in New Issue
Block a user