1 /*
2  * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6 
7 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_NACL_STACK_SAFETY_H_
8 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_NACL_STACK_SAFETY_H_
9 
10 #include "native_client/src/include/build_config.h"
11 #include "native_client/src/include/nacl_base.h"
12 #include "native_client/src/include/portability.h"
13 
14 EXTERN_C_BEGIN
15 
16 /*
17  * NB: Relying code should open-code -- not use a function call -- in
18  * assembly the necessary code to read nacl_thread_on_safe_stack.
19  */
20 
21 #if (NACL_WINDOWS && NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 &&  \
22      NACL_BUILD_SUBARCH == 64)
23 
24 extern THREAD uint32_t nacl_on_safe_stack;
25 
NaClStackSafetyNowOnUntrustedStack(void)26 static INLINE void NaClStackSafetyNowOnUntrustedStack(void) {
27   nacl_on_safe_stack = 0;
28 }
29 
NaClStackSafetyNowOnTrustedStack(void)30 static INLINE void NaClStackSafetyNowOnTrustedStack(void) {
31   nacl_on_safe_stack = 1;
32 }
33 
34 #else
35 
36 static INLINE void NaClStackSafetyNowOnUntrustedStack(void) {
37 }
38 
39 static INLINE void NaClStackSafetyNowOnTrustedStack(void) {
40 }
41 
42 #endif
43 
44 EXTERN_C_END
45 
46 #endif
47