Created
June 24, 2023 20:13
-
-
Save bartoldeman/7f894f0e759b4472de60507a6a3e9045 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/default-configure b/default-configure | |
index bfbf00f64..b376f3dd7 100755 | |
--- a/default-configure | |
+++ b/default-configure | |
@@ -23,7 +23,7 @@ if [ ! -f $CONF_FILE ]; then | |
fi | |
CONF=`cat $CONF_FILE` | |
-CONF=`echo -n "$CONF"| sed '/^config {/d' | sed '/^}/d' | tr '\n' ' ' ` | |
+CONF=`printf "$CONF"| sed '/^config {/d' | sed '/^}/d' | tr '\n' ' ' ` | |
SUFFIX="" | |
while [ "$#" != "0" ]; do | |
diff --git a/etc/global.conf b/etc/global.conf | |
index 3f1db0148..c9d7d181d 100644 | |
--- a/etc/global.conf | |
+++ b/etc/global.conf | |
@@ -428,9 +428,9 @@ else | |
$xxx_pref = strdel($xxxx, strchr($xxxx, "*"), 999); | |
$xxx_suff = strsplit($xxxx, strchr($xxxx, "*") + 1, 999); | |
if (strchr($xxx_pref, "/") == 0) | |
- $xxxx = shell("cd '", $xxx_pref, "' 2>/dev/null && echo -n *") | |
+ $xxxx = shell("cd '", $xxx_pref, "' 2>/dev/null && printf *") | |
else | |
- $xxxx = shell("cd '", $DOSEMU_IMAGE_DIR, "/", $xxx_pref, "' 2>/dev/null && echo -n *") | |
+ $xxxx = shell("cd '", $DOSEMU_IMAGE_DIR, "/", $xxx_pref, "' 2>/dev/null && printf *") | |
endif | |
if ($DOSEMU_SHELL_RETURN) | |
abort "**** directory ", $xxx_pref, " not accessible"; | |
diff --git a/scripts/mkpluginhooks b/scripts/mkpluginhooks | |
index 2368b5512..8053275bb 100755 | |
--- a/scripts/mkpluginhooks | |
+++ b/scripts/mkpluginhooks | |
@@ -20,7 +20,7 @@ gendummy() { | |
if [ "$1" = "clean" ]; then | |
rm -f $INC/$HDR | |
else | |
- echo -n "" >$INC/$HDR.$$ | |
+ printf "" >$INC/$HDR.$$ | |
fi | |
done | |
} | |
diff --git a/src/Makefile.common.post b/src/Makefile.common.post | |
index ff841d0e4..7baa0d756 100644 | |
--- a/src/Makefile.common.post | |
+++ b/src/Makefile.common.post | |
@@ -91,8 +91,10 @@ VS = $(subst .,_,$(notdir $(1)))_START | |
$(AS_LD) $(AS_LDFLAGS) -static $(if $($(call VS,$<)), \ | |
--section-start .text=$($(call VS,$<))) -o $@.elf _$@ | |
$(XOBJCOPY) -j .text -O binary $@.elf $@.bin | |
- $(OBJCOPY) -I binary -O $(O_BDFARCH) \ | |
- --add-section .note.GNU-stack=/dev/null $@.bin $@_ | |
+ echo "unsigned char _binary_$*_o_bin_start[] = {" > $@_blob.c | |
+ hexdump -v -e '"0x" 1/1 "%02X" ", "' $@.bin >> $@_blob.c | |
+ echo "};" >> $@_blob.c | |
+ $(CC) -c $@_blob.c -o $@_ | |
nm -g -n _$@ | gawk '\ | |
BEGIN {\ | |
print "// Warning: autogenerated";\ | |
diff --git a/src/arch/linux/Makefile.main b/src/arch/linux/Makefile.main | |
index fa84ed7d5..0130e1ffe 100644 | |
--- a/src/arch/linux/Makefile.main | |
+++ b/src/arch/linux/Makefile.main | |
@@ -77,9 +77,10 @@ $(top_builddir)/etc/Xfonts/%.pcf.gz: $(REALTOPDIR)/etc/%.bdf | $(top_builddir)/e | |
$(LIBS_): | $(top_builddir)/lib | |
$(BINPATH)/bin/$(DOSBIN): $(LIBS_) | |
- $(LD) $(ALL_LDFLAGS) $(DOSBIN_LDFLAGS) -o $@ \ | |
- -Wl,--whole-archive $(LIBS_) -Wl,--no-whole-archive $(LIBS) \ | |
- -Wl,-Map=$(BINPATH)/bin/dosemu.map | |
+ $(LD) $(ALL_LDFLAGS) $(DOSBIN_LDFLAGS) -o $@ $(LIBS_) $(LIBS) | |
+#\ | |
+# -Wl,--whole-archive $(LIBS_) -Wl,--no-whole-archive $(LIBS) \ | |
+# -Wl,-Map=$(BINPATH)/bin/dosemu.map | |
$(BINPATH)/bin/dosemu: $(SRCPATH)/dosemu.systemwide $(SRCPATH)/dosemu | |
cp $< $@ | |
diff --git a/src/arch/linux/async/signal.c b/src/arch/linux/async/signal.c | |
index 458a6c197..0512b40b7 100644 | |
--- a/src/arch/linux/async/signal.c | |
+++ b/src/arch/linux/async/signal.c | |
@@ -318,6 +318,9 @@ static void abort_signal(int sig, siginfo_t *si, void *uc) | |
_exit(sig); | |
} | |
+#ifdef __APPLE__ | |
+uint64_t _scp_cr2; | |
+#endif | |
SIG_PROTO_PFX | |
static void minfault(int sig, siginfo_t *si, void *uc) | |
{ | |
@@ -337,6 +340,9 @@ static void minfault(int sig, siginfo_t *si, void *uc) | |
if (_scp_trapno == 0xc) | |
_scp_trapno = 0xe; | |
#endif | |
+#ifdef __APPLE__ | |
+ _scp_cr2 = si->si_addr; | |
+#endif | |
#ifdef X86_EMULATOR | |
if (IS_EMU_JIT() && e_emu_fault(scp, in_vm86)) | |
return; | |
@@ -475,8 +481,10 @@ signal_pre_init(void) | |
newsetqsig(SIGHUP, leavedos_signal); | |
// newsetqsig(SIGTERM, leavedos_emerg); | |
/* below ones are initialized by other subsystems */ | |
+#ifdef SIG_ACQUIRE | |
setup_nf_sig(SIG_ACQUIRE); | |
setup_nf_sig(SIG_RELEASE); | |
+#endif | |
setup_nf_sig(SIGWINCH); | |
setup_nf_sig(SIGPROF); | |
/* call that after all non-fatal sigs set up */ | |
diff --git a/src/base/core/emu.c b/src/base/core/emu.c | |
index 864c44280..cab8e79f1 100644 | |
--- a/src/base/core/emu.c | |
+++ b/src/base/core/emu.c | |
@@ -279,8 +279,17 @@ static void c_nothr(void) | |
* DANG_END_FUNCTION | |
* | |
*/ | |
+ | |
int main(int argc, char **argv, char * const *envp) | |
{ | |
+extern void register_remapper_init(void); | |
+extern void cp437_init(void); | |
+extern void multibyte_init(void); | |
+extern void utf8_init(void); | |
+ register_remapper_init(); | |
+ cp437_init(); | |
+ multibyte_init(); | |
+ utf8_init(); | |
dosemu_envp = envp; | |
setlocale(LC_ALL,""); | |
srand(time(NULL)); | |
diff --git a/src/base/emu-i386/cputime.c b/src/base/emu-i386/cputime.c | |
index 5a901754f..78efe7bcd 100644 | |
--- a/src/base/emu-i386/cputime.c | |
+++ b/src/base/emu-i386/cputime.c | |
@@ -94,7 +94,11 @@ static void idle_hlt_thr(void *arg); | |
static hitimer_t do_gettime(void) | |
{ | |
struct timespec tv; | |
+#ifdef CLOCK_MONOTONIC_COURSE | |
int err = clock_gettime(CLOCK_MONOTONIC_COARSE, &tv); | |
+#else | |
+ int err = clock_gettime(CLOCK_MONOTONIC, &tv); | |
+#endif | |
if (err) { | |
error("Cannot get time!\n"); | |
leavedos(49); | |
diff --git a/src/base/emu-i386/simx86/codegen-x86.c b/src/base/emu-i386/simx86/codegen-x86.c | |
index 9b42ac7df..efae20fb1 100644 | |
--- a/src/base/emu-i386/simx86/codegen-x86.c | |
+++ b/src/base/emu-i386/simx86/codegen-x86.c | |
@@ -3319,8 +3319,8 @@ static void Exec_x86_post(unsigned long flg, unsigned int mem_ref) | |
#define EXEC_CLOBBERS | |
#endif | |
asm(".text\n" | |
- ".global do_seq_start\n" | |
- "do_seq_start:\n" | |
+ ".global _do_seq_start\n" | |
+ "_do_seq_start:\n" | |
"push "R_REG(dx)"\n" | |
"jmp *"R_REG(ax)"\n"); | |
#ifdef __cplusplus | |
diff --git a/src/base/emu-i386/simx86/cpatch.c b/src/base/emu-i386/simx86/cpatch.c | |
index 2103ae66f..adc71af2e 100644 | |
--- a/src/base/emu-i386/simx86/cpatch.c | |
+++ b/src/base/emu-i386/simx86/cpatch.c | |
@@ -365,7 +365,7 @@ asm ( | |
" pushl %esi\n" /* push source address */ | |
" pushl %esp\n" /* push stack */ | |
" cld\n" | |
-" call rep_movs_stos\n" | |
+" call _rep_movs_stos\n" | |
" addl $4,%esp\n" /* remove stack parameter */ | |
" popl %esi\n" /* obtain changed source address */ | |
" popl %edi\n" /* obtain changed dest address */ | |
@@ -429,7 +429,7 @@ asm ( | |
" pushq %rsi\n" | |
" movq %rsp,%rdi\n" /* pass stack address in %rdi */ | |
" cld\n" | |
-" call rep_movs_stos\n" | |
+" call _rep_movs_stos\n" | |
" popq %rsi\n" /* restore regs */ | |
" popq %rdi\n" | |
" popq %rcx\n" | |
@@ -444,14 +444,14 @@ asm ( | |
asm ( | |
".text\n" | |
-"stub_stk_16__:.globl stub_stk_16__\n"STUB_STK(stk_16) | |
-"stub_stk_32__:.globl stub_stk_32__\n"STUB_STK(stk_32) | |
-"stub_wri_8__: .globl stub_wri_8__\n "STUB_WRI(wri_8) | |
-"stub_wri_16__:.globl stub_wri_16__\n"STUB_WRI(wri_16) | |
-"stub_wri_32__:.globl stub_wri_32__\n"STUB_WRI(wri_32) | |
-"stub_read_8__: .globl stub_read_8__\n "STUB_READ(read_8) | |
-"stub_read_16__:.globl stub_read_16__\n"STUB_READ(read_16) | |
-"stub_read_32__:.globl stub_read_32__\n"STUB_READ(read_32) | |
+"stub_stk_16__:.globl stub_stk_16__\n"STUB_STK(_stk_16) | |
+"stub_stk_32__:.globl stub_stk_32__\n"STUB_STK(_stk_32) | |
+"stub_wri_8__: .globl stub_wri_8__\n "STUB_WRI(_wri_8) | |
+"stub_wri_16__:.globl stub_wri_16__\n"STUB_WRI(_wri_16) | |
+"stub_wri_32__:.globl stub_wri_32__\n"STUB_WRI(_wri_32) | |
+"stub_read_8__: .globl stub_read_8__\n "STUB_READ(_read_8) | |
+"stub_read_16__:.globl stub_read_16__\n"STUB_READ(_read_16) | |
+"stub_read_32__:.globl stub_read_32__\n"STUB_READ(_read_32) | |
); | |
/* call N(%ebx) */ | |
diff --git a/src/base/init/parser.y b/src/base/init/parser.y | |
index 87c452f26..ded64ddbb 100644 | |
--- a/src/base/init/parser.y | |
+++ b/src/base/init/parser.y | |
@@ -2471,7 +2471,7 @@ static void set_hdimage(struct disk *dptr, char *name) | |
c_printf("Setting up hdimage %s\n", name); | |
if (l && strlen(l) == 4) { | |
- const char *tmpl = "eval echo -n `cat %s`"; | |
+ const char *tmpl = "eval printf `cat %s`"; | |
char *cmd, path[1024], *rname; | |
FILE *f; | |
size_t ret; | |
diff --git a/src/base/lib/mapping/mapfile.c b/src/base/lib/mapping/mapfile.c | |
index 818072686..4409bc811 100644 | |
--- a/src/base/lib/mapping/mapfile.c | |
+++ b/src/base/lib/mapping/mapfile.c | |
@@ -89,12 +89,14 @@ static void *alias_mapping_file(int cap, void *target, size_t mapsize, int prote | |
addr = mmap(target, mapsize, protect & ~PROT_EXEC, MAP_SHARED | fixed, | |
p->fd, offs); | |
if (addr != MAP_FAILED) { | |
+#ifndef __APPLE__ | |
int ret = mprotect(addr, mapsize, protect); | |
if (ret == -1) { | |
perror("mprotect()"); | |
error("shared memory mprotect failed, exiting\n"); | |
exit(2); | |
} | |
+#endif | |
} else | |
perror("mmap()"); | |
} | |
diff --git a/src/base/lib/mapping/mapping.c b/src/base/lib/mapping/mapping.c | |
index 2c1a4ed7a..e9e2c7969 100644 | |
--- a/src/base/lib/mapping/mapping.c | |
+++ b/src/base/lib/mapping/mapping.c | |
@@ -422,8 +422,8 @@ int mprotect_mapping(int cap, dosaddr_t targ, size_t mapsize, int protect) | |
mprotect_kvm(cap, targ, mapsize, protect); | |
if (!(cap & MAPPING_LOWMEM)) { | |
ret = mprotect(MEM_BASE32(targ), mapsize, protect); | |
- if (ret) | |
- error("mprotect() failed: %s\n", strerror(errno)); | |
+ //if (ret) | |
+ // error("mprotect() failed: %s\n", strerror(errno)); | |
return ret; | |
} | |
for (i = 0; i < MAX_BASES; i++) { | |
@@ -436,7 +436,7 @@ int mprotect_mapping(int cap, dosaddr_t targ, size_t mapsize, int protect) | |
cap, addr, mapsize, protect); | |
ret = mprotect(addr, mapsize, protect); | |
if (ret) { | |
- error("mprotect() failed: %s\n", strerror(errno)); | |
+ //error("mprotect() failed: %s\n", strerror(errno)); | |
return ret; | |
} | |
} | |
@@ -930,6 +930,9 @@ close_kmem (void) | |
void *mapping_find_hole(unsigned long start, unsigned long stop, | |
unsigned long size) | |
{ | |
+#ifdef __APPLE__ | |
+ return MAP_FAILED; | |
+#else | |
FILE *fp; | |
unsigned long beg, end, pend; | |
int fd, ret; | |
@@ -963,6 +966,7 @@ void *mapping_find_hole(unsigned long start, unsigned long stop, | |
if (ret != 2) | |
return MAP_FAILED; | |
return (void *)pend; | |
+#endif | |
} | |
int mcommit(void *ptr, size_t size) | |
diff --git a/src/base/lib/mcontext/asm.SS b/src/base/lib/mcontext/asm.SS | |
index e27ca3f64..fefe87760 100644 | |
--- a/src/base/lib/mcontext/asm.SS | |
+++ b/src/base/lib/mcontext/asm.SS | |
@@ -25,8 +25,8 @@ | |
#define GET _getmcontext | |
#elif defined(__x86_64__) | |
#define NEEDAMD64CONTEXT 1 | |
-#define SET _setmcontext | |
-#define GET _getmcontext | |
+#define SET __setmcontext | |
+#define GET __getmcontext | |
#elif defined(__arm__) | |
#define NEEDARMCONTEXT 1 | |
#define SET _setmcontext | |
diff --git a/src/base/lib/timer/evtimer.c b/src/base/lib/timer/evtimer.c | |
index e67cda2cb..862275851 100644 | |
--- a/src/base/lib/timer/evtimer.c | |
+++ b/src/base/lib/timer/evtimer.c | |
@@ -39,8 +39,18 @@ | |
#endif | |
#include "evtimer.h" | |
+#ifdef __APPLE__ | |
+#include <dispatch/dispatch.h> | |
+#endif | |
+ | |
struct evtimer { | |
+#ifdef __APPLE__ | |
+ dispatch_queue_t queue; | |
+ dispatch_source_t source; | |
+ int suspended; | |
+#else | |
timer_t tmr; | |
+#endif | |
void (*callback)(int ticks, void *); | |
void *arg; | |
clockid_t clk_id; | |
@@ -53,14 +63,26 @@ struct evtimer { | |
int in_cbk; | |
}; | |
+#ifdef __APPLE__ | |
+static void evhandler(void *arg) | |
+#else | |
static void evhandler(union sigval sv) | |
+#endif | |
{ | |
int bl; | |
- struct evtimer *t = sv.sival_ptr; | |
+ struct evtimer *t; | |
+#ifdef __APPLE__ | |
+ t = arg; | |
+#else | |
+ t = sv.sival_ptr; | |
+#endif | |
pthread_mutex_lock(&t->block_mtx); | |
bl = t->blocked; | |
- t->ticks += timer_getoverrun(t->tmr) + 1; | |
+#ifndef __APPLE__ | |
+ t->ticks += timer_getoverrun(t->tmr); | |
+#endif | |
+ t->ticks++; | |
if (!bl) | |
t->in_cbk++; | |
pthread_mutex_unlock(&t->block_mtx); | |
@@ -74,21 +96,45 @@ static void evhandler(union sigval sv) | |
} | |
} | |
+#ifdef __APPLE__ | |
+static void evtimer_cancel(void *arg) | |
+{ | |
+ struct evtimer *t = arg; | |
+ dispatch_release(t->source); | |
+ dispatch_release(t->queue); | |
+ t->source = NULL; | |
+ t->queue = NULL; | |
+} | |
+#endif | |
+ | |
void *evtimer_create(void (*cbk)(int ticks, void *), void *arg) | |
{ | |
struct evtimer *t; | |
clockid_t id = CLOCK_MONOTONIC; | |
+#ifndef __APPLE__ | |
struct sigevent sev = { .sigev_notify = SIGEV_THREAD, | |
.sigev_notify_function = evhandler }; | |
timer_t tmr; | |
int rc; | |
+#endif | |
t = malloc(sizeof(*t)); | |
assert(t); | |
+#ifdef __APPLE__ | |
+ t->queue = dispatch_queue_create("timerqueue", 0); | |
+ t->source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, | |
+ 0, 0, t->queue); | |
+ t->suspended = 1; | |
+ dispatch_set_context(t->source, t); | |
+ dispatch_source_set_event_handler_f(t->source, evhandler); | |
+ dispatch_source_set_cancel_handler_f(t->source, evtimer_cancel); | |
+ t->start.tv_sec = t->start.tv_nsec = 0; | |
+#else | |
sev.sigev_value.sival_ptr = t; | |
rc = timer_create(id, &sev, &tmr); | |
assert(rc != -1); | |
t->tmr = tmr; | |
+#endif | |
t->callback = cbk; | |
t->arg = arg; | |
t->clk_id = id; | |
@@ -105,7 +151,11 @@ void evtimer_delete(void *tmr) | |
{ | |
struct evtimer *t = tmr; | |
+#ifndef __APPLE__ | |
timer_delete(t->tmr); | |
+#else | |
+ dispatch_source_cancel(t->source); | |
+#endif | |
pthread_mutex_destroy(&t->start_mtx); | |
pthread_mutex_destroy(&t->block_mtx); | |
pthread_cond_destroy(&t->block_cnd); | |
@@ -115,17 +165,29 @@ void evtimer_delete(void *tmr) | |
void evtimer_set_rel(void *tmr, uint64_t ns, int periodic) | |
{ | |
struct evtimer *t = tmr; | |
+ struct timespec start; | |
+ | |
+ clock_gettime(t->clk_id, &start); | |
+#ifdef __APPLE__ | |
+ dispatch_time_t dstart; | |
+ if (!t->suspended) | |
+ dispatch_suspend(t->source); | |
+ dstart = dispatch_time(DISPATCH_TIME_NOW, ns); | |
+ dispatch_source_set_timer(t->source, dstart, ns, 0); | |
+ dispatch_resume(t->source); | |
+ t->suspended = 0; | |
+#else | |
struct itimerspec i = {}; | |
- struct timespec rel, abs, start; | |
+ struct timespec rel, abs; | |
rel.tv_sec = ns / NANOSECONDS_PER_SECOND; | |
rel.tv_nsec = ns % NANOSECONDS_PER_SECOND; | |
if (periodic) | |
i.it_interval = rel; | |
- clock_gettime(t->clk_id, &start); | |
timespecadd(&start, &rel, &abs); | |
i.it_value = abs; | |
timer_settime(t->tmr, TIMER_ABSTIME, &i, NULL); | |
+#endif | |
pthread_mutex_lock(&t->start_mtx); | |
t->start = start; | |
pthread_mutex_unlock(&t->start_mtx); | |
@@ -134,22 +196,30 @@ void evtimer_set_rel(void *tmr, uint64_t ns, int periodic) | |
uint64_t evtimer_gettime(void *tmr) | |
{ | |
struct evtimer *t = tmr; | |
- struct timespec rel, abs; | |
+ struct timespec abs; | |
+ uint64_t rel; | |
clock_gettime(t->clk_id, &abs); | |
pthread_mutex_lock(&t->start_mtx); | |
- timespecsub(&abs, &t->start, &rel); | |
+ rel = abs.tv_sec * NANOSECONDS_PER_SECOND + abs.tv_nsec - | |
+ (t->start.tv_sec * NANOSECONDS_PER_SECOND + t->start.tv_nsec); | |
pthread_mutex_unlock(&t->start_mtx); | |
- return (rel.tv_sec * NANOSECONDS_PER_SECOND + rel.tv_nsec); | |
+ return rel; | |
} | |
void evtimer_stop(void *tmr) | |
{ | |
struct evtimer *t = tmr; | |
- struct itimerspec i = {}; | |
struct timespec start; | |
+#ifdef __APPLE__ | |
+ if (!t->suspended) | |
+ dispatch_suspend(t->source); | |
+ t->suspended = 1; | |
+#else | |
+ struct itimerspec i = {}; | |
timer_settime(t->tmr, 0, &i, NULL); | |
+#endif | |
clock_gettime(t->clk_id, &start); | |
pthread_mutex_lock(&t->start_mtx); | |
t->start = start; | |
diff --git a/src/base/lib/translate/translate_config.c b/src/base/lib/translate/translate_config.c | |
index b15af42e0..341ff9ed3 100644 | |
--- a/src/base/lib/translate/translate_config.c | |
+++ b/src/base/lib/translate/translate_config.c | |
@@ -10,7 +10,7 @@ | |
#include "video.h" | |
#include "utilities.h" | |
-struct translate_config_t trconfig; /* Initialized to nulls */ | |
+struct translate_config_t trconfig = {0}; /* Initialized to nulls */ | |
static void config_translate_scrub(void) | |
{ | |
diff --git a/src/base/misc/utilities.c b/src/base/misc/utilities.c | |
index fe5315391..661312586 100644 | |
--- a/src/base/misc/utilities.c | |
+++ b/src/base/misc/utilities.c | |
@@ -985,12 +985,12 @@ static int tee_close(void *cookie) | |
return ret; | |
} | |
+#ifdef HAVE_FOPENCOOKIE | |
static cookie_io_functions_t tee_ops = { | |
.write = tee_write, | |
.close = tee_close, | |
}; | |
-#ifdef HAVE_FOPENCOOKIE | |
FILE *fstream_tee(FILE *orig, FILE *copy) | |
{ | |
FILE *f; | |
@@ -1060,14 +1060,15 @@ pid_t run_external_command(const char *path, int argc, const char **argv, | |
dup(pts_fd); | |
close(pts_fd); | |
close(pty_fd); | |
- if (close_from != -1) | |
- closefrom(close_from); | |
+ //if (close_from != -1) | |
+ // closefrom(close_from); | |
/* close signals, then unblock */ | |
signal_done(); | |
/* flush pending signals */ | |
- do { | |
- wt = sigtimedwait(&set, NULL, &to); | |
- } while (wt != -1); | |
+ //do { | |
+ //wt = sigwaitinfo(&set, NULL); | |
+ //wt = sigtimedwait(&set, NULL, &to); | |
+ //} while (wt != -1); | |
sigprocmask(SIG_SETMASK, &oset, NULL); | |
#pragma GCC diagnostic push | |
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" | |
diff --git a/src/base/video/remap.c b/src/base/video/remap.c | |
index b1d6011b2..48c018f14 100644 | |
--- a/src/base/video/remap.c | |
+++ b/src/base/video/remap.c | |
@@ -3477,6 +3477,7 @@ static int _remap_get_cap(void *ros) | |
return ro->state; | |
} | |
+static struct remap_calls rmcalls; | |
static void *_remap_remap_init(int dst_mode, int features, | |
const ColorSpaceDesc *color_space, int gamma) | |
{ | |
@@ -3512,7 +3513,8 @@ static struct remap_calls rmcalls = { | |
"dosemu gfx remapper" | |
}; | |
-CONSTRUCTOR(static void initialize(void)) | |
+//CONSTRUCTOR(void register_remapper_init(void)) | |
+void register_remapper_init(void) | |
{ | |
register_remapper(&rmcalls, REMAP_DOSEMU); | |
} | |
diff --git a/src/base/video/render.c b/src/base/video/render.c | |
index 0b0ed6b02..7ba6b53e7 100644 | |
--- a/src/base/video/render.c | |
+++ b/src/base/video/render.c | |
@@ -35,7 +35,11 @@ static pthread_t render_thr; | |
#endif | |
static pthread_mutex_t render_mtx = PTHREAD_MUTEX_INITIALIZER; | |
static pthread_rwlock_t mode_mtx = PTHREAD_RWLOCK_INITIALIZER; | |
+#ifdef __APPLE__ | |
+static sem_t *render_sem; | |
+#else | |
static sem_t render_sem; | |
+#endif | |
static void do_rend_gfx(void); | |
static void do_rend_text(void); | |
static int remap_mode(void); | |
@@ -242,7 +246,11 @@ int remapper_init(int have_true_color, int have_shmap, int features, | |
static void *render_thread(void *arg) | |
{ | |
while (1) { | |
+#ifdef __APPLE__ | |
+ sem_wait(render_sem); | |
+#else | |
sem_wait(&render_sem); | |
+#endif | |
pthread_mutex_lock(&upd_mtx); | |
is_updating = 1; | |
pthread_mutex_unlock(&upd_mtx); | |
@@ -264,8 +272,16 @@ int render_init(void) | |
{ | |
int err = 0; | |
#if RENDER_THREADED | |
+#ifdef __APPLE__ | |
+ char sem_name[256]; | |
+ snprintf(sem_name, sizeof(sem_name), "/dosemu_render_sem_%i", getpid()); | |
+ render_sem = sem_open(sem_name, O_CREAT, S_IRUSR | S_IWUSR, 0); | |
+ assert(render_sem); | |
+ sem_unlink(render_sem); | |
+#else | |
err = sem_init(&render_sem, 0, 0); | |
assert(!err); | |
+#endif | |
err = pthread_create(&render_thr, NULL, render_thread, NULL); | |
#if defined(HAVE_PTHREAD_SETNAME_NP) && defined(__GLIBC__) | |
pthread_setname_np(render_thr, "dosemu: render"); | |
@@ -287,8 +303,12 @@ void render_done(void) | |
#if RENDER_THREADED | |
pthread_cancel(render_thr); | |
pthread_join(render_thr, NULL); | |
+#ifdef __APPLE__ | |
+ sem_close(render_sem); | |
+#else | |
sem_destroy(&render_sem); | |
#endif | |
+#endif | |
} | |
void remapper_done(void) | |
@@ -652,7 +672,11 @@ int update_screen(void) | |
if (upd) | |
return 1; | |
- sem_post(&render_sem); | |
+#ifdef __APPLE__ | |
+ sem_post(render_sem); | |
+#else | |
+ sem_post(&render_sem) | |
+#endif | |
return 1; | |
} | |
diff --git a/src/dosext/dpmi/dpmi.c b/src/dosext/dpmi/dpmi.c | |
index dad5470d1..6a36f2402 100644 | |
--- a/src/dosext/dpmi/dpmi.c | |
+++ b/src/dosext/dpmi/dpmi.c | |
@@ -3720,7 +3720,7 @@ void dpmi_setup(void) | |
goto err2; | |
} | |
MEMCPY_2DOS(block->base, _binary_dpmisel_o_bin_start, | |
- _binary_dpmisel_o_bin_end - _binary_dpmisel_o_bin_start); | |
+ DPMI_sel_code_end - DPMI_sel_code_start); | |
err = SetSelector(_dpmi_sel16, block->base, | |
DPMI_SEL_OFF(DPMI_sel_code_end)-1, 0, | |
MODIFY_LDT_CONTENTS_CODE, 0, 0, 0, 0); | |
@@ -5266,9 +5266,11 @@ static int dpmi_fault1(cpuctx_t *scp) | |
break; | |
case 0xe6: /* outb xx */ | |
if (debug_level('M')>=9) | |
- D_printf("DPMI: outb xx\n"); | |
+ D_printf("DPMI: outb1 xx %x %x\n", csp[0], _LO(ax)); | |
port_outb((int) csp[0], _LO(ax)); | |
LWORD32(eip, += 2); | |
+ if (debug_level('M')>=9) | |
+ D_printf("DPMI: outb2 xx %x %x\n", csp[0], _LO(ax)); | |
break; | |
case 0xef: /* outw dx */ | |
if (debug_level('M')>=9) | |
diff --git a/src/dosext/dpmi/memory.c b/src/dosext/dpmi/memory.c | |
index d71b180ed..208e271ca 100644 | |
--- a/src/dosext/dpmi/memory.c | |
+++ b/src/dosext/dpmi/memory.c | |
@@ -599,7 +599,7 @@ dpmi_pm_block *DPMI_mallocShared(dpmi_pm_block_root *root, | |
return NULL; | |
} | |
- asprintf(&shmname, "/dosemu_dpmishm_%d_%s", getpid(), name); | |
+ asprintf(&shmname, "/dosemu%s", name); | |
if (init) { | |
oflags |= O_CREAT; | |
if (flags & SHM_EXCL) | |
diff --git a/src/dosext/mfs/xattr.c b/src/dosext/mfs/xattr.c | |
index e9462092a..8f0506c7b 100644 | |
--- a/src/dosext/mfs/xattr.c | |
+++ b/src/dosext/mfs/xattr.c | |
@@ -66,12 +66,16 @@ static int xattr_err(int err, const char *name) | |
int set_dos_xattr_fd(int fd, int attr, const char *name) | |
{ | |
char xbuf[16]; | |
- return xattr_err(fsetxattr(fd, XATTR_DOSATTR_NAME, xbuf, | |
- xattr_str(xbuf, sizeof(xbuf), attr), 0), name); | |
+ return 0; | |
+ //return xattr_err(fsetxattr(fd, XATTR_DOSATTR_NAME, xbuf, | |
+ // xattr_str(xbuf, sizeof(xbuf), attr), 0), name); | |
} | |
int set_dos_xattr(const char *fname, int attr) | |
{ | |
+#ifdef __APPLE__ | |
+ return ACCESS_DENIED; | |
+#else | |
char xbuf[16]; | |
int err = setxattr(fname, XATTR_DOSATTR_NAME, xbuf, | |
xattr_str(xbuf, sizeof(xbuf), attr), 0); | |
@@ -89,17 +93,18 @@ int set_dos_xattr(const char *fname, int attr) | |
} | |
} | |
return xattr_err(err, fname); | |
+#endif | |
} | |
int get_dos_xattr(const char *fname) | |
{ | |
char xbuf[16]; | |
- ssize_t size = getxattr(fname, XATTR_DOSATTR_NAME, xbuf, sizeof(xbuf) - 1); | |
+ ssize_t size = 0; //getxattr(fname, XATTR_DOSATTR_NAME, xbuf, sizeof(xbuf) - 1); | |
/* some dosemus forgot \0 so we fix it up here */ | |
if (size > 0 && xbuf[size - 1] != '\0') { | |
error("MFS: fixup xattr for %s\n", fname); | |
xbuf[size++] = '\0'; | |
- setxattr(fname, XATTR_DOSATTR_NAME, xbuf, size, XATTR_REPLACE); | |
+ //setxattr(fname, XATTR_DOSATTR_NAME, xbuf, size, XATTR_REPLACE); | |
} | |
return do_extr_xattr(xbuf, size, fname); | |
} | |
@@ -107,12 +112,12 @@ int get_dos_xattr(const char *fname) | |
int get_dos_xattr_fd(int fd, const char *name) | |
{ | |
char xbuf[16]; | |
- ssize_t size = fgetxattr(fd, XATTR_DOSATTR_NAME, xbuf, sizeof(xbuf) - 1); | |
+ ssize_t size = 0; //fgetxattr(fd, XATTR_DOSATTR_NAME, xbuf, sizeof(xbuf) - 1); | |
/* some dosemus forgot \0 so we fix it up here */ | |
if (size > 0 && xbuf[size - 1] != '\0') { | |
error("MFS: fixup xattr\n"); | |
xbuf[size++] = '\0'; | |
- fsetxattr(fd, XATTR_DOSATTR_NAME, xbuf, size, XATTR_REPLACE); | |
+ //fsetxattr(fd, XATTR_DOSATTR_NAME, xbuf, size, XATTR_REPLACE); | |
} | |
return do_extr_xattr(xbuf, size, name); | |
} | |
diff --git a/src/include/sig.h b/src/include/sig.h | |
index bd5a009b1..5357c6554 100644 | |
--- a/src/include/sig.h | |
+++ b/src/include/sig.h | |
@@ -44,9 +44,13 @@ extern void SIG_init(void); | |
extern void SIG_close(void); | |
/* signals for Linux's process control of consoles */ | |
+#ifdef SIGRTMIN | |
#define SIG_RELEASE SIGUSR1 | |
#define SIG_ACQUIRE SIGUSR2 | |
#define SIG_THREAD_NOTIFY (SIGRTMIN + 0) | |
+#else | |
+#define SIG_THREAD_NOTIFY SIGUSR1 | |
+#endif | |
typedef mcontext_t sigcontext_t; | |
@@ -93,6 +97,17 @@ typedef mcontext_t sigcontext_t; | |
#define _scp_trapno scp->mc_trapno | |
#define _scp_err (*(unsigned *)&scp->mc_err) | |
#define _scp_fpstate scp->mc_fpstate | |
+#elif defined(__APPLE__) | |
+#define _scp_rsp ((*scp)->__ss.__rsp) | |
+#define _scp_edx ((*scp)->__ss.__rdx) | |
+#define _scp_eax ((*scp)->__ss.__rax) | |
+#define _scp_rip ((*scp)->__ss.__rip) | |
+#define _scp_cs ((*scp)->__ss.__cs) | |
+#define _scp_eflags ((*scp)->__ss.__rflags) | |
+#define _scp_trapno ((*scp)->__es.__trapno) | |
+#define _scp_err ((*scp)->__es.__err) | |
+extern uint64_t _scp_cr2; | |
+#define PRI_RG PRIx64 | |
#elif defined(__linux__) | |
#define _scp_fpstate (scp->fpregs) | |
#ifdef __x86_64__ | |
@@ -199,7 +214,7 @@ static inline void unsetsig(int sig) {} | |
/* On glibc SIGRTMAX is not a constant but NSIG cpvers rt signals. | |
* On bsd its all the other way around. */ | |
-#ifdef __GLIBC__ | |
+#if defined(__GLIBC__) || !defined(SIGRTMAX) | |
#define SIGMAX NSIG | |
#else | |
#define SIGMAX SIGRTMAX | |
diff --git a/src/plugin/X/keyb_X_keycode.c b/src/plugin/X/keyb_X_keycode.c | |
index 644832281..25d75c909 100644 | |
--- a/src/plugin/X/keyb_X_keycode.c | |
+++ b/src/plugin/X/keyb_X_keycode.c | |
@@ -586,6 +586,7 @@ void X_keycode_initialize(Display *display) | |
} | |
#if 1 | |
for(i = 0; i < MAX_X_KEYCODES; i++) { | |
+ printf("%d\n", i); | |
t_keynum keynum = KEYCODE_TO_KEYNUM(i); | |
if (keynum != NUM_VOID) { | |
k_printf("mapping keycode:%d -> keynum: 0x%02x\n", | |
@@ -646,11 +647,12 @@ static t_unicode Xkb_lookup_key(Display *display, XKeyEvent *e) | |
* Disable it for now. */ | |
if (xkey == XK_Return && (rem_mods & ControlMask)) | |
return DKY_VOID; | |
- rc = Xutf8LookupString(ic, e, chars, MB_LEN_MAX, NULL, NULL); | |
+ rc = XkbTranslateKeySym(display, &xkey, e->state, chars, MB_LEN_MAX, NULL); | |
+ //rc = Xutf8LookupString(ic, e, chars, MB_LEN_MAX, NULL, &status); | |
if (!rc) | |
return DKY_VOID; | |
- init_charset_state(&cs, lookup_charset("utf8")); | |
+ init_charset_state(&cs, trconfig.keyb_charset); //lookup_charset("utf8")); | |
charset_to_unicode(&cs, &key, | |
(const unsigned char *)chars, MB_LEN_MAX); | |
cleanup_charset_state(&cs); | |
diff --git a/src/plugin/charsets/cp437.c b/src/plugin/charsets/cp437.c | |
index 9e7c6c95f..d160b3943 100644 | |
--- a/src/plugin/charsets/cp437.c | |
+++ b/src/plugin/charsets/cp437.c | |
@@ -40,7 +40,8 @@ struct char_set cp437 = { | |
.names = { "cp437", 0 }, | |
}; | |
-CONSTRUCTOR(static void init(void)) | |
+//CONSTRUCTOR(static void init(void)) | |
+void cp437_init(void) | |
{ | |
register_charset(&cp437); | |
} | |
diff --git a/src/plugin/charsets/multibyte.c b/src/plugin/charsets/multibyte.c | |
index 485d27ad7..f1cee4b57 100644 | |
--- a/src/plugin/charsets/multibyte.c | |
+++ b/src/plugin/charsets/multibyte.c | |
@@ -66,7 +66,8 @@ static struct char_set multibyte = { | |
.ops = &multibyte_ops, | |
}; | |
-CONSTRUCTOR(static void init(void)) | |
+//CONSTRUCTOR(static void init(void)) | |
+extern void multibyte_init(void) | |
{ | |
register_charset(&multibyte); | |
} | |
diff --git a/src/plugin/charsets/utf8.c b/src/plugin/charsets/utf8.c | |
index 8e36ddfa9..623a7fb7b 100644 | |
--- a/src/plugin/charsets/utf8.c | |
+++ b/src/plugin/charsets/utf8.c | |
@@ -139,7 +139,8 @@ struct char_set utf8 = { | |
.ops = &utf8_ops, | |
}; | |
-CONSTRUCTOR(static void init(void)) | |
+//CONSTRUCTOR(static void init(void)) | |
+extern void utf8_init(void) | |
{ | |
register_charset(&utf8); | |
} | |
diff --git a/src/plugin/debugger/dosdebug.c b/src/plugin/debugger/dosdebug.c | |
index bf9e7741a..e6cef9e6b 100644 | |
--- a/src/plugin/debugger/dosdebug.c | |
+++ b/src/plugin/debugger/dosdebug.c | |
@@ -412,9 +412,9 @@ static int handle_dbg_input(int *retval) | |
char *saved_line; | |
int saved_point; | |
saved_point = rl_point; | |
- saved_line = rl_copy_text(0, rl_end); | |
+ //saved_line = rl_copy_text(0, rl_end); | |
rl_set_prompt(""); | |
- rl_replace_line("", 0); | |
+ //rl_replace_line("", 0); | |
rl_redisplay(); | |
#endif | |
@@ -424,10 +424,10 @@ static int handle_dbg_input(int *retval) | |
#ifdef HAVE_LIBREADLINE | |
rl_set_prompt(prompt); | |
- rl_replace_line(saved_line, 0); | |
+ //rl_replace_line(saved_line, 0); | |
rl_point = saved_point; | |
rl_redisplay(); | |
- free(saved_line); | |
+ //free(saved_line); | |
#endif | |
} | |
diff --git a/src/plugin/debugger/mhpdbgc.c b/src/plugin/debugger/mhpdbgc.c | |
index 600a9fe4a..3bb451d81 100644 | |
--- a/src/plugin/debugger/mhpdbgc.c | |
+++ b/src/plugin/debugger/mhpdbgc.c | |
@@ -1039,7 +1039,7 @@ static void mhp_dump(int argc, char * argv[]) | |
} else { | |
snprintf(lastd, sizeof(lastd), "%x:%x", seg, off + i); | |
} | |
- } else if (unix) { | |
+ } else if (unixaddr) { | |
snprintf(lastd, sizeof(lastd), "%#x", seekval + i); | |
} else { | |
snprintf(lastd, sizeof(lastd), "%x", seekval + i); | |
diff --git a/src/plugin/midimisc/mid_o_oss.c b/src/plugin/midimisc/mid_o_oss.c | |
index 64d19bbcf..4968672fb 100644 | |
--- a/src/plugin/midimisc/mid_o_oss.c | |
+++ b/src/plugin/midimisc/mid_o_oss.c | |
@@ -31,7 +31,8 @@ | |
#include <string.h> | |
/* declare this here to avoid warnings from soundcard.h */ | |
static void seqbuf_dump(void); | |
-#include <sys/soundcard.h> | |
+#ifndef __APPLE__ | |
+//#include <sys/soundcard.h> | |
SEQ_DEFINEBUF(128); | |
static int seq_fd = -1; | |
@@ -108,3 +109,4 @@ CONSTRUCTOR(static void midooss_register(void)) | |
{ | |
midi_register_output_plugin(&midooss); | |
} | |
+#endif | |
diff --git a/src/plugin/periph/bootnorm.S b/src/plugin/periph/bootnorm.S | |
index 27d40521e..8fc1065cd 100644 | |
--- a/src/plugin/periph/bootnorm.S | |
+++ b/src/plugin/periph/bootnorm.S | |
@@ -197,6 +197,9 @@ print1: lodsb # get token | |
jne print_1char # until done | |
ret # and jump to it | |
+.global _binary_bootnorm_o_bin_end | |
+_binary_bootnorm_o_bin_end: | |
+ | |
#ifdef __ELF__ | |
.section .note.GNU-stack,"",%progbits | |
#endif | |
diff --git a/src/plugin/periph/bootsect.S b/src/plugin/periph/bootsect.S | |
index ac50914e6..3ff25feb3 100644 | |
--- a/src/plugin/periph/bootsect.S | |
+++ b/src/plugin/periph/bootsect.S | |
@@ -68,6 +68,9 @@ end_message: | |
message_offset = beg_message - head | |
message_length = end_message - beg_message | |
+.globl _binary_bootsect_o_bin_end | |
+_binary_bootsect_o_bin_end: | |
+ | |
#ifdef __ELF__ | |
.section .note.GNU-stack,"",%progbits | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment