diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-06-22 07:28:29 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-06-22 07:28:29 +0200 |
commit | 442fd797087834cb691cf18f4a808eee6d740353 (patch) | |
tree | 108f354f498c3f7272095d58dc5b03d861ef83f0 | |
parent | 0ebf074be440dc5ba30802fdccfc786c6d4acbd7 (diff) |
misc irrelevant
-rw-r--r-- | cmake/mingw-w64.cmake | 3 | ||||
-rw-r--r-- | coverity/build.sh | 12 | ||||
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 2 | ||||
-rw-r--r-- | freetrackclient/fttypes.h | 6 | ||||
-rw-r--r-- | options/bundle.hpp | 10 | ||||
-rw-r--r-- | options/group.hpp | 4 | ||||
-rw-r--r-- | options/value.hpp | 22 | ||||
-rw-r--r-- | proto-ft/ftnoir_protocol_ft.cpp | 43 | ||||
-rw-r--r-- | tracker-hatire/ftnoir_tracker_hat.h | 6 | ||||
-rw-r--r-- | tracker-steamvr/steamvr.hpp | 2 | ||||
-rw-r--r-- | x-plane-plugin/plugin.c | 20 |
11 files changed, 73 insertions, 57 deletions
diff --git a/cmake/mingw-w64.cmake b/cmake/mingw-w64.cmake index 83501cdc..38567d54 100644 --- a/cmake/mingw-w64.cmake +++ b/cmake/mingw-w64.cmake @@ -16,7 +16,8 @@ unset(c) unset(e) # specify the cross compiler if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - set(p D:/cygwin64/opt/bin/) + #set(p D:/cygwin64/opt/bin/) + set(p "C:/msys64/mingw32/bin/") set(e .exe) endif() #set(c ${p}i686-w64-mingw32-) diff --git a/coverity/build.sh b/coverity/build.sh index 02cd5cad..3d662f8b 100644 --- a/coverity/build.sh +++ b/coverity/build.sh @@ -1,13 +1,13 @@ #!/bin/sh -function cleanup() { +cleanup() { for i in cov-build ninja; do taskkill -f -t -im "$i.exe" 2>/dev/null 1>&2 done rm -f "$myfile" } -function signal() { +signal() { set +e trap '' EXIT echo "error: $1" 1>&2 @@ -15,7 +15,7 @@ function signal() { exit 1 } -export PATH="/d/dev/cov-analysis-win64-8.7.0/bin:/c/msys64/bin:/c/msys64/mingw32/bin:/usr/bin:$PATH" +export PATH="/d/dev/cov-analysis-win64-8.7.0/bin:/c/msys64/mingw32/bin:/c/msys64/usr/bin:$PATH" for k in HUP INT QUIT ILL BUS FPE SEGV PIPE; do trap "signal 'got fatal signal SIG'$k" SIG"$k" @@ -27,7 +27,7 @@ set -e mydate="$(date --iso-8601=minutes)" mydir="$(dirname -- "$0")" -myfile="$mydir/opentrack-"$mydate".7z" +myfile="opentrack-"$mydate".7z" cd "$mydir" for k in opencv aruco libovr-025 libovr-042 libovr-080; do @@ -39,7 +39,7 @@ cd "./opentrack" cmake . ninja32 clean cov-build --dir cov-int ninja -rm -f "$myfile" || true -7za -mx a "$myfile" cov-int +rm -f "../$myfile" || true +7za -mx a "../$myfile" cov-int trap '' EXIT exit 0 diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 38c32392..a4095774 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -32,7 +32,7 @@ static inline constexpr T signum(T x) } template<int N = 3, typename F> -OTR_NEVER_INLINE +never_inline static void do_deltas(const double* deltas, double* output, double alpha, double& smoothed, F&& fun) { double norm[N]; diff --git a/freetrackclient/fttypes.h b/freetrackclient/fttypes.h index 4989a570..033d183e 100644 --- a/freetrackclient/fttypes.h +++ b/freetrackclient/fttypes.h @@ -59,6 +59,10 @@ typedef struct FTData__ { typedef struct FTHeap__ { FTData data; int32_t GameID; - unsigned char table[8]; + union + { + unsigned char table[8]; + int32_t table_ints[2]; + }; int32_t GameID2; } FTHeap; diff --git a/options/bundle.hpp b/options/bundle.hpp index 00f2aed6..b6189ba6 100644 --- a/options/bundle.hpp +++ b/options/bundle.hpp @@ -64,12 +64,12 @@ signals: void saving() const; void changed() const; public: - OTR_NEVER_INLINE bundle(const QString& group_name); - OTR_NEVER_INLINE ~bundle() override; + never_inline bundle(const QString& group_name); + never_inline ~bundle() override; QString name() const { return group_name; } - OTR_NEVER_INLINE void store_kv(const QString& name, const QVariant& datum); - OTR_NEVER_INLINE bool contains(const QString& name) const; - OTR_NEVER_INLINE bool is_modified() const; + never_inline void store_kv(const QString& name, const QVariant& datum); + never_inline bool contains(const QString& name) const; + never_inline bool is_modified() const; template<typename t> t get(const QString& name) const diff --git a/options/group.hpp b/options/group.hpp index b0e13a6a..dd070dfd 100644 --- a/options/group.hpp +++ b/options/group.hpp @@ -50,7 +50,7 @@ public: static void mark_ini_modified(); template<typename t> - OTR_NEVER_INLINE + never_inline t get(const QString& k) const { auto value = kvs.find(k); @@ -60,7 +60,7 @@ public: } template<typename F> - OTR_NEVER_INLINE + never_inline static auto with_settings_object(F&& fun) { saver_ saver { *cur_settings_object(), cur_ini_mtx }; diff --git a/options/value.hpp b/options/value.hpp index ebb2096c..ba482cf7 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -48,7 +48,7 @@ class value final : public base_value return val1.value<element_type>() == val2.value<element_type>(); } - OTR_NEVER_INLINE + never_inline t get() const { if (!b->contains(self_name) || b->get<QVariant>(self_name).type() == QVariant::Invalid) @@ -60,7 +60,7 @@ class value final : public base_value } public: - OTR_NEVER_INLINE + never_inline t operator=(const t& datum) { if (datum != get()) @@ -71,7 +71,7 @@ public: static constexpr const Qt::ConnectionType DIRECT_CONNTYPE = Qt::DirectConnection; static constexpr const Qt::ConnectionType SAFE_CONNTYPE = Qt::QueuedConnection; - OTR_NEVER_INLINE + never_inline value(bundle b, const QString& name, t def) : base_value(b, name, &is_equal, std::type_index(typeid(element_type))), def(def) @@ -81,46 +81,46 @@ public: DIRECT_CONNTYPE); } - OTR_NEVER_INLINE + never_inline value(bundle b, const char* name, t def) : value(b, QString(name), def) { } - OTR_NEVER_INLINE + never_inline t default_value() const { return def; } - OTR_NEVER_INLINE + never_inline void set_to_default() override { *this = def; } - OTR_NEVER_INLINE + never_inline operator t() const { return std::forward<t>(get()); } - OTR_NEVER_INLINE + never_inline void reload() override { *this = static_cast<t>(*this); } - OTR_NEVER_INLINE + never_inline void bundle_value_changed() const override { emit valueChanged(traits::to_storage(get())); } - OTR_NEVER_INLINE + never_inline t operator()() const { return get(); } template<typename u> - OTR_NEVER_INLINE + never_inline u to() const { return static_cast<u>(std::forward<t>(get())); diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp index 16a8fbe1..8e5996d8 100644 --- a/proto-ft/ftnoir_protocol_ft.cpp +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -7,7 +7,6 @@ */ #include "compat/ndebug-guard.hpp" -#include <cassert> #include "ftnoir_protocol_ft.h" #include "csv/csv.h" @@ -43,8 +42,9 @@ freetrack::~freetrack() } static_assert(sizeof(LONG) == sizeof(std::int32_t), ""); +static_assert(sizeof(LONG) == 4u, ""); -inline void store(float volatile& place, const float value) +never_inline void store(float volatile& place, const float value) { union { @@ -60,17 +60,12 @@ inline void store(float volatile& place, const float value) (void)InterlockedExchange((LONG volatile*)&place, value_.i32); } -inline void store(std::int32_t volatile& place, std::int32_t value) +never_inline void store(std::int32_t volatile& place, std::int32_t value) { (void)InterlockedExchange((LONG volatile*) &place, value); } -inline void store(std::uint8_t volatile& place, std::uint8_t value) -{ - (void)InterlockedExchange8((char volatile*) &place, char(value)); -} - -inline std::int32_t load(std::int32_t volatile& place) +never_inline std::int32_t load(std::int32_t volatile& place) { return InterlockedCompareExchange((volatile LONG*) &place, 0, 0); } @@ -103,12 +98,30 @@ void freetrack::pose(const double* headpose) if (intGameID != id) { QString gamename; - unsigned char table[8] {}; + union { + unsigned char table[8] alignas(alignof(std::int32_t)); + std::int32_t ints[2]; + } t; + + t.ints[0] = 0; t.ints[1] = 0; + + (void)CSV::getGameData(id, t.table, gamename); - (void)CSV::getGameData(id, (unsigned char*)table, gamename); + { + const std::uintptr_t addr = (std::uintptr_t)(void*)&pMemData->table[0]; + const std::uintptr_t addr_ = addr & (sizeof(LONG)-1); - for (unsigned k = 0; k < 8; k++) - store(pMemData->table[k], table[k]); + // the data `happens' to be aligned by virtue of element ordering + // inside FTHeap. there's no deeper reason behind it. + + if (addr != addr_) + assert("!unaligned access"); + + static_assert(sizeof(char[8])/sizeof(LONG) == 2, ""); + + for (unsigned k = 0; k < 2; k++) + store(*(std::int32_t volatile*)&pMemData->table_ints[k], t.ints[k]); + } store(ft->GameID2, id); store(data->DataID, 0); @@ -220,8 +233,8 @@ bool freetrack::correct() store(pMemData->GameID2, 0); - for (int i = 0; i < 8; i++) - store(pMemData->table[i], 0); + for (unsigned k = 0; k < 2; k++) + store(*(std::int32_t volatile*)&pMemData->table_ints[k], 0); // more games need the dummy executable than previously thought if (use_npclient) diff --git a/tracker-hatire/ftnoir_tracker_hat.h b/tracker-hatire/ftnoir_tracker_hat.h index 47f66812..fa8b8448 100644 --- a/tracker-hatire/ftnoir_tracker_hat.h +++ b/tracker-hatire/ftnoir_tracker_hat.h @@ -8,12 +8,10 @@ #include <atomic> #include <QObject> -#include <QPalette> -#include <QtGui> #include <QByteArray> #include <QMessageBox> -#include <QtSerialPort/QSerialPort> -#include <QtSerialPort/QSerialPortInfo> +#include <QSerialPort> +#include <QSerialPortInfo> #include <QSettings> class hatire : public QObject, public ITracker diff --git a/tracker-steamvr/steamvr.hpp b/tracker-steamvr/steamvr.hpp index af8fdbc8..0592dec9 100644 --- a/tracker-steamvr/steamvr.hpp +++ b/tracker-steamvr/steamvr.hpp @@ -51,7 +51,7 @@ struct device_list final void refresh_device_list(); const QList<device_spec>& devices() const { return device_specs; } - static OTR_NEVER_INLINE maybe_pose get_pose(int k); + static never_inline maybe_pose get_pose(int k); static QString strerror(error_t error); static constexpr int max_devices = int(vr::k_unMaxTrackedDeviceCount); diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 3795024c..abf34b5f 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -68,12 +68,12 @@ static void reinit_offset() { } #ifdef __GNUC__ -# define OT_UNUSED(varname) varname __attribute__((__unused__)) +# define unused(varname) varname __attribute__((__unused__)) #else -# define OT_UNUSED(varname) varname +# define unused(varname) varname #endif -PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *OT_UNUSED(mutexName), int mapSize) +PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *unused(mutexName), int mapSize) { PortableLockedShm* self = malloc(sizeof(PortableLockedShm)); char shm_filename[NAME_MAX]; @@ -107,10 +107,10 @@ void PortableLockedShm_unlock(PortableLockedShm* self) } float write_head_position( - float OT_UNUSED(inElapsedSinceLastCall), - float OT_UNUSED(inElapsedTimeSinceLastFlightLoop), - int OT_UNUSED(inCounter), - void * OT_UNUSED(inRefcon) ) + float unused(inElapsedSinceLastCall), + float unused(inElapsedTimeSinceLastFlightLoop), + int unused(inCounter), + void * unused(inRefcon) ) { if (lck_posix != NULL && shm_posix != NULL) { if(data_last == NULL){ @@ -235,9 +235,9 @@ PLUGIN_API OTR_COMPAT_EXPORT void XPluginDisable ( void ) { } PLUGIN_API OTR_COMPAT_EXPORT void XPluginReceiveMessage( - XPLMPluginID OT_UNUSED(inFromWho), - int OT_UNUSED(inMessage), - void * OT_UNUSED(inParam)) + XPLMPluginID unused(inFromWho), + int unused(inMessage), + void * unused(inParam)) { if (inMessage == XPLM_MSG_AIRPORT_LOADED) reinit_offset(); |