safe-read, safe-write: Fix conflict with Illumos-Joyent <sys/limits.h>.
[gnulib.git] / lib / sys-limits.h
blob12611b517b5cd8a1053a3b19c0d66ae39e30d89a
1 /* System call limits
3 Copyright 2018-2019 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <https://www.gnu.org/licenses/>. */
18 #ifndef _GL_SYS_LIMITS_H
19 #define _GL_SYS_LIMITS_H
21 #include <limits.h>
23 /* Maximum number of bytes to read or write in a single system call.
24 This can be useful for system calls like sendfile on GNU/Linux,
25 which do not handle more than MAX_RW_COUNT bytes correctly.
26 The Linux kernel MAX_RW_COUNT is at least INT_MAX >> 20 << 20,
27 where the 20 comes from the Hexagon port with 1 MiB pages; use that
28 as an approximation, as the exact value may not be available to us.
30 Using this also works around a serious Linux bug before 2.6.16; see
31 <https://bugzilla.redhat.com/show_bug.cgi?id=612839>.
33 Using this also works around a Tru64 5.1 bug, where attempting
34 to read INT_MAX bytes fails with errno == EINVAL. See
35 <https://lists.gnu.org/r/bug-gnu-utils/2002-04/msg00010.html>.
37 Using this is likely to work around similar bugs in other operating
38 systems. */
40 enum { SYS_BUFSIZE_MAX = INT_MAX >> 20 << 20 };
42 #endif