Get Fat Emacs working on Apple Silicon

This commit is contained in:
Justine Tunney 2023-08-17 22:01:42 -07:00
parent 3f9b39883f
commit bf835de612
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
14 changed files with 294 additions and 144 deletions

View file

@ -18,7 +18,6 @@
*/
#include "libc/dce.h"
#include "libc/intrin/weaken.h"
#include "libc/log/backtrace.internal.h"
#include "libc/log/log.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/symbols.internal.h"

View file

@ -20,6 +20,7 @@
#include "libc/calls/struct/stat.h"
#include "libc/runtime/zipos.internal.h"
#include "libc/sysv/consts/ok.h"
#include "libc/sysv/consts/s.h"
#include "libc/sysv/errfuns.h"
#include "libc/zip.internal.h"
@ -43,7 +44,12 @@ int __zipos_access(struct ZiposUri *name, int amode) {
return -1;
}
int mode = GetZipCfileMode(z->map + cf);
int mode;
if (cf != ZIPOS_SYNTHETIC_DIRECTORY) {
mode = GetZipCfileMode(z->map + cf);
} else {
mode = S_IFDIR | 0555;
}
if (amode == F_OK) {
return 0;
}

View file

@ -33,16 +33,28 @@ static int64_t __zipos_lseek_impl(struct ZiposHandle *h, int64_t offset,
}
switch (whence) {
case SEEK_SET:
return offset;
if (offset >= 0) {
return offset;
} else {
return einval();
}
case SEEK_CUR:
if (!ckd_add(&pos, h->pos, offset)) {
return pos;
if (pos >= 0) {
return pos;
} else {
return einval();
}
} else {
return eoverflow();
}
case SEEK_END:
if (!ckd_sub(&pos, h->size, offset)) {
return pos;
if (pos >= 0) {
return pos;
} else {
return einval();
}
} else {
return eoverflow();
}
@ -61,7 +73,6 @@ static int64_t __zipos_lseek_impl(struct ZiposHandle *h, int64_t offset,
*/
int64_t __zipos_lseek(struct ZiposHandle *h, int64_t offset, unsigned whence) {
int64_t pos;
if (offset < 0) return einval();
pthread_mutex_lock(&h->lock);
if ((pos = __zipos_lseek_impl(h, offset, whence)) != -1) {
h->pos = pos;