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