mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Get Fat Emacs working on Apple Silicon
This commit is contained in:
parent
3f9b39883f
commit
bf835de612
14 changed files with 294 additions and 144 deletions
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/ape.h"
|
||||
#include "libc/calls/blockcancel.internal.h"
|
||||
#include "libc/calls/blocksigs.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
|
@ -85,9 +86,9 @@ int sys_execve(const char *prog, char *const argv[], char *const envp[]) {
|
|||
(CanExecute((ape = "/usr/bin/ape")) ||
|
||||
CanExecute((ape = Join(firstnonnull(getenv("TMPDIR"),
|
||||
firstnonnull(getenv("HOME"), ".")),
|
||||
".ape-1.7", buf))) ||
|
||||
CanExecute((ape = Join(firstnonnull(getenv("HOME"), "."), ".ape-1.7",
|
||||
buf))))) {
|
||||
".ape-" APE_VERSION_STR, buf))) ||
|
||||
CanExecute((ape = Join(firstnonnull(getenv("HOME"), "."),
|
||||
".ape-" APE_VERSION_STR, buf))))) {
|
||||
shargs[0] = ape;
|
||||
shargs[1] = "-";
|
||||
shargs[2] = prog;
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -12,62 +12,62 @@ LIBC_TIME_A_HDRS := $(filter %.h,$(LIBC_TIME_A_FILES))
|
|||
LIBC_TIME_A_SRCS_S = $(filter %.S,$(LIBC_TIME_A_FILES))
|
||||
LIBC_TIME_A_SRCS_C = $(filter %.c,$(LIBC_TIME_A_FILES))
|
||||
|
||||
LIBC_TIME_A_SRCS = \
|
||||
$(LIBC_TIME_A_SRCS_S) \
|
||||
LIBC_TIME_A_SRCS = \
|
||||
$(LIBC_TIME_A_SRCS_S) \
|
||||
$(LIBC_TIME_A_SRCS_C)
|
||||
|
||||
LIBC_TIME_A_OBJS = \
|
||||
o/$(MODE)/usr/share/zoneinfo/.zip.o \
|
||||
$(LIBC_TIME_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(LIBC_TIME_A_SRCS_C:%.c=o/$(MODE)/%.o) \
|
||||
$(LIBC_TIME_A_SRCS_C:%.c=o/$(MODE)/%.o) \
|
||||
$(LIBC_TIME_ZONEINFOS:%=o/$(MODE)/%.zip.o)
|
||||
LIBC_TIME_A_OBJS = \
|
||||
$(LIBC_TIME_A_SRCS_S:%.S=o/$(MODE)/%.o) \
|
||||
$(LIBC_TIME_A_SRCS_C:%.c=o/$(MODE)/%.o) \
|
||||
$(LIBC_TIME_A_SRCS_C:%.c=o/$(MODE)/%.o) \
|
||||
$(LIBC_TIME_ZONEINFOS:%=o/$(MODE)/%.zip.o) \
|
||||
o/$(MODE)/usr/share/zoneinfo/.zip.o
|
||||
|
||||
LIBC_TIME_A_CHECKS = \
|
||||
$(LIBC_TIME_A).pkg \
|
||||
LIBC_TIME_A_CHECKS = \
|
||||
$(LIBC_TIME_A).pkg \
|
||||
$(LIBC_TIME_A_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
||||
LIBC_TIME_A_DIRECTDEPS = \
|
||||
LIBC_CALLS \
|
||||
LIBC_FMT \
|
||||
LIBC_INTRIN \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_NT_KERNEL32 \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_TIME_A_DIRECTDEPS = \
|
||||
LIBC_CALLS \
|
||||
LIBC_FMT \
|
||||
LIBC_INTRIN \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_NT_KERNEL32 \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
THIRD_PARTY_COMPILER_RT
|
||||
|
||||
LIBC_TIME_A_DEPS := \
|
||||
LIBC_TIME_A_DEPS := \
|
||||
$(call uniq,$(foreach x,$(LIBC_TIME_A_DIRECTDEPS),$($(x))))
|
||||
|
||||
$(LIBC_TIME_A): libc/time/ \
|
||||
$(LIBC_TIME_A).pkg \
|
||||
$(LIBC_TIME_A): libc/time/ \
|
||||
$(LIBC_TIME_A).pkg \
|
||||
$(LIBC_TIME_A_OBJS)
|
||||
|
||||
$(LIBC_TIME_A).pkg: \
|
||||
$(LIBC_TIME_A_OBJS) \
|
||||
$(LIBC_TIME_A).pkg: \
|
||||
$(LIBC_TIME_A_OBJS) \
|
||||
$(foreach x,$(LIBC_TIME_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
o/$(MODE)/libc/time/strftime.o: private \
|
||||
CFLAGS += \
|
||||
o/$(MODE)/libc/time/strftime.o: private \
|
||||
CFLAGS += \
|
||||
-fno-jump-tables
|
||||
|
||||
o/$(MODE)/libc/time/localtime.o: private \
|
||||
CFLAGS += \
|
||||
-fdata-sections \
|
||||
o/$(MODE)/libc/time/localtime.o: private \
|
||||
CFLAGS += \
|
||||
-fdata-sections \
|
||||
-ffunction-sections
|
||||
|
||||
# we need -O3 because:
|
||||
# we're dividing by constants
|
||||
o/$(MODE)/libc/time/iso8601.o \
|
||||
o/$(MODE)/libc/time/iso8601us.o: private \
|
||||
CFLAGS += \
|
||||
o/$(MODE)/libc/time/iso8601.o \
|
||||
o/$(MODE)/libc/time/iso8601us.o: private \
|
||||
CFLAGS += \
|
||||
-O3
|
||||
|
||||
o/$(MODE)/usr/share/zoneinfo/.zip.o: \
|
||||
o/$(MODE)/usr/share/zoneinfo/.zip.o: \
|
||||
usr/share/zoneinfo
|
||||
|
||||
o/$(MODE)/libc/time/kmonthname.o: libc/time/kmonthname.S
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue