putchar.c revision 22993
1139749Simp/*- 2119815Smarcel * Copyright (c) 1990, 1993 3119815Smarcel * The Regents of the University of California. All rights reserved. 4119815Smarcel * 5119815Smarcel * This code is derived from software contributed to Berkeley by 6119815Smarcel * Chris Torek. 7119815Smarcel * 8119815Smarcel * Redistribution and use in source and binary forms, with or without 9119815Smarcel * modification, are permitted provided that the following conditions 10119815Smarcel * are met: 11119815Smarcel * 1. Redistributions of source code must retain the above copyright 12119815Smarcel * notice, this list of conditions and the following disclaimer. 13119815Smarcel * 2. Redistributions in binary form must reproduce the above copyright 14119815Smarcel * notice, this list of conditions and the following disclaimer in the 15119815Smarcel * documentation and/or other materials provided with the distribution. 16119815Smarcel * 3. All advertising materials mentioning features or use of this software 17119815Smarcel * must display the following acknowledgement: 18119815Smarcel * This product includes software developed by the University of 19119815Smarcel * California, Berkeley and its contributors. 20119815Smarcel * 4. Neither the name of the University nor the names of its contributors 21119815Smarcel * may be used to endorse or promote products derived from this software 22119815Smarcel * without specific prior written permission. 23119815Smarcel * 24119815Smarcel * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25119815Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26119815Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27119815Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28120143Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29234194Sgrehan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30120143Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31120143Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32119815Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33119815Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34119815Smarcel * SUCH DAMAGE. 35119815Smarcel */ 36119815Smarcel 37119815Smarcel#if defined(LIBC_SCCS) && !defined(lint) 38119815Smarcel#if 0 39119815Smarcelstatic char sccsid[] = "@(#)putchar.c 8.1 (Berkeley) 6/4/93"; 40119815Smarcel#endif 41119815Smarcelstatic const char rcsid[] = 42119815Smarcel "$Id$"; 43119815Smarcel#endif /* LIBC_SCCS and not lint */ 44119815Smarcel 45119815Smarcel#include <stdio.h> 46119815Smarcel#ifdef _THREAD_SAFE 47119815Smarcel#include <pthread.h> 48119815Smarcel#include "pthread_private.h" 49119815Smarcel#endif 50119815Smarcel 51119815Smarcel#undef putchar 52119815Smarcel 53119815Smarcel/* 54119815Smarcel * A subroutine version of the macro putchar 55119815Smarcel */ 56119815Smarcelint 57119815Smarcelputchar(c) 58119815Smarcel int c; 59119815Smarcel{ 60119815Smarcel int retval; 61119815Smarcel register FILE *so = stdout; 62119815Smarcel 63119815Smarcel#ifdef _THREAD_SAFE 64119815Smarcel _thread_flockfile(so,__FILE__,__LINE__); 65119815Smarcel#endif 66119815Smarcel retval = __sputc(c, so); 67119815Smarcel#ifdef _THREAD_SAFE 68119815Smarcel _thread_funlockfile(so); 69119815Smarcel#endif 70119815Smarcel return (retval); 71119815Smarcel} 72119815Smarcel