#ifdef _WIN32
#define __thread __declspec( thread )
-__thread int tls_i = 1;
+#endif
-int test(void) {
- return tls_i;
-}
-#else
-int test() {
- return 1;
+__thread int tls_i[10];
+__thread int tls_j = 5;
+
+int test(int i) {
+ tls_j = i;
+ return tls_i[i];
}
-#endif
int main()
{
- printf("Result: %d\n", test());
+ printf("tls_i: %d\n", test(3));
+ printf("tls_j: %d\n", tls_j);
return 0;
}