[io-layer] Remove Sleep and SleepEx
[mono.git] / mono / io-layer / shared.c
index 3607779aa92e93cffc65c1d0bbe6cb686172e31b..f8539039cad103441bc63f977c3331251ff5df2c 100644 (file)
@@ -18,7 +18,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#ifdef HAVE_SYS_SEM_H
+#if defined(HAVE_SYS_SEM_H) && !(defined(__native_client__) && defined(__GLIBC__))
 #  include <sys/sem.h>
 #else
 #  define DISABLE_SHARED_HANDLES
 
 static mono_mutex_t noshm_sems[_WAPI_SHARED_SEM_COUNT];
 
-gboolean _wapi_shm_disabled = TRUE;
-
 static gpointer wapi_storage [16];
 
 static void
 noshm_semaphores_init (void)
 {
-       int i;
+       int i;
 
-       for (i = 0; i < _WAPI_SHARED_SEM_COUNT; i++) 
-               mono_mutex_init (&noshm_sems [i], NULL);
+       for (i = 0; i < _WAPI_SHARED_SEM_COUNT; i++) 
+               mono_mutex_init (&noshm_sems [i]);
 }
 
 static int
@@ -127,16 +125,15 @@ _wapi_shm_sem_unlock (int sem)
 gpointer
 _wapi_shm_attach (_wapi_shm_t type)
 {
-       guint32 size;
        gpointer res;
 
        switch(type) {
        case WAPI_SHM_DATA:
                res = g_malloc0 (sizeof(struct _WapiHandleSharedLayout));
-               
+               break;
        case WAPI_SHM_FILESHARE:
                res = g_malloc0 (sizeof(struct _WapiFileShareLayout));
-
+               break;
        default:
                g_error ("Invalid type in _wapi_shm_attach ()");
                return NULL;
@@ -152,7 +149,14 @@ _wapi_shm_detach (_wapi_shm_t type)
        g_free (wapi_storage [type]);
 }
 
-#else
+gboolean
+_wapi_shm_enabled_internal (void)
+{
+       return FALSE;
+}
+
+#else /* DISABLE_SHARED_HANDLES */
+
 /*
  * Use POSIX shared memory if possible, it is simpler, and it has the advantage that 
  * writes to the shared area does not need to be written to disk, avoiding spinning up 
@@ -162,6 +166,8 @@ _wapi_shm_detach (_wapi_shm_t type)
 #define USE_SHM 1
 #endif
 
+static gboolean _wapi_shm_disabled = TRUE;
+
 static gchar *
 _wapi_shm_base_name (_wapi_shm_t type)
 {
@@ -249,7 +255,8 @@ static gchar *
 _wapi_shm_file (_wapi_shm_t type)
 {
        static gchar file[_POSIX_PATH_MAX];
-       gchar *name = NULL, *filename, *wapi_dir;
+       gchar *name = NULL, *filename;
+       const gchar *wapi_dir;
 
        name = _wapi_shm_base_name (type);
 
@@ -257,7 +264,7 @@ _wapi_shm_file (_wapi_shm_t type)
         * nfs mounts breaks, then there should be an option to set
         * the directory.
         */
-       wapi_dir = getenv ("MONO_SHARED_DIR");
+       wapi_dir = g_getenv ("MONO_SHARED_DIR");
        if (wapi_dir == NULL) {
                filename = g_build_filename (g_get_home_dir (), ".wapi", name,
                                             NULL);
@@ -398,7 +405,7 @@ try_again:
 }
 
 gboolean
-_wapi_shm_enabled (void)
+_wapi_shm_enabled_internal (void)
 {
        static gboolean env_checked;