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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 g_stack_ptr = stack_ptr; | 92 g_stack_ptr = stack_ptr; |
93 __libnacl_irt_thread.thread_exit((int32_t *) &g_stack_in_use); | 93 __libnacl_irt_thread.thread_exit((int32_t *) &g_stack_in_use); |
94 } | 94 } |
95 | 95 |
96 int main(void) { | 96 int main(void) { |
97 __nc_initialize_interfaces(); | 97 __nc_initialize_interfaces(); |
98 | 98 |
99 int offset; | 99 int offset; |
100 for (offset = 0; offset <= 32; offset++) { | 100 for (offset = 0; offset <= 32; offset++) { |
101 char *stack_top = stack + sizeof(stack) - offset; | 101 char *stack_top = stack + sizeof(stack) - offset; |
102 printf("Checking offset %i: stack_top=%p...\n", offset, stack_top); | 102 printf("Checking offset %i: stack_top=%p...\n", offset, (void *)stack_top); |
103 g_stack_ptr = NULL; | 103 g_stack_ptr = NULL; |
104 g_stack_in_use = 1; | 104 g_stack_in_use = 1; |
105 void *dummy_tls = &dummy_tls; | 105 void *dummy_tls = &dummy_tls; |
106 int rc = __libnacl_irt_thread.thread_create(ThreadStartWrapper, stack_top, | 106 int rc = __libnacl_irt_thread.thread_create(ThreadStartWrapper, stack_top, |
107 dummy_tls); | 107 dummy_tls); |
108 assert(rc == 0); | 108 assert(rc == 0); |
109 /* Spin until the thread exits. */ | 109 /* Spin until the thread exits. */ |
110 while (g_stack_in_use) { | 110 while (g_stack_in_use) { |
111 sched_yield(); | 111 sched_yield(); |
112 } | 112 } |
113 printf("got g_stack_ptr=%p\n", g_stack_ptr); | 113 printf("got g_stack_ptr=%p\n", (void *)g_stack_ptr); |
114 assert(g_stack_ptr <= stack_top); | 114 assert(g_stack_ptr <= stack_top); |
115 assert(((uintptr_t) g_stack_ptr + kStackPadBelowAlign) % kStackAlignment | 115 assert(((uintptr_t) g_stack_ptr + kStackPadBelowAlign) % kStackAlignment |
116 == 0); | 116 == 0); |
117 } | 117 } |
118 | 118 |
119 return 0; | 119 return 0; |
120 } | 120 } |
OLD | NEW |