kernel-features.h 16 KB

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