OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [gthr-vxworks.h] - Blame information for rev 780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 734 jeremybenn
/* Threads compatibility routines for libgcc2 and libobjc for VxWorks.  */
2
/* Compile this one with gcc.  */
3
/* Copyright (C) 1997, 1999, 2000, 2008, 2009, 2011
4
   Free Software Foundation, Inc.
5
   Contributed by Mike Stump <mrs@wrs.com>.
6
 
7
This file is part of GCC.
8
 
9
GCC is free software; you can redistribute it and/or modify it under
10
the terms of the GNU General Public License as published by the Free
11
Software Foundation; either version 3, or (at your option) any later
12
version.
13
 
14
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15
WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17
for more details.
18
 
19
Under Section 7 of GPL version 3, you are granted additional
20
permissions described in the GCC Runtime Library Exception, version
21
3.1, as published by the Free Software Foundation.
22
 
23
You should have received a copy of the GNU General Public License and
24
a copy of the GCC Runtime Library Exception along with this program;
25
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
26
<http://www.gnu.org/licenses/>.  */
27
 
28
#ifndef GCC_GTHR_VXWORKS_H
29
#define GCC_GTHR_VXWORKS_H
30
 
31
#ifdef _LIBOBJC
32
 
33
/* libobjc requires the optional pthreads component.  */
34
#include "gthr-posix.h"
35
 
36
#else
37
#ifdef __cplusplus
38
#define UNUSED(x)
39
#else
40
#define UNUSED(x) x __attribute__((unused))
41
#endif
42
 
43
#ifdef __cplusplus
44
extern "C" {
45
#endif
46
 
47
#define __GTHREADS 1
48
#define __gthread_active_p() 1
49
 
50
/* Mutexes are easy, except that they need to be initialized at runtime.  */
51
 
52
#include <semLib.h>
53
 
54
typedef SEM_ID __gthread_mutex_t;
55
/* All VxWorks mutexes are recursive.  */
56
typedef SEM_ID __gthread_recursive_mutex_t;
57
#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
58
#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
59
 
60
static inline void
61
__gthread_mutex_init_function (__gthread_mutex_t *mutex)
62
{
63
  *mutex = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
64
}
65
 
66
static inline int
67
__gthread_mutex_destroy (__gthread_mutex_t * UNUSED(mutex))
68
{
69
  return 0;
70
}
71
 
72
static inline int
73
__gthread_mutex_lock (__gthread_mutex_t *mutex)
74
{
75
  return semTake (*mutex, WAIT_FOREVER);
76
}
77
 
78
static inline int
79
__gthread_mutex_trylock (__gthread_mutex_t *mutex)
80
{
81
  return semTake (*mutex, NO_WAIT);
82
}
83
 
84
static inline int
85
__gthread_mutex_unlock (__gthread_mutex_t *mutex)
86
{
87
  return semGive (*mutex);
88
}
89
 
90
static inline void
91
__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
92
{
93
  __gthread_mutex_init_function (mutex);
94
}
95
 
96
static inline int
97
__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
98
{
99
  return __gthread_mutex_lock (mutex);
100
}
101
 
102
static inline int
103
__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
104
{
105
  return __gthread_mutex_trylock (mutex);
106
}
107
 
108
static inline int
109
__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
110
{
111
  return __gthread_mutex_unlock (mutex);
112
}
113
 
114
/* pthread_once is complicated enough that it's implemented
115
   out-of-line.  See config/vxlib.c.  */
116
 
117
typedef struct
118
{
119
#if !defined(__RTP__)
120
#if defined(__PPC__)
121
  __attribute ((aligned (__alignof (unsigned))))
122
#endif
123
  volatile unsigned char busy;
124
#endif
125
  volatile unsigned char done;
126
#if !defined(__RTP__) && defined(__PPC__)
127
  /* PPC's test-and-set implementation requires a 4 byte aligned
128
     object, of which it only sets the first byte.  We use padding
129
     here, in order to maintain some amount of backwards
130
     compatibility.  Without this padding, gthread_once objects worked
131
     by accident because they happen to be static objects and the ppc
132
     port automatically increased their alignment to 4 bytes.  */
133
  unsigned char pad1;
134
  unsigned char pad2;
135
#endif
136
}
137
__gthread_once_t;
138
 
139
#if defined (__RTP__)
140
# define __GTHREAD_ONCE_INIT { 0 }
141
#elif defined (__PPC__)
142
# define __GTHREAD_ONCE_INIT { 0, 0, 0, 0 }
143
#else
144
# define __GTHREAD_ONCE_INIT { 0, 0 }
145
#endif
146
 
147
extern int __gthread_once (__gthread_once_t *__once, void (*__func)(void));
148
 
149
/* Thread-specific data requires a great deal of effort, since VxWorks
150
   is not really set up for it.  See config/vxlib.c for the gory
151
   details.  All the TSD routines are sufficiently complex that they
152
   need to be implemented out of line.  */
153
 
154
typedef unsigned int __gthread_key_t;
155
 
156
extern int __gthread_key_create (__gthread_key_t *__keyp, void (*__dtor)(void *));
157
extern int __gthread_key_delete (__gthread_key_t __key);
158
 
159
extern void *__gthread_getspecific (__gthread_key_t __key);
160
extern int __gthread_setspecific (__gthread_key_t __key, void *__ptr);
161
 
162
#undef UNUSED
163
 
164
#ifdef __cplusplus
165
}
166
#endif
167
 
168
#endif /* not _LIBOBJC */
169
 
170
#endif /* gthr-vxworks.h */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.