Back to index

glibc  2.9
malloc-machine.h
Go to the documentation of this file.
00001 /* Basic platform-independent macro definitions for mutexes,
00002    thread-specific data and parameters for malloc.
00003    Copyright (C) 2003, 2008 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #ifndef _MALLOC_MACHINE_H
00022 #define _MALLOC_MACHINE_H
00023 
00024 #undef thread_atfork_static
00025 
00026 #include <atomic.h>
00027 #include <bits/libc-lock.h>
00028 
00029 /* Assume hurd, with cthreads */
00030 
00031 /* Cthreads `mutex_t' is a pointer to a mutex, and malloc wants just the
00032    mutex itself.  */
00033 #undef mutex_t
00034 #define mutex_t struct mutex
00035 
00036 #undef mutex_init
00037 #define mutex_init(m) (__mutex_init(m), 0)
00038 
00039 #undef mutex_lock
00040 #define mutex_lock(m) (__mutex_lock(m), 0)
00041 
00042 #undef mutex_unlock
00043 #define mutex_unlock(m) (__mutex_unlock(m), 0)
00044 
00045 #define mutex_trylock(m) (!__mutex_trylock(m))
00046 
00047 #define thread_atfork(prepare, parent, child) do {} while(0)
00048 #define thread_atfork_static(prepare, parent, child) \
00049  text_set_element(_hurd_fork_prepare_hook, prepare); \
00050  text_set_element(_hurd_fork_parent_hook, parent); \
00051  text_set_element(_hurd_fork_child_hook, child);
00052 
00053 /* No we're *not* using pthreads.  */
00054 #define __pthread_initialize ((void (*)(void))0)
00055 
00056 /* thread specific data for glibc */
00057 
00058 #include <bits/libc-tsd.h>
00059 
00060 typedef int tsd_key_t[1];   /* no key data structure, libc magic does it */
00061 __libc_tsd_define (static, void *, MALLOC)       /* declaration/common definition */
00062 #define tsd_key_create(key, destr) ((void) (key))
00063 #define tsd_setspecific(key, data) __libc_tsd_set (void *, MALLOC, (data))
00064 #define tsd_getspecific(key, vptr) ((vptr) = __libc_tsd_get (void *, MALLOC))
00065 
00066 #include <sysdeps/generic/malloc-machine.h>
00067 
00068 #endif /* !defined(_MALLOC_MACHINE_H) */