mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 16:58:30 +00:00
Rewrite brk() and sbrk()
This change reduces the .bss memory requirement for all executables by O(64kb). The brk system calls are now fully tested and figured out and might be useful for tiny programs that only target System Five.
This commit is contained in:
parent
bc8532688b
commit
5005f2e446
23 changed files with 643 additions and 294 deletions
|
@ -43,6 +43,7 @@
|
|||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#include "libc/nt/winsock.h"
|
||||
#include "libc/runtime/brk.internal.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -103,8 +104,17 @@ privileged static inline bool kistextpointer(const void *p) {
|
|||
return _base <= (const unsigned char *)p && (const unsigned char *)p < _etext;
|
||||
}
|
||||
|
||||
privileged static inline unsigned char *kend(void) {
|
||||
unsigned char *p;
|
||||
if (_weaken(__brk) && (p = _weaken(__brk)->p)) {
|
||||
return p;
|
||||
} else {
|
||||
return _end;
|
||||
}
|
||||
}
|
||||
|
||||
privileged static inline bool kisimagepointer(const void *p) {
|
||||
return _base <= (const unsigned char *)p && (const unsigned char *)p < _end;
|
||||
return _base <= (const unsigned char *)p && (const unsigned char *)p < kend();
|
||||
}
|
||||
|
||||
privileged static inline bool kischarmisaligned(const char *p, signed char t) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue