* c-parser.c (c_parser_lex_all): Don't enforce location constraint
[official-gcc.git] / gcc / host-thread.h
blobba5396a060201c203cf012459a0373a09e76a1a3
1 /* Host thread abstraction for GCC.
2 Copyright (C) 2007
3 Free Software Foundation, Inc.
5 This file is part of GCC.
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 3, or (at your option) any later
10 version.
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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_HOST_THREAD_H
22 #define GCC_HOST_THREAD_H
24 /* For now, just pthreads. */
25 #include <pthread.h>
27 typedef pthread_mutex_t host_mutex;
28 typedef pthread_cond_t host_condition;
30 static inline host_mutex *
31 host_mutex_create (void)
33 host_mutex *result = XNEW (host_mutex);
34 pthread_mutex_init (result, NULL);
35 return result;
38 static inline void
39 host_mutex_lock (host_mutex *m)
41 pthread_mutex_lock (m);
44 static inline void
45 host_mutex_unlock (host_mutex *m)
47 pthread_mutex_unlock (m);
50 static inline host_condition *
51 host_condition_create (void)
53 host_condition *result = XNEW (host_condition);
54 pthread_cond_init (result, NULL);
55 return result;
58 static inline void
59 host_condition_wait (host_condition *c, host_mutex *m)
61 pthread_cond_wait (c, m);
64 static inline void
65 host_condition_broadcast (host_condition *c)
67 pthread_cond_broadcast (c);
70 static inline void
71 host_thread_create (void *(*func) (void *), void *arg)
73 pthread_t thr;
74 pthread_attr_t attr;
75 pthread_attr_init (&attr);
76 pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
77 /* FIXME: error handling. */
78 pthread_create (&thr, &attr, func, arg);
79 pthread_attr_destroy (&attr);
82 #endif /* GCC_HOST_THREAD_H */