syscalls.c 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Syscalls for uClibc
  4. *
  5. * Copyright (C) 2000 by Lineo, inc
  6. * Copyright (C) 2001, 2002 by Erik Andersen
  7. * Written by Erik Andersen <andersen@codpoet.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Library General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
  17. * for more details.
  18. *
  19. * You should have received a copy of the GNU Library General Public License
  20. * along with this program; if not, write to the Free Software Foundation,
  21. * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #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(uid_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. #ifndef __NR_ugetrlimit
  481. /* Only wrap setrlimit if the new ugetrlimit is not present */
  482. #ifdef L___setrlimit
  483. #define __NR___setrlimit __NR_setrlimit
  484. #include <unistd.h>
  485. #include <sys/resource.h>
  486. #define RMIN(x, y) ((x) < (y) ? (x) : (y))
  487. _syscall2(int, __setrlimit, int, resource, const struct rlimit *, rlim);
  488. int setrlimit (__rlimit_resource_t resource, const struct rlimit *rlimits)
  489. {
  490. struct rlimit rlimits_small;
  491. /* We might have to correct the limits values. Since the old values
  492. * were signed the new values might be too large. */
  493. rlimits_small.rlim_cur = RMIN ((unsigned long int) rlimits->rlim_cur,
  494. RLIM_INFINITY >> 1);
  495. rlimits_small.rlim_max = RMIN ((unsigned long int) rlimits->rlim_max,
  496. RLIM_INFINITY >> 1);
  497. return(__setrlimit(resource, &rlimits_small));
  498. }
  499. #undef RMIN
  500. #endif
  501. #else /* We don't need to wrap setrlimit */
  502. #ifdef L_setrlimit
  503. #include <unistd.h>
  504. #include <sys/resource.h>
  505. _syscall2(int, setrlimit, int, resource, const struct rlimit *, rlim);
  506. #endif
  507. #endif /* __NR_setrlimit */
  508. //#define __NR_getrlimit 76
  509. #ifdef L___getrlimit
  510. /* Only include the old getrlimit if the new one (ugetrlimit) is not around */
  511. #ifndef __NR_ugetrlimit
  512. #define __NR___getrlimit __NR_getrlimit
  513. #include <unistd.h>
  514. #include <sys/resource.h>
  515. _syscall2(int, __getrlimit, int, resource, struct rlimit *, rlim);
  516. int getrlimit (__rlimit_resource_t resource, struct rlimit *rlimits)
  517. {
  518. int result;
  519. result = __getrlimit(resource, rlimits);
  520. if (result == -1)
  521. return result;
  522. /* We might have to correct the limits values. Since the old values
  523. * were signed the infinity value is too small. */
  524. if (rlimits->rlim_cur == RLIM_INFINITY >> 1)
  525. rlimits->rlim_cur = RLIM_INFINITY;
  526. if (rlimits->rlim_max == RLIM_INFINITY >> 1)
  527. rlimits->rlim_max = RLIM_INFINITY;
  528. return result;
  529. }
  530. #endif
  531. #endif /* __NR_getrlimit */
  532. //#define __NR_getrusage 77
  533. #ifdef L_getrusage
  534. #include <unistd.h>
  535. #include <wait.h>
  536. _syscall2(int, getrusage, int, who, struct rusage *, usage);
  537. #endif
  538. //#define __NR_gettimeofday 78
  539. #ifdef L_gettimeofday
  540. #include <sys/time.h>
  541. _syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);
  542. #endif
  543. //#define __NR_settimeofday 79
  544. #ifdef L_settimeofday
  545. #include <sys/time.h>
  546. _syscall2(int, settimeofday, const struct timeval *, tv,
  547. const struct timezone *, tz);
  548. #endif
  549. //#define __NR_getgroups 80
  550. #ifdef L_getgroups
  551. #include <unistd.h>
  552. _syscall2(int, getgroups, int, size, gid_t *, list);
  553. #endif
  554. //#define __NR_setgroups 81
  555. #ifdef L_setgroups
  556. #include <unistd.h>
  557. #include <grp.h>
  558. _syscall2(int, setgroups, size_t, size, const gid_t *, list);
  559. #endif
  560. //#define __NR_select 82
  561. //#define __NR_symlink 83
  562. #ifdef L_symlink
  563. #include <unistd.h>
  564. _syscall2(int, symlink, const char *, oldpath, const char *, newpath);
  565. #endif
  566. //#define __NR_oldlstat 84
  567. //#define __NR_readlink 85
  568. #ifdef L_readlink
  569. #include <unistd.h>
  570. _syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);
  571. #endif
  572. //#define __NR_uselib 86
  573. #ifdef L_uselib
  574. #include <unistd.h>
  575. _syscall1(int, uselib, const char *, library);
  576. #endif
  577. //#define __NR_swapon 87
  578. #ifdef L_swapon
  579. #include <sys/swap.h>
  580. _syscall2(int, swapon, const char *, path, int, swapflags);
  581. #endif
  582. //#define __NR_reboot 88
  583. #ifdef L__reboot
  584. #define __NR__reboot __NR_reboot
  585. extern int _reboot(int magic, int magic2, int flag);
  586. _syscall3(int, _reboot, int, magic, int, magic2, int, flag);
  587. int reboot(int flag)
  588. {
  589. return (_reboot((int) 0xfee1dead, 672274793, flag));
  590. }
  591. #endif
  592. //#define __NR_readdir 89
  593. //#define __NR_mmap 90
  594. #ifdef L__mmap
  595. #define __NR__mmap __NR_mmap
  596. #include <unistd.h>
  597. #include <sys/mman.h>
  598. extern __ptr_t _mmap(unsigned long *buffer);
  599. _syscall1(__ptr_t, _mmap, unsigned long *, buffer);
  600. __ptr_t mmap(__ptr_t addr, size_t len, int prot,
  601. int flags, int fd, __off_t offset)
  602. {
  603. unsigned long buffer[6];
  604. buffer[0] = (unsigned long) addr;
  605. buffer[1] = (unsigned long) len;
  606. buffer[2] = (unsigned long) prot;
  607. buffer[3] = (unsigned long) flags;
  608. buffer[4] = (unsigned long) fd;
  609. buffer[5] = (unsigned long) offset;
  610. return (__ptr_t) _mmap(buffer);
  611. }
  612. #endif
  613. //#define __NR_munmap 91
  614. #ifdef L_munmap
  615. #include <unistd.h>
  616. #include <sys/mman.h>
  617. _syscall2(int, munmap, void *, start, size_t, length);
  618. #endif
  619. //#define __NR_truncate 92
  620. #ifdef L_truncate
  621. #include <unistd.h>
  622. _syscall2(int, truncate, const char *, path, __off_t, length);
  623. #endif
  624. //#define __NR_ftruncate 93
  625. #ifdef L_ftruncate
  626. #include <unistd.h>
  627. _syscall2(int, ftruncate, int, fd, __off_t, length);
  628. #endif
  629. //#define __NR_fchmod 94
  630. #ifdef L_fchmod
  631. #include <sys/stat.h>
  632. _syscall2(int, fchmod, int, fildes, mode_t, mode);
  633. #endif
  634. //#define __NR_fchown 95
  635. #ifdef L_fchown
  636. #include <unistd.h>
  637. _syscall3(int, fchown, int, fd, uid_t, owner, gid_t, group);
  638. #endif
  639. //#define __NR_getpriority 96
  640. #ifdef L_getpriority
  641. #include <sys/resource.h>
  642. _syscall2(int, getpriority, __priority_which_t, which, id_t, who);
  643. #endif
  644. //#define __NR_setpriority 97
  645. #ifdef L_setpriority
  646. #include <sys/resource.h>
  647. _syscall3(int, setpriority, __priority_which_t, which, id_t, who, int, prio);
  648. #endif
  649. //#define __NR_profil 98
  650. //#define __NR_statfs 99
  651. #ifdef L_statfs
  652. #include <sys/vfs.h>
  653. _syscall2(int, statfs, const char *, path, struct statfs *, buf);
  654. #endif
  655. //#define __NR_fstatfs 100
  656. #ifdef L_fstatfs
  657. #include <sys/vfs.h>
  658. _syscall2(int, fstatfs, int, fd, struct statfs *, buf);
  659. #endif
  660. //#define __NR_ioperm 101
  661. #ifdef L_ioperm
  662. # if defined __UCLIBC_HAS_MMU__ && defined __NR_ioperm
  663. _syscall3(int, ioperm, unsigned long, from, unsigned long, num, int, turn_on);
  664. # else
  665. int ioperm(unsigned long from, unsigned long num, int turn_on)
  666. {
  667. __set_errno(ENOSYS);
  668. return -1;
  669. }
  670. # endif
  671. #endif
  672. //#define __NR_socketcall 102
  673. #ifdef L_socketcall
  674. _syscall2(int, socketcall, int, call, unsigned long *, args);
  675. #endif
  676. //#define __NR_syslog 103
  677. #ifdef L__syslog
  678. #include <unistd.h>
  679. #define __NR__syslog __NR_syslog
  680. extern int _syslog(int type, char *buf, int len);
  681. _syscall3(int, _syslog, int, type, char *, buf, int, len);
  682. int klogctl(int type, char *buf, int len)
  683. {
  684. return (_syslog(type, buf, len));
  685. }
  686. #endif
  687. //#define __NR_setitimer 104
  688. #ifdef L_setitimer
  689. #include <sys/time.h>
  690. _syscall3(int, setitimer, __itimer_which_t, which,
  691. const struct itimerval *, new, struct itimerval *, old);
  692. #endif
  693. //#define __NR_getitimer 105
  694. #ifdef L_getitimer
  695. #include <sys/time.h>
  696. _syscall2(int, getitimer, __itimer_which_t, which, struct itimerval *, value);
  697. #endif
  698. //#define __NR_stat 106
  699. #ifdef L___stat
  700. #include <unistd.h>
  701. #include "statfix.h"
  702. #define __NR___stat __NR_stat
  703. extern int __stat(const char *file_name, struct kernel_stat *buf);
  704. _syscall2(int, __stat, const char *, file_name, struct kernel_stat *, buf);
  705. int __xstat(int version, const char * file_name, struct libc_stat * cstat)
  706. {
  707. struct kernel_stat kstat;
  708. int result = __stat(file_name, &kstat);
  709. if (result == 0) {
  710. statfix(cstat, &kstat);
  711. }
  712. return result;
  713. }
  714. int stat(const char *file_name, struct libc_stat *buf)
  715. {
  716. return(__xstat(0, file_name, buf));
  717. }
  718. #endif
  719. //#define __NR_lstat 107
  720. #ifdef L___lstat
  721. #include <unistd.h>
  722. #include "statfix.h"
  723. #define __NR___lstat __NR_lstat
  724. extern int __lstat(const char *file_name, struct kernel_stat *buf);
  725. _syscall2(int, __lstat, const char *, file_name, struct kernel_stat *, buf);
  726. int __lxstat(int version, const char * file_name, struct libc_stat * cstat)
  727. {
  728. struct kernel_stat kstat;
  729. int result = __lstat(file_name, &kstat);
  730. if (result == 0) {
  731. statfix(cstat, &kstat);
  732. }
  733. return result;
  734. }
  735. int lstat(const char *file_name, struct libc_stat *buf)
  736. {
  737. return(__lxstat(0, file_name, buf));
  738. }
  739. #endif
  740. //#define __NR_fstat 108
  741. #ifdef L___fstat
  742. #include <unistd.h>
  743. #include "statfix.h"
  744. #define __NR___fstat __NR_fstat
  745. extern int __fstat(int filedes, struct kernel_stat *buf);
  746. _syscall2(int, __fstat, int, filedes, struct kernel_stat *, buf);
  747. int __fxstat(int version, int fd, struct libc_stat * cstat)
  748. {
  749. struct kernel_stat kstat;
  750. int result = __fstat(fd, &kstat);
  751. if (result == 0) {
  752. statfix(cstat, &kstat);
  753. }
  754. return result;
  755. }
  756. int fstat(int filedes, struct libc_stat *buf)
  757. {
  758. return(__fxstat(0, filedes, buf));
  759. }
  760. #endif
  761. //#define __NR_olduname 109
  762. //#define __NR_iopl 110
  763. #ifdef L_iopl
  764. /* Tuns out the m68k unistd.h kernel header is broken */
  765. # if defined __UCLIBC_HAS_MMU__ && defined __NR_iopl && ! defined(__mc68000__)
  766. _syscall1(int, iopl, int, level);
  767. # else
  768. int iopl(int level)
  769. {
  770. __set_errno(ENOSYS);
  771. return -1;
  772. }
  773. # endif
  774. #endif
  775. //#define __NR_vhangup 111
  776. #ifdef L_vhangup
  777. #include <unistd.h>
  778. _syscall0(int, vhangup);
  779. #endif
  780. //#define __NR_idle 112
  781. //int idle(void);
  782. //#define __NR_vm86old 113
  783. //#define __NR_wait4 114
  784. #ifdef L_wait4
  785. _syscall4(int, wait4, pid_t, pid, int *, status, int, opts, void *, rusage);
  786. #endif
  787. //#define __NR_swapoff 115
  788. #ifdef L_swapoff
  789. #include <sys/swap.h>
  790. _syscall1(int, swapoff, const char *, path);
  791. #endif
  792. //#define __NR_sysinfo 116
  793. #ifdef L_sysinfo
  794. #include <sys/sysinfo.h>
  795. _syscall1(int, sysinfo, struct sysinfo *, info);
  796. #endif
  797. //#define __NR_ipc 117
  798. #ifdef L___ipc
  799. #define __NR___ipc __NR_ipc
  800. _syscall5(int, __ipc, unsigned int, call, int, first, int, second, int, third, void *, ptr);
  801. #endif
  802. //#define __NR_fsync 118
  803. #ifdef L___libc_fsync
  804. #include <unistd.h>
  805. #define __NR___libc_fsync __NR_fsync
  806. _syscall1(int, __libc_fsync, int, fd);
  807. weak_alias(__libc_fsync, fsync)
  808. #endif
  809. //#define __NR_sigreturn 119
  810. //int sigreturn(unsigned long __unused);
  811. //#define __NR_clone 120
  812. //See architecture specific implementation...
  813. //#define __NR_setdomainname 121
  814. #ifdef L_setdomainname
  815. #include <unistd.h>
  816. _syscall2(int, setdomainname, const char *, name, size_t, len);
  817. #endif
  818. //#define __NR_uname 122
  819. #ifdef L_uname
  820. #include <sys/utsname.h>
  821. _syscall1(int, uname, struct utsname *, buf);
  822. #endif
  823. //#define __NR_modify_ldt 123
  824. //#define __NR_adjtimex 124
  825. #ifdef L_adjtimex
  826. #include <sys/timex.h>
  827. _syscall1(int, adjtimex, struct timex *, buf);
  828. weak_alias(adjtimex, __adjtimex);
  829. #endif
  830. //#define __NR_mprotect 125
  831. #ifdef L_mprotect
  832. #include <sys/mman.h>
  833. _syscall3(int, mprotect, void *, addr, size_t, len, int, prot);
  834. #endif
  835. //#define __NR_sigprocmask 126
  836. #ifndef __NR_rt_sigprocmask
  837. #ifdef L_sigprocmask
  838. #include <signal.h>
  839. #undef sigprocmask
  840. _syscall3(int, sigprocmask, int, how, const sigset_t *, set,
  841. sigset_t *, oldset);
  842. #endif
  843. #endif
  844. //#define __NR_create_module 127
  845. //See sysdeps/linux/commom/create_module.c
  846. //#define __NR_init_module 128
  847. #ifdef L_init_module
  848. /* This may have 5 arguments (for old 2.0 kernels) or 2 arguments
  849. * (for 2.2 and 2.4 kernels). Use the greatest common denominator,
  850. * and let the kernel cope with whatever it gets. It's good at that. */
  851. _syscall5(int, init_module, void *, first, void *, second, void *, third,
  852. void *, fourth, void *, fifth);
  853. #endif
  854. //#define __NR_delete_module 129
  855. #ifdef L_delete_module
  856. # ifdef __NR_delete_module
  857. _syscall1(int, delete_module, const char *, name);
  858. # else
  859. int delete_module(const char * name)
  860. {
  861. __set_errno(ENOSYS);
  862. return -1;
  863. }
  864. # endif
  865. #endif
  866. //#define __NR_get_kernel_syms 130
  867. #ifdef L_get_kernel_syms
  868. struct kernel_sym;
  869. _syscall1(int, get_kernel_syms, struct kernel_sym *, table);
  870. #endif
  871. //#define __NR_quotactl 131
  872. #ifdef __NR_quotactl
  873. #ifdef L_quotactl
  874. #include <sys/quota.h>
  875. _syscall4(int, quotactl, int, cmd, const char *, special , int, id, caddr_t, addr);
  876. #endif
  877. #endif
  878. //#define __NR_getpgid 132
  879. #ifdef L_getpgid
  880. _syscall1(pid_t, getpgid, pid_t, pid);
  881. #endif
  882. //#define __NR_fchdir 133
  883. #ifdef L_fchdir
  884. #include <unistd.h>
  885. _syscall1(int, fchdir, int, fd);
  886. #endif
  887. //#define __NR_bdflush 134
  888. #ifdef L_bdflush
  889. #include <sys/kdaemon.h>
  890. _syscall2(int, bdflush, int, __func, long int, __data);
  891. #endif
  892. //#define __NR_sysfs 135
  893. //#define __NR_personality 136
  894. //#define __NR_afs_syscall 137
  895. //#define __NR_setfsuid 138
  896. #ifdef __NR_setfsuid
  897. #ifdef L_setfsuid
  898. #include <sys/fsuid.h>
  899. _syscall1(int, setfsuid, uid_t, uid);
  900. #endif
  901. #endif
  902. //#define __NR_setfsgid 139
  903. #ifdef __NR_setfsgid
  904. #ifdef L_setfsgid
  905. #include <sys/fsuid.h>
  906. _syscall1(int, setfsgid, gid_t, gid);
  907. #endif
  908. #endif
  909. //#define __NR__llseek 140
  910. #ifdef L__llseek
  911. #ifdef __UCLIBC_HAVE_LFS__
  912. extern int _llseek(int fd, __off_t offset_hi, __off_t offset_lo,
  913. __loff_t *result, int whence);
  914. _syscall5(int, _llseek, int, fd, __off_t, offset_hi, __off_t, offset_lo,
  915. __loff_t *, result, int, whence);
  916. __loff_t __libc_lseek64(int fd, __loff_t offset, int whence)
  917. {
  918. int ret;
  919. __loff_t result;
  920. ret = _llseek(fd, (__off_t) (offset >> 32),
  921. (__off_t) (offset & 0xffffffff), &result, whence);
  922. return ret ? (__loff_t) ret : result;
  923. }
  924. weak_alias(__libc_lseek64, llseek);
  925. weak_alias(__libc_lseek64, lseek64);
  926. #endif
  927. #endif
  928. //#define __NR_getdents 141
  929. #ifdef L_getdents
  930. #include <unistd.h>
  931. #include <dirent.h>
  932. _syscall3(int, getdents, int, fd, char *, dirp, size_t, count);
  933. #endif
  934. //#define __NR__newselect 142
  935. #ifdef L__newselect
  936. #include <unistd.h>
  937. extern int _newselect(int n, fd_set *readfds, fd_set *writefds,
  938. fd_set *exceptfds, struct timeval *timeout);
  939. _syscall5(int, _newselect, int, n, fd_set *, readfds, fd_set *, writefds,
  940. fd_set *, exceptfds, struct timeval *, timeout);
  941. weak_alias(_newselect, select);
  942. #endif
  943. //#define __NR_flock 143
  944. #ifdef L_flock
  945. #include <sys/file.h>
  946. _syscall2(int,flock,int,fd, int,operation);
  947. #endif
  948. //#define __NR_msync 144
  949. #ifdef L___libc_msync
  950. #include <unistd.h>
  951. #include <sys/mman.h>
  952. #define __NR___libc_msync __NR_msync
  953. _syscall3(int, __libc_msync, void *, addr, size_t, length, int, flags);
  954. weak_alias(__libc_msync, msync);
  955. #endif
  956. //#define __NR_readv 145
  957. #ifdef L_readv
  958. #include <sys/uio.h>
  959. _syscall3(ssize_t, readv, int, filedes, const struct iovec *, vector, int,
  960. count);
  961. #endif
  962. //#define __NR_writev 146
  963. #ifdef L_writev
  964. #include <sys/uio.h>
  965. _syscall3(ssize_t, writev, int, filedes, const struct iovec *, vector, int,
  966. count);
  967. #endif
  968. //#define __NR_getsid 147
  969. #ifdef L_getsid
  970. #include <unistd.h>
  971. _syscall1(pid_t, getsid, pid_t, pid);
  972. #endif
  973. //#define __NR_fdatasync 148
  974. #ifdef __NR_fdatasync
  975. #ifdef L_fdatasync
  976. #include <unistd.h>
  977. _syscall1(int, fdatasync, int, fd);
  978. #endif
  979. #endif
  980. //#define __NR__sysctl 149
  981. //#define __NR_mlock 150
  982. #ifdef L_mlock
  983. #include <sys/mman.h>
  984. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlock
  985. _syscall2(int, mlock, const void *, addr, size_t, len);
  986. # endif
  987. #endif
  988. //#define __NR_munlock 151
  989. #ifdef L_munlock
  990. #include <sys/mman.h>
  991. # if defined __UCLIBC_HAS_MMU__ && defined __NR_munlock
  992. _syscall2(int, munlock, const void *, addr, size_t, len);
  993. # endif
  994. #endif
  995. //#define __NR_mlockall 152
  996. #ifdef L_mlockall
  997. #include <sys/mman.h>
  998. # if defined __UCLIBC_HAS_MMU__ && defined __NR_mlockall
  999. _syscall1(int, mlockall, int, flags);
  1000. # endif
  1001. #endif
  1002. //#define __NR_munlockall 153
  1003. #ifdef L_munlockall
  1004. #include <sys/mman.h>
  1005. # if defined __UCLIBC_HAS_MMU__ && defined L_munlockall
  1006. _syscall0(int, munlockall);
  1007. # endif
  1008. #endif
  1009. //#define __NR_sched_setparam 154
  1010. #ifdef __NR_sched_setparam
  1011. #ifdef L_sched_setparam
  1012. #include <sched.h>
  1013. _syscall2(int, sched_setparam, pid_t, pid, const struct sched_param *, p);
  1014. #endif
  1015. #endif
  1016. //#define __NR_sched_getparam 155
  1017. #ifdef __NR_sched_getparam
  1018. #ifdef L_sched_getparam
  1019. #include <sched.h>
  1020. _syscall2(int, sched_getparam, pid_t, pid, struct sched_param *, p);
  1021. #endif
  1022. #endif
  1023. //#define __NR_sched_setscheduler 156
  1024. #ifdef __NR_sched_setscheduler
  1025. #ifdef L_sched_setscheduler
  1026. #include <sched.h>
  1027. _syscall3(int, sched_setscheduler, pid_t, pid, int, policy, const struct sched_param *, p);
  1028. #endif
  1029. #endif
  1030. //#define __NR_sched_getscheduler 157
  1031. #ifdef __NR_sched_getscheduler
  1032. #ifdef L_sched_getscheduler
  1033. #include <sched.h>
  1034. _syscall1(int, sched_getscheduler, pid_t, pid);
  1035. #endif
  1036. #endif
  1037. //#define __NR_sched_yield 158
  1038. #ifdef __NR_sched_yield
  1039. #ifdef L_sched_yield
  1040. #include <sched.h>
  1041. _syscall0(int, sched_yield);
  1042. #endif
  1043. #endif
  1044. //#define __NR_sched_get_priority_max 159
  1045. #ifdef __NR_sched_get_priority_max
  1046. #ifdef L_sched_get_priority_max
  1047. #include <sched.h>
  1048. _syscall1(int, sched_get_priority_max, int, policy);
  1049. #endif
  1050. #endif
  1051. //#define __NR_sched_get_priority_min 160
  1052. #ifdef __NR_sched_get_priority_min
  1053. #ifdef L_sched_get_priority_min
  1054. #include <sched.h>
  1055. _syscall1(int, sched_get_priority_min, int, policy);
  1056. #endif
  1057. #endif
  1058. //#define __NR_sched_rr_get_interval 161
  1059. #ifdef __NR_sched_rr_get_interval
  1060. #ifdef L_sched_rr_get_interval
  1061. #include <sched.h>
  1062. _syscall2(int, sched_rr_get_interval, pid_t, pid, struct timespec *, tp);
  1063. #endif
  1064. #endif
  1065. //#define __NR_nanosleep 162
  1066. #ifdef L___libc_nanosleep
  1067. #include <time.h>
  1068. #define __NR___libc_nanosleep __NR_nanosleep
  1069. _syscall2(int, __libc_nanosleep, const struct timespec *, req, struct timespec *, rem);
  1070. weak_alias(__libc_nanosleep, nanosleep)
  1071. #endif
  1072. //#define __NR_mremap 163
  1073. #ifdef L_mremap
  1074. #include <unistd.h>
  1075. #include <sys/mman.h>
  1076. _syscall4(__ptr_t, mremap, __ptr_t, old_address, size_t, old_size, size_t, new_size, int, may_move);
  1077. #endif
  1078. //#define __NR_setresuid 164
  1079. //#define __NR_getresuid 165
  1080. //#define __NR_vm86 166
  1081. //#define __NR_query_module 167
  1082. #ifdef L_query_module
  1083. # ifdef __NR_query_module
  1084. _syscall5(int, query_module, const char *, name, int, which,
  1085. void *, buf, size_t, bufsize, size_t*, ret);
  1086. # else
  1087. int query_module(const char * name, int which,
  1088. void * buf, size_t bufsize, size_t* ret)
  1089. {
  1090. __set_errno(ENOSYS);
  1091. return -1;
  1092. }
  1093. # endif
  1094. #endif
  1095. //#define __NR_poll 168
  1096. #if defined(L_poll) && defined(__NR_poll) /* uClinux 2.0 doesn't have poll */
  1097. #include <sys/poll.h>
  1098. _syscall3(int, poll, struct pollfd *, fds, unsigned long int, nfds, int, timeout);
  1099. #endif
  1100. //#define __NR_nfsservctl 169
  1101. //nfsservctl EXTRA nfsservctl i:ipp nfsservctl
  1102. //#define __NR_setresgid 170
  1103. //#define __NR_getresgid 171
  1104. //#define __NR_prctl 172
  1105. //#define __NR_rt_sigreturn 173
  1106. //#define __NR_rt_sigaction 174
  1107. #ifdef __NR_rt_sigaction
  1108. #define __NR___rt_sigaction __NR_rt_sigaction
  1109. #ifdef L___rt_sigaction
  1110. #include <signal.h>
  1111. #undef sigaction
  1112. _syscall4(int, __rt_sigaction, int, signum, const struct sigaction *, act,
  1113. struct sigaction *, oldact, size_t, size);
  1114. #endif
  1115. #endif
  1116. //#define __NR_rt_sigprocmask 175
  1117. #ifdef __NR_rt_sigprocmask
  1118. #define __NR___rt_sigprocmask __NR_rt_sigprocmask
  1119. #ifdef L___rt_sigprocmask
  1120. #include <signal.h>
  1121. #undef sigprocmask
  1122. _syscall4(int, __rt_sigprocmask, int, how, const sigset_t *, set,
  1123. sigset_t *, oldset, size_t, size);
  1124. int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
  1125. {
  1126. return __rt_sigprocmask(how, set, oldset, _NSIG/8);
  1127. }
  1128. #endif
  1129. #endif
  1130. //#define __NR_rt_sigpending 176
  1131. #ifdef __NR_rt_sigpending
  1132. #define __NR___rt_sigpending __NR_rt_sigpending
  1133. #ifdef L___rt_sigpending
  1134. #include <signal.h>
  1135. #undef sigpending
  1136. _syscall2(int, __rt_sigpending, sigset_t *, set, size_t, size);
  1137. int sigpending(sigset_t *set)
  1138. {
  1139. return __rt_sigpending(set, _NSIG/8);
  1140. }
  1141. #endif
  1142. #endif
  1143. //#define __NR_rt_sigtimedwait 177
  1144. //#define __NR_rt_sigqueueinfo 178
  1145. //#define __NR_rt_sigsuspend 179
  1146. #ifdef __NR_rt_sigsuspend
  1147. #define __NR___rt_sigsuspend __NR_rt_sigsuspend
  1148. #ifdef L___rt_sigsuspend
  1149. #include <signal.h>
  1150. #undef _sigsuspend
  1151. _syscall2(int, __rt_sigsuspend, const sigset_t *, mask, size_t, size);
  1152. int sigsuspend (const sigset_t *mask)
  1153. {
  1154. return __rt_sigsuspend(mask, _NSIG/8);
  1155. }
  1156. #endif
  1157. #endif
  1158. //#define __NR_pread 180
  1159. #ifdef L___libc_pread
  1160. #define _XOPEN_SOURCE 500
  1161. #include <unistd.h>
  1162. #define __NR___libc_pread __NR_pread
  1163. _syscall4(ssize_t, __libc_pread, int, fd, void *, buf, size_t, count, __off_t, offset);
  1164. weak_alias (__libc_pread, pread)
  1165. #endif
  1166. //#define __NR_pwrite 181
  1167. #ifdef L___libc_pwrite
  1168. #define _XOPEN_SOURCE 500
  1169. #include <unistd.h>
  1170. #define __NR___libc_pwrite __NR_pwrite
  1171. _syscall4(ssize_t, __libc_pwrite, int, fd, const void *, buf, size_t, count, __off_t, offset);
  1172. weak_alias (__libc_pwrite, pwrite)
  1173. #endif
  1174. //#define __NR_chown 182
  1175. #ifdef L_chown
  1176. #include <unistd.h>
  1177. _syscall3(int, chown, const char *, path, uid_t, owner, gid_t, group);
  1178. #endif
  1179. //#define __NR_getcwd 183
  1180. // See unistd/getcwd.c -- we don't use this syscall, even when it is available...
  1181. //#define __NR_capget 184
  1182. #ifdef L_capget
  1183. # ifdef __NR_capget
  1184. _syscall2(int, capget, void*, header, void*, data);
  1185. # else
  1186. int capget(void* header, void* data)
  1187. {
  1188. __set_errno(ENOSYS);
  1189. return -1;
  1190. }
  1191. # endif
  1192. #endif
  1193. //#define __NR_capset 185
  1194. #ifdef L_capset
  1195. # ifdef __NR_capset
  1196. _syscall2(int, capset, void*, header, const void*, data);
  1197. # else
  1198. int capset(void* header, const void* data)
  1199. {
  1200. __set_errno(ENOSYS);
  1201. return -1;
  1202. }
  1203. # endif
  1204. #endif
  1205. //#define __NR_sigaltstack 186
  1206. #ifdef __NR_sigaltstack
  1207. #ifdef L_sigaltstack
  1208. #include <signal.h>
  1209. _syscall2(int, sigaltstack, const struct sigaltstack *, ss, struct sigaltstack *, oss);
  1210. #endif
  1211. #endif
  1212. //#define __NR_sendfile 187
  1213. #ifdef __NR_sendfile
  1214. #ifdef L_sendfile
  1215. #include <unistd.h>
  1216. #include <sys/sendfile.h>
  1217. _syscall4(ssize_t,sendfile, int, out_fd, int, in_fd, __off_t *, offset, size_t, count)
  1218. #endif
  1219. #endif
  1220. //#define __NR_getpmsg 188
  1221. //#define __NR_putpmsg 189
  1222. //#define __NR_vfork 190
  1223. //See sysdeps/linux/<arch>vfork.[cS] for architecture specific implementation...
  1224. //#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
  1225. #ifdef L___ugetrlimit
  1226. #ifdef __NR_ugetrlimit
  1227. #define __NR___ugetrlimit __NR_ugetrlimit
  1228. #include <unistd.h>
  1229. #include <sys/resource.h>
  1230. _syscall2(int, __ugetrlimit, enum __rlimit_resource, resource, struct rlimit *, rlim);
  1231. int getrlimit (__rlimit_resource_t resource, struct rlimit *rlimits)
  1232. {
  1233. return(__ugetrlimit(resource, rlimits));
  1234. }
  1235. #endif /* __NR_ugetrlimit */
  1236. #endif
  1237. //#define __NR_mmap2 192
  1238. //#define __NR_truncate64 193
  1239. //See libc/sysdeps/linux/common/truncate64.c
  1240. //#define __NR_ftruncate64 194
  1241. //See libc/sysdeps/linux/common/ftruncate64.c
  1242. //#define __NR_stat64 195
  1243. #ifdef L___stat64
  1244. #ifdef __UCLIBC_HAVE_LFS__
  1245. #include <unistd.h>
  1246. #include "statfix64.h"
  1247. #define __NR___stat64 __NR_stat64
  1248. extern int __stat64(const char *file_name, struct kernel_stat64 *buf);
  1249. _syscall2(int, __stat64, const char *, file_name, struct kernel_stat64 *, buf);
  1250. int __xstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1251. {
  1252. struct kernel_stat64 kstat;
  1253. int result = __stat64(file_name, &kstat);
  1254. if (result == 0) {
  1255. statfix64(cstat, &kstat);
  1256. }
  1257. return result;
  1258. }
  1259. int stat64(const char *file_name, struct libc_stat64 *buf)
  1260. {
  1261. return(__xstat64(0, file_name, buf));
  1262. }
  1263. #endif /* __UCLIBC_HAVE_LFS__ */
  1264. #endif
  1265. //#define __NR_lstat64 196
  1266. #ifdef L___lstat64
  1267. #ifdef __UCLIBC_HAVE_LFS__
  1268. #include <unistd.h>
  1269. #include "statfix64.h"
  1270. #define __NR___lstat64 __NR_lstat64
  1271. extern int __lstat64(const char *file_name, struct kernel_stat64 *buf);
  1272. _syscall2(int, __lstat64, const char *, file_name, struct kernel_stat64 *, buf);
  1273. int __lxstat64(int version, const char * file_name, struct libc_stat64 * cstat)
  1274. {
  1275. struct kernel_stat64 kstat;
  1276. int result = __lstat64(file_name, &kstat);
  1277. if (result == 0) {
  1278. statfix64(cstat, &kstat);
  1279. }
  1280. return result;
  1281. }
  1282. int lstat64(const char *file_name, struct libc_stat64 *buf)
  1283. {
  1284. return(__lxstat64(0, file_name, buf));
  1285. }
  1286. #endif /* __UCLIBC_HAVE_LFS__ */
  1287. #endif
  1288. //#define __NR_fstat64 197
  1289. #ifdef L___fstat64
  1290. #ifdef __UCLIBC_HAVE_LFS__
  1291. #include <unistd.h>
  1292. #include "statfix64.h"
  1293. #define __NR___fstat64 __NR_fstat64
  1294. extern int __fstat64(int filedes, struct kernel_stat64 *buf);
  1295. _syscall2(int, __fstat64, int, filedes, struct kernel_stat64 *, buf);
  1296. int __fxstat64(int version, int fd, struct libc_stat64 * cstat)
  1297. {
  1298. struct kernel_stat64 kstat;
  1299. int result = __fstat64(fd, &kstat);
  1300. if (result == 0) {
  1301. statfix64(cstat, &kstat);
  1302. }
  1303. return result;
  1304. }
  1305. int fstat64(int filedes, struct libc_stat64 *buf)
  1306. {
  1307. return(__fxstat64(0, filedes, buf));
  1308. }
  1309. #endif /* __UCLIBC_HAVE_LFS__ */
  1310. #endif
  1311. //#define __NR_lchown32 198
  1312. //#define __NR_getuid32 199
  1313. //#define __NR_getgid32 200
  1314. //#define __NR_geteuid32 201
  1315. //#define __NR_getegid32 202
  1316. //#define __NR_setreuid32 203
  1317. //#define __NR_setregid32 204
  1318. //#define __NR_getgroups32 205
  1319. //#define __NR_setgroups32 206
  1320. //#define __NR_fchown32 207
  1321. //#define __NR_setresuid32 208
  1322. //#define __NR_getresuid32 209
  1323. //#define __NR_setresgid32 210
  1324. //#define __NR_getresgid32 211
  1325. //#define __NR_chown32 212
  1326. //#define __NR_setuid32 213
  1327. //#define __NR_setgid32 214
  1328. //#define __NR_setfsuid32 215
  1329. //#define __NR_setfsgid32 216
  1330. //#define __NR_pivot_root 217
  1331. #ifdef __NR_pivot_root
  1332. #ifdef L_pivot_root
  1333. _syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
  1334. #endif
  1335. #endif
  1336. //#define __NR_mincore 218
  1337. //#define __NR_madvise 219
  1338. //#define __NR_madvise1 219 /* delete when C lib stub is removed */
  1339. //#define __NR_getdents64 220
  1340. #ifdef L_getdents64
  1341. #ifdef __UCLIBC_HAVE_LFS__
  1342. #include <unistd.h>
  1343. #include <dirent.h>
  1344. _syscall3(int, getdents64, int, fd, char *, dirp, size_t, count);
  1345. #endif /* __UCLIBC_HAVE_LFS__ */
  1346. #endif
  1347. //#define __NR_fcntl64 221
  1348. #ifdef L__fcntl64
  1349. #ifdef __UCLIBC_HAVE_LFS__
  1350. #define __NR__fcntl64 __NR_fcntl64
  1351. #include <stdarg.h>
  1352. #include <fcntl.h>
  1353. extern int _fcntl64(int fd, int cmd, long arg);
  1354. _syscall3(int, _fcntl64, int, fd, int, cmd, long, arg);
  1355. int fcntl64(int fd, int command, ...)
  1356. {
  1357. long arg;
  1358. va_list list;
  1359. va_start(list, command);
  1360. arg = va_arg(list, long);
  1361. va_end(list);
  1362. return _fcntl64(fd, command, arg);
  1363. }
  1364. #endif
  1365. #endif
  1366. //#define __NR_security 223 /* syscall for security modules */
  1367. //#define __NR_gettid 224
  1368. //#define __NR_readahead 225