Deleted Added
full compact
fwrite.c (165903) fwrite.c (195637)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#if defined(LIBC_SCCS) && !defined(lint)
34static char sccsid[] = "@(#)fwrite.c 8.1 (Berkeley) 6/4/93";
35#endif /* LIBC_SCCS and not lint */
36#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#if defined(LIBC_SCCS) && !defined(lint)
34static char sccsid[] = "@(#)fwrite.c 8.1 (Berkeley) 6/4/93";
35#endif /* LIBC_SCCS and not lint */
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/lib/libc/stdio/fwrite.c 165903 2007-01-09 00:28:16Z imp $");
37__FBSDID("$FreeBSD: head/lib/libc/stdio/fwrite.c 195637 2009-07-12 13:09:43Z ed $");
38
39#include "namespace.h"
40#include <stdio.h>
41#include "un-namespace.h"
42#include "local.h"
43#include "fvwrite.h"
44#include "libc_private.h"
45

--- 6 unchanged lines hidden (view full) ---

52 const void * __restrict buf;
53 size_t size, count;
54 FILE * __restrict fp;
55{
56 size_t n;
57 struct __suio uio;
58 struct __siov iov;
59
38
39#include "namespace.h"
40#include <stdio.h>
41#include "un-namespace.h"
42#include "local.h"
43#include "fvwrite.h"
44#include "libc_private.h"
45

--- 6 unchanged lines hidden (view full) ---

52 const void * __restrict buf;
53 size_t size, count;
54 FILE * __restrict fp;
55{
56 size_t n;
57 struct __suio uio;
58 struct __siov iov;
59
60 /*
61 * ANSI and SUSv2 require a return value of 0 if size or count are 0.
62 */
63 n = count * size;
64 if (n == 0)
65 return (0);
66
60 iov.iov_base = (void *)buf;
67 iov.iov_base = (void *)buf;
61 uio.uio_resid = iov.iov_len = n = count * size;
68 uio.uio_resid = iov.iov_len = n;
62 uio.uio_iov = &iov;
63 uio.uio_iovcnt = 1;
64
65 FLOCKFILE(fp);
66 ORIENT(fp, -1);
67 /*
68 * The usual case is success (__sfvwrite returns 0);
69 * skip the divide if this happens, since divides are
70 * generally slow and since this occurs whenever size==0.
71 */
72 if (__sfvwrite(fp, &uio) != 0)
73 count = (n - uio.uio_resid) / size;
74 FUNLOCKFILE(fp);
75 return (count);
76}
69 uio.uio_iov = &iov;
70 uio.uio_iovcnt = 1;
71
72 FLOCKFILE(fp);
73 ORIENT(fp, -1);
74 /*
75 * The usual case is success (__sfvwrite returns 0);
76 * skip the divide if this happens, since divides are
77 * generally slow and since this occurs whenever size==0.
78 */
79 if (__sfvwrite(fp, &uio) != 0)
80 count = (n - uio.uio_resid) / size;
81 FUNLOCKFILE(fp);
82 return (count);
83}