From b32a8c85886ab765a74188c4307329871995a6f3 Mon Sep 17 00:00:00 2001 From: Ricky Zhang Date: Mon, 7 Aug 2017 10:42:29 -0400 Subject: [PATCH 1/5] Fix Sierra clock_gettime issue Signed-off-by: Ricky Zhang --- BasiliskII/src/Unix/sysdeps.h | 10 +++++----- BasiliskII/src/Unix/timer_unix.cpp | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/BasiliskII/src/Unix/sysdeps.h b/BasiliskII/src/Unix/sysdeps.h index df291939..d74a2eda 100644 --- a/BasiliskII/src/Unix/sysdeps.h +++ b/BasiliskII/src/Unix/sysdeps.h @@ -185,10 +185,10 @@ typedef char * caddr_t; #endif /* Time data type for Time Manager emulation */ -#ifdef HAVE_CLOCK_GETTIME -typedef struct timespec tm_time_t; -#elif defined(__MACH__) +#if defined(__MACH__) typedef mach_timespec_t tm_time_t; +#elif defined(HAVE_CLOCK_GETTIME) +typedef struct timespec tm_time_t; #else typedef struct timeval tm_time_t; #endif @@ -266,7 +266,7 @@ static inline int testandset(volatile int *p) __asm__ __volatile__("0: cs %0,%1,0(%2)\n" " jl 0b" : "=&d" (ret) - : "r" (1), "a" (p), "0" (*p) + : "r" (1), "a" (p), "0" (*p) : "cc", "memory" ); return ret; } @@ -315,7 +315,7 @@ static inline int testandset(volatile int *p) __asm__ __volatile__("swp %0, %1, [%2]" : "=r"(ret) : "0"(1), "r"(p)); - + return ret; } #endif diff --git a/BasiliskII/src/Unix/timer_unix.cpp b/BasiliskII/src/Unix/timer_unix.cpp index 9e227d02..709194cd 100644 --- a/BasiliskII/src/Unix/timer_unix.cpp +++ b/BasiliskII/src/Unix/timer_unix.cpp @@ -44,7 +44,7 @@ static inline void mach_current_time(tm_time_t &t) { host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &host_clock); host_clock_inited = true; } - + clock_get_time(host_clock, &t); } #endif @@ -57,14 +57,14 @@ static inline void mach_current_time(tm_time_t &t) { void Microseconds(uint32 &hi, uint32 &lo) { D(bug("Microseconds\n")); -#if defined(HAVE_CLOCK_GETTIME) - struct timespec t; - clock_gettime(CLOCK_REALTIME, &t); - uint64 tl = (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; -#elif defined(__MACH__) +#if defined(__MACH__) tm_time_t t; mach_current_time(t); uint64 tl = (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; +#elif defined(HAVE_CLOCK_GETTIME) + struct timespec t; + clock_gettime(CLOCK_REALTIME, &t); + uint64 tl = (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; #else struct timeval t; gettimeofday(&t, NULL); @@ -91,10 +91,10 @@ uint32 TimerDateTime(void) void timer_current_time(tm_time_t &t) { -#ifdef HAVE_CLOCK_GETTIME - clock_gettime(CLOCK_REALTIME, &t); -#elif defined(__MACH__) +#if defined(__MACH__) mach_current_time(t); +#elif defined(HAVE_CLOCK_GETTIME) + clock_gettime(CLOCK_REALTIME, &t); #else gettimeofday(&t, NULL); #endif @@ -229,14 +229,14 @@ int32 timer_host2mac_time(tm_time_t hosttime) uint64 GetTicks_usec(void) { -#ifdef HAVE_CLOCK_GETTIME - struct timespec t; - clock_gettime(CLOCK_REALTIME, &t); - return (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; -#elif defined(__MACH__) +#if defined(__MACH__) tm_time_t t; mach_current_time(t); return (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; +#elif defined(HAVE_CLOCK_GETTIME) + struct timespec t; + clock_gettime(CLOCK_REALTIME, &t); + return (uint64)t.tv_sec * 1000000 + t.tv_nsec / 1000; #else struct timeval t; gettimeofday(&t, NULL); From 35ca220d90b215d48211d04f91e493fb7aabe023 Mon Sep 17 00:00:00 2001 From: Alexei Svitkine Date: Tue, 8 Aug 2017 23:19:39 -0400 Subject: [PATCH 2/5] Fix build when targeting Sierra. Sierra now supports clock_gettime(), so fix some code that assumed mach and HAVE_CLOCK_GETTIME where mutually exclusive. --- BasiliskII/src/Unix/timer_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BasiliskII/src/Unix/timer_unix.cpp b/BasiliskII/src/Unix/timer_unix.cpp index 9e227d02..3bf78f43 100644 --- a/BasiliskII/src/Unix/timer_unix.cpp +++ b/BasiliskII/src/Unix/timer_unix.cpp @@ -32,7 +32,7 @@ #define CLOCK_REALTIME 0 #endif -#if defined(__MACH__) +#if !defined(HAVE_CLOCK_GETTIME) && defined(__MACH__) #include #include From 9f93648ea52eadb31858d2877665885c431dac0b Mon Sep 17 00:00:00 2001 From: Alexei Svitkine Date: Tue, 8 Aug 2017 23:37:56 -0400 Subject: [PATCH 3/5] Revert "Fix build when targeting Sierra." This reverts commit 35ca220d90b215d48211d04f91e493fb7aabe023. Going with https://github.com/cebix/macemu/pull/115 instead. --- BasiliskII/src/Unix/timer_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BasiliskII/src/Unix/timer_unix.cpp b/BasiliskII/src/Unix/timer_unix.cpp index 3bf78f43..9e227d02 100644 --- a/BasiliskII/src/Unix/timer_unix.cpp +++ b/BasiliskII/src/Unix/timer_unix.cpp @@ -32,7 +32,7 @@ #define CLOCK_REALTIME 0 #endif -#if !defined(HAVE_CLOCK_GETTIME) && defined(__MACH__) +#if defined(__MACH__) #include #include From 123a23fad59d894e01d85a255cd29ff6db2319e4 Mon Sep 17 00:00:00 2001 From: Alexei Svitkine Date: Wed, 9 Aug 2017 00:14:05 -0400 Subject: [PATCH 4/5] fix sequence error compiler warning --- BasiliskII/src/pict.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BasiliskII/src/pict.c b/BasiliskII/src/pict.c index 715c8feb..76633934 100644 --- a/BasiliskII/src/pict.c +++ b/BasiliskII/src/pict.c @@ -101,7 +101,8 @@ static ssize_t CompressUsingRLE(uint8_t *row, uint16_t uncmpLength, uint8_t *out uint8_t literals = 0; uint8_t i; - while (cursor + literals + 1 < uncmpLength && literals < 127 && nextByte != (nextByte = row[cursor + literals + 1])) { + while (cursor + literals + 1 < uncmpLength && literals < 127 && nextByte != row[cursor + literals + 1]) { + nextByte = row[cursor + literals + 1]; literals++; } From 3fc8924636c4a6bc4d0fcc9b5fd7a86f6d9de0ff Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Wed, 9 Aug 2017 13:04:46 +0100 Subject: [PATCH 5/5] Use ucontext_t instead of struct ucontext ucontext_t is what POSIX requires; glibc no longer provides struct ucontext as of 2.26: https://sourceware.org/glibc/wiki/Release/2.26 (Most architectures were already using ucontext_t, so this also makes things more consistent; only arm and mips change.) --- BasiliskII/src/CrossPlatform/sigsegv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BasiliskII/src/CrossPlatform/sigsegv.cpp b/BasiliskII/src/CrossPlatform/sigsegv.cpp index 570058c2..f1322d1e 100644 --- a/BasiliskII/src/CrossPlatform/sigsegv.cpp +++ b/BasiliskII/src/CrossPlatform/sigsegv.cpp @@ -342,12 +342,12 @@ static void powerpc_decode_instruction(instruction_t *instruction, unsigned int #define SIGSEGV_REGISTER_FILE (unsigned long *)&SIGSEGV_CONTEXT_REGS->nip, (unsigned long *)(SIGSEGV_CONTEXT_REGS->gpr) #define SIGSEGV_SKIP_INSTRUCTION powerpc_skip_instruction #elif (defined(arm) || defined(__arm__)) -#define SIGSEGV_CONTEXT_REGS (((struct ucontext *)scp)->uc_mcontext) +#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext) #define SIGSEGV_FAULT_INSTRUCTION (SIGSEGV_CONTEXT_REGS.arm_pc) #define SIGSEGV_REGISTER_FILE (&SIGSEGV_CONTEXT_REGS.arm_r0) #define SIGSEGV_SKIP_INSTRUCTION arm_skip_instruction #elif (defined(mips) || defined(__mips__)) -#define SIGSEGV_CONTEXT_REGS (((struct ucontext *)scp)->uc_mcontext) +#define SIGSEGV_CONTEXT_REGS (((ucontext_t *)scp)->uc_mcontext) #define SIGSEGV_FAULT_INSTRUCTION (SIGSEGV_CONTEXT_REGS.pc) #define SIGSEGV_REGISTER_FILE &SIGSEGV_CONTEXT_REGS.pc, &SIGSEGV_CONTEXT_REGS.gregs[0] #define SIGSEGV_SKIP_INSTRUCTION mips_skip_instruction