OSDN Git Service

Make -fdata-sections work for AVR port.
[pf3gnuchains/gcc-fork.git] / gcc / gthr.h
1 /* Threads compatibility routines for libgcc2.  */
2 /* Compile this one with gcc.  */
3 /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING.  If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.  */
21
22 /* As a special exception, if you link this library with other files,
23    some of which are compiled with GCC, to produce an executable,
24    this library does not by itself cause the resulting executable
25    to be covered by the GNU General Public License.
26    This exception does not however invalidate any other reasons why
27    the executable file might be covered by the GNU General Public License.  */
28
29 #ifndef GCC_GTHR_H
30 #define GCC_GTHR_H
31
32 #pragma GCC visibility push(default)
33
34 /* If this file is compiled with threads support, it must
35        #define __GTHREADS 1
36    to indicate that threads support is present.  Also it has define
37    function
38      int __gthread_active_p ()
39    that returns 1 if thread system is active, 0 if not.
40
41    The threads interface must define the following types:
42      __gthread_key_t
43      __gthread_once_t
44      __gthread_mutex_t
45      __gthread_recursive_mutex_t
46
47    The threads interface must define the following macros:
48
49      __GTHREAD_ONCE_INIT
50                 to initialize __gthread_once_t
51      __GTHREAD_MUTEX_INIT
52                 to initialize __gthread_mutex_t to get a fast
53                 non-recursive mutex.
54      __GTHREAD_MUTEX_INIT_FUNCTION
55                 some systems can't initialize a mutex without a
56                 function call.  On such systems, define this to a
57                 function which looks like this:
58                   void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *)
59                 Don't define __GTHREAD_MUTEX_INIT in this case
60      __GTHREAD_RECURSIVE_MUTEX_INIT
61      __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
62                 as above, but for a recursive mutex.
63
64    The threads interface must define the following static functions:
65
66      int __gthread_once (__gthread_once_t *once, void (*func) ())
67
68      int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *))
69      int __gthread_key_delete (__gthread_key_t key)
70
71      void *__gthread_getspecific (__gthread_key_t key)
72      int __gthread_setspecific (__gthread_key_t key, const void *ptr)
73
74      int __gthread_mutex_lock (__gthread_mutex_t *mutex);
75      int __gthread_mutex_trylock (__gthread_mutex_t *mutex);
76      int __gthread_mutex_unlock (__gthread_mutex_t *mutex);
77
78      int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
79      int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
80      int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
81
82    All functions returning int should return zero on success or the error
83    number.  If the operation is not supported, -1 is returned.
84
85    Currently supported threads packages are
86      POSIX threads with -D_PTHREADS
87      DCE threads with -D_DCE_THREADS
88      Solaris/UI threads with -D_SOLARIS_THREADS
89 */
90
91 /* Check first for thread specific defines.  */
92 #if _PTHREADS
93 #include "gthr-posix.h"
94 #elif _DCE_THREADS
95 #include "gthr-dce.h"
96 #elif _SOLARIS_THREADS
97 #include "gthr-solaris.h"
98
99 /* Include GTHREAD_FILE if one is defined.  */
100 #elif defined(HAVE_GTHR_DEFAULT)
101 #if SUPPORTS_WEAK
102 #ifndef GTHREAD_USE_WEAK
103 #define GTHREAD_USE_WEAK 1
104 #endif
105 #endif
106 #include "gthr-default.h"
107
108 /* Fallback to single thread definitions.  */
109 #else
110 #include "gthr-single.h"
111 #endif
112
113 #pragma GCC visibility pop
114
115 #endif /* ! GCC_GTHR_H */