diff options
author | Bogusevschi, Silviu <[email protected]> | 2020-09-18 11:53:37 -0700 |
---|---|---|
committer | Bogusevschi, Silviu <[email protected]> | 2020-09-18 11:53:37 -0700 |
commit | 070b4c09af04001331f933da8895b1604764c70a (patch) | |
tree | 16212d01ffbcd9908e2f6d8cfb7e1d724081a41b | |
parent | 9a4e6579743ce05f9b4497c681eb358466197184 (diff) | |
download | xbyak-070b4c09af04001331f933da8895b1604764c70a.tar.gz xbyak-070b4c09af04001331f933da8895b1604764c70a.zip |
make l_err() inline with block scope static TLS l_error
-rw-r--r-- | xbyak/xbyak.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h index 67b75f3..88a3919 100644 --- a/xbyak/xbyak.h +++ b/xbyak/xbyak.h @@ -267,13 +267,23 @@ inline const char *ConvertErrorToString(int err) #ifdef XBYAK_NO_EXCEPTION namespace local { -static XBYAK_TLS int l_err = 0; -inline void SetError(int err) { if (err) l_err = err; } // keep the first err code - +inline int &l_err() { + static XBYAK_TLS int l_error; + return l_error; +} +inline void SetError(int err) { + if (err) { // keep the first err code + int &l_error = local::l_err(); + l_error = err; + } +} } // local -inline void ClearError() { local::l_err = 0; } -inline int GetError() { return local::l_err; } +inline void ClearError() { + int &l_error = local::l_err(); + l_error = 0; +} +inline int GetError() { return local::l_err(); } #define XBYAK_THROW(err) { local::SetError(err); return; } #define XBYAK_THROW_RET(err, r) { local::SetError(err); return r; } |