kernel-features.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /* Set flags signalling availability of kernel features based on given
  2. kernel version number.
  3. Copyright (C) 1999-2003, 2004, 2005 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, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. /* This file must not contain any C code. At least it must be protected
  18. to allow using the file also in assembler files. */
  19. #if defined __mips__
  20. # include <sgidefs.h>
  21. #endif
  22. #include <linux/version.h>
  23. #define __LINUX_KERNEL_VERSION LINUX_VERSION_CODE
  24. /* We assume for __LINUX_KERNEL_VERSION the same encoding used in
  25. linux/version.h. I.e., the major, minor, and subminor all get a
  26. byte with the major number being in the highest byte. This means
  27. we can do numeric comparisons.
  28. In the following we will define certain symbols depending on
  29. whether the describes kernel feature is available in the kernel
  30. version given by __LINUX_KERNEL_VERSION. We are not always exactly
  31. recording the correct versions in which the features were
  32. introduced. If somebody cares these values can afterwards be
  33. corrected. Most of the numbers here are set corresponding to
  34. 2.2.0. */
  35. /* `getcwd' system call. */
  36. #if __LINUX_KERNEL_VERSION >= 131584
  37. # define __ASSUME_GETCWD_SYSCALL 1
  38. #endif
  39. /* When was `poll' introduced? */
  40. #if __LINUX_KERNEL_VERSION >= 131584
  41. # define __ASSUME_POLL_SYSCALL 1
  42. #endif
  43. /* Real-time signal became usable in 2.1.70. */
  44. #if __LINUX_KERNEL_VERSION >= 131398
  45. # define __ASSUME_REALTIME_SIGNALS 1
  46. #endif
  47. /* When were the `pread'/`pwrite' syscalls introduced? */
  48. #if __LINUX_KERNEL_VERSION >= 131584
  49. # define __ASSUME_PREAD_SYSCALL 1
  50. # define __ASSUME_PWRITE_SYSCALL 1
  51. #endif
  52. /* When was `poll' introduced? */
  53. #if __LINUX_KERNEL_VERSION >= 131584
  54. # define __ASSUME_POLL_SYSCALL 1
  55. #endif
  56. /* The `lchown' syscall was introduced in 2.1.80. */
  57. #if __LINUX_KERNEL_VERSION >= 131408
  58. # define __ASSUME_LCHOWN_SYSCALL 1
  59. #endif
  60. /* When did the `setresuid' sysall became available? */
  61. #if __LINUX_KERNEL_VERSION >= 131584 && !defined __sparc__
  62. # define __ASSUME_SETRESUID_SYSCALL 1
  63. #endif
  64. /* The SIOCGIFNAME ioctl is available starting with 2.1.50. */
  65. #if __LINUX_KERNEL_VERSION >= 131408
  66. # define __ASSUME_SIOCGIFNAME 1
  67. #endif
  68. /* MSG_NOSIGNAL was at least available with Linux 2.2.0. */
  69. #if __LINUX_KERNEL_VERSION >= 131584
  70. # define __ASSUME_MSG_NOSIGNAL 1
  71. #endif
  72. /* On x86 another `getrlimit' syscall was added in 2.3.25. */
  73. #if __LINUX_KERNEL_VERSION >= 131865 && defined __i386__
  74. # define __ASSUME_NEW_GETRLIMIT_SYSCALL 1
  75. #endif
  76. /* On x86 the truncate64/ftruncate64 syscalls were introduced in 2.3.31. */
  77. #if __LINUX_KERNEL_VERSION >= 131871 && defined __i386__
  78. # define __ASSUME_TRUNCATE64_SYSCALL 1
  79. #endif
  80. /* On x86 the mmap2 syscall was introduced in 2.3.31. */
  81. #if __LINUX_KERNEL_VERSION >= 131871 && defined __i386__
  82. # define __ASSUME_MMAP2_SYSCALL 1
  83. #endif
  84. /* On x86 the stat64/lstat64/fstat64 syscalls were introduced in 2.3.34. */
  85. #if __LINUX_KERNEL_VERSION >= 131874 && defined __i386__
  86. # define __ASSUME_STAT64_SYSCALL 1
  87. #endif
  88. /* On sparc and ARM the truncate64/ftruncate64/mmap2/stat64/lstat64/fstat64
  89. syscalls were introduced in 2.3.35. */
  90. #if __LINUX_KERNEL_VERSION >= 131875 && (defined __sparc__ || defined __arm__)
  91. # define __ASSUME_TRUNCATE64_SYSCALL 1
  92. # define __ASSUME_MMAP2_SYSCALL 1
  93. # define __ASSUME_STAT64_SYSCALL 1
  94. #endif
  95. /* I know for sure that getrlimit are in 2.3.35 on powerpc. */
  96. #if __LINUX_KERNEL_VERSION >= 131875 && defined __powerpc__
  97. # define __ASSUME_NEW_GETRLIMIT_SYSCALL 1
  98. #endif
  99. /* I know for sure that these are in 2.3.35 on powerpc. But PowerPC64 does not
  100. support separate 64-bit syscalls, already 64-bit */
  101. #if __LINUX_KERNEL_VERSION >= 131875 && defined __powerpc__ \
  102. && !defined __powerpc64__
  103. # define __ASSUME_TRUNCATE64_SYSCALL 1
  104. # define __ASSUME_STAT64_SYSCALL 1
  105. #endif
  106. /* Linux 2.3.39 introduced 32bit UID/GIDs. Some platforms had 32
  107. bit type all along. */
  108. #if __LINUX_KERNEL_VERSION >= 131879 || defined __powerpc__ || defined __mips__
  109. # define __ASSUME_32BITUIDS 1
  110. #endif
  111. /* Linux 2.3.39 sparc added setresuid. */
  112. #if __LINUX_KERNEL_VERSION >= 131879 && defined __sparc__
  113. # define __ASSUME_SETRESUID_SYSCALL 1
  114. #endif
  115. #if __LINUX_KERNEL_VERSION >= 131879
  116. # define __ASSUME_SETRESGID_SYSCALL 1
  117. #endif
  118. /* Linux 2.3.39 introduced IPC64. Except for powerpc. */
  119. #if __LINUX_KERNEL_VERSION >= 131879 && !defined __powerpc__
  120. # define __ASSUME_IPC64 1
  121. #endif
  122. /* MIPS platforms had IPC64 all along. */
  123. #if defined __mips__
  124. # define __ASSUME_IPC64 1
  125. #endif
  126. /* We can use the LDTs for threading with Linux 2.3.99 and newer. */
  127. #if __LINUX_KERNEL_VERSION >= 131939
  128. # define __ASSUME_LDT_WORKS 1
  129. #endif
  130. /* Linux 2.4.0 on PPC introduced a correct IPC64. But PowerPC64 does not
  131. support a separate 64-bit sys call, already 64-bit */
  132. #if __LINUX_KERNEL_VERSION >= 132096 && defined __powerpc__ \
  133. && !defined __powerpc64__
  134. # define __ASSUME_IPC64 1
  135. #endif
  136. /* SH kernels got stat64, mmap2, and truncate64 during 2.4.0-test. */
  137. #if __LINUX_KERNEL_VERSION >= 132096 && defined __sh__
  138. # define __ASSUME_TRUNCATE64_SYSCALL 1
  139. # define __ASSUME_MMAP2_SYSCALL 1
  140. # define __ASSUME_STAT64_SYSCALL 1
  141. #endif
  142. /* The changed st_ino field appeared in 2.4.0-test6. But we cannot
  143. distinguish this version from other 2.4.0 releases. Therefore play
  144. save and assume it available is for 2.4.1 and up. However, SH is lame,
  145. and still does not have a 64-bit inode field. */
  146. #if __LINUX_KERNEL_VERSION >= 132097 && !defined __alpha__ && !defined __sh__
  147. # define __ASSUME_ST_INO_64_BIT 1
  148. #endif
  149. /* To support locking of large files a new fcntl() syscall was introduced
  150. in 2.4.0-test7. We test for 2.4.1 for the earliest version we know
  151. the syscall is available. */
  152. #if __LINUX_KERNEL_VERSION >= 132097 && (defined __i386__ || defined __sparc__)
  153. # define __ASSUME_FCNTL64 1
  154. #endif
  155. /* The AT_CLKTCK auxiliary vector entry was introduction in the 2.4.0
  156. series. */
  157. #if __LINUX_KERNEL_VERSION >= 132097
  158. # define __ASSUME_AT_CLKTCK 1
  159. #endif
  160. /* Arm got fcntl64 in 2.4.4, PowerPC and SH have it also in 2.4.4 (I
  161. don't know when it got introduced). But PowerPC64 does not support
  162. separate FCNTL64 call, FCNTL is already 64-bit */
  163. #if __LINUX_KERNEL_VERSION >= 132100 \
  164. && (defined __arm__ || defined __powerpc__ || defined __sh__) \
  165. && !defined __powerpc64__
  166. # define __ASSUME_FCNTL64 1
  167. #endif
  168. /* The getdents64 syscall was introduced in 2.4.0-test7. We test for
  169. 2.4.1 for the earliest version we know the syscall is available. */
  170. #if __LINUX_KERNEL_VERSION >= 132097
  171. # define __ASSUME_GETDENTS64_SYSCALL 1
  172. #endif
  173. /* When did O_DIRECTORY became available? Early in 2.3 but when?
  174. Be safe, use 2.3.99. */
  175. #if __LINUX_KERNEL_VERSION >= 131939
  176. # define __ASSUME_O_DIRECTORY 1
  177. #endif
  178. /* Starting with one of the 2.4.0 pre-releases the Linux kernel passes
  179. up the page size information. */
  180. #if __LINUX_KERNEL_VERSION >= 132097
  181. # define __ASSUME_AT_PAGESIZE 1
  182. #endif
  183. /* Starting with at least 2.4.0 the kernel passes the uid/gid unconditionally
  184. up to the child. */
  185. #if __LINUX_KERNEL_VERSION >= 132097
  186. # define __ASSUME_AT_XID 1
  187. #endif
  188. /* Starting with 2.4.5 kernels PPC passes the AUXV in the standard way
  189. and the vfork syscall made it into the official kernel. */
  190. #if __LINUX_KERNEL_VERSION >= (132096+5) && defined __powerpc__
  191. # define __ASSUME_STD_AUXV 1
  192. # define __ASSUME_VFORK_SYSCALL 1
  193. #endif
  194. /* Starting with 2.4.5 kernels the mmap2 syscall made it into the official
  195. kernel. But PowerPC64 does not support a separate MMAP2 call. */
  196. #if __LINUX_KERNEL_VERSION >= (132096+5) && defined __powerpc__ \
  197. && !defined __powerpc64__
  198. # define __ASSUME_MMAP2_SYSCALL 1
  199. #endif
  200. /* Starting with 2.4.21 PowerPC implements the new prctl syscall.
  201. This allows applications to get/set the Floating Point Exception Mode. */
  202. #if __LINUX_KERNEL_VERSION >= (132096+21) && defined __powerpc__
  203. # define __ASSUME_NEW_PRCTL_SYSCALL 1
  204. #endif
  205. /* Starting with 2.4.21 the PowerPC32 clone syscall works as expected. */
  206. #if __LINUX_KERNEL_VERSION >= (132096+21) && defined __powerpc__ \
  207. && !defined __powerpc64__
  208. # define __ASSUME_FIXED_CLONE_SYSCALL 1
  209. #endif
  210. /* Starting with 2.4.21 PowerPC64 implements the new rt_sigreturn syscall.
  211. The new rt_sigreturn takes an ucontext pointer allowing rt_sigreturn
  212. to be used in the set/swapcontext implementation. */
  213. #if __LINUX_KERNEL_VERSION >= (132096+21) && defined __powerpc64__
  214. # define __ASSUME_NEW_RT_SIGRETURN_SYSCALL 1
  215. #endif
  216. /* On x86, the set_thread_area syscall was introduced in 2.5.29, but its
  217. semantics was changed in 2.5.30, and again after 2.5.31. */
  218. #if __LINUX_KERNEL_VERSION >= 132384 && defined __i386__
  219. # define __ASSUME_SET_THREAD_AREA_SYSCALL 1
  220. #endif
  221. /* The vfork syscall on x86 and arm was definitely available in 2.4. */
  222. #if __LINUX_KERNEL_VERSION >= 132097 && (defined __i386__ || defined __arm__)
  223. # define __ASSUME_VFORK_SYSCALL 1
  224. #endif
  225. /* There are an infinite number of PA-RISC kernel versions numbered
  226. 2.4.0. But they've not really been released as such. We require
  227. and expect the final version here. */
  228. #ifdef __hppa__
  229. # define __ASSUME_32BITUIDS 1
  230. # define __ASSUME_TRUNCATE64_SYSCALL 1
  231. # define __ASSUME_MMAP2_SYSCALL 1
  232. # define __ASSUME_STAT64_SYSCALL 1
  233. # define __ASSUME_IPC64 1
  234. # define __ASSUME_ST_INO_64_BIT 1
  235. # define __ASSUME_FCNTL64 1
  236. # define __ASSUME_GETDENTS64_SYSCALL 1
  237. #endif
  238. /* Alpha switched to a 64-bit timeval sometime before 2.2.0. */
  239. #if __LINUX_KERNEL_VERSION >= 131584 && defined __alpha__
  240. # define __ASSUME_TIMEVAL64 1
  241. #endif
  242. #if defined __mips__ && _MIPS_SIM == _ABIN32
  243. # define __ASSUME_FCNTL64 1
  244. #endif
  245. /* The late 2.5 kernels saw a lot of new CLONE_* flags. Summarize
  246. their availability with one define. The changes were made first
  247. for i386 and the have to be done separately for the other archs.
  248. For i386 we pick 2.5.50 as the first version with support. */
  249. #if __LINUX_KERNEL_VERSION >= 132402 && defined __i386__
  250. # define __ASSUME_CLONE_THREAD_FLAGS 1
  251. #endif
  252. /* Support for various CLOEXEC and NONBLOCK flags was added for x86,
  253. x86-64, PPC, IA-64, SPARC< and S390 in 2.6.23. */
  254. #if __LINUX_KERNEL_VERSION >= 0x020617 \
  255. && (defined __i386__ || defined __x86_64__ || defined __powerpc__ \
  256. || defined __ia64__ || defined __sparc__ || defined __s390__)
  257. # define __ASSUME_O_CLOEXEC 1
  258. #endif
  259. /* These features were surely available with 2.4.12. */
  260. #if __LINUX_KERNEL_VERSION >= 132108 && defined __mc68000__
  261. # define __ASSUME_MMAP2_SYSCALL 1
  262. # define __ASSUME_TRUNCATE64_SYSCALL 1
  263. # define __ASSUME_STAT64_SYSCALL 1
  264. # define __ASSUME_FCNTL64 1
  265. # define __ASSUME_VFORK_SYSCALL 1
  266. #endif
  267. /* Beginning with 2.5.63 support for realtime and monotonic clocks and
  268. timers based on them is available. */
  269. #if __LINUX_KERNEL_VERSION >= 132415
  270. # define __ASSUME_POSIX_TIMERS 1
  271. #endif
  272. /* Beginning with 2.6.12 the clock and timer supports CPU clocks. */
  273. #if __LINUX_KERNEL_VERSION >= 0x2060c
  274. # define __ASSUME_POSIX_CPU_TIMERS 1
  275. #endif
  276. /* The late 2.5 kernels saw a lot of new CLONE_* flags. Summarize
  277. their availability with one define. The changes were made first
  278. for i386 and the have to be done separately for the other archs.
  279. For ia64, s390*, PPC, x86-64 we pick 2.5.64 as the first version
  280. with support. */
  281. #if __LINUX_KERNEL_VERSION >= 132416 \
  282. && (defined __ia64__ || defined __s390__ || defined __powerpc__ \
  283. || defined __x86_64__ || defined __sh__)
  284. # define __ASSUME_CLONE_THREAD_FLAGS 1
  285. #endif
  286. /* With kernel 2.4.17 we always have netlink support. */
  287. #if __LINUX_KERNEL_VERSION >= (132096+17)
  288. # define __ASSUME_NETLINK_SUPPORT 1
  289. #endif
  290. /* The requeue futex functionality was introduced in 2.5.70. */
  291. #if __LINUX_KERNEL_VERSION >= 132422
  292. # define __ASSUME_FUTEX_REQUEUE 1
  293. #endif
  294. /* The statfs64 syscalls are available in 2.5.74. */
  295. #if __LINUX_KERNEL_VERSION >= 132426
  296. # define __ASSUME_STATFS64 1
  297. #endif
  298. /* Starting with at least 2.5.74 the kernel passes the setuid-like exec
  299. flag unconditionally up to the child. */
  300. #if __LINUX_KERNEL_VERSION >= 132426
  301. # define __ASSUME_AT_SECURE 1
  302. #endif
  303. /* Starting with the 2.5.75 kernel the kernel fills in the correct value
  304. in the si_pid field passed as part of the siginfo_t struct to signal
  305. handlers. */
  306. #if __LINUX_KERNEL_VERSION >= 132427
  307. # define __ASSUME_CORRECT_SI_PID 1
  308. #endif
  309. /* The tgkill syscall was instroduced for i386 in 2.5.75. For Alpha
  310. it was introduced in 2.6.0-test1 which unfortunately cannot be
  311. distinguished from 2.6.0. On x86-64, ppc, and ppc64 it was
  312. introduced in 2.6.0-test3. */
  313. #if (__LINUX_KERNEL_VERSION >= 132427 && defined __i386__) \
  314. || (__LINUX_KERNEL_VERSION >= 132609 && defined __alpha__) \
  315. || (__LINUX_KERNEL_VERSION >= 132609 && defined __x86_64__) \
  316. || (__LINUX_KERNEL_VERSION >= 132609 && defined __powerpc__) \
  317. || (__LINUX_KERNEL_VERSION >= 132609 && defined __sh__)
  318. # define __ASSUME_TGKILL 1
  319. #endif
  320. /* The utimes syscall has been available for some architectures
  321. forever. For x86 it was introduced after 2.5.75, for x86-64,
  322. ppc, and ppc64 it was introduced in 2.6.0-test3. */
  323. #if defined __alpha__ || defined __ia64__ || defined __hppa__ \
  324. || defined __sparc__ \
  325. || (__LINUX_KERNEL_VERSION > 132427 && defined __i386__) \
  326. || (__LINUX_KERNEL_VERSION > 132609 && defined __x86_64__) \
  327. || (__LINUX_KERNEL_VERSION >= 132609 && defined __powerpc__) \
  328. || (__LINUX_KERNEL_VERSION >= 132609 && defined __sh__)
  329. # define __ASSUME_UTIMES 1
  330. #endif
  331. // XXX Disabled for now since the semantics we want is not achieved.
  332. #if 0
  333. /* The CLONE_STOPPED flag was introduced in the 2.6.0-test1 series. */
  334. #if __LINUX_KERNEL_VERSION >= 132609
  335. # define __ASSUME_CLONE_STOPPED 1
  336. #endif
  337. #endif
  338. /* The fixed version of the posix_fadvise64 syscall appeared in
  339. 2.6.0-test3. At least for x86. Powerpc support appeared in
  340. 2.6.2, but for 32-bit userspace only. */
  341. #if (__LINUX_KERNEL_VERSION >= 132609 && defined __i386__) \
  342. || (__LINUX_KERNEL_VERSION >= 132610 && defined __powerpc__ \
  343. && !defined __powerpc64__)
  344. # define __ASSUME_FADVISE64_64_SYSCALL 1
  345. #endif
  346. /* The PROT_GROWSDOWN/PROT_GROWSUP flags were introduced in the 2.6.0-test
  347. series. */
  348. #if __LINUX_KERNEL_VERSION >= 132609
  349. # define __ASSUME_PROT_GROWSUPDOWN 1
  350. #endif
  351. /* Starting with 2.6.0 PowerPC adds signal/swapcontext support for Vector
  352. SIMD (AKA Altivec, VMX) instructions and register state. This changes
  353. the overall size of the sigcontext and adds the swapcontext syscall. */
  354. #if __LINUX_KERNEL_VERSION >= 132608 && defined __powerpc__
  355. # define __ASSUME_SWAPCONTEXT_SYSCALL 1
  356. #endif
  357. /* The CLONE_DETACHED flag is not necessary in 2.6.2 kernels, it is
  358. implied. */
  359. #if __LINUX_KERNEL_VERSION >= 132610
  360. # define __ASSUME_NO_CLONE_DETACHED 1
  361. #endif
  362. /* Starting with version 2.6.4-rc1 the getdents syscall returns d_type
  363. information as well and in between 2.6.5 and 2.6.8 most compat wrappers
  364. were fixed too. Except s390{,x} which was fixed in 2.6.11. */
  365. #if (__LINUX_KERNEL_VERSION >= 0x020608 && !defined __s390__) \
  366. || (__LINUX_KERNEL_VERSION >= 0x02060b && defined __s390__)
  367. # define __ASSUME_GETDENTS32_D_TYPE 1
  368. #endif
  369. /* Starting with version 2.5.3, the initial location returned by `brk'
  370. after exec is always rounded up to the next page. */
  371. #if __LINUX_KERNEL_VERSION >= 132355
  372. # define __ASSUME_BRK_PAGE_ROUNDED 1
  373. #endif
  374. /* Starting with version 2.6.9, the waitid system call is available.
  375. Except for powerpc and powerpc64, where it is available in 2.6.12. */
  376. #if (__LINUX_KERNEL_VERSION >= 0x020609 && !defined __powerpc__) \
  377. || (__LINUX_KERNEL_VERSION >= 0x02060c && defined __powerpc__)
  378. # define __ASSUME_WAITID_SYSCALL 1
  379. #endif
  380. /* Starting with version 2.6.9, SSI_IEEE_RAISE_EXCEPTION exists. */
  381. #if __LINUX_KERNEL_VERSION >= 0x020609 && defined __alpha__
  382. #define __ASSUME_IEEE_RAISE_EXCEPTION 1
  383. #endif
  384. /* Support for the FUTEX_CLOCK_REALTIME flag was added in 2.6.29. */
  385. #if __LINUX_KERNEL_VERSION >= 0x02061d
  386. # define __ASSUME_FUTEX_CLOCK_REALTIME 1
  387. #endif
  388. /* Support for PI futexes was added in 2.6.18. */
  389. #if __LINUX_KERNEL_VERSION >= 0x020612
  390. # define __ASSUME_FUTEX_LOCK_PI 1
  391. #endif
  392. /* Support for private futexes was added in 2.6.22. */
  393. #if __LINUX_KERNEL_VERSION >= 0x020616
  394. # define __ASSUME_PRIVATE_FUTEX 1
  395. #endif