syscalls.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812
  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. #define _SYS_STAT_H
  840. #include <bits/stat.h>
  841. #include "xstatconv.h"
  842. _syscall2(int, __syscall_stat, const char *, file_name, struct kernel_stat *, buf);
  843. int stat(const char * file_name, struct stat * buf)
  844. {
  845. int result;
  846. struct kernel_stat kbuf;
  847. result = __syscall_stat(file_name, &kbuf);
  848. if (result == 0) {
  849. __xstat_conv(&kbuf, buf);
  850. }
  851. return result;
  852. }
  853. #if ! defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
  854. weak_alias(stat, stat64);
  855. #endif
  856. #endif
  857. //#define __NR_lstat 107
  858. #ifdef L___syscall_lstat
  859. #define __NR___syscall_lstat __NR_lstat
  860. #include <unistd.h>
  861. #define _SYS_STAT_H
  862. #include <bits/stat.h>
  863. #include <bits/kernel_stat.h>
  864. #include "xstatconv.h"
  865. _syscall2(int, __syscall_lstat, const char *, file_name, struct kernel_stat *, buf);
  866. int lstat(const char * file_name, struct stat * buf)
  867. {
  868. int result;
  869. struct kernel_stat kbuf;
  870. result = __syscall_lstat(file_name, &kbuf);
  871. if (result == 0) {
  872. __xstat_conv(&kbuf, buf);
  873. }
  874. return result;
  875. }
  876. #if ! defined __NR_lstat64 && defined __UCLIBC_HAS_LFS__
  877. weak_alias(lstat, lstat64);
  878. #endif
  879. #endif
  880. //#define __NR_fstat 108
  881. #ifdef L___syscall_fstat
  882. #define __NR___syscall_fstat __NR_fstat
  883. #include <unistd.h>
  884. #define _SYS_STAT_H
  885. #include <bits/stat.h>
  886. #include <bits/kernel_stat.h>
  887. #include "xstatconv.h"
  888. _syscall2(int, __syscall_fstat, int, fd, struct kernel_stat *, buf);
  889. int fstat(int fd, struct stat * buf)
  890. {
  891. int result;
  892. struct kernel_stat kbuf;
  893. result = __syscall_fstat(fd, &kbuf);
  894. if (result == 0) {
  895. __xstat_conv(&kbuf, buf);
  896. }
  897. return result;
  898. }
  899. #if ! defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
  900. weak_alias(fstat, fstat64);
  901. #endif
  902. #endif
  903. //#define __NR_olduname 109
  904. //#define __NR_iopl 110
  905. #ifdef L_iopl
  906. /* For arm there is a totally different implementation */
  907. #if !defined(__arm__)
  908. /* Tuns out the m68k unistd.h kernel header is broken */
  909. # if defined __UCLIBC_HAS_MMU__ && defined __NR_iopl && ( !defined(__mc68000__))
  910. _syscall1(int, iopl, int, level);
  911. # else
  912. int iopl(int level)
  913. {
  914. __set_errno(ENOSYS);
  915. return -1;
  916. }
  917. # endif
  918. # endif
  919. #endif
  920. //#define __NR_vhangup 111
  921. #ifdef L_vhangup
  922. #include <unistd.h>
  923. _syscall0(int, vhangup);
  924. #endif
  925. //#define __NR_idle 112
  926. //int idle(void);
  927. //#define __NR_vm86old 113
  928. //#define __NR_wait4 114
  929. #ifdef L_wait4
  930. _syscall4(int, wait4, pid_t, pid, int *, status, int, opts, void *, rusage);
  931. #endif
  932. //#define __NR_swapoff 115
  933. #ifdef L_swapoff
  934. #include <sys/swap.h>
  935. _syscall1(int, swapoff, const char *, path);
  936. #endif
  937. //#define __NR_sysinfo 116
  938. #ifdef L_sysinfo
  939. #include <sys/sysinfo.h>
  940. _syscall1(int, sysinfo, struct sysinfo *, info);
  941. #endif
  942. //#define __NR_ipc 117
  943. #ifdef L___ipc
  944. #ifdef __NR_ipc
  945. #define __NR___ipc __NR_ipc
  946. _syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
  947. #endif
  948. #endif
  949. //#define __NR_fsync 118
  950. #ifdef L___libc_fsync
  951. #include <unistd.h>
  952. #define __NR___libc_fsync __NR_fsync
  953. _syscall1(int, __libc_fsync, int, fd);
  954. weak_alias(__libc_fsync, fsync)
  955. #endif
  956. //#define __NR_sigreturn 119
  957. //int sigreturn(unsigned long __unused);
  958. //#define __NR_clone 120
  959. //See architecture specific implementation...
  960. //#define __NR_setdomainname 121
  961. #ifdef L_setdomainname
  962. #include <unistd.h>
  963. _syscall2(int, setdomainname, const char *, name, size_t, len);
  964. #endif
  965. //#define __NR_uname 122
  966. #ifdef L_uname
  967. #include <sys/utsname.h>
  968. _syscall1(int, uname, struct utsname *, buf);
  969. #endif
  970. //#define __NR_modify_ldt 123
  971. #ifdef __NR_modify_ldt
  972. #ifdef L_modify_ldt
  973. _syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount);
  974. #endif
  975. #endif
  976. //#define __NR_adjtimex 124
  977. #ifdef L_adjtimex
  978. #include <sys/timex.h>
  979. _syscall1(int, adjtimex, struct timex *, buf);
  980. weak_alias(adjtimex, __adjtimex);
  981. #endif
  982. //#define __NR_mprotect 125
  983. #ifdef L_mprotect
  984. #include <sys/mman.h>
  985. _syscall3(int, mprotect, void *, addr, size_t, len, int, prot);
  986. #endif
  987. //#define __NR_sigprocmask 126
  988. #ifndef __NR_rt_sigprocmask
  989. #ifdef L_sigprocmask
  990. #include <signal.h>
  991. #undef sigprocmask
  992. _syscall3(int, sigprocmask, int, how, const sigset_t *, set,
  993. sigset_t *, oldset);
  994. #endif
  995. #endif
  996. //#define __NR_create_module 127
  997. //See sysdeps/linux/commom/create_module.c
  998. //#define __NR_init_module 128
  999. #ifdef L_init_module
  1000. /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
  1001. * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
  1002. * and let the kernel cope with whatever it gets. It's good at that. */
  1003. _syscall5(int, init_module, void *, first, void *, second, void *, third,
  1004. void *, fourth, void *, fifth);
  1005. #endif
  1006. //#define __NR_delete_module 129
  1007. #ifdef L_delete_module
  1008. # ifdef __NR_delete_module
  1009. _syscall1(int, delete_module, const char *, name);
  1010. # else
  1011. int delete_module(const char * name)
  1012. {
  1013. __set_errno(ENOSYS);
  1014. return -1;
  1015. }
  1016. # endif
  1017. #endif
  1018. //#define __NR_get_kernel_syms 130
  1019. #ifdef L_get_kernel_syms
  1020. struct kernel_sym;
  1021. _syscall1(int, get_kernel_syms, struct kernel_sym *, table);
  1022. #endif
  1023. //#define __NR_quotactl 131
  1024. #ifdef __NR_quotactl
  1025. #ifdef L_quotactl
  1026. #include <sys/quota.h>
  1027. _syscall4(int, quotactl, int, cmd, const char *, special , int, id, caddr_t, addr);
  1028. #endif
  1029. #endif
  1030. //#define __NR_getpgid 132
  1031. #ifdef L_getpgid
  1032. _syscall1(pid_t, getpgid, pid_t, pid);
  1033. #endif
  1034. //#define __NR_fchdir 133
  1035. #ifdef L_fchdir
  1036. #include <unistd.h>
  1037. _syscall1(int, fchdir, int, fd);
  1038. #endif
  1039. //#define __NR_bdflush 134
  1040. #ifdef L_bdflush
  1041. #include <sys/kdaemon.h>
  1042. _syscall2(int, bdflush, int, __func, long int, __data);
  1043. #endif
  1044. //#define __NR_sysfs 135
  1045. //#define __NR_personality 136
  1046. //#define __NR_afs_syscall 137
  1047. //#define __NR_setfsuid 138
  1048. #ifdef __NR_setfsuid
  1049. #ifdef L_setfsuid
  1050. #include <sys/fsuid.h>
  1051. _syscall1(int, setfsuid, uid_t, uid);
  1052. #endif
  1053. #endif
  1054. //#define __NR_setfsgid 139
  1055. #ifdef __NR_setfsgid
  1056. #ifdef L_setfsgid
  1057. #include <sys/fsuid.h>
  1058. _syscall1(int, setfsgid, gid_t, gid);
  1059. #endif
  1060. #endif
  1061. //#define __NR__llseek 140
  1062. //See llseek.c
  1063. //#define __NR_getdents 141
  1064. // See getdents.c
  1065. //#define __NR__newselect 142
  1066. #ifdef L__newselect
  1067. //Used in preference to select when available...
  1068. #ifdef __NR__newselect
  1069. #include <unistd.h>
  1070. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  1071. fd_set *exceptfds, struct timeval *timeout);
  1072. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  1073. fd_set *, exceptfds, struct timeval *, timeout);
  1074. weak_alias(_newselect, select);
  1075. #endif
  1076. #endif
  1077. //#define __NR_flock 143
  1078. #ifdef L_flock
  1079. #include <sys/file.h>
  1080. _syscall2(int,flock,int,fd, int,operation);
  1081. #endif
  1082. //#define __NR_msync 144
  1083. #ifdef L___libc_msync
  1084. #include <unistd.h>
  1085. #include <sys/mman.h>
  1086. #define __NR___libc_msync __NR_msync
  1087. _syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags);
  1088. weak_alias(__libc_msync, msync);
  1089. #endif
  1090. //#define __NR_readv 145
  1091. #ifdef L_readv
  1092. #include <sys/uio.h>
  1093. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  1094. count);
  1095. #endif
  1096. //#define __NR_writev 146
  1097. #ifdef L_writev
  1098. #include <sys/uio.h>
  1099. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  1100. count);
  1101. #endif
  1102. //#define __NR_getsid 147
  1103. #ifdef L_getsid
  1104. #include <unistd.h>
  1105. _syscall1(pid_t, getsid, pid_t, pid);
  1106. #endif
  1107. //#define __NR_fdatasync 148
  1108. #ifdef __NR_fdatasync
  1109. #ifdef L_fdatasync
  1110. #include <unistd.h>
  1111. _syscall1(int, fdatasync, int, fd);
  1112. #endif
  1113. #endif
  1114. //#define __NR__sysctl 149
  1115. #ifdef __NR__sysctl
  1116. #ifdef L__sysctl
  1117. #include <linux/sysctl.h>
  1118. _syscall1(int, _sysctl, struct __sysctl_args *, args);
  1119. int sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
  1120. void *newval, size_t newlen)
  1121. {
  1122. struct __sysctl_args args =
  1123. {
  1124. name: name,
  1125. nlen: nlen,
  1126. oldval: oldval,
  1127. oldlenp: oldlenp,
  1128. newval: newval,
  1129. newlen: newlen
  1130. };
  1131. return _sysctl(&args);
  1132. }
  1133. #endif
  1134. #endif
  1135. //#define __NR_mlock 150
  1136. #ifdef L_mlock
  1137. #include <sys/mman.h>
  1138. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlock
  1139. _syscall2(int, mlock, const void *, addr, size_t, len);
  1140. # endif
  1141. #endif
  1142. //#define __NR_munlock 151
  1143. #ifdef L_munlock
  1144. #include <sys/mman.h>
  1145. # if defined __UCLIBC_HAS_MMU__ && defined __NR_munlock
  1146. _syscall2(int, munlock, const void *, addr, size_t, len);
  1147. # endif
  1148. #endif
  1149. //#define __NR_mlockall 152
  1150. #ifdef L_mlockall
  1151. #include <sys/mman.h>
  1152. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlockall
  1153. _syscall1(int, mlockall, int, flags);
  1154. # endif
  1155. #endif
  1156. //#define __NR_munlockall 153
  1157. #ifdef L_munlockall
  1158. #include <sys/mman.h>
  1159. # if defined __UCLIBC_HAS_MMU__ && defined L_munlockall
  1160. _syscall0(int, munlockall);
  1161. # endif
  1162. #endif
  1163. //#define __NR_sched_setparam 154
  1164. #ifdef __NR_sched_setparam
  1165. #ifdef L_sched_setparam
  1166. #include <sched.h>
  1167. _syscall2(int, sched_setparam, pid_t, pid, const struct sched_param *, p);
  1168. #endif
  1169. #endif
  1170. //#define __NR_sched_getparam 155
  1171. #ifdef __NR_sched_getparam
  1172. #ifdef L_sched_getparam
  1173. #include <sched.h>
  1174. _syscall2(int, sched_getparam, pid_t, pid, struct sched_param *, p);
  1175. #endif
  1176. #endif
  1177. //#define __NR_sched_setscheduler 156
  1178. #ifdef __NR_sched_setscheduler
  1179. #ifdef L_sched_setscheduler
  1180. #include <sched.h>
  1181. _syscall3(int, sched_setscheduler, pid_t, pid, int, policy, const struct sched_param *, p);
  1182. #endif
  1183. #endif
  1184. //#define __NR_sched_getscheduler 157
  1185. #ifdef __NR_sched_getscheduler
  1186. #ifdef L_sched_getscheduler
  1187. #include <sched.h>
  1188. _syscall1(int, sched_getscheduler, pid_t, pid);
  1189. #endif
  1190. #endif
  1191. //#define __NR_sched_yield 158
  1192. #ifdef __NR_sched_yield
  1193. #ifdef L_sched_yield
  1194. #include <sched.h>
  1195. _syscall0(int, sched_yield);
  1196. #endif
  1197. #endif
  1198. //#define __NR_sched_get_priority_max 159
  1199. #ifdef __NR_sched_get_priority_max
  1200. #ifdef L_sched_get_priority_max
  1201. #include <sched.h>
  1202. _syscall1(int, sched_get_priority_max, int, policy);
  1203. #endif
  1204. #endif
  1205. //#define __NR_sched_get_priority_min 160
  1206. #ifdef __NR_sched_get_priority_min
  1207. #ifdef L_sched_get_priority_min
  1208. #include <sched.h>
  1209. _syscall1(int, sched_get_priority_min, int, policy);
  1210. #endif
  1211. #endif
  1212. //#define __NR_sched_rr_get_interval 161
  1213. #ifdef __NR_sched_rr_get_interval
  1214. #ifdef L_sched_rr_get_interval
  1215. #include <sched.h>
  1216. _syscall2(int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp);
  1217. #endif
  1218. #endif
  1219. //#define __NR_nanosleep 162
  1220. #ifdef L___libc_nanosleep
  1221. #include <time.h>
  1222. #define __NR___libc_nanosleep __NR_nanosleep
  1223. _syscall2(int, __libc_nanosleep, const struct timespec *, req, struct timespec *, rem);
  1224. weak_alias(__libc_nanosleep, nanosleep)
  1225. #endif
  1226. //#define __NR_mremap 163
  1227. #ifdef L_mremap
  1228. #include <unistd.h>
  1229. #include <sys/mman.h>
  1230. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t, new_size, int, may_move);
  1231. #endif
  1232. //#define __NR_setresuid 164
  1233. #ifdef __NR_setresuid
  1234. #ifdef L_setresuid
  1235. _syscall3(int, setresuid, uid_t, ruid, uid_t, euid, uid_t, suid);
  1236. #endif
  1237. #endif
  1238. //#define __NR_getresuid 165
  1239. #ifdef __NR_getresuid
  1240. #ifdef L_getresuid
  1241. _syscall3(int, getresuid, uid_t *, euid, uid_t *, ruid, uid_t *, suid);
  1242. #endif
  1243. #endif
  1244. //#define __NR_vm86 166
  1245. //#define __NR_query_module 167
  1246. #ifdef L_query_module
  1247. # ifdef __NR_query_module
  1248. _syscall5(int, query_module, const char *, name, int, which,
  1249. void *, buf, size_t, bufsize, size_t*, ret);
  1250. # else
  1251. int query_module(const char * name, int which,
  1252. void * buf, size_t bufsize, size_t* ret)
  1253. {
  1254. __set_errno(ENOSYS);
  1255. return -1;
  1256. }
  1257. # endif
  1258. #endif
  1259. //#define __NR_poll 168
  1260. #if defined(L_poll) && defined(__NR_poll) /* uClinux 2.0 doesn't have poll */
  1261. #include <sys/poll.h>
  1262. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  1263. #endif
  1264. //#define __NR_nfsservctl 169
  1265. //nfsservctl EXTRA nfsservctl i:ipp nfsservctl
  1266. //#define __NR_setresgid 170
  1267. #ifdef __NR_setresgid
  1268. #ifdef L_setresgid
  1269. _syscall3(int, setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid);
  1270. #endif
  1271. #endif
  1272. //#define __NR_getresgid 171
  1273. #ifdef __NR_getresgid
  1274. #ifdef L_getresgid
  1275. _syscall3(int, getresgid, gid_t *, egid, gid_t *, rgid, gid_t *, sgid);
  1276. #endif
  1277. #endif
  1278. //#define __NR_prctl 172
  1279. //#define __NR_rt_sigreturn 173
  1280. //#define __NR_rt_sigaction 174
  1281. #ifdef __NR_rt_sigaction
  1282. #define __NR___syscall_rt_sigaction __NR_rt_sigaction
  1283. #ifdef L___syscall_rt_sigaction
  1284. #include <signal.h>
  1285. #undef sigaction
  1286. _syscall4(int, __syscall_rt_sigaction, int, signum, const struct sigaction *, act,
  1287. struct sigaction *, oldact, size_t, size);
  1288. #endif
  1289. #endif
  1290. //#define __NR_rt_sigprocmask 175
  1291. #ifdef __NR_rt_sigprocmask
  1292. #define __NR___rt_sigprocmask __NR_rt_sigprocmask
  1293. #ifdef L___rt_sigprocmask
  1294. #include <signal.h>
  1295. #undef sigprocmask
  1296. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  1297. sigset_t *, oldset, size_t, size);
  1298. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
  1299. {
  1300. return __rt_sigprocmask(how, set, oldset, _NSIG/8);
  1301. }
  1302. #endif
  1303. #endif
  1304. //#define __NR_rt_sigpending 176
  1305. #ifdef __NR_rt_sigpending
  1306. #define __NR___rt_sigpending __NR_rt_sigpending
  1307. #ifdef L___rt_sigpending
  1308. #include <signal.h>
  1309. #undef sigpending
  1310. _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size);
  1311. int sigpending(sigset_t *set)
  1312. {
  1313. return __rt_sigpending(set, _NSIG/8);
  1314. }
  1315. #endif
  1316. #endif
  1317. //#define __NR_rt_sigtimedwait 177
  1318. #ifdef L___rt_sigtimedwait
  1319. #include <signal.h>
  1320. #define __need_NULL
  1321. #include <stddef.h>
  1322. #ifdef __NR_rt_sigtimedwait
  1323. #define __NR___rt_sigtimedwait __NR_rt_sigtimedwait
  1324. _syscall4(int, __rt_sigtimedwait, const sigset_t *, set, siginfo_t *, info,
  1325. const struct timespec *, timeout, size_t, setsize);
  1326. int sigwaitinfo(const sigset_t *set, siginfo_t *info)
  1327. {
  1328. return __rt_sigtimedwait (set, info, NULL, _NSIG/8);
  1329. }
  1330. int sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
  1331. {
  1332. return __rt_sigtimedwait (set, info, timeout, _NSIG/8);
  1333. }
  1334. #else
  1335. int sigwaitinfo(const sigset_t *set, siginfo_t *info)
  1336. {
  1337. if (set==NULL)
  1338. __set_errno (EINVAL);
  1339. else
  1340. __set_errno (ENOSYS);
  1341. return -1;
  1342. }
  1343. int sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
  1344. {
  1345. if (set==NULL)
  1346. __set_errno (EINVAL);
  1347. else
  1348. __set_errno (ENOSYS);
  1349. return -1;
  1350. }
  1351. #endif
  1352. #endif
  1353. //#define __NR_rt_sigqueueinfo 178
  1354. //#define __NR_rt_sigsuspend 179
  1355. #ifdef __NR_rt_sigsuspend
  1356. #define __NR___rt_sigsuspend __NR_rt_sigsuspend
  1357. #ifdef L___rt_sigsuspend
  1358. #include <signal.h>
  1359. #undef _sigsuspend
  1360. _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
  1361. int sigsuspend (const sigset_t *mask)
  1362. {
  1363. return __rt_sigsuspend(mask, _NSIG/8);
  1364. }
  1365. #endif
  1366. #endif
  1367. //#define __NR_pread 180
  1368. // See pread_write.c
  1369. //#define __NR_pwrite 181
  1370. // See pread_write.c
  1371. //#define __NR_chown 182
  1372. #ifdef L_chown
  1373. #include <unistd.h>
  1374. _syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
  1375. #endif
  1376. //#define __NR_getcwd 183
  1377. // See getcwd.c in this directory
  1378. //#define __NR_capget 184
  1379. #ifdef L_capget
  1380. # ifdef __NR_capget
  1381. _syscall2(int, capget, void*, header, void*, data);
  1382. # else
  1383. int capget(void* header, void* data)
  1384. {
  1385. __set_errno(ENOSYS);
  1386. return -1;
  1387. }
  1388. # endif
  1389. #endif
  1390. //#define __NR_capset 185
  1391. #ifdef L_capset
  1392. # ifdef __NR_capset
  1393. _syscall2(int, capset, void*, header, const void*, data);
  1394. # else
  1395. int capset(void* header, const void* data)
  1396. {
  1397. __set_errno(ENOSYS);
  1398. return -1;
  1399. }
  1400. # endif
  1401. #endif
  1402. //#define __NR_sigaltstack 186
  1403. #ifdef __NR_sigaltstack
  1404. #ifdef L_sigaltstack
  1405. #include <signal.h>
  1406. _syscall2(int, sigaltstack, const struct sigaltstack *, ss, struct sigaltstack *, oss);
  1407. #endif
  1408. #endif
  1409. //#define __NR_sendfile 187
  1410. #ifdef __NR_sendfile
  1411. #ifdef L_sendfile
  1412. #include <unistd.h>
  1413. #include <sys/sendfile.h>
  1414. _syscall4(ssize_t,sendfile, int, out_fd, int, in_fd, __off_t *, offset, size_t, count);
  1415. #endif
  1416. #endif
  1417. //#define __NR_getpmsg 188
  1418. //#define __NR_putpmsg 189
  1419. //#define __NR_vfork 190
  1420. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...
  1421. //#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
  1422. #ifdef L___ugetrlimit
  1423. #ifdef __NR_ugetrlimit
  1424. #define __NR___ugetrlimit __NR_ugetrlimit
  1425. #include <unistd.h>
  1426. #include <sys/resource.h>
  1427. _syscall2(int, __ugetrlimit, enum __rlimit_resource, resource, struct rlimit *, rlim);
  1428. int getrlimit (__rlimit_resource_t resource, struct rlimit *rlimits)
  1429. {
  1430. return(__ugetrlimit(resource, rlimits));
  1431. }
  1432. #endif /* __NR_ugetrlimit */
  1433. #endif
  1434. //#define __NR_mmap2 192
  1435. //#define __NR_truncate64 193
  1436. //See libc/sysdeps/linux/common/truncate64.c
  1437. //#define __NR_ftruncate64 194
  1438. //See libc/sysdeps/linux/common/ftruncate64.c
  1439. //#define __NR_stat64 195
  1440. #ifdef L___syscall_stat64
  1441. #if defined __NR_stat64 && defined __UCLIBC_HAS_LFS__
  1442. #define __NR___syscall_stat64 __NR_stat64
  1443. #include <unistd.h>
  1444. #include <sys/stat.h>
  1445. #include <bits/kernel_stat.h>
  1446. #include "xstatconv.h"
  1447. _syscall2(int, __syscall_stat64, const char *, file_name, struct kernel_stat64 *, buf);
  1448. int stat64(const char * file_name, struct stat64 * buf)
  1449. {
  1450. int result;
  1451. struct kernel_stat64 kbuf;
  1452. result = __syscall_stat64(file_name, &kbuf);
  1453. if (result == 0) {
  1454. __xstat64_conv(&kbuf, buf);
  1455. }
  1456. return result;
  1457. }
  1458. #endif /* __UCLIBC_HAS_LFS__ */
  1459. #endif
  1460. //#define __NR_lstat64 196
  1461. #ifdef L___syscall_lstat64
  1462. #if defined __NR_lstat64 && defined __UCLIBC_HAS_LFS__
  1463. #define __NR___syscall_lstat64 __NR_lstat64
  1464. #include <unistd.h>
  1465. #include <sys/stat.h>
  1466. #include <bits/kernel_stat.h>
  1467. #include "xstatconv.h"
  1468. _syscall2(int, __syscall_lstat64, const char *, file_name, struct kernel_stat64 *, buf);
  1469. int lstat64(const char * file_name, struct stat64 * buf)
  1470. {
  1471. int result;
  1472. struct kernel_stat64 kbuf;
  1473. result = __syscall_lstat64(file_name, &kbuf);
  1474. if (result == 0) {
  1475. __xstat64_conv(&kbuf, buf);
  1476. }
  1477. return result;
  1478. }
  1479. #endif /* __UCLIBC_HAS_LFS__ */
  1480. #endif
  1481. //#define __NR_fstat64 197
  1482. #ifdef L___syscall_fstat64
  1483. #if defined __NR_fstat64 && defined __UCLIBC_HAS_LFS__
  1484. #define __NR___syscall_fstat64 __NR_fstat64
  1485. #include <unistd.h>
  1486. #include <sys/stat.h>
  1487. #include <bits/kernel_stat.h>
  1488. #include "xstatconv.h"
  1489. _syscall2(int, __syscall_fstat64, int, filedes, struct kernel_stat64 *, buf);
  1490. int fstat64(int fd, struct stat64 * buf)
  1491. {
  1492. int result;
  1493. struct kernel_stat64 kbuf;
  1494. result = __syscall_fstat64(fd, &kbuf);
  1495. if (result == 0) {
  1496. __xstat64_conv(&kbuf, buf);
  1497. }
  1498. return result;
  1499. }
  1500. #endif /* __UCLIBC_HAS_LFS__ */
  1501. #endif
  1502. //#define __NR_lchown32 198
  1503. //#define __NR_getuid32 199
  1504. //#define __NR_getgid32 200
  1505. //#define __NR_geteuid32 201
  1506. //#define __NR_getegid32 202
  1507. //#define __NR_setreuid32 203
  1508. //#define __NR_setregid32 204
  1509. //#define __NR_getgroups32 205
  1510. //#define __NR_setgroups32 206
  1511. //#define __NR_fchown32 207
  1512. //#define __NR_setresuid32 208
  1513. //#define __NR_getresuid32 209
  1514. //#define __NR_setresgid32 210
  1515. //#define __NR_getresgid32 211
  1516. //#define __NR_chown32 212
  1517. //#define __NR_setuid32 213
  1518. //#define __NR_setgid32 214
  1519. //#define __NR_setfsuid32 215
  1520. //#define __NR_setfsgid32 216
  1521. //#define __NR_pivot_root 217
  1522. #ifdef __NR_pivot_root
  1523. #ifdef L_pivot_root
  1524. _syscall2(int, pivot_root, const char *, new_root, const char *, put_old);
  1525. #endif
  1526. #endif
  1527. //#define __NR_mincore 218
  1528. //#define __NR_madvise 219
  1529. //#define __NR_madvise1 219 /* delete when C lib stub is removed */
  1530. //#define __NR_getdents64 220
  1531. // See getdents64.c
  1532. //#define __NR_fcntl64 221
  1533. #ifdef L__fcntl64
  1534. #ifdef __UCLIBC_HAS_LFS__
  1535. #include <stdarg.h>
  1536. #include <fcntl.h>
  1537. #ifdef __NR_fcntl64
  1538. #define __NR__fcntl64 __NR_fcntl64
  1539. extern int _fcntl64(int fd, int cmd, long arg);
  1540. _syscall3(int, _fcntl64, int, fd, int, cmd, long, arg);
  1541. int fcntl64(int fd, int command, ...)
  1542. {
  1543. long arg;
  1544. va_list list;
  1545. va_start(list, command);
  1546. arg = va_arg(list, long);
  1547. va_end(list);
  1548. return _fcntl64(fd, command, arg);
  1549. }
  1550. #else
  1551. extern int _fcntl(int fd, int cmd, long arg);
  1552. int fcntl64(int fd, int command, ...)
  1553. {
  1554. long arg;
  1555. va_list list;
  1556. va_start(list, command);
  1557. arg = va_arg(list, long);
  1558. va_end(list);
  1559. return _fcntl(fd, command, arg);
  1560. }
  1561. #endif
  1562. #endif
  1563. #endif
  1564. //#define __NR_security 223 /* syscall for security modules */
  1565. //#define __NR_gettid 224
  1566. //#define __NR_readahead 225