libc_private.h revision 106880
135124Sjb/* 235124Sjb * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. 335124Sjb * All rights reserved. 435124Sjb * 535124Sjb * Redistribution and use in source and binary forms, with or without 635124Sjb * modification, are permitted provided that the following conditions 735124Sjb * are met: 835124Sjb * 1. Redistributions of source code must retain the above copyright 935124Sjb * notice, this list of conditions and the following disclaimer. 1035124Sjb * 2. Redistributions in binary form must reproduce the above copyright 1135124Sjb * notice, this list of conditions and the following disclaimer in the 1235124Sjb * documentation and/or other materials provided with the distribution. 1335124Sjb * 3. All advertising materials mentioning features or use of this software 1435124Sjb * must display the following acknowledgement: 1535124Sjb * This product includes software developed by John Birrell. 1635124Sjb * 4. Neither the name of the author nor the names of any co-contributors 1735124Sjb * may be used to endorse or promote products derived from this software 1835124Sjb * without specific prior written permission. 1935124Sjb * 2035124Sjb * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 2135124Sjb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2235124Sjb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2335124Sjb * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2435124Sjb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2535124Sjb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2635124Sjb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2735124Sjb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2835124Sjb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2935124Sjb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3035124Sjb * SUCH DAMAGE. 3135124Sjb * 3250476Speter * $FreeBSD: head/lib/libc/include/libc_private.h 106880 2002-11-13 21:55:22Z deischen $ 3335124Sjb * 3435124Sjb * Private definitions for libc, libc_r and libpthread. 3535124Sjb * 3635124Sjb */ 3735124Sjb 3835124Sjb#ifndef _LIBC_PRIVATE_H_ 3935124Sjb#define _LIBC_PRIVATE_H_ 4035124Sjb 4135124Sjb/* 4235124Sjb * This global flag is non-zero when a process has created one 4335124Sjb * or more threads. It is used to avoid calling locking functions 4435124Sjb * when they are not required. 4535124Sjb */ 4635124Sjbextern int __isthreaded; 4735124Sjb 4835124Sjb/* 4935124Sjb * File lock contention is difficult to diagnose without knowing 5035124Sjb * where locks were set. Allow a debug library to be built which 5135124Sjb * records the source file and line number of each lock call. 5235124Sjb */ 5335124Sjb#ifdef _FLOCK_DEBUG 5435124Sjb#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__) 5535124Sjb#else 5671579Sdeischen#define _FLOCKFILE(x) _flockfile(x) 5735124Sjb#endif 5835124Sjb 5935124Sjb/* 6035124Sjb * Macros for locking and unlocking FILEs. These test if the 6135124Sjb * process is threaded to avoid locking when not required. 6235124Sjb */ 6335124Sjb#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) 6471579Sdeischen#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) 6535124Sjb 6693399Smarkm/* 67106866Sdeischen * Indexes into the pthread jump table. 68106866Sdeischen * 69106866Sdeischen * Warning! If you change this type, you must also change the threads 70106866Sdeischen * libraries that reference it (libc_r, libpthread). 71106866Sdeischen */ 72106866Sdeischentypedef enum { 73106866Sdeischen PJT_COND_BROADCAST, 74106866Sdeischen PJT_COND_DESTROY, 75106866Sdeischen PJT_COND_INIT, 76106866Sdeischen PJT_COND_SIGNAL, 77106866Sdeischen PJT_COND_WAIT, 78106866Sdeischen PJT_GETSPECIFIC, 79106866Sdeischen PJT_KEY_CREATE, 80106866Sdeischen PJT_KEY_DELETE, 81106866Sdeischen PJT_MAIN_NP, 82106866Sdeischen PJT_MUTEX_DESTROY, 83106866Sdeischen PJT_MUTEX_INIT, 84106866Sdeischen PJT_MUTEX_LOCK, 85106866Sdeischen PJT_MUTEX_TRYLOCK, 86106866Sdeischen PJT_MUTEX_UNLOCK, 87106866Sdeischen PJT_MUTEXATTR_DESTROY, 88106866Sdeischen PJT_MUTEXATTR_INIT, 89106866Sdeischen PJT_MUTEXATTR_SETTYPE, 90106866Sdeischen PJT_ONCE, 91106866Sdeischen PJT_RWLOCK_DESTROY, 92106866Sdeischen PJT_RWLOCK_INIT, 93106866Sdeischen PJT_RWLOCK_RDLOCK, 94106866Sdeischen PJT_RWLOCK_TRYRDLOCK, 95106866Sdeischen PJT_RWLOCK_TRYWRLOCK, 96106866Sdeischen PJT_RWLOCK_UNLOCK, 97106866Sdeischen PJT_RWLOCK_WRLOCK, 98106866Sdeischen PJT_SELF, 99106866Sdeischen PJT_SETSPECIFIC, 100106866Sdeischen PJT_SIGMASK, 101106866Sdeischen PJT_MAX 102106866Sdeischen} pjt_index_t; 103106866Sdeischen 104106870Sdeischentypedef int (*pthread_func_t)(void); 105106880Sdeischentypedef pthread_func_t pthread_func_entry_t[2]; 106106866Sdeischen 107106880Sdeischenextern pthread_func_entry_t __thr_jtable[]; 108106866Sdeischen 109106866Sdeischen/* 11093399Smarkm * This is a pointer in the C run-time startup code. It is used 11193399Smarkm * by getprogname() and setprogname(). 11293399Smarkm */ 11393399Smarkmextern const char *__progname; 11493399Smarkm 11535124Sjb#endif /* _LIBC_PRIVATE_H_ */ 116