Skip to content

Commit

Permalink
use thread_local for VS compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pefoley2 committed Jun 15, 2016
1 parent 253b0cd commit 22d9723
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
9 changes: 9 additions & 0 deletions common/h/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@
#endif
#endif

#ifndef TLS_VAR
#if defined(_MSC_VER) && _MSC_VER < 1900
#define TLS_VAR __declspec(thread)
#else
#define TLS_VAR thread_local
#endif
#endif


#ifndef __UTIL_H__
#define __UTIL_H__

Expand Down
2 changes: 1 addition & 1 deletion common/src/arch-x86.C
Original file line number Diff line number Diff line change
Expand Up @@ -8093,7 +8093,7 @@ static struct ia32_entry vexWMap[][2] =
/** END_DYNINST_TABLE_VERIFICATION */
#undef VEX3_ILL

static __thread bool mode_64 = false;
static TLS_VAR bool mode_64 = false;

void ia32_set_mode_64(bool mode) {
mode_64 = mode;
Expand Down
2 changes: 1 addition & 1 deletion dyninstAPI_RT/src/RTcommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ FILE *stOut;
int fakeTickCount;


#if defined(_MSC_VER)
#ifdef _MSC_VER
#define TLS_VAR __declspec(thread)
#else
#define TLS_VAR __thread
Expand Down
8 changes: 4 additions & 4 deletions instructionAPI/src/InstructionDecoder-x86.C
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ namespace Dyninst
}


__thread NS_x86::ia32_instruction* InstructionDecoder_x86::decodedInstruction = NULL;
__thread ia32_locations* InstructionDecoder_x86::locs = NULL;
__thread bool InstructionDecoder_x86::sizePrefixPresent = false;
__thread bool InstructionDecoder_x86::addrSizePrefixPresent = false;
TLS_VAR NS_x86::ia32_instruction* InstructionDecoder_x86::decodedInstruction = NULL;
TLS_VAR ia32_locations* InstructionDecoder_x86::locs = NULL;
TLS_VAR bool InstructionDecoder_x86::sizePrefixPresent = false;
TLS_VAR bool InstructionDecoder_x86::addrSizePrefixPresent = false;
INSTRUCTION_EXPORT InstructionDecoder_x86::InstructionDecoder_x86(Architecture a) :
InstructionDecoderImpl(a)
{
Expand Down
8 changes: 4 additions & 4 deletions instructionAPI/src/InstructionDecoder-x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ namespace Dyninst
void doIA32Decode(InstructionDecoder::buffer& b);
bool isDefault64Insn();

static __thread ia32_locations* locs;
static __thread NS_x86::ia32_instruction* decodedInstruction;
static __thread bool sizePrefixPresent;
static __thread bool addrSizePrefixPresent;
static TLS_VAR ia32_locations* locs;
static TLS_VAR NS_x86::ia32_instruction* decodedInstruction;
static TLS_VAR bool sizePrefixPresent;
static TLS_VAR bool addrSizePrefixPresent;
};
};
};
Expand Down

0 comments on commit 22d9723

Please sign in to comment.