syscalls.c 42 KB

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