mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Make improvements
- Clean up sigaction() code - Add a port scanner example - Introduce a ParseCidr() API - Clean up our futex abstraction code - Fix a harmless integer overflow in ParseIp() - Use kernel semaphores on NetBSD to make threads much faster
This commit is contained in:
parent
539bddce8c
commit
c995838e5c
107 changed files with 1085 additions and 492 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
const char *(DescribeTimespec)(char buf[45], int rc,
|
||||
const struct timespec *ts) {
|
||||
|
@ -30,7 +31,11 @@ const char *(DescribeTimespec)(char buf[45], int rc,
|
|||
(IsAsan() && !__asan_is_valid(ts, sizeof(*ts)))) {
|
||||
ksnprintf(buf, 45, "%p", ts);
|
||||
} else {
|
||||
ksnprintf(buf, 45, "{%ld, %ld}", ts->tv_sec, ts->tv_nsec);
|
||||
if (!memcmp(ts, ×pec_max, sizeof(*ts))) {
|
||||
strcpy(buf, "timespec_max");
|
||||
} else {
|
||||
ksnprintf(buf, 45, "{%ld, %ld}", ts->tv_sec, ts->tv_nsec);
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/calls/state.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
/**
|
||||
|
@ -36,9 +37,9 @@
|
|||
*/
|
||||
int gettid(void) {
|
||||
int tid;
|
||||
if (__tls_enabled && !__vforked) {
|
||||
tid = atomic_load_explicit(&__get_tls()->tib_tid, memory_order_relaxed);
|
||||
if (tid > 0) {
|
||||
if (VERY_LIKELY(__tls_enabled && !__vforked)) {
|
||||
tid = atomic_load_explicit(&__get_tls()->tib_tid, memory_order_acquire);
|
||||
if (VERY_LIKELY(tid > 0)) {
|
||||
return tid;
|
||||
}
|
||||
}
|
||||
|
|
0
libc/intrin/intrin.h
Executable file
0
libc/intrin/intrin.h
Executable file
Loading…
Add table
Add a link
Reference in a new issue