]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libpthread/linuxthreads/sysdeps/unix/sysv/linux/hppa/malloc-machine.h
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libpthread / linuxthreads / sysdeps / unix / sysv / linux / hppa / malloc-machine.h
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.
6
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.
11
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.
16
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/>.  */
20
21 #ifndef _MALLOC_MACHINE_H
22 #define _MALLOC_MACHINE_H
23
24 #undef thread_atfork_static
25
26 #include <atomic.h>
27 #include <bits/libc-lock.h>
28
29 __libc_lock_define (typedef, mutex_t)
30
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))) )
45
46 /* This is defined by newer gcc version unique for each module.  */
47 extern void *__dso_handle __attribute__ ((__weak__));
48
49 #include <fork.h>
50
51 #ifdef SHARED
52 # define thread_atfork(prepare, parent, child) \
53    __register_atfork (prepare, parent, child, __dso_handle)
54 #else
55 # define thread_atfork(prepare, parent, child) \
56    __register_atfork (prepare, parent, child,                                 \
57                       &__dso_handle == NULL ? NULL : __dso_handle)
58 #endif
59
60 /* thread specific data for glibc */
61
62 #include <bits/libc-tsd.h>
63
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))
69
70 #include <sysdeps/generic/malloc-machine.h>
71
72 #endif /* !defined(_MALLOC_MACHINE_H) */