Flush
[mono.git] / mono / io-layer / mono-mutex.h
index ea533aa18423d95b6e70eae647bb27b3e062cea3..3c4ba577fff5c2255c574820fe09d81349a975dc 100644 (file)
 
 #ifdef __cplusplus
 extern "C" {
+#pragma }
 #endif /* __cplusplus */
 
+#include <glib.h>
 #include <pthread.h>
 #include <time.h>
 
-#ifndef HAVE_PTHREAD_MUTEX_TIMEDLOCK
-extern int pthread_mutex_timedlock (pthread_mutex_t *mutex,
-                                   const struct timespec *timeout);
-#endif /* HAVE_PTHREAD_MUTEX_TIMEDLOCK */
+typedef struct {
+       pthread_mutex_t mutex;
+       gboolean complete;
+} mono_once_t;
+
+#define MONO_ONCE_INIT { PTHREAD_MUTEX_INITIALIZER, FALSE }
+
+int mono_once (mono_once_t *once, void (*once_init) (void));
 
 
 #ifdef USE_MONO_MUTEX
@@ -153,6 +159,14 @@ typedef pthread_mutexattr_t mono_mutexattr_t;
 
 #endif /* USE_MONO_MUTEX */
 
+/* This is a function so it can be passed to pthread_cleanup_push -
+ * that is a macro and giving it a macro as a parameter breaks.
+ */
+static inline int mono_mutex_unlock_in_cleanup (mono_mutex_t *mutex)
+{
+       return(mono_mutex_unlock (mutex));
+}
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */