mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-02 02:32:27 +00:00
Get rid of kmalloc()
This changes *NSYNC to allocate waiters on the stack so our locks don't need to depend on dynamic memory. This make our runtiem simpler, and it also fixes bugs with thread cancellation support.
This commit is contained in:
parent
77a7873057
commit
a359de7893
57 changed files with 405 additions and 472 deletions
|
@ -68,7 +68,6 @@
|
|||
extern int64_t __wincrashearly;
|
||||
bool32 __onntconsoleevent(uint32_t);
|
||||
void sys_setitimer_nt_reset(void);
|
||||
void kmalloc_unlock(void);
|
||||
|
||||
static textwindows wontreturn void AbortFork(const char *func) {
|
||||
#ifdef SYSDEBUG
|
||||
|
|
|
@ -12,19 +12,17 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define kAutomapStart 0x100080040000
|
||||
#define kAutomapSize (kMemtrackStart - kAutomapStart)
|
||||
#define kMemtrackStart 0x1fe7fffc0000
|
||||
#define kMemtrackSize (0x1ffffffc0000 - kMemtrackStart)
|
||||
#define kFixedmapStart 0x300000040000
|
||||
#define kFixedmapSize (0x400000040000 - kFixedmapStart)
|
||||
#define kMemtrackFdsStart 0x6fe000040000
|
||||
#define kMemtrackFdsSize (0x6feffffc0000 - kMemtrackFdsStart)
|
||||
#define kMemtrackZiposStart 0x6fd000040000
|
||||
#define kMemtrackZiposSize (0x6fdffffc0000 - kMemtrackZiposStart)
|
||||
#define kMemtrackKmallocStart 0x6fc000040000
|
||||
#define kMemtrackKmallocSize (0x6fcffffc0000 - kMemtrackKmallocStart)
|
||||
#define kMemtrackGran (!IsAsan() ? FRAMESIZE : FRAMESIZE * 8)
|
||||
#define kAutomapStart 0x100080040000
|
||||
#define kAutomapSize (kMemtrackStart - kAutomapStart)
|
||||
#define kMemtrackStart 0x1fe7fffc0000
|
||||
#define kMemtrackSize (0x1ffffffc0000 - kMemtrackStart)
|
||||
#define kFixedmapStart 0x300000040000
|
||||
#define kFixedmapSize (0x400000040000 - kFixedmapStart)
|
||||
#define kMemtrackFdsStart 0x6fe000040000
|
||||
#define kMemtrackFdsSize (0x6feffffc0000 - kMemtrackFdsStart)
|
||||
#define kMemtrackZiposStart 0x6fd000040000
|
||||
#define kMemtrackZiposSize (0x6fdffffc0000 - kMemtrackZiposStart)
|
||||
#define kMemtrackGran (!IsAsan() ? FRAMESIZE : FRAMESIZE * 8)
|
||||
|
||||
struct MemoryInterval {
|
||||
int x;
|
||||
|
@ -132,11 +130,6 @@ forceinline pureconst bool IsZiposFrame(int x) {
|
|||
x <= (int)((kMemtrackZiposStart + kMemtrackZiposSize - 1) >> 16);
|
||||
}
|
||||
|
||||
forceinline pureconst bool IsKmallocFrame(int x) {
|
||||
return (int)(kMemtrackKmallocStart >> 16) <= x &&
|
||||
x <= (int)((kMemtrackKmallocStart + kMemtrackKmallocSize - 1) >> 16);
|
||||
}
|
||||
|
||||
forceinline pureconst bool IsShadowFrame(int x) {
|
||||
return 0x7fff <= x && x < 0x10008000;
|
||||
}
|
||||
|
|
|
@ -1808,7 +1808,7 @@
|
|||
6f900000-6f9fffff 64gb free
|
||||
6fa00000-6fafffff 64gb free
|
||||
6fb00000-6fbfffff 64gb free
|
||||
6fc00004-6fcffffb 64gb kmalloc
|
||||
6fc00004-6fcffffb 64gb free
|
||||
6fd00004-6fdffffb 64gb zipos
|
||||
6fe00004-6feffffb 64gb g_fds
|
||||
6ff00004-70000003 64gb free
|
||||
|
|
|
@ -44,6 +44,7 @@ struct Syslib {
|
|||
dispatch_time_t (*dispatch_walltime)(const struct timespec *, int64_t);
|
||||
/* v2 (2023-09-10) */
|
||||
long (*pthread_self)(void);
|
||||
void (*dispatch_release)(dispatch_semaphore_t);
|
||||
};
|
||||
|
||||
extern struct Syslib *__syslib;
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "libc/cosmo.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/intrin/cmpxchg.h"
|
||||
#include "libc/intrin/kmalloc.h"
|
||||
#include "libc/intrin/promises.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
@ -91,7 +90,7 @@ static int __zipos_compare_names(const void *a, const void *b, void *c) {
|
|||
static void __zipos_generate_index(struct Zipos *zipos) {
|
||||
size_t c, i;
|
||||
zipos->records = GetZipCdirRecords(zipos->cdir);
|
||||
zipos->index = kmalloc(zipos->records * sizeof(size_t));
|
||||
zipos->index = _mapanon(zipos->records * sizeof(size_t));
|
||||
for (i = 0, c = GetZipCdirOffset(zipos->cdir); i < zipos->records;
|
||||
++i, c += ZIP_CFILE_HDRSIZE(zipos->map + c)) {
|
||||
zipos->index[i] = c;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue