Skip to content

Commit 046dc9d

Browse files
committed
Darwin, fixincludes: Handle Apple Blocks in objc/runtime.h.
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.
1 parent 442d2bd commit 046dc9d

File tree

3 files changed

+117
-5
lines changed

3 files changed

+117
-5
lines changed

fixincludes/fixincl.x

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
*
33
* DO NOT EDIT THIS FILE (fixincl.x)
44
*
5-
* It has been AutoGen-ed January 18, 2023 at 07:54:50 PM by AutoGen 5.18.7
5+
* It has been AutoGen-ed January 18, 2023 at 09:06:47 PM by AutoGen 5.18.7
66
* From the definitions inclhack.def
77
* and the template file fixincl
88
*/
9-
/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Jan 18 19:54:50 GMT 2023
9+
/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Jan 18 21:06:47 GMT 2023
1010
*
1111
* You must regenerate it. Use the ./genfixes script.
1212
*
@@ -15,7 +15,7 @@
1515
* certain ANSI-incompatible system header files which are fixed to work
1616
* correctly with ANSI C and placed in a directory that GNU C will search.
1717
*
18-
* This file contains 273 fixup descriptions.
18+
* This file contains 274 fixup descriptions.
1919
*
2020
* See README for more information.
2121
*
@@ -3084,6 +3084,53 @@ static const char* apzDarwin_Os_Trace_2Patch[] = {
30843084
#endif",
30853085
(char*)NULL };
30863086

