blob: c146563f70104f21b48e92b60f0ef6e8dd494b36 (
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
42
43
44
45
46
|
/* Common definitions for splice and vmsplice.
Copyright (C) 2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef SPLICE_H
# define SPLICE_H 1
# if HAVE_VMSPLICE
/* splice() and vmsplice() were introduced at the same time,
so assume splice() is available. Note AIX also has a different
splice() which is why we don't explicitly check for that function. */
# define HAVE_SPLICE 1
/* Empirically determined pipe size for best throughput.
Needs to be <= /proc/sys/fs/pipe-max-size */
enum { SPLICE_PIPE_SIZE = 512 * 1024 };
static inline idx_t
increase_pipe_size (int fd)
{
int pipe_cap = 0;
# if defined F_SETPIPE_SZ && defined F_GETPIPE_SZ
if ((pipe_cap = fcntl (fd, F_SETPIPE_SZ, SPLICE_PIPE_SIZE)) < 0)
pipe_cap = fcntl (fd, F_GETPIPE_SZ);
# endif
if (pipe_cap <= 0)
pipe_cap = 64 * 1024;
return pipe_cap;
}
# endif
#endif
|