gcc.libc.imp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. # This was initially taken from the IWYU repository:
  2. # github.com/include-what-you-use/include-what-you-use/blob/164b8fe7597805ae55f029ecf6580dc46a74c7ed/gcc.libc.imp
  3. # It has useful mappings that are normally enabled by default, but there are
  4. # other default mappings that conflict with our builds. The best solution seems
  5. # to be to disable all defaults, import the defaults from the IWYU
  6. # repo and modify the rules that conflict with our build.
  7. #
  8. # TODO(dundargoc): Check if there is a way to disable specific builtin maps as
  9. # to avoid this file entirely.
  10. # Mappings for GNU libc
  11. # ( cd /usr/include && grep '^ *# *include' {sys/,net/,}* | perl -nle 'm/^([^:]+).*<([^>]+)>/ && print qq@ { include: [ "<$2>", private, "<$1>", public ] },@' | grep bits/ | sort )
  12. # When I saw more than one mapping for these, I typically picked
  13. # what I thought was the "best" one.
  14. [
  15. { include: [ "<bits/a.out.h>", private, "<a.out.h>", public ] },
  16. { include: [ "<bits/auxv.h>", private, "<sys/auxv.h>", public ] },
  17. { include: [ "<bits/byteswap.h>", private, "<byteswap.h>", public ] },
  18. { include: [ "<bits/cmathcalls.h>", private, "<complex.h>", public ] },
  19. { include: [ "<bits/confname.h>", private, "<unistd.h>", private ] },
  20. { include: [ "<bits/dirent.h>", private, "<dirent.h>", public ] },
  21. { include: [ "<bits/dlfcn.h>", private, "<dlfcn.h>", public ] },
  22. { include: [ "<bits/elfclass.h>", private, "<link.h>", public ] },
  23. { include: [ "<bits/endian.h>", private, "<endian.h>", public ] },
  24. { include: [ "<bits/environments.h>", private, "<unistd.h>", private ] },
  25. { include: [ "<bits/epoll.h>", private, "<sys/epoll.h>", public ] },
  26. { include: [ "<bits/errno.h>", private, "<errno.h>", public ] },
  27. { include: [ "<bits/error.h>", private, "<error.h>", public ] },
  28. { include: [ "<bits/eventfd.h>", private, "<sys/eventfd.h>", public ] },
  29. { include: [ "<bits/fcntl.h>", private, "<fcntl.h>", public ] },
  30. { include: [ "<bits/fcntl2.h>", private, "<fcntl.h>", public ] },
  31. { include: [ "<bits/fenv.h>", private, "<fenv.h>", public ] },
  32. { include: [ "<bits/fenvinline.h>", private, "<fenv.h>", public ] },
  33. { include: [ "<bits/huge_val.h>", private, "<math.h>", public ] },
  34. { include: [ "<bits/huge_valf.h>", private, "<math.h>", public ] },
  35. { include: [ "<bits/huge_vall.h>", private, "<math.h>", public ] },
  36. { include: [ "<bits/hwcap.h>", private, "<sys/auxv.h>", public ] },
  37. { include: [ "<bits/inf.h>", private, "<math.h>", public ] },
  38. { include: [ "<bits/inotify.h>", private, "<sys/inotify.h>", public ] },
  39. { include: [ "<bits/ioctl-types.h>", private, "<sys/ioctl.h>", public ] },
  40. { include: [ "<bits/ioctls.h>", private, "<sys/ioctl.h>", public ] },
  41. { include: [ "<bits/ipc.h>", private, "<sys/ipc.h>", public ] },
  42. { include: [ "<bits/ipctypes.h>", private, "<sys/ipc.h>", public ] },
  43. { include: [ "<bits/libio-ldbl.h>", private, "<libio.h>", public ] },
  44. { include: [ "<bits/link.h>", private, "<link.h>", public ] },
  45. { include: [ "<bits/locale.h>", private, "<locale.h>", public ] },
  46. { include: [ "<bits/math-finite.h>", private, "<math.h>", public ] },
  47. { include: [ "<bits/mathcalls.h>", private, "<math.h>", public ] },
  48. { include: [ "<bits/mathdef.h>", private, "<math.h>", public ] },
  49. { include: [ "<bits/mathinline.h>", private, "<math.h>", public ] },
  50. { include: [ "<bits/mman.h>", private, "<sys/mman.h>", public ] },
  51. { include: [ "<bits/mman-shared.h>", private, "<sys/mman.h>", public ] },
  52. { include: [ "<bits/monetary-ldbl.h>", private, "<monetary.h>", public ] },
  53. { include: [ "<bits/mqueue.h>", private, "<mqueue.h>", public ] },
  54. { include: [ "<bits/mqueue2.h>", private, "<mqueue.h>", public ] },
  55. { include: [ "<bits/msq.h>", private, "<sys/msg.h>", public ] },
  56. { include: [ "<bits/nan.h>", private, "<math.h>", public ] },
  57. { include: [ "<bits/netdb.h>", private, "<netdb.h>", private ] },
  58. { include: [ "<bits/param.h>", private, "<sys/param.h>", public ] },
  59. { include: [ "<bits/poll.h>", private, "<sys/poll.h>", private ] },
  60. { include: [ "<bits/poll2.h>", private, "<sys/poll.h>", private ] },
  61. { include: [ "<bits/posix1_lim.h>", private, "<limits.h>", public ] },
  62. { include: [ "<bits/posix2_lim.h>", private, "<limits.h>", public ] },
  63. { include: [ "<bits/posix_opt.h>", private, "<unistd.h>", private ] },
  64. { include: [ "<bits/printf-ldbl.h>", private, "<printf.h>", public ] },
  65. { include: [ "<bits/pthreadtypes.h>", private, "<pthread.h>", private ] },
  66. { include: [ "<bits/resource.h>", private, "<sys/resource.h>", public ] },
  67. { include: [ "<bits/sched.h>", private, "<sched.h>", public ] },
  68. { include: [ "<bits/select.h>", private, "<sys/select.h>", public ] },
  69. { include: [ "<bits/select2.h>", private, "<sys/select.h>", public ] },
  70. { include: [ "<bits/sem.h>", private, "<sys/sem.h>", public ] },
  71. { include: [ "<bits/semaphore.h>", private, "<semaphore.h>", public ] },
  72. { include: [ "<bits/setjmp.h>", private, "<setjmp.h>", public ] },
  73. { include: [ "<bits/setjmp2.h>", private, "<setjmp.h>", public ] },
  74. { include: [ "<bits/shm.h>", private, "<sys/shm.h>", public ] },
  75. { include: [ "<bits/sigaction.h>", private, "<signal.h>", public ] },
  76. { include: [ "<bits/sigcontext.h>", private, "<signal.h>", public ] },
  77. { include: [ "<bits/siginfo.h>", private, "<signal.h>", public ] },
  78. { include: [ "<bits/signum.h>", private, "<signal.h>", public ] },
  79. { include: [ "<bits/sigset.h>", private, "<signal.h>", public ] },
  80. { include: [ "<bits/sigstack.h>", private, "<signal.h>", public ] },
  81. { include: [ "<bits/sigthread.h>", private, "<signal.h>", public ] },
  82. { include: [ "<bits/sockaddr.h>", private, "<sys/un.h>", public ] },
  83. { include: [ "<bits/socket.h>", private, "<sys/socket.h>", private ] },
  84. { include: [ "<bits/socket2.h>", private, "<sys/socket.h>", private ] },
  85. { include: [ "<bits/socket_type.h>", private, "<sys/socket.h>", private ] },
  86. { include: [ "<bits/stab.def>", private, "<stab.h>", public ] },
  87. { include: [ "<bits/stat.h>", private, "<sys/stat.h>", public ] },
  88. { include: [ "<bits/statfs.h>", private, "<sys/statfs.h>", public ] },
  89. { include: [ "<bits/statvfs.h>", private, "<sys/statvfs.h>", public ] },
  90. { include: [ "<bits/stdio-ldbl.h>", private, "<stdio.h>", public ] },
  91. { include: [ "<bits/stdio-lock.h>", private, "<libio.h>", public ] },
  92. { include: [ "<bits/stdio.h>", private, "<stdio.h>", public ] },
  93. { include: [ "<bits/stdio2.h>", private, "<stdio.h>", public ] },
  94. { include: [ "<bits/stdio_lim.h>", private, "<stdio.h>", public ] },
  95. { include: [ "<bits/stdlib-bsearch.h>", private, "<stdlib.h>", public ] },
  96. { include: [ "<bits/stdlib-float.h>", private, "<stdlib.h>", public ] },
  97. { include: [ "<bits/stdlib-ldbl.h>", private, "<stdlib.h>", public ] },
  98. { include: [ "<bits/stdlib.h>", private, "<stdlib.h>", public ] },
  99. { include: [ "<bits/string.h>", private, "<string.h>", public ] },
  100. { include: [ "<bits/string2.h>", private, "<string.h>", public ] },
  101. { include: [ "<bits/string3.h>", private, "<string.h>", public ] },
  102. { include: [ "<bits/stropts.h>", private, "<stropts.h>", public ] },
  103. { include: [ "<bits/struct_stat.h>", private, "<sys/stat.h>", public ] },
  104. { include: [ "<bits/struct_stat.h>", private, "<ftw.h>", public ] },
  105. { include: [ "<bits/sys_errlist.h>", private, "<stdio.h>", public ] },
  106. { include: [ "<bits/syscall.h>", private, "<sys/syscall.h>", public ] },
  107. { include: [ "<bits/sysctl.h>", private, "<sys/sysctl.h>", public ] },
  108. { include: [ "<bits/syslog-ldbl.h>", private, "<sys/syslog.h>", private ] },
  109. { include: [ "<bits/syslog-path.h>", private, "<sys/syslog.h>", private ] },
  110. { include: [ "<bits/syslog.h>", private, "<sys/syslog.h>", private ] },
  111. { include: [ "<bits/termios.h>", private, "<termios.h>", private ] },
  112. { include: [ "<bits/termios-c_lflag.h>", private, "<termios.h>", private ] },
  113. { include: [ "<bits/termios-struct.h>", private, "<termios.h>", private ] },
  114. { include: [ "<bits/termios-tcflow.h>", private, "<termios.h>", private ] },
  115. { include: [ "<bits/time.h>", private, "<time.h>", public ] },
  116. { include: [ "<bits/time.h>", private, "<sys/time.h>", public ] },
  117. { include: [ "<bits/timerfd.h>", private, "<sys/timerfd.h>", public ] },
  118. { include: [ "<bits/timex.h>", private, "<sys/timex.h>", public ] },
  119. { include: [ "<bits/types.h>", private, "<sys/types.h>", public ] },
  120. { include: [ "<bits/types/siginfo_t.h>", private, "<signal.h>", public ] },
  121. { include: [ "<bits/types/siginfo_t.h>", private, "<sys/wait.h>", public ] },
  122. { include: [ "<bits/uio.h>", private, "<sys/uio.h>", public ] },
  123. { include: [ "<bits/unistd.h>", private, "<unistd.h>", private ] },
  124. { include: [ "<bits/ustat.h>", private, "<sys/ustat.h>", private ] },
  125. { include: [ "<bits/utmp.h>", private, "<utmp.h>", public ] },
  126. { include: [ "<bits/utmpx.h>", private, "<utmpx.h>", public ] },
  127. { include: [ "<bits/utsname.h>", private, "<sys/utsname.h>", public ] },
  128. { include: [ "<bits/waitflags.h>", private, "<sys/wait.h>", public ] },
  129. { include: [ "<bits/waitstatus.h>", private, "<sys/wait.h>", public ] },
  130. { include: [ "<bits/wchar-ldbl.h>", private, "<wchar.h>", public ] },
  131. { include: [ "<bits/wchar.h>", private, "<wchar.h>", public ] },
  132. { include: [ "<bits/wchar2.h>", private, "<wchar.h>", public ] },
  133. { include: [ "<bits/wordsize.h>", private, "<limits.h>", public ] },
  134. { include: [ "<bits/xopen_lim.h>", private, "<limits.h>", public ] },
  135. { include: [ "<bits/xtitypes.h>", private, "<stropts.h>", public ] },
  136. # Sometimes libc tells you what mapping to do via an '#error':
  137. # # error "Never use <bits/dlfcn.h> directly; include <dlfcn.h> instead."
  138. # or
  139. # # error "Never include <bits/socket_type.h> directly; use <sys/socket.h> instead."
  140. # ( cd /usr/include && grep -R '^ *# *error "Never use\|include' * | perl -nle 'm/<([^>]+).*directly.*<([^>]+)/ && print qq@ { include: [ "<$1>", private, "<$2>", public ] },@' | sort )
  141. { include: [ "<bits/a.out.h>", private, "<a.out.h>", public ] },
  142. { include: [ "<bits/byteswap-16.h>", private, "<byteswap.h>", public ] },
  143. { include: [ "<bits/byteswap.h>", private, "<byteswap.h>", public ] },
  144. { include: [ "<bits/cmathcalls.h>", private, "<complex.h>", public ] },
  145. { include: [ "<bits/confname.h>", private, "<unistd.h>", private ] },
  146. { include: [ "<bits/dirent.h>", private, "<dirent.h>", public ] },
  147. { include: [ "<bits/dlfcn.h>", private, "<dlfcn.h>", public ] },
  148. { include: [ "<bits/elfclass.h>", private, "<link.h>", public ] },
  149. { include: [ "<bits/endian.h>", private, "<endian.h>", public ] },
  150. { include: [ "<bits/epoll.h>", private, "<sys/epoll.h>", public ] },
  151. { include: [ "<bits/eventfd.h>", private, "<sys/eventfd.h>", public ] },
  152. { include: [ "<bits/fcntl-linux.h>", private, "<fcntl.h>", public ] },
  153. { include: [ "<bits/fcntl.h>", private, "<fcntl.h>", public ] },
  154. { include: [ "<bits/fenv.h>", private, "<fenv.h>", public ] },
  155. { include: [ "<bits/huge_val.h>", private, "<math.h>", public ] },
  156. { include: [ "<bits/huge_valf.h>", private, "<math.h>", public ] },
  157. { include: [ "<bits/huge_vall.h>", private, "<math.h>", public ] },
  158. { include: [ "<bits/in.h>", private, "<netinet/in.h>", private ] },
  159. { include: [ "<bits/inf.h>", private, "<math.h>", public ] },
  160. { include: [ "<bits/inotify.h>", private, "<sys/inotify.h>", public ] },
  161. { include: [ "<bits/ioctl-types.h>", private, "<sys/ioctl.h>", public ] },
  162. { include: [ "<bits/ioctls.h>", private, "<sys/ioctl.h>", public ] },
  163. { include: [ "<bits/ipc.h>", private, "<sys/ipc.h>", public ] },
  164. { include: [ "<bits/ipctypes.h>", private, "<sys/ipc.h>", public ] },
  165. { include: [ "<bits/locale.h>", private, "<locale.h>", public ] },
  166. { include: [ "<bits/math-finite.h>", private, "<math.h>", public ] },
  167. { include: [ "<bits/mathdef.h>", private, "<math.h>", public ] },
  168. { include: [ "<bits/mathinline.h>", private, "<math.h>", public ] },
  169. { include: [ "<bits/mman-linux.h>", private, "<sys/mman.h>", public ] },
  170. { include: [ "<bits/mman.h>", private, "<sys/mman.h>", public ] },
  171. { include: [ "<bits/mqueue.h>", private, "<mqueue.h>", public ] },
  172. { include: [ "<bits/msq.h>", private, "<sys/msg.h>", public ] },
  173. { include: [ "<bits/nan.h>", private, "<math.h>", public ] },
  174. { include: [ "<bits/param.h>", private, "<sys/param.h>", public ] },
  175. { include: [ "<bits/poll.h>", private, "<sys/poll.h>", private ] },
  176. { include: [ "<bits/predefs.h>", private, "<features.h>", public ] },
  177. { include: [ "<bits/resource.h>", private, "<sys/resource.h>", public ] },
  178. { include: [ "<bits/select.h>", private, "<sys/select.h>", public ] },
  179. { include: [ "<bits/semaphore.h>", private, "<semaphore.h>", public ] },
  180. { include: [ "<bits/sigcontext.h>", private, "<signal.h>", public ] },
  181. { include: [ "<bits/signalfd.h>", private, "<sys/signalfd.h>", public ] },
  182. { include: [ "<bits/stdlib-float.h>", private, "<stdlib.h>", public ] },
  183. { include: [ "<bits/string.h>", private, "<string.h>", public ] },
  184. { include: [ "<bits/string2.h>", private, "<string.h>", public ] },
  185. { include: [ "<bits/string3.h>", private, "<string.h>", public ] },
  186. { include: [ "<bits/timerfd.h>", private, "<sys/timerfd.h>", public ] },
  187. { include: [ "<bits/typesizes.h>", private, "<sys/types.h>", public ] },
  188. # Top-level #includes that just forward to another file:
  189. # $ for i in /usr/include/*; do [ -f $i ] } && [ `wc -l < $i` = 1 ] } && echo $i; done
  190. # (poll.h, syscall.h, syslog.h, ustat.h, wait.h).
  191. # For each file, I looked at the list of canonical header files --
  192. # http://www.opengroup.org/onlinepubs/9699919799/idx/head.html --
  193. # to decide which of the two files is canonical. If neither is
  194. # on the POSIX.1 1998 list, I just choose the top-level one.
  195. { include: [ "<sys/poll.h>", private, "<poll.h>", public ] },
  196. { include: [ "<sys/syslog.h>", private, "<syslog.h>", public ] },
  197. { include: [ "<sys/ustat.h>", private, "<ustat.h>", public ] },
  198. { include: [ "<wait.h>", private, "<sys/wait.h>", public ] },
  199. # These are all files in bits/ that delegate to asm/ and linux/ to
  200. # do all (or lots) of the work. Note these are private->private.
  201. # $ for i in /usr/include/bits/*; do for dir in asm linux; do grep -H -e $dir/`basename $i` $i; done; done
  202. { include: [ "<linux/errno.h>", private, "<bits/errno.h>", private ] },
  203. { include: [ "<asm/ioctls.h>", private, "<bits/ioctls.h>", private ] },
  204. { include: [ "<asm/socket.h>", private, "<bits/socket.h>", private ] },
  205. { include: [ "<linux/socket.h>", private, "<bits/socket.h>", private ] },
  206. # Some asm files have 32- and 64-bit variants:
  207. # $ ls /usr/include/asm/*_{32,64}.h
  208. { include: [ "<asm/posix_types_32.h>", private, "<asm/posix_types.h>", public ] },
  209. { include: [ "<asm/posix_types_64.h>", private, "<asm/posix_types.h>", public ] },
  210. { include: [ "<asm/unistd_32.h>", private, "<asm/unistd.h>", private ] },
  211. { include: [ "<asm/unistd_64.h>", private, "<asm/unistd.h>", private ] },
  212. # I don't know what grep would have found these. I found them
  213. # via user report.
  214. { include: [ "<asm/errno.h>", private, "<errno.h>", public ] },
  215. { include: [ "<asm/errno-base.h>", private, "<errno.h>", public ] },
  216. { include: [ "<asm/ptrace-abi.h>", private, "<asm/ptrace.h>", public ] },
  217. { include: [ "<asm/unistd.h>", private, "<sys/syscall.h>", public ] },
  218. { include: [ "<linux/limits.h>", private, "<limits.h>", public ] }, # PATH_MAX
  219. { include: [ "<linux/prctl.h>", private, "<sys/prctl.h>", public ] },
  220. { include: [ "<sys/ucontext.h>", private, "<ucontext.h>", public ] },
  221. # Exports guaranteed by the C standard
  222. { include: [ "<stdint.h>", public, "<inttypes.h>", public ] },
  223. ]
  224. # vim: set ft=toml: