syscalls.c 39 KB

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