libc_private.h revision 71579
1219820Sjeff/* 2219820Sjeff * Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>. 3219820Sjeff * All rights reserved. 4219820Sjeff * 5219820Sjeff * Redistribution and use in source and binary forms, with or without 6219820Sjeff * modification, are permitted provided that the following conditions 7219820Sjeff * are met: 8219820Sjeff * 1. Redistributions of source code must retain the above copyright 9219820Sjeff * notice, this list of conditions and the following disclaimer. 10219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright 11219820Sjeff * notice, this list of conditions and the following disclaimer in the 12219820Sjeff * documentation and/or other materials provided with the distribution. 13219820Sjeff * 3. All advertising materials mentioning features or use of this software 14219820Sjeff * must display the following acknowledgement: 15219820Sjeff * This product includes software developed by John Birrell. 16219820Sjeff * 4. Neither the name of the author nor the names of any co-contributors 17219820Sjeff * may be used to endorse or promote products derived from this software 18219820Sjeff * without specific prior written permission. 19219820Sjeff * 20219820Sjeff * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 21219820Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22219820Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23219820Sjeff * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24219820Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25219820Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26219820Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27219820Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28219820Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29219820Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30219820Sjeff * SUCH DAMAGE. 31219820Sjeff * 32219820Sjeff * $FreeBSD: head/lib/libc/include/libc_private.h 71579 2001-01-24 13:01:12Z deischen $ 33219820Sjeff * 34219820Sjeff * Private definitions for libc, libc_r and libpthread. 35219820Sjeff * 36219820Sjeff */ 37219820Sjeff 38219820Sjeff#ifndef _LIBC_PRIVATE_H_ 39219820Sjeff#define _LIBC_PRIVATE_H_ 40219820Sjeff 41219820Sjeff/* 42219820Sjeff * This global flag is non-zero when a process has created one 43219820Sjeff * or more threads. It is used to avoid calling locking functions 44219820Sjeff * when they are not required. 45219820Sjeff */ 46219820Sjeffextern int __isthreaded; 47219820Sjeff 48219820Sjeff/* 49219820Sjeff * File lock contention is difficult to diagnose without knowing 50219820Sjeff * where locks were set. Allow a debug library to be built which 51219820Sjeff * records the source file and line number of each lock call. 52219820Sjeff */ 53219820Sjeff#ifdef _FLOCK_DEBUG 54219820Sjeff#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__) 55219820Sjeff#else 56219820Sjeff#define _FLOCKFILE(x) _flockfile(x) 57219820Sjeff#endif 58219820Sjeff 59219820Sjeff/* 60219820Sjeff * Macros for locking and unlocking FILEs. These test if the 61219820Sjeff * process is threaded to avoid locking when not required. 62219820Sjeff */ 63219820Sjeff#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp) 64219820Sjeff#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp) 65219820Sjeff 66219820Sjeff#endif /* _LIBC_PRIVATE_H_ */ 67219820Sjeff