mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-17 16:10:29 +00:00
Rewrite memory manager
Actually Portable Executable now supports Android. Cosmo's old mmap code required a 47 bit address space. The new implementation is very agnostic and supports both smaller address spaces (e.g. embedded) and even modern 56-bit PML5T paging for x86 which finally came true on Zen4 Threadripper Cosmopolitan no longer requires UNIX systems to observe the Windows 64kb granularity; i.e. sysconf(_SC_PAGE_SIZE) will now report the host native page size. This fixes a longstanding POSIX conformance issue, concerning file mappings that overlap the end of file. Other aspects of conformance have been improved too, such as the subtleties of address assignment and and the various subtleties surrounding MAP_FIXED and MAP_FIXED_NOREPLACE On Windows, mappings larger than 100 megabytes won't be broken down into thousands of independent 64kb mappings. Support for MAP_STACK is removed by this change; please use NewCosmoStack() instead. Stack overflow avoidance is now being implemented using the POSIX thread APIs. Please use GetStackBottom() and GetStackAddr(), instead of the old error-prone GetStackAddr() and HaveStackMemory() APIs which are removed.
This commit is contained in:
parent
7f6d0b8709
commit
6ffed14b9c
150 changed files with 1893 additions and 5634 deletions
|
@ -219,10 +219,9 @@ syscon mmap MAP_FILE 0 0 0 0 0 0 0 0 # consensus
|
|||
syscon mmap MAP_SHARED 1 1 1 1 1 1 1 1 # forced consensus & faked nt
|
||||
syscon mmap MAP_SHARED_VALIDATE 3 3 1 1 1 1 1 1 # weird linux thing
|
||||
syscon mmap MAP_PRIVATE 2 2 2 2 2 2 2 2 # forced consensus & faked nt
|
||||
syscon mmap MAP_STACK 6 6 6 6 6 6 6 6 # our definition
|
||||
syscon mmap MAP_TYPE 15 15 15 15 15 15 15 15 # mask for type of mapping
|
||||
syscon mmap MAP_FIXED 0x00000010 0x00000010 0x00000010 0x00000010 0x00000010 0x00000010 0x00000010 0x00000010 # unix consensus; openbsd appears to forbid; faked nt
|
||||
syscon mmap MAP_FIXED_NOREPLACE 0x08000000 0x08000000 0x00004010 0x00004010 0x08000000 0x08000000 0x08000000 0x08000000 # handled and defined by cosmo runtime; 0x100000 on linux 4.7+; MAP_FIXED|MAP_EXCL on FreeBSD
|
||||
syscon mmap MAP_FIXED_NOREPLACE 0x08000000 0x08000000 0x00004000 0x00004000 0x08000000 0x08000000 0x08000000 0x08000000 # handled and defined by cosmo runtime; 0x100000 on linux 4.7+; MAP_FIXED|MAP_EXCL on FreeBSD
|
||||
syscon mmap MAP_ANONYMOUS 0x00000020 0x00000020 0x00001000 0x00001000 0x00001000 0x00001000 0x00001000 0x00000020 # bsd consensus; faked nt
|
||||
syscon mmap MAP_GROWSDOWN 0x00000100 0x00000100 0 0 0 0 0 0 # use MAP_STACK; abstracted by MAP_STACK; may be passed to __sys_mmap() for low-level Linux fiddling
|
||||
syscon mmap MAP_LOCKED 0x00002000 0x00002000 0 0 0 0 0 0
|
||||
|
@ -293,8 +292,6 @@ syscon mprot PROT_NONE 0 0 0 0 0 0 0 0 # mmap, mprotect, unix
|
|||
syscon mprot PROT_READ 1 1 1 1 1 1 1 1 # mmap, mprotect, unix consensus
|
||||
syscon mprot PROT_WRITE 2 2 2 2 2 2 2 2 # mmap, mprotect, unix consensus
|
||||
syscon mprot PROT_EXEC 4 4 4 4 4 4 4 4 # mmap, mprotect, unix consensus
|
||||
syscon mprot PROT_GROWSDOWN 0x01000000 0x01000000 0 0 0 0 0 0 # intended for mprotect; see MAP_GROWSDOWN for mmap() (todo: what was 0x01000000 on nt)
|
||||
syscon mprot PROT_GROWSUP 0x02000000 0x02000000 0 0 0 0 0 0 # intended for mprotect; see MAP_GROWSDOWN for mmap()
|
||||
|
||||
# mremap() flags
|
||||
# the revolutionary praxis of realloc()
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mmap,MAP_FIXED_NOREPLACE,0x08000000,0x08000000,0x00004010,0x00004010,0x08000000,0x08000000,0x08000000,0x08000000
|
||||
.syscon mmap,MAP_FIXED_NOREPLACE,0x08000000,0x08000000,0x00004000,0x00004000,0x08000000,0x08000000,0x08000000,0x08000000
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mmap,MAP_STACK,6,6,6,6,6,6,6,6
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mprot,PROT_GROWSDOWN,0x01000000,0x01000000,0,0,0,0,0,0
|
|
@ -1,2 +0,0 @@
|
|||
#include "libc/sysv/consts/syscon.internal.h"
|
||||
.syscon mprot,PROT_GROWSUP,0x02000000,0x02000000,0,0,0,0,0,0
|
|
@ -33,7 +33,6 @@ COSMOPOLITAN_C_END_
|
|||
#define MAP_FILE 0
|
||||
#define MAP_SHARED 1
|
||||
#define MAP_PRIVATE 2
|
||||
#define MAP_STACK 6
|
||||
#define MAP_TYPE 15
|
||||
#define MAP_FIXED 16
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ extern const int PROT_NONE;
|
|||
extern const int PROT_READ;
|
||||
extern const int PROT_WRITE;
|
||||
extern const int PROT_EXEC;
|
||||
extern const int PROT_GROWSDOWN;
|
||||
extern const int PROT_GROWSUP;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/thread/pt.internal.h"
|
||||
|
@ -378,30 +377,8 @@ _init_systemfive_magnums:
|
|||
jnz 3b
|
||||
xchg %rbx,%rax
|
||||
stosq
|
||||
#if SYSDEBUG
|
||||
inc %r8d
|
||||
#endif
|
||||
jmp 2b
|
||||
5: nop
|
||||
#if SYSDEBUG
|
||||
push %rdi
|
||||
push %rsi
|
||||
push %r8
|
||||
call __describe_os
|
||||
mov %rax,%rdx
|
||||
pop %r8
|
||||
.weak __stracef
|
||||
ezlea __stracef,ax
|
||||
test %rax,%rax
|
||||
jz 5f
|
||||
ezlea .Llog,di
|
||||
mov %r8d,%esi
|
||||
push %rax
|
||||
call *%rax
|
||||
pop %rax
|
||||
5: pop %rsi
|
||||
pop %rdi
|
||||
#endif /* DEBUGSYS */
|
||||
pop %rdi
|
||||
pop %rsi
|
||||
pop %rbx
|
||||
|
@ -447,11 +424,3 @@ _init_systemfive_sigsys:
|
|||
_init_systemfive_done:
|
||||
nop
|
||||
.init.end 300,_init_systemfive,globl,hidden
|
||||
|
||||
#if SYSDEBUG
|
||||
.rodata.str1.1
|
||||
.Llog: .ascii STRACE_PROLOGUE
|
||||
.ascii "bell system five system call support"
|
||||
.asciz " %'u magnums loaded on %s\n"
|
||||
.previous
|
||||
#endif /* DEBUGSYS */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue