Skip to content

Instantly share code, notes, and snippets.

@randallb
Created July 8, 2014 17:35
Show Gist options
  • Save randallb/c2927c90b2e83ee80ec9 to your computer and use it in GitHub Desktop.
Save randallb/c2927c90b2e83ee80ec9 to your computer and use it in GitHub Desktop.
diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index dd45802..0db14d7 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -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 224 fixup descriptions.
+ * This file contains 225 fixup descriptions.
*
* See README for more information.
*
@@ -9182,6 +9182,44 @@ static const char* apzX11_SprintfPatch[] = {
#endif /* !defined __STDC__ */",
(char*)NULL };
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ * Description of Darwin14_Has_Feature fix
+ */
+tSCC zDarwin14_Has_FeatureName[] =
+ "darwin14_has_feature";
+
+/*
+ * File name selection pattern
+ */
+tSCC zDarwin14_Has_FeatureList[] =
+ "Availability.h\0";
+/*
+ * Machine/OS name selection pattern
+ */
+tSCC* apzDarwin14_Has_FeatureMachs[] = {
+ "*-*-darwin14.0*",
+ (const char*)NULL };
+#define DARWIN14_HAS_FEATURE_TEST_CT 0
+#define aDarwin14_Has_FeatureTests (tTestDesc*)NULL
+
+/*
+ * Fix Command Arguments for Darwin14_Has_Feature
+ */
+static const char* apzDarwin14_Has_FeaturePatch[] = {
+ "wrap",
+ "\n\
+/* GCC doesn't support __has_feature built-in in C mode and\n\
+ * using defined(__has_feature) && __has_feature in the same\n\
+ * macro expression is not valid. So, easiest way is to define\n\
+ * for this header __has_feature as a macro, returning 0, in case\n\
+ * it is not defined internally\n\
+ */\n\
+#ifndef __has_feature\n\
+#define __has_feature(x) 0\n\
+#endif\n",
+ (char*)NULL };
+
/* * * * * * * * * * * * * * * * * * * * * * * * * *
*
@@ -9189,7 +9227,7 @@ static const char* apzX11_SprintfPatch[] = {
*/
#define REGEX_COUNT 261
#define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT 224
+#define FIX_COUNT 225
/*
* Enumerate the fixes
@@ -9418,7 +9456,8 @@ typedef enum {
X11_CLASS_FIXIDX,
X11_CLASS_USAGE_FIXIDX,
X11_NEW_FIXIDX,
- X11_SPRINTF_FIXIDX
+ X11_SPRINTF_FIXIDX,
+ DARWIN14_HAS_FEATURE_FIXIDX
} t_fixinc_idx;
tFixDesc fixDescList[ FIX_COUNT ] = {
@@ -10540,5 +10579,10 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
{ zX11_SprintfName, zX11_SprintfList,
apzX11_SprintfMachs,
X11_SPRINTF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
- aX11_SprintfTests, apzX11_SprintfPatch, 0 }
+ aX11_SprintfTests, apzX11_SprintfPatch, 0 },
+
+ { zDarwin14_Has_FeatureName, zDarwin14_Has_FeatureList,
+ apzDarwin14_Has_FeatureMachs,
+ DARWIN14_HAS_FEATURE_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+ aDarwin14_Has_FeatureTests, apzDarwin14_Has_FeaturePatch, 0 }
};
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index 6a1136c..b536080 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -4751,4 +4751,33 @@ fix = {
test_text = "extern char *\tsprintf();";
};
+
+/*
+ * Fix stdio.h using C++ __has_feature built-in on OS X 10.10
+ */
+fix = {
+ hackname = darwin14_has_feature;
+ files = Availability.h;
+ mach = "*-*-darwin14.0*";
+
+ c_fix = wrap;
+ c_fix_arg = <<- _HasFeature_
+
+/*
+ * GCC doesn't support __has_feature built-in in C mode and
+ * using defined(__has_feature) && __has_feature in the same
+ * macro expression is not valid. So, easiest way is to define
+ * for this header __has_feature as a macro, returning 0, in case
+ * it is not defined internally
+ */
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+
+
+_HasFeature_;
+
+ test_text = '';
+};
+
/*EOF*/
diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c
index 892ba35..39f795f 100644
--- a/gcc/config/darwin-c.c
+++ b/gcc/config/darwin-c.c
@@ -572,20 +572,31 @@ find_subframework_header (cpp_reader *pfile, const char *header, cpp_dir **dirp)
/* Return the value of darwin_macosx_version_min suitable for the
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro,
- so '10.4.2' becomes 1040. The lowest digit is always zero.
- Print a warning if the version number can't be understood. */
+ so '10.4.2' becomes 1040 and '10.10.0' becomes 101000. The lowest
+ digit is always zero. Print a warning if the version number
+ can't be understood. */
static const char *
version_as_macro (void)
{
- static char result[] = "1000";
+ static char result[7] = "1000";
+ int minorDigitIdx;
if (strncmp (darwin_macosx_version_min, "10.", 3) != 0)
goto fail;
if (! ISDIGIT (darwin_macosx_version_min[3]))
goto fail;
- result[2] = darwin_macosx_version_min[3];
- if (darwin_macosx_version_min[4] != '\0'
- && darwin_macosx_version_min[4] != '.')
+
+ minorDigitIdx = 3;
+ result[2] = darwin_macosx_version_min[minorDigitIdx++];
+ if (ISDIGIT(darwin_macosx_version_min[minorDigitIdx])) {
+ /* Starting with 10.10 numeration for mactro changed */
+ result[3] = darwin_macosx_version_min[minorDigitIdx++];
+ result[4] = '0';
+ result[5] = '0';
+ result[6] = '\0';
+ }
+ if (darwin_macosx_version_min[minorDigitIdx] != '\0'
+ && darwin_macosx_version_min[minorDigitIdx] != '.')
goto fail;
return result;
diff --git a/gcc/config/darwin-driver.c b/gcc/config/darwin-driver.c
index 8b6ae93..a115616 100644
--- a/gcc/config/darwin-driver.c
+++ b/gcc/config/darwin-driver.c
@@ -57,7 +57,7 @@ darwin_find_version_from_kernel (char *new_flag)
version_p = osversion + 1;
if (ISDIGIT (*version_p))
major_vers = major_vers * 10 + (*version_p++ - '0');
- if (major_vers > 4 + 9)
+ if (major_vers > 4 + 10)
goto parse_failed;
if (*version_p++ != '.')
goto parse_failed;
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
index a93d38d..6783108 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -834,8 +834,10 @@ CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
CHECK_SIZE_AND_OFFSET(dirent, d_ino);
-#if SANITIZER_MAC
+#if SANITIZER_MAC && ( !defined(__DARWIN_64_BIT_INO_T) || __DARWIN_64_BIT_INO_T)
CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
+#elif SANITIZER_MAC
+// There is no d_seekoff with non 64-bit ino_t
#elif SANITIZER_FREEBSD
// There is no 'd_off' field on FreeBSD.
#else
diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
index dece2d3..c830486 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -274,12 +274,20 @@ namespace __sanitizer {
#endif
#if SANITIZER_MAC
+# if ! defined(__DARWIN_64_BIT_INO_T) || __DARWIN_64_BIT_INO_T
struct __sanitizer_dirent {
unsigned long long d_ino;
unsigned long long d_seekoff;
unsigned short d_reclen;
// more fields that we don't care about
};
+# else
+ struct __sanitizer_dirent {
+ unsigned int d_ino;
+ unsigned short d_reclen;
+ // more fields that we don't care about
+ };
+# endif
#elif SANITIZER_FREEBSD
struct __sanitizer_dirent {
unsigned int d_fileno;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment