mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Avoid clobbering errno
This commit is contained in:
parent
0a79c6961f
commit
1671283f1a
1 changed files with 3 additions and 0 deletions
3
third_party/dlmalloc/threaded.inc
vendored
3
third_party/dlmalloc/threaded.inc
vendored
|
@ -24,6 +24,7 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/threads.h"
|
||||
#include "libc/errno.h"
|
||||
#include "third_party/dlmalloc/dlmalloc.h"
|
||||
|
||||
#if !FOOTERS || !MSPACES
|
||||
|
@ -102,8 +103,10 @@ static mstate get_arena(void) {
|
|||
if (n == 50)
|
||||
n = 0;
|
||||
if (!n) {
|
||||
int e = errno;
|
||||
i = sched_getcpu();
|
||||
if (i == -1) {
|
||||
errno = e;
|
||||
i = atomic_fetch_add_explicit(&assign, 1, memory_order_relaxed);
|
||||
i %= g_cpucount;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue