Remove support for custom thread implementations
[platform/upstream/glib.git] / gthread / gthread-impl.c
1 /* GLIB - Library of useful routines for C programming
2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * gthread.c: thread related functions
5  * Copyright 1998 Sebastian Wilhelmi; University of Karlsruhe
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This 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 this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /*
24  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
25  * file for a list of people on the GLib Team.  See the ChangeLog
26  * files for a list of changes.  These files are distributed with
27  * GLib at ftp://ftp.gtk.org/pub/gtk/.
28  */
29
30 /*
31  * MT safe
32  */
33
34 #include "config.h"
35
36 #include "glib.h"
37 #include "gthreadprivate.h"
38
39 static gint g_thread_priority_map [G_THREAD_PRIORITY_URGENT + 1];
40
41 #include G_THREAD_SOURCE
42
43 #ifndef PRIORITY_LOW_VALUE
44 # define PRIORITY_LOW_VALUE 0
45 #endif
46
47 #ifndef PRIORITY_URGENT_VALUE
48 # define PRIORITY_URGENT_VALUE 0
49 #endif
50
51 #ifndef PRIORITY_NORMAL_VALUE
52 # define PRIORITY_NORMAL_VALUE                                          \
53   ((PRIORITY_LOW_VALUE * 6 + PRIORITY_URGENT_VALUE * 4) / 10)
54 #endif /* PRIORITY_NORMAL_VALUE */
55
56 #ifndef PRIORITY_HIGH_VALUE
57 # define PRIORITY_HIGH_VALUE                                            \
58   ((PRIORITY_NORMAL_VALUE + PRIORITY_URGENT_VALUE * 2) / 3)
59 #endif /* PRIORITY_HIGH_VALUE */
60
61 void
62 g_thread_init (GThreadFunctions *init)
63 {
64   static gboolean already_done;
65
66   if (init != NULL)
67     g_warning ("GThread system no longer supports custom thread implementations.");
68
69   if (already_done)
70     return;
71
72   already_done = TRUE;
73
74 #ifdef HAVE_G_THREAD_IMPL_INIT
75   g_thread_impl_init();
76 #endif /* HAVE_G_THREAD_IMPL_INIT */
77
78   g_thread_functions_for_glib_use = g_thread_functions_for_glib_use_default;
79
80   g_thread_priority_map [G_THREAD_PRIORITY_LOW] = PRIORITY_LOW_VALUE;
81   g_thread_priority_map [G_THREAD_PRIORITY_NORMAL] = PRIORITY_NORMAL_VALUE;
82   g_thread_priority_map [G_THREAD_PRIORITY_HIGH] = PRIORITY_HIGH_VALUE;
83   g_thread_priority_map [G_THREAD_PRIORITY_URGENT] = PRIORITY_URGENT_VALUE;
84
85   g_thread_init_glib ();
86 }
87
88 void
89 g_thread_init_with_errorcheck_mutexes (GThreadFunctions *vtable)
90 {
91   g_assert (vtable == NULL);
92
93   g_thread_init (NULL);
94 }