Skip to content

Instantly share code, notes, and snippets.

@plainprogrammer
Created May 10, 2021 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plainprogrammer/5d064c4703e99fedc084a0a8c95aef5b to your computer and use it in GitHub Desktop.
Save plainprogrammer/5d064c4703e99fedc084a0a8c95aef5b to your computer and use it in GitHub Desktop.
Patch Redis 3.2 code to compile cleanly for Apple M1 Macs (ARM)
diff --git a/src/debug.c b/src/debug.c
index 1ecb251bd..d4d2f0508 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -662,8 +662,10 @@ static void *getMcontextEip(ucontext_t *uc) {
/* OSX >= 10.6 */
#if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__)
return (void*) uc->uc_mcontext->__ss.__rip;
- #else
+ #elif defined(__i386__)
return (void*) uc->uc_mcontext->__ss.__eip;
+ #else
+ return NULL;
#endif
#elif defined(__linux__)
/* Linux */
@@ -731,7 +733,7 @@ void logRegisters(ucontext_t *uc) {
(unsigned long) uc->uc_mcontext->__ss.__gs
);
logStackContent((void**)uc->uc_mcontext->__ss.__rsp);
- #else
+ #elif defined(__i386__)
/* OSX x86 */
serverLog(LL_WARNING,
"\n"
@@ -757,6 +759,9 @@ void logRegisters(ucontext_t *uc) {
(unsigned long) uc->uc_mcontext->__ss.__gs
);
logStackContent((void**)uc->uc_mcontext->__ss.__esp);
+ #else
+ serverLog(LL_WARNING,
+ " Dumping of registers not supported for this OS/arch");
#endif
/* Linux */
#elif defined(__linux__)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment