syscalls.c 54 KB

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