stubs.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. /*
  2. * system call not available stub
  3. *
  4. * Copyright (C) 2009 Analog Devices Inc.
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. /* Please keep the list sorted alphabetically, in ascending order
  9. * of the stub name! */
  10. #include <errno.h>
  11. #include <bits/wordsize.h>
  12. #include <sys/syscall.h>
  13. #ifdef __UCLIBC_HAS_STUBS__
  14. __attribute_used__ static int enosys_stub(void)
  15. {
  16. __set_errno(ENOSYS);
  17. return -1;
  18. }
  19. __attribute_used__ static int ret_enosys_stub(void)
  20. {
  21. return ENOSYS;
  22. }
  23. #define make_stub(stub) \
  24. link_warning(stub, #stub ": this function is not implemented") \
  25. strong_alias(enosys_stub, stub)
  26. #define make_ret_stub(stub) \
  27. link_warning(stub, #stub ": this function is not implemented") \
  28. strong_alias(ret_enosys_stub, stub)
  29. #ifndef __ARCH_USE_MMU__
  30. # undef __NR_fork
  31. #endif
  32. #ifdef __arm__
  33. # define __NR_fadvise64_64 __NR_arm_fadvise64_64
  34. # define __NR_fadvise64 __NR_arm_fadvise64_64
  35. /* ARM always provides funcs w/out syscalls; disable the stubs */
  36. # define __NR_ioperm 0
  37. # define __NR_iopl 0
  38. #endif
  39. #ifdef __mips__
  40. # define __NR_fadvise64_64 __NR_fadvise64
  41. #endif
  42. #ifdef __xtensa__
  43. # define __NR_fadvise64 __NR_fadvise64_64
  44. #endif
  45. #if !defined __NR_accept && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  46. make_stub(accept)
  47. #endif
  48. #if !defined __NR_accept4 && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__ && defined __UCLIBC_LINUX_SPECIFIC__
  49. make_stub(accept4)
  50. #endif
  51. #if !defined __NR_arch_prctl && defined __UCLIBC_LINUX_SPECIFIC__
  52. make_stub(arch_prctl)
  53. #endif
  54. #if !defined __NR_bdflush && defined __UCLIBC_LINUX_SPECIFIC__
  55. make_stub(bdflush)
  56. #endif
  57. #if !defined __NR_bind && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  58. make_stub(bind)
  59. #endif
  60. #if !defined __NR_capget && defined __UCLIBC_LINUX_SPECIFIC__
  61. make_stub(capget)
  62. #endif
  63. #if !defined __NR_capset && defined __UCLIBC_LINUX_SPECIFIC__
  64. make_stub(capset)
  65. #endif
  66. #if !defined __NR_connect && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  67. make_stub(connect)
  68. #endif
  69. #if !defined __NR_delete_module && defined __UCLIBC_LINUX_MODULE_26__
  70. make_stub(delete_module)
  71. #endif
  72. #if !defined __NR_epoll_create && defined __UCLIBC_HAS_EPOLL__ \
  73. && !defined __NR_epoll_create1
  74. make_stub(epoll_create)
  75. #endif
  76. #if !defined __NR_epoll_ctl && defined __UCLIBC_HAS_EPOLL__
  77. make_stub(epoll_ctl)
  78. #endif
  79. #if !defined __NR_epoll_pwait && defined __UCLIBC_HAS_EPOLL__
  80. make_stub(epoll_pwait)
  81. #endif
  82. #if !defined __NR_epoll_wait && defined __UCLIBC_HAS_EPOLL__ \
  83. && !defined __NR_epoll_pwait
  84. make_stub(epoll_wait)
  85. #endif
  86. #if !defined __NR_eventfd && !defined __NR_eventfd2 && defined __UCLIBC_LINUX_SPECIFIC__
  87. make_stub(eventfd)
  88. #endif
  89. #if !defined __NR_fdatasync && !defined __NR_osf_fdatasync
  90. make_stub(fdatasync)
  91. #endif
  92. #ifndef __NR_fgetxattr
  93. make_stub(fgetxattr)
  94. #endif
  95. #ifndef __NR_flistxattr
  96. make_stub(flistxattr)
  97. #endif
  98. #if !defined __NR_fork && !defined __NR_clone
  99. make_stub(fork)
  100. #endif
  101. #ifndef __NR_fremovexattr
  102. make_stub(fremovexattr)
  103. #endif
  104. #ifndef __NR_fsetxattr
  105. make_stub(fsetxattr)
  106. #endif
  107. #if !defined __NR_fstatfs && !defined __NR_fstatfs64 \
  108. && defined __UCLIBC_LINUX_SPECIFIC__
  109. make_stub(fstatfs)
  110. #endif
  111. #ifndef __NR_get_kernel_syms
  112. make_stub(get_kernel_syms)
  113. #endif
  114. #if !defined __NR_getpeername && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  115. make_stub(getpeername)
  116. #endif
  117. #if !defined __NR_getpgrp && !defined __NR_getpgid
  118. make_stub(getpgrp)
  119. #endif
  120. #if !defined __NR_getrandom && defined __UCLIBC_LINUX_SPECIFIC__
  121. make_stub(getrandom)
  122. #endif
  123. #if !defined __NR_getsockname && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  124. make_stub(getsockname)
  125. #endif
  126. #if !defined __NR_getsockopt && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  127. make_stub(getsockopt)
  128. #endif
  129. #ifndef __NR_getxattr
  130. make_stub(getxattr)
  131. #endif
  132. #if !defined __NR_init_module && defined __UCLIBC_LINUX_MODULE_26__
  133. make_stub(init_module)
  134. #endif
  135. #if !defined __NR_inotify_add_watch && defined __UCLIBC_LINUX_SPECIFIC__
  136. make_stub(inotify_add_watch)
  137. #endif
  138. #if !defined __NR_inotify_init && defined __UCLIBC_LINUX_SPECIFIC__ \
  139. && !defined __NR_inotify_init1
  140. make_stub(inotify_init)
  141. #endif
  142. #if !defined __NR_inotify_init1 && defined __UCLIBC_LINUX_SPECIFIC__
  143. make_stub(inotify_init1)
  144. #endif
  145. #if !defined __NR_inotify_rm_watch && defined __UCLIBC_LINUX_SPECIFIC__
  146. make_stub(inotify_rm_watch)
  147. #endif
  148. #if !defined __NR_ioperm && defined __UCLIBC_LINUX_SPECIFIC__
  149. make_stub(ioperm)
  150. #endif
  151. #if !defined __NR_iopl && defined __UCLIBC_LINUX_SPECIFIC__
  152. make_stub(iopl)
  153. #endif
  154. #ifndef __NR_lgetxattr
  155. make_stub(lgetxattr)
  156. #endif
  157. #if !defined __NR_listen && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  158. make_stub(listen)
  159. #endif
  160. #ifndef __NR_listxattr
  161. make_stub(listxattr)
  162. #endif
  163. #ifndef __NR_llistxattr
  164. make_stub(llistxattr)
  165. #endif
  166. #ifndef __NR_lremovexattr
  167. make_stub(lremovexattr)
  168. #endif
  169. #ifndef __NR_lsetxattr
  170. make_stub(lsetxattr)
  171. #endif
  172. #if !defined __NR_madvise && defined __UCLIBC_LINUX_SPECIFIC__
  173. make_stub(madvise)
  174. #endif
  175. #if !defined __NR_modify_ldt && defined __UCLIBC_LINUX_SPECIFIC__
  176. make_stub(modify_ldt)
  177. #endif
  178. #ifndef __NR_openat
  179. make_stub(openat)
  180. make_stub(openat64)
  181. #endif
  182. #if !defined __NR_personality && defined __UCLIBC_LINUX_SPECIFIC__
  183. make_stub(personality)
  184. #endif
  185. #if !defined __NR_pipe2 && defined __UCLIBC_LINUX_SPECIFIC__
  186. make_stub(pipe2)
  187. #endif
  188. #if !defined __NR_pivot_root && defined __UCLIBC_LINUX_SPECIFIC__
  189. make_stub(pivot_root)
  190. #endif
  191. #if !defined __NR_fadvise64
  192. make_ret_stub(posix_fadvise)
  193. #endif
  194. #if !defined __NR_fadvise64_64 && __WORDSIZE == 32
  195. make_ret_stub(posix_fadvise64)
  196. #endif
  197. #ifndef __NR_madvise
  198. make_ret_stub(posix_madvise)
  199. #endif
  200. #if !defined __NR_ppoll && defined __UCLIBC_LINUX_SPECIFIC__
  201. make_stub(ppoll)
  202. #endif
  203. #if !defined __NR_prctl && defined __UCLIBC_LINUX_SPECIFIC__
  204. make_stub(prctl)
  205. #endif
  206. #if !defined __NR_readahead && defined __UCLIBC_LINUX_SPECIFIC__
  207. make_stub(readahead)
  208. #endif
  209. #if !defined __NR_reboot && defined __UCLIBC_LINUX_SPECIFIC__
  210. make_stub(reboot)
  211. #endif
  212. #if !defined __NR_recv && !defined __NR_socketcall && !defined __NR_recvfrom && defined __UCLIBC_HAS_SOCKET__
  213. make_stub(recv)
  214. #endif
  215. #if !defined __NR_recvfrom && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  216. make_stub(recvfrom)
  217. #endif
  218. #if !defined __NR_recvmsg && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  219. make_stub(recvmsg)
  220. #endif
  221. #if !defined __NR_remap_file_pages && defined __UCLIBC_LINUX_SPECIFIC__
  222. make_stub(remap_file_pages)
  223. #endif
  224. #ifndef __NR_removexattr
  225. make_stub(removexattr)
  226. #endif
  227. #ifndef __NR_renameat
  228. make_stub(renameat)
  229. #endif
  230. #if !defined __NR_sched_getaffinity && defined __UCLIBC_LINUX_SPECIFIC__
  231. make_stub(sched_getaffinity)
  232. #endif
  233. #if !defined __NR_getcpu && defined __UCLIBC_LINUX_SPECIFIC__ && ((defined __x86_64__ && !defined __UCLIBC_HAS_TLS__) || !defined __x86_64__)
  234. make_stub(sched_getcpu)
  235. #endif
  236. #if !defined __NR_sched_setaffinity && defined __UCLIBC_LINUX_SPECIFIC__
  237. make_stub(sched_setaffinity)
  238. #endif
  239. #if !defined __NR_send && !defined __NR_socketcall && !defined __NR_sendto && defined __UCLIBC_HAS_SOCKET__
  240. make_stub(send)
  241. #endif
  242. #if !defined __NR_sendfile && !defined __NR_sendfile64 \
  243. && defined __UCLIBC_LINUX_SPECIFIC__
  244. make_stub(sendfile)
  245. #endif
  246. #if !defined __NR_sendfile64 && !defined __NR_sendfile && defined __UCLIBC_LINUX_SPECIFIC__
  247. make_stub(sendfile64)
  248. #endif
  249. #if !defined __NR_sendmsg && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  250. make_stub(sendmsg)
  251. #endif
  252. #if !defined __NR_sendto && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  253. make_stub(sendto)
  254. #endif
  255. #if ((__WORDSIZE == 32 && (!defined __NR_setfsgid32 && !defined __NR_setfsgid)) || (__WORDSIZE == 64 && !defined __NR_setfsgid)) && defined __UCLIBC_LINUX_SPECIFIC__
  256. make_stub(setfsgid)
  257. #endif
  258. #if ((__WORDSIZE == 32 && (!defined __NR_setfsuid32 && !defined __NR_setfsuid)) || (__WORDSIZE == 64 && !defined __NR_setfsuid)) && defined __UCLIBC_LINUX_SPECIFIC__
  259. make_stub(setfsuid)
  260. #endif
  261. #if !defined __NR_setns && defined __UCLIBC_LINUX_SPECIFIC__
  262. make_stub(setns)
  263. #endif
  264. #if !defined __NR_setresgid32 && !defined __NR_setresgid && defined __UCLIBC_LINUX_SPECIFIC__
  265. make_stub(setresgid)
  266. #endif
  267. #if !defined __NR_setresuid32 && !defined __NR_setresuid && defined __UCLIBC_LINUX_SPECIFIC__
  268. make_stub(setresuid)
  269. #endif
  270. #if !defined __NR_setsockopt && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  271. make_stub(setsockopt)
  272. #endif
  273. #ifndef __NR_setxattr
  274. make_stub(setxattr)
  275. #endif
  276. #if !defined __NR_shutdown && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  277. make_stub(shutdown)
  278. #endif
  279. #if !defined __NR_signalfd4 && !defined __NR_signalfd && defined __UCLIBC_LINUX_SPECIFIC__
  280. make_stub(signalfd)
  281. #endif
  282. #ifndef __NR_rt_sigtimedwait
  283. make_stub(sigtimedwait)
  284. make_stub(sigwaitinfo)
  285. #endif
  286. #ifndef __NR_rt_sigqueueinfo
  287. make_stub(sigqueue)
  288. #endif
  289. #if !defined __NR_socket && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  290. make_stub(socket)
  291. #endif
  292. #if !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  293. make_stub(socketcall)
  294. #endif
  295. #if !defined __NR_socketpair && !defined __NR_socketcall && defined __UCLIBC_HAS_SOCKET__
  296. make_stub(socketpair)
  297. #endif
  298. #if !defined __NR_stime && !defined __NR_settimeofday
  299. make_stub(stime)
  300. make_stub(settimeofday)
  301. #endif
  302. #if !defined __NR_splice && defined __UCLIBC_LINUX_SPECIFIC__
  303. make_stub(splice)
  304. #endif
  305. #if !defined __NR_swapoff && defined __UCLIBC_LINUX_SPECIFIC__
  306. make_stub(swapoff)
  307. #endif
  308. #if !defined __NR_swapon && defined __UCLIBC_LINUX_SPECIFIC__
  309. make_stub(swapon)
  310. #endif
  311. #if !defined __NR_symlink && !defined __NR_symlinkat
  312. make_stub(symlink)
  313. #endif
  314. #if !defined __NR_sync_file_range && defined __UCLIBC_LINUX_SPECIFIC__
  315. make_stub(sync_file_range)
  316. #endif
  317. #if !defined __NR__sysctl && defined __UCLIBC_LINUX_SPECIFIC__
  318. make_stub(_sysctl)
  319. #endif
  320. #if !defined __NR_sysinfo && defined __UCLIBC_LINUX_SPECIFIC__
  321. make_stub(sysinfo)
  322. #endif
  323. #if !defined __NR_tee && defined __UCLIBC_LINUX_SPECIFIC__
  324. make_stub(tee)
  325. #endif
  326. #if !defined __NR_timerfd_create && defined __UCLIBC_LINUX_SPECIFIC__
  327. make_stub(timerfd_create)
  328. #endif
  329. #if !defined __NR_timerfd_settime && defined __UCLIBC_LINUX_SPECIFIC__
  330. make_stub(timerfd_settime)
  331. #endif
  332. #if !defined __NR_timerfd_gettime && defined __UCLIBC_LINUX_SPECIFIC__
  333. make_stub(timerfd_gettime)
  334. #endif
  335. #ifndef __NR_utimensat
  336. make_stub(futimens)
  337. make_stub(utimensat)
  338. # ifndef __NR_lutimes
  339. make_stub(lutimes)
  340. # endif
  341. #endif
  342. #ifndef __NR_utimensat
  343. #if !defined __NR_utime && !defined __NR_utimes
  344. /*make_stub(utime) obsoleted */
  345. make_stub(utimes)
  346. #endif
  347. #endif
  348. #if !defined __NR_umount && !defined __NR_umount2 && defined __UCLIBC_LINUX_SPECIFIC__
  349. make_stub(umount)
  350. #endif
  351. #if !defined __NR_umount2 && defined __UCLIBC_LINUX_SPECIFIC__
  352. make_stub(umount2)
  353. #endif
  354. #if !defined __NR_unshare && defined __UCLIBC_LINUX_SPECIFIC__
  355. make_stub(unshare)
  356. #endif
  357. #if defined __UCLIBC_SV4_DEPRECATED__ && !defined __NR_ustat
  358. make_stub(ustat)
  359. #endif
  360. #if !defined __NR_vhangup && defined __UCLIBC_LINUX_SPECIFIC__
  361. make_stub(vhangup)
  362. #endif
  363. #if !defined __NR_vmsplice && defined __UCLIBC_LINUX_SPECIFIC__
  364. make_stub(vmsplice)
  365. #endif
  366. #endif