summaryrefslogtreecommitdiffhomepage
path: root/compat
diff options
context:
space:
mode:
Diffstat (limited to 'compat')
-rw-r--r--compat/compat.cpp33
-rw-r--r--compat/compat.h17
-rw-r--r--compat/qt-bug-appeasement.cpp1
3 files changed, 30 insertions, 21 deletions
diff --git a/compat/compat.cpp b/compat/compat.cpp
index 8eedc845..7b695617 100644
--- a/compat/compat.cpp
+++ b/compat/compat.cpp
@@ -6,8 +6,9 @@
*/
#define IN_FTNOIR_COMPAT
#include "compat.h"
+#include <string.h>
-#if defined(_WIN32) || defined(__WIN32)
+#if defined(_WIN32)
PortableLockedShm::PortableLockedShm(const char* shmName, const char* mutexName, int mapSize)
{
@@ -44,21 +45,14 @@ void PortableLockedShm::unlock()
}
#else
-PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, int mapSize) : size(mapSize)
+PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize)
{
- char shm_filename[NAME_MAX];
- shm_filename[0] = '/';
- strncpy(shm_filename+1, shmName, NAME_MAX-2);
- sprintf(shm_filename + strlen(shm_filename), "%ld\n", (long) getuid());
- shm_filename[NAME_MAX-1] = '\0';
-
- //(void) shm_unlink(shm_filename);
-
- fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600);
- if (ftruncate(fd, mapSize) == 0)
- mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0);
- else
- mem = (void*) -1;
+ char filename[512] = {0};
+ strcpy(filename, "/");
+ strcat(filename, shmName);
+ fd = shm_open(filename, O_RDWR | O_CREAT, 0600);
+ (void) ftruncate(fd, mapSize);
+ mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0);
}
PortableLockedShm::~PortableLockedShm()
@@ -79,6 +73,13 @@ void PortableLockedShm::unlock()
flock(fd, LOCK_UN);
}
+#endif
-
+bool PortableLockedShm::success()
+{
+#ifndef _WIN32
+ return (void*) mem != (void*) -1;
+#else
+ return (void*) mem != NULL;
#endif
+}
diff --git a/compat/compat.h b/compat/compat.h
index 7692b38a..0e488752 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -6,7 +6,7 @@
*/
#pragma once
-#if defined(_WIN32) || defined(__WIN32)
+#if defined(_WIN32)
#include <windows.h>
#else
#include <stdio.h>
@@ -19,10 +19,16 @@
#include <sys/types.h>
#endif
-#if defined(IN_FTNOIR_COMPAT) && (defined(_WIN32) || defined(__WIN32))
-# define COMPAT_EXPORT __declspec(dllexport)
+#if !defined(OPENTRACK_COMPAT_BUNDLED)
+# if defined(IN_FTNOIR_COMPAT) && defined(_WIN32)
+# define COMPAT_EXPORT __declspec(dllexport)
+# elif defined(_WIN32)
+# define COMPAT_EXPORT __declspec(dllimport)
+# else
+# define COMPAT_EXPORT __attribute__ ((visibility ("default")))
+# endif
#else
-# define COMPAT_EXPORT
+# define COMPAT_EXPORT
#endif
class COMPAT_EXPORT PortableLockedShm {
@@ -31,9 +37,10 @@ public:
~PortableLockedShm();
void lock();
void unlock();
+ bool success();
void* mem;
private:
-#if defined(_WIN32) || defined(__WIN32)
+#if defined(_WIN32)
HANDLE hMutex, hMapFile;
#else
int fd, size;
diff --git a/compat/qt-bug-appeasement.cpp b/compat/qt-bug-appeasement.cpp
new file mode 100644
index 00000000..9a86ac0a
--- /dev/null
+++ b/compat/qt-bug-appeasement.cpp
@@ -0,0 +1 @@
+#include "facetracknoir/qt-moc.h"