libc_private.h revision 106866
1121663Sharti/* 2121663Sharti * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. 3121663Sharti * All rights reserved. 4121663Sharti * 5121663Sharti * Redistribution and use in source and binary forms, with or without 6131823Sharti * modification, are permitted provided that the following conditions 7131823Sharti * are met: 8121663Sharti * 1. Redistributions of source code must retain the above copyright 9121663Sharti * notice, this list of conditions and the following disclaimer. 10121663Sharti * 2. Redistributions in binary form must reproduce the above copyright 11121663Sharti * notice, this list of conditions and the following disclaimer in the 12121663Sharti * documentation and/or other materials provided with the distribution. 13121663Sharti * 3. All advertising materials mentioning features or use of this software 14121663Sharti * must display the following acknowledgement: 15121663Sharti * This product includes software developed by John Birrell. 16121663Sharti * 4. Neither the name of the author nor the names of any co-contributors 17121663Sharti * may be used to endorse or promote products derived from this software 18121663Sharti * without specific prior written permission. 19121663Sharti * 20121663Sharti * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 21121663Sharti * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22121663Sharti * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23121663Sharti * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24121663Sharti * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25121663Sharti * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26121663Sharti * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27121663Sharti * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28121663Sharti * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29146532Sharti * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30121663Sharti * SUCH DAMAGE. 31121663Sharti * 32121663Sharti * $FreeBSD: head/lib/libc/include/libc_private.h 106866 2002-11-13 18:12:09Z deischen $ 33121663Sharti * 34121663Sharti * Private definitions for libc, libc_r and libpthread. 35121663Sharti * 36121663Sharti */ 37121663Sharti 38121663Sharti#ifndef _LIBC_PRIVATE_H_ 39121663Sharti#define _LIBC_PRIVATE_H_ 40121663Sharti 41121663Sharti/* 42121663Sharti * This global flag is non-zero when a process has created one 43121663Sharti * or more threads. It is used to avoid calling locking functions 44121663Sharti * when they are not required. 45121663Sharti */ 46121663Shartiextern int __isthreaded; 47121663Sharti 48121663Sharti/* 49121663Sharti * File lock contention is difficult to diagnose without knowing 50121663Sharti * where locks were set. Allow a debug library to be built which 51121663Sharti * records the source file and line number of each lock call. 52121663Sharti */ 53121663Sharti#ifdef _FLOCK_DEBUG 54121663Sharti#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__) 55121663Sharti#else 56121663Sharti#define _FLOCKFILE(x) _flockfile(x) 57121663Sharti#endif 58121663Sharti 59121663Sharti/* 60121663Sharti * Macros for locking and unlocking FILEs. These test if the 61121663Sharti * process is threaded to avoid locking when not required. 62121663Sharti */ 63121663Sharti#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) 64121663Sharti#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) 65121663Sharti 66121663Sharti/* 67121663Sharti * Indexes into the pthread jump table. 68121663Sharti * 69121663Sharti * Warning! If you change this type, you must also change the threads 70121663Sharti * libraries that reference it (libc_r, libpthread). 71121663Sharti */ 72121663Shartitypedef enum { 73121663Sharti PJT_COND_BROADCAST, 74121663Sharti PJT_COND_DESTROY, 75121663Sharti PJT_COND_INIT, 76121663Sharti PJT_COND_SIGNAL, 77121663Sharti PJT_COND_WAIT, 78121663Sharti PJT_GETSPECIFIC, 79121663Sharti PJT_KEY_CREATE, 80121663Sharti PJT_KEY_DELETE, 81121663Sharti PJT_MAIN_NP, 82121663Sharti PJT_MUTEX_DESTROY, 83121663Sharti PJT_MUTEX_INIT, 84121663Sharti PJT_MUTEX_LOCK, 85121663Sharti PJT_MUTEX_TRYLOCK, 86121663Sharti PJT_MUTEX_UNLOCK, 87121663Sharti PJT_MUTEXATTR_DESTROY, 88121663Sharti PJT_MUTEXATTR_INIT, 89121663Sharti PJT_MUTEXATTR_SETTYPE, 90121663Sharti PJT_ONCE, 91121663Sharti PJT_RWLOCK_DESTROY, 92121663Sharti PJT_RWLOCK_INIT, 93121663Sharti PJT_RWLOCK_RDLOCK, 94121663Sharti PJT_RWLOCK_TRYRDLOCK, 95121663Sharti PJT_RWLOCK_TRYWRLOCK, 96121663Sharti PJT_RWLOCK_UNLOCK, 97135923Strhodes PJT_RWLOCK_WRLOCK, 98121663Sharti PJT_SELF, 99135923Strhodes PJT_SETSPECIFIC, 100135923Strhodes PJT_SIGMASK, 101135923Strhodes PJT_MAX 102121663Sharti} pjt_index_t; 103135923Strhodes 104121663Shartitypedef int (*pthread_func_t)(); 105121663Sharti 106121663Shartiextern pthread_func_t __thr_jtable[][]; 107121663Sharti 108121663Sharti/* 109121663Sharti * This is a pointer in the C run-time startup code. It is used 110121663Sharti * by getprogname() and setprogname(). 111121663Sharti */ 112121663Shartiextern const char *__progname; 113121663Sharti 114135923Strhodes#endif /* _LIBC_PRIVATE_H_ */ 115121663Sharti