sd: remove 'ssd' driver support
[unleashed/tickless.git] / usr / src / lib / libsendfile / common / sendfile.c
blobf4f772484392e30deaa27fe1c7a72a0a330e9598
2 /*
3 * CDDL HEADER START
5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License (the "License").
7 * You may not use this file except in compliance with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * sendfilev is the native interface : 32 bit app on 32 bit kernel
31 * and 64 bit app on 64 bit kernel. sendfilev64() is used by
32 * 32 bit apps on a 64 bit kernel or 32 bit kernel for large
33 * file offsets. Similar things apply to sendfile.
36 #pragma weak sendfilev = _sendfilev
37 #pragma weak sendfile = _sendfile
39 #include <sys/types.h>
40 #include <sys/syscall.h>
41 #include <sys/sendfile.h>
42 #include <errno.h>
44 ssize_t
45 _sendfilev(int sock, const struct sendfilevec *vec, int sfvcnt, size_t *xferred)
47 sysret_t rval;
48 int error;
50 error = __systemcall(&rval, SYS_sendfilev, SENDFILEV, sock, vec,
51 sfvcnt, xferred);
52 if (error != 0) {
53 if (error == EINTR && *xferred != 0) {
54 rval.sys_rval1 = *xferred;
55 } else {
56 (void) __set_errno(error);
59 return ((ssize_t)rval.sys_rval1);
62 ssize_t
63 _sendfile(int sock, int fd, off_t *off, size_t len)
65 sysret_t rval;
66 int error;
67 struct sendfilevec sfv;
68 size_t xferred;
70 sfv.sfv_fd = fd;
71 sfv.sfv_flag = 0;
72 sfv.sfv_off = *off;
73 sfv.sfv_len = len;
74 error = __systemcall(&rval, SYS_sendfilev, SENDFILEV, sock, &sfv,
75 1, &xferred);
76 *off += xferred;
77 if (error != 0) {
78 if (error == EINTR && xferred != 0) {
79 rval.sys_rval1 = xferred;
80 } else {
81 (void) __set_errno(error);
84 return ((ssize_t)rval.sys_rval1);
87 #if (!defined(_LP64))
89 #pragma weak sendfilev64 = _sendfilev64
90 #pragma weak sendfile64 = _sendfile64
92 ssize_t
93 _sendfilev64(int sock, const struct sendfilevec64 *vec, int sfvcnt,
94 size_t *xferred)
96 sysret_t rval;
97 int error;
99 error = __systemcall(&rval, SYS_sendfilev, SENDFILEV64, sock, vec,
100 sfvcnt, xferred);
101 if (error != 0) {
102 if (error == EINTR && *xferred != 0) {
103 rval.sys_rval1 = *xferred;
104 } else {
105 (void) __set_errno(error);
108 return ((ssize_t)rval.sys_rval1);
111 ssize_t
112 _sendfile64(int sock, int fd, off64_t *off, size_t len)
114 sysret_t rval;
115 int error;
116 struct sendfilevec64 sfv;
117 size_t xferred;
119 sfv.sfv_fd = fd;
120 sfv.sfv_flag = 0;
121 sfv.sfv_off = *off;
122 sfv.sfv_len = len;
123 error = __systemcall(&rval, SYS_sendfilev, SENDFILEV64, sock, &sfv,
124 1, &xferred);
125 *off += xferred;
126 if (error != 0) {
127 if (error == EINTR && xferred != 0) {
128 rval.sys_rval1 = xferred;
129 } else {
130 (void) __set_errno(error);
133 return ((ssize_t)rval.sys_rval1);
135 #endif