__thread is not supported by all darwin versions and architectures,
use pthreads instead to allow for building darwin lsan on iossim.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
| lib/lsan/lsan_common_linux.cc | ||
|---|---|---|
| 37 ↗ | (On Diff #88553) | Please use some constant. Move the definition of kInvalidTid if you need to. |
| lib/lsan/lsan_common_mac.cc | ||
| 27 ↗ | (On Diff #88553) | same here |
| 28 ↗ | (On Diff #88553) | Can we come up with a better name for the struct? Perhaps something containing "thread_local_data"... |
| 35 ↗ | (On Diff #88553) | We're removing the "allocate" argument. Wasn't that necessary for something? Why did we have it in the first place? |
| lib/lsan/lsan_common_mac.cc | ||
|---|---|---|
| 35 ↗ | (On Diff #88553) | We had this so that we could return false for DisabledInThisThread without allocating any thread-local data if DisableInThisThread had never been called. It's possibly a small performance optimization, but I don't think it's significant, and now that we're using the pthread key for more data, I think it's now more complex than it's worth. I believe the idea of doing it that way came about was a remnant from trying to use __thread, which would fail if you accessed the value too early in the initialization process. |
| lib/lsan/lsan_common.h | ||
|---|---|---|
| 58 ↗ | (On Diff #88783) | Why does this have to fit into 24 bits? |
| lib/lsan/lsan_common.h | ||
|---|---|---|
| 58 ↗ | (On Diff #88783) | lsan_thread.cc already declared kInvalidThread as -1. Can we use this declaration and just move it here? |
LGTM with a nit.
| lib/lsan/lsan_common_mac.cc | ||
|---|---|---|
| 25 ↗ | (On Diff #88838) | Remove "thread_info", we already have "thread_local_data_t" below. (Or change this to a C++-ish declaration, up to you.) |
| lib/lsan/lsan_common_mac.cc | ||
|---|---|---|
| 40 ↗ | (On Diff #88838) | Oh, wait, we need a memset(0) + current_thread_id = kInvalidTid here or something like that. |
Initialize thread-local struct
Not sure if this is the best way to do the initialization, in terms of style.
My main concern is with the initialization of the AllocatorCache, I wasn't
sure how to do that outside of the way I did it here.
(The AllocatorCache doesn't show up until the next patch, but might as well account for it now.)
| lib/lsan/lsan_common_mac.cc | ||
|---|---|---|
| 42 ↗ | (On Diff #88839) | Hm, that's weird. Either use placement new, new(ptr) thread_local_data_t(), or just initialize this field-by-field (and remove the default values). |