libc_private.h revision 106870
169800Stomsoft/* 269800Stomsoft * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. 369800Stomsoft * All rights reserved. 469800Stomsoft * 569800Stomsoft * Redistribution and use in source and binary forms, with or without 669800Stomsoft * modification, are permitted provided that the following conditions 769800Stomsoft * are met: 869800Stomsoft * 1. Redistributions of source code must retain the above copyright 969800Stomsoft * notice, this list of conditions and the following disclaimer. 1069800Stomsoft * 2. Redistributions in binary form must reproduce the above copyright 1169800Stomsoft * notice, this list of conditions and the following disclaimer in the 1269800Stomsoft * documentation and/or other materials provided with the distribution. 1369800Stomsoft * 3. All advertising materials mentioning features or use of this software 1469800Stomsoft * must display the following acknowledgement: 1569800Stomsoft * This product includes software developed by John Birrell. 1669800Stomsoft * 4. Neither the name of the author nor the names of any co-contributors 1769800Stomsoft * may be used to endorse or promote products derived from this software 1869800Stomsoft * without specific prior written permission. 1969800Stomsoft * 2069800Stomsoft * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 2169800Stomsoft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2269800Stomsoft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2369800Stomsoft * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2469800Stomsoft * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2569800Stomsoft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2669800Stomsoft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2769800Stomsoft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2869800Stomsoft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2969800Stomsoft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3069800Stomsoft * SUCH DAMAGE. 3169800Stomsoft * 3269800Stomsoft * $FreeBSD: head/lib/libc/include/libc_private.h 106870 2002-11-13 19:35:40Z deischen $ 3369800Stomsoft * 3469800Stomsoft * Private definitions for libc, libc_r and libpthread. 3569800Stomsoft * 3669800Stomsoft */ 3769800Stomsoft 3869800Stomsoft#ifndef _LIBC_PRIVATE_H_ 3969800Stomsoft#define _LIBC_PRIVATE_H_ 4069800Stomsoft 4169800Stomsoft/* 4269800Stomsoft * This global flag is non-zero when a process has created one 4369800Stomsoft * or more threads. It is used to avoid calling locking functions 4469800Stomsoft * when they are not required. 4569800Stomsoft */ 4669800Stomsoftextern int __isthreaded; 4769800Stomsoft 4869800Stomsoft/* 4969800Stomsoft * File lock contention is difficult to diagnose without knowing 5069800Stomsoft * where locks were set. Allow a debug library to be built which 5169800Stomsoft * records the source file and line number of each lock call. 5269800Stomsoft */ 5369800Stomsoft#ifdef _FLOCK_DEBUG 5469800Stomsoft#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__) 5569800Stomsoft#else 5669800Stomsoft#define _FLOCKFILE(x) _flockfile(x) 57118915Srwatson#endif 58118915Srwatson 59118915Srwatson/* 6069800Stomsoft * Macros for locking and unlocking FILEs. These test if the 6169800Stomsoft * process is threaded to avoid locking when not required. 6269800Stomsoft */ 6369800Stomsoft#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) 6469800Stomsoft#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) 6569800Stomsoft 6669800Stomsoft/* 6769800Stomsoft * Indexes into the pthread jump table. 6869800Stomsoft * 6969800Stomsoft * Warning! If you change this type, you must also change the threads 7069800Stomsoft * libraries that reference it (libc_r, libpthread). 7169800Stomsoft */ 7269800Stomsofttypedef enum { 73118915Srwatson PJT_COND_BROADCAST, 74118915Srwatson PJT_COND_DESTROY, 75118915Srwatson PJT_COND_INIT, 7669800Stomsoft PJT_COND_SIGNAL, 7769800Stomsoft PJT_COND_WAIT, 7869800Stomsoft PJT_GETSPECIFIC, 7969800Stomsoft PJT_KEY_CREATE, 8069800Stomsoft PJT_KEY_DELETE, 81118915Srwatson PJT_MAIN_NP, 8269800Stomsoft PJT_MUTEX_DESTROY, 83118915Srwatson PJT_MUTEX_INIT, 8469800Stomsoft PJT_MUTEX_LOCK, 8569800Stomsoft PJT_MUTEX_TRYLOCK, 8669800Stomsoft PJT_MUTEX_UNLOCK, 8769800Stomsoft PJT_MUTEXATTR_DESTROY, 8869800Stomsoft PJT_MUTEXATTR_INIT, 89131720Sstefanf PJT_MUTEXATTR_SETTYPE, 9069800Stomsoft PJT_ONCE, 9169800Stomsoft PJT_RWLOCK_DESTROY, 9269800Stomsoft PJT_RWLOCK_INIT, 9369800Stomsoft PJT_RWLOCK_RDLOCK, 9469800Stomsoft PJT_RWLOCK_TRYRDLOCK, 9569800Stomsoft PJT_RWLOCK_TRYWRLOCK, 9669800Stomsoft PJT_RWLOCK_UNLOCK, 9769800Stomsoft PJT_RWLOCK_WRLOCK, 9869800Stomsoft PJT_SELF, 9969800Stomsoft PJT_SETSPECIFIC, 10069800Stomsoft PJT_SIGMASK, 10169800Stomsoft PJT_MAX 10269800Stomsoft} pjt_index_t; 10369800Stomsoft 10469800Stomsofttypedef int (*pthread_func_t)(void); 10569800Stomsoft 10669800Stomsoftextern pthread_func_t *__thr_jtable[]; 10769800Stomsoft 10869800Stomsoft/* 10969800Stomsoft * This is a pointer in the C run-time startup code. It is used 11069800Stomsoft * by getprogname() and setprogname(). 11169800Stomsoft */ 11269800Stomsoftextern const char *__progname; 11369800Stomsoft 11469800Stomsoft#endif /* _LIBC_PRIVATE_H_ */ 11569800Stomsoft