3 Commits

Author SHA1 Message Date
cyy
53e356a1c0 [2/N] Enable cppcoreguidelines-special-member-functions (#138670)
Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/138670
Approved by: https://github.com/sraikund16
2024-10-24 04:35:18 +00:00
4b3d17c0a2 Include Macros.h in ThreadLocal
Summary: This wasn't picking up C10_ANDROID.  Not sure how to prevent stuff like this.

Test Plan: Build for Android+gnustl, saw proper ThreadLocal being defined.

Reviewed By: swolchok

Differential Revision: D28720763

fbshipit-source-id: 58eb4ea80ad32a856fcea6d65e5c1c37ebf3bd55
2021-05-27 20:47:56 -07:00
7870450706 [PyTorch] Use c10::ThreadLocal instead thread_local in record_function.cpp for specific __GLIBCXX__ on Android (#57689)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57689
* Older versions of libgnustd have issues with thread_local C++ qualifier on Android devices prior to r17+. Use c10::tls<> wrapper with smart pointer semantics in such cases.
* Convenient macro `C10_DEFINE_TLS_static` was added as well:

```
  // Define static TLS variable str_tls_ of type std::string
  C10_DEFINE_TLS_static(std::string, str_tls_);

  //////// Excercise it ////////
  {
     *str_tls_ = "abc";
     assert(str_tls_->length(), 3);
  }
```
ghstack-source-id: 128233742

Test Plan: CI +

Reviewed By: ilia-cher

Differential Revision: D27875779

fbshipit-source-id: 7764f96ac1e121051c6ea66eabcedb9ef54d290e
2021-05-06 00:13:33 -07:00