Skip to content

Commit 442d2bd

Browse files
committed
Darwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations [PR107568].
The SDK for MacOS13 includes Apple-specific deprecations of some functions that are not deprecated in Posix, C or C++ and widely used in GCC. The fix makes the deprecation conditional on __APPLE_LOCAL_DEPRECATIONS so that end users may still observe them but they are hidden from normal compilations. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk> PR target/107568 fixincludes/ChangeLog: * fixincl.x: Regenerate. * inclhack.def: Add a fix for MacOS13 SDK function deprecations in stdio.h. * tests/base/stdio.h (__deprecated_msg): New test.
1 parent 1bdb176 commit 442d2bd

File tree

3 files changed

+70
-5
lines changed

3 files changed

+70
-5
lines changed

fixincludes/fixincl.x

Lines changed: 51 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 September 29, 2022 at 10:22:55 PM by AutoGen 5.18.16
5+
* It has been AutoGen-ed January 18, 2023 at 07:54:50 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 Thu Sep 29 22:22:55 CEST 2022
9+
/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Jan 18 19:54:50 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 272 fixup descriptions.
18+
* This file contains 273 fixup descriptions.
1919
*
2020
* See README for more information.
2121
*
@@ -2608,6 +2608,46 @@ static const char* apzBsd_Stdio_Attrs_ConflictPatch[] = {
26082608
int vfscanf(FILE *, const char *, __builtin_va_list) __asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) \"__svfscanf\");",
26092609
(char*)NULL };
26102610

2611+
/* * * * * * * * * * * * * * * * * * * * * * * * * *
2612+
*
2613+
* Description of Apple_Local_Stdio_Fn_Deprecation fix
2614+
*/
2615+
tSCC zApple_Local_Stdio_Fn_DeprecationName[] =
2616+
"apple_local_stdio_fn_deprecation";
2617+
2618+
/*
2619+
* File name selection pattern
2620+
*/
2621+
tSCC zApple_Local_Stdio_Fn_DeprecationList[] =
2622+
"stdio.h\0";
2623+
/*
2624+
* Machine/OS name selection pattern
2625+
*/
2626+
tSCC* apzApple_Local_Stdio_Fn_DeprecationMachs[] = {
2627+
"*-*-*darwin2*",
2628+
(const char*)NULL };
2629+
2630+
/*
2631+
* content selection pattern - do fix if pattern found
2632+
*/
2633+
tSCC zApple_Local_Stdio_Fn_DeprecationSelect0[] =
2634+
"__deprecated_msg([^\n\
2635+
]*)$";
2636+
2637+
#define APPLE_LOCAL_STDIO_FN_DEPRECATION_TEST_CT 1
2638+
static tTestDesc aApple_Local_Stdio_Fn_DeprecationTests[] = {
2639+
{ TT_EGREP, zApple_Local_Stdio_Fn_DeprecationSelect0, (regex_t*)NULL }, };
2640+
2641+
/*
2642+
* Fix Command Arguments for Apple_Local_Stdio_Fn_Deprecation
2643+
*/
2644+
static const char* apzApple_Local_Stdio_Fn_DeprecationPatch[] = {
2645+
"format",
2646+
"#if defined(__APPLE_LOCAL_DEPRECATIONS)\n\
2647+
%0\n\
2648+
#endif",
2649+
(char*)NULL };
2650+
26112651
/* * * * * * * * * * * * * * * * * * * * * * * * * *
26122652
*
26132653
* Description of Ctrl_Quotes_Def fix
@@ -11075,9 +11115,9 @@ static const char* apzX11_SprintfPatch[] = {
1107511115
*
1107611116
* List of all fixes
1107711117
*/
11078-
#define REGEX_COUNT 310
11118+
#define REGEX_COUNT 311
1107911119
#define MACH_LIST_SIZE_LIMIT 187
11080-
#define FIX_COUNT 272
11120+
#define FIX_COUNT 273
1108111121

1108211122
/*
1108311123
* Enumerate the fixes
@@ -11144,6 +11184,7 @@ typedef enum {
1114411184
BROKEN_CABS_FIXIDX,
1114511185
BROKEN_NAN_FIXIDX,
1114611186
BSD_STDIO_ATTRS_CONFLICT_FIXIDX,
11187+
APPLE_LOCAL_STDIO_FN_DEPRECATION_FIXIDX,
1114711188
CTRL_QUOTES_DEF_FIXIDX,
1114811189
CTRL_QUOTES_USE_FIXIDX,
1114911190
CXX_UNREADY_FIXIDX,
@@ -11663,6 +11704,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
1166311704
BSD_STDIO_ATTRS_CONFLICT_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
1166411705
aBsd_Stdio_Attrs_ConflictTests, apzBsd_Stdio_Attrs_ConflictPatch, 0 },
1166511706

11707+
{ zApple_Local_Stdio_Fn_DeprecationName, zApple_Local_Stdio_Fn_DeprecationList,
11708+
apzApple_Local_Stdio_Fn_DeprecationMachs,
11709+
APPLE_LOCAL_STDIO_FN_DEPRECATION_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
11710+
aApple_Local_Stdio_Fn_DeprecationTests, apzApple_Local_Stdio_Fn_DeprecationPatch, 0 },
11711+
1166611712
{ zCtrl_Quotes_DefName, zCtrl_Quotes_DefList,
1166711713
apzCtrl_Quotes_DefMachs,
1166811714
CTRL_QUOTES_DEF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,

fixincludes/inclhack.def

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,18 @@ fix = {
12691269
test_text = '#define vfscanf __svfscanf';
12701270
};
12711271

1272+
fix = {
1273+
hackname = apple_local_stdio_fn_deprecation;
1274+
mach = "*-*-*darwin2*";
1275+
files = stdio.h;
1276+
select = "__deprecated_msg([^\n]*)$";
1277+
c_fix = format;
1278+
c_fix_arg = "#if defined(__APPLE_LOCAL_DEPRECATIONS)\n"
1279+
"%0\n"
1280+
"#endif";
1281+
test_text = '__deprecated_msg("This function is provided for compat...")';
1282+
};
1283+
12721284
/*
12731285
* Fix various macros used to define ioctl numbers.
12741286
* The traditional syntax was:

fixincludes/tests/base/stdio.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ int vfscanf(FILE *, const char *, __builtin_va_list) __asm__ (_BSD_STRING(__USER
4141
#endif /* BSD_STDIO_ATTRS_CONFLICT_CHECK */
4242

4343

44+
#if defined( APPLE_LOCAL_STDIO_FN_DEPRECATION_CHECK )
45+
#if defined(__APPLE_LOCAL_DEPRECATIONS)
46+
__deprecated_msg("This function is provided for compat...")
47+
#endif
48+
#endif /* APPLE_LOCAL_STDIO_FN_DEPRECATION_CHECK */
49+
50+
4451
#if defined( HPUX10_STDIO_DECLARATIONS_CHECK )
4552
# define _iob __iob
4653

0 commit comments

Comments
 (0)