source: trunk/src/3rdparty/ptmalloc/sysdeps/solaris/malloc-machine.h@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 1.9 KB
Line 
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 <[email protected]>.
5
6Permission to use, copy, modify, distribute, and sell this software
7and its documentation for any purpose is hereby granted without fee,
8provided that (i) the above copyright notices and this permission
9notice appear in all copies of the software and related documentation,
10and (ii) the name of Wolfram Gloger may not be used in any advertising
11or publicity relating to the software.
12
13THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16
17IN NO EVENT SHALL WOLFRAM GLOGER BE LIABLE FOR ANY SPECIAL,
18INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
19DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY
21OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22PERFORMANCE OF THIS SOFTWARE.
23*/
24
25#ifndef _SOLARIS_MALLOC_MACHINE_H
26#define _SOLARIS_MALLOC_MACHINE_H
27
28#include <thread.h>
29
30typedef 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 */
39typedef 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) */
Note: See TracBrowser for help on using the repository browser.