syscalls.c 20 KB

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