summaryrefslogtreecommitdiff
path: root/gcc/gthr-win32.h
diff options
context:
space:
mode:
authordannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-11 05:25:44 +0000
committerdannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-11 05:25:44 +0000
commit29dcbe46ff709e200b4885d7ef63a2ec3f52b3f4 (patch)
treef6283ed4f74366bef33687bff46a7119233f9661 /gcc/gthr-win32.h
parent1bc6752875c37f0e7dfdd1755ef1741450271010 (diff)
downloadgcc-29dcbe46ff709e200b4885d7ef63a2ec3f52b3f4.tar.gz
* gthr-win32.h: Wrap all functions in extern "C".
(__gthread_key_t): Typedef as unsigned long, not win32 DWORD. (__GTHREAD_ONCE_INIT): Use 0, not win32 FALSE. (__gthread_mutex_t): Typedef as void*, not win32 HANDLE. (__gthr_win32_once, __gthr_win32_key_create, __gthr_win32_key_delete, __gthr_win32_getspecific, __gthr_win32_setspecific, __gthr_win32_mutex_init_function, __gthr_win32_mutex_lock,__gthr_win32_mutex_trylock, __gthr_win32_mutex_unlock): Declare. (__gthread_once,__gthread_key_create, __gthread_key_delete, __gthread_getspecific, __gthread_setspecific, __gthread_mutex_init_function, __gthread_mutex_lock,__gthread_mutex_trylock, __gthread_mutex_unlock): Call corresponding __gthr_win32_* extern implementations if #defined __GTHREAD_HIDE_WIN32API. * config/i386/t-mingw32 (LIB2FUNCS_EXTRA): Set to $(srcdir)/config/i386/gthr-win32.c * config/i386/gthr-win32.c: New implementation file. (__gthr_win32_once, __gthr_win32_key_create, __gthr_win32_key_delete, __gthr_win32_getspecific, __gthr_win32_setspecific, __gthr_win32_mutex_init_function, __gthr_win32_mutex_lock,__gthr_win32_mutex_trylock, __gthr_win32_mutex_unlock): New functions, based on static inlines in gthr-win32.h. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54484 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gthr-win32.h')
-rw-r--r--gcc/gthr-win32.h122
1 files changed, 108 insertions, 14 deletions
diff --git a/gcc/gthr-win32.h b/gcc/gthr-win32.h
index a4ff4e0edde..97f4f49ebb2 100644
--- a/gcc/gthr-win32.h
+++ b/gcc/gthr-win32.h
@@ -328,37 +328,32 @@ __gthread_objc_condition_signal(objc_condition_t condition)
#else /* _LIBOBJC */
-#include <windows.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
-typedef DWORD __gthread_key_t;
+typedef unsigned long __gthread_key_t;
typedef struct {
int done;
long started;
} __gthread_once_t;
-typedef HANDLE __gthread_mutex_t;
+typedef void* __gthread_mutex_t;
-#define __GTHREAD_ONCE_INIT {FALSE, -1}
+#define __GTHREAD_ONCE_INIT {0, -1}
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
#define __GTHREAD_MUTEX_INIT_DEFAULT 0
#if __MINGW32_MAJOR_VERSION >= 1 || \
(__MINGW32_MAJOR_VERSION == 0 && __MINGW32_MINOR_VERSION > 2)
#define MINGW32_SUPPORTS_MT_EH 1
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern int __mingwthr_key_dtor (DWORD, void (*) (void *));
-#ifdef __cplusplus
-}
-#endif
-
/* Mingw runtime >= v0.3 provides a magic variable that is set to non-zero
if -mthreads option was specified, or 0 otherwise. This is to get around
the lack of weak symbols in PE-COFF. */
extern int _CRT_MT;
-#endif
+extern int __mingwthr_key_dtor (unsigned long, void (*) (void *));
+#endif /* __MINGW32__ version */
static inline int
__gthread_active_p (void)
@@ -370,6 +365,100 @@ __gthread_active_p (void)
#endif
}
+#ifdef __GTHREAD_HIDE_WIN32API
+
+/* The implementations are in config/i386/gthr-win32.c in libgcc.a.
+ Only stubs are exposed to avoid polluting the C++ namespace with
+ windows api definitions. */
+
+extern int __gthr_win32_once (__gthread_once_t *, void (*) (void));
+extern int __gthr_win32_key_create (__gthread_key_t *, void (*) (void*));
+extern int __gthr_win32_key_delete (__gthread_key_t);
+extern void * __gthr_win32_getspecific (__gthread_key_t);
+extern int __gthr_win32_setspecific (__gthread_key_t, const void *);
+extern void __gthr_win32_mutex_init_function (__gthread_mutex_t *);
+extern int __gthr_win32_mutex_lock (__gthread_mutex_t *);
+extern int __gthr_win32_mutex_trylock (__gthread_mutex_t *);
+extern int __gthr_win32_mutex_unlock (__gthread_mutex_t *);
+
+static inline int
+__gthread_once (__gthread_once_t *once, void (*func) (void))
+{
+ if ( __gthread_active_p ())
+ return __gthr_win32_once (once, func);
+ else
+ return -1;
+}
+
+static inline int
+__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
+{
+ return __gthr_win32_key_create (key, dtor);
+}
+
+static inline int
+__gthread_key_dtor (__gthread_key_t key, void *ptr)
+{
+ /* Nothing needed. */
+ return 0;
+}
+
+ static inline int
+__gthread_key_delete (__gthread_key_t key)
+{
+ return __gthr_win32_key_delete (key);
+}
+
+static inline void *
+__gthread_getspecific (__gthread_key_t key)
+{
+ return __gthr_win32_getspecific (key);
+}
+
+static inline int
+__gthread_setspecific (__gthread_key_t key, const void *ptr)
+{
+ return __gthr_win32_setspecific (key, ptr);
+}
+
+static inline void
+__gthread_mutex_init_function (__gthread_mutex_t *mutex)
+{
+ __gthr_win32_mutex_init_function (mutex);
+}
+
+static inline int
+__gthread_mutex_lock (__gthread_mutex_t *mutex)
+{
+ if (__gthread_active_p ())
+ return __gthr_win32_mutex_lock (mutex);
+ else
+ return 0;
+}
+
+static inline int
+__gthread_mutex_trylock (__gthread_mutex_t *mutex)
+{
+ if (__gthread_active_p ())
+ return __gthr_win32_mutex_trylock (mutex);
+ else
+ return 0;
+}
+
+static inline int
+__gthread_mutex_unlock (__gthread_mutex_t *mutex)
+{
+ if (__gthread_active_p ())
+ return __gthr_win32_mutex_unlock (mutex);
+ else
+ return 0;
+}
+
+#else /* ! __GTHREAD_HIDE_WIN32API */
+
+#include <windows.h>
+#include <errno.h>
+
static inline int
__gthread_once (__gthread_once_t *once, void (*func) (void))
{
@@ -504,7 +593,12 @@ __gthread_mutex_unlock (__gthread_mutex_t *mutex)
return 0;
}
+#endif /* __GTHREAD_HIDE_WIN32API */
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _LIBOBJC */
#endif /* ! GCC_GTHR_WIN32_H */
-