Skip to content

Commit

Permalink
#306: tls: fix warning about unused static struct
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Apr 16, 2019
1 parent bdcc629 commit ba3e950
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/vt/utils/tls/null_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ namespace vt { namespace util { namespace tls {

template <typename T, char const* tag>
struct ThreadLocalNull {
static T& get() { return value_; }
T& get() { access_++; return value_; }
int64_t numAccess() const { return access_; }
private:
static T value_;
int64_t access_ = 0;
};

template <typename T, char const* tag, T val>
struct ThreadLocalInitNull {
static T& get() { return value_; }
T& get() { access_++; return value_; }
int64_t numAccess() const { return access_; }
private:
static T value_;
int64_t access_ = 0;
};

template <typename T, char const* tag>
Expand Down
8 changes: 6 additions & 2 deletions src/vt/utils/tls/omp_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,30 @@ namespace vt { namespace util { namespace tls {

template <typename T, char const* tag, T val>
struct ThreadLocalInitOMP {
static T& get() { return value_; }
T& get() { access_++; return value_; }
int64_t numAccess() const { return access_; }
private:
#if defined(__GNUC__)
static thread_local T value_;
#else
static T value_;
#pragma omp threadprivate (value_)
#endif
int64_t access_ = 0;
};

template <typename T, char const* tag>
struct ThreadLocalOMP {
static T& get() { return value_; }
T& get() { access_++; return value_; }
int64_t numAccess() const { return access_; }
private:
#if defined(__GNUC__)
static thread_local T value_;
#else
static T value_;
#pragma omp threadprivate (value_)
#endif
int64_t access_ = 0;
};

#if defined(__GNUC__)
Expand Down
8 changes: 6 additions & 2 deletions src/vt/utils/tls/std_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ namespace vt { namespace util { namespace tls {

template <typename T, char const* tag, T val = T{}>
struct ThreadLocalInitSTD {
static T& get() { return value_; }
T& get() { access_++; return value_; }
int64_t numAccess() const { return access_; }
private:
static thread_local T value_;
int64_t access_ = 0;
};

template <typename T, char const* tag>
struct ThreadLocalSTD {
static T& get() { return value_; }
T& get() { access_++; return value_; }
int64_t numAccess() const { return access_; }
private:
static thread_local T value_;
int64_t access_ = 0;
};

template <typename T, char const* tag, T val>
Expand Down
4 changes: 2 additions & 2 deletions src/vt/utils/tls/tls.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace vt { namespace util { namespace tls {
#define ExternImplTLS(tlcls, type, var) \
InnerTLS(tlcls, type, var, , , extern, )
#define AccessImplTLS(var) \
decltype(TagTLS(var))::get()
TagTLS(var).get()

// Variants for static file TLS variables
#define DeclareStImplTLS(tlcls, type, var) \
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace vt { namespace util { namespace tls {
InnerClsOutTLS(tlcls, cls, type, var, InitTempTLS(init), InitStrTLS(var))
// Variant for static class TLS variables access
#define AccessClsImplTLS(cls, var) \
decltype(cls::TagTLS(var))::get()
cls::TagTLS(var).get()

}}} /* end namespace vt::util::tls */

Expand Down

0 comments on commit ba3e950

Please sign in to comment.