Created
May 1, 2019 01:33
-
-
Save ricarkol/9ebd3b260216dbbdbe3957ecb426459d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "solo5.h" | |
#include "../../bindings/lib.c" | |
#if defined(__linux__) | |
__thread volatile uint64_t data; | |
#else | |
/* This case is not tested. */ | |
volatile uint64_t data; | |
#endif | |
volatile uint64_t data_thread_1 = 1; | |
volatile uint64_t data_thread_2 = 2; | |
volatile uint64_t data_thread_3 = 3; | |
static void puts(const char *s) | |
{ | |
solo5_console_write(s, strlen(s)); | |
} | |
int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) | |
{ | |
puts("\n**** Solo5 standalone test_tls ****\n\n"); | |
solo5_set_arch_tls_base((uint64_t)&data_thread_1 + (sizeof(uint64_t))); | |
if (data != 1) | |
return 1; | |
solo5_set_arch_tls_base((uint64_t)&data_thread_2 + (sizeof(uint64_t))); | |
if (data != 2) | |
return 2; | |
solo5_set_arch_tls_base((uint64_t)&data_thread_3 + (sizeof(uint64_t))); | |
if (data != 3) | |
return 3; | |
solo5_set_arch_tls_base((uint64_t)&data_thread_1 + (sizeof(uint64_t))); | |
data = 4; | |
if (data_thread_1 != 4) | |
return 4; | |
solo5_set_arch_tls_base((uint64_t)&data_thread_2 + (sizeof(uint64_t))); | |
data = 5; | |
if (data_thread_2 != 5) | |
return 5; | |
solo5_set_arch_tls_base((uint64_t)&data_thread_3 + (sizeof(uint64_t))); | |
data = 6; | |
if (data_thread_3 != 6) | |
return 6; | |
puts("SUCCESS\n"); | |
return SOLO5_EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment