syscalls.c 50 KB

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