sys-limits.h 1.6 KB

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