From 97448adf21ff74d0efe757d580dcefb5aab75244 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Sun, 20 Nov 2016 10:49:47 +0000 Subject: Fix libsanitizer build on OS X 10.1[01], macOS 10.12 (PR sanitizer/78267) fixincludes: PR sanitizer/78267 * inclhack.def (darwin_availabilityinternal, darwin_os_trace_1) (darwin_os_trace_2, darwin_os_trace_3): New fixes. (hpux_stdint_least_fast): Remove spurious _EOFix_. * fixincl.x: Regenerate. * tests/bases/AvailabilityInternal.h: New file. * tests/bases/os/trace.h: New file. 2016-11-20 Jack Howarth libsanitizer: PR sanitizer/78267 * sanitizer_common/sanitizer_mac.cc: Include only if compiler supports blocks extension. From-SVN: r242633 --- fixincludes/ChangeLog | 10 ++ fixincludes/fixincl.x | 197 +++++++++++++++++++++++++- fixincludes/inclhack.def | 83 ++++++++++- fixincludes/tests/base/AvailabilityInternal.h | 31 ++++ fixincludes/tests/base/os/trace.h | 38 +++++ 5 files changed, 353 insertions(+), 6 deletions(-) create mode 100644 fixincludes/tests/base/AvailabilityInternal.h create mode 100644 fixincludes/tests/base/os/trace.h (limited to 'fixincludes') diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog index 1d55b657d8c..fef9f9fdc6f 100644 --- a/fixincludes/ChangeLog +++ b/fixincludes/ChangeLog @@ -1,3 +1,13 @@ +2016-11-20 Rainer Orth + + PR sanitizer/78267 + * inclhack.def (darwin_availabilityinternal, darwin_os_trace_1) + (darwin_os_trace_2, darwin_os_trace_3): New fixes. + (hpux_stdint_least_fast): Remove spurious _EOFix_. + * fixincl.x: Regenerate. + * tests/bases/AvailabilityInternal.h: New file. + * tests/bases/os/trace.h: New file. + 2016-09-30 Tadek Kijkowski * check.tpl: Convert line endings to unix on test outputs diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x index cc5209e6205..00d03be8ffe 100644 --- a/fixincludes/fixincl.x +++ b/fixincludes/fixincl.x @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed Sunday September 4, 2016 at 12:15:33 PM EDT + * It has been AutoGen-ed November 20, 2016 at 11:44:36 AM by AutoGen 5.16.2 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Sun 4 Sep 2016 12:15:33 EDT +/* DO NOT SVN-MERGE THIS FILE, EITHER Sun Nov 20 11:44:37 MET 2016 * * You must regenerate it. Use the ./genfixes script. * @@ -15,7 +15,7 @@ * certain ANSI-incompatible system header files which are fixed to work * correctly with ANSI C and placed in a directory that GNU C will search. * - * This file contains 237 fixup descriptions. + * This file contains 241 fixup descriptions. * * See README for more information. * @@ -2577,6 +2577,51 @@ extern \"C\" {\n\ #endif\n", (char*)NULL }; +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Darwin_Availabilityinternal fix + */ +tSCC zDarwin_AvailabilityinternalName[] = + "darwin_availabilityinternal"; + +/* + * File name selection pattern + */ +tSCC zDarwin_AvailabilityinternalList[] = + "AvailabilityInternal.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzDarwin_AvailabilityinternalMachs[] = { + "*-*-darwin*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zDarwin_AvailabilityinternalSelect0[] = + "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*"; + +#define DARWIN_AVAILABILITYINTERNAL_TEST_CT 1 +static tTestDesc aDarwin_AvailabilityinternalTests[] = { + { TT_EGREP, zDarwin_AvailabilityinternalSelect0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Darwin_Availabilityinternal + */ +static const char* apzDarwin_AvailabilityinternalPatch[] = { + "format", + "#if defined(__has_attribute)\n\ + #if __has_attribute(availability)\n\ +%0\n\ + #else\n\ + #define %1\n\ + #endif\n\ +#else\n\ + #define %1\n\ +#endif", + (char*)NULL }; + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * Description of Darwin_9_Long_Double_Funcs_2 fix @@ -2741,6 +2786,124 @@ static const char* apzDarwin_Longjmp_NoreturnPatch[] = { "%1 __attribute__ ((__noreturn__));", (char*)NULL }; +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Darwin_Os_Trace_1 fix + */ +tSCC zDarwin_Os_Trace_1Name[] = + "darwin_os_trace_1"; + +/* + * File name selection pattern + */ +tSCC zDarwin_Os_Trace_1List[] = + "os/trace.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzDarwin_Os_Trace_1Machs[] = { + "*-*-darwin*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zDarwin_Os_Trace_1Select0[] = + "^(_os_trace_verify_printf.*) (__attribute__.*)"; + +#define DARWIN_OS_TRACE_1_TEST_CT 1 +static tTestDesc aDarwin_Os_Trace_1Tests[] = { + { TT_EGREP, zDarwin_Os_Trace_1Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Darwin_Os_Trace_1 + */ +static const char* apzDarwin_Os_Trace_1Patch[] = { + "format", + "%1", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Darwin_Os_Trace_2 fix + */ +tSCC zDarwin_Os_Trace_2Name[] = + "darwin_os_trace_2"; + +/* + * File name selection pattern + */ +tSCC zDarwin_Os_Trace_2List[] = + "os/trace.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzDarwin_Os_Trace_2Machs[] = { + "*-*-darwin*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zDarwin_Os_Trace_2Select0[] = + "typedef.*\\^os_trace_payload_t.*"; + +#define DARWIN_OS_TRACE_2_TEST_CT 1 +static tTestDesc aDarwin_Os_Trace_2Tests[] = { + { TT_EGREP, zDarwin_Os_Trace_2Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Darwin_Os_Trace_2 + */ +static const char* apzDarwin_Os_Trace_2Patch[] = { + "format", + "#if __BLOCKS__\n\ +%0\n\ +#endif", + (char*)NULL }; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Darwin_Os_Trace_3 fix + */ +tSCC zDarwin_Os_Trace_3Name[] = + "darwin_os_trace_3"; + +/* + * File name selection pattern + */ +tSCC zDarwin_Os_Trace_3List[] = + "os/trace.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzDarwin_Os_Trace_3Machs[] = { + "*-*-darwin*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zDarwin_Os_Trace_3Select0[] = + "__(API|OSX)_.*\n\ +OS_EXPORT.*\n\ +.*\n\ +_os_trace.*os_trace_payload_t payload);"; + +#define DARWIN_OS_TRACE_3_TEST_CT 1 +static tTestDesc aDarwin_Os_Trace_3Tests[] = { + { TT_EGREP, zDarwin_Os_Trace_3Select0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Darwin_Os_Trace_3 + */ +static const char* apzDarwin_Os_Trace_3Patch[] = { + "format", + "#if __BLOCKS__\n\ +%0\n\ +#endif", + (char*)NULL }; + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * Description of Darwin_Private_Extern fix @@ -9714,9 +9877,9 @@ static const char* apzX11_SprintfPatch[] = { * * List of all fixes */ -#define REGEX_COUNT 275 +#define REGEX_COUNT 279 #define MACH_LIST_SIZE_LIMIT 187 -#define FIX_COUNT 237 +#define FIX_COUNT 241 /* * Enumerate the fixes @@ -9781,10 +9944,14 @@ typedef enum { CTRL_QUOTES_DEF_FIXIDX, CTRL_QUOTES_USE_FIXIDX, CXX_UNREADY_FIXIDX, + DARWIN_AVAILABILITYINTERNAL_FIXIDX, DARWIN_9_LONG_DOUBLE_FUNCS_2_FIXIDX, DARWIN_EXTERNC_FIXIDX, DARWIN_GCC4_BREAKAGE_FIXIDX, DARWIN_LONGJMP_NORETURN_FIXIDX, + DARWIN_OS_TRACE_1_FIXIDX, + DARWIN_OS_TRACE_2_FIXIDX, + DARWIN_OS_TRACE_3_FIXIDX, DARWIN_PRIVATE_EXTERN_FIXIDX, DARWIN_STDINT_1_FIXIDX, DARWIN_STDINT_2_FIXIDX, @@ -10257,6 +10424,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { CXX_UNREADY_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aCxx_UnreadyTests, apzCxx_UnreadyPatch, 0 }, + { zDarwin_AvailabilityinternalName, zDarwin_AvailabilityinternalList, + apzDarwin_AvailabilityinternalMachs, + DARWIN_AVAILABILITYINTERNAL_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aDarwin_AvailabilityinternalTests, apzDarwin_AvailabilityinternalPatch, 0 }, + { zDarwin_9_Long_Double_Funcs_2Name, zDarwin_9_Long_Double_Funcs_2List, apzDarwin_9_Long_Double_Funcs_2Machs, DARWIN_9_LONG_DOUBLE_FUNCS_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, @@ -10277,6 +10449,21 @@ tFixDesc fixDescList[ FIX_COUNT ] = { DARWIN_LONGJMP_NORETURN_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aDarwin_Longjmp_NoreturnTests, apzDarwin_Longjmp_NoreturnPatch, 0 }, + { zDarwin_Os_Trace_1Name, zDarwin_Os_Trace_1List, + apzDarwin_Os_Trace_1Machs, + DARWIN_OS_TRACE_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aDarwin_Os_Trace_1Tests, apzDarwin_Os_Trace_1Patch, 0 }, + + { zDarwin_Os_Trace_2Name, zDarwin_Os_Trace_2List, + apzDarwin_Os_Trace_2Machs, + DARWIN_OS_TRACE_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aDarwin_Os_Trace_2Tests, apzDarwin_Os_Trace_2Patch, 0 }, + + { zDarwin_Os_Trace_3Name, zDarwin_Os_Trace_3List, + apzDarwin_Os_Trace_3Machs, + DARWIN_OS_TRACE_3_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aDarwin_Os_Trace_3Tests, apzDarwin_Os_Trace_3Patch, 0 }, + { zDarwin_Private_ExternName, zDarwin_Private_ExternList, apzDarwin_Private_ExternMachs, DARWIN_PRIVATE_EXTERN_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index 1183b590f44..931161b69ce 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -1337,6 +1337,32 @@ fix = { test_text = "extern void* malloc( size_t );"; }; +/* + * macOS 10.12 uses __attribute__((availability)) + * unconditionally. + */ +fix = { + hackname = darwin_availabilityinternal; + mach = "*-*-darwin*"; + files = AvailabilityInternal.h; + select = "#define[ \t]+(__API_[ADU]\\([^)]*\\)).*"; + c_fix = format; + c_fix_arg = <<- _EOFix_ + #if defined(__has_attribute) + #if __has_attribute(availability) + %0 + #else + #define %1 + #endif + #else + #define %1 + #endif + _EOFix_; + + test_text = "#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))\n" + "#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg)))"; +}; + /* * For the AAB_darwin7_9_long_double_funcs fix to be useful, * you have to not use "" includes. @@ -1409,6 +1435,62 @@ fix = { test_text = "void siglongjmp(sigjmp_buf, int);"; }; +/* + * Mac OS X 10.11 uses attribute on function definition. + */ +fix = { + hackname = darwin_os_trace_1; + mach = "*-*-darwin*"; + files = os/trace.h; + select = "^(_os_trace_verify_printf.*) (__attribute__.*)"; + c_fix = format; + c_fix_arg = "%1"; + test_text = "_os_trace_verify_printf(const char *msg, ...) __attribute__((format(printf, 1, 2)))"; +}; + +/* + * Mac OS X 10.1[012] os_trace_payload_t typedef uses Blocks + * extension without guard. + */ +fix = { + hackname = darwin_os_trace_2; + mach = "*-*-darwin*"; + files = os/trace.h; + select = "typedef.*\\^os_trace_payload_t.*"; + c_fix = format; + c_fix_arg = "#if __BLOCKS__\n%0\n#endif"; + test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);"; +}; + +/* + * In Mac OS X 10.1[012] , need to guard users of + * os_trace_payload_t typedef, too. + */ +fix = { + hackname = darwin_os_trace_3; + mach = "*-*-darwin*"; + files = os/trace.h; + select = <<- _EOSelect_ + __(API|OSX)_.* + OS_EXPORT.* + .* + _os_trace.*os_trace_payload_t payload); + _EOSelect_; + c_fix = format; + c_fix_arg = "#if __BLOCKS__\n%0\n#endif"; + test_text = <<- _EOText_ + __API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0)) + OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED + void + _os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload); + + __OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0) + OS_EXPORT OS_NOTHROW + void + _os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload); + _EOText_; +}; + /* * __private_extern__ doesn't exist in FSF GCC. Even if it did, * why would you ever put it in a system header file? @@ -2638,7 +2720,6 @@ fix = { c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__"; test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n" "# define UINT_LEAST64_MAX ULLONG_MAX\n"; - _EOFix_; }; /* diff --git a/fixincludes/tests/base/AvailabilityInternal.h b/fixincludes/tests/base/AvailabilityInternal.h new file mode 100644 index 00000000000..60b3503f153 --- /dev/null +++ b/fixincludes/tests/base/AvailabilityInternal.h @@ -0,0 +1,31 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "fixinc/tests/inc/AvailabilityInternal.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + + + +#if defined( DARWIN_AVAILABILITYINTERNAL_CHECK ) +#if defined(__has_attribute) + #if __has_attribute(availability) +#define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x))) + #else + #define __API_A(x) + #endif +#else + #define __API_A(x) +#endif +#if defined(__has_attribute) + #if __has_attribute(availability) +#define __API_D(msg,x) __attribute__((availability(__API_DEPRECATED_PLATFORM_##x,message=msg))) + #else + #define __API_D(msg,x) + #endif +#else + #define __API_D(msg,x) +#endif +#endif /* DARWIN_AVAILABILITYINTERNAL_CHECK */ diff --git a/fixincludes/tests/base/os/trace.h b/fixincludes/tests/base/os/trace.h new file mode 100644 index 00000000000..fdbf1a809fe --- /dev/null +++ b/fixincludes/tests/base/os/trace.h @@ -0,0 +1,38 @@ +/* DO NOT EDIT THIS FILE. + + It has been auto-edited by fixincludes from: + + "fixinc/tests/inc/os/trace.h" + + This had to be done to correct non-standard usages in the + original, manufacturer supplied header file. */ + + + +#if defined( DARWIN_OS_TRACE_1_CHECK ) +_os_trace_verify_printf(const char *msg, ...) +#endif /* DARWIN_OS_TRACE_1_CHECK */ + + +#if defined( DARWIN_OS_TRACE_2_CHECK ) +#if __BLOCKS__ +typedef void (^os_trace_payload_t)(xpc_object_t xdict); +#endif +#endif /* DARWIN_OS_TRACE_2_CHECK */ + + +#if defined( DARWIN_OS_TRACE_3_CHECK ) +#if __BLOCKS__ +__API_AVAILABLE(macosx(10.10), ios(8.0), watchos(2.0), tvos(8.0)) +OS_EXPORT OS_NOTHROW OS_NOT_TAIL_CALLED +void +_os_trace_with_buffer(void *dso, const char *message, uint8_t type, const void *buffer, size_t buffer_size, os_trace_payload_t payload); +#endif + +#if __BLOCKS__ +__OSX_AVAILABLE_STARTING(__MAC_10_12, __IPHONE_10_0) +OS_EXPORT OS_NOTHROW +void +_os_trace_internal(void *dso, uint8_t type, const char *format, const uint8_t *buf, size_t buf_size, os_trace_payload_t payload); +#endif +#endif /* DARWIN_OS_TRACE_3_CHECK */ -- cgit v1.2.3