libc_private.h revision 122069
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 122069 2003-11-04 19:49:56Z 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 41122069Sdeischen#include <spinlock.h> 42122069Sdeischen 4335124Sjb/* 4435124Sjb * This global flag is non-zero when a process has created one 4535124Sjb * or more threads. It is used to avoid calling locking functions 4635124Sjb * when they are not required. 4735124Sjb */ 4835124Sjbextern int __isthreaded; 4935124Sjb 5035124Sjb/* 5135124Sjb * File lock contention is difficult to diagnose without knowing 5235124Sjb * where locks were set. Allow a debug library to be built which 5335124Sjb * records the source file and line number of each lock call. 5435124Sjb */ 5535124Sjb#ifdef _FLOCK_DEBUG 5635124Sjb#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__) 5735124Sjb#else 5871579Sdeischen#define _FLOCKFILE(x) _flockfile(x) 5935124Sjb#endif 6035124Sjb 6135124Sjb/* 6235124Sjb * Macros for locking and unlocking FILEs. These test if the 6335124Sjb * process is threaded to avoid locking when not required. 6435124Sjb */ 6535124Sjb#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) 6671579Sdeischen#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) 6735124Sjb 6893399Smarkm/* 69106866Sdeischen * Indexes into the pthread jump table. 70106866Sdeischen * 71106866Sdeischen * Warning! If you change this type, you must also change the threads 72106866Sdeischen * libraries that reference it (libc_r, libpthread). 73106866Sdeischen */ 74106866Sdeischentypedef enum { 75106866Sdeischen PJT_COND_BROADCAST, 76106866Sdeischen PJT_COND_DESTROY, 77106866Sdeischen PJT_COND_INIT, 78106866Sdeischen PJT_COND_SIGNAL, 79106866Sdeischen PJT_COND_WAIT, 80106866Sdeischen PJT_GETSPECIFIC, 81106866Sdeischen PJT_KEY_CREATE, 82106866Sdeischen PJT_KEY_DELETE, 83106866Sdeischen PJT_MAIN_NP, 84106866Sdeischen PJT_MUTEX_DESTROY, 85106866Sdeischen PJT_MUTEX_INIT, 86106866Sdeischen PJT_MUTEX_LOCK, 87106866Sdeischen PJT_MUTEX_TRYLOCK, 88106866Sdeischen PJT_MUTEX_UNLOCK, 89106866Sdeischen PJT_MUTEXATTR_DESTROY, 90106866Sdeischen PJT_MUTEXATTR_INIT, 91106866Sdeischen PJT_MUTEXATTR_SETTYPE, 92106866Sdeischen PJT_ONCE, 93106866Sdeischen PJT_RWLOCK_DESTROY, 94106866Sdeischen PJT_RWLOCK_INIT, 95106866Sdeischen PJT_RWLOCK_RDLOCK, 96106866Sdeischen PJT_RWLOCK_TRYRDLOCK, 97106866Sdeischen PJT_RWLOCK_TRYWRLOCK, 98106866Sdeischen PJT_RWLOCK_UNLOCK, 99106866Sdeischen PJT_RWLOCK_WRLOCK, 100106866Sdeischen PJT_SELF, 101106866Sdeischen PJT_SETSPECIFIC, 102106866Sdeischen PJT_SIGMASK, 103106866Sdeischen PJT_MAX 104106866Sdeischen} pjt_index_t; 105106866Sdeischen 106106870Sdeischentypedef int (*pthread_func_t)(void); 107106880Sdeischentypedef pthread_func_t pthread_func_entry_t[2]; 108106866Sdeischen 109106880Sdeischenextern pthread_func_entry_t __thr_jtable[]; 110106866Sdeischen 111106866Sdeischen/* 112111618Snectar * yplib internal interfaces 113111618Snectar */ 114111618Snectar#ifdef YP 115111618Snectarint _yp_check(char **); 116111618Snectar#endif 117111618Snectar 118111618Snectar 119111618Snectar/* 12093399Smarkm * This is a pointer in the C run-time startup code. It is used 12193399Smarkm * by getprogname() and setprogname(). 12293399Smarkm */ 12393399Smarkmextern const char *__progname; 12493399Smarkm 125122069Sdeischen/* 126122069Sdeischen * This is the lock to make malloc() thread-safe. It is externalized 127122069Sdeischen * so that thread libraries can protect malloc across fork(). 128122069Sdeischen */ 129122069Sdeischenextern spinlock_t *__malloc_lock; 130122069Sdeischen 13135124Sjb#endif /* _LIBC_PRIVATE_H_ */ 132