syscalls.c 39 KB

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