Skip to content

Commit

Permalink
Support building with MSVC
Browse files Browse the repository at this point in the history
Issue reported and the usage of __declspec(thread) suggested by cpuchainorg

Fixes #2
  • Loading branch information
solardiz committed Jun 2, 2024
1 parent aec52ab commit 84ddaad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ int main(int argc, const char * const *argv)

printf("Will use %.2f KiB RAM\n", 0.125 * params.N * params.r);

static __thread union {
static
#ifdef _MSC_VER
__declspec(thread)
#else
__thread
#endif
union {
uint8_t u8[80];
uint32_t u32[20];
} src;
Expand Down
5 changes: 5 additions & 0 deletions yespower-opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,8 +1129,13 @@ int yespower(yespower_local_t *local,
int yespower_tls(const uint8_t *src, size_t srclen,
const yespower_params_t *params, yespower_binary_t *dst)
{
#ifdef _MSC_VER
static __declspec(thread) int initialized = 0;
static __declspec(thread) yespower_local_t local;
#else
static __thread int initialized = 0;
static __thread yespower_local_t local;
#endif

if (!initialized) {
init_region(&local);
Expand Down

0 comments on commit 84ddaad

Please sign in to comment.