Deleted Added
full compact
thr_writev.c (36830) thr_writev.c (36877)
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $Id: uthread_writev.c,v 1.7 1998/05/27 00:44:58 jb Exp $
32 * $Id: uthread_writev.c,v 1.8 1998/06/09 23:21:05 jb Exp $
33 *
34 */
35#include <sys/types.h>
36#include <sys/fcntl.h>
37#include <sys/uio.h>
38#include <errno.h>
39#include <stdlib.h>
40#include <string.h>
41#include <unistd.h>
42#ifdef _THREAD_SAFE
43#include <pthread.h>
44#include "pthread_private.h"
45
46ssize_t
47writev(int fd, const struct iovec * iov, int iovcnt)
48{
49 int blocking;
50 int idx = 0;
33 *
34 */
35#include <sys/types.h>
36#include <sys/fcntl.h>
37#include <sys/uio.h>
38#include <errno.h>
39#include <stdlib.h>
40#include <string.h>
41#include <unistd.h>
42#ifdef _THREAD_SAFE
43#include <pthread.h>
44#include "pthread_private.h"
45
46ssize_t
47writev(int fd, const struct iovec * iov, int iovcnt)
48{
49 int blocking;
50 int idx = 0;
51 int type;
51 ssize_t cnt;
52 ssize_t n;
53 ssize_t num = 0;
54 ssize_t ret;
55 struct iovec liov[20];
56 struct iovec *p_iov = liov;
57
58 /* Check if the array size exceeds to compiled in size: */

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

66 }
67 }
68
69 /* Copy the caller's array so that it can be modified locally: */
70 memcpy(p_iov,iov,iovcnt * sizeof(struct iovec));
71
72 /* Lock the file descriptor for write: */
73 if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
52 ssize_t cnt;
53 ssize_t n;
54 ssize_t num = 0;
55 ssize_t ret;
56 struct iovec liov[20];
57 struct iovec *p_iov = liov;
58
59 /* Check if the array size exceeds to compiled in size: */

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

67 }
68 }
69
70 /* Copy the caller's array so that it can be modified locally: */
71 memcpy(p_iov,iov,iovcnt * sizeof(struct iovec));
72
73 /* Lock the file descriptor for write: */
74 if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
75 /* Get the read/write mode type: */
76 type = _thread_fd_table[fd]->flags & O_ACCMODE;
77
78 /* Check if the file is not open for write: */
79 if (type != O_WRONLY && type != O_RDWR) {
80 /* File is not open for write: */
81 errno = EBADF;
82 _FD_UNLOCK(fd, FD_WRITE);
83 return (-1);
84 }
85
74 /* Check if file operations are to block */
75 blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
76
77 /*
78 * Loop while no error occurs and until the expected number
79 * of bytes are written if performing a blocking write:
80 */
81 while (ret == 0) {

--- 98 unchanged lines hidden ---
86 /* Check if file operations are to block */
87 blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
88
89 /*
90 * Loop while no error occurs and until the expected number
91 * of bytes are written if performing a blocking write:
92 */
93 while (ret == 0) {

--- 98 unchanged lines hidden ---