Bug 548967 - 1 bit mutex lock
[platform/upstream/glib.git] / glib / gthreadprivate.h
1 /* GLIB - Library of useful routines for C programming
2  *
3  * gthreadprivate.h - GLib internal thread system related declarations.
4  *
5  *  Copyright (C) 2003 Sebastian Wilhelmi
6  *
7  * The Gnome Library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * The Gnome Library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with the Gnome Library; see the file COPYING.LIB.  If not,
19  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  *   Boston, MA 02111-1307, USA.
21  */
22
23 #ifndef __G_THREADPRIVATE_H__
24 #define __G_THREADPRIVATE_H__
25
26 G_BEGIN_DECLS
27
28 /* System thread identifier comparision and assignment */
29 #if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
30 # define g_system_thread_equal_simple(thread1, thread2)                 \
31    ((thread1).dummy_pointer == (thread2).dummy_pointer)
32 # define g_system_thread_assign(dest, src)                              \
33    ((dest).dummy_pointer = (src).dummy_pointer)
34 #else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */
35 # define g_system_thread_equal_simple(thread1, thread2)                 \
36    (memcmp (&(thread1), &(thread2), GLIB_SIZEOF_SYSTEM_THREAD) == 0)
37 # define g_system_thread_assign(dest, src)                              \
38    (memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
39 #endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
40
41 #define g_system_thread_equal(thread1, thread2)                         \
42   (g_thread_functions_for_glib_use.thread_equal ?                       \
43    g_thread_functions_for_glib_use.thread_equal (&(thread1), &(thread2)) :\
44    g_system_thread_equal_simple((thread1), (thread2)))
45
46 /* Is called from gthread/gthread-impl.c */
47 void g_thread_init_glib (void);
48
49 /* base initializers, may only use g_mutex_new(), g_cond_new() */
50 G_GNUC_INTERNAL void _g_mem_thread_init_noprivate_nomessage (void);
51 /* initializers that may also use g_private_new() */
52 G_GNUC_INTERNAL void _g_slice_thread_init_nomessage         (void);
53 G_GNUC_INTERNAL void _g_messages_thread_init_nomessage      (void);
54
55 /* full fledged initializers */
56 G_GNUC_INTERNAL void _g_convert_thread_init (void);
57 G_GNUC_INTERNAL void _g_rand_thread_init (void);
58 G_GNUC_INTERNAL void _g_main_thread_init (void);
59 G_GNUC_INTERNAL void _g_atomic_thread_init (void);
60 G_GNUC_INTERNAL void _g_utils_thread_init (void);
61 G_GNUC_INTERNAL void _g_futex_thread_init (void);
62
63 #ifdef G_OS_WIN32
64 G_GNUC_INTERNAL void _g_win32_thread_init (void);
65 #endif /* G_OS_WIN32 */
66
67 G_END_DECLS
68
69 #endif /* __G_THREADPRIVATE_H__ */