1259698Sdim/* $NetBSD: putw.c,v 1.11 2003/08/07 16:43:29 agc Exp $ */ 2259698Sdim 3259698Sdim/*- 4259698Sdim * Copyright (c) 1990, 1993 5259698Sdim * The Regents of the University of California. All rights reserved. 6259698Sdim * 7259698Sdim * This code is derived from software contributed to Berkeley by 8259698Sdim * Chris Torek. 9259698Sdim * 10259698Sdim * Redistribution and use in source and binary forms, with or without 11259698Sdim * modification, are permitted provided that the following conditions 12259698Sdim * are met: 13259698Sdim * 1. Redistributions of source code must retain the above copyright 14259698Sdim * notice, this list of conditions and the following disclaimer. 15259698Sdim * 2. Redistributions in binary form must reproduce the above copyright 16259698Sdim * notice, this list of conditions and the following disclaimer in the 17259698Sdim * documentation and/or other materials provided with the distribution. 18259698Sdim * 3. Neither the name of the University nor the names of its contributors 19259698Sdim * may be used to endorse or promote products derived from this software 20259698Sdim * without specific prior written permission. 21259698Sdim * 22259698Sdim * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23259698Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24259698Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25259698Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26259698Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27259698Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28259698Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29259698Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30259698Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31259698Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32259698Sdim * SUCH DAMAGE. 33259698Sdim */ 34259698Sdim 35259698Sdim#include <sys/cdefs.h> 36259698Sdim#if defined(LIBC_SCCS) && !defined(lint) 37259698Sdim#if 0 38259698Sdimstatic char sccsid[] = "@(#)putw.c 8.1 (Berkeley) 6/4/93"; 39259698Sdim#else 40259698Sdim__RCSID("$NetBSD: putw.c,v 1.11 2003/08/07 16:43:29 agc Exp $"); 41259698Sdim#endif 42259698Sdim#endif /* LIBC_SCCS and not lint */ 43259698Sdim 44259698Sdim#include <assert.h> 45259698Sdim#include <errno.h> 46259698Sdim#include <stdio.h> 47259698Sdim#include "fvwrite.h" 48259698Sdim#include "reentrant.h" 49259698Sdim#include "local.h" 50259698Sdim 51259698Sdimint 52259698Sdimputw(int w, FILE *fp) 53259698Sdim{ 54259698Sdim struct __suio uio; 55259698Sdim struct __siov iov; 56259698Sdim int r; 57259698Sdim 58259698Sdim _DIAGASSERT(fp != NULL); 59259698Sdim 60259698Sdim iov.iov_base = &w; 61259698Sdim iov.iov_len = uio.uio_resid = sizeof(w); 62259698Sdim uio.uio_iov = &iov; 63259698Sdim uio.uio_iovcnt = 1; 64259698Sdim FLOCKFILE(fp); 65259698Sdim r = __sfvwrite(fp, &uio); 66259698Sdim FUNLOCKFILE(fp); 67259698Sdim return r; 68259698Sdim} 69259698Sdim