3087+
/* * * * * * * * * * * * * * * * * * * * * * * * * *
3088+
*
3089+
* Description of Darwin_Objc_Runtime_1 fix
3090+
*/
3091+
tSCC zDarwin_Objc_Runtime_1Name[] =
3092+
"darwin_objc_runtime_1";
3093+
3094+
/*
3095+
* File name selection pattern
3096+
*/
3097+
tSCC zDarwin_Objc_Runtime_1List[] =
3098+
"objc/runtime.h\0";
3099+
/*
3100+
* Machine/OS name selection pattern
3101+
*/
3102+
tSCC* apzDarwin_Objc_Runtime_1Machs[] = {
3103+
"*-*-darwin2*",
3104+
(const char*)NULL };
3105+
3106+
/*
3107+
* content selection pattern - do fix if pattern found
3108+
*/
3109+
tSCC zDarwin_Objc_Runtime_1Select0[] =
3110+
"OBJC_EXPORT void.*\n\
3111+
objc_enumerateClasses.*\n\
3112+
.*\n\
3113+
.*\n\
3114+
.*\n\
3115+
.*void \\(\\^ _Nonnull block.*\n\
3116+
.*\n\
3117+
.*\n\
3118+
.*OBJC_REFINED_FOR_SWIFT.*";
3119+
3120+
#define DARWIN_OBJC_RUNTIME_1_TEST_CT 1
3121+
static tTestDesc aDarwin_Objc_Runtime_1Tests[] = {
3122+
{ TT_EGREP, zDarwin_Objc_Runtime_1Select0, (regex_t*)NULL }, };
3123+
3124+
/*
3125+
* Fix Command Arguments for Darwin_Objc_Runtime_1
3126+
*/
3127+
static const char* apzDarwin_Objc_Runtime_1Patch[] = {
3128+
"format",
3129+
"#if __BLOCKS__\n\
3130+
%0\n\
3131+
#endif",
3132+
(char*)NULL };
3133+
30873134
/* * * * * * * * * * * * * * * * * * * * * * * * * *
30883135
*
30893136
* Description of Darwin_Os_Trace_3 fix
@@ -11115,9 +11162,9 @@ static const char* apzX11_SprintfPatch[] = {
1111511162
*
1111611163
* List of all fixes
1111711164
*/
11118-
#define REGEX_COUNT 311
11165+
#define REGEX_COUNT 312
1111911166
#define MACH_LIST_SIZE_LIMIT 187
11120-
#define FIX_COUNT 273
11167+
#define FIX_COUNT 274
1112111168

1112211169
/*
1112311170
* Enumerate the fixes
@@ -11196,6 +11243,7 @@ typedef enum {
1119611243
DARWIN_LONGJMP_NORETURN_FIXIDX,
1119711244
DARWIN_OS_TRACE_1_FIXIDX,
1119811245
DARWIN_OS_TRACE_2_FIXIDX,
11246+
DARWIN_OBJC_RUNTIME_1_FIXIDX,
1119911247
DARWIN_OS_TRACE_3_FIXIDX,
1120011248
DARWIN_OS_BASE_1_FIXIDX,
1120111249
DARWIN_DISPATCH_OBJECT_1_FIXIDX,
@@ -11764,6 +11812,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
1176411812
DARWIN_OS_TRACE_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
1176511813
aDarwin_Os_Trace_2Tests, apzDarwin_Os_Trace_2Patch, 0 },
1176611814

11815+
{ zDarwin_Objc_Runtime_1Name, zDarwin_Objc_Runtime_1List,
11816+
apzDarwin_Objc_Runtime_1Machs,
11817+
DARWIN_OBJC_RUNTIME_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
11818+
aDarwin_Objc_Runtime_1Tests, apzDarwin_Objc_Runtime_1Patch, 0 },
11819+
1176711820
{ zDarwin_Os_Trace_3Name, zDarwin_Os_Trace_3List,
1176811821
apzDarwin_Os_Trace_3Machs,
1176911822
DARWIN_OS_TRACE_3_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,

fixincludes/inclhack.def

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,41 @@ fix = {
14911491
test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
14921492
};
14931493

1494+
/*
1495+
* macOSX 13.0 SDK objc/runtime.h uses Apple Blocks extension without a guard.
1496+
*/
1497+
1498+
fix = {
1499+
hackname = darwin_objc_runtime_1;
1500+
mach = "*-*-darwin2*";
1501+
files = objc/runtime.h;
1502+
select = <<- _EOSelect_
1503+
OBJC_EXPORT void.*
1504+
objc_enumerateClasses.*
1505+
.*
1506+
.*
1507+
.*
1508+
.*void \(\^ _Nonnull block.*
1509+
.*
1510+
.*
1511+
.*OBJC_REFINED_FOR_SWIFT.*
1512+
_EOSelect_;
1513+
c_fix = format;
1514+
c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
1515+
test_text = <<- _OBJC_RUNTIME_1
1516+
OBJC_EXPORT void
1517+
objc_enumerateClasses(const void * _Nullable image,
1518+
const char * _Nullable namePrefix,
1519+
Protocol * _Nullable conformingTo,
1520+
Class _Nullable subclassing,
1521+
void (^ _Nonnull block)(Class _Nonnull aClass, BOOL * _Nonnull stop)
1522+
OBJC_NOESCAPE)
1523+
OBJC_AVAILABLE(13.0, 16.0, 16.0, 9.0, 7.0)
1524+
OBJC_REFINED_FOR_SWIFT;
1525+
_OBJC_RUNTIME_1;
1526+
};
1527+
1528+
14941529
/*
14951530
* In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
14961531
* os_trace_payload_t typedef, too.

fixincludes/tests/base/objc/runtime.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* DO NOT EDIT THIS FILE.
2+
3+
It has been auto-edited by fixincludes from:
4+
5+
"fixinc/tests/inc/objc/runtime.h"
6+
7+
This had to be done to correct non-standard usages in the
8+
original, manufacturer supplied header file. */
9+
10+
11+
12+
#if defined( DARWIN_OBJC_RUNTIME_1_CHECK )
13+
#if __BLOCKS__
14+
OBJC_EXPORT void
15+
objc_enumerateClasses(const void * _Nullable image,
16+
const char * _Nullable namePrefix,
17+
Protocol * _Nullable conformingTo,
18+
Class _Nullable subclassing,
19+
void (^ _Nonnull block)(Class _Nonnull aClass, BOOL * _Nonnull stop)
20+
OBJC_NOESCAPE)
21+
OBJC_AVAILABLE(13.0, 16.0, 16.0, 9.0, 7.0)
22+
OBJC_REFINED_FOR_SWIFT;
23+
#endif
24+
#endif /* DARWIN_OBJC_RUNTIME_1_CHECK */

0 commit comments

Comments
 (0)