diff --git a/companion/src/eeprominterface.h b/companion/src/eeprominterface.h index 14a8793a1..30f81b58c 100644 --- a/companion/src/eeprominterface.h +++ b/companion/src/eeprominterface.h @@ -26,6 +26,7 @@ #include #include #include "constants.h" +#include "../../radio/src/definitions.h" #include "simulatorinterface.h" #define EESIZE_STOCK 2048 diff --git a/companion/src/simulation/simulatorinterface.h b/companion/src/simulation/simulatorinterface.h index 1f4adf883..9e57c4e70 100644 --- a/companion/src/simulation/simulatorinterface.h +++ b/companion/src/simulation/simulatorinterface.h @@ -24,12 +24,7 @@ #include #include -#if __GNUC__ - #define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) -#else - #include "../targets/windows/winbuild.h" -#endif - +// TODO can be removed? template t LIMIT(t mi, t x, t ma) { return std::min(std::max(mi, x), ma); } struct TxInputs diff --git a/companion/targets/windows/winbuild.h b/companion/targets/windows/winbuild.h deleted file mode 100644 index 64bdc89bb..000000000 --- a/companion/targets/windows/winbuild.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Author - Bertrand Songis - * - * Based on th9x -> http://code.google.com/p/th9x/ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef WINBUILD_H -#define WINBUILD_H - -#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) -#undef FORCEINLINE -#define FORCEINLINE inline -#define NOINLINE - -#define strcasecmp _stricmp -#define strncasecmp _tcsnicmp -#define snprintf _snprintf - -inline double round(double number) -{ - return number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5); -} - -#endif diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index 20ec3b0c7..0034a8e20 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -66,12 +66,6 @@ #define NOBACKUP(...) __VA_ARGS__ #endif -#if __GNUC__ - #define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) -#else - #define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) -#endif - #if defined(PCBTARANIS) || defined(PCBHORUS) typedef uint16_t source_t; #else diff --git a/radio/src/definitions.h b/radio/src/definitions.h index 9f95c2ded..47862da04 100644 --- a/radio/src/definitions.h +++ b/radio/src/definitions.h @@ -42,9 +42,24 @@ #endif #if defined(SIMU) || defined(CPUARM) || GCC_VERSION < 472 - typedef int32_t int24_t; +typedef int32_t int24_t; #else - typedef __int24 int24_t; +typedef __int24 int24_t; +#endif + +#if __GNUC__ +#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) +#else +#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) +#endif + +#if defined(WIN32) +#define FORCEINLINE inline +#define NOINLINE +#define round(x) floor(x+0.5) +#define strcasecmp _stricmp +#define strncasecmp _tcsnicmp +#define snprintf _snprintf #endif #endif // _DEFINITIONS_H_ diff --git a/radio/src/storage/eeprom_rlc.h b/radio/src/storage/eeprom_rlc.h index 58af375c7..c1b55d910 100644 --- a/radio/src/storage/eeprom_rlc.h +++ b/radio/src/storage/eeprom_rlc.h @@ -21,10 +21,7 @@ #ifndef _EEPROM_RLC_H_ #define _EEPROM_RLC_H_ -// TODO duplicated -#ifndef PACK -#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) -#endif +#include "definitions.h" #if defined(PCBTARANIS) #define blkid_t uint16_t diff --git a/radio/src/telemetry/frsky.h b/radio/src/telemetry/frsky.h index b2b74fd5f..86600b03c 100644 --- a/radio/src/telemetry/frsky.h +++ b/radio/src/telemetry/frsky.h @@ -21,6 +21,7 @@ #ifndef _FRSKY_H_ #define _FRSKY_H_ +#include "../definitions.h" #include "telemetry_holders.h" #define FRSKY_SPORT_BAUDRATE 57600 diff --git a/radio/src/thirdparty/Lua/src/lobject.h b/radio/src/thirdparty/Lua/src/lobject.h index 4a0375464..7e5c03ab4 100644 --- a/radio/src/thirdparty/Lua/src/lobject.h +++ b/radio/src/thirdparty/Lua/src/lobject.h @@ -8,13 +8,9 @@ #ifndef lobject_h #define lobject_h -#ifndef PACK -#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__)) -#endif - #include - +#include "definitions.h" #include "llimits.h" #include "lua.h"