syscalls.c 36 KB

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