OLD | NEW |
1 /* Copyright (c) 2005-2011, Google Inc. | 1 /* Copyright (c) 2005-2011, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 2677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2688 type5 arg5,type6 arg6) { \ | 2688 type5 arg5,type6 arg6) { \ |
2689 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ | 2689 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ |
2690 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \ | 2690 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \ |
2691 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ | 2691 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ |
2692 "r"(__r8), "r"(__r9)); \ | 2692 "r"(__r8), "r"(__r9)); \ |
2693 } | 2693 } |
2694 #endif | 2694 #endif |
2695 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, | 2695 LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack, |
2696 int flags, void *arg, int *parent_tidptr, | 2696 int flags, void *arg, int *parent_tidptr, |
2697 void *newtls, int *child_tidptr) { | 2697 void *newtls, int *child_tidptr) { |
2698 register unsigned long __v0 __asm__("$2"); | 2698 register unsigned long __v0 __asm__("$2") = -EINVAL; |
2699 register unsigned long __r7 __asm__("$7") = (unsigned long)newtls; | 2699 register unsigned long __r7 __asm__("$7") = (unsigned long)newtls; |
2700 { | 2700 { |
2701 register int __flags __asm__("$4") = flags; | 2701 register int __flags __asm__("$4") = flags; |
2702 register void *__stack __asm__("$5") = child_stack; | 2702 register void *__stack __asm__("$5") = child_stack; |
2703 register void *__ptid __asm__("$6") = parent_tidptr; | 2703 register void *__ptid __asm__("$6") = parent_tidptr; |
2704 register int *__ctid __asm__("$8") = child_tidptr; | 2704 register int *__ctid __asm__("$8") = child_tidptr; |
2705 __asm__ __volatile__( | 2705 __asm__ __volatile__( |
2706 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 | 2706 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 |
2707 "subu $29,24\n" | 2707 "subu $29,24\n" |
2708 #elif _MIPS_SIM == _MIPS_SIM_NABI32 | 2708 #elif _MIPS_SIM == _MIPS_SIM_NABI32 |
2709 "sub $29,16\n" | 2709 "sub $29,16\n" |
2710 #else | 2710 #else |
2711 "dsubu $29,16\n" | 2711 "dsubu $29,16\n" |
2712 #endif | 2712 #endif |
2713 | 2713 |
2714 /* if (fn == NULL || child_stack == NULL) | 2714 /* if (fn == NULL || child_stack == NULL) |
2715 * return -EINVAL; | 2715 * return -EINVAL; |
2716 */ | 2716 */ |
2717 "li %0,%2\n" | 2717 "beqz %4,1f\n" |
2718 "beqz %5,1f\n" | 2718 "beqz %5,1f\n" |
2719 "beqz %6,1f\n" | |
2720 | 2719 |
2721 /* Push "arg" and "fn" onto the stack that will be | 2720 /* Push "arg" and "fn" onto the stack that will be |
2722 * used by the child. | 2721 * used by the child. |
2723 */ | 2722 */ |
2724 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 | 2723 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 |
2725 "subu %6,32\n" | 2724 "subu %5,32\n" |
2726 "sw %5,0(%6)\n" | 2725 "sw %4,0(%5)\n" |
2727 "sw %8,4(%6)\n" | 2726 "sw %7,4(%5)\n" |
2728 #elif _MIPS_SIM == _MIPS_SIM_NABI32 | 2727 #elif _MIPS_SIM == _MIPS_SIM_NABI32 |
2729 "sub %6,32\n" | 2728 "sub %5,32\n" |
2730 "sw %5,0(%6)\n" | 2729 "sw %4,0(%5)\n" |
2731 "sw %8,8(%6)\n" | 2730 "sw %7,8(%5)\n" |
2732 #else | 2731 #else |
2733 "dsubu %6,32\n" | 2732 "dsubu %5,32\n" |
2734 "sd %5,0(%6)\n" | 2733 "sd %4,0(%5)\n" |
2735 "sd %8,8(%6)\n" | 2734 "sd %7,8(%5)\n" |
2736 #endif | 2735 #endif |
2737 | 2736 |
2738 /* $7 = syscall($4 = flags, | 2737 /* $7 = syscall($4 = flags, |
2739 * $5 = child_stack, | 2738 * $5 = child_stack, |
2740 * $6 = parent_tidptr, | 2739 * $6 = parent_tidptr, |
2741 * $7 = newtls, | 2740 * $7 = newtls, |
2742 * $8 = child_tidptr) | 2741 * $8 = child_tidptr) |
2743 */ | 2742 */ |
2744 "li $2,%3\n" | 2743 "li $2,%2\n" |
2745 "syscall\n" | 2744 "syscall\n" |
2746 | 2745 |
2747 /* if ($7 != 0) | 2746 /* if ($7 != 0) |
2748 * return $2; | 2747 * return $2; |
2749 */ | 2748 */ |
2750 "bnez $7,1f\n" | 2749 "bnez $7,1f\n" |
2751 "bnez $2,1f\n" | 2750 "bnez $2,1f\n" |
2752 | 2751 |
2753 /* In the child, now. Call "fn(arg)". | 2752 /* In the child, now. Call "fn(arg)". |
2754 */ | 2753 */ |
2755 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 | 2754 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 |
2756 "lw $25,0($29)\n" | 2755 "lw $25,0($29)\n" |
2757 "lw $4,4($29)\n" | 2756 "lw $4,4($29)\n" |
2758 #elif _MIPS_SIM == _MIPS_SIM_NABI32 | 2757 #elif _MIPS_SIM == _MIPS_SIM_NABI32 |
2759 "lw $25,0($29)\n" | 2758 "lw $25,0($29)\n" |
2760 "lw $4,8($29)\n" | 2759 "lw $4,8($29)\n" |
2761 #else | 2760 #else |
2762 "ld $25,0($29)\n" | 2761 "ld $25,0($29)\n" |
2763 "ld $4,8($29)\n" | 2762 "ld $4,8($29)\n" |
2764 #endif | 2763 #endif |
2765 "jalr $25\n" | 2764 "jalr $25\n" |
2766 | 2765 |
2767 /* Call _exit($2) | 2766 /* Call _exit($2) |
2768 */ | 2767 */ |
2769 "move $4,$2\n" | 2768 "move $4,$2\n" |
2770 "li $2,%4\n" | 2769 "li $2,%3\n" |
2771 "syscall\n" | 2770 "syscall\n" |
2772 | 2771 |
2773 "1:\n" | 2772 "1:\n" |
2774 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 | 2773 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 |
2775 "addu $29, 24\n" | 2774 "addu $29, 24\n" |
2776 #elif _MIPS_SIM == _MIPS_SIM_NABI32 | 2775 #elif _MIPS_SIM == _MIPS_SIM_NABI32 |
2777 "add $29, 16\n" | 2776 "add $29, 16\n" |
2778 #else | 2777 #else |
2779 "daddu $29,16\n" | 2778 "daddu $29,16\n" |
2780 #endif | 2779 #endif |
2781 : "+r" (__v0), "+r" (__r7) | 2780 : "+r" (__v0), "+r" (__r7) |
2782 : "i"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), | 2781 : "i"(__NR_clone), "i"(__NR_exit), "r"(fn), |
2783 "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), | 2782 "r"(__stack), "r"(__flags), "r"(arg), |
2784 "r"(__ptid), "r"(__r7), "r"(__ctid) | 2783 "r"(__ptid), "r"(__ctid) |
2785 : "$9", "$10", "$11", "$12", "$13", "$14", "$15", | 2784 : "$9", "$10", "$11", "$12", "$13", "$14", "$15", |
2786 "$24", "$25", "memory"); | 2785 "$24", "$25", "memory"); |
2787 } | 2786 } |
2788 LSS_RETURN(int, __v0, __r7); | 2787 LSS_RETURN(int, __v0, __r7); |
2789 } | 2788 } |
2790 #elif defined (__PPC__) | 2789 #elif defined (__PPC__) |
2791 #undef LSS_LOADARGS_0 | 2790 #undef LSS_LOADARGS_0 |
2792 #define LSS_LOADARGS_0(name, dummy...) \ | 2791 #define LSS_LOADARGS_0(name, dummy...) \ |
2793 __sc_0 = __NR_##name | 2792 __sc_0 = __NR_##name |
2794 #undef LSS_LOADARGS_1 | 2793 #undef LSS_LOADARGS_1 |
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4020 # pragma pop_macro("fstat64") | 4019 # pragma pop_macro("fstat64") |
4021 # pragma pop_macro("lstat64") | 4020 # pragma pop_macro("lstat64") |
4022 #endif | 4021 #endif |
4023 | 4022 |
4024 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) | 4023 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) |
4025 } | 4024 } |
4026 #endif | 4025 #endif |
4027 | 4026 |
4028 #endif | 4027 #endif |
4029 #endif | 4028 #endif |
OLD | NEW |