From: Iain Sandoe <iains.gcc@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Darwin, fixincludes: Handle Apple Blocks in objc/runtime.h.
Date: Sat, 21 Jan 2023 17:12:20 +0000 [thread overview]
Message-ID: <20230121171220.36495-1-iain@sandoe.co.uk> (raw)
tested on i686-darwin9, x86_64-darwin19,20,21 x86_64-linux-gnu,
pushed to trunk, thanks
Iain
--- 8< ---
The macOS 13 SDK has unguarded Apple Blocks use in objc/runtime.h which
causes most of the objective-c tests to fail.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
fixincludes/ChangeLog:
* fixincl.x: Regenerate.
* inclhack.def (darwin_objc_runtime_1): New hack.
* tests/base/objc/runtime.h: New file.
---
fixincludes/fixincl.x | 63 ++++++++++++++++++++++++---
fixincludes/inclhack.def | 35 +++++++++++++++
fixincludes/tests/base/objc/runtime.h | 24 ++++++++++
3 files changed, 117 insertions(+), 5 deletions(-)
create mode 100644 fixincludes/tests/base/objc/runtime.h
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index ea879b73bad..b02dd8e0575 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1491,6 +1491,41 @@ fix = {
test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
};
+/*
+ * macOSX 13.0 SDK objc/runtime.h uses Apple Blocks extension without a guard.
+ */
+
+fix = {
+ hackname = darwin_objc_runtime_1;
+ mach = "*-*-darwin2*";
+ files = objc/runtime.h;
+ select = <<- _EOSelect_
+ OBJC_EXPORT void.*
+ objc_enumerateClasses.*
+ .*
+ .*
+ .*
+ .*void \(\^ _Nonnull block.*
+ .*
+ .*
+ .*OBJC_REFINED_FOR_SWIFT.*
+ _EOSelect_;
+ c_fix = format;
+ c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
+ test_text = <<- _OBJC_RUNTIME_1
+OBJC_EXPORT void
+objc_enumerateClasses(const void * _Nullable image,
+ const char * _Nullable namePrefix,
+ Protocol * _Nullable conformingTo,
+ Class _Nullable subclassing,
+ void (^ _Nonnull block)(Class _Nonnull aClass, BOOL * _Nonnull stop)
+ OBJC_NOESCAPE)
+OBJC_AVAILABLE(13.0, 16.0, 16.0, 9.0, 7.0)
+OBJC_REFINED_FOR_SWIFT;
+_OBJC_RUNTIME_1;
+};
+
+
/*
* In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
* os_trace_payload_t typedef, too.
diff --git a/fixincludes/tests/base/objc/runtime.h b/fixincludes/tests/base/objc/runtime.h
new file mode 100644
index 00000000000..8b4855bb8ab
--- /dev/null
+++ b/fixincludes/tests/base/objc/runtime.h
@@ -0,0 +1,24 @@
+/* DO NOT EDIT THIS FILE.
+
+ It has been auto-edited by fixincludes from:
+
+ "fixinc/tests/inc/objc/runtime.h"
+
+ This had to be done to correct non-standard usages in the
+ original, manufacturer supplied header file. */
+
+
+
+#if defined( DARWIN_OBJC_RUNTIME_1_CHECK )
+#if __BLOCKS__
+OBJC_EXPORT void
+objc_enumerateClasses(const void * _Nullable image,
+ const char * _Nullable namePrefix,
+ Protocol * _Nullable conformingTo,
+ Class _Nullable subclassing,
+ void (^ _Nonnull block)(Class _Nonnull aClass, BOOL * _Nonnull stop)
+ OBJC_NOESCAPE)
+OBJC_AVAILABLE(13.0, 16.0, 16.0, 9.0, 7.0)
+OBJC_REFINED_FOR_SWIFT;
+#endif
+#endif /* DARWIN_OBJC_RUNTIME_1_CHECK */
--
2.37.1 (Apple Git-137.1)
reply other threads:[~2023-01-21 17:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230121171220.36495-1-iain@sandoe.co.uk \
--to=iains.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=iain@sandoe.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).