1 /* Set flags signalling availability of kernel features based on given
3 Copyright (C) 1999-2014 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 /* This file must not contain any C code. At least it must be protected
21 to allow using the file also in assembler files. */
23 #ifndef __LINUX_KERNEL_VERSION
24 /* We assume the worst; all kernels should be supported. */
25 # define __LINUX_KERNEL_VERSION 0
28 /* We assume for __LINUX_KERNEL_VERSION the same encoding used in
29 linux/version.h. I.e., the major, minor, and subminor all get a
30 byte with the major number being in the highest byte. This means
31 we can do numeric comparisons.
33 In the following we will define certain symbols depending on
34 whether the describes kernel feature is available in the kernel
35 version given by __LINUX_KERNEL_VERSION. We are not always exactly
36 recording the correct versions in which the features were
37 introduced. If somebody cares these values can afterwards be
40 /* The sendfile syscall was introduced in 2.2.0. */
41 #define __ASSUME_SENDFILE 1
43 /* Some architectures use the socketcall multiplexer for some or all
44 socket-related operations, via a socket.S file in glibc, instead of
45 separate syscalls. __ASSUME_SOCKETCALL is defined for such
47 #if defined __i386__ \
48 || defined __powerpc__ \
52 # define __ASSUME_SOCKETCALL 1
55 /* Linux 2.3.39 introduced IPC64. Except for powerpc. Linux 2.4.0 on
56 PPC introduced a correct IPC64. But PowerPC64 does not support a
57 separate 64-bit syscall, already 64-bit. */
59 # define __ASSUME_IPC64 1
62 /* The changed st_ino field appeared in 2.4.0-test6. However, SH is lame,
63 and still does not have a 64-bit inode field. */
65 # define __ASSUME_ST_INO_64_BIT 1
68 /* The getdents64 syscall was introduced in 2.4.0-test7 (but later for
70 #define __ASSUME_GETDENTS64_SYSCALL 1
72 /* The statfs64 syscalls are available in 2.5.74 (but not for alpha). */
73 #define __ASSUME_STATFS64 1
75 /* The utimes syscall has been available for some architectures
76 forever. For x86 it was introduced after 2.5.75, for x86-64,
77 ppc, and ppc64 it was introduced in 2.6.0-test3, for s390 it was
78 introduced in 2.6.21-rc5. */
79 #if defined __sparc__ \
81 || defined __x86_64__ \
82 || defined __powerpc__ \
84 || (defined __s390__ && __LINUX_KERNEL_VERSION >= 0x020616)
85 # define __ASSUME_UTIMES 1
88 /* pselect/ppoll were introduced just after 2.6.16-rc1. Due to the way
89 the kernel versions are advertised we can only rely on 2.6.17 to have
90 the code. On x86_64 and SH this appeared first in 2.6.19-rc1,
91 on ia64 in 2.6.22-rc1. */
92 #if __LINUX_KERNEL_VERSION >= 0x020611 \
93 && ((!defined __x86_64__ && !defined __sh__) \
94 || (__LINUX_KERNEL_VERSION >= 0x020613 \
95 && (defined __x86_64__ || defined __sh__)))
96 # define __ASSUME_PSELECT 1
97 # define __ASSUME_PPOLL 1
100 /* The *at syscalls were introduced just after 2.6.16-rc1. Due to the way the
101 kernel versions are advertised we can only rely on 2.6.17 to have
102 the code. On PPC they were introduced in 2.6.17-rc1,
103 on SH in 2.6.19-rc1. */
104 #if __LINUX_KERNEL_VERSION >= 0x020611 \
105 && (!defined __sh__ || __LINUX_KERNEL_VERSION >= 0x020613)
106 # define __ASSUME_ATFCTS 1
109 /* Support for inter-process robust mutexes was added in 2.6.17. */
110 #if __LINUX_KERNEL_VERSION >= 0x020611 \
111 && (!defined __sh__ || __LINUX_KERNEL_VERSION >= 0x020613)
112 # define __ASSUME_SET_ROBUST_LIST 1
115 /* Pessimistically assume that 2.6.18 introduced real handling of
116 large numbers of requests to readv and writev and that we don't
117 need a fallback. It likely worked for much longer. */
118 #if __LINUX_KERNEL_VERSION >= 0x020612
119 # define __ASSUME_COMPLETE_READV_WRITEV 1
122 /* Support for PI futexes was added in 2.6.18. */
123 #if __LINUX_KERNEL_VERSION >= 0x020612
124 # define __ASSUME_FUTEX_LOCK_PI 1
127 /* Support for utimensat syscall was added in 2.6.22, on SH
128 only after 2.6.22-rc1. */
129 #if __LINUX_KERNEL_VERSION >= 0x020616 \
130 && (!defined __sh__ || __LINUX_KERNEL_VERSION >= 0x020617)
131 # define __ASSUME_UTIMENSAT 1
134 /* Support for private futexes was added in 2.6.22. */
135 #if __LINUX_KERNEL_VERSION >= 0x020616
136 # define __ASSUME_PRIVATE_FUTEX 1
139 /* Support for fallocate was added in 2.6.23, on s390
140 only after 2.6.23-rc1. */
141 #if __LINUX_KERNEL_VERSION >= 0x020617 \
142 && (!defined __s390__ || __LINUX_KERNEL_VERSION >= 0x020618)
143 # define __ASSUME_FALLOCATE 1
146 /* Support for various CLOEXEC and NONBLOCK flags was added for x86,
147 x86-64, PPC, IA-64, SPARC< and S390 in 2.6.23. */
148 #if __LINUX_KERNEL_VERSION >= 0x020617 \
149 && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
150 || defined __sparc__ || defined __s390__)
151 # define __ASSUME_O_CLOEXEC 1
154 /* From 2.6.23 onwards the value of ARG_MAX depends on the stack
156 #define __LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL 0x020617
157 #if __LINUX_KERNEL_VERSION >= __LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL
158 # define __ASSUME_ARG_MAX_STACK_BASED 1
161 /* Support for ADJ_OFFSET_SS_READ was added in 2.6.24. */
162 #if __LINUX_KERNEL_VERSION >= 0x020618
163 # define __ASSUME_ADJ_OFFSET_SS_READ 1
166 /* Support for various CLOEXEC and NONBLOCK flags was added for x86,
167 x86-64, PPC, IA-64, and SPARC in 2.6.27. */
168 #if __LINUX_KERNEL_VERSION >= 0x02061b \
169 && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
170 || defined __sparc__ || defined __s390__)
171 # define __ASSUME_SOCK_CLOEXEC 1
172 # define __ASSUME_IN_NONBLOCK 1
173 # define __ASSUME_PIPE2 1
174 # define __ASSUME_EVENTFD2 1
175 # define __ASSUME_SIGNALFD4 1
176 # define __ASSUME_DUP3 1
179 /* Support for accept4 functionality was added in 2.6.28, but for some
180 architectures using a separate syscall rather than socketcall that
181 syscall was only added later, and some architectures first had
182 socketcall support then a separate syscall. Define
183 __ASSUME_ACCEPT4_SOCKETCALL if glibc uses socketcall on this
184 architecture and accept4 is available through socketcall,
185 __ASSUME_ACCEPT4_SYSCALL if it is available through a separate
186 syscall, __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL if it became
187 available through a separate syscall at the same time as through
188 socketcall, and __ASSUME_ACCEPT4 if the accept4 function is known
190 #if __LINUX_KERNEL_VERSION >= 0x02061c && defined __ASSUME_SOCKETCALL
191 # define __ASSUME_ACCEPT4_SOCKETCALL 1
194 /* The accept4 syscall was added for x86_64 and SPARC in 2.6.28, and
195 for PowerPC and SH in 2.6.37. */
196 #if (__LINUX_KERNEL_VERSION >= 0x02061c \
197 && (defined __x86_64__ || defined __sparc__)) \
198 || (__LINUX_KERNEL_VERSION >= 0x020625 \
199 && (defined __powerpc__ || defined __sh__))
200 # define __ASSUME_ACCEPT4_SYSCALL 1
203 # define __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL 1
206 #if defined __ASSUME_ACCEPT4_SOCKETCALL || defined __ASSUME_ACCEPT4_SYSCALL
207 # define __ASSUME_ACCEPT4 1
210 /* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */
211 #if __LINUX_KERNEL_VERSION >= 0x02061d
212 # define __ASSUME_FUTEX_CLOCK_REALTIME 1
215 /* Support for the AT_RANDOM auxiliary vector entry was added in 2.6.29. */
216 #if __LINUX_KERNEL_VERSION >= 0x02061d
217 # define __ASSUME_AT_RANDOM 1
220 /* Support for preadv and pwritev was added in 2.6.30. */
221 #if __LINUX_KERNEL_VERSION >= 0x02061e
222 # define __ASSUME_PREADV 1
223 # define __ASSUME_PWRITEV 1
226 /* Support for FUTEX_*_REQUEUE_PI was added in 2.6.31. */
227 #if __LINUX_KERNEL_VERSION >= 0x02061f
228 # define __ASSUME_REQUEUE_PI 1
231 /* Support for F_GETOWN_EX was introduced in 2.6.32. */
232 #if __LINUX_KERNEL_VERSION >= 0x020620
233 # define __ASSUME_F_GETOWN_EX 1
236 /* Support for recvmmsg functionality was added in 2.6.33. The macros
237 defined correspond to those for accept4. */
238 #if __LINUX_KERNEL_VERSION >= 0x020621 && defined __ASSUME_SOCKETCALL
239 # define __ASSUME_RECVMMSG_SOCKETCALL 1
242 /* The recvmmsg syscall was added for i386, x86_64 and SPARC in
243 2.6.33, and for PowerPC and SH in 2.6.37. */
244 #if (__LINUX_KERNEL_VERSION >= 0x020621 \
245 && (defined __i386__ || defined __x86_64__ || defined __sparc__)) \
246 || (__LINUX_KERNEL_VERSION >= 0x020625 \
247 && (defined __powerpc__ || defined __sh__))
248 # define __ASSUME_RECVMMSG_SYSCALL 1
250 #if defined __i386__ || defined __sparc__
251 # define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1
254 #if defined __ASSUME_RECVMMSG_SOCKETCALL || defined __ASSUME_RECVMMSG_SYSCALL
255 # define __ASSUME_RECVMMSG 1
258 /* Support for /proc/self/task/$tid/comm and /proc/$pid/task/$tid/comm was
260 #if __LINUX_KERNEL_VERSION >= 0x020621
261 # define __ASSUME_PROC_PID_TASK_COMM 1
264 /* statfs fills in f_flags since 2.6.36. */
265 #if __LINUX_KERNEL_VERSION >= 0x020624
266 # define __ASSUME_STATFS_F_FLAGS 1
269 /* prlimit64 is available in 2.6.36. */
270 #if __LINUX_KERNEL_VERSION >= 0x020624
271 # define __ASSUME_PRLIMIT64 1
274 /* sendmmsg is available in 2.6.39. */
275 #if __LINUX_KERNEL_VERSION >= 0x020627
276 # define __ASSUME_SENDMMSG 1
279 /* getcpu is a syscall for x86-64 since 3.1. */
280 #if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
281 # define __ASSUME_GETCPU_SYSCALL 1
284 /* 2.6.29 removed the XFS restricted_chown sysctl, so it is pointless looking
285 for it in newer kernels. */
286 #if __LINUX_KERNEL_VERSION >= 0x02061d
287 # define __ASSUME_XFS_RESTRICTED_CHOWN 1