From patchwork Mon Aug 25 18:03:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jessica Clarke X-Patchwork-Id: 382825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1F6BB140088 for ; Tue, 26 Aug 2014 04:04:19 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=ocFU/8mx1zWn 9LtN5t6tpwZgnaPlPZspzIetArM3v5aMaudMVEFC1PrOGNbrxNAD7IeQJQ2ewbPV w9FdRKwL+lijEKcRkKOF7wavY8/osNPtUxJ6deU7NooEGqvD3FUXgkqqKAuTlNhc KX/tiDtnqLevALYkiAD0JephNs8vAQA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=oJ/EtUjr086LjIGqaL NNOoiO3zA=; b=SPrmhr1UsPEDaNKuGphKskaLI9+meW02WJQV77hnqWeva2W8n0 0ggijMsvkDxSkfB0H+fXmlr6WnTRczU45FuAEb9BSHPsizHyU3Gqbfc7qVYdvU5l Ujwd7j7YYEc2NtJWHW1GhTr9uk1+Cq++6APNJHEu8uOKlJoUzfXCSjTdM= Received: (qmail 568 invoked by alias); 25 Aug 2014 18:04:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 516 invoked by uid 89); 25 Aug 2014 18:04:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f176.google.com Received: from mail-we0-f176.google.com (HELO mail-we0-f176.google.com) (74.125.82.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 25 Aug 2014 18:04:00 +0000 Received: by mail-we0-f176.google.com with SMTP id q58so13596091wes.35 for ; Mon, 25 Aug 2014 11:03:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4FcCvrfnAvW3bOzKcXMccvaG86ykPHRgHi2IWYnDfNQ=; b=QQXTbkGTigx3Y88XW/XLu6ADDxgqerXSOnBmQoIvNibIDYKt6s52DBNzbO/t1zWGIh 2sCeT5IhZulr92efGXULSCRJplZwvSMnObHFux8MHp9fG4u+rKqWAcC1UNGRkuSQVRFf /AtcQk5RXoPbEvr6Xrj8WJMtfqsjtbL+4Mc+klV0IEh5ubrY2VE8ZC1s6HtFuxYwCz/1 dL4IMTsAycOct57CPLCF8HuMvDoBnRF0AbakDSDDYIEKOipGdpRQbR2q5JXSgZYIFS1I hQENVReox08ym/LOUOW3CiY7D0COayIsFay+YmajGtpOyTg0537K6is2YFQ0Gspj+TzK LVEQ== X-Gm-Message-State: ALoCoQmfDDGo7U7s6enypnGM+LrbKZ99dxGI4qYUWXQlUB/W+YO+4Pt29fjxUThDglwSl3f+1BCB X-Received: by 10.194.186.178 with SMTP id fl18mr24447352wjc.8.1408989837575; Mon, 25 Aug 2014 11:03:57 -0700 (PDT) Received: from localhost.localdomain (host81-133-133-27.in-addr.btopenworld.com. [81.133.133.27]) by mx.google.com with ESMTPSA id mz16sm2940235wic.13.2014.08.25.11.03.56 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Aug 2014 11:03:56 -0700 (PDT) From: James Clarke To: gcc-patches@gcc.gnu.org Cc: James Clarke Subject: [PATCH 1/2] Fix __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ Date: Mon, 25 Aug 2014 19:03:37 +0100 Message-Id: <1408989818-40728-1-git-send-email-jrtc27@jrtc27.com> Previously, this macro had taken the form 10X0, where X is the minor version number, e.g. 1090 for OS X 10.9 Mavericks. However, as of OS X 10.10 Yosemite, it should take the form 10XX00, i.e. 101000 for 10.10. Added a test for the new format and fixed the formatting for the existing ones. gcc/ChangeLog: * config/darwin-c.c (version_as_macro): Added extra 0 for OS X 10.10 and above * config/darwin-driver.c (darwin_find_version_from_kernel): Bump supported kernel version gcc/testsuite/ChangeLog: * gcc.db/darwin-minversion-1.c: Fixed formatting * gcc.db/darwin-minversion-2.c: Fixed formatting * gcc.db/darwin-minversion-3.c: Fixed formatting * gcc.dg/darwin-minversion-4.c: Added test for OS X 10.10 --- gcc/config/darwin-c.c | 25 +++++++++++++++++++------ gcc/config/darwin-driver.c | 2 +- gcc/testsuite/gcc.dg/darwin-minversion-1.c | 3 ++- gcc/testsuite/gcc.dg/darwin-minversion-2.c | 3 ++- gcc/testsuite/gcc.dg/darwin-minversion-3.c | 3 ++- gcc/testsuite/gcc.dg/darwin-minversion-4.c | 12 ++++++++++++ 6 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/darwin-minversion-4.c diff --git a/gcc/config/darwin-c.c b/gcc/config/darwin-c.c index 892ba35..7fe4b1f 100644 --- a/gcc/config/darwin-c.c +++ b/gcc/config/darwin-c.c @@ -571,21 +571,34 @@ 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. + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ macro, so '10.4.2' + becomes 1040 and '10.10.0' becomes 101000. The lowest digit is + always zero, as is the second lowest for '10.10.x' and above. 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 OS X 10.10, the macro ends '00' rather than '0', + i.e. 10.10.x becomes 101000 rather than 10100. */ + 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/gcc/testsuite/gcc.dg/darwin-minversion-1.c b/gcc/testsuite/gcc.dg/darwin-minversion-1.c index d8a3243..6221d61 100644 --- a/gcc/testsuite/gcc.dg/darwin-minversion-1.c +++ b/gcc/testsuite/gcc.dg/darwin-minversion-1.c @@ -2,7 +2,8 @@ /* { dg-options "-mmacosx-version-min=10.1" } */ /* { dg-do run { target *-*-darwin* } } */ -int main(void) +int +main () { #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010 fail me; diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-2.c b/gcc/testsuite/gcc.dg/darwin-minversion-2.c index fd4975a..8e18d52 100644 --- a/gcc/testsuite/gcc.dg/darwin-minversion-2.c +++ b/gcc/testsuite/gcc.dg/darwin-minversion-2.c @@ -2,7 +2,8 @@ /* { dg-options "-mmacosx-version-min=10.1 -mmacosx-version-min=10.3" } */ /* { dg-do run { target *-*-darwin* } } */ -int main(void) +int +main () { #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1030 fail me; diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-3.c b/gcc/testsuite/gcc.dg/darwin-minversion-3.c index d0c5934..4fcb969 100644 --- a/gcc/testsuite/gcc.dg/darwin-minversion-3.c +++ b/gcc/testsuite/gcc.dg/darwin-minversion-3.c @@ -2,7 +2,8 @@ /* { dg-options "-mmacosx-version-min=10.4.10" } */ /* { dg-do compile { target *-*-darwin* } } */ -int main(void) +int +main () { #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1040 fail me; diff --git a/gcc/testsuite/gcc.dg/darwin-minversion-4.c b/gcc/testsuite/gcc.dg/darwin-minversion-4.c new file mode 100644 index 0000000..1cb42eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/darwin-minversion-4.c @@ -0,0 +1,12 @@ +/* Test that major versions greater than 9 work and have the additional 0. */ +/* { dg-options "-mmacosx-version-min=10.10.0" } */ +/* { dg-do compile { target *-*-darwin* } } */ + +int +main () +{ +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 101000 + fail me; +#endif + return 0; +}