libc_private.h revision 156319
1227569Sphilip/* 2227569Sphilip * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. 3227569Sphilip * All rights reserved. 4227569Sphilip * 5227569Sphilip * Redistribution and use in source and binary forms, with or without 6227569Sphilip * modification, are permitted provided that the following conditions 7227569Sphilip * are met: 8227569Sphilip * 1. Redistributions of source code must retain the above copyright 9227569Sphilip * notice, this list of conditions and the following disclaimer. 10227569Sphilip * 2. Redistributions in binary form must reproduce the above copyright 11227569Sphilip * notice, this list of conditions and the following disclaimer in the 12227569Sphilip * documentation and/or other materials provided with the distribution. 13227569Sphilip * 3. All advertising materials mentioning features or use of this software 14227569Sphilip * must display the following acknowledgement: 15227569Sphilip * This product includes software developed by John Birrell. 16227569Sphilip * 4. Neither the name of the author nor the names of any co-contributors 17227569Sphilip * may be used to endorse or promote products derived from this software 18227569Sphilip * without specific prior written permission. 19227569Sphilip * 20227569Sphilip * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 21227569Sphilip * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22227569Sphilip * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23227569Sphilip * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24227569Sphilip * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25227569Sphilip * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26227569Sphilip * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27227569Sphilip * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28227569Sphilip * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29227569Sphilip * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30227569Sphilip * SUCH DAMAGE. 31227569Sphilip * 32227569Sphilip * $FreeBSD: head/lib/libc/include/libc_private.h 156319 2006-03-05 18:10:28Z deischen $ 33227569Sphilip * 34227699Sphilip * Private definitions for libc, libc_r and libpthread. 35227569Sphilip * 36227569Sphilip */ 37227569Sphilip 38227569Sphilip#ifndef _LIBC_PRIVATE_H_ 39227569Sphilip#define _LIBC_PRIVATE_H_ 40227569Sphilip 41227569Sphilip/* 42227569Sphilip * This global flag is non-zero when a process has created one 43227569Sphilip * or more threads. It is used to avoid calling locking functions 44227569Sphilip * when they are not required. 45227569Sphilip */ 46227569Sphilipextern int __isthreaded; 47227569Sphilip 48227569Sphilip/* 49227569Sphilip * File lock contention is difficult to diagnose without knowing 50227569Sphilip * where locks were set. Allow a debug library to be built which 51278248Sarybchik * records the source file and line number of each lock call. 52227569Sphilip */ 53279351Sarybchik#ifdef _FLOCK_DEBUG 54227569Sphilip#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__) 55227569Sphilip#else 56227569Sphilip#define _FLOCKFILE(x) _flockfile(x) 57227569Sphilip#endif 58227569Sphilip 59227569Sphilip/* 60227569Sphilip * Macros for locking and unlocking FILEs. These test if the 61227569Sphilip * process is threaded to avoid locking when not required. 62227569Sphilip */ 63227569Sphilip#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) 64227569Sphilip#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) 65227569Sphilip 66227569Sphilip/* 67227569Sphilip * Indexes into the pthread jump table. 68227569Sphilip * 69227569Sphilip * Warning! If you change this type, you must also change the threads 70227569Sphilip * libraries that reference it (libc_r, libpthread). 71227569Sphilip */ 72227569Sphiliptypedef enum { 73227569Sphilip PJT_ATFORK, 74227569Sphilip PJT_ATTR_DESTROY, 75227569Sphilip PJT_ATTR_GETDETACHSTATE, 76227569Sphilip PJT_ATTR_GETGUARDSIZE, 77272325Sgnn PJT_ATTR_GETINHERITSCHED, 78227569Sphilip PJT_ATTR_GETSCHEDPARAM, 79227569Sphilip PJT_ATTR_GETSCHEDPOLICY, 80227569Sphilip PJT_ATTR_GETSCOPE, 81227569Sphilip PJT_ATTR_GETSTACKADDR, 82227569Sphilip PJT_ATTR_GETSTACKSIZE, 83227569Sphilip PJT_ATTR_INIT, 84227569Sphilip PJT_ATTR_SETDETACHSTATE, 85272325Sgnn PJT_ATTR_SETGUARDSIZE, 86227569Sphilip PJT_ATTR_SETINHERITSCHED, 87227569Sphilip PJT_ATTR_SETSCHEDPARAM, 88279184Sarybchik PJT_ATTR_SETSCHEDPOLICY, 89279184Sarybchik PJT_ATTR_SETSCOPE, 90279184Sarybchik PJT_ATTR_SETSTACKADDR, 91279184Sarybchik PJT_ATTR_SETSTACKSIZE, 92279184Sarybchik PJT_CANCEL, 93279184Sarybchik PJT_CLEANUP_POP, 94279184Sarybchik PJT_CLEANUP_PUSH, 95279184Sarybchik PJT_COND_BROADCAST, 96279184Sarybchik PJT_COND_DESTROY, 97279184Sarybchik PJT_COND_INIT, 98279184Sarybchik PJT_COND_SIGNAL, 99279184Sarybchik PJT_COND_TIMEDWAIT, 100279184Sarybchik PJT_COND_WAIT, 101279184Sarybchik PJT_DETACH, 102279184Sarybchik PJT_EQUAL, 103279184Sarybchik PJT_EXIT, 104279184Sarybchik PJT_GETSPECIFIC, 105279184Sarybchik PJT_JOIN, 106279184Sarybchik PJT_KEY_CREATE, 107279184Sarybchik PJT_KEY_DELETE, 108279184Sarybchik PJT_KILL, 109279184Sarybchik PJT_MAIN_NP, 110279184Sarybchik PJT_MUTEXATTR_DESTROY, 111279184Sarybchik PJT_MUTEXATTR_INIT, 112279184Sarybchik PJT_MUTEXATTR_SETTYPE, 113279184Sarybchik PJT_MUTEX_DESTROY, 114279184Sarybchik PJT_MUTEX_INIT, 115279184Sarybchik PJT_MUTEX_LOCK, 116279184Sarybchik PJT_MUTEX_TRYLOCK, 117279184Sarybchik PJT_MUTEX_UNLOCK, 118279184Sarybchik PJT_ONCE, 119279184Sarybchik PJT_RWLOCK_DESTROY, 120279184Sarybchik PJT_RWLOCK_INIT, 121279184Sarybchik PJT_RWLOCK_RDLOCK, 122279184Sarybchik PJT_RWLOCK_TRYRDLOCK, 123279184Sarybchik PJT_RWLOCK_TRYWRLOCK, 124279184Sarybchik PJT_RWLOCK_UNLOCK, 125279184Sarybchik PJT_RWLOCK_WRLOCK, 126279184Sarybchik PJT_SELF, 127279184Sarybchik PJT_SETCANCELSTATE, 128279184Sarybchik PJT_SETCANCELTYPE, 129279184Sarybchik PJT_SETSPECIFIC, 130279184Sarybchik PJT_SIGMASK, 131279184Sarybchik PJT_TESTCANCEL, 132279184Sarybchik PJT_MAX 133279184Sarybchik} pjt_index_t; 134279184Sarybchik 135279184Sarybchiktypedef int (*pthread_func_t)(void); 136279184Sarybchiktypedef pthread_func_t pthread_func_entry_t[2]; 137279184Sarybchik 138279184Sarybchikextern pthread_func_entry_t __thr_jtable[]; 139279184Sarybchik 140279184Sarybchik/* 141279184Sarybchik * yplib internal interfaces 142279184Sarybchik */ 143279184Sarybchik#ifdef YP 144279184Sarybchikint _yp_check(char **); 145279184Sarybchik#endif 146279184Sarybchik 147279184Sarybchik/* 148279184Sarybchik * Initialise TLS for static programs 149279184Sarybchik */ 150227569Sphilipvoid _init_tls(void); 151227569Sphilip 152227569Sphilip/* 153227569Sphilip * Set the TLS thread pointer 154227569Sphilip */ 155227569Sphilipvoid _set_tp(void *tp); 156278838Sarybchik 157227569Sphilip/* 158278248Sarybchik * This is a pointer in the C run-time startup code. It is used 159278838Sarybchik * by getprogname() and setprogname(). 160278838Sarybchik */ 161278838Sarybchikextern const char *__progname; 162227569Sphilip 163278838Sarybchik/* 164278838Sarybchik * These functions are used by the threading libraries in order to protect 165278248Sarybchik * malloc across fork(). 166227569Sphilip */ 167227569Sphilipvoid _malloc_prefork(void); 168227569Sphilipvoid _malloc_postfork(void); 169227569Sphilip 170227569Sphilip/* 171227569Sphilip * Function to clean up streams, called from abort() and exit(). 172227569Sphilip */ 173227569Sphilipextern void (*__cleanup)(void); 174227569Sphilip 175227569Sphilip#endif /* _LIBC_PRIVATE_H_ */ 176227569Sphilip