OLD | NEW |
1 /* Copyright (c) 2005-2010, Google Inc. | 1 /* Copyright (c) 2005-2010, 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 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 | 2163 |
2164 /* if (%r0 != 0) | 2164 /* if (%r0 != 0) |
2165 * return %r0; | 2165 * return %r0; |
2166 */ | 2166 */ |
2167 "movs %0,r0\n" | 2167 "movs %0,r0\n" |
2168 "bne 1f\n" | 2168 "bne 1f\n" |
2169 | 2169 |
2170 /* In the child, now. Call "fn(arg)". | 2170 /* In the child, now. Call "fn(arg)". |
2171 */ | 2171 */ |
2172 "ldr r0,[sp, #4]\n" | 2172 "ldr r0,[sp, #4]\n" |
| 2173 |
| 2174 /* When compiling for Thumb-2 the "MOV LR,PC" here |
| 2175 * won't work because it loads PC+4 into LR, |
| 2176 * whereas the LDR is a 4-byte instruction. |
| 2177 * This results in the child thread always |
| 2178 * crashing with an "Illegal Instruction" when it |
| 2179 * returned into the middle of the LDR instruction |
| 2180 * The instruction sequence used instead was |
| 2181 * recommended by |
| 2182 * "https://wiki.edubuntu.org/ARM/Thumb2PortingHowt
o#Quick_Reference". |
| 2183 */ |
| 2184 #ifdef __thumb2__ |
| 2185 "ldr r7,[sp]\n" |
| 2186 "blx r7\n" |
| 2187 #else |
2173 "mov lr,pc\n" | 2188 "mov lr,pc\n" |
2174 "ldr pc,[sp]\n" | 2189 "ldr pc,[sp]\n" |
| 2190 #endif |
2175 | 2191 |
2176 /* Call _exit(%r0). | 2192 /* Call _exit(%r0). |
2177 */ | 2193 */ |
2178 "mov r7, %10\n" | 2194 "mov r7, %10\n" |
2179 "swi 0x0\n" | 2195 "swi 0x0\n" |
2180 "1:\n" | 2196 "1:\n" |
2181 : "=r" (__res) | 2197 : "=r" (__res) |
2182 : "i"(-EINVAL), | 2198 : "i"(-EINVAL), |
2183 "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), | 2199 "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), |
2184 "r"(__ptid), "r"(__tls), "r"(__ctid), | 2200 "r"(__ptid), "r"(__tls), "r"(__ctid), |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3475 } | 3491 } |
3476 #endif | 3492 #endif |
3477 #endif | 3493 #endif |
3478 | 3494 |
3479 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) | 3495 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) |
3480 } | 3496 } |
3481 #endif | 3497 #endif |
3482 | 3498 |
3483 #endif | 3499 #endif |
3484 #endif | 3500 #endif |
OLD | NEW |