mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +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/runtime/runtime.h"
|
||||||
#include "libc/thread/thread.h"
|
#include "libc/thread/thread.h"
|
||||||
#include "libc/thread/threads.h"
|
#include "libc/thread/threads.h"
|
||||||
|
#include "libc/errno.h"
|
||||||
#include "third_party/dlmalloc/dlmalloc.h"
|
#include "third_party/dlmalloc/dlmalloc.h"
|
||||||
|
|
||||||
#if !FOOTERS || !MSPACES
|
#if !FOOTERS || !MSPACES
|
||||||
|
@ -102,8 +103,10 @@ static mstate get_arena(void) {
|
||||||
if (n == 50)
|
if (n == 50)
|
||||||
n = 0;
|
n = 0;
|
||||||
if (!n) {
|
if (!n) {
|
||||||
|
int e = errno;
|
||||||
i = sched_getcpu();
|
i = sched_getcpu();
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
|
errno = e;
|
||||||
i = atomic_fetch_add_explicit(&assign, 1, memory_order_relaxed);
|
i = atomic_fetch_add_explicit(&assign, 1, memory_order_relaxed);
|
||||||
i %= g_cpucount;
|
i %= g_cpucount;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue