projects
/
mono.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
NaCl runtime fixes
[mono.git]
/
mono
/
io-layer
/
shared.c
diff --git
a/mono/io-layer/shared.c
b/mono/io-layer/shared.c
index bf966d202c3c01f1a37590693c7e8bb104c465d0..ed9bb1fb21178c6d5ec1f8a653ac85c56729e8d0 100644
(file)
--- a/
mono/io-layer/shared.c
+++ b/
mono/io-layer/shared.c
@@
-18,7
+18,7
@@
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
-#if
def HAVE_SYS_SEM_H
+#if
defined(HAVE_SYS_SEM_H) && !(defined(__native_client__) && defined(__GLIBC__))
# include <sys/sem.h>
#else
# define DISABLE_SHARED_HANDLES
# include <sys/sem.h>
#else
# define DISABLE_SHARED_HANDLES
@@
-46,6
+46,8
@@
static mono_mutex_t noshm_sems[_WAPI_SHARED_SEM_COUNT];
gboolean _wapi_shm_disabled = TRUE;
gboolean _wapi_shm_disabled = TRUE;
+static gpointer wapi_storage [16];
+
static void
noshm_semaphores_init (void)
{
static void
noshm_semaphores_init (void)
{
@@
-125,20
+127,36
@@
_wapi_shm_sem_unlock (int sem)
gpointer
_wapi_shm_attach (_wapi_shm_t type)
{
gpointer
_wapi_shm_attach (_wapi_shm_t type)
{
- g
uint32 size
;
+ g
pointer res
;
switch(type) {
case WAPI_SHM_DATA:
switch(type) {
case WAPI_SHM_DATA:
- re
turn
g_malloc0 (sizeof(struct _WapiHandleSharedLayout));
-
+ re
s =
g_malloc0 (sizeof(struct _WapiHandleSharedLayout));
+ break;
case WAPI_SHM_FILESHARE:
case WAPI_SHM_FILESHARE:
- re
turn
g_malloc0 (sizeof(struct _WapiFileShareLayout));
-
+ re
s =
g_malloc0 (sizeof(struct _WapiFileShareLayout));
+ break;
default:
g_error ("Invalid type in _wapi_shm_attach ()");
return NULL;
}
default:
g_error ("Invalid type in _wapi_shm_attach ()");
return NULL;
}
+
+ wapi_storage [type] = res;
+ return res;
+}
+
+void
+_wapi_shm_detach (_wapi_shm_t type)
+{
+ g_free (wapi_storage [type]);
+}
+
+gboolean
+_wapi_shm_enabled (void)
+{
+ return FALSE;
}
}
+
#else
/*
* Use POSIX shared memory if possible, it is simpler, and it has the advantage that
#else
/*
* Use POSIX shared memory if possible, it is simpler, and it has the advantage that
@@
-384,8
+402,8
@@
try_again:
return fd;
}
return fd;
}
-
static
gboolean
-
check_dis
abled (void)
+gboolean
+
_wapi_shm_en
abled (void)
{
static gboolean env_checked;
{
static gboolean env_checked;
@@
-395,7
+413,7
@@
check_disabled (void)
env_checked = TRUE;
}
env_checked = TRUE;
}
- return _wapi_shm_disabled;
+ return
!
_wapi_shm_disabled;
}
/*
}
/*
@@
-427,8
+445,9
@@
_wapi_shm_attach (_wapi_shm_t type)
return NULL;
}
return NULL;
}
- if (check_disabled ()) {
- return g_malloc0 (size);
+ if (!_wapi_shm_enabled ()) {
+ wapi_storage [type] = g_malloc0 (size);
+ return wapi_storage [type];
}
#ifdef USE_SHM
}
#ifdef USE_SHM
@@
-471,6
+490,13
@@
_wapi_shm_attach (_wapi_shm_t type)
return shm_seg;
}
return shm_seg;
}
+void
+_wapi_shm_detach (_wapi_shm_t type)
+{
+ if (!_wapi_shm_enabled ())
+ g_free (wapi_storage [type]);
+}
+
static void
shm_semaphores_init (void)
{
static void
shm_semaphores_init (void)
{
@@
-815,7
+841,7
@@
shm_sem_unlock (int sem)
void
_wapi_shm_semaphores_init (void)
{
void
_wapi_shm_semaphores_init (void)
{
- if (
check_disabled ())
+ if (
!_wapi_shm_enabled ())
noshm_semaphores_init ();
else
shm_semaphores_init ();
noshm_semaphores_init ();
else
shm_semaphores_init ();