[MSVCRT]
[reactos.git] / reactos / lib / sdk / crt / include / internal / tls.h
1 /* tls.h */
2
3 #ifndef __CRT_INTERNAL_TLS_H
4 #define __CRT_INTERNAL_TLS_H
5
6 #ifndef _CRT_PRECOMP_H
7 #error DO NOT INCLUDE THIS HEADER DIRECTLY
8 #endif
9
10 #include <stddef.h>
11 #include <time.h>
12 #include <locale.h>
13 #include <windef.h>
14 #include <winbase.h>
15 #include <winnt.h>
16
17 #include <internal/wine/eh.h>
18
19 typedef struct MSVCRT_threadlocaleinfostruct {
20 LONG refcount;
21 unsigned int lc_codepage;
22 unsigned int lc_collate_cp;
23 unsigned long lc_handle[6];
24 LC_ID lc_id[6];
25 struct {
26 char *locale;
27 wchar_t *wlocale;
28 int *refcount;
29 int *wrefcount;
30 } lc_category[6];
31 int lc_clike;
32 int mb_cur_max;
33 int *lconv_intl_refcount;
34 int *lconv_num_refcount;
35 int *lconv_mon_refcount;
36 struct MSVCRT_lconv *lconv;
37 int *ctype1_refcount;
38 unsigned short *ctype1;
39 const unsigned short *pctype;
40 unsigned char *pclmap;
41 unsigned char *pcumap;
42 struct __lc_time_data *lc_time_curr;
43 } MSVCRT_threadlocinfo;
44
45 typedef struct MSVCRT_threadmbcinfostruct {
46 LONG refcount;
47 int mbcodepage;
48 int ismbcodepage;
49 int mblcid;
50 unsigned short mbulinfo[6];
51 char mbctype[257];
52 char mbcasemap[256];
53 } MSVCRT_threadmbcinfo;
54
55 struct MSVCRT_lconv {
56 char* decimal_point;
57 char* thousands_sep;
58 char* grouping;
59 char* int_curr_symbol;
60 char* currency_symbol;
61 char* mon_decimal_point;
62 char* mon_thousands_sep;
63 char* mon_grouping;
64 char* positive_sign;
65 char* negative_sign;
66 char int_frac_digits;
67 char frac_digits;
68 char p_cs_precedes;
69 char p_sep_by_space;
70 char n_cs_precedes;
71 char n_sep_by_space;
72 char p_sign_posn;
73 char n_sign_posn;
74 };
75
76 typedef struct MSVCRT_threadlocaleinfostruct *MSVCRT_pthreadlocinfo;
77 typedef struct MSVCRT_threadmbcinfostruct *MSVCRT_pthreadmbcinfo;
78
79 typedef struct MSVCRT_localeinfo_struct
80 {
81 MSVCRT_pthreadlocinfo locinfo;
82 MSVCRT_pthreadmbcinfo mbcinfo;
83 } MSVCRT__locale_tstruct, *MSVCRT__locale_t;
84
85 /* TLS data */
86 extern DWORD tls_index;
87
88 struct __thread_data {
89 DWORD tid;
90 HANDLE handle;
91 int thread_errno;
92 unsigned long thread_doserrno;
93 int unk1;
94 unsigned int random_seed; /* seed for rand() */
95 char *strtok_next; /* next ptr for strtok() */
96 wchar_t *wcstok_next; /* next ptr for wcstok() */
97 unsigned char *mbstok_next; /* next ptr for mbstok() */
98 char *strerror_buffer; /* buffer for strerror */
99 wchar_t *wcserror_buffer; /* buffer for wcserror */
100 char *tmpnam_buffer; /* buffer for tmpname() */
101 wchar_t *wtmpnam_buffer; /* buffer for wtmpname() */
102 void *unk2[2];
103 char *asctime_buffer; /* buffer for asctime */
104 wchar_t *wasctime_buffer; /* buffer for wasctime */
105 struct tm *time_buffer; /* buffer for localtime/gmtime */
106 char *efcvt_buffer; /* buffer for ecvt/fcvt */
107 int unk3[2];
108 void *unk4[4];
109 int fpecode;
110 MSVCRT_pthreadmbcinfo mbcinfo;
111 MSVCRT_pthreadlocinfo locinfo;
112 BOOL have_locale;
113 int unk5[1];
114 terminate_function terminate_handler;
115 unexpected_function unexpected_handler;
116 _se_translator_function se_translator;
117 void *unk6[3];
118 int unk7;
119 EXCEPTION_RECORD *exc_record;
120 void *unk8[100];
121 };
122
123 typedef struct __thread_data thread_data_t;
124
125 extern inline BOOL msvcrt_init_tls(void);
126 extern inline BOOL msvcrt_free_tls(void);
127 extern thread_data_t *msvcrt_get_thread_data(void);
128 extern inline void msvcrt_free_tls_mem(void);
129
130 #define MSVCRT_ENABLE_PER_THREAD_LOCALE 1
131 #define MSVCRT_DISABLE_PER_THREAD_LOCALE 2
132
133 void __init_global_locale();
134 extern MSVCRT__locale_t global_locale;
135 #define MSVCRT_locale __get_MSVCRT_locale()
136 extern inline MSVCRT__locale_t __get_MSVCRT_locale()
137 {
138 if(!global_locale)
139 __init_global_locale();
140 return global_locale;
141 }
142
143 MSVCRT_pthreadlocinfo get_locinfo(void);
144 void __cdecl MSVCRT__free_locale(MSVCRT__locale_t);
145 void free_locinfo(MSVCRT_pthreadlocinfo);
146 void free_mbcinfo(MSVCRT_pthreadmbcinfo);
147
148 #endif /* __MSVCRT_INTERNAL_TLS_H */
149
150 /* EOF */