Fix bugs and make improvements

- Get clone() working on FreeBSD
- Increase some Python build quotas
- Add more atomic builtins to chibicc
- Fix ASAN poisoning of alloca() memory
- Make MODE= mandatory link path tinier
- Improve the examples folder a little bit
- Start working on some more resource limits
- Make the linenoise auto-complete UI as good as GNU readline
- Update compile.com, avoiding AVX codegen on non-AVX systems
- Make sure empty path to syscalls like opendir raises ENOENT
- Correctly polyfill ENOENT vs. ENOTDIR on the New Technology
- Port bestline's paredit features to //third_party/linenoise
- Remove workarounds for RHEL 5.0 bugs that were fixed in 5.1
This commit is contained in:
Justine Tunney 2022-04-20 09:56:53 -07:00
parent c3fb624647
commit ae638c0850
181 changed files with 2994 additions and 1367 deletions

View file

@ -32,22 +32,21 @@
*/
void *xslurp(const char *path, size_t *opt_out_size) {
int fd;
ssize_t rc;
size_t i, got;
char *res, *p;
struct stat st;
ssize_t rc, size;
res = NULL;
if ((fd = open(path, O_RDONLY)) != -1) {
if (fstat(fd, &st) != -1 && (res = valloc(st.st_size + 1))) {
if (st.st_size > 2 * 1024 * 1024) {
fadvise(fd, 0, st.st_size, MADV_SEQUENTIAL);
if ((size = getfiledescriptorsize(fd)) != -1 && (res = valloc(size + 1))) {
if (size > 2 * 1024 * 1024) {
fadvise(fd, 0, size, MADV_SEQUENTIAL);
}
for (i = 0; i < st.st_size; i += got) {
for (i = 0; i < size; i += got) {
TryAgain:
if ((rc = pread(fd, res + i, st.st_size - i, i)) != -1) {
if ((rc = pread(fd, res + i, size - i, i)) != -1) {
if (!(got = rc)) {
if (fstat(fd, &st) == -1) {
abort();
if (getfiledescriptorsize(fd) == -1) {
abort(); // TODO(jart): what is this
}
}
} else if (errno == EINTR) {
@ -60,7 +59,7 @@ void *xslurp(const char *path, size_t *opt_out_size) {
}
if (res) {
if (opt_out_size) {
*opt_out_size = st.st_size;
*opt_out_size = size;
}
res[i] = '\0';
}