blob: 28785e6374984c55d71c0a744b1d5317fc61f5f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* ISC license. */
#include <skalibs/sysdeps.h>
#ifdef SKALIBS_HASSPLICE
#include <skalibs/nonposix.h>
#include <fcntl.h>
#include <sys/uio.h>
#include <skalibs/buffer.h>
#include <skalibs/iobuffer.h>
#include <skalibs/siovec.h>
int iobuffer_kfromu (iobufferk_ref k, iobufferu_ref u)
{
struct iovec iov[2] ;
siovec_t v[2] ;
int r ;
buffer_rpeek(&u->b[0], v) ;
iovec_from_siovec(iov, v, 2) ;
r = vmsplice(k->p[1], iov, 2, 0) ;
if (r < 0) return 0 ;
k->n += r ;
buffer_rseek(&u->b[0], (unsigned int)r) ;
u->b[1].c.p = u->b[0].c.p ;
return iobufferu_isempty(u) ;
}
#else
#include <errno.h>
#include <skalibs/iobuffer.h>
int iobuffer_kfromu (iobufferk_ref k, iobufferu_ref u)
{
(void)k ;
(void)u ;
return (errno = ENOSYS, 0) ;
}
#endif
|