mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
Iterate more on recent changes
This commit is contained in:
parent
7138399f96
commit
d0ad2694ed
22 changed files with 90 additions and 158 deletions
|
@ -41,6 +41,8 @@ static const char *GetFrameName(int x) {
|
|||
return "stack";
|
||||
} else if (IsGfdsFrame(x)) {
|
||||
return "g_fds";
|
||||
} else if (IsNsyncFrame(x)) {
|
||||
return "nsync";
|
||||
} else if (IsZiposFrame(x)) {
|
||||
return "zipos";
|
||||
} else if (IsMemtrackFrame(x)) {
|
||||
|
|
|
@ -44,11 +44,9 @@ static void *_mapframe_impl(void *p, int f) {
|
|||
if (!rc) {
|
||||
return p;
|
||||
} else {
|
||||
unassert(errno == ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
unassert(errno == ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -86,12 +84,16 @@ static void *_mapframe(void *p, int f) {
|
|||
*/
|
||||
void *_extend(void *p, size_t n, void *e, int f, intptr_t h) {
|
||||
char *q;
|
||||
unassert(!((uintptr_t)SHADOW(p) & (G - 1)));
|
||||
unassert((uintptr_t)p + (G << kAsanScale) <= h);
|
||||
#ifndef NDEBUG
|
||||
if ((uintptr_t)SHADOW(p) & (G - 1)) notpossible;
|
||||
if ((uintptr_t)p + (G << kAsanScale) > h) notpossible;
|
||||
#endif
|
||||
// TODO(jart): Make this spin less in non-ASAN mode.
|
||||
for (q = e; q < ((char *)p + n); q += 8) {
|
||||
if (!((uintptr_t)q & (G - 1))) {
|
||||
unassert(q + G <= (char *)h);
|
||||
#ifndef NDEBUG
|
||||
if (q + G > (char *)h) notpossible;
|
||||
#endif
|
||||
if (!_mapframe(q, f)) return 0;
|
||||
if (IsAsan()) {
|
||||
if (!((uintptr_t)SHADOW(q) & (G - 1))) {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
// nsync depends on this non-nsync lock
|
||||
|
||||
extern pthread_mutex_t __mmi_lock_obj;
|
||||
|
||||
void __mmi_lock(void) {
|
||||
|
|
|
@ -21,9 +21,11 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/describentoverlapped.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/internal.h"
|
||||
|
||||
__msabi extern typeof(WSARecv) *const __imp_WSARecv;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/describentoverlapped.internal.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
|
|
|
@ -25,6 +25,12 @@
|
|||
#define _X86_CC_AVX2 0
|
||||
#endif
|
||||
|
||||
#ifdef __F16C__
|
||||
#define _X86_CC_F16C 1
|
||||
#else
|
||||
#define _X86_CC_F16C 0
|
||||
#endif
|
||||
|
||||
#ifdef __AVXVNNI__
|
||||
#define _X86_CC_AVXVNNI 1
|
||||
#else
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
#define X86_DTES64 1H, ECX, 2, 0
|
||||
#define X86_ERMS 7H, EBX, 9, 0 /* broaadwell c. 2014 */
|
||||
#define X86_EST 1H, ECX, 7, 0
|
||||
#define X86_F16C 1H, ECX, 29, 0
|
||||
#define X86_F16C 1H, ECX, 29, _X86_CC_F16C
|
||||
#define X86_FDP_EXCPTN_ONLY 7H, EBX, 6, 0
|
||||
#define X86_FLUSH_L1D 7H, EDX, 28, 0
|
||||
#define X86_FMA 1H, ECX, 12, _X86_CC_FMA /* haswell c. 2013 */
|
||||
|
|
|
@ -288,9 +288,6 @@ static textwindows errno_t posix_spawn_nt_impl(
|
|||
char errno_buf[30];
|
||||
char oflags_buf[128];
|
||||
char openmode_buf[15];
|
||||
(void)errno_buf;
|
||||
(void)oflags_buf;
|
||||
(void)openmode_buf;
|
||||
switch (a->action) {
|
||||
case _POSIX_SPAWN_CLOSE:
|
||||
err = spawnfds_close(&fds, a->fildes);
|
||||
|
@ -331,13 +328,12 @@ static textwindows errno_t posix_spawn_nt_impl(
|
|||
|
||||
// figure out flags
|
||||
uint32_t dwCreationFlags = 0;
|
||||
if (attrp && *attrp) {
|
||||
if ((*attrp)->flags & POSIX_SPAWN_SETSID) {
|
||||
dwCreationFlags |= kNtDetachedProcess;
|
||||
}
|
||||
if ((*attrp)->flags & POSIX_SPAWN_SETPGROUP) {
|
||||
dwCreationFlags |= kNtCreateNewProcessGroup;
|
||||
}
|
||||
short flags = attrp && *attrp ? (*attrp)->flags : 0;
|
||||
if (flags & POSIX_SPAWN_SETSID) {
|
||||
dwCreationFlags |= kNtDetachedProcess;
|
||||
}
|
||||
if (flags & POSIX_SPAWN_SETPGROUP) {
|
||||
dwCreationFlags |= kNtCreateNewProcessGroup;
|
||||
}
|
||||
|
||||
// create process startinfo
|
||||
|
@ -361,8 +357,14 @@ static textwindows errno_t posix_spawn_nt_impl(
|
|||
}
|
||||
|
||||
// inherit signal mask
|
||||
sigset_t childmask;
|
||||
char maskvar[6 + 21];
|
||||
FormatUint64(stpcpy(maskvar, "_MASK="), sigmask);
|
||||
if (flags & POSIX_SPAWN_SETSIGMASK) {
|
||||
childmask = (*attrp)->sigmask;
|
||||
} else {
|
||||
childmask = sigmask;
|
||||
}
|
||||
FormatUint64(stpcpy(maskvar, "_MASK="), childmask);
|
||||
|
||||
// launch process
|
||||
int rc = -1;
|
||||
|
@ -490,7 +492,7 @@ errno_t posix_spawn(int *pid, const char *path,
|
|||
}
|
||||
if (!(child = vfork())) {
|
||||
can_clobber = true;
|
||||
sigset_t *childmask;
|
||||
sigset_t childmask;
|
||||
bool lost_cloexec = 0;
|
||||
struct sigaction dfl = {0};
|
||||
short flags = attrp && *attrp ? (*attrp)->flags : 0;
|
||||
|
@ -599,11 +601,11 @@ errno_t posix_spawn(int *pid, const char *path,
|
|||
fcntl(pfds[1], F_SETFD, FD_CLOEXEC);
|
||||
}
|
||||
if (flags & POSIX_SPAWN_SETSIGMASK) {
|
||||
childmask = &(*attrp)->sigmask;
|
||||
childmask = (*attrp)->sigmask;
|
||||
} else {
|
||||
childmask = &oldmask;
|
||||
childmask = oldmask;
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, childmask, 0);
|
||||
sigprocmask(SIG_SETMASK, &childmask, 0);
|
||||
if (!envp) envp = environ;
|
||||
execve(path, argv, envp);
|
||||
ChildFailed:
|
||||
|
|
|
@ -157,8 +157,12 @@ static textwindows int __proc_wait(int pid, int *wstatus, int options,
|
|||
|
||||
// check if killed or win32 error
|
||||
if (wi) {
|
||||
if (pr && !--pr->waiters && pr->status == PROC_UNDEAD) {
|
||||
__proc_free(pr);
|
||||
if (pr) {
|
||||
if (!--pr->waiters && pr->status == PROC_UNDEAD) {
|
||||
__proc_free(pr);
|
||||
}
|
||||
} else {
|
||||
--__proc.waiters;
|
||||
}
|
||||
__proc_unlock();
|
||||
if (wi == 1) {
|
||||
|
|
|
@ -17,6 +17,8 @@ COSMOPOLITAN_C_START_
|
|||
#define kMemtrackSize (0x1ffffffc0000 - kMemtrackStart)
|
||||
#define kFixedmapStart 0x300000040000
|
||||
#define kFixedmapSize (0x400000040000 - kFixedmapStart)
|
||||
#define kMemtrackNsyncStart 0x6fc000040000
|
||||
#define kMemtrackNsyncSize (0x6fcffffc0000 - kMemtrackNsyncStart)
|
||||
#define kMemtrackFdsStart 0x6fe000040000
|
||||
#define kMemtrackFdsSize (0x6feffffc0000 - kMemtrackFdsStart)
|
||||
#define kMemtrackZiposStart 0x6fd000040000
|
||||
|
@ -114,6 +116,11 @@ forceinline pureconst bool IsGfdsFrame(int x) {
|
|||
x <= (int)((kMemtrackFdsStart + kMemtrackFdsSize - 1) >> 16);
|
||||
}
|
||||
|
||||
forceinline pureconst bool IsNsyncFrame(int x) {
|
||||
return (int)(kMemtrackNsyncStart >> 16) <= x &&
|
||||
x <= (int)((kMemtrackNsyncStart + kMemtrackNsyncSize - 1) >> 16);
|
||||
}
|
||||
|
||||
forceinline pureconst bool IsZiposFrame(int x) {
|
||||
return (int)(kMemtrackZiposStart >> 16) <= x &&
|
||||
x <= (int)((kMemtrackZiposStart + kMemtrackZiposSize - 1) >> 16);
|
||||
|
|
|
@ -1808,7 +1808,7 @@
|
|||
6f900000-6f9fffff 64gb free
|
||||
6fa00000-6fafffff 64gb free
|
||||
6fb00000-6fbfffff 64gb free
|
||||
6fc00004-6fcffffb 64gb free
|
||||
6fc00004-6fcffffb 64gb nsync
|
||||
6fd00004-6fdffffb 64gb zipos
|
||||
6fe00004-6feffffb 64gb g_fds
|
||||
6ff00004-70000003 64gb free
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue