Move remaining files out of nptl/sysdeps/unix/sysv/linux/x86/.
[glibc.git] / sysdeps / unix / sysv / linux / kernel-features.h
blob026f89fbc569334aaa5968a11652ae0821a0732b
1 /* Set flags signalling availability of kernel features based on given
2 kernel version number.
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
26 #endif
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
38 corrected. */
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
46 architectures. */
47 #if defined __i386__ \
48 || defined __powerpc__ \
49 || defined __s390__ \
50 || defined __sh__ \
51 || defined __sparc__
52 # define __ASSUME_SOCKETCALL 1
53 #endif
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. */
58 #ifndef __powerpc64__
59 # define __ASSUME_IPC64 1
60 #endif
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. */
64 #ifndef __sh__
65 # define __ASSUME_ST_INO_64_BIT 1
66 #endif
68 /* The getdents64 syscall was introduced in 2.4.0-test7 (but later for
69 MIPS n32). */
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 #define __ASSUME_UTIMES 1
81 /* pselect/ppoll were introduced just after 2.6.16-rc1. On x86_64 and
82 SH this appeared first in 2.6.19-rc1, on ia64 in 2.6.22-rc1. */
83 #define __ASSUME_PSELECT 1
84 #define __ASSUME_PPOLL 1
86 /* The *at syscalls were introduced just after 2.6.16-rc1. On PPC
87 they were introduced in 2.6.17-rc1, on SH in 2.6.19-rc1. */
88 #define __ASSUME_ATFCTS 1
90 /* Support for inter-process robust mutexes was added in 2.6.17 (but
91 some architectures lack futex_atomic_cmpxchg_inatomic in some
92 configurations). */
93 #if !(defined __sparc__ && !defined __arch64__ && !defined __sparc_v9__)
94 # define __ASSUME_SET_ROBUST_LIST 1
95 #endif
97 /* Pessimistically assume that 2.6.18 introduced real handling of
98 large numbers of requests to readv and writev and that we don't
99 need a fallback. It likely worked for much longer. */
100 #define __ASSUME_COMPLETE_READV_WRITEV 1
102 /* Support for PI futexes was added in 2.6.18 (but some architectures
103 lack futex_atomic_cmpxchg_inatomic in some configurations). */
104 #if !(defined __sparc__ && !defined __arch64__ && !defined __sparc_v9__)
105 # define __ASSUME_FUTEX_LOCK_PI 1
106 #endif
108 /* Support for utimensat syscall was added in 2.6.22, on SH
109 only after 2.6.22-rc1. */
110 #define __ASSUME_UTIMENSAT 1
112 /* Support for private futexes was added in 2.6.22. */
113 #define __ASSUME_PRIVATE_FUTEX 1
115 /* Support for fallocate was added in 2.6.23, on s390
116 only after 2.6.23-rc1. */
117 #define __ASSUME_FALLOCATE 1
119 /* Support for various CLOEXEC and NONBLOCK flags was added in
120 2.6.23. */
121 #define __ASSUME_O_CLOEXEC 1
123 /* Support for ADJ_OFFSET_SS_READ was added in 2.6.24. */
124 #define __ASSUME_ADJ_OFFSET_SS_READ 1
126 /* Support for various CLOEXEC and NONBLOCK flags was added in
127 2.6.27. */
128 #define __ASSUME_SOCK_CLOEXEC 1
129 #define __ASSUME_IN_NONBLOCK 1
130 #define __ASSUME_PIPE2 1
131 #define __ASSUME_EVENTFD2 1
132 #define __ASSUME_SIGNALFD4 1
133 #define __ASSUME_DUP3 1
135 /* Support for accept4 functionality was added in 2.6.28, but for some
136 architectures using a separate syscall rather than socketcall that
137 syscall was only added later, and some architectures first had
138 socketcall support then a separate syscall. Define
139 __ASSUME_ACCEPT4_SOCKETCALL if glibc uses socketcall on this
140 architecture and accept4 is available through socketcall,
141 __ASSUME_ACCEPT4_SYSCALL if it is available through a separate
142 syscall, __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL if it became
143 available through a separate syscall at the same time as through
144 socketcall, and __ASSUME_ACCEPT4 if the accept4 function is known
145 to work. */
146 #ifdef __ASSUME_SOCKETCALL
147 # define __ASSUME_ACCEPT4_SOCKETCALL 1
148 #endif
150 /* The accept4 syscall was added for x86_64 and SPARC in 2.6.28, and
151 for PowerPC and SH in 2.6.37. */
152 #if (defined __x86_64__ || defined __sparc__) \
153 || (__LINUX_KERNEL_VERSION >= 0x020625 \
154 && (defined __powerpc__ || defined __sh__))
155 # define __ASSUME_ACCEPT4_SYSCALL 1
156 #endif
157 #ifdef __sparc__
158 # define __ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL 1
159 #endif
161 #if defined __ASSUME_ACCEPT4_SOCKETCALL || defined __ASSUME_ACCEPT4_SYSCALL
162 # define __ASSUME_ACCEPT4 1
163 #endif
165 /* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */
166 #define __ASSUME_FUTEX_CLOCK_REALTIME 1
168 /* Support for the AT_RANDOM auxiliary vector entry was added in 2.6.29. */
169 #define __ASSUME_AT_RANDOM 1
171 /* Support for preadv and pwritev was added in 2.6.30. */
172 #define __ASSUME_PREADV 1
173 #define __ASSUME_PWRITEV 1
175 /* Support for FUTEX_*_REQUEUE_PI was added in 2.6.31 (but some
176 architectures lack futex_atomic_cmpxchg_inatomic in some
177 configurations). */
178 #if !(defined __sparc__ && !defined __arch64__ && !defined __sparc_v9__)
179 # define __ASSUME_REQUEUE_PI 1
180 #endif
182 /* Support for F_GETOWN_EX was introduced in 2.6.32. */
183 #define __ASSUME_F_GETOWN_EX 1
185 /* Support for recvmmsg functionality was added in 2.6.33. The macros
186 defined correspond to those for accept4. */
187 #if __LINUX_KERNEL_VERSION >= 0x020621 && defined __ASSUME_SOCKETCALL
188 # define __ASSUME_RECVMMSG_SOCKETCALL 1
189 #endif
191 /* The recvmmsg syscall was added for i386, x86_64 and SPARC in
192 2.6.33, and for PowerPC and SH in 2.6.37. */
193 #if (__LINUX_KERNEL_VERSION >= 0x020621 \
194 && (defined __i386__ || defined __x86_64__ || defined __sparc__)) \
195 || (__LINUX_KERNEL_VERSION >= 0x020625 \
196 && (defined __powerpc__ || defined __sh__))
197 # define __ASSUME_RECVMMSG_SYSCALL 1
198 #endif
199 #if defined __i386__ || defined __sparc__
200 # define __ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL 1
201 #endif
203 #if defined __ASSUME_RECVMMSG_SOCKETCALL || defined __ASSUME_RECVMMSG_SYSCALL
204 # define __ASSUME_RECVMMSG 1
205 #endif
207 /* Support for /proc/self/task/$tid/comm and /proc/$pid/task/$tid/comm was
208 added in 2.6.33. */
209 #if __LINUX_KERNEL_VERSION >= 0x020621
210 # define __ASSUME_PROC_PID_TASK_COMM 1
211 #endif
213 /* statfs fills in f_flags since 2.6.36. */
214 #if __LINUX_KERNEL_VERSION >= 0x020624
215 # define __ASSUME_STATFS_F_FLAGS 1
216 #endif
218 /* prlimit64 is available in 2.6.36. */
219 #if __LINUX_KERNEL_VERSION >= 0x020624
220 # define __ASSUME_PRLIMIT64 1
221 #endif
223 /* Support for sendmmsg functionality was added in 3.0. The macros
224 defined correspond to those for accept4 and recvmmsg. */
225 #if __LINUX_KERNEL_VERSION >= 0x030000 && defined __ASSUME_SOCKETCALL
226 # define __ASSUME_SENDMMSG_SOCKETCALL 1
227 #endif
229 /* The sendmmsg syscall was added for i386, x86_64, PowerPC, SH and
230 SPARC in 3.0. */
231 #if __LINUX_KERNEL_VERSION >= 0x030000 \
232 && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
233 || defined __sh__ || defined __sparc__)
234 # define __ASSUME_SENDMMSG_SYSCALL 1
235 #endif
236 #if defined __i386__ || defined __powerpc__ || defined __sh__ \
237 || defined __sparc__
238 # define __ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL 1
239 #endif
241 #if defined __ASSUME_SENDMMSG_SOCKETCALL || defined __ASSUME_SENDMMSG_SYSCALL
242 # define __ASSUME_SENDMMSG 1
243 #endif
245 /* getcpu is a syscall for x86-64 since 3.1. */
246 #if defined __x86_64__ && __LINUX_KERNEL_VERSION >= 0x030100
247 # define __ASSUME_GETCPU_SYSCALL 1
248 #endif
250 /* 2.6.29 removed the XFS restricted_chown sysctl, so it is pointless looking
251 for it in newer kernels. */
252 #define __ASSUME_XFS_RESTRICTED_CHOWN 1