mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 04:08:32 +00:00
Remove some problematic APIs
In order to improve our chances of success building other open source projects we shouldn't define APIs that'll lead any ./configure script astray. For example: - brk() and sbrk() can break mac/windows support - syscall() is a superb way to break portability - arch_prctl() is the greatest of all horror shows
This commit is contained in:
parent
7512318a2a
commit
32682f0ce7
24 changed files with 37 additions and 919 deletions
|
@ -38,7 +38,7 @@ void *xslurp(const char *path, size_t *opt_out_size) {
|
|||
ssize_t rc, size;
|
||||
res = NULL;
|
||||
if ((fd = open(path, O_RDONLY)) != -1) {
|
||||
if ((size = getfiledescriptorsize(fd)) != -1 &&
|
||||
if ((size = lseek(fd, 0, SEEK_END)) != -1 &&
|
||||
(res = memalign(PAGESIZE, size + 1))) {
|
||||
if (size > 2 * 1024 * 1024) {
|
||||
fadvise(fd, 0, size, MADV_SEQUENTIAL);
|
||||
|
@ -47,7 +47,7 @@ void *xslurp(const char *path, size_t *opt_out_size) {
|
|||
TryAgain:
|
||||
if ((rc = pread(fd, res + i, size - i, i)) != -1) {
|
||||
if (!(got = rc)) {
|
||||
if (getfiledescriptorsize(fd) == -1) {
|
||||
if (lseek(fd, 0, SEEK_CUR) == -1) {
|
||||
abort(); // TODO(jart): what is this
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue