syscalls.c 51 KB

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