syscalls.c 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Syscalls for uClibc
  4. *
  5. * Copyright (C) 2000 by Lineo, inc
  6. * Copyright (C) 2001 by Erik Andersen
  7. * Written by Erik Andersen <andersen@codpoet.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Library General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  17. * for more details.
  18. *
  19. * You should have received a copy of the GNU Library General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #include <features.h>
  25. #include <errno.h>
  26. #include <sys/types.h>
  27. #include <sys/syscall.h>
  28. //#define __NR_exit 1
  29. #ifdef L__exit
  30. /* Do not include unistd.h, so gcc doesn't whine about
  31. * _exit returning. It really doesn't return... */
  32. #define __NR__exit __NR_exit
  33. #ifdef __STR_NR_exit
  34. #define __STR_NR__exit __STR_NR_exit
  35. #endif
  36. _syscall1(void, _exit, int, status);
  37. #endif
  38. //#define __NR_fork 2
  39. #ifdef L___libc_fork
  40. #include <unistd.h>
  41. # ifdef __UCLIBC_HAS_MMU__
  42. #define __NR___libc_fork __NR_fork
  43. _syscall0(pid_t, __libc_fork);
  44. weak_alias (__libc_fork, fork)
  45. # else
  46. pid_t fork(void)
  47. {
  48. __set_errno(ENOSYS);
  49. return -1;
  50. }
  51. # endif
  52. #endif
  53. //#define __NR_read 3
  54. #ifdef L___libc_read
  55. #include <unistd.h>
  56. #define __NR___libc_read __NR_read
  57. _syscall3(ssize_t, __libc_read, int, fd, __ptr_t, buf, size_t, count);
  58. weak_alias(__libc_read, read)
  59. #endif
  60. //#define __NR_write 4
  61. #ifdef L___libc_write
  62. #include <unistd.h>
  63. #define __NR___libc_write __NR_write
  64. _syscall3(ssize_t, __libc_write, int, fd, const __ptr_t, buf, size_t, count);
  65. weak_alias(__libc_write, write)
  66. #endif
  67. //#define __NR_open 5
  68. #ifdef L___open
  69. #include <stdarg.h>
  70. #include <fcntl.h>
  71. #define __NR___open __NR_open
  72. #ifdef __STR_NR_open
  73. #define __STR_NR___open __STR_NR_open
  74. #endif
  75. _syscall3(int, __open, const char *, fn, int, flags, mode_t, mode);
  76. int __libc_open(const char *file, int oflag, ...)
  77. {
  78. int mode = 0;
  79. if (oflag & O_CREAT) {
  80. va_list args;
  81. va_start(args, oflag);
  82. mode = va_arg(args, int);
  83. va_end(args);
  84. }
  85. return __open(file, oflag, mode);
  86. }
  87. weak_alias(__libc_open, open)
  88. #endif
  89. //#define __NR_close 6
  90. #ifdef L___libc_close
  91. #include <unistd.h>
  92. #define __NR___libc_close __NR_close
  93. _syscall1(int, __libc_close, int, fd);
  94. weak_alias(__libc_close, close)
  95. #endif
  96. //#define __NR_waitpid 7
  97. // Implemented using wait4
  98. //#define __NR_creat 8
  99. #ifdef L_creat
  100. #include <fcntl.h>
  101. _syscall2(int, creat, const char *, file, mode_t, mode);
  102. #endif
  103. //#define __NR_link 9
  104. #ifdef L_link
  105. #include <unistd.h>
  106. _syscall2(int, link, const char *, oldpath, const char *, newpath);
  107. #endif
  108. //#define __NR_unlink 10
  109. #ifdef L_unlink
  110. #include <unistd.h>
  111. _syscall1(int, unlink, const char *, pathname);
  112. #endif
  113. //#define __NR_execve 11
  114. #ifdef L_execve
  115. #include <unistd.h>
  116. _syscall3(int, execve, const char *, filename, char *const *, argv,
  117. char *const *, envp);
  118. #endif
  119. //#define __NR_chdir 12
  120. #ifdef L_chdir
  121. #include <unistd.h>
  122. _syscall1(int, chdir, const char *, path);
  123. #endif
  124. //#define __NR_time 13
  125. #ifdef L_time
  126. #include <time.h>
  127. _syscall1(time_t, time, time_t *, t);
  128. #endif
  129. //#define __NR_mknod 14
  130. #ifdef L_mknod
  131. #include <unistd.h>
  132. extern int mknod(const char *pathname, mode_t mode, dev_t dev);
  133. _syscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev);
  134. int __xmknod (int version, const char * path, mode_t mode, dev_t *dev)
  135. {
  136. switch(version)
  137. {
  138. case 1:
  139. return mknod (path, mode, *dev);
  140. default:
  141. __set_errno(EINVAL);
  142. return -1;
  143. }
  144. }
  145. #endif
  146. //#define __NR_chmod 15
  147. #ifdef L_chmod
  148. #include <sys/stat.h>
  149. _syscall2(int, chmod, const char *, path, mode_t, mode);
  150. #endif
  151. /* Old kernels don't have lchown -- do chown instead. This
  152. * is sick and wrong, but at least things will compile.
  153. * They may not follow links when they should though... */
  154. #ifndef __NR_lchown
  155. #define __NR_lchown __NR_chown
  156. #endif
  157. //#define __NR_lchown 16
  158. #ifdef L_lchown
  159. #include <unistd.h>
  160. _syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);
  161. #endif
  162. //#define __NR_break 17
  163. //#define __NR_oldstat 18
  164. //#define __NR_lseek 19
  165. #ifdef L___libc_lseek
  166. #include <unistd.h>
  167. #define __NR___libc_lseek __NR_lseek
  168. _syscall3(off_t, __libc_lseek, int, fildes, off_t, offset, int, whence);
  169. weak_alias(__libc_lseek, lseek)
  170. #endif
  171. //#define __NR_getpid 20
  172. #ifdef L___libc_getpid
  173. #include <unistd.h>
  174. #define __NR___libc_getpid __NR_getpid
  175. _syscall0(pid_t, __libc_getpid);
  176. weak_alias(__libc_getpid, getpid)
  177. weak_alias(__libc_getpid, __getpid)
  178. #endif
  179. //#define __NR_mount 21
  180. #ifdef L_mount
  181. #include <sys/mount.h>
  182. _syscall5(int, mount, const char *, specialfile, const char *, dir,
  183. const char *, filesystemtype, unsigned long, rwflag,
  184. const void *, data);
  185. #endif
  186. //#define __NR_umount 22
  187. #ifdef L_umount
  188. #include <sys/mount.h>
  189. _syscall1(int, umount, const char *, specialfile);
  190. #endif
  191. //#define __NR_setuid 23
  192. #ifdef L___setuid
  193. #define __NR___setuid __NR_setuid
  194. #include <unistd.h>
  195. static inline
  196. _syscall1(int, __setuid, uid_t, uid);
  197. int setuid(uid_t uid)
  198. {
  199. if (uid == (uid_t) ~0) {
  200. __set_errno (EINVAL);
  201. return -1;
  202. }
  203. return(__setuid(uid));
  204. }
  205. #endif
  206. //#define __NR_getuid 24
  207. #ifdef L_getuid
  208. #include <unistd.h>
  209. _syscall0(gid_t, getuid);
  210. #endif
  211. //#define __NR_stime 25
  212. #ifdef L_stime
  213. #include <time.h>
  214. _syscall1(int, stime, const time_t *, t);
  215. #endif
  216. //#define __NR_ptrace 26
  217. #ifdef L___ptrace
  218. #include <sys/ptrace.h>
  219. #define __NR___ptrace __NR_ptrace
  220. #ifdef __STR_NR_ptrace
  221. #define __STR_NR___ptrace __STR_NR_ptrace
  222. #endif
  223. _syscall4(long, __ptrace, enum __ptrace_request, request, pid_t, pid,
  224. void*, addr, void*, data);
  225. #endif
  226. //#define __NR_alarm 27
  227. #ifdef L_alarm
  228. #include <unistd.h>
  229. _syscall1(unsigned int, alarm, unsigned int, seconds);
  230. #endif
  231. //#define __NR_oldfstat 28
  232. //#define __NR_pause 29
  233. #ifdef L___libc_pause
  234. #include <unistd.h>
  235. #define __NR___libc_pause __NR_pause
  236. _syscall0(int, __libc_pause);
  237. weak_alias(__libc_pause, pause)
  238. #endif
  239. //#define __NR_utime 30
  240. #ifdef L_utime
  241. #include <utime.h>
  242. _syscall2(int, utime, const char *, filename, const struct utimbuf *, buf);
  243. #endif
  244. //#define __NR_stty 31
  245. #ifdef L_stty
  246. #include <sgtty.h>
  247. int stty (int __fd, __const struct sgttyb *__params);
  248. {
  249. __set_errno(ENOSYS);
  250. return -1;
  251. }
  252. #endif
  253. //#define __NR_gtty 32
  254. #ifdef L_gtty
  255. #include <sgtty.h>
  256. int gtty (int __fd, struct sgttyb *__params)
  257. {
  258. __set_errno(ENOSYS);
  259. return -1;
  260. }
  261. #endif
  262. //#define __NR_access 33
  263. #ifdef L_access
  264. #include <unistd.h>
  265. _syscall2(int, access, const char *, pathname, int, mode);
  266. #endif
  267. //#define __NR_nice 34
  268. #ifdef L_nice
  269. #include <unistd.h>
  270. _syscall1(int, nice, int, inc);
  271. #endif
  272. //#define __NR_ftime 35
  273. //#define __NR_sync 36
  274. #ifdef L_sync
  275. #include <unistd.h>
  276. _syscall0(void, sync);
  277. #endif
  278. //#define __NR_kill 37
  279. #ifdef L_kill
  280. #include <signal.h>
  281. #undef kill
  282. _syscall2(int, kill, pid_t, pid, int, sig);
  283. #endif
  284. //#define __NR_rename 38
  285. #ifdef L_rename
  286. #include <stdio.h>
  287. _syscall2(int, rename, const char *, oldpath, const char *, newpath);
  288. #endif
  289. //#define __NR_mkdir 39
  290. #ifdef L_mkdir
  291. #include <sys/stat.h>
  292. _syscall2(int, mkdir, const char *, pathname, mode_t, mode);
  293. #endif
  294. //#define __NR_rmdir 40
  295. #ifdef L_rmdir
  296. #include <unistd.h>
  297. _syscall1(int, rmdir, const char *, pathname);
  298. #endif
  299. //#define __NR_dup 41
  300. #ifdef L_dup
  301. #include <unistd.h>
  302. _syscall1(int, dup, int, oldfd);
  303. #endif
  304. //#define __NR_pipe 42
  305. #ifdef L_pipe
  306. #include <unistd.h>
  307. _syscall1(int, pipe, int *, filedes);
  308. #endif
  309. //#define __NR_times 43
  310. #ifdef L_times
  311. #include <sys/times.h>
  312. _syscall1(clock_t, times, struct tms *, buf);
  313. #endif
  314. //#define __NR_prof 44
  315. //#define __NR_brk 45
  316. //#define __NR_setgid 46
  317. #ifdef L_setgid
  318. #include <unistd.h>
  319. _syscall1(int, setgid, gid_t, gid);
  320. #endif
  321. //#define __NR_getgid 47
  322. #ifdef L_getgid
  323. #include <unistd.h>
  324. _syscall0(gid_t, getgid);
  325. #endif
  326. //#define __NR_signal 48
  327. //#define __NR_geteuid 49
  328. #ifdef L_geteuid
  329. # ifdef __NR_geteuid
  330. # include <unistd.h>
  331. _syscall0(uid_t, geteuid);
  332. # else
  333. uid_t geteuid(void)
  334. {
  335. return (getuid());
  336. }
  337. # endif
  338. #endif
  339. //#define __NR_getegid 50
  340. #ifdef L_getegid
  341. # ifdef __NR_getegid
  342. # include <unistd.h>
  343. _syscall0(gid_t, getegid);
  344. # else
  345. gid_t getegid(void)
  346. {
  347. return (getgid());
  348. }
  349. # endif
  350. #endif
  351. //#define __NR_acct 51
  352. #ifdef L_acct
  353. #include <unistd.h>
  354. _syscall1(int, acct, const char *, filename);
  355. #endif
  356. //#define __NR_umount2 52
  357. #ifdef L_umount2
  358. # ifdef __NR_umount2 /* Old kernels don't have umount2 */
  359. # include <sys/mount.h>
  360. _syscall2(int, umount2, const char *, special_file, int, flags);
  361. # else
  362. int umount2(const char * special_file, int flags)
  363. {
  364. __set_errno(ENOSYS);
  365. return -1;
  366. }
  367. # endif
  368. #endif
  369. //#define __NR_lock 53
  370. //#define __NR_ioctl 54
  371. #ifdef L__ioctl
  372. #include <stdarg.h>
  373. #include <sys/ioctl.h>
  374. #define __NR__ioctl __NR_ioctl
  375. #ifdef __STR_NR_ioctl
  376. #define __STR_NR__ioctl __STR_NR_ioctl
  377. #endif
  378. extern int _ioctl(int fd, int request, void *arg);
  379. _syscall3(int, _ioctl, int, fd, int, request, void *, arg);
  380. int ioctl(int fd, unsigned long int request, ...)
  381. {
  382. void *arg;
  383. va_list list;
  384. va_start(list, request);
  385. arg = va_arg(list, void *);
  386. va_end(list);
  387. return _ioctl(fd, request, arg);
  388. }
  389. #endif
  390. //#define __NR_fcntl 55
  391. #ifdef L__fcntl
  392. #include <stdarg.h>
  393. #include <fcntl.h>
  394. #define __NR__fcntl __NR_fcntl
  395. #ifdef __STR_NR_fcntl
  396. #define __STR_NR__fcntl __STR_NR_fcntl
  397. #endif
  398. extern int _fcntl(int fd, int cmd, long arg);
  399. _syscall3(int, _fcntl, int, fd, int, cmd, long, arg);
  400. int __libc_fcntl(int fd, int command, ...)
  401. {
  402. long arg;
  403. va_list list;
  404. va_start(list, command);
  405. arg = va_arg(list, long);
  406. va_end(list);
  407. return _fcntl(fd, command, arg);
  408. }
  409. weak_alias(__libc_fcntl, fcntl)
  410. #endif
  411. //#define __NR_mpx 56
  412. //#define __NR_setpgid 57
  413. #ifdef L_setpgid
  414. #include <unistd.h>
  415. _syscall2(int, setpgid, pid_t, pid, pid_t, pgid);
  416. #endif
  417. //#define __NR_ulimit 58
  418. //#define __NR_oldolduname 59
  419. //#define __NR_umask 60
  420. #ifdef L_umask
  421. #include <sys/stat.h>
  422. _syscall1(mode_t, umask, mode_t, mask);
  423. #endif
  424. //#define __NR_chroot 61
  425. #ifdef L_chroot
  426. #include <unistd.h>
  427. _syscall1(int, chroot, const char *, path);
  428. #endif
  429. //#define __NR_ustat 62
  430. //#define __NR_dup2 63
  431. #ifdef L_dup2
  432. #include <unistd.h>
  433. _syscall2(int, dup2, int, oldfd, int, newfd);
  434. #endif
  435. //#define __NR_getppid 64
  436. #ifdef L_getppid
  437. # include <unistd.h>
  438. # ifdef __NR_getppid
  439. _syscall0(pid_t, getppid);
  440. # else
  441. pid_t getppid(void)
  442. {
  443. return (getpid());
  444. }
  445. # endif
  446. #endif
  447. //#define __NR_getpgrp 65
  448. #ifdef L_getpgrp
  449. #include <unistd.h>
  450. _syscall0(pid_t, getpgrp);
  451. #endif
  452. //#define __NR_setsid 66
  453. #ifdef L_setsid
  454. #include <unistd.h>
  455. _syscall0(pid_t, setsid);
  456. #endif
  457. //#define __NR_sigaction 67
  458. #ifndef __NR_rt_sigaction
  459. #define __NR___sigaction __NR_sigaction
  460. #ifdef L___sigaction
  461. #include <signal.h>
  462. #undef sigaction
  463. _syscall3(int, __sigaction, int, signum, const struct sigaction *, act,
  464. struct sigaction *, oldact);
  465. #endif
  466. #endif
  467. //#define __NR_sgetmask 68
  468. //#define __NR_ssetmask 69
  469. //#define __NR_setreuid 70
  470. #ifdef L_setreuid
  471. #include <unistd.h>
  472. _syscall2(int, setreuid, uid_t, ruid, uid_t, euid);
  473. #endif
  474. //#define __NR_setregid 71
  475. #ifdef L_setregid
  476. #include <unistd.h>
  477. _syscall2(int, setregid, gid_t, rgid, gid_t, egid);
  478. #endif
  479. //#define __NR_sigsuspend 72
  480. #ifndef __NR_rt_sigsuspend
  481. #define __NR___sigsuspend __NR_sigsuspend
  482. #ifdef L___sigsuspend
  483. #include <signal.h>
  484. #undef sigsuspend
  485. _syscall3(int, __sigsuspend, int, a, unsigned long int, b, unsigned long int, c);
  486. int sigsuspend (const sigset_t *set)
  487. {
  488. return __sigsuspend(0, 0, set->__val[0]);
  489. }
  490. #endif
  491. #endif
  492. //#define __NR_sigpending 73
  493. #ifndef __NR_rt_sigpending
  494. #ifdef L_sigpending
  495. #include <signal.h>
  496. #undef sigpending
  497. _syscall1(int, sigpending, sigset_t *, set);
  498. #endif
  499. #endif
  500. //#define __NR_sethostname 74
  501. #ifdef L_sethostname
  502. #include <unistd.h>
  503. _syscall2(int, sethostname, const char *, name, size_t, len);
  504. #endif
  505. //#define __NR_setrlimit 75
  506. #ifdef L_setrlimit
  507. #include <unistd.h>
  508. #include <sys/resource.h>
  509. _syscall2(int, setrlimit, int, resource, const struct rlimit *, rlim);
  510. #endif
  511. //#define __NR_getrlimit 76
  512. #ifdef L_getrlimit
  513. #include <unistd.h>
  514. #include <sys/resource.h>
  515. _syscall2(int, getrlimit, int, resource, struct rlimit *, rlim);
  516. #endif
  517. //#define __NR_getrusage 77
  518. #ifdef L_getrusage
  519. #include <unistd.h>
  520. #include <wait.h>
  521. _syscall2(int, getrusage, int, who, struct rusage *, usage);
  522. #endif
  523. //#define __NR_gettimeofday 78
  524. #ifdef L_gettimeofday
  525. #include <sys/time.h>
  526. _syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
  527. #endif
  528. //#define __NR_settimeofday 79
  529. #ifdef L_settimeofday
  530. #include <sys/time.h>
  531. _syscall2(int, settimeofday, const struct timeval *, tv,
  532. const struct timezone *, tz);
  533. #endif
  534. //#define __NR_getgroups 80
  535. #ifdef L_getgroups
  536. #include <unistd.h>
  537. _syscall2(int, getgroups, int, size, gid_t *, list);
  538. #endif
  539. //#define __NR_setgroups 81
  540. #ifdef L_setgroups
  541. #include <unistd.h>
  542. #include <grp.h>
  543. _syscall2(int, setgroups, size_t, size, const gid_t *, list);
  544. #endif
  545. //#define __NR_select 82
  546. //#define __NR_symlink 83
  547. #ifdef L_symlink
  548. #include <unistd.h>
  549. _syscall2(int, symlink, const char *, oldpath, const char *, newpath);
  550. #endif
  551. //#define __NR_oldlstat 84
  552. //#define __NR_readlink 85
  553. #ifdef L_readlink
  554. #include <unistd.h>
  555. _syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);
  556. #endif
  557. //#define __NR_uselib 86
  558. #ifdef L_uselib
  559. #include <unistd.h>
  560. _syscall1(int, uselib, const char *, library);
  561. #endif
  562. //#define __NR_swapon 87
  563. #ifdef L_swapon
  564. #include <sys/swap.h>
  565. _syscall2(int, swapon, const char *, path, int, swapflags);
  566. #endif
  567. //#define __NR_reboot 88
  568. #ifdef L__reboot
  569. #define __NR__reboot __NR_reboot
  570. #ifdef __STR_NR_reboot
  571. #define __STR_NR__reboot __STR_NR_reboot
  572. #endif
  573. extern int _reboot(int magic, int magic2, int flag);
  574. _syscall3(int, _reboot, int, magic, int, magic2, int, flag);
  575. int reboot(int flag)
  576. {
  577. return (_reboot((int) 0xfee1dead, 672274793, flag));
  578. }
  579. #endif
  580. //#define __NR_readdir 89
  581. //#define __NR_mmap 90
  582. #ifdef L__mmap
  583. #define __NR__mmap __NR_mmap
  584. #ifdef __STR_NR_mmap
  585. #define __STR_NR__mmap __STR_NR_mmap
  586. #endif
  587. #include <unistd.h>
  588. #include <sys/mman.h>
  589. extern __ptr_t _mmap(unsigned long *buffer);
  590. _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
  591. __ptr_t mmap(__ptr_t addr, size_t len, int prot,
  592. int flags, int fd, __off_t offset)
  593. {
  594. unsigned long buffer[6];
  595. buffer[0] = (unsigned long) addr;
  596. buffer[1] = (unsigned long) len;
  597. buffer[2] = (unsigned long) prot;
  598. buffer[3] = (unsigned long) flags;
  599. buffer[4] = (unsigned long) fd;
  600. buffer[5] = (unsigned long) offset;
  601. return (__ptr_t) _mmap(buffer);
  602. }
  603. #endif
  604. //#define __NR_munmap 91
  605. #ifdef L_munmap
  606. #include <unistd.h>
  607. #include <sys/mman.h>
  608. _syscall2(int, munmap, void *, start, size_t, length);
  609. #endif
  610. //#define __NR_truncate 92
  611. #ifdef L_truncate
  612. #include <unistd.h>
  613. _syscall2(int, truncate, const char *, path, off_t, length);
  614. #endif
  615. //#define __NR_ftruncate 93
  616. #ifdef L_ftruncate
  617. #include <unistd.h>
  618. _syscall2(int, ftruncate, int, fd, off_t, length);
  619. #endif
  620. //#define __NR_fchmod 94
  621. #ifdef L_fchmod
  622. #include <sys/stat.h>
  623. _syscall2(int, fchmod, int, fildes, mode_t, mode);
  624. #endif
  625. //#define __NR_fchown 95
  626. #ifdef L_fchown
  627. #include <unistd.h>
  628. _syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group);
  629. #endif
  630. //#define __NR_getpriority 96
  631. #ifdef L_getpriority
  632. #include <sys/resource.h>
  633. _syscall2(int, getpriority, __priority_which_t, which, id_t, who);
  634. #endif
  635. //#define __NR_setpriority 97
  636. #ifdef L_setpriority
  637. #include <sys/resource.h>
  638. _syscall3(int, setpriority, __priority_which_t, which, id_t, who, int, prio);
  639. #endif
  640. //#define __NR_profil 98
  641. //#define __NR_statfs 99
  642. #ifdef L_statfs
  643. #include <sys/vfs.h>
  644. _syscall2(int, statfs, const char *, path, struct statfs *, buf);
  645. #endif
  646. //#define __NR_fstatfs 100
  647. #ifdef L_fstatfs
  648. #include <sys/vfs.h>
  649. _syscall2(int, fstatfs, int, fd, struct statfs *, buf);
  650. #endif
  651. //#define __NR_ioperm 101
  652. #ifdef L_ioperm
  653. #include <sys/io.h>
  654. # if defined __UCLIBC_HAS_MMU__ && defined __NR_ioperm
  655. _syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
  656. # else
  657. int ioperm(unsigned long from, unsigned long num, int turn_on)
  658. {
  659. __set_errno(ENOSYS);
  660. return -1;
  661. }
  662. # endif
  663. #endif
  664. //#define __NR_socketcall 102
  665. #ifdef L_socketcall
  666. _syscall2(int, socketcall, int, call, unsigned long *, args);
  667. #endif
  668. //#define __NR_syslog 103
  669. #ifdef L__syslog
  670. #include <unistd.h>
  671. #define __NR__syslog __NR_syslog
  672. #ifdef __STR_NR_syslog
  673. #define __STR_NR__syslog __STR_NR_syslog
  674. #endif
  675. extern int _syslog(int type, char *buf, int len);
  676. _syscall3(int, _syslog, int, type, char *, buf, int, len);
  677. int klogctl(int type, char *buf, int len)
  678. {
  679. return (_syslog(type, buf, len));
  680. }
  681. #endif
  682. //#define __NR_setitimer 104
  683. #ifdef L_setitimer
  684. #include <sys/time.h>
  685. _syscall3(int, setitimer, __itimer_which_t, which,
  686. const struct itimerval *, new, struct itimerval *, old);
  687. #endif
  688. //#define __NR_getitimer 105
  689. #ifdef L_getitimer
  690. #include <sys/time.h>
  691. _syscall2(int, getitimer, __itimer_which_t, which, struct itimerval *, value);
  692. #endif
  693. //#define __NR_stat 106
  694. #ifdef L___stat
  695. #include <unistd.h>
  696. #include "statfix.h"
  697. #define __NR___stat __NR_stat
  698. #ifdef __STR_NR_stat
  699. #define __STR_NR___stat __STR_NR_stat
  700. #endif
  701. extern int __stat(const char *file_name, struct kernel_stat *buf);
  702. _syscall2(int, __stat, const char *, file_name, struct kernel_stat *, buf);
  703. int __xstat(int version, const char * file_name, struct libc_stat * cstat)
  704. {
  705. struct kernel_stat kstat;
  706. int result = __stat(file_name, &kstat);
  707. if (result == 0) {
  708. statfix(cstat, &kstat);
  709. }
  710. return result;
  711. }
  712. int stat(const char *file_name, struct libc_stat *buf)
  713. {
  714. return(__xstat(0, file_name, buf));
  715. }
  716. #endif
  717. //#define __NR_lstat 107
  718. #ifdef L___lstat
  719. #include <unistd.h>
  720. #include "statfix.h"
  721. #define __NR___lstat __NR_lstat
  722. #ifdef __STR_NR_lstat
  723. #define __STR_NR___lstat __STR_NR_lstat
  724. #endif
  725. extern int __lstat(const char *file_name, struct kernel_stat *buf);
  726. _syscall2(int, __lstat, const char *, file_name, struct kernel_stat *, buf);
  727. int __lxstat(int version, const char * file_name, struct libc_stat * cstat)
  728. {
  729. struct kernel_stat kstat;
  730. int result = __lstat(file_name, &kstat);
  731. if (result == 0) {
  732. statfix(cstat, &kstat);
  733. }
  734. return result;
  735. }
  736. int lstat(const char *file_name, struct libc_stat *buf)
  737. {
  738. return(__lxstat(0, file_name, buf));
  739. }
  740. #endif
  741. //#define __NR_fstat 108
  742. #ifdef L___fstat
  743. #include <unistd.h>
  744. #include "statfix.h"
  745. #define __NR___fstat __NR_fstat
  746. #ifdef __STR_NR_fstat
  747. #define __STR_NR___fstat __STR_NR_fstat
  748. #endif
  749. extern int __fstat(int filedes, struct kernel_stat *buf);
  750. _syscall2(int, __fstat, int, filedes, struct kernel_stat *, buf);
  751. int __fxstat(int version, int fd, struct libc_stat * cstat)
  752. {
  753. struct kernel_stat kstat;
  754. int result = __fstat(fd, &kstat);
  755. if (result == 0) {
  756. statfix(cstat, &kstat);
  757. }
  758. return result;
  759. }
  760. int fstat(int filedes, struct libc_stat *buf)
  761. {
  762. return(__fxstat(0, filedes, buf));
  763. }
  764. #endif
  765. //#define __NR_olduname 109
  766. //#define __NR_iopl 110
  767. #ifdef L_iopl
  768. #include <sys/io.h>
  769. /* Tuns out the m68k unistd.h kernel header is broken */
  770. # if defined __UCLIBC_HAS_MMU__ && defined __NR_iopl && ! defined(__mc68000__)
  771. _syscall1(int, iopl, int, level);
  772. # else
  773. int iopl(int level)
  774. {
  775. __set_errno(ENOSYS);
  776. return -1;
  777. }
  778. # endif
  779. #endif
  780. //#define __NR_vhangup 111
  781. #ifdef L_vhangup
  782. #include <unistd.h>
  783. _syscall0(int, vhangup);
  784. #endif
  785. //#define __NR_idle 112
  786. //int idle(void);
  787. //#define __NR_vm86old 113
  788. //#define __NR_wait4 114
  789. #ifdef L_wait4
  790. _syscall4(int, wait4, pid_t, pid, int *, status, int, opts, void *, rusage);
  791. #endif
  792. //#define __NR_swapoff 115
  793. #ifdef L_swapoff
  794. #include <sys/swap.h>
  795. _syscall1(int, swapoff, const char *, path);
  796. #endif
  797. //#define __NR_sysinfo 116
  798. #ifdef L_sysinfo
  799. #include <sys/sysinfo.h>
  800. _syscall1(int, sysinfo, struct sysinfo *, info);
  801. #endif
  802. //#define __NR_ipc 117
  803. #ifdef L___ipc
  804. #define __NR___ipc __NR_ipc
  805. #ifdef __STR_NR_ipc
  806. #define __STR_NR___ipc __STR_NR_ipc
  807. #endif
  808. _syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
  809. #endif
  810. //#define __NR_fsync 118
  811. #ifdef L___libc_fsync
  812. #include <unistd.h>
  813. #define __NR___libc_fsync __NR_fsync
  814. _syscall1(int, __libc_fsync, int, fd);
  815. weak_alias(__libc_fsync, fsync)
  816. #endif
  817. //#define __NR_sigreturn 119
  818. //int sigreturn(unsigned long __unused);
  819. //#define __NR_clone 120
  820. //See architecture specific implementation...
  821. //#define __NR_setdomainname 121
  822. #ifdef L_setdomainname
  823. #include <unistd.h>
  824. _syscall2(int, setdomainname, const char *, name, size_t, len);
  825. #endif
  826. //#define __NR_uname 122
  827. #ifdef L_uname
  828. #include <sys/utsname.h>
  829. _syscall1(int, uname, struct utsname *, buf);
  830. #endif
  831. //#define __NR_modify_ldt 123
  832. //#define __NR_adjtimex 124
  833. #ifdef L_adjtimex
  834. #include <sys/timex.h>
  835. _syscall1(int, adjtimex, struct timex *, buf);
  836. weak_alias(adjtimex, __adjtimex);
  837. #endif
  838. //#define __NR_mprotect 125
  839. #ifdef L_mprotect
  840. #include <sys/mman.h>
  841. _syscall3(int, mprotect, void *, addr, size_t, len, int, prot);
  842. #endif
  843. //#define __NR_sigprocmask 126
  844. #ifndef __NR_rt_sigprocmask
  845. #ifdef L_sigprocmask
  846. #include <signal.h>
  847. #undef sigprocmask
  848. _syscall3(int, sigprocmask, int, how, const sigset_t *, set,
  849. sigset_t *, oldset);
  850. #endif
  851. #endif
  852. //#define __NR_create_module 127
  853. //See sysdeps/linux/commom/create_module.c
  854. //#define __NR_init_module 128
  855. #ifdef L_init_module
  856. /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
  857. * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
  858. * and let the kernel cope with whatever it gets. It's good at that. */
  859. _syscall5(int, init_module, void *, first, void *, second, void *, third,
  860. void *, fourth, void *, fifth);
  861. #endif
  862. //#define __NR_delete_module 129
  863. #ifdef L_delete_module
  864. # ifdef __NR_delete_module
  865. _syscall1(int, delete_module, const char *, name);
  866. # else
  867. int delete_module(const char * name)
  868. {
  869. __set_errno(ENOSYS);
  870. return -1;
  871. }
  872. # endif
  873. #endif
  874. //#define __NR_get_kernel_syms 130
  875. #ifdef L_get_kernel_syms
  876. struct kernel_sym;
  877. _syscall1(int, get_kernel_syms, struct kernel_sym *, table);
  878. #endif
  879. //#define __NR_quotactl 131
  880. #ifdef __NR_quotactl
  881. #ifdef L_quotactl
  882. #include <sys/quota.h>
  883. _syscall4(int, quotactl, int, cmd, const char *, special , int, id, caddr_t, addr);
  884. #endif
  885. #endif
  886. //#define __NR_getpgid 132
  887. #ifdef L_getpgid
  888. _syscall1(pid_t, getpgid, pid_t, pid);
  889. #endif
  890. //#define __NR_fchdir 133
  891. #ifdef L_fchdir
  892. #include <unistd.h>
  893. _syscall1(int, fchdir, int, fd);
  894. #endif
  895. //#define __NR_bdflush 134
  896. #ifdef L_bdflush
  897. #include <sys/kdaemon.h>
  898. _syscall2(int, bdflush, int, __func, long int, __data);
  899. #endif
  900. //#define __NR_sysfs 135
  901. //#define __NR_personality 136
  902. //#define __NR_afs_syscall 137
  903. //#define __NR_setfsuid 138
  904. #ifdef __NR_setfsuid
  905. #ifdef L_setfsuid
  906. #include <sys/fsuid.h>
  907. _syscall1(int, setfsuid, uid_t, uid);
  908. #endif
  909. #endif
  910. //#define __NR_setfsgid 139
  911. #ifdef __NR_setfsgid
  912. #ifdef L_setfsgid
  913. #include <sys/fsuid.h>
  914. _syscall1(int, setfsgid, gid_t, gid);
  915. #endif
  916. #endif
  917. //#define __NR__llseek 140
  918. #ifdef L__llseek
  919. extern int _llseek(int fd, off_t hoff, off_t loff, loff_t *res, int whence);
  920. _syscall5(int, _llseek, int, fd, off_t, hoff, off_t, loff, loff_t *, res,
  921. int, whence);
  922. loff_t llseek(int fd, loff_t offset, int whence)
  923. {
  924. int ret;
  925. loff_t result;
  926. ret = _llseek(fd, (off_t) (offset >> 32),
  927. (off_t) (offset & 0xffffffff), &result, whence);
  928. return ret ? (loff_t) ret : result;
  929. }
  930. #ifdef __UCLIBC_HAVE_LFS__
  931. weak_alias(llseek, lseek64);
  932. #endif
  933. #endif
  934. //#define __NR_getdents 141
  935. #ifdef L_getdents
  936. #include <unistd.h>
  937. #include <dirent.h>
  938. _syscall3(int, getdents, int, fd, char *, dirp, size_t, count);
  939. #endif
  940. //#define __NR__newselect 142
  941. #ifdef L__newselect
  942. #include <unistd.h>
  943. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  944. fd_set *exceptfds, struct timeval *timeout);
  945. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  946. fd_set *, exceptfds, struct timeval *, timeout);
  947. weak_alias(_newselect, select);
  948. #endif
  949. //#define __NR_flock 143
  950. #ifdef L_flock
  951. #include <sys/file.h>
  952. _syscall2(int,flock,int,fd, int,operation);
  953. #endif
  954. //#define __NR_msync 144
  955. /* If this ever gets implemented, be sure to use the __libc_ convention
  956. * so that it can be over-ridden with a cancelable version by linuxthreads.
  957. * Also update uClibc/libpthread/linuxthreads/wrapsyscall.c to do the override.
  958. */
  959. //#define __NR_readv 145
  960. #ifdef L_readv
  961. #include <sys/uio.h>
  962. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  963. count);
  964. #endif
  965. //#define __NR_writev 146
  966. #ifdef L_writev
  967. #include <sys/uio.h>
  968. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  969. count);
  970. #endif
  971. //#define __NR_getsid 147
  972. #ifdef L_getsid
  973. #include <unistd.h>
  974. _syscall1(pid_t, getsid, pid_t, pid);
  975. #endif
  976. //#define __NR_fdatasync 148
  977. #ifdef __NR_fdatasync
  978. #ifdef L_fdatasync
  979. #include <unistd.h>
  980. _syscall1(int, fdatasync, int, fd);
  981. #endif
  982. #endif
  983. //#define __NR__sysctl 149
  984. //#define __NR_mlock 150
  985. #ifdef L_mlock
  986. #include <sys/mman.h>
  987. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlock
  988. _syscall2(int, mlock, const void *, addr, size_t, len);
  989. # endif
  990. #endif
  991. //#define __NR_munlock 151
  992. #ifdef L_munlock
  993. #include <sys/mman.h>
  994. # if defined __UCLIBC_HAS_MMU__ && defined __NR_munlock
  995. _syscall2(int, munlock, const void *, addr, size_t, len);
  996. # endif
  997. #endif
  998. //#define __NR_mlockall 152
  999. #ifdef L_mlockall
  1000. #include <sys/mman.h>
  1001. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlockall
  1002. _syscall1(int, mlockall, int, flags);
  1003. # endif
  1004. #endif
  1005. //#define __NR_munlockall 153
  1006. #ifdef L_munlockall
  1007. #include <sys/mman.h>
  1008. # if defined __UCLIBC_HAS_MMU__ && defined L_munlockall
  1009. _syscall0(int, munlockall);
  1010. # endif
  1011. #endif
  1012. //#define __NR_sched_setparam 154
  1013. #ifdef __NR_sched_setparam
  1014. #ifdef L_sched_setparam
  1015. #include <sched.h>
  1016. _syscall2(int, sched_setparam, pid_t, pid, const struct sched_param *, p);
  1017. #endif
  1018. #endif
  1019. //#define __NR_sched_getparam 155
  1020. #ifdef __NR_sched_getparam
  1021. #ifdef L_sched_getparam
  1022. #include <sched.h>
  1023. _syscall2(int, sched_getparam, pid_t, pid, struct sched_param *, p);
  1024. #endif
  1025. #endif
  1026. //#define __NR_sched_setscheduler 156
  1027. #ifdef __NR_sched_setscheduler
  1028. #ifdef L_sched_setscheduler
  1029. #include <sched.h>
  1030. _syscall3(int, sched_setscheduler, pid_t, pid, int, policy, const struct sched_param *, p);
  1031. #endif
  1032. #endif
  1033. //#define __NR_sched_getscheduler 157
  1034. #ifdef __NR_sched_getscheduler
  1035. #ifdef L_sched_getscheduler
  1036. #include <sched.h>
  1037. _syscall1(int, sched_getscheduler, pid_t, pid);
  1038. #endif
  1039. #endif
  1040. //#define __NR_sched_yield 158
  1041. #ifdef __NR_sched_yield
  1042. #ifdef L_sched_yield
  1043. #include <sched.h>
  1044. _syscall0(int, sched_yield);
  1045. #endif
  1046. #endif
  1047. //#define __NR_sched_get_priority_max 159
  1048. #ifdef __NR_sched_get_priority_max
  1049. #ifdef L_sched_get_priority_max
  1050. #include <sched.h>
  1051. _syscall1(int, sched_get_priority_max, int, policy);
  1052. #endif
  1053. #endif
  1054. //#define __NR_sched_get_priority_min 160
  1055. #ifdef __NR_sched_get_priority_min
  1056. #ifdef L_sched_get_priority_min
  1057. #include <sched.h>
  1058. _syscall1(int, sched_get_priority_min, int, policy);
  1059. #endif
  1060. #endif
  1061. //#define __NR_sched_rr_get_interval 161
  1062. #ifdef __NR_sched_rr_get_interval
  1063. #ifdef L_sched_rr_get_interval
  1064. #include <sched.h>
  1065. _syscall2(int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp);
  1066. #endif
  1067. #endif
  1068. //#define __NR_nanosleep 162
  1069. #ifdef L___libc_nanosleep
  1070. #include <time.h>
  1071. #define __NR___libc_nanosleep __NR_nanosleep
  1072. _syscall2(int, __libc_nanosleep, const struct timespec *, req, struct timespec *, rem);
  1073. weak_alias(__libc_nanosleep, nanosleep)
  1074. #endif
  1075. //#define __NR_mremap 163
  1076. #ifdef L_mremap
  1077. #include <unistd.h>
  1078. #include <sys/mman.h>
  1079. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t, new_size, int, may_move);
  1080. #endif
  1081. //#define __NR_setresuid 164
  1082. //#define __NR_getresuid 165
  1083. //#define __NR_vm86 166
  1084. //#define __NR_query_module 167
  1085. #ifdef L_query_module
  1086. # ifdef __NR_query_module
  1087. _syscall5(int, query_module, const char *, name, int, which,
  1088. void *, buf, size_t, bufsize, size_t*, ret);
  1089. # else
  1090. int query_module(const char * name, int which,
  1091. void * buf, size_t bufsize, size_t* ret)
  1092. {
  1093. __set_errno(ENOSYS);
  1094. return -1;
  1095. }
  1096. # endif
  1097. #endif
  1098. //#define __NR_poll 168
  1099. #if defined(L_poll) && defined(__NR_poll) /* uClinux 2.0 doesn't have poll */
  1100. #include <sys/poll.h>
  1101. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  1102. #endif
  1103. //#define __NR_nfsservctl 169
  1104. //nfsservctl EXTRA nfsservctl i:ipp nfsservctl
  1105. //#define __NR_setresgid 170
  1106. //#define __NR_getresgid 171
  1107. //#define __NR_prctl 172
  1108. //#define __NR_rt_sigreturn 173
  1109. //#define __NR_rt_sigaction 174
  1110. #ifdef __NR_rt_sigaction
  1111. #define __NR___rt_sigaction __NR_rt_sigaction
  1112. #ifdef L___rt_sigaction
  1113. #include <signal.h>
  1114. #undef sigaction
  1115. _syscall4(int, __rt_sigaction, int, signum, const struct sigaction *, act,
  1116. struct sigaction *, oldact, size_t, size);
  1117. #endif
  1118. #endif
  1119. //#define __NR_rt_sigprocmask 175
  1120. #ifdef __NR_rt_sigprocmask
  1121. #define __NR___rt_sigprocmask __NR_rt_sigprocmask
  1122. #ifdef L___rt_sigprocmask
  1123. #include <signal.h>
  1124. #undef sigprocmask
  1125. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  1126. sigset_t *, oldset, size_t, size);
  1127. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
  1128. {
  1129. return __rt_sigprocmask(how, set, oldset, _NSIG/8);
  1130. }
  1131. #endif
  1132. #endif
  1133. //#define __NR_rt_sigpending 176
  1134. #ifdef __NR_rt_sigpending
  1135. #define __NR___rt_sigpending __NR_rt_sigpending
  1136. #ifdef L___rt_sigpending
  1137. #include <signal.h>
  1138. #undef sigpending
  1139. _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size);
  1140. int sigpending(sigset_t *set)
  1141. {
  1142. return __rt_sigpending(set, _NSIG/8);
  1143. }
  1144. #endif
  1145. #endif
  1146. //#define __NR_rt_sigtimedwait 177
  1147. //#define __NR_rt_sigqueueinfo 178
  1148. //#define __NR_rt_sigsuspend 179
  1149. #ifdef __NR_rt_sigsuspend
  1150. #define __NR___rt_sigsuspend __NR_rt_sigsuspend
  1151. #ifdef L___rt_sigsuspend
  1152. #include <signal.h>
  1153. #undef _sigsuspend
  1154. _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
  1155. int sigsuspend (const sigset_t *mask)
  1156. {
  1157. return __rt_sigsuspend(mask, _NSIG/8);
  1158. }
  1159. #endif
  1160. #endif
  1161. //#define __NR_pread 180
  1162. //#define __NR_pwrite 181
  1163. //#define __NR_chown 182
  1164. #ifdef L_chown
  1165. #include <unistd.h>
  1166. _syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
  1167. #endif
  1168. //#define __NR_getcwd 183
  1169. // See unistd/getcwd.c -- we don't use this syscall, even when it is available...
  1170. //#define __NR_capget 184
  1171. #ifdef L_capget
  1172. # ifdef __NR_capget
  1173. _syscall2(int, capget, void*, header, void*, data);
  1174. # else
  1175. int capget(void* header, void* data)
  1176. {
  1177. __set_errno(ENOSYS);
  1178. return -1;
  1179. }
  1180. # endif
  1181. #endif
  1182. //#define __NR_capset 185
  1183. #ifdef L_capset
  1184. # ifdef __NR_capset
  1185. _syscall2(int, capset, void*, header, const void*, data);
  1186. # else
  1187. int capset(void* header, const void* data)
  1188. {
  1189. __set_errno(ENOSYS);
  1190. return -1;
  1191. }
  1192. # endif
  1193. #endif
  1194. //#define __NR_sigaltstack 186
  1195. #ifdef __NR_sigaltstack
  1196. #ifdef L_sigaltstack
  1197. #include <signal.h>
  1198. _syscall2(int, sigaltstack, const struct sigaltstack *, ss, struct sigaltstack *, oss);
  1199. #endif
  1200. #endif
  1201. //#define __NR_sendfile 187
  1202. #ifdef __NR_sendfile
  1203. #ifdef L_sendfile
  1204. #include <unistd.h>
  1205. #include <sys/sendfile.h>
  1206. _syscall4(ssize_t,sendfile, int, out_fd, int, in_fd, off_t *, offset, size_t, count)
  1207. #endif
  1208. #endif
  1209. //#define __NR_getpmsg 188
  1210. //#define __NR_putpmsg 189
  1211. //#define __NR_vfork 190
  1212. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...
  1213. //#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
  1214. //#define __NR_mmap2 192
  1215. //#define __NR_truncate64 193
  1216. #ifdef __UCLIBC_HAVE_LFS__
  1217. #ifdef L_truncate64
  1218. #include <unistd.h>
  1219. _syscall2(int, truncate64, const char *, path, __off64_t, length);
  1220. #endif
  1221. #endif /* __UCLIBC_HAVE_LFS__ */
  1222. //#define __NR_ftruncate64 194
  1223. #ifdef __UCLIBC_HAVE_LFS__
  1224. #ifdef L_ftruncate64
  1225. #include <unistd.h>
  1226. _syscall2(int, ftruncate64, int, fd, __off64_t, length);
  1227. #endif
  1228. #endif /* __UCLIBC_HAVE_LFS__ */
  1229. //#define __NR_stat64 195
  1230. #ifdef __UCLIBC_HAVE_LFS__
  1231. #ifdef L___stat64
  1232. #include <unistd.h>
  1233. #include "statfix64.h"
  1234. #define __NR___stat64 __NR_stat64
  1235. #ifdef __STR_NR_stat64
  1236. #define __STR_NR___stat64 __STR_NR_stat64
  1237. #endif
  1238. extern int __stat64(const char *file_name, struct kernel_stat64 *buf);
  1239. _syscall2(int, __stat64, const char *, file_name, struct kernel_stat64 *, buf);
  1240. int __xstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1241. {
  1242. struct kernel_stat64 kstat;
  1243. int result = __stat64(file_name, &kstat);
  1244. if (result == 0) {
  1245. statfix64(cstat, &kstat);
  1246. }
  1247. return result;
  1248. }
  1249. int stat64(const char *file_name, struct libc_stat64 *buf)
  1250. {
  1251. return(__xstat64(0, file_name, buf));
  1252. }
  1253. #endif
  1254. #endif /* __UCLIBC_HAVE_LFS__ */
  1255. //#define __NR_lstat64 196
  1256. #ifdef __UCLIBC_HAVE_LFS__
  1257. #ifdef L___lstat64
  1258. #include <unistd.h>
  1259. #include "statfix64.h"
  1260. #define __NR___lstat64 __NR_lstat64
  1261. #ifdef __STR_NR_lstat64
  1262. #define __STR_NR___lstat64 __STR_NR_lstat64
  1263. #endif
  1264. extern int __lstat64(const char *file_name, struct kernel_stat64 *buf);
  1265. _syscall2(int, __lstat64, const char *, file_name, struct kernel_stat64 *, buf);
  1266. int __lxstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1267. {
  1268. struct kernel_stat64 kstat;
  1269. int result = __lstat64(file_name, &kstat);
  1270. if (result == 0) {
  1271. statfix64(cstat, &kstat);
  1272. }
  1273. return result;
  1274. }
  1275. int lstat64(const char *file_name, struct libc_stat64 *buf)
  1276. {
  1277. return(__lxstat64(0, file_name, buf));
  1278. }
  1279. #endif
  1280. #endif /* __UCLIBC_HAVE_LFS__ */
  1281. //#define __NR_fstat64 197
  1282. #ifdef __UCLIBC_HAVE_LFS__
  1283. #ifdef L___fstat64
  1284. #include <unistd.h>
  1285. #include "statfix64.h"
  1286. #define __NR___fstat64 __NR_fstat64
  1287. #ifdef __STR_NR_fstat64
  1288. #define __STR_NR___fstat64 __STR_NR_fstat64
  1289. #endif
  1290. extern int __fstat64(int filedes, struct kernel_stat64 *buf);
  1291. _syscall2(int, __fstat64, int, filedes, struct kernel_stat64 *, buf);
  1292. int __fxstat64(int version, int fd, struct libc_stat64 * cstat)
  1293. {
  1294. struct kernel_stat64 kstat;
  1295. int result = __fstat64(fd, &kstat);
  1296. if (result == 0) {
  1297. statfix64(cstat, &kstat);
  1298. }
  1299. return result;
  1300. }
  1301. int fstat64(int filedes, struct libc_stat64 *buf)
  1302. {
  1303. return(__fxstat64(0, filedes, buf));
  1304. }
  1305. #endif
  1306. #endif /* __UCLIBC_HAVE_LFS__ */
  1307. //#define __NR_lchown32 198
  1308. //#define __NR_getuid32 199
  1309. //#define __NR_getgid32 200
  1310. //#define __NR_geteuid32 201
  1311. //#define __NR_getegid32 202
  1312. //#define __NR_setreuid32 203
  1313. //#define __NR_setregid32 204
  1314. //#define __NR_getgroups32 205
  1315. //#define __NR_setgroups32 206
  1316. //#define __NR_fchown32 207
  1317. //#define __NR_setresuid32 208
  1318. //#define __NR_getresuid32 209
  1319. //#define __NR_setresgid32 210
  1320. //#define __NR_getresgid32 211
  1321. //#define __NR_chown32 212
  1322. //#define __NR_setuid32 213
  1323. //#define __NR_setgid32 214
  1324. //#define __NR_setfsuid32 215
  1325. //#define __NR_setfsgid32 216
  1326. //#define __NR_pivot_root 217
  1327. #ifdef __NR_pivot_root
  1328. #ifdef L_pivot_root
  1329. _syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
  1330. #endif
  1331. #endif
  1332. //#define __NR_mincore 218
  1333. //#define __NR_madvise 219
  1334. //#define __NR_madvise1 219 /* delete when C lib stub is removed */
  1335. //#define __NR_getdents64 220
  1336. #ifdef __UCLIBC_HAVE_LFS__
  1337. #ifdef L_getdents64
  1338. #include <unistd.h>
  1339. #include <dirent.h>
  1340. _syscall3(int, getdents64, int, fd, char *, dirp, size_t, count);
  1341. #endif
  1342. #endif /* __UCLIBC_HAVE_LFS__ */
  1343. //#define __NR_fcntl64 221
  1344. #ifdef __UCLIBC_HAVE_LFS__
  1345. #define __NR__fcntl64 __NR_fcntl64
  1346. #ifdef L__fcntl64
  1347. #include <stdarg.h>
  1348. #include <fcntl.h>
  1349. extern int _fcntl64(int fd, int cmd, long arg);
  1350. _syscall3(int, _fcntl64, int, fd, int, cmd, long, arg);
  1351. int fcntl64(int fd, int command, ...)
  1352. {
  1353. long arg;
  1354. va_list list;
  1355. va_start(list, command);
  1356. arg = va_arg(list, long);
  1357. va_end(list);
  1358. return _fcntl64(fd, command, arg);
  1359. }
  1360. #endif
  1361. #endif
  1362. //#define __NR_security 223 /* syscall for security modules */
  1363. //#define __NR_gettid 224
  1364. //#define __NR_readahead 225