aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/kernel/vsyscall.c1
-rw-r--r--include/asm-alpha/unistd.h182
-rw-r--r--include/asm-arm/unistd.h150
-rw-r--r--include/asm-arm26/unistd.h133
-rw-r--r--include/asm-frv/unistd.h119
-rw-r--r--include/asm-h8300/unistd.h166
-rw-r--r--include/asm-i386/unistd.h98
-rw-r--r--include/asm-m32r/unistd.h111
-rw-r--r--include/asm-m68k/unistd.h97
-rw-r--r--include/asm-m68knommu/unistd.h150
-rw-r--r--include/asm-mips/unistd.h262
-rw-r--r--include/asm-powerpc/unistd.h109
-rw-r--r--include/asm-s390/unistd.h154
-rw-r--r--include/asm-sh/unistd.h137
-rw-r--r--include/asm-sh64/unistd.h142
-rw-r--r--include/asm-sparc/unistd.h130
-rw-r--r--include/asm-sparc64/unistd.h118
-rw-r--r--include/asm-v850/unistd.h160
-rw-r--r--include/asm-x86_64/unistd.h99
-rw-r--r--include/asm-xtensa/unistd.h184
20 files changed, 1 insertions, 2701 deletions
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index 92546c1526f1..630036c06c75 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -42,6 +42,7 @@
42#include <asm/topology.h> 42#include <asm/topology.h>
43 43
44#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr))) 44#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
45#define __syscall_clobber "r11","rcx","memory"
45 46
46int __sysctl_vsyscall __section_sysctl_vsyscall = 1; 47int __sysctl_vsyscall __section_sysctl_vsyscall = 1;
47seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED; 48seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED;
diff --git a/include/asm-alpha/unistd.h b/include/asm-alpha/unistd.h
index 2cabbd465c0c..84313d14e780 100644
--- a/include/asm-alpha/unistd.h
+++ b/include/asm-alpha/unistd.h
@@ -387,188 +387,6 @@
387 387
388#define NR_SYSCALLS 447 388#define NR_SYSCALLS 447
389 389
390#if defined(__GNUC__)
391
392#define _syscall_return(type) \
393 return (_sc_err ? errno = _sc_ret, _sc_ret = -1L : 0), (type) _sc_ret
394
395#define _syscall_clobbers \
396 "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
397 "$22", "$23", "$24", "$25", "$27", "$28" \
398
399#define _syscall0(type, name) \
400type name(void) \
401{ \
402 long _sc_ret, _sc_err; \
403 { \
404 register long _sc_0 __asm__("$0"); \
405 register long _sc_19 __asm__("$19"); \
406 \
407 _sc_0 = __NR_##name; \
408 __asm__("callsys # %0 %1 %2" \
409 : "=r"(_sc_0), "=r"(_sc_19) \
410 : "0"(_sc_0) \
411 : _syscall_clobbers); \
412 _sc_ret = _sc_0, _sc_err = _sc_19; \
413 } \
414 _syscall_return(type); \
415}
416
417#define _syscall1(type,name,type1,arg1) \
418type name(type1 arg1) \
419{ \
420 long _sc_ret, _sc_err; \
421 { \
422 register long _sc_0 __asm__("$0"); \
423 register long _sc_16 __asm__("$16"); \
424 register long _sc_19 __asm__("$19"); \
425 \
426 _sc_0 = __NR_##name; \
427 _sc_16 = (long) (arg1); \
428 __asm__("callsys # %0 %1 %2 %3" \
429 : "=r"(_sc_0), "=r"(_sc_19) \
430 : "0"(_sc_0), "r"(_sc_16) \
431 : _syscall_clobbers); \
432 _sc_ret = _sc_0, _sc_err = _sc_19; \
433 } \
434 _syscall_return(type); \
435}
436
437#define _syscall2(type,name,type1,arg1,type2,arg2) \
438type name(type1 arg1,type2 arg2) \
439{ \
440 long _sc_ret, _sc_err; \
441 { \
442 register long _sc_0 __asm__("$0"); \
443 register long _sc_16 __asm__("$16"); \
444 register long _sc_17 __asm__("$17"); \
445 register long _sc_19 __asm__("$19"); \
446 \
447 _sc_0 = __NR_##name; \
448 _sc_16 = (long) (arg1); \
449 _sc_17 = (long) (arg2); \
450 __asm__("callsys # %0 %1 %2 %3 %4" \
451 : "=r"(_sc_0), "=r"(_sc_19) \
452 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17) \
453 : _syscall_clobbers); \
454 _sc_ret = _sc_0, _sc_err = _sc_19; \
455 } \
456 _syscall_return(type); \
457}
458
459#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
460type name(type1 arg1,type2 arg2,type3 arg3) \
461{ \
462 long _sc_ret, _sc_err; \
463 { \
464 register long _sc_0 __asm__("$0"); \
465 register long _sc_16 __asm__("$16"); \
466 register long _sc_17 __asm__("$17"); \
467 register long _sc_18 __asm__("$18"); \
468 register long _sc_19 __asm__("$19"); \
469 \
470 _sc_0 = __NR_##name; \
471 _sc_16 = (long) (arg1); \
472 _sc_17 = (long) (arg2); \
473 _sc_18 = (long) (arg3); \
474 __asm__("callsys # %0 %1 %2 %3 %4 %5" \
475 : "=r"(_sc_0), "=r"(_sc_19) \
476 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
477 "r"(_sc_18) \
478 : _syscall_clobbers); \
479 _sc_ret = _sc_0, _sc_err = _sc_19; \
480 } \
481 _syscall_return(type); \
482}
483
484#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
485type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
486{ \
487 long _sc_ret, _sc_err; \
488 { \
489 register long _sc_0 __asm__("$0"); \
490 register long _sc_16 __asm__("$16"); \
491 register long _sc_17 __asm__("$17"); \
492 register long _sc_18 __asm__("$18"); \
493 register long _sc_19 __asm__("$19"); \
494 \
495 _sc_0 = __NR_##name; \
496 _sc_16 = (long) (arg1); \
497 _sc_17 = (long) (arg2); \
498 _sc_18 = (long) (arg3); \
499 _sc_19 = (long) (arg4); \
500 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6" \
501 : "=r"(_sc_0), "=r"(_sc_19) \
502 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
503 "r"(_sc_18), "1"(_sc_19) \
504 : _syscall_clobbers); \
505 _sc_ret = _sc_0, _sc_err = _sc_19; \
506 } \
507 _syscall_return(type); \
508}
509
510#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
511 type5,arg5) \
512type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
513{ \
514 long _sc_ret, _sc_err; \
515 { \
516 register long _sc_0 __asm__("$0"); \
517 register long _sc_16 __asm__("$16"); \
518 register long _sc_17 __asm__("$17"); \
519 register long _sc_18 __asm__("$18"); \
520 register long _sc_19 __asm__("$19"); \
521 register long _sc_20 __asm__("$20"); \
522 \
523 _sc_0 = __NR_##name; \
524 _sc_16 = (long) (arg1); \
525 _sc_17 = (long) (arg2); \
526 _sc_18 = (long) (arg3); \
527 _sc_19 = (long) (arg4); \
528 _sc_20 = (long) (arg5); \
529 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7" \
530 : "=r"(_sc_0), "=r"(_sc_19) \
531 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
532 "r"(_sc_18), "1"(_sc_19), "r"(_sc_20) \
533 : _syscall_clobbers); \
534 _sc_ret = _sc_0, _sc_err = _sc_19; \
535 } \
536 _syscall_return(type); \
537}
538
539#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
540 type5,arg5,type6,arg6) \
541type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6)\
542{ \
543 long _sc_ret, _sc_err; \
544 { \
545 register long _sc_0 __asm__("$0"); \
546 register long _sc_16 __asm__("$16"); \
547 register long _sc_17 __asm__("$17"); \
548 register long _sc_18 __asm__("$18"); \
549 register long _sc_19 __asm__("$19"); \
550 register long _sc_20 __asm__("$20"); \
551 register long _sc_21 __asm__("$21"); \
552 \
553 _sc_0 = __NR_##name; \
554 _sc_16 = (long) (arg1); \
555 _sc_17 = (long) (arg2); \
556 _sc_18 = (long) (arg3); \
557 _sc_19 = (long) (arg4); \
558 _sc_20 = (long) (arg5); \
559 _sc_21 = (long) (arg6); \
560 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7 %8" \
561 : "=r"(_sc_0), "=r"(_sc_19) \
562 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
563 "r"(_sc_18), "1"(_sc_19), "r"(_sc_20), "r"(_sc_21) \
564 : _syscall_clobbers); \
565 _sc_ret = _sc_0, _sc_err = _sc_19; \
566 } \
567 _syscall_return(type); \
568}
569
570#endif /* __GNUC__ */
571
572#define __ARCH_WANT_IPC_PARSE_VERSION 390#define __ARCH_WANT_IPC_PARSE_VERSION
573#define __ARCH_WANT_OLD_READDIR 391#define __ARCH_WANT_OLD_READDIR
574#define __ARCH_WANT_STAT64 392#define __ARCH_WANT_STAT64
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index 14a87eec5a2d..d44c629d8424 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -377,156 +377,6 @@
377#endif 377#endif
378 378
379#ifdef __KERNEL__ 379#ifdef __KERNEL__
380#include <linux/err.h>
381#include <linux/linkage.h>
382
383#define __sys2(x) #x
384#define __sys1(x) __sys2(x)
385
386#ifndef __syscall
387#if defined(__thumb__) || defined(__ARM_EABI__)
388#define __SYS_REG(name) register long __sysreg __asm__("r7") = __NR_##name;
389#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
390#define __syscall(name) "swi\t0"
391#else
392#define __SYS_REG(name)
393#define __SYS_REG_LIST(regs...) regs
394#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
395#endif
396#endif
397
398#define __syscall_return(type, res) \
399do { \
400 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
401 errno = -(res); \
402 res = -1; \
403 } \
404 return (type) (res); \
405} while (0)
406
407#define _syscall0(type,name) \
408type name(void) { \
409 __SYS_REG(name) \
410 register long __res_r0 __asm__("r0"); \
411 long __res; \
412 __asm__ __volatile__ ( \
413 __syscall(name) \
414 : "=r" (__res_r0) \
415 : __SYS_REG_LIST() \
416 : "memory" ); \
417 __res = __res_r0; \
418 __syscall_return(type,__res); \
419}
420
421#define _syscall1(type,name,type1,arg1) \
422type name(type1 arg1) { \
423 __SYS_REG(name) \
424 register long __r0 __asm__("r0") = (long)arg1; \
425 register long __res_r0 __asm__("r0"); \
426 long __res; \
427 __asm__ __volatile__ ( \
428 __syscall(name) \
429 : "=r" (__res_r0) \
430 : __SYS_REG_LIST( "0" (__r0) ) \
431 : "memory" ); \
432 __res = __res_r0; \
433 __syscall_return(type,__res); \
434}
435
436#define _syscall2(type,name,type1,arg1,type2,arg2) \
437type name(type1 arg1,type2 arg2) { \
438 __SYS_REG(name) \
439 register long __r0 __asm__("r0") = (long)arg1; \
440 register long __r1 __asm__("r1") = (long)arg2; \
441 register long __res_r0 __asm__("r0"); \
442 long __res; \
443 __asm__ __volatile__ ( \
444 __syscall(name) \
445 : "=r" (__res_r0) \
446 : __SYS_REG_LIST( "0" (__r0), "r" (__r1) ) \
447 : "memory" ); \
448 __res = __res_r0; \
449 __syscall_return(type,__res); \
450}
451
452
453#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
454type name(type1 arg1,type2 arg2,type3 arg3) { \
455 __SYS_REG(name) \
456 register long __r0 __asm__("r0") = (long)arg1; \
457 register long __r1 __asm__("r1") = (long)arg2; \
458 register long __r2 __asm__("r2") = (long)arg3; \
459 register long __res_r0 __asm__("r0"); \
460 long __res; \
461 __asm__ __volatile__ ( \
462 __syscall(name) \
463 : "=r" (__res_r0) \
464 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2) ) \
465 : "memory" ); \
466 __res = __res_r0; \
467 __syscall_return(type,__res); \
468}
469
470
471#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
472type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
473 __SYS_REG(name) \
474 register long __r0 __asm__("r0") = (long)arg1; \
475 register long __r1 __asm__("r1") = (long)arg2; \
476 register long __r2 __asm__("r2") = (long)arg3; \
477 register long __r3 __asm__("r3") = (long)arg4; \
478 register long __res_r0 __asm__("r0"); \
479 long __res; \
480 __asm__ __volatile__ ( \
481 __syscall(name) \
482 : "=r" (__res_r0) \
483 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) ) \
484 : "memory" ); \
485 __res = __res_r0; \
486 __syscall_return(type,__res); \
487}
488
489
490#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
491type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
492 __SYS_REG(name) \
493 register long __r0 __asm__("r0") = (long)arg1; \
494 register long __r1 __asm__("r1") = (long)arg2; \
495 register long __r2 __asm__("r2") = (long)arg3; \
496 register long __r3 __asm__("r3") = (long)arg4; \
497 register long __r4 __asm__("r4") = (long)arg5; \
498 register long __res_r0 __asm__("r0"); \
499 long __res; \
500 __asm__ __volatile__ ( \
501 __syscall(name) \
502 : "=r" (__res_r0) \
503 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), \
504 "r" (__r3), "r" (__r4) ) \
505 : "memory" ); \
506 __res = __res_r0; \
507 __syscall_return(type,__res); \
508}
509
510#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
511type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \
512 __SYS_REG(name) \
513 register long __r0 __asm__("r0") = (long)arg1; \
514 register long __r1 __asm__("r1") = (long)arg2; \
515 register long __r2 __asm__("r2") = (long)arg3; \
516 register long __r3 __asm__("r3") = (long)arg4; \
517 register long __r4 __asm__("r4") = (long)arg5; \
518 register long __r5 __asm__("r5") = (long)arg6; \
519 register long __res_r0 __asm__("r0"); \
520 long __res; \
521 __asm__ __volatile__ ( \
522 __syscall(name) \
523 : "=r" (__res_r0) \
524 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), \
525 "r" (__r3), "r" (__r4), "r" (__r5) ) \
526 : "memory" ); \
527 __res = __res_r0; \
528 __syscall_return(type,__res); \
529}
530 380
531#define __ARCH_WANT_IPC_PARSE_VERSION 381#define __ARCH_WANT_IPC_PARSE_VERSION
532#define __ARCH_WANT_STAT64 382#define __ARCH_WANT_STAT64
diff --git a/include/asm-arm26/unistd.h b/include/asm-arm26/unistd.h
index 25a5eead85be..4c3b919177e5 100644
--- a/include/asm-arm26/unistd.h
+++ b/include/asm-arm26/unistd.h
@@ -311,139 +311,6 @@
311#define __ARM_NR_usr26 (__ARM_NR_BASE+3) 311#define __ARM_NR_usr26 (__ARM_NR_BASE+3)
312 312
313#ifdef __KERNEL__ 313#ifdef __KERNEL__
314#include <linux/err.h>
315#include <linux/linkage.h>
316
317#define __sys2(x) #x
318#define __sys1(x) __sys2(x)
319
320#ifndef __syscall
321#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
322#endif
323
324#define __syscall_return(type, res) \
325do { \
326 if ((unsigned long)(res) >= (unsigned long)-MAX_ERRNO) { \
327 errno = -(res); \
328 res = -1; \
329 } \
330 return (type) (res); \
331} while (0)
332
333#define _syscall0(type,name) \
334type name(void) { \
335 register long __res_r0 __asm__("r0"); \
336 long __res; \
337 __asm__ __volatile__ ( \
338 __syscall(name) \
339 : "=r" (__res_r0) \
340 : \
341 : "lr"); \
342 __res = __res_r0; \
343 __syscall_return(type,__res); \
344}
345
346#define _syscall1(type,name,type1,arg1) \
347type name(type1 arg1) { \
348 register long __r0 __asm__("r0") = (long)arg1; \
349 register long __res_r0 __asm__("r0"); \
350 long __res; \
351 __asm__ __volatile__ ( \
352 __syscall(name) \
353 : "=r" (__res_r0) \
354 : "r" (__r0) \
355 : "lr"); \
356 __res = __res_r0; \
357 __syscall_return(type,__res); \
358}
359
360#define _syscall2(type,name,type1,arg1,type2,arg2) \
361type name(type1 arg1,type2 arg2) { \
362 register long __r0 __asm__("r0") = (long)arg1; \
363 register long __r1 __asm__("r1") = (long)arg2; \
364 register long __res_r0 __asm__("r0"); \
365 long __res; \
366 __asm__ __volatile__ ( \
367 __syscall(name) \
368 : "=r" (__res_r0) \
369 : "r" (__r0),"r" (__r1) \
370 : "lr"); \
371 __res = __res_r0; \
372 __syscall_return(type,__res); \
373}
374
375
376#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
377type name(type1 arg1,type2 arg2,type3 arg3) { \
378 register long __r0 __asm__("r0") = (long)arg1; \
379 register long __r1 __asm__("r1") = (long)arg2; \
380 register long __r2 __asm__("r2") = (long)arg3; \
381 register long __res_r0 __asm__("r0"); \
382 long __res; \
383 __asm__ __volatile__ ( \
384 __syscall(name) \
385 : "=r" (__res_r0) \
386 : "r" (__r0),"r" (__r1),"r" (__r2) \
387 : "lr"); \
388 __res = __res_r0; \
389 __syscall_return(type,__res); \
390}
391
392
393#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
394type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
395 register long __r0 __asm__("r0") = (long)arg1; \
396 register long __r1 __asm__("r1") = (long)arg2; \
397 register long __r2 __asm__("r2") = (long)arg3; \
398 register long __r3 __asm__("r3") = (long)arg4; \
399 register long __res_r0 __asm__("r0"); \
400 long __res; \
401 __asm__ __volatile__ ( \
402 __syscall(name) \
403 : "=r" (__res_r0) \
404 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3) \
405 : "lr"); \
406 __res = __res_r0; \
407 __syscall_return(type,__res); \
408}
409
410
411#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
412type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
413 register long __r0 __asm__("r0") = (long)arg1; \
414 register long __r1 __asm__("r1") = (long)arg2; \
415 register long __r2 __asm__("r2") = (long)arg3; \
416 register long __r3 __asm__("r3") = (long)arg4; \
417 register long __r4 __asm__("r4") = (long)arg5; \
418 register long __res_r0 __asm__("r0"); \
419 long __res; \
420 __asm__ __volatile__ ( \
421 __syscall(name) \
422 : "=r" (__res_r0) \
423 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4) \
424 : "lr"); \
425 __res = __res_r0; \
426 __syscall_return(type,__res); \
427}
428
429#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
430type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \
431 register long __r0 __asm__("r0") = (long)arg1; \
432 register long __r1 __asm__("r1") = (long)arg2; \
433 register long __r2 __asm__("r2") = (long)arg3; \
434 register long __r3 __asm__("r3") = (long)arg4; \
435 register long __r4 __asm__("r4") = (long)arg5; \
436 register long __r5 __asm__("r5") = (long)arg6; \
437 register long __res_r0 __asm__("r0"); \
438 long __res; \
439 __asm__ __volatile__ ( \
440 __syscall(name) \
441 : "=r" (__res_r0) \
442 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5) \
443 : "lr"); \
444 __res = __res_r0; \
445 __syscall_return(type,__res); \
446}
447 314
448#define __ARCH_WANT_IPC_PARSE_VERSION 315#define __ARCH_WANT_IPC_PARSE_VERSION
449#define __ARCH_WANT_OLD_READDIR 316#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-frv/unistd.h b/include/asm-frv/unistd.h
index 725e854928cf..584c0417ae4d 100644
--- a/include/asm-frv/unistd.h
+++ b/include/asm-frv/unistd.h
@@ -320,125 +320,6 @@
320#ifdef __KERNEL__ 320#ifdef __KERNEL__
321 321
322#define NR_syscalls 310 322#define NR_syscalls 310
323#include <linux/err.h>
324
325/*
326 * process the return value of a syscall, consigning it to one of two possible fates
327 * - user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h>
328 */
329#undef __syscall_return
330#define __syscall_return(type, res) \
331do { \
332 unsigned long __sr2 = (res); \
333 if (__builtin_expect(__sr2 >= (unsigned long)(-MAX_ERRNO), 0)) { \
334 errno = (-__sr2); \
335 __sr2 = ~0UL; \
336 } \
337 return (type) __sr2; \
338} while (0)
339
340/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
341
342#undef _syscall0
343#define _syscall0(type,name) \
344type name(void) \
345{ \
346 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
347 register unsigned long __sc0 __asm__ ("gr8"); \
348 __asm__ __volatile__ ("tira gr0,#0" \
349 : "=r" (__sc0) \
350 : "r" (__scnum)); \
351 __syscall_return(type, __sc0); \
352}
353
354#undef _syscall1
355#define _syscall1(type,name,type1,arg1) \
356type name(type1 arg1) \
357{ \
358 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
359 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
360 __asm__ __volatile__ ("tira gr0,#0" \
361 : "+r" (__sc0) \
362 : "r" (__scnum)); \
363 __syscall_return(type, __sc0); \
364}
365
366#undef _syscall2
367#define _syscall2(type,name,type1,arg1,type2,arg2) \
368type name(type1 arg1,type2 arg2) \
369{ \
370 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
371 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
372 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
373 __asm__ __volatile__ ("tira gr0,#0" \
374 : "+r" (__sc0) \
375 : "r" (__scnum), "r" (__sc1)); \
376 __syscall_return(type, __sc0); \
377}
378
379#undef _syscall3
380#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
381type name(type1 arg1,type2 arg2,type3 arg3) \
382{ \
383 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
384 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
385 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
386 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
387 __asm__ __volatile__ ("tira gr0,#0" \
388 : "+r" (__sc0) \
389 : "r" (__scnum), "r" (__sc1), "r" (__sc2)); \
390 __syscall_return(type, __sc0); \
391}
392
393#undef _syscall4
394#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
395type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
396{ \
397 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
398 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
399 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
400 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
401 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
402 __asm__ __volatile__ ("tira gr0,#0" \
403 : "+r" (__sc0) \
404 : "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3)); \
405 __syscall_return(type, __sc0); \
406}
407
408#undef _syscall5
409#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
410type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
411{ \
412 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
413 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
414 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
415 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
416 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
417 register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
418 __asm__ __volatile__ ("tira gr0,#0" \
419 : "+r" (__sc0) \
420 : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
421 "r" (__sc3), "r" (__sc4)); \
422 __syscall_return(type, __sc0); \
423}
424
425#undef _syscall6
426#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
427type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
428{ \
429 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
430 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
431 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
432 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
433 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
434 register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
435 register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6; \
436 __asm__ __volatile__ ("tira gr0,#0" \
437 : "+r" (__sc0) \
438 : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
439 "r" (__sc3), "r" (__sc4), "r" (__sc5)); \
440 __syscall_return(type, __sc0); \
441}
442 323
443#define __ARCH_WANT_IPC_PARSE_VERSION 324#define __ARCH_WANT_IPC_PARSE_VERSION
444/* #define __ARCH_WANT_OLD_READDIR */ 325/* #define __ARCH_WANT_OLD_READDIR */
diff --git a/include/asm-h8300/unistd.h b/include/asm-h8300/unistd.h
index 747788d629ae..7ddd414f8d16 100644
--- a/include/asm-h8300/unistd.h
+++ b/include/asm-h8300/unistd.h
@@ -295,172 +295,6 @@
295#ifdef __KERNEL__ 295#ifdef __KERNEL__
296 296
297#define NR_syscalls 289 297#define NR_syscalls 289
298#include <linux/err.h>
299
300/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
301 <asm-m68k/errno.h> */
302
303#define __syscall_return(type, res) \
304do { \
305 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
306 /* avoid using res which is declared to be in register d0; \
307 errno might expand to a function call and clobber it. */ \
308 int __err = -(res); \
309 errno = __err; \
310 res = -1; \
311 } \
312 return (type) (res); \
313} while (0)
314
315#define _syscall0(type, name) \
316type name(void) \
317{ \
318 register long __res __asm__("er0"); \
319 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
320 "trapa #0\n\t" \
321 : "=r" (__res) \
322 : "g" (__NR_##name) \
323 : "cc", "memory"); \
324 __syscall_return(type, __res); \
325}
326
327#define _syscall1(type, name, atype, a) \
328type name(atype a) \
329{ \
330 register long __res __asm__("er0"); \
331 register long _a __asm__("er1"); \
332 _a = (long)a; \
333 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
334 "trapa #0\n\t" \
335 : "=r" (__res) \
336 : "g" (__NR_##name), \
337 "g" (_a) \
338 : "cc", "memory"); \
339 __syscall_return(type, __res); \
340}
341
342#define _syscall2(type, name, atype, a, btype, b) \
343type name(atype a, btype b) \
344{ \
345 register long __res __asm__("er0"); \
346 register long _a __asm__("er1"); \
347 register long _b __asm__("er2"); \
348 _a = (long)a; \
349 _b = (long)b; \
350 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
351 "trapa #0\n\t" \
352 : "=r" (__res) \
353 : "g" (__NR_##name), \
354 "g" (_a), \
355 "g" (_b) \
356 : "cc", "memory"); \
357 __syscall_return(type, __res); \
358}
359
360#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
361type name(atype a, btype b, ctype c) \
362{ \
363 register long __res __asm__("er0"); \
364 register long _a __asm__("er1"); \
365 register long _b __asm__("er2"); \
366 register long _c __asm__("er3"); \
367 _a = (long)a; \
368 _b = (long)b; \
369 _c = (long)c; \
370 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
371 "trapa #0\n\t" \
372 : "=r" (__res) \
373 : "g" (__NR_##name), \
374 "g" (_a), \
375 "g" (_b), \
376 "g" (_c) \
377 : "cc", "memory"); \
378 __syscall_return(type, __res); \
379}
380
381#define _syscall4(type, name, atype, a, btype, b, \
382 ctype, c, dtype, d) \
383type name(atype a, btype b, ctype c, dtype d) \
384{ \
385 register long __res __asm__("er0"); \
386 register long _a __asm__("er1"); \
387 register long _b __asm__("er2"); \
388 register long _c __asm__("er3"); \
389 register long _d __asm__("er4"); \
390 _a = (long)a; \
391 _b = (long)b; \
392 _c = (long)c; \
393 _d = (long)d; \
394 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
395 "trapa #0\n\t" \
396 : "=r" (__res) \
397 : "g" (__NR_##name), \
398 "g" (_a), \
399 "g" (_b), \
400 "g" (_c), \
401 "g" (_d) \
402 : "cc", "memory"); \
403 __syscall_return(type, __res); \
404}
405
406#define _syscall5(type, name, atype, a, btype, b, \
407 ctype, c, dtype, d, etype, e) \
408type name(atype a, btype b, ctype c, dtype d, etype e) \
409{ \
410 register long __res __asm__("er0"); \
411 register long _a __asm__("er1"); \
412 register long _b __asm__("er2"); \
413 register long _c __asm__("er3"); \
414 register long _d __asm__("er4"); \
415 register long _e __asm__("er5"); \
416 _a = (long)a; \
417 _b = (long)b; \
418 _c = (long)c; \
419 _d = (long)d; \
420 _e = (long)e; \
421 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
422 "trapa #0\n\t" \
423 : "=r" (__res) \
424 : "g" (__NR_##name), \
425 "g" (_a), \
426 "g" (_b), \
427 "g" (_c), \
428 "g" (_d), \
429 "g" (_e) \
430 : "cc", "memory"); \
431 __syscall_return(type, __res); \
432}
433
434#define _syscall6(type, name, atype, a, btype, b, \
435 ctype, c, dtype, d, etype, e, ftype, f) \
436type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
437{ \
438 register long __res __asm__("er0"); \
439 register long _a __asm__("er1"); \
440 register long _b __asm__("er2"); \
441 register long _c __asm__("er3"); \
442 register long _d __asm__("er4"); \
443 register long _e __asm__("er5"); \
444 register long _f __asm__("er6"); \
445 _a = (long)a; \
446 _b = (long)b; \
447 _c = (long)c; \
448 _d = (long)d; \
449 _e = (long)e; \
450 _f = (long)f; \
451 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
452 "trapa #0\n\t" \
453 : "=r" (__res) \
454 : "g" (__NR_##name), \
455 "g" (_a), \
456 "g" (_b), \
457 "g" (_c), \
458 "g" (_d), \
459 "g" (_e) \
460 "g" (_f) \
461 : "cc", "memory"); \
462 __syscall_return(type, __res); \
463}
464 298
465#define __ARCH_WANT_IPC_PARSE_VERSION 299#define __ARCH_WANT_IPC_PARSE_VERSION
466#define __ARCH_WANT_OLD_READDIR 300#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index beeeaf6b054a..833fa1704ff9 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -329,104 +329,6 @@
329#ifdef __KERNEL__ 329#ifdef __KERNEL__
330 330
331#define NR_syscalls 320 331#define NR_syscalls 320
332#include <linux/err.h>
333
334/*
335 * user-visible error numbers are in the range -1 - -MAX_ERRNO: see
336 * <asm-i386/errno.h>
337 */
338#define __syscall_return(type, res) \
339do { \
340 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
341 errno = -(res); \
342 res = -1; \
343 } \
344 return (type) (res); \
345} while (0)
346
347/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
348#define _syscall0(type,name) \
349type name(void) \
350{ \
351long __res; \
352__asm__ volatile ("int $0x80" \
353 : "=a" (__res) \
354 : "0" (__NR_##name)); \
355__syscall_return(type,__res); \
356}
357
358#define _syscall1(type,name,type1,arg1) \
359type name(type1 arg1) \
360{ \
361long __res; \
362__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
363 : "=a" (__res) \
364 : "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
365__syscall_return(type,__res); \
366}
367
368#define _syscall2(type,name,type1,arg1,type2,arg2) \
369type name(type1 arg1,type2 arg2) \
370{ \
371long __res; \
372__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
373 : "=a" (__res) \
374 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
375 : "memory"); \
376__syscall_return(type,__res); \
377}
378
379#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
380type name(type1 arg1,type2 arg2,type3 arg3) \
381{ \
382long __res; \
383__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
384 : "=a" (__res) \
385 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
386 "d" ((long)(arg3)) : "memory"); \
387__syscall_return(type,__res); \
388}
389
390#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
391type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
392{ \
393long __res; \
394__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
395 : "=a" (__res) \
396 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
397 "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
398__syscall_return(type,__res); \
399}
400
401#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
402 type5,arg5) \
403type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
404{ \
405long __res; \
406__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
407 "int $0x80 ; pop %%ebx" \
408 : "=a" (__res) \
409 : "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
410 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
411 : "memory"); \
412__syscall_return(type,__res); \
413}
414
415#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
416 type5,arg5,type6,arg6) \
417type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
418{ \
419long __res; \
420 struct { long __a1; long __a6; } __s = { (long)arg1, (long)arg6 }; \
421__asm__ volatile ("push %%ebp ; push %%ebx ; movl 4(%2),%%ebp ; " \
422 "movl 0(%2),%%ebx ; movl %1,%%eax ; int $0x80 ; " \
423 "pop %%ebx ; pop %%ebp" \
424 : "=a" (__res) \
425 : "i" (__NR_##name),"0" ((long)(&__s)),"c" ((long)(arg2)), \
426 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
427 : "memory"); \
428__syscall_return(type,__res); \
429}
430 332
431#define __ARCH_WANT_IPC_PARSE_VERSION 333#define __ARCH_WANT_IPC_PARSE_VERSION
432#define __ARCH_WANT_OLD_READDIR 334#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h
index 95aa34298d82..5b66bd3c6ed6 100644
--- a/include/asm-m32r/unistd.h
+++ b/include/asm-m32r/unistd.h
@@ -296,117 +296,6 @@
296#ifdef __KERNEL__ 296#ifdef __KERNEL__
297 297
298#define NR_syscalls 285 298#define NR_syscalls 285
299#include <linux/err.h>
300
301/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
302 * <asm-m32r/errno.h>
303 */
304
305#include <asm/syscall.h> /* SYSCALL_* */
306
307#define __syscall_return(type, res) \
308do { \
309 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
310 /* Avoid using "res" which is declared to be in register r0; \
311 errno might expand to a function call and clobber it. */ \
312 int __err = -(res); \
313 errno = __err; \
314 res = -1; \
315 } \
316 return (type) (res); \
317} while (0)
318
319#define _syscall0(type,name) \
320type name(void) \
321{ \
322register long __scno __asm__ ("r7") = __NR_##name; \
323register long __res __asm__("r0"); \
324__asm__ __volatile__ (\
325 "trap #" SYSCALL_VECTOR "|| nop"\
326 : "=r" (__res) \
327 : "r" (__scno) \
328 : "memory"); \
329__syscall_return(type,__res); \
330}
331
332#define _syscall1(type,name,type1,arg1) \
333type name(type1 arg1) \
334{ \
335register long __scno __asm__ ("r7") = __NR_##name; \
336register long __res __asm__ ("r0") = (long)(arg1); \
337__asm__ __volatile__ (\
338 "trap #" SYSCALL_VECTOR "|| nop"\
339 : "=r" (__res) \
340 : "r" (__scno), "0" (__res) \
341 : "memory"); \
342__syscall_return(type,__res); \
343}
344
345#define _syscall2(type,name,type1,arg1,type2,arg2) \
346type name(type1 arg1,type2 arg2) \
347{ \
348register long __scno __asm__ ("r7") = __NR_##name; \
349register long __arg2 __asm__ ("r1") = (long)(arg2); \
350register long __res __asm__ ("r0") = (long)(arg1); \
351__asm__ __volatile__ (\
352 "trap #" SYSCALL_VECTOR "|| nop"\
353 : "=r" (__res) \
354 : "r" (__scno), "0" (__res), "r" (__arg2) \
355 : "memory"); \
356__syscall_return(type,__res); \
357}
358
359#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
360type name(type1 arg1,type2 arg2,type3 arg3) \
361{ \
362register long __scno __asm__ ("r7") = __NR_##name; \
363register long __arg3 __asm__ ("r2") = (long)(arg3); \
364register long __arg2 __asm__ ("r1") = (long)(arg2); \
365register long __res __asm__ ("r0") = (long)(arg1); \
366__asm__ __volatile__ (\
367 "trap #" SYSCALL_VECTOR "|| nop"\
368 : "=r" (__res) \
369 : "r" (__scno), "0" (__res), "r" (__arg2), \
370 "r" (__arg3) \
371 : "memory"); \
372__syscall_return(type,__res); \
373}
374
375#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
376type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
377{ \
378register long __scno __asm__ ("r7") = __NR_##name; \
379register long __arg4 __asm__ ("r3") = (long)(arg4); \
380register long __arg3 __asm__ ("r2") = (long)(arg3); \
381register long __arg2 __asm__ ("r1") = (long)(arg2); \
382register long __res __asm__ ("r0") = (long)(arg1); \
383__asm__ __volatile__ (\
384 "trap #" SYSCALL_VECTOR "|| nop"\
385 : "=r" (__res) \
386 : "r" (__scno), "0" (__res), "r" (__arg2), \
387 "r" (__arg3), "r" (__arg4) \
388 : "memory"); \
389__syscall_return(type,__res); \
390}
391
392#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
393 type5,arg5) \
394type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
395{ \
396register long __scno __asm__ ("r7") = __NR_##name; \
397register long __arg5 __asm__ ("r4") = (long)(arg5); \
398register long __arg4 __asm__ ("r3") = (long)(arg4); \
399register long __arg3 __asm__ ("r2") = (long)(arg3); \
400register long __arg2 __asm__ ("r1") = (long)(arg2); \
401register long __res __asm__ ("r0") = (long)(arg1); \
402__asm__ __volatile__ (\
403 "trap #" SYSCALL_VECTOR "|| nop"\
404 : "=r" (__res) \
405 : "r" (__scno), "0" (__res), "r" (__arg2), \
406 "r" (__arg3), "r" (__arg4), "r" (__arg5) \
407 : "memory"); \
408__syscall_return(type,__res); \
409}
410 299
411#define __ARCH_WANT_IPC_PARSE_VERSION 300#define __ARCH_WANT_IPC_PARSE_VERSION
412#define __ARCH_WANT_STAT64 301#define __ARCH_WANT_STAT64
diff --git a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h
index ad4348058c66..fdbb60e6a0d4 100644
--- a/include/asm-m68k/unistd.h
+++ b/include/asm-m68k/unistd.h
@@ -317,103 +317,6 @@
317#ifdef __KERNEL__ 317#ifdef __KERNEL__
318 318
319#define NR_syscalls 311 319#define NR_syscalls 311
320#include <linux/err.h>
321
322/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
323 <asm-m68k/errno.h> */
324
325#define __syscall_return(type, res) \
326do { \
327 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
328 /* avoid using res which is declared to be in register d0; \
329 errno might expand to a function call and clobber it. */ \
330 int __err = -(res); \
331 errno = __err; \
332 res = -1; \
333 } \
334 return (type) (res); \
335} while (0)
336
337#define _syscall0(type,name) \
338type name(void) \
339{ \
340register long __res __asm__ ("%d0") = __NR_##name; \
341__asm__ __volatile__ ("trap #0" \
342 : "+d" (__res) ); \
343__syscall_return(type,__res); \
344}
345
346#define _syscall1(type,name,atype,a) \
347type name(atype a) \
348{ \
349register long __res __asm__ ("%d0") = __NR_##name; \
350register long __a __asm__ ("%d1") = (long)(a); \
351__asm__ __volatile__ ("trap #0" \
352 : "+d" (__res) \
353 : "d" (__a) ); \
354__syscall_return(type,__res); \
355}
356
357#define _syscall2(type,name,atype,a,btype,b) \
358type name(atype a,btype b) \
359{ \
360register long __res __asm__ ("%d0") = __NR_##name; \
361register long __a __asm__ ("%d1") = (long)(a); \
362register long __b __asm__ ("%d2") = (long)(b); \
363__asm__ __volatile__ ("trap #0" \
364 : "+d" (__res) \
365 : "d" (__a), "d" (__b) \
366 ); \
367__syscall_return(type,__res); \
368}
369
370#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
371type name(atype a,btype b,ctype c) \
372{ \
373register long __res __asm__ ("%d0") = __NR_##name; \
374register long __a __asm__ ("%d1") = (long)(a); \
375register long __b __asm__ ("%d2") = (long)(b); \
376register long __c __asm__ ("%d3") = (long)(c); \
377__asm__ __volatile__ ("trap #0" \
378 : "+d" (__res) \
379 : "d" (__a), "d" (__b), \
380 "d" (__c) \
381 ); \
382__syscall_return(type,__res); \
383}
384
385#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
386type name (atype a, btype b, ctype c, dtype d) \
387{ \
388register long __res __asm__ ("%d0") = __NR_##name; \
389register long __a __asm__ ("%d1") = (long)(a); \
390register long __b __asm__ ("%d2") = (long)(b); \
391register long __c __asm__ ("%d3") = (long)(c); \
392register long __d __asm__ ("%d4") = (long)(d); \
393__asm__ __volatile__ ("trap #0" \
394 : "+d" (__res) \
395 : "d" (__a), "d" (__b), \
396 "d" (__c), "d" (__d) \
397 ); \
398__syscall_return(type,__res); \
399}
400
401#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
402type name (atype a,btype b,ctype c,dtype d,etype e) \
403{ \
404register long __res __asm__ ("%d0") = __NR_##name; \
405register long __a __asm__ ("%d1") = (long)(a); \
406register long __b __asm__ ("%d2") = (long)(b); \
407register long __c __asm__ ("%d3") = (long)(c); \
408register long __d __asm__ ("%d4") = (long)(d); \
409register long __e __asm__ ("%d5") = (long)(e); \
410__asm__ __volatile__ ("trap #0" \
411 : "+d" (__res) \
412 : "d" (__a), "d" (__b), \
413 "d" (__c), "d" (__d), "d" (__e) \
414 ); \
415__syscall_return(type,__res); \
416}
417 320
418#define __ARCH_WANT_IPC_PARSE_VERSION 321#define __ARCH_WANT_IPC_PARSE_VERSION
419#define __ARCH_WANT_OLD_READDIR 322#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h
index ebaf03197114..82e03195f325 100644
--- a/include/asm-m68knommu/unistd.h
+++ b/include/asm-m68knommu/unistd.h
@@ -318,156 +318,6 @@
318#ifdef __KERNEL__ 318#ifdef __KERNEL__
319 319
320#define NR_syscalls 311 320#define NR_syscalls 311
321#include <linux/err.h>
322
323/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
324 <asm-m68k/errno.h> */
325
326#define __syscall_return(type, res) \
327do { \
328 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
329 /* avoid using res which is declared to be in register d0; \
330 errno might expand to a function call and clobber it. */ \
331 int __err = -(res); \
332 errno = __err; \
333 res = -1; \
334 } \
335 return (type) (res); \
336} while (0)
337
338#define _syscall0(type, name) \
339type name(void) \
340{ \
341 long __res; \
342 __asm__ __volatile__ ("movel %1, %%d0\n\t" \
343 "trap #0\n\t" \
344 "movel %%d0, %0" \
345 : "=g" (__res) \
346 : "i" (__NR_##name) \
347 : "cc", "%d0"); \
348 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
349 errno = -__res; \
350 __res = -1; \
351 } \
352 return (type)__res; \
353}
354
355#define _syscall1(type, name, atype, a) \
356type name(atype a) \
357{ \
358 long __res; \
359 __asm__ __volatile__ ("movel %2, %%d1\n\t" \
360 "movel %1, %%d0\n\t" \
361 "trap #0\n\t" \
362 "movel %%d0, %0" \
363 : "=g" (__res) \
364 : "i" (__NR_##name), \
365 "g" ((long)a) \
366 : "cc", "%d0", "%d1"); \
367 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
368 errno = -__res; \
369 __res = -1; \
370 } \
371 return (type)__res; \
372}
373
374#define _syscall2(type, name, atype, a, btype, b) \
375type name(atype a, btype b) \
376{ \
377 long __res; \
378 __asm__ __volatile__ ("movel %3, %%d2\n\t" \
379 "movel %2, %%d1\n\t" \
380 "movel %1, %%d0\n\t" \
381 "trap #0\n\t" \
382 "movel %%d0, %0" \
383 : "=g" (__res) \
384 : "i" (__NR_##name), \
385 "a" ((long)a), \
386 "g" ((long)b) \
387 : "cc", "%d0", "%d1", "%d2"); \
388 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
389 errno = -__res; \
390 __res = -1; \
391 } \
392 return (type)__res; \
393}
394
395#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
396type name(atype a, btype b, ctype c) \
397{ \
398 long __res; \
399 __asm__ __volatile__ ("movel %4, %%d3\n\t" \
400 "movel %3, %%d2\n\t" \
401 "movel %2, %%d1\n\t" \
402 "movel %1, %%d0\n\t" \
403 "trap #0\n\t" \
404 "movel %%d0, %0" \
405 : "=g" (__res) \
406 : "i" (__NR_##name), \
407 "a" ((long)a), \
408 "a" ((long)b), \
409 "g" ((long)c) \
410 : "cc", "%d0", "%d1", "%d2", "%d3"); \
411 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
412 errno = -__res; \
413 __res = -1; \
414 } \
415 return (type)__res; \
416}
417
418#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
419type name(atype a, btype b, ctype c, dtype d) \
420{ \
421 long __res; \
422 __asm__ __volatile__ ("movel %5, %%d4\n\t" \
423 "movel %4, %%d3\n\t" \
424 "movel %3, %%d2\n\t" \
425 "movel %2, %%d1\n\t" \
426 "movel %1, %%d0\n\t" \
427 "trap #0\n\t" \
428 "movel %%d0, %0" \
429 : "=g" (__res) \
430 : "i" (__NR_##name), \
431 "a" ((long)a), \
432 "a" ((long)b), \
433 "a" ((long)c), \
434 "g" ((long)d) \
435 : "cc", "%d0", "%d1", "%d2", "%d3", \
436 "%d4"); \
437 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
438 errno = -__res; \
439 __res = -1; \
440 } \
441 return (type)__res; \
442}
443
444#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \
445type name(atype a, btype b, ctype c, dtype d, etype e) \
446{ \
447 long __res; \
448 __asm__ __volatile__ ("movel %6, %%d5\n\t" \
449 "movel %5, %%d4\n\t" \
450 "movel %4, %%d3\n\t" \
451 "movel %3, %%d2\n\t" \
452 "movel %2, %%d1\n\t" \
453 "movel %1, %%d0\n\t" \
454 "trap #0\n\t" \
455 "movel %%d0, %0" \
456 : "=g" (__res) \
457 : "i" (__NR_##name), \
458 "a" ((long)a), \
459 "a" ((long)b), \
460 "a" ((long)c), \
461 "a" ((long)d), \
462 "g" ((long)e) \
463 : "cc", "%d0", "%d1", "%d2", "%d3", \
464 "%d4", "%d5"); \
465 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
466 errno = -__res; \
467 __res = -1; \
468 } \
469 return (type)__res; \
470}
471 321
472#define __ARCH_WANT_IPC_PARSE_VERSION 322#define __ARCH_WANT_IPC_PARSE_VERSION
473#define __ARCH_WANT_OLD_READDIR 323#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index ec56aa52f669..696cff39a1d3 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -933,268 +933,6 @@
933 933
934#ifndef __ASSEMBLY__ 934#ifndef __ASSEMBLY__
935 935
936/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
937#define _syscall0(type,name) \
938type name(void) \
939{ \
940 register unsigned long __a3 asm("$7"); \
941 unsigned long __v0; \
942 \
943 __asm__ volatile ( \
944 ".set\tnoreorder\n\t" \
945 "li\t$2, %2\t\t\t# " #name "\n\t" \
946 "syscall\n\t" \
947 "move\t%0, $2\n\t" \
948 ".set\treorder" \
949 : "=&r" (__v0), "=r" (__a3) \
950 : "i" (__NR_##name) \
951 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
952 "memory"); \
953 \
954 if (__a3 == 0) \
955 return (type) __v0; \
956 errno = __v0; \
957 return (type) -1; \
958}
959
960/*
961 * DANGER: This macro isn't usable for the pipe(2) call
962 * which has a unusual return convention.
963 */
964#define _syscall1(type,name,atype,a) \
965type name(atype a) \
966{ \
967 register unsigned long __a0 asm("$4") = (unsigned long) a; \
968 register unsigned long __a3 asm("$7"); \
969 unsigned long __v0; \
970 \
971 __asm__ volatile ( \
972 ".set\tnoreorder\n\t" \
973 "li\t$2, %3\t\t\t# " #name "\n\t" \
974 "syscall\n\t" \
975 "move\t%0, $2\n\t" \
976 ".set\treorder" \
977 : "=&r" (__v0), "=r" (__a3) \
978 : "r" (__a0), "i" (__NR_##name) \
979 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
980 "memory"); \
981 \
982 if (__a3 == 0) \
983 return (type) __v0; \
984 errno = __v0; \
985 return (type) -1; \
986}
987
988#define _syscall2(type,name,atype,a,btype,b) \
989type name(atype a, btype b) \
990{ \
991 register unsigned long __a0 asm("$4") = (unsigned long) a; \
992 register unsigned long __a1 asm("$5") = (unsigned long) b; \
993 register unsigned long __a3 asm("$7"); \
994 unsigned long __v0; \
995 \
996 __asm__ volatile ( \
997 ".set\tnoreorder\n\t" \
998 "li\t$2, %4\t\t\t# " #name "\n\t" \
999 "syscall\n\t" \
1000 "move\t%0, $2\n\t" \
1001 ".set\treorder" \
1002 : "=&r" (__v0), "=r" (__a3) \
1003 : "r" (__a0), "r" (__a1), "i" (__NR_##name) \
1004 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1005 "memory"); \
1006 \
1007 if (__a3 == 0) \
1008 return (type) __v0; \
1009 errno = __v0; \
1010 return (type) -1; \
1011}
1012
1013#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
1014type name(atype a, btype b, ctype c) \
1015{ \
1016 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1017 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1018 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1019 register unsigned long __a3 asm("$7"); \
1020 unsigned long __v0; \
1021 \
1022 __asm__ volatile ( \
1023 ".set\tnoreorder\n\t" \
1024 "li\t$2, %5\t\t\t# " #name "\n\t" \
1025 "syscall\n\t" \
1026 "move\t%0, $2\n\t" \
1027 ".set\treorder" \
1028 : "=&r" (__v0), "=r" (__a3) \
1029 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
1030 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1031 "memory"); \
1032 \
1033 if (__a3 == 0) \
1034 return (type) __v0; \
1035 errno = __v0; \
1036 return (type) -1; \
1037}
1038
1039#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
1040type name(atype a, btype b, ctype c, dtype d) \
1041{ \
1042 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1043 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1044 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1045 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1046 unsigned long __v0; \
1047 \
1048 __asm__ volatile ( \
1049 ".set\tnoreorder\n\t" \
1050 "li\t$2, %5\t\t\t# " #name "\n\t" \
1051 "syscall\n\t" \
1052 "move\t%0, $2\n\t" \
1053 ".set\treorder" \
1054 : "=&r" (__v0), "+r" (__a3) \
1055 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
1056 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1057 "memory"); \
1058 \
1059 if (__a3 == 0) \
1060 return (type) __v0; \
1061 errno = __v0; \
1062 return (type) -1; \
1063}
1064
1065#if (_MIPS_SIM == _MIPS_SIM_ABI32)
1066
1067/*
1068 * Using those means your brain needs more than an oil change ;-)
1069 */
1070
1071#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
1072type name(atype a, btype b, ctype c, dtype d, etype e) \
1073{ \
1074 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1075 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1076 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1077 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1078 unsigned long __v0; \
1079 \
1080 __asm__ volatile ( \
1081 ".set\tnoreorder\n\t" \
1082 "lw\t$2, %6\n\t" \
1083 "subu\t$29, 32\n\t" \
1084 "sw\t$2, 16($29)\n\t" \
1085 "li\t$2, %5\t\t\t# " #name "\n\t" \
1086 "syscall\n\t" \
1087 "move\t%0, $2\n\t" \
1088 "addiu\t$29, 32\n\t" \
1089 ".set\treorder" \
1090 : "=&r" (__v0), "+r" (__a3) \
1091 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
1092 "m" ((unsigned long)e) \
1093 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1094 "memory"); \
1095 \
1096 if (__a3 == 0) \
1097 return (type) __v0; \
1098 errno = __v0; \
1099 return (type) -1; \
1100}
1101
1102#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
1103type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
1104{ \
1105 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1106 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1107 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1108 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1109 unsigned long __v0; \
1110 \
1111 __asm__ volatile ( \
1112 ".set\tnoreorder\n\t" \
1113 "lw\t$2, %6\n\t" \
1114 "lw\t$8, %7\n\t" \
1115 "subu\t$29, 32\n\t" \
1116 "sw\t$2, 16($29)\n\t" \
1117 "sw\t$8, 20($29)\n\t" \
1118 "li\t$2, %5\t\t\t# " #name "\n\t" \
1119 "syscall\n\t" \
1120 "move\t%0, $2\n\t" \
1121 "addiu\t$29, 32\n\t" \
1122 ".set\treorder" \
1123 : "=&r" (__v0), "+r" (__a3) \
1124 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
1125 "m" ((unsigned long)e), "m" ((unsigned long)f) \
1126 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1127 "memory"); \
1128 \
1129 if (__a3 == 0) \
1130 return (type) __v0; \
1131 errno = __v0; \
1132 return (type) -1; \
1133}
1134
1135#endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */
1136
1137#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
1138
1139#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
1140type name (atype a,btype b,ctype c,dtype d,etype e) \
1141{ \
1142 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1143 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1144 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1145 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1146 register unsigned long __a4 asm("$8") = (unsigned long) e; \
1147 unsigned long __v0; \
1148 \
1149 __asm__ volatile ( \
1150 ".set\tnoreorder\n\t" \
1151 "li\t$2, %6\t\t\t# " #name "\n\t" \
1152 "syscall\n\t" \
1153 "move\t%0, $2\n\t" \
1154 ".set\treorder" \
1155 : "=&r" (__v0), "+r" (__a3) \
1156 : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "i" (__NR_##name) \
1157 : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1158 "memory"); \
1159 \
1160 if (__a3 == 0) \
1161 return (type) __v0; \
1162 errno = __v0; \
1163 return (type) -1; \
1164}
1165
1166#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
1167type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
1168{ \
1169 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1170 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1171 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1172 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1173 register unsigned long __a4 asm("$8") = (unsigned long) e; \
1174 register unsigned long __a5 asm("$9") = (unsigned long) f; \
1175 unsigned long __v0; \
1176 \
1177 __asm__ volatile ( \
1178 ".set\tnoreorder\n\t" \
1179 "li\t$2, %7\t\t\t# " #name "\n\t" \
1180 "syscall\n\t" \
1181 "move\t%0, $2\n\t" \
1182 ".set\treorder" \
1183 : "=&r" (__v0), "+r" (__a3) \
1184 : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "r" (__a5), \
1185 "i" (__NR_##name) \
1186 : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1187 "memory"); \
1188 \
1189 if (__a3 == 0) \
1190 return (type) __v0; \
1191 errno = __v0; \
1192 return (type) -1; \
1193}
1194
1195#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
1196
1197
1198#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 936#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1199#define __ARCH_WANT_IPC_PARSE_VERSION 937#define __ARCH_WANT_IPC_PARSE_VERSION
1200#define __ARCH_WANT_OLD_READDIR 938#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
index 04b6c17cc59b..0ae954e3d258 100644
--- a/include/asm-powerpc/unistd.h
+++ b/include/asm-powerpc/unistd.h
@@ -334,115 +334,6 @@
334 334
335#ifndef __ASSEMBLY__ 335#ifndef __ASSEMBLY__
336 336
337/* On powerpc a system call basically clobbers the same registers like a
338 * function call, with the exception of LR (which is needed for the
339 * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal
340 * an error return status).
341 */
342
343#define __syscall_nr(nr, type, name, args...) \
344 unsigned long __sc_ret, __sc_err; \
345 { \
346 register unsigned long __sc_0 __asm__ ("r0"); \
347 register unsigned long __sc_3 __asm__ ("r3"); \
348 register unsigned long __sc_4 __asm__ ("r4"); \
349 register unsigned long __sc_5 __asm__ ("r5"); \
350 register unsigned long __sc_6 __asm__ ("r6"); \
351 register unsigned long __sc_7 __asm__ ("r7"); \
352 register unsigned long __sc_8 __asm__ ("r8"); \
353 \
354 __sc_loadargs_##nr(name, args); \
355 __asm__ __volatile__ \
356 ("sc \n\t" \
357 "mfcr %0 " \
358 : "=&r" (__sc_0), \
359 "=&r" (__sc_3), "=&r" (__sc_4), \
360 "=&r" (__sc_5), "=&r" (__sc_6), \
361 "=&r" (__sc_7), "=&r" (__sc_8) \
362 : __sc_asm_input_##nr \
363 : "cr0", "ctr", "memory", \
364 "r9", "r10","r11", "r12"); \
365 __sc_ret = __sc_3; \
366 __sc_err = __sc_0; \
367 } \
368 if (__sc_err & 0x10000000) \
369 { \
370 errno = __sc_ret; \
371 __sc_ret = -1; \
372 } \
373 return (type) __sc_ret
374
375#define __sc_loadargs_0(name, dummy...) \
376 __sc_0 = __NR_##name
377#define __sc_loadargs_1(name, arg1) \
378 __sc_loadargs_0(name); \
379 __sc_3 = (unsigned long) (arg1)
380#define __sc_loadargs_2(name, arg1, arg2) \
381 __sc_loadargs_1(name, arg1); \
382 __sc_4 = (unsigned long) (arg2)
383#define __sc_loadargs_3(name, arg1, arg2, arg3) \
384 __sc_loadargs_2(name, arg1, arg2); \
385 __sc_5 = (unsigned long) (arg3)
386#define __sc_loadargs_4(name, arg1, arg2, arg3, arg4) \
387 __sc_loadargs_3(name, arg1, arg2, arg3); \
388 __sc_6 = (unsigned long) (arg4)
389#define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5) \
390 __sc_loadargs_4(name, arg1, arg2, arg3, arg4); \
391 __sc_7 = (unsigned long) (arg5)
392#define __sc_loadargs_6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
393 __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5); \
394 __sc_8 = (unsigned long) (arg6)
395
396#define __sc_asm_input_0 "0" (__sc_0)
397#define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3)
398#define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4)
399#define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5)
400#define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6)
401#define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7)
402#define __sc_asm_input_6 __sc_asm_input_5, "6" (__sc_8)
403
404#define _syscall0(type,name) \
405type name(void) \
406{ \
407 __syscall_nr(0, type, name); \
408}
409
410#define _syscall1(type,name,type1,arg1) \
411type name(type1 arg1) \
412{ \
413 __syscall_nr(1, type, name, arg1); \
414}
415
416#define _syscall2(type,name,type1,arg1,type2,arg2) \
417type name(type1 arg1, type2 arg2) \
418{ \
419 __syscall_nr(2, type, name, arg1, arg2); \
420}
421
422#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
423type name(type1 arg1, type2 arg2, type3 arg3) \
424{ \
425 __syscall_nr(3, type, name, arg1, arg2, arg3); \
426}
427
428#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
429type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
430{ \
431 __syscall_nr(4, type, name, arg1, arg2, arg3, arg4); \
432}
433
434#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
435type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
436{ \
437 __syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5); \
438}
439#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
440type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
441{ \
442 __syscall_nr(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6); \
443}
444
445
446#include <linux/types.h> 337#include <linux/types.h>
447#include <linux/compiler.h> 338#include <linux/compiler.h>
448#include <linux/linkage.h> 339#include <linux/linkage.h>
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index 71d3c21b84f0..fb6fef97d739 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -345,160 +345,6 @@
345 345
346#ifdef __KERNEL__ 346#ifdef __KERNEL__
347 347
348#include <linux/err.h>
349
350#define __syscall_return(type, res) \
351do { \
352 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
353 errno = -(res); \
354 res = -1; \
355 } \
356 return (type) (res); \
357} while (0)
358
359#define _svc_clobber "1", "cc", "memory"
360
361#define _syscall0(type,name) \
362type name(void) { \
363 register long __svcres asm("2"); \
364 long __res; \
365 asm volatile( \
366 " .if %1 < 256\n" \
367 " svc %b1\n" \
368 " .else\n" \
369 " la %%r1,%1\n" \
370 " svc 0\n" \
371 " .endif" \
372 : "=d" (__svcres) \
373 : "i" (__NR_##name) \
374 : _svc_clobber); \
375 __res = __svcres; \
376 __syscall_return(type,__res); \
377}
378
379#define _syscall1(type,name,type1,arg1) \
380type name(type1 arg1) { \
381 register type1 __arg1 asm("2") = arg1; \
382 register long __svcres asm("2"); \
383 long __res; \
384 asm volatile( \
385 " .if %1 < 256\n" \
386 " svc %b1\n" \
387 " .else\n" \
388 " la %%r1,%1\n" \
389 " svc 0\n" \
390 " .endif" \
391 : "=d" (__svcres) \
392 : "i" (__NR_##name), \
393 "0" (__arg1) \
394 : _svc_clobber); \
395 __res = __svcres; \
396 __syscall_return(type,__res); \
397}
398
399#define _syscall2(type,name,type1,arg1,type2,arg2) \
400type name(type1 arg1, type2 arg2) { \
401 register type1 __arg1 asm("2") = arg1; \
402 register type2 __arg2 asm("3") = arg2; \
403 register long __svcres asm("2"); \
404 long __res; \
405 asm volatile( \
406 " .if %1 < 256\n" \
407 " svc %b1\n" \
408 " .else\n" \
409 " la %%r1,%1\n" \
410 " svc 0\n" \
411 " .endif" \
412 : "=d" (__svcres) \
413 : "i" (__NR_##name), \
414 "0" (__arg1), \
415 "d" (__arg2) \
416 : _svc_clobber ); \
417 __res = __svcres; \
418 __syscall_return(type,__res); \
419}
420
421#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
422type name(type1 arg1, type2 arg2, type3 arg3) { \
423 register type1 __arg1 asm("2") = arg1; \
424 register type2 __arg2 asm("3") = arg2; \
425 register type3 __arg3 asm("4") = arg3; \
426 register long __svcres asm("2"); \
427 long __res; \
428 asm volatile( \
429 " .if %1 < 256\n" \
430 " svc %b1\n" \
431 " .else\n" \
432 " la %%r1,%1\n" \
433 " svc 0\n" \
434 " .endif" \
435 : "=d" (__svcres) \
436 : "i" (__NR_##name), \
437 "0" (__arg1), \
438 "d" (__arg2), \
439 "d" (__arg3) \
440 : _svc_clobber); \
441 __res = __svcres; \
442 __syscall_return(type,__res); \
443}
444
445#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3, \
446 type4,name4) \
447type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
448 register type1 __arg1 asm("2") = arg1; \
449 register type2 __arg2 asm("3") = arg2; \
450 register type3 __arg3 asm("4") = arg3; \
451 register type4 __arg4 asm("5") = arg4; \
452 register long __svcres asm("2"); \
453 long __res; \
454 asm volatile( \
455 " .if %1 < 256\n" \
456 " svc %b1\n" \
457 " .else\n" \
458 " la %%r1,%1\n" \
459 " svc 0\n" \
460 " .endif" \
461 : "=d" (__svcres) \
462 : "i" (__NR_##name), \
463 "0" (__arg1), \
464 "d" (__arg2), \
465 "d" (__arg3), \
466 "d" (__arg4) \
467 : _svc_clobber); \
468 __res = __svcres; \
469 __syscall_return(type,__res); \
470}
471
472#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3, \
473 type4,name4,type5,name5) \
474type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
475 type5 arg5) { \
476 register type1 __arg1 asm("2") = arg1; \
477 register type2 __arg2 asm("3") = arg2; \
478 register type3 __arg3 asm("4") = arg3; \
479 register type4 __arg4 asm("5") = arg4; \
480 register type5 __arg5 asm("6") = arg5; \
481 register long __svcres asm("2"); \
482 long __res; \
483 asm volatile( \
484 " .if %1 < 256\n" \
485 " svc %b1\n" \
486 " .else\n" \
487 " la %%r1,%1\n" \
488 " svc 0\n" \
489 " .endif" \
490 : "=d" (__svcres) \
491 : "i" (__NR_##name), \
492 "0" (__arg1), \
493 "d" (__arg2), \
494 "d" (__arg3), \
495 "d" (__arg4), \
496 "d" (__arg5) \
497 : _svc_clobber); \
498 __res = __svcres; \
499 __syscall_return(type,__res); \
500}
501
502#define __ARCH_WANT_IPC_PARSE_VERSION 348#define __ARCH_WANT_IPC_PARSE_VERSION
503#define __ARCH_WANT_OLD_READDIR 349#define __ARCH_WANT_OLD_READDIR
504#define __ARCH_WANT_SYS_ALARM 350#define __ARCH_WANT_SYS_ALARM
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index 0cae1d248761..f982073dc6c6 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -332,143 +332,6 @@
332 332
333#ifdef __KERNEL__ 333#ifdef __KERNEL__
334 334
335#include <linux/err.h>
336
337/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
338 * see <asm-sh/errno.h> */
339
340#define __syscall_return(type, res) \
341do { \
342 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
343 /* Avoid using "res" which is declared to be in register r0; \
344 errno might expand to a function call and clobber it. */ \
345 int __err = -(res); \
346 errno = __err; \
347 res = -1; \
348 } \
349 return (type) (res); \
350} while (0)
351
352#if defined(__sh2__) || defined(__SH2E__) || defined(__SH2A__)
353#define SYSCALL_ARG0 "trapa #0x20"
354#define SYSCALL_ARG1 "trapa #0x21"
355#define SYSCALL_ARG2 "trapa #0x22"
356#define SYSCALL_ARG3 "trapa #0x23"
357#define SYSCALL_ARG4 "trapa #0x24"
358#define SYSCALL_ARG5 "trapa #0x25"
359#define SYSCALL_ARG6 "trapa #0x26"
360#else
361#define SYSCALL_ARG0 "trapa #0x10"
362#define SYSCALL_ARG1 "trapa #0x11"
363#define SYSCALL_ARG2 "trapa #0x12"
364#define SYSCALL_ARG3 "trapa #0x13"
365#define SYSCALL_ARG4 "trapa #0x14"
366#define SYSCALL_ARG5 "trapa #0x15"
367#define SYSCALL_ARG6 "trapa #0x16"
368#endif
369
370/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
371#define _syscall0(type,name) \
372type name(void) \
373{ \
374register long __sc0 __asm__ ("r3") = __NR_##name; \
375__asm__ __volatile__ (SYSCALL_ARG0 \
376 : "=z" (__sc0) \
377 : "0" (__sc0) \
378 : "memory" ); \
379__syscall_return(type,__sc0); \
380}
381
382#define _syscall1(type,name,type1,arg1) \
383type name(type1 arg1) \
384{ \
385register long __sc0 __asm__ ("r3") = __NR_##name; \
386register long __sc4 __asm__ ("r4") = (long) arg1; \
387__asm__ __volatile__ (SYSCALL_ARG1 \
388 : "=z" (__sc0) \
389 : "0" (__sc0), "r" (__sc4) \
390 : "memory"); \
391__syscall_return(type,__sc0); \
392}
393
394#define _syscall2(type,name,type1,arg1,type2,arg2) \
395type name(type1 arg1,type2 arg2) \
396{ \
397register long __sc0 __asm__ ("r3") = __NR_##name; \
398register long __sc4 __asm__ ("r4") = (long) arg1; \
399register long __sc5 __asm__ ("r5") = (long) arg2; \
400__asm__ __volatile__ (SYSCALL_ARG2 \
401 : "=z" (__sc0) \
402 : "0" (__sc0), "r" (__sc4), "r" (__sc5) \
403 : "memory"); \
404__syscall_return(type,__sc0); \
405}
406
407#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
408type name(type1 arg1,type2 arg2,type3 arg3) \
409{ \
410register long __sc0 __asm__ ("r3") = __NR_##name; \
411register long __sc4 __asm__ ("r4") = (long) arg1; \
412register long __sc5 __asm__ ("r5") = (long) arg2; \
413register long __sc6 __asm__ ("r6") = (long) arg3; \
414__asm__ __volatile__ (SYSCALL_ARG3 \
415 : "=z" (__sc0) \
416 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \
417 : "memory"); \
418__syscall_return(type,__sc0); \
419}
420
421#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
422type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
423{ \
424register long __sc0 __asm__ ("r3") = __NR_##name; \
425register long __sc4 __asm__ ("r4") = (long) arg1; \
426register long __sc5 __asm__ ("r5") = (long) arg2; \
427register long __sc6 __asm__ ("r6") = (long) arg3; \
428register long __sc7 __asm__ ("r7") = (long) arg4; \
429__asm__ __volatile__ (SYSCALL_ARG4 \
430 : "=z" (__sc0) \
431 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), \
432 "r" (__sc7) \
433 : "memory" ); \
434__syscall_return(type,__sc0); \
435}
436
437#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
438type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
439{ \
440register long __sc3 __asm__ ("r3") = __NR_##name; \
441register long __sc4 __asm__ ("r4") = (long) arg1; \
442register long __sc5 __asm__ ("r5") = (long) arg2; \
443register long __sc6 __asm__ ("r6") = (long) arg3; \
444register long __sc7 __asm__ ("r7") = (long) arg4; \
445register long __sc0 __asm__ ("r0") = (long) arg5; \
446__asm__ __volatile__ (SYSCALL_ARG5 \
447 : "=z" (__sc0) \
448 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
449 "r" (__sc3) \
450 : "memory" ); \
451__syscall_return(type,__sc0); \
452}
453
454#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
455type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
456{ \
457register long __sc3 __asm__ ("r3") = __NR_##name; \
458register long __sc4 __asm__ ("r4") = (long) arg1; \
459register long __sc5 __asm__ ("r5") = (long) arg2; \
460register long __sc6 __asm__ ("r6") = (long) arg3; \
461register long __sc7 __asm__ ("r7") = (long) arg4; \
462register long __sc0 __asm__ ("r0") = (long) arg5; \
463register long __sc1 __asm__ ("r1") = (long) arg6; \
464__asm__ __volatile__ (SYSCALL_ARG6 \
465 : "=z" (__sc0) \
466 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
467 "r" (__sc3), "r" (__sc1) \
468 : "memory" ); \
469__syscall_return(type,__sc0); \
470}
471
472#define __ARCH_WANT_IPC_PARSE_VERSION 335#define __ARCH_WANT_IPC_PARSE_VERSION
473#define __ARCH_WANT_OLD_READDIR 336#define __ARCH_WANT_OLD_READDIR
474#define __ARCH_WANT_OLD_STAT 337#define __ARCH_WANT_OLD_STAT
diff --git a/include/asm-sh64/unistd.h b/include/asm-sh64/unistd.h
index ee7828b27ad1..1f38a7aacaaf 100644
--- a/include/asm-sh64/unistd.h
+++ b/include/asm-sh64/unistd.h
@@ -347,148 +347,6 @@
347#ifdef __KERNEL__ 347#ifdef __KERNEL__
348 348
349#define NR_syscalls 321 349#define NR_syscalls 321
350#include <linux/err.h>
351
352/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
353 * see <asm-sh64/errno.h> */
354
355#define __syscall_return(type, res) \
356do { \
357 /* Note: when returning from kernel the return value is in r9 \
358 ** This prevents conflicts between return value and arg1 \
359 ** when dispatching signal handler, in other words makes \
360 ** life easier in the system call epilogue (see entry.S) \
361 */ \
362 register unsigned long __sr2 __asm__ ("r2") = res; \
363 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
364 errno = -(res); \
365 __sr2 = -1; \
366 } \
367 return (type) (__sr2); \
368} while (0)
369
370/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
371
372#define _syscall0(type,name) \
373type name(void) \
374{ \
375register unsigned long __sc0 __asm__ ("r9") = ((0x10 << 16) | __NR_##name); \
376__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "()" \
377 : "=r" (__sc0) \
378 : "r" (__sc0) ); \
379__syscall_return(type,__sc0); \
380}
381
382 /*
383 * The apparent spurious "dummy" assembler comment is *needed*,
384 * as without it, the compiler treats the arg<n> variables
385 * as no longer live just before the asm. The compiler can
386 * then optimize the storage into any registers it wishes.
387 * The additional dummy statement forces the compiler to put
388 * the arguments into the correct registers before the TRAPA.
389 */
390#define _syscall1(type,name,type1,arg1) \
391type name(type1 arg1) \
392{ \
393register unsigned long __sc0 __asm__ ("r9") = ((0x11 << 16) | __NR_##name); \
394register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
395__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2)" \
396 : "=r" (__sc0) \
397 : "r" (__sc0), "r" (__sc2)); \
398__asm__ __volatile__ ("!dummy %0 %1" \
399 : \
400 : "r" (__sc0), "r" (__sc2)); \
401__syscall_return(type,__sc0); \
402}
403
404#define _syscall2(type,name,type1,arg1,type2,arg2) \
405type name(type1 arg1,type2 arg2) \
406{ \
407register unsigned long __sc0 __asm__ ("r9") = ((0x12 << 16) | __NR_##name); \
408register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
409register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
410__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3)" \
411 : "=r" (__sc0) \
412 : "r" (__sc0), "r" (__sc2), "r" (__sc3) ); \
413__asm__ __volatile__ ("!dummy %0 %1 %2" \
414 : \
415 : "r" (__sc0), "r" (__sc2), "r" (__sc3) ); \
416__syscall_return(type,__sc0); \
417}
418
419#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
420type name(type1 arg1,type2 arg2,type3 arg3) \
421{ \
422register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_##name); \
423register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
424register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
425register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
426__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4)" \
427 : "=r" (__sc0) \
428 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) ); \
429__asm__ __volatile__ ("!dummy %0 %1 %2 %3" \
430 : \
431 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) ); \
432__syscall_return(type,__sc0); \
433}
434
435#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
436type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
437{ \
438register unsigned long __sc0 __asm__ ("r9") = ((0x14 << 16) | __NR_##name); \
439register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
440register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
441register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
442register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
443__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5)" \
444 : "=r" (__sc0) \
445 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
446__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4" \
447 : \
448 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
449__syscall_return(type,__sc0); \
450}
451
452#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
453type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
454{ \
455register unsigned long __sc0 __asm__ ("r9") = ((0x15 << 16) | __NR_##name); \
456register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
457register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
458register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
459register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
460register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5; \
461__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5,%6)" \
462 : "=r" (__sc0) \
463 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
464 "r" (__sc6)); \
465__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4 %5" \
466 : \
467 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
468 "r" (__sc6)); \
469__syscall_return(type,__sc0); \
470}
471
472#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
473type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
474{ \
475register unsigned long __sc0 __asm__ ("r9") = ((0x16 << 16) | __NR_##name); \
476register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
477register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
478register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
479register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
480register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5; \
481register unsigned long __sc7 __asm__ ("r7") = (unsigned long) arg6; \
482__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5,%6,%7)" \
483 : "=r" (__sc0) \
484 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
485 "r" (__sc6), "r" (__sc7)); \
486__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4 %5 %6" \
487 : \
488 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
489 "r" (__sc6), "r" (__sc7)); \
490__syscall_return(type,__sc0); \
491}
492 350
493#define __ARCH_WANT_IPC_PARSE_VERSION 351#define __ARCH_WANT_IPC_PARSE_VERSION
494#define __ARCH_WANT_OLD_READDIR 352#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
index f7827fa4cd5e..d5b2f8053b3b 100644
--- a/include/asm-sparc/unistd.h
+++ b/include/asm-sparc/unistd.h
@@ -329,136 +329,6 @@
329 * find a free slot in the 0-302 range. 329 * find a free slot in the 0-302 range.
330 */ 330 */
331 331
332#define _syscall0(type,name) \
333type name(void) \
334{ \
335long __res; \
336register long __g1 __asm__ ("g1") = __NR_##name; \
337__asm__ __volatile__ ("t 0x10\n\t" \
338 "bcc 1f\n\t" \
339 "mov %%o0, %0\n\t" \
340 "sub %%g0, %%o0, %0\n\t" \
341 "1:\n\t" \
342 : "=r" (__res)\
343 : "r" (__g1) \
344 : "o0", "cc"); \
345if (__res < -255 || __res >= 0) \
346 return (type) __res; \
347errno = -__res; \
348return -1; \
349}
350
351#define _syscall1(type,name,type1,arg1) \
352type name(type1 arg1) \
353{ \
354long __res; \
355register long __g1 __asm__ ("g1") = __NR_##name; \
356register long __o0 __asm__ ("o0") = (long)(arg1); \
357__asm__ __volatile__ ("t 0x10\n\t" \
358 "bcc 1f\n\t" \
359 "mov %%o0, %0\n\t" \
360 "sub %%g0, %%o0, %0\n\t" \
361 "1:\n\t" \
362 : "=r" (__res), "=&r" (__o0) \
363 : "1" (__o0), "r" (__g1) \
364 : "cc"); \
365if (__res < -255 || __res >= 0) \
366 return (type) __res; \
367errno = -__res; \
368return -1; \
369}
370
371#define _syscall2(type,name,type1,arg1,type2,arg2) \
372type name(type1 arg1,type2 arg2) \
373{ \
374long __res; \
375register long __g1 __asm__ ("g1") = __NR_##name; \
376register long __o0 __asm__ ("o0") = (long)(arg1); \
377register long __o1 __asm__ ("o1") = (long)(arg2); \
378__asm__ __volatile__ ("t 0x10\n\t" \
379 "bcc 1f\n\t" \
380 "mov %%o0, %0\n\t" \
381 "sub %%g0, %%o0, %0\n\t" \
382 "1:\n\t" \
383 : "=r" (__res), "=&r" (__o0) \
384 : "1" (__o0), "r" (__o1), "r" (__g1) \
385 : "cc"); \
386if (__res < -255 || __res >= 0) \
387 return (type) __res; \
388errno = -__res; \
389return -1; \
390}
391
392#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
393type name(type1 arg1,type2 arg2,type3 arg3) \
394{ \
395long __res; \
396register long __g1 __asm__ ("g1") = __NR_##name; \
397register long __o0 __asm__ ("o0") = (long)(arg1); \
398register long __o1 __asm__ ("o1") = (long)(arg2); \
399register long __o2 __asm__ ("o2") = (long)(arg3); \
400__asm__ __volatile__ ("t 0x10\n\t" \
401 "bcc 1f\n\t" \
402 "mov %%o0, %0\n\t" \
403 "sub %%g0, %%o0, %0\n\t" \
404 "1:\n\t" \
405 : "=r" (__res), "=&r" (__o0) \
406 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
407 : "cc"); \
408if (__res < -255 || __res>=0) \
409 return (type) __res; \
410errno = -__res; \
411return -1; \
412}
413
414#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
415type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
416{ \
417long __res; \
418register long __g1 __asm__ ("g1") = __NR_##name; \
419register long __o0 __asm__ ("o0") = (long)(arg1); \
420register long __o1 __asm__ ("o1") = (long)(arg2); \
421register long __o2 __asm__ ("o2") = (long)(arg3); \
422register long __o3 __asm__ ("o3") = (long)(arg4); \
423__asm__ __volatile__ ("t 0x10\n\t" \
424 "bcc 1f\n\t" \
425 "mov %%o0, %0\n\t" \
426 "sub %%g0, %%o0, %0\n\t" \
427 "1:\n\t" \
428 : "=r" (__res), "=&r" (__o0) \
429 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
430 : "cc"); \
431if (__res < -255 || __res>=0) \
432 return (type) __res; \
433errno = -__res; \
434return -1; \
435}
436
437#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
438 type5,arg5) \
439type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
440{ \
441long __res; \
442register long __g1 __asm__ ("g1") = __NR_##name; \
443register long __o0 __asm__ ("o0") = (long)(arg1); \
444register long __o1 __asm__ ("o1") = (long)(arg2); \
445register long __o2 __asm__ ("o2") = (long)(arg3); \
446register long __o3 __asm__ ("o3") = (long)(arg4); \
447register long __o4 __asm__ ("o4") = (long)(arg5); \
448__asm__ __volatile__ ("t 0x10\n\t" \
449 "bcc 1f\n\t" \
450 "mov %%o0, %0\n\t" \
451 "sub %%g0, %%o0, %0\n\t" \
452 "1:\n\t" \
453 : "=r" (__res), "=&r" (__o0) \
454 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
455 : "cc"); \
456if (__res < -255 || __res>=0) \
457 return (type) __res; \
458errno = -__res; \
459return -1; \
460}
461
462#define __ARCH_WANT_IPC_PARSE_VERSION 332#define __ARCH_WANT_IPC_PARSE_VERSION
463#define __ARCH_WANT_OLD_READDIR 333#define __ARCH_WANT_OLD_READDIR
464#define __ARCH_WANT_STAT64 334#define __ARCH_WANT_STAT64
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
index 63669dad0d72..47047536f261 100644
--- a/include/asm-sparc64/unistd.h
+++ b/include/asm-sparc64/unistd.h
@@ -332,124 +332,6 @@
332 * find a free slot in the 0-302 range. 332 * find a free slot in the 0-302 range.
333 */ 333 */
334 334
335#define _syscall0(type,name) \
336type name(void) \
337{ \
338long __res; \
339register long __g1 __asm__ ("g1") = __NR_##name; \
340__asm__ __volatile__ ("t 0x6d\n\t" \
341 "sub %%g0, %%o0, %0\n\t" \
342 "movcc %%xcc, %%o0, %0\n\t" \
343 : "=r" (__res)\
344 : "r" (__g1) \
345 : "o0", "cc"); \
346if (__res >= 0) \
347 return (type) __res; \
348errno = -__res; \
349return -1; \
350}
351
352#define _syscall1(type,name,type1,arg1) \
353type name(type1 arg1) \
354{ \
355long __res; \
356register long __g1 __asm__ ("g1") = __NR_##name; \
357register long __o0 __asm__ ("o0") = (long)(arg1); \
358__asm__ __volatile__ ("t 0x6d\n\t" \
359 "sub %%g0, %%o0, %0\n\t" \
360 "movcc %%xcc, %%o0, %0\n\t" \
361 : "=r" (__res), "=&r" (__o0) \
362 : "1" (__o0), "r" (__g1) \
363 : "cc"); \
364if (__res >= 0) \
365 return (type) __res; \
366errno = -__res; \
367return -1; \
368}
369
370#define _syscall2(type,name,type1,arg1,type2,arg2) \
371type name(type1 arg1,type2 arg2) \
372{ \
373long __res; \
374register long __g1 __asm__ ("g1") = __NR_##name; \
375register long __o0 __asm__ ("o0") = (long)(arg1); \
376register long __o1 __asm__ ("o1") = (long)(arg2); \
377__asm__ __volatile__ ("t 0x6d\n\t" \
378 "sub %%g0, %%o0, %0\n\t" \
379 "movcc %%xcc, %%o0, %0\n\t" \
380 : "=r" (__res), "=&r" (__o0) \
381 : "1" (__o0), "r" (__o1), "r" (__g1) \
382 : "cc"); \
383if (__res >= 0) \
384 return (type) __res; \
385errno = -__res; \
386return -1; \
387}
388
389#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
390type name(type1 arg1,type2 arg2,type3 arg3) \
391{ \
392long __res; \
393register long __g1 __asm__ ("g1") = __NR_##name; \
394register long __o0 __asm__ ("o0") = (long)(arg1); \
395register long __o1 __asm__ ("o1") = (long)(arg2); \
396register long __o2 __asm__ ("o2") = (long)(arg3); \
397__asm__ __volatile__ ("t 0x6d\n\t" \
398 "sub %%g0, %%o0, %0\n\t" \
399 "movcc %%xcc, %%o0, %0\n\t" \
400 : "=r" (__res), "=&r" (__o0) \
401 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
402 : "cc"); \
403if (__res>=0) \
404 return (type) __res; \
405errno = -__res; \
406return -1; \
407}
408
409#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
410type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
411{ \
412long __res; \
413register long __g1 __asm__ ("g1") = __NR_##name; \
414register long __o0 __asm__ ("o0") = (long)(arg1); \
415register long __o1 __asm__ ("o1") = (long)(arg2); \
416register long __o2 __asm__ ("o2") = (long)(arg3); \
417register long __o3 __asm__ ("o3") = (long)(arg4); \
418__asm__ __volatile__ ("t 0x6d\n\t" \
419 "sub %%g0, %%o0, %0\n\t" \
420 "movcc %%xcc, %%o0, %0\n\t" \
421 : "=r" (__res), "=&r" (__o0) \
422 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
423 : "cc"); \
424if (__res>=0) \
425 return (type) __res; \
426errno = -__res; \
427return -1; \
428}
429
430#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
431 type5,arg5) \
432type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
433{ \
434long __res; \
435register long __g1 __asm__ ("g1") = __NR_##name; \
436register long __o0 __asm__ ("o0") = (long)(arg1); \
437register long __o1 __asm__ ("o1") = (long)(arg2); \
438register long __o2 __asm__ ("o2") = (long)(arg3); \
439register long __o3 __asm__ ("o3") = (long)(arg4); \
440register long __o4 __asm__ ("o4") = (long)(arg5); \
441__asm__ __volatile__ ("t 0x6d\n\t" \
442 "sub %%g0, %%o0, %0\n\t" \
443 "movcc %%xcc, %%o0, %0\n\t" \
444 : "=r" (__res), "=&r" (__o0) \
445 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
446 : "cc"); \
447if (__res>=0) \
448 return (type) __res; \
449errno = -__res; \
450return -1; \
451}
452
453/* sysconf options, for SunOS compatibility */ 335/* sysconf options, for SunOS compatibility */
454#define _SC_ARG_MAX 1 336#define _SC_ARG_MAX 1
455#define _SC_CHILD_MAX 2 337#define _SC_CHILD_MAX 2
diff --git a/include/asm-v850/unistd.h b/include/asm-v850/unistd.h
index 737401e7d3ad..2241ed45ecfe 100644
--- a/include/asm-v850/unistd.h
+++ b/include/asm-v850/unistd.h
@@ -204,168 +204,8 @@
204#define __NR_gettid 201 204#define __NR_gettid 201
205#define __NR_tkill 202 205#define __NR_tkill 202
206 206
207
208/* Syscall protocol:
209 Syscall number in r12, args in r6-r9, r13-r14
210 Return value in r10
211 Trap 0 for `short' syscalls, where all the args can fit in function
212 call argument registers, and trap 1 when there are additional args in
213 r13-r14. */
214
215#define SYSCALL_NUM "r12"
216#define SYSCALL_ARG0 "r6"
217#define SYSCALL_ARG1 "r7"
218#define SYSCALL_ARG2 "r8"
219#define SYSCALL_ARG3 "r9"
220#define SYSCALL_ARG4 "r13"
221#define SYSCALL_ARG5 "r14"
222#define SYSCALL_RET "r10"
223
224#define SYSCALL_SHORT_TRAP "0"
225#define SYSCALL_LONG_TRAP "1"
226
227/* Registers clobbered by any syscall. This _doesn't_ include the syscall
228 number (r12) or the `extended arg' registers (r13, r14), even though
229 they are actually clobbered too (this is because gcc's `asm' statement
230 doesn't allow a clobber to be used as an input or output). */
231#define SYSCALL_CLOBBERS "r1", "r5", "r11", "r15", "r16", \
232 "r17", "r18", "r19"
233
234/* Registers clobbered by a `short' syscall. This includes all clobbers
235 except the syscall number (r12). */
236#define SYSCALL_SHORT_CLOBBERS SYSCALL_CLOBBERS, "r13", "r14"
237
238#ifdef __KERNEL__ 207#ifdef __KERNEL__
239 208
240#include <asm/clinkage.h>
241#include <linux/err.h>
242
243#define __syscall_return(type, res) \
244 do { \
245 /* user-visible error numbers are in the range -1 - -MAX_ERRNO: \
246 see <asm-v850/errno.h> */ \
247 if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO), 0)) { \
248 errno = -(res); \
249 res = -1; \
250 } \
251 return (type) (res); \
252 } while (0)
253
254
255#define _syscall0(type, name) \
256type name (void) \
257{ \
258 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
259 register unsigned long __ret __asm__ (SYSCALL_RET); \
260 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
261 : "=r" (__ret), "=r" (__syscall) \
262 : "1" (__syscall) \
263 : SYSCALL_SHORT_CLOBBERS); \
264 __syscall_return (type, __ret); \
265}
266
267#define _syscall1(type, name, atype, a) \
268type name (atype a) \
269{ \
270 register atype __a __asm__ (SYSCALL_ARG0) = a; \
271 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
272 register unsigned long __ret __asm__ (SYSCALL_RET); \
273 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
274 : "=r" (__ret), "=r" (__syscall) \
275 : "1" (__syscall), "r" (__a) \
276 : SYSCALL_SHORT_CLOBBERS); \
277 __syscall_return (type, __ret); \
278}
279
280#define _syscall2(type, name, atype, a, btype, b) \
281type name (atype a, btype b) \
282{ \
283 register atype __a __asm__ (SYSCALL_ARG0) = a; \
284 register btype __b __asm__ (SYSCALL_ARG1) = b; \
285 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
286 register unsigned long __ret __asm__ (SYSCALL_RET); \
287 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
288 : "=r" (__ret), "=r" (__syscall) \
289 : "1" (__syscall), "r" (__a), "r" (__b) \
290 : SYSCALL_SHORT_CLOBBERS); \
291 __syscall_return (type, __ret); \
292}
293
294#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
295type name (atype a, btype b, ctype c) \
296{ \
297 register atype __a __asm__ (SYSCALL_ARG0) = a; \
298 register btype __b __asm__ (SYSCALL_ARG1) = b; \
299 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
300 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
301 register unsigned long __ret __asm__ (SYSCALL_RET); \
302 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
303 : "=r" (__ret), "=r" (__syscall) \
304 : "1" (__syscall), "r" (__a), "r" (__b), "r" (__c) \
305 : SYSCALL_SHORT_CLOBBERS); \
306 __syscall_return (type, __ret); \
307}
308
309#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
310type name (atype a, btype b, ctype c, dtype d) \
311{ \
312 register atype __a __asm__ (SYSCALL_ARG0) = a; \
313 register btype __b __asm__ (SYSCALL_ARG1) = b; \
314 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
315 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
316 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
317 register unsigned long __ret __asm__ (SYSCALL_RET); \
318 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
319 : "=r" (__ret), "=r" (__syscall) \
320 : "1" (__syscall), \
321 "r" (__a), "r" (__b), "r" (__c), "r" (__d) \
322 : SYSCALL_SHORT_CLOBBERS); \
323 __syscall_return (type, __ret); \
324}
325
326#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype,e)\
327type name (atype a, btype b, ctype c, dtype d, etype e) \
328{ \
329 register atype __a __asm__ (SYSCALL_ARG0) = a; \
330 register btype __b __asm__ (SYSCALL_ARG1) = b; \
331 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
332 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
333 register etype __e __asm__ (SYSCALL_ARG4) = e; \
334 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
335 register unsigned long __ret __asm__ (SYSCALL_RET); \
336 __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \
337 : "=r" (__ret), "=r" (__syscall), "=r" (__e) \
338 : "1" (__syscall), \
339 "r" (__a), "r" (__b), "r" (__c), "r" (__d), "2" (__e) \
340 : SYSCALL_CLOBBERS); \
341 __syscall_return (type, __ret); \
342}
343
344#define __SYSCALL6_TRAP(syscall, ret, a, b, c, d, e, f) \
345 __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \
346 : "=r" (ret), "=r" (syscall), \
347 "=r" (e), "=r" (f) \
348 : "1" (syscall), \
349 "r" (a), "r" (b), "r" (c), "r" (d), \
350 "2" (e), "3" (f) \
351 : SYSCALL_CLOBBERS);
352
353#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
354type name (atype a, btype b, ctype c, dtype d, etype e, ftype f) \
355{ \
356 register atype __a __asm__ (SYSCALL_ARG0) = a; \
357 register btype __b __asm__ (SYSCALL_ARG1) = b; \
358 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
359 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
360 register etype __e __asm__ (SYSCALL_ARG4) = e; \
361 register etype __f __asm__ (SYSCALL_ARG5) = f; \
362 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
363 register unsigned long __ret __asm__ (SYSCALL_RET); \
364 __SYSCALL6_TRAP(__syscall, __ret, __a, __b, __c, __d, __e, __f); \
365 __syscall_return (type, __ret); \
366}
367
368
369#define __ARCH_WANT_IPC_PARSE_VERSION 209#define __ARCH_WANT_IPC_PARSE_VERSION
370#define __ARCH_WANT_OLD_READDIR 210#define __ARCH_WANT_OLD_READDIR
371#define __ARCH_WANT_STAT64 211#define __ARCH_WANT_STAT64
diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h
index 777288eb7e75..c5f596e71faa 100644
--- a/include/asm-x86_64/unistd.h
+++ b/include/asm-x86_64/unistd.h
@@ -622,25 +622,7 @@ __SYSCALL(__NR_move_pages, sys_move_pages)
622 622
623#define __NR_syscall_max __NR_move_pages 623#define __NR_syscall_max __NR_move_pages
624 624
625#ifdef __KERNEL__
626#include <linux/err.h>
627#endif
628
629#ifndef __NO_STUBS 625#ifndef __NO_STUBS
630
631/* user-visible error numbers are in the range -1 - -MAX_ERRNO */
632
633#define __syscall_clobber "r11","rcx","memory"
634
635#define __syscall_return(type, res) \
636do { \
637 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
638 errno = -(res); \
639 res = -1; \
640 } \
641 return (type) (res); \
642} while (0)
643
644#define __ARCH_WANT_OLD_READDIR 626#define __ARCH_WANT_OLD_READDIR
645#define __ARCH_WANT_OLD_STAT 627#define __ARCH_WANT_OLD_STAT
646#define __ARCH_WANT_SYS_ALARM 628#define __ARCH_WANT_SYS_ALARM
@@ -664,87 +646,6 @@ do { \
664#define __ARCH_WANT_SYS_TIME 646#define __ARCH_WANT_SYS_TIME
665#define __ARCH_WANT_COMPAT_SYS_TIME 647#define __ARCH_WANT_COMPAT_SYS_TIME
666 648
667#define __syscall "syscall"
668
669#define _syscall0(type,name) \
670type name(void) \
671{ \
672long __res; \
673__asm__ volatile (__syscall \
674 : "=a" (__res) \
675 : "0" (__NR_##name) : __syscall_clobber ); \
676__syscall_return(type,__res); \
677}
678
679#define _syscall1(type,name,type1,arg1) \
680type name(type1 arg1) \
681{ \
682long __res; \
683__asm__ volatile (__syscall \
684 : "=a" (__res) \
685 : "0" (__NR_##name),"D" ((long)(arg1)) : __syscall_clobber ); \
686__syscall_return(type,__res); \
687}
688
689#define _syscall2(type,name,type1,arg1,type2,arg2) \
690type name(type1 arg1,type2 arg2) \
691{ \
692long __res; \
693__asm__ volatile (__syscall \
694 : "=a" (__res) \
695 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)) : __syscall_clobber ); \
696__syscall_return(type,__res); \
697}
698
699#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
700type name(type1 arg1,type2 arg2,type3 arg3) \
701{ \
702long __res; \
703__asm__ volatile (__syscall \
704 : "=a" (__res) \
705 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
706 "d" ((long)(arg3)) : __syscall_clobber); \
707__syscall_return(type,__res); \
708}
709
710#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
711type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
712{ \
713long __res; \
714__asm__ volatile ("movq %5,%%r10 ;" __syscall \
715 : "=a" (__res) \
716 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
717 "d" ((long)(arg3)),"g" ((long)(arg4)) : __syscall_clobber,"r10" ); \
718__syscall_return(type,__res); \
719}
720
721#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
722 type5,arg5) \
723type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
724{ \
725long __res; \
726__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall \
727 : "=a" (__res) \
728 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
729 "d" ((long)(arg3)),"g" ((long)(arg4)),"g" ((long)(arg5)) : \
730 __syscall_clobber,"r8","r10" ); \
731__syscall_return(type,__res); \
732}
733
734#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
735 type5,arg5,type6,arg6) \
736type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
737{ \
738long __res; \
739__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; movq %7,%%r9 ; " __syscall \
740 : "=a" (__res) \
741 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
742 "d" ((long)(arg3)), "g" ((long)(arg4)), "g" ((long)(arg5)), \
743 "g" ((long)(arg6)) : \
744 __syscall_clobber,"r8","r10","r9" ); \
745__syscall_return(type,__res); \
746}
747
748#ifdef __KERNEL__ 649#ifdef __KERNEL__
749#ifndef __ASSEMBLY__ 650#ifndef __ASSEMBLY__
750 651
diff --git a/include/asm-xtensa/unistd.h b/include/asm-xtensa/unistd.h
index 411f810a55c6..2e1a1b997e7d 100644
--- a/include/asm-xtensa/unistd.h
+++ b/include/asm-xtensa/unistd.h
@@ -218,190 +218,6 @@
218 218
219#define SYSXTENSA_COUNT 5 /* count of syscall0 functions*/ 219#define SYSXTENSA_COUNT 5 /* count of syscall0 functions*/
220 220
221#ifdef __KERNEL__
222#include <linux/linkage.h>
223
224#define __syscall_return(type, res) return ((type)(res))
225
226/* Tensilica's xt-xcc compiler is much more agressive at code
227 * optimization than gcc. Multiple __asm__ statements are
228 * insufficient for xt-xcc because subsequent optimization passes
229 * (beyond the front-end that knows of __asm__ statements and other
230 * such GNU Extensions to C) can modify the register selection for
231 * containment of C variables.
232 *
233 * xt-xcc cannot modify the contents of a single __asm__ statement, so
234 * we create single-asm versions of the syscall macros that are
235 * suitable and optimal for both xt-xcc and gcc.
236 *
237 * Linux takes system-call arguments in registers. The following
238 * design is optimized for user-land apps (e.g., glibc) which
239 * typically have a function wrapper around the "syscall" assembly
240 * instruction. It satisfies the Xtensa ABI while minizing argument
241 * shifting.
242 *
243 * The Xtensa ABI and software conventions require the system-call
244 * number in a2. If an argument exists in a2, we move it to the next
245 * available register. Note that for improved efficiency, we do NOT
246 * shift all parameters down one register to maintain the original
247 * order.
248 *
249 * At best case (zero arguments), we just write the syscall number to
250 * a2. At worst case (1 to 6 arguments), we move the argument in a2
251 * to the next available register, then write the syscall number to
252 * a2.
253 *
254 * For clarity, the following truth table enumerates all possibilities.
255 *
256 * arguments syscall number arg0, arg1, arg2, arg3, arg4, arg5
257 * --------- -------------- ----------------------------------
258 * 0 a2
259 * 1 a2 a3
260 * 2 a2 a4, a3
261 * 3 a2 a5, a3, a4
262 * 4 a2 a6, a3, a4, a5
263 * 5 a2 a7, a3, a4, a5, a6
264 * 6 a2 a8, a3, a4, a5, a6, a7
265 */
266
267#define _syscall0(type,name) \
268type name(void) \
269{ \
270long __res; \
271__asm__ __volatile__ ( \
272 " movi a2, %1 \n" \
273 " syscall \n" \
274 " mov %0, a2 \n" \
275 : "=a" (__res) \
276 : "i" (__NR_##name) \
277 : "a2" \
278 ); \
279__syscall_return(type,__res); \
280}
281
282#define _syscall1(type,name,type0,arg0) \
283type name(type0 arg0) \
284{ \
285long __res; \
286__asm__ __volatile__ ( \
287 " mov a3, %2 \n" \
288 " movi a2, %1 \n" \
289 " syscall \n" \
290 " mov %0, a2 \n" \
291 : "=a" (__res) \
292 : "i" (__NR_##name), "a" (arg0) \
293 : "a2", "a3" \
294 ); \
295__syscall_return(type,__res); \
296}
297
298#define _syscall2(type,name,type0,arg0,type1,arg1) \
299type name(type0 arg0,type1 arg1) \
300{ \
301long __res; \
302__asm__ __volatile__ ( \
303 " mov a4, %2 \n" \
304 " mov a3, %3 \n" \
305 " movi a2, %1 \n" \
306 " syscall \n" \
307 " mov %0, a2 \n" \
308 : "=a" (__res) \
309 : "i" (__NR_##name), "a" (arg0), "a" (arg1) \
310 : "a2", "a3", "a4" \
311 ); \
312__syscall_return(type,__res); \
313}
314
315#define _syscall3(type,name,type0,arg0,type1,arg1,type2,arg2) \
316type name(type0 arg0,type1 arg1,type2 arg2) \
317{ \
318long __res; \
319__asm__ __volatile__ ( \
320 " mov a5, %2 \n" \
321 " mov a4, %4 \n" \
322 " mov a3, %3 \n" \
323 " movi a2, %1 \n" \
324 " syscall \n" \
325 " mov %0, a2 \n" \
326 : "=a" (__res) \
327 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2) \
328 : "a2", "a3", "a4", "a5" \
329 ); \
330__syscall_return(type,__res); \
331}
332
333#define _syscall4(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3) \
334type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3) \
335{ \
336long __res; \
337__asm__ __volatile__ ( \
338 " mov a6, %2 \n" \
339 " mov a5, %5 \n" \
340 " mov a4, %4 \n" \
341 " mov a3, %3 \n" \
342 " movi a2, %1 \n" \
343 " syscall \n" \
344 " mov %0, a2 \n" \
345 : "=a" (__res) \
346 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), "a" (arg3) \
347 : "a2", "a3", "a4", "a5", "a6" \
348 ); \
349__syscall_return(type,__res); \
350}
351
352/* Note that we save and restore the a7 frame pointer.
353 * Including a7 in the clobber list doesn't do what you'd expect.
354 */
355#define _syscall5(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
356type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
357{ \
358long __res; \
359__asm__ __volatile__ ( \
360 " mov a9, a7 \n" \
361 " mov a7, %2 \n" \
362 " mov a6, %6 \n" \
363 " mov a5, %5 \n" \
364 " mov a4, %4 \n" \
365 " mov a3, %3 \n" \
366 " movi a2, %1 \n" \
367 " syscall \n" \
368 " mov a7, a9 \n" \
369 " mov %0, a2 \n" \
370 : "=a" (__res) \
371 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
372 "a" (arg3), "a" (arg4) \
373 : "a2", "a3", "a4", "a5", "a6", "a9" \
374 ); \
375__syscall_return(type,__res); \
376}
377
378/* Note that we save and restore the a7 frame pointer.
379 * Including a7 in the clobber list doesn't do what you'd expect.
380 */
381#define _syscall6(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
382type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
383{ \
384long __res; \
385__asm__ __volatile__ ( \
386 " mov a9, a7 \n" \
387 " mov a8, %2 \n" \
388 " mov a7, %7 \n" \
389 " mov a6, %6 \n" \
390 " mov a5, %5 \n" \
391 " mov a4, %4 \n" \
392 " mov a3, %3 \n" \
393 " movi a2, %1 \n" \
394 " syscall \n" \
395 " mov a7, a9 \n" \
396 " mov %0, a2 \n" \
397 : "=a" (__res) \
398 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
399 "a" (arg3), "a" (arg4), "a" (arg5) \
400 : "a2", "a3", "a4", "a5", "a6", "a8", "a9" \
401 ); \
402__syscall_return(type,__res); \
403}
404
405/* 221/*
406 * "Conditional" syscalls 222 * "Conditional" syscalls
407 * 223 *