|
1 /* Basic platform-independent macro definitions for mutexes, |
|
2 thread-specific data and parameters for malloc. |
|
3 Solaris threads version. |
|
4 Copyright (C) 2004 Wolfram Gloger <wg@malloc.de>. |
|
5 |
|
6 Permission to use, copy, modify, distribute, and sell this software |
|
7 and its documentation for any purpose is hereby granted without fee, |
|
8 provided that (i) the above copyright notices and this permission |
|
9 notice appear in all copies of the software and related documentation, |
|
10 and (ii) the name of Wolfram Gloger may not be used in any advertising |
|
11 or publicity relating to the software. |
|
12 |
|
13 THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, |
|
14 EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY |
|
15 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. |
|
16 |
|
17 IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL, |
|
18 INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY |
|
19 DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
|
20 WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY |
|
21 OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
22 PERFORMANCE OF THIS SOFTWARE. |
|
23 */ |
|
24 |
|
25 #ifndef _SOLARIS_MALLOC_MACHINE_H |
|
26 #define _SOLARIS_MALLOC_MACHINE_H |
|
27 |
|
28 #include <thread.h> |
|
29 |
|
30 typedef thread_t thread_id; |
|
31 |
|
32 #define MUTEX_INITIALIZER { 0 } |
|
33 #define mutex_init(m) mutex_init(m, USYNC_THREAD, NULL) |
|
34 |
|
35 /* |
|
36 * Hack for thread-specific data on Solaris. We can't use thr_setspecific |
|
37 * because that function calls malloc() itself. |
|
38 */ |
|
39 typedef void *tsd_key_t[256]; |
|
40 #define tsd_key_create(key, destr) do { \ |
|
41 int i; \ |
|
42 for(i=0; i<256; i++) (*key)[i] = 0; \ |
|
43 } while(0) |
|
44 #define tsd_setspecific(key, data) (key[(unsigned)thr_self() % 256] = (data)) |
|
45 #define tsd_getspecific(key, vptr) (vptr = key[(unsigned)thr_self() % 256]) |
|
46 |
|
47 #define thread_atfork(prepare, parent, child) do {} while(0) |
|
48 |
|
49 #include <sysdeps/generic/malloc-machine.h> |
|
50 |
|
51 #endif /* !defined(_SOLARIS_MALLOC_MACHINE_H) */ |