Skip to content

Commit 852ee50

Browse files
committed
Merge branch 'mr-tlschain' into 'master'
Fix problems with glibc setlocale See merge request cea/mpc_allocator!2
2 parents fb2d8df + 3745a78 commit 852ee50

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. The format
77
### Changed
88

99
- Move to Hwloc 2+
10+
- Initialize before main to avoid problems with setlocale
1011

1112
## [0.1]
1213

src/sctk_alloc_posix.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ SCTK_INTERN struct sctk_alloc_chain * sctk_alloc_posix_create_new_tls_chain(void
519519
* Setup the allocation chain for the current thread. It init an allocation chain and point it with
520520
* the TLS sctk_current_alloc_chain.
521521
**/
522+
522523
SCTK_INTERN struct sctk_alloc_chain * sctk_alloc_posix_setup_tls_chain(void)
523524
{
524525
//vars
@@ -544,6 +545,18 @@ SCTK_INTERN struct sctk_alloc_chain * sctk_alloc_posix_setup_tls_chain(void)
544545
return chain;
545546
}
546547

548+
/* Ensure Main thread has an allocator before the main */
549+
void __build_tls_chain(void) __attribute__ ((constructor));
550+
551+
void __build_tls_chain(void)
552+
{
553+
if(sctk_get_tls_chain() == NULL)
554+
{
555+
sctk_alloc_posix_setup_tls_chain();
556+
}
557+
}
558+
559+
547560
/************************* FUNCTION ************************/
548561
SCTK_PUBLIC void * sctk_calloc (size_t nmemb, size_t size)
549562
{

0 commit comments

Comments
 (0)