syscalls.c 41 KB

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