syscalls.c 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Syscalls for uClibc
  4. *
  5. * Copyright (C) 2000 by Lineo, inc
  6. * Copyright (C) 2001 by Erik Andersen
  7. * Written by Erik Andersen <andersen@codpoet.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Library General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  17. * for more details.
  18. *
  19. * You should have received a copy of the GNU Library General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #include <features.h>
  25. #include <errno.h>
  26. #include <sys/types.h>
  27. #include <sys/syscall.h>
  28. //#define __NR_exit 1
  29. #ifdef L__exit
  30. /* Do not include unistd.h, so gcc doesn't whine about
  31. * _exit returning. It really doesn't return... */
  32. #define __NR__exit __NR_exit
  33. _syscall1(void, _exit, int, status);
  34. #endif
  35. //#define __NR_fork 2
  36. #ifdef L___libc_fork
  37. #include <unistd.h>
  38. # ifdef __UCLIBC_HAS_MMU__
  39. #define __NR___libc_fork __NR_fork
  40. _syscall0(pid_t, __libc_fork);
  41. weak_alias (__libc_fork, fork)
  42. # else
  43. pid_t fork(void)
  44. {
  45. __set_errno(ENOSYS);
  46. return -1;
  47. }
  48. # endif
  49. #endif
  50. //#define __NR_read 3
  51. #ifdef L___libc_read
  52. #include <unistd.h>
  53. #define __NR___libc_read __NR_read
  54. _syscall3(ssize_t, __libc_read, int, fd, __ptr_t, buf, size_t, count);
  55. weak_alias(__libc_read, read)
  56. #endif
  57. //#define __NR_write 4
  58. #ifdef L___libc_write
  59. #include <unistd.h>
  60. #define __NR___libc_write __NR_write
  61. _syscall3(ssize_t, __libc_write, int, fd, const __ptr_t, buf, size_t, count);
  62. weak_alias(__libc_write, write)
  63. #endif
  64. //#define __NR_open 5
  65. #ifdef L___libc_open
  66. #include <stdarg.h>
  67. /* Do not include fcntl.h, so gcc doesn't whine the prototype */
  68. #define __NR___libc_open __NR_open
  69. _syscall3(int, __libc_open, const char *, fn, int, flags, mode_t, mode);
  70. weak_alias(__libc_open, open)
  71. #endif
  72. //#define __NR_close 6
  73. #ifdef L___libc_close
  74. #include <unistd.h>
  75. #define __NR___libc_close __NR_close
  76. _syscall1(int, __libc_close, int, fd);
  77. weak_alias(__libc_close, close)
  78. #endif
  79. //#define __NR_waitpid 7
  80. // Implemented using wait4
  81. //#define __NR_creat 8
  82. #ifdef L_creat
  83. #include <fcntl.h>
  84. _syscall2(int, creat, const char *, file, mode_t, mode);
  85. #endif
  86. //#define __NR_link 9
  87. #ifdef L_link
  88. #include <unistd.h>
  89. _syscall2(int, link, const char *, oldpath, const char *, newpath);
  90. #endif
  91. //#define __NR_unlink 10
  92. #ifdef L_unlink
  93. #include <unistd.h>
  94. _syscall1(int, unlink, const char *, pathname);
  95. #endif
  96. //#define __NR_execve 11
  97. #ifdef L_execve
  98. #include <unistd.h>
  99. _syscall3(int, execve, const char *, filename, char *const *, argv,
  100. char *const *, envp);
  101. #endif
  102. //#define __NR_chdir 12
  103. #ifdef L_chdir
  104. #include <unistd.h>
  105. _syscall1(int, chdir, const char *, path);
  106. #endif
  107. //#define __NR_time 13
  108. #ifdef L_time
  109. #include <time.h>
  110. _syscall1(time_t, time, time_t *, t);
  111. #endif
  112. //#define __NR_mknod 14
  113. #ifdef L_mknod
  114. #include <unistd.h>
  115. extern int mknod(const char *pathname, mode_t mode, dev_t dev);
  116. _syscall3(int, mknod, const char *, pathname, mode_t, mode, dev_t, dev);
  117. int __xmknod (int version, const char * path, mode_t mode, dev_t *dev)
  118. {
  119. switch(version)
  120. {
  121. case 1:
  122. return mknod (path, mode, *dev);
  123. default:
  124. __set_errno(EINVAL);
  125. return -1;
  126. }
  127. }
  128. #endif
  129. //#define __NR_chmod 15
  130. #ifdef L_chmod
  131. #include <sys/stat.h>
  132. _syscall2(int, chmod, const char *, path, mode_t, mode);
  133. #endif
  134. /* Old kernels don't have lchown -- do chown instead. This
  135. * is sick and wrong, but at least things will compile.
  136. * They may not follow links when they should though... */
  137. #ifndef __NR_lchown
  138. #define __NR_lchown __NR_chown
  139. #endif
  140. //#define __NR_lchown 16
  141. #ifdef L_lchown
  142. #include <unistd.h>
  143. _syscall3(int, lchown, const char *, path, uid_t, owner, gid_t, group);
  144. #endif
  145. //#define __NR_break 17
  146. //#define __NR_oldstat 18
  147. //#define __NR_lseek 19
  148. #ifdef L___libc_lseek
  149. #include <unistd.h>
  150. #define __NR___libc_lseek __NR_lseek
  151. _syscall3(off_t, __libc_lseek, int, fildes, off_t, offset, int, whence);
  152. weak_alias(__libc_lseek, lseek)
  153. #endif
  154. //#define __NR_getpid 20
  155. #ifdef L___libc_getpid
  156. #include <unistd.h>
  157. #define __NR___libc_getpid __NR_getpid
  158. _syscall0(pid_t, __libc_getpid);
  159. weak_alias(__libc_getpid, getpid)
  160. weak_alias(__libc_getpid, __getpid)
  161. #endif
  162. //#define __NR_mount 21
  163. #ifdef L_mount
  164. #include <sys/mount.h>
  165. _syscall5(int, mount, const char *, specialfile, const char *, dir,
  166. const char *, filesystemtype, unsigned long, rwflag,
  167. const void *, data);
  168. #endif
  169. //#define __NR_umount 22
  170. #ifdef L_umount
  171. #include <sys/mount.h>
  172. _syscall1(int, umount, const char *, specialfile);
  173. #endif
  174. //#define __NR_setuid 23
  175. #ifdef L___setuid
  176. #define __NR___setuid __NR_setuid
  177. #include <unistd.h>
  178. static inline
  179. _syscall1(int, __setuid, uid_t, uid);
  180. int setuid(uid_t uid)
  181. {
  182. if (uid == (uid_t) ~0) {
  183. __set_errno (EINVAL);
  184. return -1;
  185. }
  186. return(__setuid(uid));
  187. }
  188. #endif
  189. //#define __NR_getuid 24
  190. #ifdef L_getuid
  191. #include <unistd.h>
  192. _syscall0(gid_t, getuid);
  193. #endif
  194. //#define __NR_stime 25
  195. #ifdef L_stime
  196. #include <time.h>
  197. _syscall1(int, stime, const time_t *, t);
  198. #endif
  199. //#define __NR_ptrace 26
  200. #ifdef L___ptrace
  201. #include <sys/ptrace.h>
  202. #define __NR___ptrace __NR_ptrace
  203. _syscall4(long, __ptrace, enum __ptrace_request, request, pid_t, pid,
  204. void*, addr, void*, data);
  205. #endif
  206. //#define __NR_alarm 27
  207. #ifdef L_alarm
  208. #include <unistd.h>
  209. _syscall1(unsigned int, alarm, unsigned int, seconds);
  210. #endif
  211. //#define __NR_oldfstat 28
  212. //#define __NR_pause 29
  213. #ifdef L___libc_pause
  214. #include <unistd.h>
  215. #define __NR___libc_pause __NR_pause
  216. _syscall0(int, __libc_pause);
  217. weak_alias(__libc_pause, pause)
  218. #endif
  219. //#define __NR_utime 30
  220. #ifdef L_utime
  221. #include <utime.h>
  222. _syscall2(int, utime, const char *, filename, const struct utimbuf *, buf);
  223. #endif
  224. //#define __NR_stty 31
  225. #ifdef L_stty
  226. #include <sgtty.h>
  227. int stty (int __fd, __const struct sgttyb *__params);
  228. {
  229. __set_errno(ENOSYS);
  230. return -1;
  231. }
  232. #endif
  233. //#define __NR_gtty 32
  234. #ifdef L_gtty
  235. #include <sgtty.h>
  236. int gtty (int __fd, struct sgttyb *__params)
  237. {
  238. __set_errno(ENOSYS);
  239. return -1;
  240. }
  241. #endif
  242. //#define __NR_access 33
  243. #ifdef L_access
  244. #include <unistd.h>
  245. _syscall2(int, access, const char *, pathname, int, mode);
  246. #endif
  247. //#define __NR_nice 34
  248. #ifdef L_nice
  249. #include <unistd.h>
  250. _syscall1(int, nice, int, inc);
  251. #endif
  252. //#define __NR_ftime 35
  253. //#define __NR_sync 36
  254. #ifdef L_sync
  255. #include <unistd.h>
  256. _syscall0(void, sync);
  257. #endif
  258. //#define __NR_kill 37
  259. #ifdef L_kill
  260. #include <signal.h>
  261. #undef kill
  262. _syscall2(int, kill, pid_t, pid, int, sig);
  263. #endif
  264. //#define __NR_rename 38
  265. #ifdef L_rename
  266. #include <stdio.h>
  267. _syscall2(int, rename, const char *, oldpath, const char *, newpath);
  268. #endif
  269. //#define __NR_mkdir 39
  270. #ifdef L_mkdir
  271. #include <sys/stat.h>
  272. _syscall2(int, mkdir, const char *, pathname, mode_t, mode);
  273. #endif
  274. //#define __NR_rmdir 40
  275. #ifdef L_rmdir
  276. #include <unistd.h>
  277. _syscall1(int, rmdir, const char *, pathname);
  278. #endif
  279. //#define __NR_dup 41
  280. #ifdef L_dup
  281. #include <unistd.h>
  282. _syscall1(int, dup, int, oldfd);
  283. #endif
  284. //#define __NR_pipe 42
  285. #ifdef L_pipe
  286. #include <unistd.h>
  287. _syscall1(int, pipe, int *, filedes);
  288. #endif
  289. //#define __NR_times 43
  290. #ifdef L_times
  291. #include <sys/times.h>
  292. _syscall1(clock_t, times, struct tms *, buf);
  293. #endif
  294. //#define __NR_prof 44
  295. //#define __NR_brk 45
  296. //#define __NR_setgid 46
  297. #ifdef L_setgid
  298. #include <unistd.h>
  299. _syscall1(int, setgid, gid_t, gid);
  300. #endif
  301. //#define __NR_getgid 47
  302. #ifdef L_getgid
  303. #include <unistd.h>
  304. _syscall0(gid_t, getgid);
  305. #endif
  306. //#define __NR_signal 48
  307. //#define __NR_geteuid 49
  308. #ifdef L_geteuid
  309. # ifdef __NR_geteuid
  310. # include <unistd.h>
  311. _syscall0(uid_t, geteuid);
  312. # else
  313. uid_t geteuid(void)
  314. {
  315. return (getuid());
  316. }
  317. # endif
  318. #endif
  319. //#define __NR_getegid 50
  320. #ifdef L_getegid
  321. # ifdef __NR_getegid
  322. # include <unistd.h>
  323. _syscall0(gid_t, getegid);
  324. # else
  325. gid_t getegid(void)
  326. {
  327. return (getgid());
  328. }
  329. # endif
  330. #endif
  331. //#define __NR_acct 51
  332. #ifdef L_acct
  333. #include <unistd.h>
  334. _syscall1(int, acct, const char *, filename);
  335. #endif
  336. //#define __NR_umount2 52
  337. #ifdef L_umount2
  338. # ifdef __NR_umount2 /* Old kernels don't have umount2 */
  339. # include <sys/mount.h>
  340. _syscall2(int, umount2, const char *, special_file, int, flags);
  341. # else
  342. int umount2(const char * special_file, int flags)
  343. {
  344. __set_errno(ENOSYS);
  345. return -1;
  346. }
  347. # endif
  348. #endif
  349. //#define __NR_lock 53
  350. //#define __NR_ioctl 54
  351. #ifdef L__ioctl
  352. #include <stdarg.h>
  353. #include <sys/ioctl.h>
  354. #define __NR__ioctl __NR_ioctl
  355. extern int _ioctl(int fd, int request, void *arg);
  356. _syscall3(int, _ioctl, int, fd, int, request, void *, arg);
  357. int ioctl(int fd, unsigned long int request, ...)
  358. {
  359. void *arg;
  360. va_list list;
  361. va_start(list, request);
  362. arg = va_arg(list, void *);
  363. va_end(list);
  364. return _ioctl(fd, request, arg);
  365. }
  366. #endif
  367. //#define __NR_fcntl 55
  368. #ifdef L__fcntl
  369. #include <stdarg.h>
  370. #include <fcntl.h>
  371. #define __NR__fcntl __NR_fcntl
  372. extern int _fcntl(int fd, int cmd, long arg);
  373. _syscall3(int, _fcntl, int, fd, int, cmd, long, arg);
  374. int __libc_fcntl(int fd, int command, ...)
  375. {
  376. long arg;
  377. va_list list;
  378. va_start(list, command);
  379. arg = va_arg(list, long);
  380. va_end(list);
  381. return _fcntl(fd, command, arg);
  382. }
  383. weak_alias(__libc_fcntl, fcntl)
  384. #endif
  385. //#define __NR_mpx 56
  386. //#define __NR_setpgid 57
  387. #ifdef L_setpgid
  388. #include <unistd.h>
  389. _syscall2(int, setpgid, pid_t, pid, pid_t, pgid);
  390. #endif
  391. //#define __NR_ulimit 58
  392. //#define __NR_oldolduname 59
  393. //#define __NR_umask 60
  394. #ifdef L_umask
  395. #include <sys/stat.h>
  396. _syscall1(mode_t, umask, mode_t, mask);
  397. #endif
  398. //#define __NR_chroot 61
  399. #ifdef L_chroot
  400. #include <unistd.h>
  401. _syscall1(int, chroot, const char *, path);
  402. #endif
  403. //#define __NR_ustat 62
  404. //#define __NR_dup2 63
  405. #ifdef L_dup2
  406. #include <unistd.h>
  407. _syscall2(int, dup2, int, oldfd, int, newfd);
  408. #endif
  409. //#define __NR_getppid 64
  410. #ifdef L_getppid
  411. # include <unistd.h>
  412. # ifdef __NR_getppid
  413. _syscall0(pid_t, getppid);
  414. # else
  415. pid_t getppid(void)
  416. {
  417. return (getpid());
  418. }
  419. # endif
  420. #endif
  421. //#define __NR_getpgrp 65
  422. #ifdef L_getpgrp
  423. #include <unistd.h>
  424. _syscall0(pid_t, getpgrp);
  425. #endif
  426. //#define __NR_setsid 66
  427. #ifdef L_setsid
  428. #include <unistd.h>
  429. _syscall0(pid_t, setsid);
  430. #endif
  431. //#define __NR_sigaction 67
  432. #ifndef __NR_rt_sigaction
  433. #define __NR___sigaction __NR_sigaction
  434. #ifdef L___sigaction
  435. #include <signal.h>
  436. #undef sigaction
  437. _syscall3(int, __sigaction, int, signum, const struct sigaction *, act,
  438. struct sigaction *, oldact);
  439. #endif
  440. #endif
  441. //#define __NR_sgetmask 68
  442. //#define __NR_ssetmask 69
  443. //#define __NR_setreuid 70
  444. #ifdef L_setreuid
  445. #include <unistd.h>
  446. _syscall2(int, setreuid, uid_t, ruid, uid_t, euid);
  447. #endif
  448. //#define __NR_setregid 71
  449. #ifdef L_setregid
  450. #include <unistd.h>
  451. _syscall2(int, setregid, gid_t, rgid, gid_t, egid);
  452. #endif
  453. //#define __NR_sigsuspend 72
  454. #ifndef __NR_rt_sigsuspend
  455. #define __NR___sigsuspend __NR_sigsuspend
  456. #ifdef L___sigsuspend
  457. #include <signal.h>
  458. #undef sigsuspend
  459. _syscall3(int, __sigsuspend, int, a, unsigned long int, b, unsigned long int, c);
  460. int sigsuspend (const sigset_t *set)
  461. {
  462. return __sigsuspend(0, 0, set->__val[0]);
  463. }
  464. #endif
  465. #endif
  466. //#define __NR_sigpending 73
  467. #ifndef __NR_rt_sigpending
  468. #ifdef L_sigpending
  469. #include <signal.h>
  470. #undef sigpending
  471. _syscall1(int, sigpending, sigset_t *, set);
  472. #endif
  473. #endif
  474. //#define __NR_sethostname 74
  475. #ifdef L_sethostname
  476. #include <unistd.h>
  477. _syscall2(int, sethostname, const char *, name, size_t, len);
  478. #endif
  479. //#define __NR_setrlimit 75
  480. #ifdef L_setrlimit
  481. #include <unistd.h>
  482. #include <sys/resource.h>
  483. _syscall2(int, setrlimit, int, resource, const struct rlimit *, rlim);
  484. #endif
  485. //#define __NR_getrlimit 76
  486. #ifdef L_getrlimit
  487. #include <unistd.h>
  488. #include <sys/resource.h>
  489. _syscall2(int, getrlimit, int, resource, struct rlimit *, rlim);
  490. #endif
  491. //#define __NR_getrusage 77
  492. #ifdef L_getrusage
  493. #include <unistd.h>
  494. #include <wait.h>
  495. _syscall2(int, getrusage, int, who, struct rusage *, usage);
  496. #endif
  497. //#define __NR_gettimeofday 78
  498. #ifdef L_gettimeofday
  499. #include <sys/time.h>
  500. _syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
  501. #endif
  502. //#define __NR_settimeofday 79
  503. #ifdef L_settimeofday
  504. #include <sys/time.h>
  505. _syscall2(int, settimeofday, const struct timeval *, tv,
  506. const struct timezone *, tz);
  507. #endif
  508. //#define __NR_getgroups 80
  509. #ifdef L_getgroups
  510. #include <unistd.h>
  511. _syscall2(int, getgroups, int, size, gid_t *, list);
  512. #endif
  513. //#define __NR_setgroups 81
  514. #ifdef L_setgroups
  515. #include <unistd.h>
  516. #include <grp.h>
  517. _syscall2(int, setgroups, size_t, size, const gid_t *, list);
  518. #endif
  519. //#define __NR_select 82
  520. //#define __NR_symlink 83
  521. #ifdef L_symlink
  522. #include <unistd.h>
  523. _syscall2(int, symlink, const char *, oldpath, const char *, newpath);
  524. #endif
  525. //#define __NR_oldlstat 84
  526. //#define __NR_readlink 85
  527. #ifdef L_readlink
  528. #include <unistd.h>
  529. _syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);
  530. #endif
  531. //#define __NR_uselib 86
  532. #ifdef L_uselib
  533. #include <unistd.h>
  534. _syscall1(int, uselib, const char *, library);
  535. #endif
  536. //#define __NR_swapon 87
  537. #ifdef L_swapon
  538. #include <sys/swap.h>
  539. _syscall2(int, swapon, const char *, path, int, swapflags);
  540. #endif
  541. //#define __NR_reboot 88
  542. #ifdef L__reboot
  543. #define __NR__reboot __NR_reboot
  544. extern int _reboot(int magic, int magic2, int flag);
  545. _syscall3(int, _reboot, int, magic, int, magic2, int, flag);
  546. int reboot(int flag)
  547. {
  548. return (_reboot((int) 0xfee1dead, 672274793, flag));
  549. }
  550. #endif
  551. //#define __NR_readdir 89
  552. //#define __NR_mmap 90
  553. #ifdef L__mmap
  554. #define __NR__mmap __NR_mmap
  555. #include <unistd.h>
  556. #include <sys/mman.h>
  557. extern __ptr_t _mmap(unsigned long *buffer);
  558. _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
  559. __ptr_t mmap(__ptr_t addr, size_t len, int prot,
  560. int flags, int fd, __off_t offset)
  561. {
  562. unsigned long buffer[6];
  563. buffer[0] = (unsigned long) addr;
  564. buffer[1] = (unsigned long) len;
  565. buffer[2] = (unsigned long) prot;
  566. buffer[3] = (unsigned long) flags;
  567. buffer[4] = (unsigned long) fd;
  568. buffer[5] = (unsigned long) offset;
  569. return (__ptr_t) _mmap(buffer);
  570. }
  571. #endif
  572. //#define __NR_munmap 91
  573. #ifdef L_munmap
  574. #include <unistd.h>
  575. #include <sys/mman.h>
  576. _syscall2(int, munmap, void *, start, size_t, length);
  577. #endif
  578. //#define __NR_truncate 92
  579. #ifdef L_truncate
  580. #include <unistd.h>
  581. _syscall2(int, truncate, const char *, path, off_t, length);
  582. #endif
  583. //#define __NR_ftruncate 93
  584. #ifdef L_ftruncate
  585. #include <unistd.h>
  586. _syscall2(int, ftruncate, int, fd, off_t, length);
  587. #endif
  588. //#define __NR_fchmod 94
  589. #ifdef L_fchmod
  590. #include <sys/stat.h>
  591. _syscall2(int, fchmod, int, fildes, mode_t, mode);
  592. #endif
  593. //#define __NR_fchown 95
  594. #ifdef L_fchown
  595. #include <unistd.h>
  596. _syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group);
  597. #endif
  598. //#define __NR_getpriority 96
  599. #ifdef L_getpriority
  600. #include <sys/resource.h>
  601. _syscall2(int, getpriority, __priority_which_t, which, id_t, who);
  602. #endif
  603. //#define __NR_setpriority 97
  604. #ifdef L_setpriority
  605. #include <sys/resource.h>
  606. _syscall3(int, setpriority, __priority_which_t, which, id_t, who, int, prio);
  607. #endif
  608. //#define __NR_profil 98
  609. //#define __NR_statfs 99
  610. #ifdef L_statfs
  611. #include <sys/vfs.h>
  612. _syscall2(int, statfs, const char *, path, struct statfs *, buf);
  613. #endif
  614. //#define __NR_fstatfs 100
  615. #ifdef L_fstatfs
  616. #include <sys/vfs.h>
  617. _syscall2(int, fstatfs, int, fd, struct statfs *, buf);
  618. #endif
  619. //#define __NR_ioperm 101
  620. #ifdef L_ioperm
  621. # if defined __UCLIBC_HAS_MMU__ && defined __NR_ioperm
  622. _syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
  623. # else
  624. int ioperm(unsigned long from, unsigned long num, int turn_on)
  625. {
  626. __set_errno(ENOSYS);
  627. return -1;
  628. }
  629. # endif
  630. #endif
  631. //#define __NR_socketcall 102
  632. #ifdef L_socketcall
  633. _syscall2(int, socketcall, int, call, unsigned long *, args);
  634. #endif
  635. //#define __NR_syslog 103
  636. #ifdef L__syslog
  637. #include <unistd.h>
  638. #define __NR__syslog __NR_syslog
  639. extern int _syslog(int type, char *buf, int len);
  640. _syscall3(int, _syslog, int, type, char *, buf, int, len);
  641. int klogctl(int type, char *buf, int len)
  642. {
  643. return (_syslog(type, buf, len));
  644. }
  645. #endif
  646. //#define __NR_setitimer 104
  647. #ifdef L_setitimer
  648. #include <sys/time.h>
  649. _syscall3(int, setitimer, __itimer_which_t, which,
  650. const struct itimerval *, new, struct itimerval *, old);
  651. #endif
  652. //#define __NR_getitimer 105
  653. #ifdef L_getitimer
  654. #include <sys/time.h>
  655. _syscall2(int, getitimer, __itimer_which_t, which, struct itimerval *, value);
  656. #endif
  657. //#define __NR_stat 106
  658. #ifdef L___stat
  659. #include <unistd.h>
  660. #include "statfix.h"
  661. #define __NR___stat __NR_stat
  662. extern int __stat(const char *file_name, struct kernel_stat *buf);
  663. _syscall2(int, __stat, const char *, file_name, struct kernel_stat *, buf);
  664. int __xstat(int version, const char * file_name, struct libc_stat * cstat)
  665. {
  666. struct kernel_stat kstat;
  667. int result = __stat(file_name, &kstat);
  668. if (result == 0) {
  669. statfix(cstat, &kstat);
  670. }
  671. return result;
  672. }
  673. int stat(const char *file_name, struct libc_stat *buf)
  674. {
  675. return(__xstat(0, file_name, buf));
  676. }
  677. #endif
  678. //#define __NR_lstat 107
  679. #ifdef L___lstat
  680. #include <unistd.h>
  681. #include "statfix.h"
  682. #define __NR___lstat __NR_lstat
  683. extern int __lstat(const char *file_name, struct kernel_stat *buf);
  684. _syscall2(int, __lstat, const char *, file_name, struct kernel_stat *, buf);
  685. int __lxstat(int version, const char * file_name, struct libc_stat * cstat)
  686. {
  687. struct kernel_stat kstat;
  688. int result = __lstat(file_name, &kstat);
  689. if (result == 0) {
  690. statfix(cstat, &kstat);
  691. }
  692. return result;
  693. }
  694. int lstat(const char *file_name, struct libc_stat *buf)
  695. {
  696. return(__lxstat(0, file_name, buf));
  697. }
  698. #endif
  699. //#define __NR_fstat 108
  700. #ifdef L___fstat
  701. #include <unistd.h>
  702. #include "statfix.h"
  703. #define __NR___fstat __NR_fstat
  704. extern int __fstat(int filedes, struct kernel_stat *buf);
  705. _syscall2(int, __fstat, int, filedes, struct kernel_stat *, buf);
  706. int __fxstat(int version, int fd, struct libc_stat * cstat)
  707. {
  708. struct kernel_stat kstat;
  709. int result = __fstat(fd, &kstat);
  710. if (result == 0) {
  711. statfix(cstat, &kstat);
  712. }
  713. return result;
  714. }
  715. int fstat(int filedes, struct libc_stat *buf)
  716. {
  717. return(__fxstat(0, filedes, buf));
  718. }
  719. #endif
  720. //#define __NR_olduname 109
  721. //#define __NR_iopl 110
  722. #ifdef L_iopl
  723. /* Tuns out the m68k unistd.h kernel header is broken */
  724. # if defined __UCLIBC_HAS_MMU__ && defined __NR_iopl && ! defined(__mc68000__)
  725. _syscall1(int, iopl, int, level);
  726. # else
  727. int iopl(int level)
  728. {
  729. __set_errno(ENOSYS);
  730. return -1;
  731. }
  732. # endif
  733. #endif
  734. //#define __NR_vhangup 111
  735. #ifdef L_vhangup
  736. #include <unistd.h>
  737. _syscall0(int, vhangup);
  738. #endif
  739. //#define __NR_idle 112
  740. //int idle(void);
  741. //#define __NR_vm86old 113
  742. //#define __NR_wait4 114
  743. #ifdef L_wait4
  744. _syscall4(int, wait4, pid_t, pid, int *, status, int, opts, void *, rusage);
  745. #endif
  746. //#define __NR_swapoff 115
  747. #ifdef L_swapoff
  748. #include <sys/swap.h>
  749. _syscall1(int, swapoff, const char *, path);
  750. #endif
  751. //#define __NR_sysinfo 116
  752. #ifdef L_sysinfo
  753. #include <sys/sysinfo.h>
  754. _syscall1(int, sysinfo, struct sysinfo *, info);
  755. #endif
  756. //#define __NR_ipc 117
  757. #ifdef L___ipc
  758. #define __NR___ipc __NR_ipc
  759. _syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
  760. #endif
  761. //#define __NR_fsync 118
  762. #ifdef L___libc_fsync
  763. #include <unistd.h>
  764. #define __NR___libc_fsync __NR_fsync
  765. _syscall1(int, __libc_fsync, int, fd);
  766. weak_alias(__libc_fsync, fsync)
  767. #endif
  768. //#define __NR_sigreturn 119
  769. //int sigreturn(unsigned long __unused);
  770. //#define __NR_clone 120
  771. //See architecture specific implementation...
  772. //#define __NR_setdomainname 121
  773. #ifdef L_setdomainname
  774. #include <unistd.h>
  775. _syscall2(int, setdomainname, const char *, name, size_t, len);
  776. #endif
  777. //#define __NR_uname 122
  778. #ifdef L_uname
  779. #include <sys/utsname.h>
  780. _syscall1(int, uname, struct utsname *, buf);
  781. #endif
  782. //#define __NR_modify_ldt 123
  783. //#define __NR_adjtimex 124
  784. #ifdef L_adjtimex
  785. #include <sys/timex.h>
  786. _syscall1(int, adjtimex, struct timex *, buf);
  787. weak_alias(adjtimex, __adjtimex);
  788. #endif
  789. //#define __NR_mprotect 125
  790. #ifdef L_mprotect
  791. #include <sys/mman.h>
  792. _syscall3(int, mprotect, void *, addr, size_t, len, int, prot);
  793. #endif
  794. //#define __NR_sigprocmask 126
  795. #ifndef __NR_rt_sigprocmask
  796. #ifdef L_sigprocmask
  797. #include <signal.h>
  798. #undef sigprocmask
  799. _syscall3(int, sigprocmask, int, how, const sigset_t *, set,
  800. sigset_t *, oldset);
  801. #endif
  802. #endif
  803. //#define __NR_create_module 127
  804. //See sysdeps/linux/commom/create_module.c
  805. //#define __NR_init_module 128
  806. #ifdef L_init_module
  807. /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
  808. * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
  809. * and let the kernel cope with whatever it gets. It's good at that. */
  810. _syscall5(int, init_module, void *, first, void *, second, void *, third,
  811. void *, fourth, void *, fifth);
  812. #endif
  813. //#define __NR_delete_module 129
  814. #ifdef L_delete_module
  815. # ifdef __NR_delete_module
  816. _syscall1(int, delete_module, const char *, name);
  817. # else
  818. int delete_module(const char * name)
  819. {
  820. __set_errno(ENOSYS);
  821. return -1;
  822. }
  823. # endif
  824. #endif
  825. //#define __NR_get_kernel_syms 130
  826. #ifdef L_get_kernel_syms
  827. struct kernel_sym;
  828. _syscall1(int, get_kernel_syms, struct kernel_sym *, table);
  829. #endif
  830. //#define __NR_quotactl 131
  831. #ifdef __NR_quotactl
  832. #ifdef L_quotactl
  833. #include <sys/quota.h>
  834. _syscall4(int, quotactl, int, cmd, const char *, special , int, id, caddr_t, addr);
  835. #endif
  836. #endif
  837. //#define __NR_getpgid 132
  838. #ifdef L_getpgid
  839. _syscall1(pid_t, getpgid, pid_t, pid);
  840. #endif
  841. //#define __NR_fchdir 133
  842. #ifdef L_fchdir
  843. #include <unistd.h>
  844. _syscall1(int, fchdir, int, fd);
  845. #endif
  846. //#define __NR_bdflush 134
  847. #ifdef L_bdflush
  848. #include <sys/kdaemon.h>
  849. _syscall2(int, bdflush, int, __func, long int, __data);
  850. #endif
  851. //#define __NR_sysfs 135
  852. //#define __NR_personality 136
  853. //#define __NR_afs_syscall 137
  854. //#define __NR_setfsuid 138
  855. #ifdef __NR_setfsuid
  856. #ifdef L_setfsuid
  857. #include <sys/fsuid.h>
  858. _syscall1(int, setfsuid, uid_t, uid);
  859. #endif
  860. #endif
  861. //#define __NR_setfsgid 139
  862. #ifdef __NR_setfsgid
  863. #ifdef L_setfsgid
  864. #include <sys/fsuid.h>
  865. _syscall1(int, setfsgid, gid_t, gid);
  866. #endif
  867. #endif
  868. //#define __NR__llseek 140
  869. #ifdef L__llseek
  870. #ifdef __UCLIBC_HAVE_LFS__
  871. extern int _llseek(int fd, off_t offset_hi, off_t offset_lo,
  872. loff_t *result, int whence);
  873. _syscall5(int, _llseek, int, fd, off_t, offset_hi, off_t, offset_lo,
  874. loff_t *, result, int, whence);
  875. loff_t __libc_lseek64(int fd, loff_t offset, int whence)
  876. {
  877. int ret;
  878. loff_t result;
  879. ret = _llseek(fd, (off_t) (offset >> 32),
  880. (off_t) (offset & 0xffffffff), &result, whence);
  881. return ret ? (loff_t) ret : result;
  882. }
  883. weak_alias(__libc_lseek64, llseek);
  884. weak_alias(__libc_lseek64, lseek64);
  885. #endif
  886. #endif
  887. //#define __NR_getdents 141
  888. #ifdef L_getdents
  889. #include <unistd.h>
  890. #include <dirent.h>
  891. _syscall3(int, getdents, int, fd, char *, dirp, size_t, count);
  892. #endif
  893. //#define __NR__newselect 142
  894. #ifdef L__newselect
  895. #include <unistd.h>
  896. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  897. fd_set *exceptfds, struct timeval *timeout);
  898. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  899. fd_set *, exceptfds, struct timeval *, timeout);
  900. weak_alias(_newselect, select);
  901. #endif
  902. //#define __NR_flock 143
  903. #ifdef L_flock
  904. #include <sys/file.h>
  905. _syscall2(int,flock,int,fd, int,operation);
  906. #endif
  907. //#define __NR_msync 144
  908. #ifdef L___libc_msync
  909. #include <unistd.h>
  910. #include <sys/mman.h>
  911. #define __NR___libc_msync __NR_msync
  912. _syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags);
  913. weak_alias(__libc_msync, msync);
  914. #endif
  915. //#define __NR_readv 145
  916. #ifdef L_readv
  917. #include <sys/uio.h>
  918. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  919. count);
  920. #endif
  921. //#define __NR_writev 146
  922. #ifdef L_writev
  923. #include <sys/uio.h>
  924. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  925. count);
  926. #endif
  927. //#define __NR_getsid 147
  928. #ifdef L_getsid
  929. #include <unistd.h>
  930. _syscall1(pid_t, getsid, pid_t, pid);
  931. #endif
  932. //#define __NR_fdatasync 148
  933. #ifdef __NR_fdatasync
  934. #ifdef L_fdatasync
  935. #include <unistd.h>
  936. _syscall1(int, fdatasync, int, fd);
  937. #endif
  938. #endif
  939. //#define __NR__sysctl 149
  940. //#define __NR_mlock 150
  941. #ifdef L_mlock
  942. #include <sys/mman.h>
  943. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlock
  944. _syscall2(int, mlock, const void *, addr, size_t, len);
  945. # endif
  946. #endif
  947. //#define __NR_munlock 151
  948. #ifdef L_munlock
  949. #include <sys/mman.h>
  950. # if defined __UCLIBC_HAS_MMU__ && defined __NR_munlock
  951. _syscall2(int, munlock, const void *, addr, size_t, len);
  952. # endif
  953. #endif
  954. //#define __NR_mlockall 152
  955. #ifdef L_mlockall
  956. #include <sys/mman.h>
  957. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlockall
  958. _syscall1(int, mlockall, int, flags);
  959. # endif
  960. #endif
  961. //#define __NR_munlockall 153
  962. #ifdef L_munlockall
  963. #include <sys/mman.h>
  964. # if defined __UCLIBC_HAS_MMU__ && defined L_munlockall
  965. _syscall0(int, munlockall);
  966. # endif
  967. #endif
  968. //#define __NR_sched_setparam 154
  969. #ifdef __NR_sched_setparam
  970. #ifdef L_sched_setparam
  971. #include <sched.h>
  972. _syscall2(int, sched_setparam, pid_t, pid, const struct sched_param *, p);
  973. #endif
  974. #endif
  975. //#define __NR_sched_getparam 155
  976. #ifdef __NR_sched_getparam
  977. #ifdef L_sched_getparam
  978. #include <sched.h>
  979. _syscall2(int, sched_getparam, pid_t, pid, struct sched_param *, p);
  980. #endif
  981. #endif
  982. //#define __NR_sched_setscheduler 156
  983. #ifdef __NR_sched_setscheduler
  984. #ifdef L_sched_setscheduler
  985. #include <sched.h>
  986. _syscall3(int, sched_setscheduler, pid_t, pid, int, policy, const struct sched_param *, p);
  987. #endif
  988. #endif
  989. //#define __NR_sched_getscheduler 157
  990. #ifdef __NR_sched_getscheduler
  991. #ifdef L_sched_getscheduler
  992. #include <sched.h>
  993. _syscall1(int, sched_getscheduler, pid_t, pid);
  994. #endif
  995. #endif
  996. //#define __NR_sched_yield 158
  997. #ifdef __NR_sched_yield
  998. #ifdef L_sched_yield
  999. #include <sched.h>
  1000. _syscall0(int, sched_yield);
  1001. #endif
  1002. #endif
  1003. //#define __NR_sched_get_priority_max 159
  1004. #ifdef __NR_sched_get_priority_max
  1005. #ifdef L_sched_get_priority_max
  1006. #include <sched.h>
  1007. _syscall1(int, sched_get_priority_max, int, policy);
  1008. #endif
  1009. #endif
  1010. //#define __NR_sched_get_priority_min 160
  1011. #ifdef __NR_sched_get_priority_min
  1012. #ifdef L_sched_get_priority_min
  1013. #include <sched.h>
  1014. _syscall1(int, sched_get_priority_min, int, policy);
  1015. #endif
  1016. #endif
  1017. //#define __NR_sched_rr_get_interval 161
  1018. #ifdef __NR_sched_rr_get_interval
  1019. #ifdef L_sched_rr_get_interval
  1020. #include <sched.h>
  1021. _syscall2(int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp);
  1022. #endif
  1023. #endif
  1024. //#define __NR_nanosleep 162
  1025. #ifdef L___libc_nanosleep
  1026. #include <time.h>
  1027. #define __NR___libc_nanosleep __NR_nanosleep
  1028. _syscall2(int, __libc_nanosleep, const struct timespec *, req, struct timespec *, rem);
  1029. weak_alias(__libc_nanosleep, nanosleep)
  1030. #endif
  1031. //#define __NR_mremap 163
  1032. #ifdef L_mremap
  1033. #include <unistd.h>
  1034. #include <sys/mman.h>
  1035. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t, new_size, int, may_move);
  1036. #endif
  1037. //#define __NR_setresuid 164
  1038. //#define __NR_getresuid 165
  1039. //#define __NR_vm86 166
  1040. //#define __NR_query_module 167
  1041. #ifdef L_query_module
  1042. # ifdef __NR_query_module
  1043. _syscall5(int, query_module, const char *, name, int, which,
  1044. void *, buf, size_t, bufsize, size_t*, ret);
  1045. # else
  1046. int query_module(const char * name, int which,
  1047. void * buf, size_t bufsize, size_t* ret)
  1048. {
  1049. __set_errno(ENOSYS);
  1050. return -1;
  1051. }
  1052. # endif
  1053. #endif
  1054. //#define __NR_poll 168
  1055. #if defined(L_poll) && defined(__NR_poll) /* uClinux 2.0 doesn't have poll */
  1056. #include <sys/poll.h>
  1057. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  1058. #endif
  1059. //#define __NR_nfsservctl 169
  1060. //nfsservctl EXTRA nfsservctl i:ipp nfsservctl
  1061. //#define __NR_setresgid 170
  1062. //#define __NR_getresgid 171
  1063. //#define __NR_prctl 172
  1064. //#define __NR_rt_sigreturn 173
  1065. //#define __NR_rt_sigaction 174
  1066. #ifdef __NR_rt_sigaction
  1067. #define __NR___rt_sigaction __NR_rt_sigaction
  1068. #ifdef L___rt_sigaction
  1069. #include <signal.h>
  1070. #undef sigaction
  1071. _syscall4(int, __rt_sigaction, int, signum, const struct sigaction *, act,
  1072. struct sigaction *, oldact, size_t, size);
  1073. #endif
  1074. #endif
  1075. //#define __NR_rt_sigprocmask 175
  1076. #ifdef __NR_rt_sigprocmask
  1077. #define __NR___rt_sigprocmask __NR_rt_sigprocmask
  1078. #ifdef L___rt_sigprocmask
  1079. #include <signal.h>
  1080. #undef sigprocmask
  1081. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  1082. sigset_t *, oldset, size_t, size);
  1083. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
  1084. {
  1085. return __rt_sigprocmask(how, set, oldset, _NSIG/8);
  1086. }
  1087. #endif
  1088. #endif
  1089. //#define __NR_rt_sigpending 176
  1090. #ifdef __NR_rt_sigpending
  1091. #define __NR___rt_sigpending __NR_rt_sigpending
  1092. #ifdef L___rt_sigpending
  1093. #include <signal.h>
  1094. #undef sigpending
  1095. _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size);
  1096. int sigpending(sigset_t *set)
  1097. {
  1098. return __rt_sigpending(set, _NSIG/8);
  1099. }
  1100. #endif
  1101. #endif
  1102. //#define __NR_rt_sigtimedwait 177
  1103. //#define __NR_rt_sigqueueinfo 178
  1104. //#define __NR_rt_sigsuspend 179
  1105. #ifdef __NR_rt_sigsuspend
  1106. #define __NR___rt_sigsuspend __NR_rt_sigsuspend
  1107. #ifdef L___rt_sigsuspend
  1108. #include <signal.h>
  1109. #undef _sigsuspend
  1110. _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
  1111. int sigsuspend (const sigset_t *mask)
  1112. {
  1113. return __rt_sigsuspend(mask, _NSIG/8);
  1114. }
  1115. #endif
  1116. #endif
  1117. //#define __NR_pread 180
  1118. #ifdef L___libc_pread
  1119. #define _XOPEN_SOURCE 500
  1120. #include <unistd.h>
  1121. #define __NR___libc_pread __NR_pread
  1122. _syscall4(ssize_t, __libc_pread, int, fd, void *, buf, size_t, count, off_t, offset);
  1123. weak_alias (__libc_pread, pread)
  1124. #endif
  1125. //#define __NR_pwrite 181
  1126. #ifdef L___libc_pwrite
  1127. #define _XOPEN_SOURCE 500
  1128. #include <unistd.h>
  1129. #define __NR___libc_pwrite __NR_pwrite
  1130. _syscall4(ssize_t, __libc_pwrite, int, fd, const void *, buf, size_t, count, off_t, offset);
  1131. weak_alias (__libc_pwrite, pwrite)
  1132. #endif
  1133. //#define __NR_chown 182
  1134. #ifdef L_chown
  1135. #include <unistd.h>
  1136. _syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
  1137. #endif
  1138. //#define __NR_getcwd 183
  1139. // See unistd/getcwd.c -- we don't use this syscall, even when it is available...
  1140. //#define __NR_capget 184
  1141. #ifdef L_capget
  1142. # ifdef __NR_capget
  1143. _syscall2(int, capget, void*, header, void*, data);
  1144. # else
  1145. int capget(void* header, void* data)
  1146. {
  1147. __set_errno(ENOSYS);
  1148. return -1;
  1149. }
  1150. # endif
  1151. #endif
  1152. //#define __NR_capset 185
  1153. #ifdef L_capset
  1154. # ifdef __NR_capset
  1155. _syscall2(int, capset, void*, header, const void*, data);
  1156. # else
  1157. int capset(void* header, const void* data)
  1158. {
  1159. __set_errno(ENOSYS);
  1160. return -1;
  1161. }
  1162. # endif
  1163. #endif
  1164. //#define __NR_sigaltstack 186
  1165. #ifdef __NR_sigaltstack
  1166. #ifdef L_sigaltstack
  1167. #include <signal.h>
  1168. _syscall2(int, sigaltstack, const struct sigaltstack *, ss, struct sigaltstack *, oss);
  1169. #endif
  1170. #endif
  1171. //#define __NR_sendfile 187
  1172. #ifdef __NR_sendfile
  1173. #ifdef L_sendfile
  1174. #include <unistd.h>
  1175. #include <sys/sendfile.h>
  1176. _syscall4(ssize_t,sendfile, int, out_fd, int, in_fd, off_t *, offset, size_t, count)
  1177. #endif
  1178. #endif
  1179. //#define __NR_getpmsg 188
  1180. //#define __NR_putpmsg 189
  1181. //#define __NR_vfork 190
  1182. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...
  1183. //#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
  1184. //#define __NR_mmap2 192
  1185. //#define __NR_truncate64 193
  1186. #ifdef L_truncate64
  1187. #ifdef __UCLIBC_HAVE_LFS__
  1188. #include <bits/wordsize.h>
  1189. /* Using _syscall2 to pass 64-bit arguments generally only works on 64-bit
  1190. * systems, so we only implement truncate64/ftruncate64 in that case. Ports
  1191. * for processors with shorter word-lengths should define their own custom
  1192. * versions instead. */
  1193. #if __WORDSIZE >= 64
  1194. #include <unistd.h>
  1195. _syscall2(int, truncate64, const char *, path, __off64_t, length);
  1196. #endif /* __WORDSIZE >= 64 */
  1197. #endif /* __UCLIBC_HAVE_LFS__ */
  1198. #endif
  1199. //#define __NR_ftruncate64 194
  1200. #ifdef L_ftruncate64
  1201. #ifdef __UCLIBC_HAVE_LFS__
  1202. #include <bits/wordsize.h>
  1203. /* Using _syscall2 to pass 64-bit arguments generally only works on 64-bit
  1204. * systems, so we only implement truncate64/ftruncate64 in that case. Ports
  1205. * for processors with shorter word-lengths should define their own custom
  1206. * versions instead. */
  1207. #if __WORDSIZE >= 64
  1208. #include <unistd.h>
  1209. _syscall2(int, ftruncate64, int, fd, __off64_t, length);
  1210. #endif /* __WORDSIZE >= 64 */
  1211. #endif /* __UCLIBC_HAVE_LFS__ */
  1212. #endif
  1213. //#define __NR_stat64 195
  1214. #ifdef L___stat64
  1215. #ifdef __UCLIBC_HAVE_LFS__
  1216. #include <unistd.h>
  1217. #include "statfix64.h"
  1218. #define __NR___stat64 __NR_stat64
  1219. extern int __stat64(const char *file_name, struct kernel_stat64 *buf);
  1220. _syscall2(int, __stat64, const char *, file_name, struct kernel_stat64 *, buf);
  1221. int __xstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1222. {
  1223. struct kernel_stat64 kstat;
  1224. int result = __stat64(file_name, &kstat);
  1225. if (result == 0) {
  1226. statfix64(cstat, &kstat);
  1227. }
  1228. return result;
  1229. }
  1230. int stat64(const char *file_name, struct libc_stat64 *buf)
  1231. {
  1232. return(__xstat64(0, file_name, buf));
  1233. }
  1234. #endif /* __UCLIBC_HAVE_LFS__ */
  1235. #endif
  1236. //#define __NR_lstat64 196
  1237. #ifdef L___lstat64
  1238. #ifdef __UCLIBC_HAVE_LFS__
  1239. #include <unistd.h>
  1240. #include "statfix64.h"
  1241. #define __NR___lstat64 __NR_lstat64
  1242. extern int __lstat64(const char *file_name, struct kernel_stat64 *buf);
  1243. _syscall2(int, __lstat64, const char *, file_name, struct kernel_stat64 *, buf);
  1244. int __lxstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1245. {
  1246. struct kernel_stat64 kstat;
  1247. int result = __lstat64(file_name, &kstat);
  1248. if (result == 0) {
  1249. statfix64(cstat, &kstat);
  1250. }
  1251. return result;
  1252. }
  1253. int lstat64(const char *file_name, struct libc_stat64 *buf)
  1254. {
  1255. return(__lxstat64(0, file_name, buf));
  1256. }
  1257. #endif /* __UCLIBC_HAVE_LFS__ */
  1258. #endif
  1259. //#define __NR_fstat64 197
  1260. #ifdef L___fstat64
  1261. #ifdef __UCLIBC_HAVE_LFS__
  1262. #include <unistd.h>
  1263. #include "statfix64.h"
  1264. #define __NR___fstat64 __NR_fstat64
  1265. extern int __fstat64(int filedes, struct kernel_stat64 *buf);
  1266. _syscall2(int, __fstat64, int, filedes, struct kernel_stat64 *, buf);
  1267. int __fxstat64(int version, int fd, struct libc_stat64 * cstat)
  1268. {
  1269. struct kernel_stat64 kstat;
  1270. int result = __fstat64(fd, &kstat);
  1271. if (result == 0) {
  1272. statfix64(cstat, &kstat);
  1273. }
  1274. return result;
  1275. }
  1276. int fstat64(int filedes, struct libc_stat64 *buf)
  1277. {
  1278. return(__fxstat64(0, filedes, buf));
  1279. }
  1280. #endif /* __UCLIBC_HAVE_LFS__ */
  1281. #endif
  1282. //#define __NR_lchown32 198
  1283. //#define __NR_getuid32 199
  1284. //#define __NR_getgid32 200
  1285. //#define __NR_geteuid32 201
  1286. //#define __NR_getegid32 202
  1287. //#define __NR_setreuid32 203
  1288. //#define __NR_setregid32 204
  1289. //#define __NR_getgroups32 205
  1290. //#define __NR_setgroups32 206
  1291. //#define __NR_fchown32 207
  1292. //#define __NR_setresuid32 208
  1293. //#define __NR_getresuid32 209
  1294. //#define __NR_setresgid32 210
  1295. //#define __NR_getresgid32 211
  1296. //#define __NR_chown32 212
  1297. //#define __NR_setuid32 213
  1298. //#define __NR_setgid32 214
  1299. //#define __NR_setfsuid32 215
  1300. //#define __NR_setfsgid32 216
  1301. //#define __NR_pivot_root 217
  1302. #ifdef __NR_pivot_root
  1303. #ifdef L_pivot_root
  1304. _syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
  1305. #endif
  1306. #endif
  1307. //#define __NR_mincore 218
  1308. //#define __NR_madvise 219
  1309. //#define __NR_madvise1 219 /* delete when C lib stub is removed */
  1310. //#define __NR_getdents64 220
  1311. #ifdef L_getdents64
  1312. #ifdef __UCLIBC_HAVE_LFS__
  1313. #include <unistd.h>
  1314. #include <dirent.h>
  1315. _syscall3(int, getdents64, int, fd, char *, dirp, size_t, count);
  1316. #endif /* __UCLIBC_HAVE_LFS__ */
  1317. #endif
  1318. //#define __NR_fcntl64 221
  1319. #ifdef L__fcntl64
  1320. #ifdef __UCLIBC_HAVE_LFS__
  1321. #define __NR__fcntl64 __NR_fcntl64
  1322. #include <stdarg.h>
  1323. #include <fcntl.h>
  1324. extern int _fcntl64(int fd, int cmd, long arg);
  1325. _syscall3(int, _fcntl64, int, fd, int, cmd, long, arg);
  1326. int fcntl64(int fd, int command, ...)
  1327. {
  1328. long arg;
  1329. va_list list;
  1330. va_start(list, command);
  1331. arg = va_arg(list, long);
  1332. va_end(list);
  1333. return _fcntl64(fd, command, arg);
  1334. }
  1335. #endif
  1336. #endif
  1337. //#define __NR_security 223 /* syscall for security modules */
  1338. //#define __NR_gettid 224
  1339. //#define __NR_readahead 225