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 #158.  Tested locally against the 10.4 SDK.

From Jonathan Perkin <[email protected]>
via drecklypkg commit 05d082e
  • Loading branch information
0-wiz-0 committed Feb 18, 2025
1 parent 5187e94 commit 89b8d17
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
4 changes: 2 additions & 2 deletions devel/m4/distinfo
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
$NetBSD: distinfo,v 1.53 2022/05/24 14:43:03 hauke Exp $
$NetBSD: distinfo,v 1.54 2025/02/18 15:07:14 wiz Exp $

BLAKE2s (m4-1.4.19.tar.gz) = f1380114d839935b2afa53fdd7162dc5df2bbeb6d5eab48528916a138f483cbc
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
43 changes: 40 additions & 3 deletions devel/m4/patches/patch-lib_sigsegv.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,53 @@
$NetBSD: patch-lib_sigsegv.c,v 1.1 2022/05/24 14:43:03 hauke Exp $
$NetBSD: patch-lib_sigsegv.c,v 1.2 2025/02/18 15:07:14 wiz Exp $

Use older regnames on MacOS X 10.4 "Tiger", taken from
<https://github.com/macports/macports-ports/blob/f9641f5f5cb7287e6787b566945fff460a80bc39/devel/m4/files/patch-m4-use-older-regnames-on-tiger.diff>

--- 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 89b8d17

Please sign in to comment.