1 /* HP-PARISC macro definitions for mutexes, thread-specific data
2 and parameters for malloc.
3 Copyright (C) 2003 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Carlos O'Donell <carlos@baldric.uwo.ca>, 2003.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef _MALLOC_MACHINE_H
22 #define _MALLOC_MACHINE_H
24 #undef thread_atfork_static
27 #include <bits/libc-lock.h>
29 __libc_lock_define (typedef, mutex_t)
31 /* Since our lock structure does not tolerate being initialized to zero, we must
32 modify the standard function calls made by malloc */
33 # define mutex_init(m) \
34 __libc_maybe_call (__pthread_mutex_init, (m, NULL), \
35 (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT),(*(int *)(m))) )
36 # define mutex_lock(m) \
37 __libc_maybe_call (__pthread_mutex_lock, (m), \
38 (__load_and_clear(&((m)->__m_lock.__spinlock)), 0))
39 # define mutex_trylock(m) \
40 __libc_maybe_call (__pthread_mutex_trylock, (m), \
41 (*(int *)(m) ? 1 : (__load_and_clear(&((m)->__m_lock.__spinlock)), 0)))
42 # define mutex_unlock(m) \
43 __libc_maybe_call (__pthread_mutex_unlock, (m), \
44 (((m)->__m_lock.__spinlock = __LT_SPINLOCK_INIT), (*(int *)(m))) )
46 /* This is defined by newer gcc version unique for each module. */
47 extern void *__dso_handle __attribute__ ((__weak__));
52 # define thread_atfork(prepare, parent, child) \
53 __register_atfork (prepare, parent, child, __dso_handle)
55 # define thread_atfork(prepare, parent, child) \
56 __register_atfork (prepare, parent, child, \
57 &__dso_handle == NULL ? NULL : __dso_handle)
60 /* thread specific data for glibc */
62 #include <bits/libc-tsd.h>
64 typedef int tsd_key_t[1]; /* no key data structure, libc magic does it */
65 __libc_tsd_define (static, MALLOC) /* declaration/common definition */
66 #define tsd_key_create(key, destr) ((void) (key))
67 #define tsd_setspecific(key, data) __libc_tsd_set (MALLOC, (data))
68 #define tsd_getspecific(key, vptr) ((vptr) = __libc_tsd_get (MALLOC))
70 #include <sysdeps/generic/malloc-machine.h>
72 #endif /* !defined(_MALLOC_MACHINE_H) */