xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Basic platform-independent macro definitions for mutexes, |
| 2 | thread-specific data and parameters for malloc. |
| 3 | Copyright (C) 2003-2016 Free Software Foundation, Inc. |
| 4 | This file is part of the GNU C Library. |
| 5 | |
| 6 | The GNU C Library is free software; you can redistribute it and/or |
| 7 | modify it under the terms of the GNU Lesser General Public |
| 8 | License as published by the Free Software Foundation; either |
| 9 | version 2.1 of the License, or (at your option) any later version. |
| 10 | |
| 11 | The GNU C Library is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | Lesser General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU Lesser General Public |
| 17 | License along with the GNU C Library; if not, see |
| 18 | <http://www.gnu.org/licenses/>. */ |
| 19 | |
| 20 | #ifndef _MALLOC_MACHINE_H |
| 21 | #define _MALLOC_MACHINE_H |
| 22 | |
| 23 | #undef thread_atfork_static |
| 24 | |
| 25 | #include <atomic.h> |
| 26 | #include <libc-lock.h> |
| 27 | |
| 28 | __libc_lock_define (typedef, mutex_t) |
| 29 | |
| 30 | #define mutex_init(m) __libc_lock_init (*(m)) |
| 31 | #define mutex_lock(m) __libc_lock_lock (*(m)) |
| 32 | #define mutex_trylock(m) __libc_lock_trylock (*(m)) |
| 33 | #define mutex_unlock(m) __libc_lock_unlock (*(m)) |
| 34 | |
| 35 | /* This is defined by newer gcc version unique for each module. */ |
| 36 | extern void *__dso_handle __attribute__ ((__weak__)); |
| 37 | |
| 38 | #include <fork.h> |
| 39 | |
| 40 | #define ATFORK_MEM static struct fork_handler atfork_mem |
| 41 | |
| 42 | #ifdef SHARED |
| 43 | # define thread_atfork(prepare, parent, child) \ |
| 44 | atfork_mem.prepare_handler = prepare; \ |
| 45 | atfork_mem.parent_handler = parent; \ |
| 46 | atfork_mem.child_handler = child; \ |
| 47 | atfork_mem.dso_handle = __dso_handle; \ |
| 48 | atfork_mem.refcntr = 1; \ |
| 49 | __linkin_atfork (&atfork_mem) |
| 50 | #else |
| 51 | # define thread_atfork(prepare, parent, child) \ |
| 52 | atfork_mem.prepare_handler = prepare; \ |
| 53 | atfork_mem.parent_handler = parent; \ |
| 54 | atfork_mem.child_handler = child; \ |
| 55 | atfork_mem.dso_handle = &__dso_handle == NULL ? NULL : __dso_handle; \ |
| 56 | atfork_mem.refcntr = 1; \ |
| 57 | __linkin_atfork (&atfork_mem) |
| 58 | #endif |
| 59 | |
| 60 | #include <sysdeps/generic/malloc-machine.h> |
| 61 | |
| 62 | #endif /* !defined(_MALLOC_MACHINE_H) */ |