syscalls.c 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Syscalls for uClibc
  4. *
  5. * Copyright (C) 2000 by Lineo, inc. Written by Erik Andersen
  6. * <andersen@lineo.com>, <andersee@debian.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU Library General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  16. * for more details.
  17. *
  18. * You should have received a copy of the GNU Library General Public License
  19. * along with this program; if not, write to the Free Software Foundation,
  20. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <errno.h>
  24. #include <features.h>
  25. #include <sys/types.h>
  26. #include <sys/syscall.h>
  27. #include "unified_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. _syscall1(void, _exit, int, status);
  34. #endif
  35. //#define __NR_fork 2
  36. #ifdef L_fork
  37. # ifdef __UCLIBC_HAS_MMU__
  38. # include <unistd.h>
  39. _syscall0(pid_t, fork);
  40. # endif
  41. #endif
  42. //#define __NR_read 3
  43. #ifdef L_read
  44. #include <unistd.h>
  45. _syscall3(ssize_t, read, int, fd, __ptr_t, buf, size_t, count);
  46. #endif
  47. //#define __NR_write 4
  48. #ifdef L_write
  49. #include <unistd.h>
  50. _syscall3(ssize_t, write, int, fd, const __ptr_t, buf, size_t, count);
  51. #endif
  52. //#define __NR_open 5
  53. #ifdef L___open
  54. #include <stdarg.h>
  55. #include <fcntl.h>
  56. #define __NR___open __NR_open
  57. _syscall3(int, __open, const char *, fn, int, flags, mode_t, mode);
  58. int open(const char *file, int oflag, ...)
  59. {
  60. int mode = 0;
  61. if (oflag & O_CREAT) {
  62. va_list args;
  63. va_start(args, oflag);
  64. mode = va_arg(args, int);
  65. va_end(args);
  66. }
  67. return __open(file, oflag, mode);
  68. }
  69. #endif
  70. //#define __NR_close 6
  71. #ifdef L_close
  72. #include <unistd.h>
  73. _syscall1(int, close, int, fd);
  74. #endif
  75. //#define __NR_waitpid 7
  76. // Implemented using wait4
  77. //#define __NR_creat 8
  78. #ifdef L_creat
  79. #include <fcntl.h>
  80. _syscall2(int, creat, const char *, file, mode_t, mode);
  81. #endif
  82. //#define __NR_link 9
  83. #ifdef L_link
  84. #include <unistd.h>
  85. _syscall2(int, link, const char *, oldpath, const char *, newpath);
  86. #endif
  87. //#define __NR_unlink 10
  88. #ifdef L_unlink
  89. #include <unistd.h>
  90. _syscall1(int, unlink, const char *, pathname);
  91. #endif
  92. //#define __NR_execve 11
  93. #ifdef L_execve
  94. #include <unistd.h>
  95. _syscall3(int, execve, const char *, filename, char *const *, argv,
  96. char *const *, envp);
  97. #endif
  98. //#define __NR_chdir 12
  99. #ifdef L_chdir
  100. #include <unistd.h>
  101. _syscall1(int, chdir, const char *, path);
  102. #endif
  103. //#define __NR_time 13
  104. #ifdef L_time
  105. #include <time.h>
  106. _syscall1(time_t, time, time_t *, t);
  107. #endif
  108. //#define __NR_mknod 14
  109. #ifdef L_mknod
  110. #include <unistd.h>
  111. extern int mknod(const char *pathname, mode_t mode, dev_t dev);
  112. _syscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev);
  113. int _xmknod (int version, const char * path, mode_t mode, dev_t *dev)
  114. {
  115. switch(version)
  116. {
  117. case 1:
  118. return mknod (path, mode, *dev);
  119. default:
  120. __set_errno(EINVAL);
  121. return -1;
  122. }
  123. }
  124. #endif
  125. //#define __NR_chmod 15
  126. #ifdef L_chmod
  127. #include <sys/stat.h>
  128. _syscall2(int, chmod, const char *, path, mode_t, mode);
  129. #endif
  130. /* Old kernels don't have lchown -- do chown instead. This
  131. * is sick and wrong, but at least things will compile.
  132. * They may not follow links when they should though... */
  133. #ifndef __NR_lchown
  134. #define __NR_lchown __NR_chown
  135. #endif
  136. //#define __NR_lchown 16
  137. #ifdef L_lchown
  138. #include <unistd.h>
  139. _syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);
  140. #endif
  141. //#define __NR_break 17
  142. //#define __NR_oldstat 18
  143. //#define __NR_lseek 19
  144. #ifdef L_lseek
  145. #include <unistd.h>
  146. _syscall3(off_t, lseek, int, fildes, off_t, offset, int, whence);
  147. #endif
  148. //#define __NR_getpid 20
  149. #ifdef L_getpid
  150. #include <unistd.h>
  151. _syscall0(pid_t, getpid);
  152. #endif
  153. //#define __NR_mount 21
  154. #ifdef L_mount
  155. #include <sys/mount.h>
  156. _syscall5(int, mount, const char *, specialfile, const char *, dir,
  157. const char *, filesystemtype, unsigned long, rwflag,
  158. const void *, data);
  159. #endif
  160. //#define __NR_umount 22
  161. #ifdef L_umount
  162. #include <sys/mount.h>
  163. _syscall1(int, umount, const char *, specialfile);
  164. #endif
  165. //#define __NR_setuid 23
  166. #ifdef L_setuid
  167. #include <unistd.h>
  168. _syscall1(int, setuid, uid_t, uid);
  169. #endif
  170. //#define __NR_getuid 24
  171. #ifdef L_getuid
  172. #include <unistd.h>
  173. _syscall0(gid_t, getuid);
  174. #endif
  175. //#define __NR_stime 25
  176. #ifdef L_stime
  177. #include <time.h>
  178. _syscall1(int, stime, time_t *, t);
  179. #endif
  180. //#define __NR_ptrace 26
  181. #ifdef L___ptrace
  182. #include <sys/ptrace.h>
  183. #define __NR___ptrace __NR_ptrace
  184. _syscall4(long, __ptrace, enum __ptrace_request, request, pid_t, pid,
  185. void*, addr, void*, data);
  186. #endif
  187. //#define __NR_alarm 27
  188. #ifdef L_alarm
  189. #include <unistd.h>
  190. _syscall1(unsigned int, alarm, unsigned int, seconds);
  191. #endif
  192. //#define __NR_oldfstat 28
  193. //#define __NR_pause 29
  194. #ifdef L_pause
  195. #include <unistd.h>
  196. _syscall0(int, pause);
  197. #endif
  198. //#define __NR_utime 30
  199. #ifdef L_utime
  200. #include <utime.h>
  201. _syscall2(int, utime, const char *, filename, struct utimbuf *, buf);
  202. #endif
  203. //#define __NR_stty 31
  204. //#define __NR_gtty 32
  205. //#define __NR_access 33
  206. #ifdef L_access
  207. #include <unistd.h>
  208. _syscall2(int, access, const char *, pathname, int, mode);
  209. #endif
  210. //#define __NR_nice 34
  211. #ifdef L_nice
  212. #include <unistd.h>
  213. _syscall1(int, nice, int, inc);
  214. #endif
  215. //#define __NR_ftime 35
  216. //#define __NR_sync 36
  217. #ifdef L_sync
  218. #include <unistd.h>
  219. _syscall0(int, sync);
  220. #endif
  221. //#define __NR_kill 37
  222. #ifdef L_kill
  223. #include <signal.h>
  224. _syscall2(int, kill, pid_t, pid, int, sig);
  225. #endif
  226. //#define __NR_rename 38
  227. #ifdef L_rename
  228. #include <stdio.h>
  229. _syscall2(int, rename, const char *, oldpath, const char *, newpath);
  230. #endif
  231. //#define __NR_mkdir 39
  232. #ifdef L_mkdir
  233. #include <sys/stat.h>
  234. _syscall2(int, mkdir, const char *, pathname, mode_t, mode);
  235. #endif
  236. //#define __NR_rmdir 40
  237. #ifdef L_rmdir
  238. #include <unistd.h>
  239. _syscall1(int, rmdir, const char *, pathname);
  240. #endif
  241. //#define __NR_dup 41
  242. #ifdef L_dup
  243. #include <unistd.h>
  244. _syscall1(int, dup, int, oldfd);
  245. #endif
  246. //#define __NR_pipe 42
  247. #ifdef L_pipe
  248. #include <unistd.h>
  249. _syscall1(int, pipe, int *, filedes);
  250. #endif
  251. //#define __NR_times 43
  252. #ifdef L_times
  253. #include <sys/times.h>
  254. _syscall1(clock_t, times, struct tms *, buf);
  255. #endif
  256. //#define __NR_prof 44
  257. //#define __NR_brk 45
  258. //#define __NR_setgid 46
  259. #ifdef L_setgid
  260. #include <unistd.h>
  261. _syscall1(int, setgid, gid_t, gid);
  262. #endif
  263. //#define __NR_getgid 47
  264. #ifdef L_getgid
  265. #include <unistd.h>
  266. _syscall0(gid_t, getgid);
  267. #endif
  268. //#define __NR_signal 48
  269. //#define __NR_geteuid 49
  270. #ifdef L_geteuid
  271. #ifdef SYS_geteuid
  272. #include <unistd.h>
  273. _syscall0(uid_t, geteuid);
  274. #else
  275. uid_t geteuid(void)
  276. {
  277. return (getuid());
  278. }
  279. #endif
  280. #endif
  281. //#define __NR_getegid 50
  282. #ifdef L_getegid
  283. #ifdef SYS_getegid
  284. #include <unistd.h>
  285. _syscall0(gid_t, getegid);
  286. #else
  287. gid_t getegid(void)
  288. {
  289. return (getgid());
  290. }
  291. #endif
  292. #endif
  293. //#define __NR_acct 51
  294. #ifdef __NR_umount2 /* Old kernels don't have umount2 */
  295. //#define __NR_umount2 52
  296. # ifdef L_umount2
  297. # include <sys/mount.h>
  298. _syscall2(int, umount2, const char *, special_file, int, flags);
  299. # endif
  300. #endif
  301. //#define __NR_lock 53
  302. //#define __NR_ioctl 54
  303. #ifdef L__ioctl
  304. #include <stdarg.h>
  305. #include <sys/ioctl.h>
  306. #define __NR__ioctl __NR_ioctl
  307. extern int _ioctl(int fd, int request, void *arg);
  308. _syscall3(int, _ioctl, int, fd, int, request, void *, arg);
  309. int ioctl(int fd, unsigned long int request, ...)
  310. {
  311. void *arg;
  312. va_list list;
  313. va_start(list, request);
  314. arg = va_arg(list, void *);
  315. va_end(list);
  316. return _ioctl(fd, request, arg);
  317. }
  318. #endif
  319. //#define __NR_fcntl 55
  320. #ifdef L__fcntl
  321. #include <stdarg.h>
  322. #include <fcntl.h>
  323. #define __NR__fcntl __NR_fcntl
  324. extern int _fcntl(int fd, int cmd, long arg);
  325. _syscall3(int, _fcntl, int, fd, int, cmd, long, arg);
  326. int fcntl(int fd, int command, ...)
  327. {
  328. long arg;
  329. va_list list;
  330. va_start(list, command);
  331. arg = va_arg(list, long);
  332. va_end(list);
  333. return _fcntl(fd, command, arg);
  334. }
  335. #endif
  336. //#define __NR_mpx 56
  337. //#define __NR_setpgid 57
  338. #ifdef L_setpgid
  339. #include <unistd.h>
  340. _syscall2(int, setpgid, pid_t, pid, pid_t, pgid);
  341. #endif
  342. //#define __NR_ulimit 58
  343. //#define __NR_oldolduname 59
  344. //#define __NR_umask 60
  345. #ifdef L_umask
  346. #include <sys/stat.h>
  347. _syscall1(mode_t, umask, mode_t, mask);
  348. #endif
  349. //#define __NR_chroot 61
  350. #ifdef L_chroot
  351. #include <unistd.h>
  352. _syscall1(int, chroot, const char *, path);
  353. #endif
  354. //#define __NR_ustat 62
  355. //#define __NR_dup2 63
  356. #ifdef L_dup2
  357. #include <unistd.h>
  358. _syscall2(int, dup2, int, oldfd, int, newfd);
  359. #endif
  360. //#define __NR_getppid 64
  361. #ifdef L_getppid
  362. #include <unistd.h>
  363. #ifdef SYS_getppid
  364. _syscall0(pid_t, getppid);
  365. #else
  366. pid_t getppid(void)
  367. {
  368. return (getpid());
  369. }
  370. #endif
  371. #endif
  372. //#define __NR_getpgrp 65
  373. #ifdef L_getpgrp
  374. #include <unistd.h>
  375. _syscall0(pid_t, getpgrp);
  376. #endif
  377. //#define __NR_setsid 66
  378. #ifdef L_setsid
  379. #include <unistd.h>
  380. _syscall0(pid_t, setsid);
  381. #endif
  382. //#define __NR_sigaction 67
  383. #ifdef L_sigaction
  384. #include <signal.h>
  385. _syscall3(int, sigaction, int, signum, const struct sigaction *, act,
  386. struct sigaction *, oldact);
  387. #endif
  388. //#define __NR_sgetmask 68
  389. //#define __NR_ssetmask 69
  390. //#define __NR_setreuid 70
  391. #ifdef L_setreuid
  392. #include <unistd.h>
  393. _syscall2(int, setreuid, uid_t, ruid, uid_t, euid);
  394. #endif
  395. //#define __NR_setregid 71
  396. #ifdef L_setregid
  397. #include <unistd.h>
  398. _syscall2(int, setregid, gid_t, rgid, gid_t, egid);
  399. #endif
  400. //#define __NR_sigsuspend 72
  401. #ifdef L_sigsuspend
  402. #include <signal.h>
  403. _syscall1(int, sigsuspend, const sigset_t *, mask);
  404. #endif
  405. //#define __NR_sigpending 73
  406. #ifdef L_sigpending
  407. #include <signal.h>
  408. _syscall1(int, sigpending, sigset_t *, set);
  409. #endif
  410. //#define __NR_sethostname 74
  411. #ifdef L_sethostname
  412. #include <unistd.h>
  413. _syscall2(int, sethostname, const char *, name, size_t, len);
  414. #endif
  415. //#define __NR_setrlimit 75
  416. #ifdef L_setrlimit
  417. #include <unistd.h>
  418. #include <sys/resource.h>
  419. _syscall2(int, setrlimit, int, resource, const struct rlimit *, rlim);
  420. #endif
  421. //#define __NR_getrlimit 76
  422. #ifdef L_getrlimit
  423. #include <unistd.h>
  424. #include <sys/resource.h>
  425. _syscall2(int, getrlimit, int, resource, struct rlimit *, rlim);
  426. #endif
  427. //#define __NR_getrusage 77
  428. #ifdef L_getrusage
  429. #include <unistd.h>
  430. #include <wait.h>
  431. _syscall2(int, getrusage, int, who, struct rusage *, usage);
  432. #endif
  433. //#define __NR_gettimeofday 78
  434. #ifdef L_gettimeofday
  435. #include <unistd.h>
  436. _syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
  437. #endif
  438. //#define __NR_settimeofday 79
  439. #ifdef L_settimeofday
  440. #include <unistd.h>
  441. _syscall2(int, settimeofday, const struct timeval *, tv,
  442. const struct timezone *, tz);
  443. #endif
  444. //#define __NR_getgroups 80
  445. #ifdef L_getgroups
  446. #include <unistd.h>
  447. _syscall2(int, getgroups, int, size, gid_t *, list);
  448. #endif
  449. //#define __NR_setgroups 81
  450. #ifdef L_setgroups
  451. #include <unistd.h>
  452. #include <grp.h>
  453. _syscall2(int, setgroups, size_t, size, const gid_t *, list);
  454. #endif
  455. //#define __NR_select 82
  456. //#define __NR_symlink 83
  457. #ifdef L_symlink
  458. #include <unistd.h>
  459. _syscall2(int, symlink, const char *, oldpath, const char *, newpath);
  460. #endif
  461. //#define __NR_oldlstat 84
  462. //#define __NR_readlink 85
  463. #ifdef L_readlink
  464. #include <unistd.h>
  465. _syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);
  466. #endif
  467. //#define __NR_uselib 86
  468. #ifdef L_uselib
  469. #include <unistd.h>
  470. _syscall1(int, uselib, const char *, library);
  471. #endif
  472. //#define __NR_swapon 87
  473. #ifdef L_swapon
  474. #include <sys/swap.h>
  475. _syscall2(int, swapon, const char *, path, int, swapflags);
  476. #endif
  477. //#define __NR_reboot 88
  478. #ifdef L__reboot
  479. #define __NR__reboot __NR_reboot
  480. extern int _reboot(int magic, int magic2, int flag);
  481. _syscall3(int, _reboot, int, magic, int, magic2, int, flag);
  482. int reboot(int flag)
  483. {
  484. return (_reboot((int) 0xfee1dead, 672274793, flag));
  485. }
  486. #endif
  487. //#define __NR_readdir 89
  488. //#define __NR_mmap 90
  489. #ifdef L__mmap
  490. #define __NR__mmap __NR_mmap
  491. #include <unistd.h>
  492. #include <sys/mman.h>
  493. extern __ptr_t _mmap(unsigned long *buffer);
  494. _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
  495. __ptr_t mmap(__ptr_t addr, size_t len, int prot,
  496. int flags, int fd, __off_t offset)
  497. {
  498. unsigned long buffer[6];
  499. buffer[0] = (unsigned long) addr;
  500. buffer[1] = (unsigned long) len;
  501. buffer[2] = (unsigned long) prot;
  502. buffer[3] = (unsigned long) flags;
  503. buffer[4] = (unsigned long) fd;
  504. buffer[5] = (unsigned long) offset;
  505. return (__ptr_t) _mmap(buffer);
  506. }
  507. #endif
  508. //#define __NR_munmap 91
  509. #ifdef L_munmap
  510. #include <unistd.h>
  511. #include <sys/mman.h>
  512. _syscall2(int, munmap, void *, start, size_t, length);
  513. #endif
  514. //#define __NR_truncate 92
  515. #ifdef L_truncate
  516. #include <unistd.h>
  517. _syscall2(int, truncate, const char *, path, off_t, length);
  518. #endif
  519. //#define __NR_ftruncate 93
  520. #ifdef L_ftruncate
  521. #include <unistd.h>
  522. _syscall2(int, ftruncate, int, fd, off_t, length);
  523. #endif
  524. //#define __NR_fchmod 94
  525. #ifdef L_fchmod
  526. #include <sys/stat.h>
  527. _syscall2(int, fchmod, int, fildes, mode_t, mode);
  528. #endif
  529. //#define __NR_fchown 95
  530. #ifdef L_fchown
  531. #include <unistd.h>
  532. _syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group);
  533. #endif
  534. //#define __NR_getpriority 96
  535. #ifdef L_getpriority
  536. #include <sys/resource.h>
  537. _syscall2(int, getpriority, int, which, int, who);
  538. #endif
  539. //#define __NR_setpriority 97
  540. #ifdef L_setpriority
  541. #include <sys/resource.h>
  542. _syscall3(int, setpriority, int, which, int, who, int, prio);
  543. #endif
  544. //#define __NR_profil 98
  545. //#define __NR_statfs 99
  546. #ifdef L_statfs
  547. #include <sys/vfs.h>
  548. _syscall2(int, statfs, const char *, path, struct statfs *, buf);
  549. #endif
  550. //#define __NR_fstatfs 100
  551. #ifdef L_fstatfs
  552. #include <sys/vfs.h>
  553. _syscall2(int, fstatfs, int, fd, struct statfs *, buf);
  554. #endif
  555. #ifdef __UCLIBC_HAS_MMU__
  556. //#define __NR_ioperm 101
  557. # ifdef L_ioperm
  558. # include <sys/io.h>
  559. _syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
  560. # endif
  561. #endif
  562. //#define __NR_socketcall 102
  563. #ifdef L_socketcall
  564. _syscall2(int, socketcall, int, call, unsigned long *, args);
  565. #endif
  566. //#define __NR_syslog 103
  567. #ifdef L__syslog
  568. #include <unistd.h>
  569. #define __NR__syslog __NR_syslog
  570. extern int _syslog(int type, char *buf, int len);
  571. _syscall3(int, _syslog, int, type, char *, buf, int, len);
  572. int klogctl(int type, char *buf, int len)
  573. {
  574. return (_syslog(type, buf, len));
  575. }
  576. #endif
  577. //#define __NR_setitimer 104
  578. #ifdef L_setitimer
  579. #include <sys/time.h>
  580. _syscall3(int, setitimer, enum __itimer_which, which,
  581. const struct itimerval *, new, struct itimerval *, old);
  582. #endif
  583. //#define __NR_getitimer 105
  584. #ifdef L_getitimer
  585. #include <sys/time.h>
  586. _syscall2(int, getitimer, enum __itimer_which, which, struct itimerval *, value);
  587. #endif
  588. //#define __NR_stat 106
  589. #ifdef L___stat
  590. #include <unistd.h>
  591. #include "statfix.h"
  592. #define __NR___stat __NR_stat
  593. extern int __stat(const char *file_name, struct kernel_stat *buf);
  594. _syscall2(int, __stat, const char *, file_name, struct kernel_stat *, buf);
  595. int _xstat(int version, const char * file_name, struct libc_stat * cstat)
  596. {
  597. struct kernel_stat kstat;
  598. int result = __stat(file_name, &kstat);
  599. if (result == 0) {
  600. statfix(cstat, &kstat);
  601. }
  602. return result;
  603. }
  604. int stat(const char *file_name, struct libc_stat *buf)
  605. {
  606. return(_xstat(0, file_name, buf));
  607. }
  608. #endif
  609. //#define __NR_lstat 107
  610. #ifdef L___lstat
  611. #include <unistd.h>
  612. #include "statfix.h"
  613. #define __NR___lstat __NR_lstat
  614. extern int __lstat(const char *file_name, struct kernel_stat *buf);
  615. _syscall2(int, __lstat, const char *, file_name, struct kernel_stat *, buf);
  616. int _lxstat(int version, const char * file_name, struct libc_stat * cstat)
  617. {
  618. struct kernel_stat kstat;
  619. int result = __lstat(file_name, &kstat);
  620. if (result == 0) {
  621. statfix(cstat, &kstat);
  622. }
  623. return result;
  624. }
  625. int lstat(const char *file_name, struct libc_stat *buf)
  626. {
  627. return(_lxstat(0, file_name, buf));
  628. }
  629. #endif
  630. //#define __NR_fstat 108
  631. #ifdef L___fstat
  632. #include <unistd.h>
  633. #include "statfix.h"
  634. #define __NR___fstat __NR_fstat
  635. extern int __fstat(int filedes, struct kernel_stat *buf);
  636. _syscall2(int, __fstat, int, filedes, struct kernel_stat *, buf);
  637. int _fxstat(int version, int fd, struct libc_stat * cstat)
  638. {
  639. struct kernel_stat kstat;
  640. int result = __fstat(fd, &kstat);
  641. if (result == 0) {
  642. statfix(cstat, &kstat);
  643. }
  644. return result;
  645. }
  646. int fstat(int filedes, struct libc_stat *buf)
  647. {
  648. return(_fxstat(0, filedes, buf));
  649. }
  650. #endif
  651. //#define __NR_olduname 109
  652. #if defined __UCLIBC_HAS_MMU__ && defined __NR_iopl
  653. //#define __NR_iopl 110
  654. #ifdef L_iopl
  655. #include <sys/io.h>
  656. _syscall1(int, iopl, int, level);
  657. #endif
  658. #endif
  659. //#define __NR_vhangup 111
  660. #ifdef L_vhangup
  661. #include <unistd.h>
  662. _syscall0(int, vhangup);
  663. #endif
  664. //#define __NR_idle 112
  665. //int idle(void);
  666. //#define __NR_vm86old 113
  667. //#define __NR_wait4 114
  668. #ifdef L_wait4
  669. _syscall4(int, wait4, pid_t, pid, int *, status, int, opts, void *, rusage);
  670. #endif
  671. //#define __NR_swapoff 115
  672. #ifdef L_swapoff
  673. #include <sys/swap.h>
  674. _syscall1(int, swapoff, const char *, path);
  675. #endif
  676. //#define __NR_sysinfo 116
  677. #ifdef L_sysinfo
  678. #include <sys/sysinfo.h>
  679. _syscall1(int, sysinfo, struct sysinfo *, info);
  680. #endif
  681. //#define __NR_ipc 117
  682. #ifdef L___ipc
  683. #define __NR___ipc __NR_ipc
  684. _syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
  685. #endif
  686. //#define __NR_fsync 118
  687. #ifdef L_fsync
  688. #include <unistd.h>
  689. _syscall1(int, fsync, int, fd);
  690. #endif
  691. //#define __NR_sigreturn 119
  692. //int sigreturn(unsigned long __unused);
  693. //#define __NR_clone 120
  694. //See architecture specific implementation...
  695. //#define __NR_setdomainname 121
  696. #ifdef L_setdomainname
  697. #include <unistd.h>
  698. _syscall2(int, setdomainname, const char *, name, size_t, len);
  699. #endif
  700. //#define __NR_uname 122
  701. #ifdef L_uname
  702. #include <sys/utsname.h>
  703. _syscall1(int, uname, struct utsname *, buf);
  704. #endif
  705. //#define __NR_modify_ldt 123
  706. //#define __NR_adjtimex 124
  707. #ifdef L_adjtimex
  708. #include <sys/timex.h>
  709. _syscall1(int, adjtimex, struct timex *, buf);
  710. #endif
  711. //#define __NR_mprotect 125
  712. #ifdef L_mprotect
  713. #include <sys/mman.h>
  714. _syscall3(int, mprotect, const void *, addr, size_t, len, int, prot);
  715. #endif
  716. //#define __NR_sigprocmask 126
  717. #ifdef L_sigprocmask
  718. #include <signal.h>
  719. _syscall3(int, sigprocmask, int, how, const sigset_t *, set, sigset_t *,
  720. oldset);
  721. #endif
  722. //#define __NR_create_module 127
  723. //See sysdeps/linux/commom/create_module.c
  724. //#define __NR_init_module 128
  725. #ifdef L_init_module
  726. /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
  727. * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
  728. * and let the kernel cope with whatever it gets. It's good at that. */
  729. _syscall5(int, init_module, void *, first, void *, second, void *, third,
  730. void *, fourth, void *, fifth);
  731. #endif
  732. //#define __NR_delete_module 129
  733. #ifdef L_delete_module
  734. # ifdef __NR_delete_module
  735. _syscall1(int, delete_module, const char *, name);
  736. # endif
  737. #endif
  738. //#define __NR_get_kernel_syms 130
  739. //#define __NR_quotactl 131
  740. //#define __NR_getpgid 132
  741. #ifdef L_getpgid
  742. _syscall1(pid_t, getpgid, pid_t, pid);
  743. #endif
  744. //#define __NR_fchdir 133
  745. #ifdef L_fchdir
  746. #include <unistd.h>
  747. _syscall1(int, fchdir, int, fd);
  748. #endif
  749. //#define __NR_bdflush 134
  750. #ifdef L_bdflush
  751. #include <sys/kdaemon.h>
  752. _syscall2(int, bdflush, int, __func, long int, __data);
  753. #endif
  754. //#define __NR_sysfs 135
  755. //#define __NR_personality 136
  756. //#define __NR_afs_syscall 137
  757. //#define __NR_setfsuid 138
  758. //#define __NR_setfsgid 139
  759. //#define __NR__llseek 140
  760. #ifdef L__llseek
  761. extern int _llseek(int fd, off_t hoff, off_t loff, loff_t *res, int whence);
  762. _syscall5(int, _llseek, int, fd, off_t, hoff, off_t, loff, loff_t *, res,
  763. int, whence);
  764. loff_t llseek(int fd, loff_t offset, int whence)
  765. {
  766. int ret;
  767. loff_t result;
  768. ret = _llseek(fd, (off_t) (offset >> 32),
  769. (off_t) (offset & 0xffffffff), &result, whence);
  770. return ret ? (loff_t) ret : result;
  771. }
  772. #endif
  773. //#define __NR_getdents 141
  774. #ifdef L__getdents
  775. #define __NR__getdents __NR_getdents
  776. #include <unistd.h>
  777. #include <dirent.h>
  778. _syscall3(int, _getdents, int, fd, char *, dirp, size_t, count);
  779. #endif
  780. //#define __NR__newselect 142
  781. #ifdef L__newselect
  782. #include <unistd.h>
  783. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  784. fd_set *exceptfds, struct timeval *timeout);
  785. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  786. fd_set *, exceptfds, struct timeval *, timeout);
  787. int select(int n, fd_set * readfds, fd_set * writefds, fd_set * exceptfds,
  788. struct timeval *timeout)
  789. {
  790. return (_newselect(n, readfds, writefds, exceptfds, timeout));
  791. }
  792. #endif
  793. //#define __NR_flock 143
  794. #ifdef L_flock
  795. #include <sys/file.h>
  796. _syscall2(int,flock,int,fd, int,operation);
  797. #endif
  798. //#define __NR_msync 144
  799. //#define __NR_readv 145
  800. #ifdef L_readv
  801. #include <sys/uio.h>
  802. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  803. count);
  804. #endif
  805. //#define __NR_writev 146
  806. #ifdef L_writev
  807. #include <sys/uio.h>
  808. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  809. count);
  810. #endif
  811. //#define __NR_getsid 147
  812. #ifdef L_getsid
  813. #include <unistd.h>
  814. _syscall1(pid_t, getsid, pid_t, pid);
  815. #endif
  816. //#define __NR_fdatasync 148
  817. //#define __NR__sysctl 149
  818. //#define __NR_mlock 150
  819. //#define __NR_munlock 151
  820. //#define __NR_mlockall 152
  821. //#define __NR_munlockall 153
  822. //#define __NR_sched_setparam 154
  823. //#define __NR_sched_getparam 155
  824. //#define __NR_sched_setscheduler 156
  825. //#define __NR_sched_getscheduler 157
  826. //#define __NR_sched_yield 158
  827. //#define __NR_sched_get_priority_max 159
  828. //#define __NR_sched_get_priority_min 160
  829. //#define __NR_sched_rr_get_interval 161
  830. //#define __NR_nanosleep 162
  831. #ifdef L_nanosleep
  832. #include <time.h>
  833. _syscall2(int, nanosleep, const struct timespec *, req, struct timespec *, rem);
  834. #endif
  835. //#define __NR_mremap 163
  836. #ifdef L_mremap
  837. #include <unistd.h>
  838. #include <sys/mman.h>
  839. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t,
  840. new_size, int, may_move);
  841. #endif
  842. //#define __NR_setresuid 164
  843. //#define __NR_getresuid 165
  844. //#define __NR_vm86 166
  845. //#define __NR_query_module 167
  846. #ifdef L_query_module
  847. # ifdef __NR_query_module
  848. _syscall5(int, query_module, const char *, name, int, which,
  849. void *, buf, size_t, bufsize, size_t*, ret);
  850. # endif
  851. #endif
  852. //#define __NR_poll 168
  853. #if defined(L_poll) && defined(__NR_poll) /* uClinux 2.0 doesn't have poll */
  854. #include <sys/poll.h>
  855. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  856. #endif
  857. //#define __NR_nfsservctl 169
  858. //#define __NR_setresgid 170
  859. //#define __NR_getresgid 171
  860. //#define __NR_prctl 172
  861. //#define __NR_rt_sigreturn 173
  862. //#define __NR_rt_sigaction 174
  863. //#define __NR_rt_sigprocmask 175
  864. //#define __NR_rt_sigpending 176
  865. //#define __NR_rt_sigtimedwait 177
  866. //#define __NR_rt_sigqueueinfo 178
  867. //#define __NR_rt_sigsuspend 179
  868. //#define __NR_pread 180
  869. //#define __NR_pwrite 181
  870. //#define __NR_chown 182
  871. #ifdef L_chown
  872. #include <unistd.h>
  873. _syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
  874. #endif
  875. //#define __NR_getcwd 183
  876. // See unistd/getcwd.c -- we don't use the syscall, even when it is available...
  877. //#define __NR_capget 184
  878. //#define __NR_capset 185
  879. //#define __NR_sigaltstack 186
  880. //#define __NR_sendfile 187
  881. //#define __NR_getpmsg 188
  882. //#define __NR_putpmsg 189
  883. //#define __NR_vfork 190
  884. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...