Permalink
Browse files

Posix implementation

  • Loading branch information...
1 parent 1dc333a commit 25a36ed0a6f3f2f2dcc39333372163bb6bf40e19 @shawwn committed Dec 20, 2011
Showing with 12 additions and 5 deletions.
  1. +1 −1 CMakeLists.txt
  2. +4 −0 shmem/CMakeLists.txt
  3. +7 −4 shmem/shmem.cpp
View
@@ -62,5 +62,5 @@ configure_file(shmemConfigVersion.cmake.in
# Install the export set for use with the install-tree
install(EXPORT shmemLibraryDepends DESTINATION
- "${INSTALL_DATA_DIR}/shmem/CMake"
+ "${INSTALL_BIN_DIR}/shmem/CMake"
COMPONENT dev)
View
@@ -5,6 +5,10 @@ add_library(shmem STATIC shmem.cpp shmem.h config.h.in)
set_target_properties(shmem PROPERTIES
PUBLIC_HEADER "shmem.h;${CMAKE_CURRENT_BINARY_DIR}/config.h")
+if(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ target_link_libraries(shmem rt)
+endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
+
install(TARGETS shmem
# IMPORTANT: Add the shmem library to the "export-set"
EXPORT shmemLibraryDepends
View
@@ -158,7 +158,7 @@ shmem_t* shmem_connect( const char* name, size_t size )
shm->size = size;
#if !ON_WINDOWS
shm->fd = -1;
- shm->mapped = MAP_FAILED;
+ shm->mapped = (uint8_t*)MAP_FAILED;
#endif
uint32_t total_size = shmem_calc_total_size( size );
@@ -208,7 +208,7 @@ shmem_t* shmem_connect( const char* name, size_t size )
//---------------------------------------------------------------------------
static bool shmem_platform_startup( shmem_t* shm, uint32_t size )
{
- assert( shm && (shm->mapped == NULL) );
+ assert( shm );
bool success = false;
@@ -245,11 +245,11 @@ static bool shmem_platform_startup( shmem_t* shm, uint32_t size )
{
char* fullname = strjoin( "/", shm->name );
- shm->created = false;
+ shm->created = true;
shm->fd = shm_open( fullname, (O_CREAT | O_RDWR | O_EXCL), (S_IRUSR | S_IWUSR) );
if ( shm->fd == -1 )
{
- shm->created = true;
+ shm->created = false;
shm->fd = shm_open( fullname, (O_CREAT | O_RDWR), (S_IRUSR | S_IWUSR) );
}
@@ -315,6 +315,9 @@ void shmem_platform_shutdown( shmem_t* shm )
{
close( shm->fd );
shm->fd = -1;
+ char* fullname = strjoin( "/", shm->name );
+ shm_unlink( fullname );
+ strfree( fullname );
}
}
#endif

0 comments on commit 25a36ed

Please sign in to comment.