mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +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
|
@ -19,9 +19,9 @@ typedef unsigned long jmp_buf[18];
|
|||
typedef unsigned long jmp_buf[26];
|
||||
#endif
|
||||
|
||||
void mcount(void);
|
||||
int daemon(int, int);
|
||||
unsigned long getauxval(unsigned long);
|
||||
void mcount(void) libcesque;
|
||||
int daemon(int, int) libcesque;
|
||||
unsigned long getauxval(unsigned long) libcesque;
|
||||
int setjmp(jmp_buf)
|
||||
libcesque returnstwice paramsnonnull();
|
||||
void longjmp(jmp_buf, int) libcesque wontreturn paramsnonnull();
|
||||
|
@ -37,28 +37,28 @@ void quick_exit(int) wontreturn;
|
|||
void abort(void) wontreturn;
|
||||
int atexit(void (*)(void)) paramsnonnull() libcesque;
|
||||
char *getenv(const char *) paramsnonnull() __wur nosideeffect libcesque;
|
||||
int putenv(char *);
|
||||
int setenv(const char *, const char *, int);
|
||||
int unsetenv(const char *);
|
||||
int clearenv(void);
|
||||
void fpreset(void);
|
||||
void *mmap(void *, uint64_t, int32_t, int32_t, int32_t, int64_t);
|
||||
int munmap(void *, uint64_t);
|
||||
int mprotect(void *, uint64_t, int);
|
||||
int msync(void *, size_t, int);
|
||||
int mlock(const void *, size_t);
|
||||
int munlock(const void *, size_t);
|
||||
long gethostid(void);
|
||||
int sethostid(long);
|
||||
char *getlogin(void);
|
||||
int getlogin_r(char *, size_t);
|
||||
int login_tty(int);
|
||||
int getpagesize(void);
|
||||
int syncfs(int) dontthrow;
|
||||
int vhangup(void);
|
||||
int getdtablesize(void);
|
||||
int sethostname(const char *, size_t);
|
||||
int acct(const char *);
|
||||
int putenv(char *) libcesque;
|
||||
int setenv(const char *, const char *, int) libcesque;
|
||||
int unsetenv(const char *) libcesque;
|
||||
int clearenv(void) libcesque;
|
||||
void fpreset(void) libcesque;
|
||||
void *mmap(void *, uint64_t, int32_t, int32_t, int32_t, int64_t) libcesque;
|
||||
int munmap(void *, uint64_t) libcesque;
|
||||
int mprotect(void *, uint64_t, int) libcesque;
|
||||
int msync(void *, size_t, int) libcesque;
|
||||
int mlock(const void *, size_t) libcesque;
|
||||
int munlock(const void *, size_t) libcesque;
|
||||
long gethostid(void) libcesque;
|
||||
int sethostid(long) libcesque;
|
||||
char *getlogin(void) libcesque;
|
||||
int getlogin_r(char *, size_t) libcesque;
|
||||
int login_tty(int) libcesque;
|
||||
int getpagesize(void) libcesque;
|
||||
int syncfs(int) dontthrow libcesque;
|
||||
int vhangup(void) libcesque;
|
||||
int getdtablesize(void) libcesque;
|
||||
int sethostname(const char *, size_t) libcesque;
|
||||
int acct(const char *) libcesque;
|
||||
|
||||
#if defined(_GNU_SOURCE) || defined(_COSMO_SOURCE)
|
||||
extern char **environ;
|
||||
|
@ -80,62 +80,62 @@ extern uint64_t kStartTsc;
|
|||
extern const char kNtSystemDirectory[];
|
||||
extern const char kNtWindowsDirectory[];
|
||||
extern size_t __virtualmax;
|
||||
extern size_t __virtualsize;
|
||||
extern size_t __stackmax;
|
||||
extern bool32 __isworker;
|
||||
/* utilities */
|
||||
void _intsort(int *, size_t);
|
||||
void _longsort(long *, size_t);
|
||||
void _intsort(int *, size_t) libcesque;
|
||||
void _longsort(long *, size_t) libcesque;
|
||||
/* diagnostics */
|
||||
void ShowCrashReports(void);
|
||||
int ftrace_install(void);
|
||||
int ftrace_enabled(int);
|
||||
int strace_enabled(int);
|
||||
void __print_maps(void);
|
||||
void __printargs(const char *);
|
||||
void ShowCrashReports(void) libcesque;
|
||||
int ftrace_install(void) libcesque;
|
||||
int ftrace_enabled(int) libcesque;
|
||||
int strace_enabled(int) libcesque;
|
||||
void __print_maps(void) libcesque;
|
||||
void __printargs(const char *) libcesque;
|
||||
/* builtin sh-like system/popen dsl */
|
||||
int _cocmd(int, char **, char **);
|
||||
int _cocmd(int, char **, char **) libcesque;
|
||||
/* executable program */
|
||||
char *GetProgramExecutableName(void);
|
||||
char *GetInterpreterExecutableName(char *, size_t);
|
||||
int __open_executable(void);
|
||||
char *GetProgramExecutableName(void) libcesque;
|
||||
char *GetInterpreterExecutableName(char *, size_t) libcesque;
|
||||
int __open_executable(void) libcesque;
|
||||
/* execution control */
|
||||
int verynice(void);
|
||||
void __warn_if_powersave(void);
|
||||
void _Exit1(int) libcesque wontreturn;
|
||||
void __paginate(int, const char *);
|
||||
void __paginate_file(int, const char *);
|
||||
int verynice(void) libcesque;
|
||||
void __warn_if_powersave(void) libcesque;
|
||||
void _Exit1(int) libcesque wontreturn libcesque;
|
||||
void __paginate(int, const char *) libcesque;
|
||||
void __paginate_file(int, const char *) libcesque;
|
||||
/* memory management */
|
||||
void _weakfree(void *);
|
||||
void *_mapanon(size_t) attributeallocsize((1)) mallocesque;
|
||||
void *_mapshared(size_t) attributeallocsize((1)) mallocesque;
|
||||
void CheckForMemoryLeaks(void);
|
||||
void CheckForFileLeaks(void);
|
||||
bool32 _isheap(const void *);
|
||||
void __enable_threads(void);
|
||||
void __oom_hook(size_t);
|
||||
void _weakfree(void *) libcesque;
|
||||
void *_mapanon(size_t) attributeallocsize((1)) mallocesque libcesque;
|
||||
void *_mapshared(size_t) attributeallocsize((1)) mallocesque libcesque;
|
||||
void CheckForMemoryLeaks(void) libcesque;
|
||||
void CheckForFileLeaks(void) libcesque;
|
||||
void __enable_threads(void) libcesque;
|
||||
void __oom_hook(size_t) libcesque;
|
||||
/* code morphing */
|
||||
void __morph_begin(void);
|
||||
void __morph_end(void);
|
||||
void __jit_begin(void);
|
||||
void __jit_end(void);
|
||||
void __clear_cache(void *, void *);
|
||||
void __morph_begin(void) libcesque;
|
||||
void __morph_end(void) libcesque;
|
||||
void __jit_begin(void) libcesque;
|
||||
void __jit_end(void) libcesque;
|
||||
void __clear_cache(void *, void *) libcesque;
|
||||
/* portability */
|
||||
bool32 IsGenuineBlink(void);
|
||||
bool32 IsCygwin(void);
|
||||
const char *GetCpuidOs(void);
|
||||
const char *GetCpuidEmulator(void);
|
||||
void GetCpuidBrand(char[13], uint32_t);
|
||||
long __get_rlimit(int);
|
||||
const char *__describe_os(void);
|
||||
long __get_sysctl(int, int);
|
||||
int __get_arg_max(void) pureconst;
|
||||
int __get_cpu_count(void) pureconst;
|
||||
long __get_avphys_pages(void) pureconst;
|
||||
long __get_phys_pages(void) pureconst;
|
||||
long __get_minsigstksz(void) pureconst;
|
||||
void __get_main_stack(void **, size_t *, int *);
|
||||
long __get_safe_size(long, long);
|
||||
char *__get_tmpdir(void);
|
||||
bool32 IsGenuineBlink(void) libcesque;
|
||||
bool32 IsCygwin(void) libcesque;
|
||||
const char *GetCpuidOs(void) libcesque;
|
||||
const char *GetCpuidEmulator(void) libcesque;
|
||||
void GetCpuidBrand(char[13], uint32_t) libcesque;
|
||||
long __get_rlimit(int) libcesque;
|
||||
const char *__describe_os(void) libcesque;
|
||||
long __get_sysctl(int, int) libcesque;
|
||||
int __granularity(void) pureconst libcesque;
|
||||
int __get_arg_max(void) pureconst libcesque;
|
||||
int __get_cpu_count(void) pureconst libcesque;
|
||||
long __get_avphys_pages(void) pureconst libcesque;
|
||||
long __get_phys_pages(void) pureconst libcesque;
|
||||
long __get_minsigstksz(void) pureconst libcesque;
|
||||
long __get_safe_size(long, long) libcesque;
|
||||
char *__get_tmpdir(void) libcesque;
|
||||
forceinline int __trace_disabled(int x) {
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue