| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <sched.h> | 8 #include <sched.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 ".pushsection .text, \"ax\", %progbits\n" | 53 ".pushsection .text, \"ax\", %progbits\n" |
| 54 "ThreadStartWrapper:\n" | 54 "ThreadStartWrapper:\n" |
| 55 "mov r0, sp\n" /* Set argument */ | 55 "mov r0, sp\n" /* Set argument */ |
| 56 "nop; nop\n" /* Padding to put the "bl" at the end of the bundle */ | 56 "nop; nop\n" /* Padding to put the "bl" at the end of the bundle */ |
| 57 "bl ThreadStart\n" | 57 "bl ThreadStart\n" |
| 58 ".popsection\n"); | 58 ".popsection\n"); |
| 59 | 59 |
| 60 static const int kStackAlignment = 8; | 60 static const int kStackAlignment = 8; |
| 61 static const int kStackPadBelowAlign = 0; | 61 static const int kStackPadBelowAlign = 0; |
| 62 | 62 |
| 63 #elif defined(__mips__) |
| 64 |
| 65 __asm__( |
| 66 ".pushsection .text, \"ax\", %progbits\n" |
| 67 ".global ThreadStartWrapper\n" |
| 68 "ThreadStartWrapper:\n" |
| 69 "move $a0, $sp\n" /* Set argument. */ |
| 70 "nop\n" |
| 71 "bal ThreadStart\n" |
| 72 "nop\n" |
| 73 ".popsection\n"); |
| 74 |
| 75 static const int kStackAlignment = 8; |
| 76 static const int kStackPadBelowAlign = 0; |
| 77 |
| 63 #else | 78 #else |
| 64 # error Unsupported architecture | 79 # error Unsupported architecture |
| 65 #endif | 80 #endif |
| 66 | 81 |
| 67 void ThreadStartWrapper(void); | 82 void ThreadStartWrapper(void); |
| 68 | 83 |
| 69 void ThreadStart(char *stack_ptr) { | 84 void ThreadStart(char *stack_ptr) { |
| 70 /* | 85 /* |
| 71 * We do not have TLS set up in this thread, so we don't use libc | 86 * We do not have TLS set up in this thread, so we don't use libc |
| 72 * functions like assert() here. Instead, we save stack_ptr and let | 87 * functions like assert() here. Instead, we save stack_ptr and let |
| (...skipping 21 matching lines...) Expand all Loading... |
| 94 sched_yield(); | 109 sched_yield(); |
| 95 } | 110 } |
| 96 printf("got g_stack_ptr=%p\n", g_stack_ptr); | 111 printf("got g_stack_ptr=%p\n", g_stack_ptr); |
| 97 assert(g_stack_ptr <= stack_top); | 112 assert(g_stack_ptr <= stack_top); |
| 98 assert(((uintptr_t) g_stack_ptr + kStackPadBelowAlign) % kStackAlignment | 113 assert(((uintptr_t) g_stack_ptr + kStackPadBelowAlign) % kStackAlignment |
| 99 == 0); | 114 == 0); |
| 100 } | 115 } |
| 101 | 116 |
| 102 return 0; | 117 return 0; |
| 103 } | 118 } |
| OLD | NEW |