1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in 12 * the documentation and/or other materials provided with the 13 * distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #pragma once 30 31 /** 32 * @file thread_properties.h 33 * @brief Thread properties API. 34 * 35 * https://sourceware.org/glibc/wiki/ThreadPropertiesAPI 36 * API for querying various properties of the current thread, used mostly by 37 * the sanitizers. 38 * 39 * Available since API level 31. 40 * 41 */ 42 43 #include <sys/cdefs.h> 44 #include <unistd.h> 45 46 __BEGIN_DECLS 47 48 /** 49 * Gets the bounds of static TLS for the current thread. 50 * 51 * Available since API level 31. 52 */ 53 void __libc_get_static_tls_bounds(void** __static_tls_begin, 54 void** __static_tls_end) __INTRODUCED_IN(31); 55 56 57 /** 58 * Registers callback to be called right before the thread is dead. 59 * The callbacks are chained, they are called in the order opposite to the order 60 * they were registered. 61 * 62 * The callbacks must be registered only before any threads were created. 63 * No signals may arrive during the calls to these callbacks. 64 * The callbacks may not access the thread's dynamic TLS because they will have 65 * been freed by the time these callbacks are invoked. 66 * 67 * Available since API level 31. 68 */ 69 void __libc_register_thread_exit_callback(void (*__cb)(void)) __INTRODUCED_IN(31); 70 71 /** 72 * Iterates over all dynamic TLS chunks for the given thread. 73 * The thread should have been suspended. It is undefined-behaviour if there is concurrent 74 * modification of the target thread's dynamic TLS. 75 * 76 * Available since API level 31. 77 */ 78 void __libc_iterate_dynamic_tls(pid_t __tid, 79 void (*__cb)(void* __dynamic_tls_begin, 80 void* __dynamic_tls_end, 81 size_t __dso_id, 82 void* __arg), 83 void* __arg) __INTRODUCED_IN(31); 84 85 /** 86 * Register on_creation and on_destruction callbacks, which will be called after a dynamic 87 * TLS creation and before a dynamic TLS destruction, respectively. 88 * 89 * Available since API level 31. 90 */ 91 void __libc_register_dynamic_tls_listeners( 92 void (*__on_creation)(void* __dynamic_tls_begin, 93 void* __dynamic_tls_end), 94 void (*__on_destruction)(void* __dynamic_tls_begin, 95 void* __dynamic_tls_end)) __INTRODUCED_IN(31); 96 97 __END_DECLS 98