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:
Justine Tunney 2022-11-07 02:22:09 -08:00
parent 539bddce8c
commit c995838e5c
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
107 changed files with 1085 additions and 492 deletions

View file

@ -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;
}
}