1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     os_ThreadLocalStorage.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 47398 $
14  *---------------------------------------------------------------------------*/
15 
16 /* Please see man pages for details
17 
18 
19 
20 */
21 #ifndef NN_OS_OS_THREADLOCALSTORAGE_H_
22 #define NN_OS_OS_THREADLOCALSTORAGE_H_
23 
24 #include <nn/types.h>
25 #include <nn/config.h>
26 
27 #ifdef __cplusplus
28 
29 namespace nn{ namespace os{
30 
31     namespace detail
32     {
33         void InitializeThreadEnvrionment();
34     }
35 
36 /* Please see man pages for details
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 */
50 class ThreadLocalStorage
51 {
52 public:
53 
54     /* Please see man pages for details
55 
56     */
57     ThreadLocalStorage();
58 
59     /* Please see man pages for details
60 
61     */
62     ~ThreadLocalStorage();
63 
64     /* Please see man pages for details
65 
66 
67 
68     */
69     uptr GetValue() const;
70 
71     /* Please see man pages for details
72 
73 
74 
75 
76     */
77     void SetValue(uptr value);
78 
79 
80 public:
81     struct WithoutInitialize{};
ThreadLocalStorage(const WithoutInitialize & dummy)82     ThreadLocalStorage(const WithoutInitialize& dummy) { NN_UNUSED_VAR(dummy); }
83     void Initialize();
84     void Finalize();
85 
86     void SetValueTo(void* pTo, uptr value);
87 
88 private:
89 
90     // Slot number
91     s32 m_Index;
92 
93     friend void nn::os::detail::InitializeThreadEnvrionment();
94 
95     // Clear the values stored in all slots.
96     static void ClearAllSlots();
97 
98 };
99 
100 }} // namespace nn::os
101 
102 #endif // __cplusplus
103 
104 /* NN_OS_OS_THREADLOCALSTORAGE_H_ */
105 #endif /* NN_OS_OS_THREADLOCALSTORAGE_H_ */
106