syscalls.c 50 KB

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