syscalls.c 41 KB

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