libc_private.h revision 106870
183098Smp/*
283098Smp * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>.
359243Sobrien * All rights reserved.
483098Smp *
583098Smp * Redistribution and use in source and binary forms, with or without
659243Sobrien * modification, are permitted provided that the following conditions
759243Sobrien * are met:
859243Sobrien * 1. Redistributions of source code must retain the above copyright
959243Sobrien *    notice, this list of conditions and the following disclaimer.
1059243Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1159243Sobrien *    notice, this list of conditions and the following disclaimer in the
1259243Sobrien *    documentation and/or other materials provided with the distribution.
1359243Sobrien * 3. All advertising materials mentioning features or use of this software
1459243Sobrien *    must display the following acknowledgement:
1559243Sobrien *	This product includes software developed by John Birrell.
1659243Sobrien * 4. Neither the name of the author nor the names of any co-contributors
1759243Sobrien *    may be used to endorse or promote products derived from this software
18100616Smp *    without specific prior written permission.
1959243Sobrien *
2059243Sobrien * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
2159243Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2259243Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2359243Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2459243Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2559243Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2659243Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2759243Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2859243Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2959243Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3059243Sobrien * SUCH DAMAGE.
3159243Sobrien *
3259243Sobrien * $FreeBSD: head/lib/libc/include/libc_private.h 106870 2002-11-13 19:35:40Z deischen $
3359243Sobrien *
3483098Smp * Private definitions for libc, libc_r and libpthread.
3559243Sobrien *
3659243Sobrien */
3759243Sobrien
3859243Sobrien#ifndef _LIBC_PRIVATE_H_
3959243Sobrien#define _LIBC_PRIVATE_H_
4059243Sobrien
4183098Smp/*
4283098Smp * This global flag is non-zero when a process has created one
4383098Smp * or more threads. It is used to avoid calling locking functions
4483098Smp * when they are not required.
4583098Smp */
4683098Smpextern int	__isthreaded;
47167465Smp
4883098Smp/*
4983098Smp * File lock contention is difficult to diagnose without knowing
5083098Smp * where locks were set. Allow a debug library to be built which
5183098Smp * records the source file and line number of each lock call.
5283098Smp */
5383098Smp#ifdef	_FLOCK_DEBUG
54167465Smp#define _FLOCKFILE(x)	_flockfile_debug(x, __FILE__, __LINE__)
55167465Smp#else
56167465Smp#define _FLOCKFILE(x)	_flockfile(x)
57167465Smp#endif
58167465Smp
5959243Sobrien/*
6059243Sobrien * Macros for locking and unlocking FILEs. These test if the
6183098Smp * process is threaded to avoid locking when not required.
6283098Smp */
6383098Smp#define	FLOCKFILE(fp)		if (__isthreaded) _FLOCKFILE(fp)
6483098Smp#define	FUNLOCKFILE(fp)		if (__isthreaded) _funlockfile(fp)
6583098Smp
6683098Smp/*
6783098Smp * Indexes into the pthread jump table.
6859243Sobrien *
6983098Smp * Warning! If you change this type, you must also change the threads
7083098Smp * libraries that reference it (libc_r, libpthread).
7183098Smp */
7283098Smptypedef enum {
7359243Sobrien	PJT_COND_BROADCAST,
74100616Smp	PJT_COND_DESTROY,
7583098Smp	PJT_COND_INIT,
7683098Smp	PJT_COND_SIGNAL,
7783098Smp	PJT_COND_WAIT,
7883098Smp	PJT_GETSPECIFIC,
7983098Smp	PJT_KEY_CREATE,
8083098Smp	PJT_KEY_DELETE,
8183098Smp	PJT_MAIN_NP,
8283098Smp	PJT_MUTEX_DESTROY,
83231990Smp	PJT_MUTEX_INIT,
84231990Smp	PJT_MUTEX_LOCK,
8559243Sobrien	PJT_MUTEX_TRYLOCK,
8683098Smp	PJT_MUTEX_UNLOCK,
87100616Smp	PJT_MUTEXATTR_DESTROY,
8883098Smp	PJT_MUTEXATTR_INIT,
89167465Smp	PJT_MUTEXATTR_SETTYPE,
90167465Smp	PJT_ONCE,
91167465Smp	PJT_RWLOCK_DESTROY,
92145479Smp	PJT_RWLOCK_INIT,
9359243Sobrien	PJT_RWLOCK_RDLOCK,
94	PJT_RWLOCK_TRYRDLOCK,
95	PJT_RWLOCK_TRYWRLOCK,
96	PJT_RWLOCK_UNLOCK,
97	PJT_RWLOCK_WRLOCK,
98	PJT_SELF,
99	PJT_SETSPECIFIC,
100	PJT_SIGMASK,
101	PJT_MAX
102} pjt_index_t;
103
104typedef int (*pthread_func_t)(void);
105
106extern pthread_func_t *__thr_jtable[];
107
108/*
109 * This is a pointer in the C run-time startup code. It is used
110 * by getprogname() and setprogname().
111 */
112extern const char *__progname;
113
114#endif /* _LIBC_PRIVATE_H_ */
115