mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 04:08:32 +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
|
@ -16,39 +16,19 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/log/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
#define IsDumb(s) \
|
||||
(s[0] == 'd' && s[1] == 'u' && s[2] == 'm' && s[3] == 'b' && !s[4])
|
||||
|
||||
/**
|
||||
* Indicates if ANSI terminal colors are inappropriate.
|
||||
*
|
||||
* Normally this variable should be false. We only set it to true if
|
||||
* we're running on an old version of Windows or the environment
|
||||
* variable `TERM` is set to `dumb`.
|
||||
*
|
||||
* We think colors should be the norm, since most software is usually
|
||||
* too conservative about removing them. Rather than using `isatty`
|
||||
* consider using sed for instances where color must be removed:
|
||||
*
|
||||
* sed 's/\x1b\[[;[:digit:]]*m//g' <color.txt >uncolor.txt
|
||||
*
|
||||
* For some reason, important software is configured by default in many
|
||||
* operating systems, to not only disable colors, but utf-8 too! Here's
|
||||
* an example of how a wrapper script can fix that for `less`.
|
||||
*
|
||||
* #!/bin/sh
|
||||
* LESSCHARSET=UTF-8 exec /usr/bin/less -RS "$@"
|
||||
*
|
||||
* Thank you for using colors!
|
||||
*/
|
||||
bool __nocolor;
|
||||
|
||||
__attribute__((__constructor__(20))) optimizesize textstartup void
|
||||
__nocolor_init(int argc, char **argv, char **envp, intptr_t *auxv) {
|
||||
char *s;
|
||||
__nocolor = IsWindows() || ((s = getenv("TERM")) && IsDumb(s));
|
||||
if ((s = getenv("TERM")))
|
||||
if (s[0] == 'd' && //
|
||||
s[1] == 'u' && //
|
||||
s[2] == 'm' && //
|
||||
s[3] == 'b' && //
|
||||
s[4] == '\0')
|
||||
__nocolor = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue