Home | History | Annotate | Download | only in stdio
      1     0  stevel /*
      2     0  stevel  * CDDL HEADER START
      3     0  stevel  *
      4     0  stevel  * The contents of this file are subject to the terms of the
      5  6812     raf  * Common Development and Distribution License (the "License").
      6  6812     raf  * You may not use this file except in compliance with the License.
      7     0  stevel  *
      8     0  stevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9     0  stevel  * or http://www.opensolaris.org/os/licensing.
     10     0  stevel  * See the License for the specific language governing permissions
     11     0  stevel  * and limitations under the License.
     12     0  stevel  *
     13     0  stevel  * When distributing Covered Code, include this CDDL HEADER in each
     14     0  stevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15     0  stevel  * If applicable, add the following below this CDDL HEADER, with the
     16     0  stevel  * fields enclosed by brackets "[]" replaced with your own identifying
     17     0  stevel  * information: Portions Copyright [yyyy] [name of copyright owner]
     18     0  stevel  *
     19     0  stevel  * CDDL HEADER END
     20     0  stevel  */
     21  6812     raf 
     22     0  stevel /*
     23  6812     raf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     24     0  stevel  * Use is subject to license terms.
     25     0  stevel  */
     26     0  stevel 
     27     0  stevel /*	Copyright (c) 1988 AT&T	*/
     28     0  stevel /*	  All Rights Reserved  	*/
     29     0  stevel 
     30  6812     raf #pragma ident	"%Z%%M%	%I%	%E% SMI"
     31     0  stevel 
     32  6812     raf #pragma weak _putc_unlocked = putc_unlocked
     33     0  stevel 
     34  6812     raf #include "lint.h"
     35     0  stevel #include "file64.h"
     36     0  stevel #include "mtlib.h"
     37     0  stevel #include <sys/types.h>
     38     0  stevel #include <stdio.h>
     39     0  stevel #include <thread.h>
     40     0  stevel #include <synch.h>
     41     0  stevel #include "stdiom.h"
     42     0  stevel #include "mse.h"
     43     0  stevel 
     44     0  stevel #undef putc
     45     0  stevel #undef putc_unlocked
     46     0  stevel 
     47     0  stevel int
     48     0  stevel putc(int ch, FILE *iop)
     49     0  stevel {
     50     0  stevel 	rmutex_t *lk;
     51     0  stevel 	int ret;
     52     0  stevel 
     53     0  stevel 	FLOCKFILE(lk, iop);
     54     0  stevel 
     55     0  stevel 	_SET_ORIENTATION_BYTE(iop);
     56     0  stevel 
     57     0  stevel 	if (--iop->_cnt < 0)
     58     0  stevel 		ret = __flsbuf((unsigned char) ch, iop);
     59     0  stevel 	else {
     60     0  stevel 		(*iop->_ptr++) = (unsigned char)ch;
     61     0  stevel 		ret = (unsigned char)ch;
     62     0  stevel 	}
     63     0  stevel 	FUNLOCKFILE(lk);
     64     0  stevel 	return (ret);
     65     0  stevel }
     66     0  stevel 
     67     0  stevel 
     68     0  stevel int
     69  6812     raf putc_unlocked(int ch, FILE *iop)
     70     0  stevel {
     71     0  stevel 	if (--iop->_cnt < 0)
     72     0  stevel 		return (__flsbuf((unsigned char) ch, iop));
     73     0  stevel 	else
     74     0  stevel 		return (*iop->_ptr++ = (unsigned char)ch);
     75     0  stevel }
     76