syscalls.c 49 KB

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