syscalls.c 40 KB

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