<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96254>96254</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc] Make the freelist allocator threadsafe
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
PiJoules
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PiJoules
</td>
</tr>
</table>
<pre>
The allocator should use some locking mechanism to ensure there aren't any races when using the same global storage. The simple way is to use mutexes provided by the platform. Some baremetal targets may provide mutexes externally via an SDK, in which case, we'd need to provide some interface for libc such that we can use external mutex implementations. We can provide something akin to what glibc does with pthreads where we can have
1. An opaque mutex structure of some guaranteed size and alignment
2. A mutex lock function
3. A mutex unlock function
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxUU0-PmzoQ_zTmMlpEDCHJgUPei3J4T5UqbaWeBzNgd42d2uNk009fGZLu9gKSZ-b3z2OM0UyOqBPbf4SUX81_PlmKQkqxPRWYWPvQPU-L3g_37psmQGu9QvYBovbJDpAiQfQzgfXqzbgJZlIanYkzsAdyMQUC1hQIMJATcseA7g4BFUW4aXKQYp5jTRBxJpis79FCZB9wohIybTTzxRLc8A4mZuBMOyemd4pwCf5qBhqgvy8oF4s8-jCX8JqF9RhoJkYLjGEijjDj_Tn0B4TemYJDa-9wNQjo4PX0v5D_gnFw00ZpUBgpH9xIyN0AjmjISp5ASwjGMYURFcHoA1jTK4hJaWCNDDcChW6R_mRb6WFxN5NjZONdLOH72voZm3VOCd-My6y3DDgtBIPPQRrWcGEdCIcl1kBPPo1XEtVJVMf1uynh6MBf8Gd62IfIISnON-XH1ciUMKDj7DGaXwToBkBrJpdVrjiyhONjPt89jMmpLH-t1h_V5P6qF0NXD4f6gAV1m91mf5C7bdUWulP7fY3VKOmw3zS1HNtxj5tx16idbFt16AvTyUo2VSsrWW83TVtS3dCuUdW-rSspNySaimY0trT2Opc-TIWJMVF3aOW2KSz2ZONj4XN0j2UPXW5_6dMURVNZEzl-ALBhuzySZWB7gi_4tiw0jIEoN396E4_8caQiBdtp5ksU9VHIs5DnybBOfan8LOQ54z9-L5fgf5BiIc-L2ijkeRV87eTvAAAA__8l90Ep">