summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-12 15:32:07 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-12 15:33:12 +0100
commit75056045f8cd11801a4ab47700b80cc034c8e1a4 (patch)
treee0574e3264f7962c1d2c5ca18250d04bfa7ca06f
parent8ee0ccef9128a6a0dc8fcdba09dc9a76194f3f7e (diff)
x-plane: fix memset discarding qualifiers
-rw-r--r--x-plane-plugin/plugin.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c
index b0482d69..b062bb02 100644
--- a/x-plane-plugin/plugin.c
+++ b/x-plane-plugin/plugin.c
@@ -159,6 +159,15 @@ static int TranslationToggleHandler(XPLMCommandRef inCommand,
return 0;
}
+static inline
+void volatile_explicit_bzero(void volatile* restrict ptr, size_t len)
+{
+ for (size_t i = 0; i < len; i++)
+ *((char volatile* restrict)ptr + i) = 0;
+
+ asm volatile("" ::: "memory");
+}
+
PLUGIN_API OTR_GENERIC_EXPORT
int XPluginStart (char* outName, char* outSignature, char* outDescription) {
view_x = XPLMFindDataRef("sim/aircraft/view/acf_peX");
@@ -189,7 +198,7 @@ int XPluginStart (char* outName, char* outSignature, char* outDescription) {
return 0;
}
shm_posix = lck_posix->mem;
- memset(shm_posix, 0, sizeof(WineSHM));
+ volatile_explicit_bzero(shm_posix, sizeof(WineSHM));
strcpy(outName, "opentrack");
strcpy(outSignature, "opentrack - freetrack lives!");
strcpy(outDescription, "head tracking view control");