Permalink
Browse files

fix SharedMem build on Windows (mostly casts)

  • Loading branch information...
floe committed Jun 27, 2013
1 parent 867c440 commit 5d079f09322f8573966f7ffdbc240ebfaaed5266
Showing with 16 additions and 10 deletions.
  1. +14 −10 libs/tools/SharedMem.cc
  2. +2 −0 scripts/libtools.vcxproj
View
@@ -12,9 +12,13 @@
#include <errno.h>
#include <stdexcept>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/sem.h>
+#ifndef _MSC_VER
+ #include <sys/ipc.h>
+ #include <sys/shm.h>
+ #include <sys/sem.h>
+#else
+ #include <Windows.h>
+#endif
SharedMem::SharedMem( int _key, int _size, bool _create ) {
@@ -40,13 +44,13 @@ SharedMem::SharedMem( int _key, int _size, bool _create ) {
char name[64];
- snprintf(name,sizeof(name),"libTISCH-SHM-0x%08X",key);
- shm = CreateFileMapping( (HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, size, name );
+ sprintf_s(name,sizeof(name),"libTISCH-SHM-0x%08X",key);
+ shm = (int)CreateFileMappingA( (HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, size, name );
- snprintf(name,sizeof(name),"libTISCH-SEM-0x%08X",key);
- sem = CreateSemaphore( NULL, 1, 1, name );
+ sprintf_s(name,sizeof(name),"libTISCH-SEM-0x%08X",key);
+ sem = (int)CreateSemaphoreA( NULL, 1, 1, name );
- buffer = MapViewOfFile( handle, FILE_MAP_WRITE, 0, 0, size );
+ buffer = (unsigned char*)MapViewOfFile( (HANDLE)sem, FILE_MAP_WRITE, 0, 0, size );
#endif
}
@@ -85,8 +89,8 @@ int SharedMem::do_sem( short int val ) {
}
#else
int SharedMem::do_sem( short int val ) {
- if (val > 0) return ReleaseSemaphore( sem, val, NULL );
- else return WaitForSingleObject( sem, INFINITE );
+ if (val > 0) return ReleaseSemaphore( (HANDLE)sem, val, NULL );
+ else return WaitForSingleObject( (HANDLE)sem, INFINITE );
}
#endif
View
@@ -101,6 +101,7 @@
<ItemGroup>
<ClCompile Include="..\libs\tools\BasicBlob.cc" />
<ClCompile Include="..\libs\tools\nanolibc.cc" />
+ <ClCompile Include="..\libs\tools\SharedMem.cc" />
<ClCompile Include="..\libs\tools\Socket.cc" />
<ClCompile Include="..\libs\tools\Thread.cc" />
<ClCompile Include="..\libs\tools\TUIOInStream.cc" />
@@ -111,6 +112,7 @@
<ClInclude Include="..\libs\tools\BasicBlob.h" />
<ClInclude Include="..\libs\tools\Functor.h" />
<ClInclude Include="..\libs\tools\nanolibc.h" />
+ <ClInclude Include="..\libs\tools\SharedMem.h" />
<ClInclude Include="..\libs\tools\SmartPtr.h" />
<ClInclude Include="..\libs\tools\Socket.h" />
<ClInclude Include="..\libs\tools\Thread.h" />

0 comments on commit 5d079f0

Please sign in to comment.