Skip to content

Commit d1562cb

Browse files
author
pippocao
committed
Merge branch 'develop'
2 parents 16528ca + e0daeab commit d1562cb

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changelog
2-
## [v1.4.8] - 2024-12-20
2+
## [v1.4.8] - 2024-12-30
33
- **Bug fix**: [Support for multi-byte character paths on Windows and long paths across platforms](https://github.com/Tencent/BqLog/issues/37), resolving issues with paths exceeding 256 bytes on all platforms.
44

55
## [v1.4.7] - 2024-11-15

src/bq_common/platform/no_lib_cpp_impl.cpp

+51-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
#include "bq_common/platform/no_lib_cpp_impl.h"
1313
#if defined(BQ_NO_LIBCPP)
14+
#include <pthread.h>
1415
#include "bq_common/bq_common.h"
1516

1617
void* operator new(size_t size)
@@ -102,6 +103,55 @@ extern "C" void __cxa_guard_abort(_guard_t* gv)
102103
// Release fence is used to make all stores performed by the construction function
103104
// visible in other threads.
104105
gv->state.store(CONSTRUCTION_NOT_YET_STARTED, bq::platform::memory_order::release);
105-
//////////////////////////////////////////////cxa_guard end/////////////////////////////////////
106106
}
107+
//////////////////////////////////////////////cxa_guard end/////////////////////////////////////
108+
109+
110+
//////////////////////////////////////////////__cxa_thread_atexit begin/////////////////////////////////////
111+
struct tls_entry {
112+
void (*destructor_)(void*);
113+
void* obj_;
114+
tls_entry* next_;
115+
};
116+
117+
static pthread_key_t stl_key;
118+
119+
static BQ_TLS tls_entry* tls_entry_head_ = nullptr;
120+
121+
static void on_thread_exit(void* param)
122+
{
123+
(void)param;
124+
while (tls_entry_head_) {
125+
tls_entry_head_->destructor_(tls_entry_head_->obj_);
126+
auto next = tls_entry_head_->next_;
127+
free(tls_entry_head_);
128+
tls_entry_head_ = next;
129+
}
130+
}
131+
132+
struct st_stl_key_initer {
133+
st_stl_key_initer()
134+
{
135+
pthread_key_create(&stl_key, &on_thread_exit);
136+
}
137+
};
138+
139+
extern "C" int __cxa_thread_atexit(void (*destructor)(void*), void* obj, void* destructor_handle)
140+
{
141+
(void)destructor_handle;
142+
static st_stl_key_initer key_initer;
143+
144+
tls_entry* entry = (tls_entry*)malloc(sizeof(tls_entry));
145+
if (!entry) {
146+
return -1;
147+
}
148+
entry->destructor_ = destructor;
149+
entry->obj_ = obj;
150+
entry->next_ = tls_entry_head_;
151+
tls_entry_head_ = entry;
152+
153+
return 0;
154+
}
155+
//////////////////////////////////////////////__cxa_thread_atexit end/////////////////////////////////////
156+
107157
#endif

0 commit comments

Comments
 (0)