/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright 2003 Alexander Kabaev.4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR16* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES17* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.18* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,19* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT20* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,21* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY22* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF24* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25*/2627#ifndef _RTLD_LOCK_H_28#define _RTLD_LOCK_H_2930#define RTLI_VERSION_ONE 0x0131#define RTLI_VERSION 0x023233#define MAX_RTLD_LOCKS 83435/*36* This structure is part of the ABI between rtld and threading37* libraries, like libthr and even libc_r. Its layout is fixed and38* can be changed only by appending new fields at the end, with the39* bump of RTLI_VERSION.40*/41struct RtldLockInfo42{43/*44* Valid if the object calling _rtld_thread_init() exported45* symbol _pli_rtli_version. Otherwise assume RTLI_VERSION_ONE.46*/47unsigned int rtli_version;4849void *(*lock_create)(void);50void (*lock_destroy)(void *);51void (*rlock_acquire)(void *);52void (*wlock_acquire)(void *);53void (*lock_release)(void *);54int (*thread_set_flag)(int);55int (*thread_clr_flag)(int);56void (*at_fork)(void);5758/* Version 2 fields */59char *(*dlerror_loc)(void);60int *(*dlerror_seen)(void);61int dlerror_loc_sz;62};6364#if defined(IN_RTLD) || defined(PTHREAD_KERNEL)6566void _rtld_thread_init(struct RtldLockInfo *) __exported;67void _rtld_atfork_pre(int *) __exported;68void _rtld_atfork_post(int *) __exported;6970#endif /* IN_RTLD || PTHREAD_KERNEL */7172#ifdef IN_RTLD7374struct rtld_lock;75typedef struct rtld_lock *rtld_lock_t;7677extern rtld_lock_t rtld_bind_lock;78extern rtld_lock_t rtld_libc_lock;79extern rtld_lock_t rtld_phdr_lock;8081extern struct RtldLockInfo lockinfo;8283#define RTLD_LOCK_UNLOCKED 084#define RTLD_LOCK_RLOCKED 185#define RTLD_LOCK_WLOCKED 28687struct Struct_RtldLockState;88typedef struct Struct_RtldLockState RtldLockState;8990void rlock_acquire(rtld_lock_t, RtldLockState *);91void wlock_acquire(rtld_lock_t, RtldLockState *);92void lock_release(rtld_lock_t, RtldLockState *);93void lock_upgrade(rtld_lock_t, RtldLockState *);94void lock_restart_for_upgrade(RtldLockState *);95bool lockstate_wlocked(const RtldLockState *);9697void dlerror_dflt_init(void);9899#endif /* IN_RTLD */100101#endif102103104