syscalls.c 50 KB

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