2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * Used to inform libc_init() that we are on the primary link map, 2N/A * and to cause certain functions (like malloc() and sbrk()) to fail 2N/A * (with ENOTSUP) when they are called on an alternate link map. 2N/A * Grow the TLS module information array as necessary to include the 2N/A * specified module-id. tls_modinfo->tls_size must be a power of two. 2N/A * Return a pointer to the (possibly reallocated) module information array. 2N/A * This is called from the dynamic linker, before libc_init() is called, 2N/A * to setup all of the TLS blocks that are available at process startup 2N/A * and hence must be included as part of the static TLS block. 2N/A * No locks are needed because we are single-threaded at this point. 2N/A * We must be careful not to call any function that could possibly 2N/A * invoke the dynamic linker. That is, we must only call functions 2N/A * that are wholly private to libc. 2N/A * Retrieve whatever dynamic TLS metadata was generated by code 2N/A * running on alternate link maps prior to now (we must be running 2N/A * on the primary link map now since __tls_static_mods() is only 2N/A * called on the primary link map). 2N/A * We call lmalloc() to allocate the template even though libc_init() 2N/A * has not yet been called. lmalloc() must and does deal with this. 2N/A * Initialize the static TLS template. 2N/A * We make no assumptions about the order in memory of the TLS 2N/A * modules we are processing, only that they fit within the 2N/A * total size we are given and that they are self-consistent. 2N/A * We do not assume any order for the moduleid's; we only assume 2N/A * that they are reasonably small integers. 2N/A * Record the static TLS_modinfo information. 2N/A * Copy the new tls_metadata back to the old, if any, 2N/A * since it will be copied up again in libc_init(). 2N/A * This is called from the dynamic linker for each module not included 2N/A * in the static TLS mod list, after the module has been loaded but 2N/A * before any of the module's init code has been executed. 2N/A * Called for each module as it is unloaded from memory by dlclose(). 2N/A * Return the address of a TLS variable for the current thread. 2N/A * Run the constructors for newly-allocated dynamic TLS. 2N/A * Defer signals until we have finished calling 2N/A * all of the constructors. 2N/A /* remember the constructors */ 2N/A * Call constructors, if any, in ascending order. 2N/A * We have to do this after dropping tls_lock because 2N/A * we have no idea what the constructors will do. 2N/A * At least we have signals deferred until they are done. 2N/A * For speed, we do not make reference to any static data in this function. 2N/A * If necessary to do so, we do a tail call to slow_tls_get_addr(). 2N/A#
endif /* TLS_GET_ADDR_IS_WRITTEN_IN_ASSEMBLER */ 2N/A * This is called by _thrp_setup() to initialize the thread's static TLS. 2N/A * Constructors for initially allocated static TLS are called here. 2N/A /* static TLS initialization */ 2N/A /* call TLS constructors for the static TLS just initialized */ 2N/A * Resume where we left off in the module array. 2N/A * dropped and reacquired tls_lock, but TLS modules 2N/A * retain their positions in the new array. 2N/A * Call constructors for this module if there are any 2N/A * to be called and if it is part of the static TLS. 2N/A * Call the constructors in ascending order. 2N/A * We must drop tls_lock while doing this because 2N/A * we have no idea what the constructors will do. 2N/A * This is called by _thrp_exit() to deallocate the thread's TLS. 2N/A * Destructors for all allocated TLS are called here. 2N/A return;
/* no TLS */ 2N/A * Call TLS destructors for all TLS allocated for this thread. 2N/A * Resume where we left off in the module array. 2N/A * dropped and reacquired tls_lock, but TLS modules 2N/A * retain their positions in the new array. 2N/A * Call destructors for this module if there are any 2N/A * to be called and if it is part of the static TLS or 2N/A * if the dynamic TLS for the module has been allocated. 2N/A * Call the destructors in descending order. 2N/A * We must drop tls_lock while doing this because 2N/A * we have no idea what the destructors will do. 2N/A * We only free the dynamically allocated TLS; the statically 2N/A * allocated TLS is reused when the ulwp_t is reallocated.