kernel-features.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* Set flags signalling availability of kernel features based on given
  2. kernel version number.
  3. Copyright (C) 1999-2019 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. /* This file must not contain any C code. At least it must be protected
  17. to allow using the file also in assembler files. */
  18. #ifndef __LINUX_KERNEL_VERSION
  19. /* We assume the worst; all kernels should be supported. */
  20. # define __LINUX_KERNEL_VERSION 0
  21. #endif
  22. /* We assume for __LINUX_KERNEL_VERSION the same encoding used in
  23. linux/version.h. I.e., the major, minor, and subminor all get a
  24. byte with the major number being in the highest byte. This means
  25. we can do numeric comparisons.
  26. In the following we will define certain symbols depending on
  27. whether the describes kernel feature is available in the kernel
  28. version given by __LINUX_KERNEL_VERSION. We are not always exactly
  29. recording the correct versions in which the features were
  30. introduced. If somebody cares these values can afterwards be
  31. corrected. */
  32. /* The statfs64 syscalls are available in 2.5.74 (but not for alpha). */
  33. #define __ASSUME_STATFS64 1
  34. /* pselect/ppoll were introduced just after 2.6.16-rc1. On x86_64 and
  35. SH this appeared first in 2.6.19-rc1, on ia64 in 2.6.22-rc1. */
  36. #define __ASSUME_PSELECT 1
  37. /* The *at syscalls were introduced just after 2.6.16-rc1. On PPC
  38. they were introduced in 2.6.17-rc1, on SH in 2.6.19-rc1. */
  39. #define __ASSUME_ATFCTS 1
  40. /* Support for inter-process robust mutexes was added in 2.6.17 (but
  41. some architectures lack futex_atomic_cmpxchg_inatomic in some
  42. configurations). */
  43. #define __ASSUME_SET_ROBUST_LIST 1
  44. /* Support for various CLOEXEC and NONBLOCK flags was added in
  45. 2.6.27. */
  46. #define __ASSUME_IN_NONBLOCK 1
  47. /* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */
  48. #define __ASSUME_FUTEX_CLOCK_REALTIME 1
  49. /* Support for preadv and pwritev was added in 2.6.30. */
  50. #define __ASSUME_PREADV 1
  51. #define __ASSUME_PWRITEV 1
  52. /* Support for sendmmsg functionality was added in 3.0. */
  53. #define __ASSUME_SENDMMSG 1
  54. /* On most architectures, most socket syscalls are supported for all
  55. supported kernel versions, but on some socketcall architectures
  56. separate syscalls were only added later. */
  57. #define __ASSUME_SENDMSG_SYSCALL 1
  58. #define __ASSUME_RECVMSG_SYSCALL 1
  59. #define __ASSUME_ACCEPT_SYSCALL 1
  60. #define __ASSUME_CONNECT_SYSCALL 1
  61. #define __ASSUME_RECVFROM_SYSCALL 1
  62. #define __ASSUME_SENDTO_SYSCALL 1
  63. #define __ASSUME_ACCEPT4_SYSCALL 1
  64. #define __ASSUME_RECVMMSG_SYSCALL 1
  65. #define __ASSUME_SENDMMSG_SYSCALL 1
  66. /* Support for SysV IPC through wired syscalls. All supported architectures
  67. either support ipc syscall and/or all the ipc correspondent syscalls. */
  68. #define __ASSUME_DIRECT_SYSVIPC_SYSCALLS 1
  69. /* Support for p{read,write}v2 was added in 4.6. However Linux default
  70. implementation does not assume the __ASSUME_* and instead use a fallback
  71. implementation based on p{read,write}v and returning an error for
  72. non supported flags. */
  73. /* Support for the renameat2 system call was added in kernel 3.15. */
  74. #if __LINUX_KERNEL_VERSION >= 0x030F00
  75. # define __ASSUME_RENAMEAT2
  76. #endif
  77. /* Support for the execveat syscall was added in 3.19. */
  78. #if __LINUX_KERNEL_VERSION >= 0x031300
  79. # define __ASSUME_EXECVEAT 1
  80. #endif
  81. #if __LINUX_KERNEL_VERSION >= 0x040400
  82. # define __ASSUME_MLOCK2 1
  83. #endif
  84. #if __LINUX_KERNEL_VERSION >= 0x040500
  85. # define __ASSUME_COPY_FILE_RANGE 1
  86. #endif
  87. /* Support for statx was added in kernel 4.11. */
  88. #if __LINUX_KERNEL_VERSION >= 0x040B00
  89. # define __ASSUME_STATX 1
  90. #endif
  91. /* Support for clone call used on fork. The signature varies across the
  92. architectures with current 4 different variants:
  93. 1. long int clone (unsigned long flags, unsigned long newsp,
  94. int *parent_tidptr, unsigned long tls,
  95. int *child_tidptr)
  96. 2. long int clone (unsigned long newsp, unsigned long clone_flags,
  97. int *parent_tidptr, int * child_tidptr,
  98. unsigned long tls)
  99. 3. long int clone (unsigned long flags, unsigned long newsp,
  100. int stack_size, int *parent_tidptr,
  101. int *child_tidptr, unsigned long tls)
  102. 4. long int clone (unsigned long flags, unsigned long newsp,
  103. int *parent_tidptr, int *child_tidptr,
  104. unsigned long tls)
  105. The fourth variant is intended to be used as the default for newer ports,
  106. Also IA64 uses the third variant but with __NR_clone2 instead of
  107. __NR_clone.
  108. The macros names to define the variant used for the architecture is
  109. similar to kernel:
  110. - __ASSUME_CLONE_BACKWARDS: for variant 1.
  111. - __ASSUME_CLONE_BACKWARDS2: for variant 2 (s390).
  112. - __ASSUME_CLONE_BACKWARDS3: for variant 3 (microblaze).
  113. - __ASSUME_CLONE_DEFAULT: for variant 4.
  114. - __ASSUME_CLONE2: for clone2 with variant 3 (ia64).
  115. */
  116. #define __ASSUME_CLONE_DEFAULT 1