Detect FPU by checking CPUID features.
[dragonfly.git] / contrib / bind-9.5.2 / lib / bind / bsd / writev.c
blob65baa71cfc92f82694de5d6b506251433f414aba
1 #ifndef LINT
2 static const char rcsid[] = "$Id: writev.c,v 1.3 2005/04/27 04:56:13 sra Exp $";
3 #endif
5 #include "port_before.h"
7 #include <sys/types.h>
8 #include <sys/uio.h>
9 #include <sys/stat.h>
10 #include <sys/socket.h>
12 #include "port_after.h"
14 #ifndef NEED_WRITEV
15 int __bindcompat_writev;
16 #else
18 #ifdef _CRAY
19 #define OWN_WRITEV
20 int
21 __writev(int fd, struct iovec *iov, int iovlen)
23 struct stat statbuf;
25 if (fstat(fd, &statbuf) < 0)
26 return (-1);
29 * Allow for atomic writes to network.
31 if (statbuf.st_mode & S_IFSOCK) {
32 struct msghdr mesg;
34 memset(&mesg, 0, sizeof(mesg));
35 mesg.msg_name = 0;
36 mesg.msg_namelen = 0;
37 mesg.msg_iov = iov;
38 mesg.msg_iovlen = iovlen;
39 mesg.msg_accrights = 0;
40 mesg.msg_accrightslen = 0;
41 return (sendmsg(fd, &mesg, 0));
42 } else {
43 struct iovec *tv;
44 int i, rcode = 0, count = 0;
46 for (i = 0, tv = iov; i <= iovlen; tv++) {
47 rcode = write(fd, tv->iov_base, tv->iov_len);
49 if (rcode < 0)
50 break;
52 count += rcode;
55 if (count == 0)
56 return (rcode);
57 else
58 return (count);
62 #else /*_CRAY*/
64 int
65 __writev(fd, vp, vpcount)
66 int fd;
67 const struct iovec *vp;
68 int vpcount;
70 int count = 0;
72 while (vpcount-- > 0) {
73 int written = write(fd, vp->iov_base, vp->iov_len);
75 if (written < 0)
76 return (-1);
77 count += written;
78 if (written != vp->iov_len)
79 break;
80 vp++;
82 return (count);
85 #endif /*_CRAY*/
87 #endif /*NEED_WRITEV*/
89 /*! \file */