libc_private.h revision 50476
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 50476 1999-08-28 00:22:10Z peter $
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
5635759Sjb#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)
6435759Sjb#define	FUNLOCKFILE(fp)		if (__isthreaded) funlockfile(fp)
6535124Sjb
6635124Sjb#endif /* _LIBC_PRIVATE_H_ */
67