syscalls.c 37 KB

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