Skip to content

Commit

Permalink
m4: Improve macOS patch compatibility.
Browse files Browse the repository at this point in the history
This should now work across all versions, and fix the build problem
raised in NetBSD#158.  Tested locally against the 10.4 SDK.
  • Loading branch information
jperkin committed Feb 13, 2025
1 parent 8b598c1 commit 05d082e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion devel/m4/distinfo
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ BLAKE2s (m4-1.4.19.tar.gz) = f1380114d839935b2afa53fdd7162dc5df2bbeb6d5eab485289
SHA512 (m4-1.4.19.tar.gz) = f5dd0f02fcae65a176a16af9a8e1747c26e9440c6c224003ba458d3298b777a75ffb189aee9051fb0c4840b2a48278be4a51d959381af0b1d627570f478c58f2
Size (m4-1.4.19.tar.gz) = 2953876 bytes
SHA1 (patch-configure) = 941bba8b1a10c3fc305d20abdb247cf45e44d534
SHA1 (patch-lib_sigsegv.c) = 31eebf620879e727737af41e3283a9209bbf5a9c
SHA1 (patch-lib_sigsegv.c) = 5f49ac75d55aae5a5ad5530a212ec25e15c679e8
SHA1 (patch-lib_strerror_override.c) = 29905fecf6c92f75c4999f1e3cb56e14fe2f4aae
SHA1 (patch-m4_sparcv8+.m4) = 761e592a700ea47ac0ba15d960f073115005dedd
41 changes: 39 additions & 2 deletions devel/m4/patches/patch-lib_sigsegv.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,49 @@ Use older regnames on MacOS X 10.4 "Tiger", taken from

--- lib/sigsegv.c.orig 2021-05-19 14:36:49.000000000 +0000
+++ lib/sigsegv.c
@@ -586,7 +586,7 @@ int libsigsegv_version = LIBSIGSEGV_VERS
@@ -33,6 +33,9 @@
# include <sys/param.h> /* defines macro OpenBSD */
#endif

+#ifdef __APPLE__
+# include <AvailabilityMacros.h>
+#endif

/* Version number. */
int libsigsegv_version = LIBSIGSEGV_VERSION;
@@ -562,7 +565,11 @@ int libsigsegv_version = LIBSIGSEGV_VERS
- 'ucontext_t' and 'struct __darwin_ucontext' in <sys/_types/_ucontext.h>,
- 'struct __darwin_mcontext64' in <i386/_mcontext.h>, and
- 'struct __darwin_x86_thread_state64' in <mach/i386/_structs.h>. */
+# if __MAC_OS_X_VERSION_MAX_ALLOWED < 1050
+# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->ss.rsp
+# else
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->__ss.__rsp
+# endif

# elif defined __i386__

@@ -570,7 +577,11 @@ int libsigsegv_version = LIBSIGSEGV_VERS
- 'ucontext_t' and 'struct __darwin_ucontext' in <sys/_types/_ucontext.h>,
- 'struct __darwin_mcontext32' in <i386/_mcontext.h>, and
- 'struct __darwin_i386_thread_state' in <mach/i386/_structs.h>. */
+# if __MAC_OS_X_VERSION_MAX_ALLOWED < 1050
+# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->ss.esp
+# else
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->__ss.__esp
+# endif

# elif defined __arm64__

@@ -586,7 +597,11 @@ int libsigsegv_version = LIBSIGSEGV_VERS
- 'ucontext_t' and 'struct __darwin_ucontext' in <sys/_structs.h>,
- 'struct __darwin_mcontext' in <ppc/_structs.h>, and
- 'struct __darwin_ppc_thread_state' in <mach/ppc/_structs.h>. */
-# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->__ss.__r1
+# if __MAC_OS_X_VERSION_MAX_ALLOWED < 1050
+# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->ss.r1
+# else
# define SIGSEGV_FAULT_STACKPOINTER ((ucontext_t *) ucp)->uc_mcontext->__ss.__r1
+#endif

# endif

0 comments on commit 05d082e

Please sign in to comment.