From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70078.outbound.protection.outlook.com [40.107.7.78]) by sourceware.org (Postfix) with ESMTPS id 27A05385B835; Tue, 31 Mar 2020 12:06:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 27A05385B835 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Andrea.Corallo@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K345de+KlSUdLZEDildTG5EnATd+RKfvKZ16ZHPGFRA=; b=u37dlorA76ND1JRn2O+MoE8AJftfKfqlX0a51jDmxfJuDL+IQoY30qJ87nR3fkJHLScfWijYGsKivTABbxwJnrgqs3bw8YsSa2x3A66/wZlCWc/rq9kHZJXf1EklaFz020VRrWsG1BNeXn9O2T3Rb/0hXe4X3Ks97/P5uKK1mjA= Received: from AM6PR10CA0083.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::24) by VI1PR08MB3552.eurprd08.prod.outlook.com (2603:10a6:803:81::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.20; Tue, 31 Mar 2020 12:06:25 +0000 Received: from AM5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::c8) by AM6PR10CA0083.outlook.office365.com (2603:10a6:209:8c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.19 via Frontend Transport; Tue, 31 Mar 2020 12:06:25 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT038.mail.protection.outlook.com (10.152.17.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.17 via Frontend Transport; Tue, 31 Mar 2020 12:06:25 +0000 Received: ("Tessian outbound eadf07c3b4bb:v50"); Tue, 31 Mar 2020 12:06:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 427cc118ae887235 X-CR-MTA-TID: 64aa7808 Received: from 890c196715c4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2535B17C-ABC7-423C-BF21-1A44CD95677B.1; Tue, 31 Mar 2020 12:06:19 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 890c196715c4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 31 Mar 2020 12:06:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IpK9U5+/XVtyPLDv2/W4ILxyGSwKa7glDxcxIJH1X3XWzqPemBExkWzRSG/WiNGb2j4omzmOR/e5udl/ZEYH2TOTjFEJIEkhaHWyiGLGlY2y8EL1sEOj+5DI7UWJvyDkbdebP34f8+lFH9gYB0PUzylLEFDntwKltUCZq8tA85EwFwYzhZFbS4iAJTKwPVDJ16YwyOkX74YjOV8Yc93vvpESiNor5y69EdwhLFa6DUHkioop0iCGdhPPhYg/2xf5ERCHOm9LWLkUG+ovsXvOZZVgVCBAjKv0AzjxtODXTXX4cmvbHUC2jnUClYL+6j5sjgjC7V8AkQY4+8S9JDP29Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K345de+KlSUdLZEDildTG5EnATd+RKfvKZ16ZHPGFRA=; b=KFL8Wjbic17V58thitHJknM37DgHf8BuP4PlsvNfKWIzuq0ZMYMs4oetArBk1hD/ndNw/bLf315th1EO2tpjONgD/R+uQaIZa84KEEAmJySTVnr5jRJWsJO5849OMK8RA+UnWXgQoZQ1Y4lszS0jzQ+xjMS2bgeWe2y5MtwVObG9J7w+/3qnQ5FXYvzWfs7rjmWYLPNWdlMqvYvmhJ8wxqjLI6R8KM0eXvSTNfl1x3kXmNbT83pvfqQeA6IOVK2T6zh1WswDdwP4ZvwWq4auUNtHDv2qrkSniKlrK4O0Pxzi+r+RUCJrlDGOyTpqlc3e+CjwzYdAqJibfGe+Mwpmrg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K345de+KlSUdLZEDildTG5EnATd+RKfvKZ16ZHPGFRA=; b=u37dlorA76ND1JRn2O+MoE8AJftfKfqlX0a51jDmxfJuDL+IQoY30qJ87nR3fkJHLScfWijYGsKivTABbxwJnrgqs3bw8YsSa2x3A66/wZlCWc/rq9kHZJXf1EklaFz020VRrWsG1BNeXn9O2T3Rb/0hXe4X3Ks97/P5uKK1mjA= Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; Received: from VI1PR08MB2765.eurprd08.prod.outlook.com (10.170.236.32) by VI1PR08MB3421.eurprd08.prod.outlook.com (20.177.60.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.19; Tue, 31 Mar 2020 12:06:18 +0000 Received: from VI1PR08MB2765.eurprd08.prod.outlook.com ([fe80::d1c5:9f98:9665:8092]) by VI1PR08MB2765.eurprd08.prod.outlook.com ([fe80::d1c5:9f98:9665:8092%7]) with mapi id 15.20.2856.019; Tue, 31 Mar 2020 12:06:18 +0000 From: Andrea Corallo To: David Malcolm Cc: "jit@gcc.gnu.org" , nd , gcc-patches@gcc.gnu.org Subject: [PATCH V4][gcc] libgccjit: introduce version entry points References: <330ed10fb3e66abdbc5d30fdf2ba2fd3c3b30cf6.camel@redhat.com> <878sjivr6m.fsf@arm.com> Date: Tue, 31 Mar 2020 14:05:52 +0200 In-Reply-To: <878sjivr6m.fsf@arm.com> (Andrea Corallo's message of "Sun, 29 Mar 2020 21:31:29 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: multipart/mixed; boundary="=-=-=" X-ClientProxiedBy: DM5PR17CA0049.namprd17.prod.outlook.com (2603:10b6:3:13f::11) To VI1PR08MB2765.eurprd08.prod.outlook.com (2603:10a6:802:18::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from e112547 (217.140.99.251) by DM5PR17CA0049.namprd17.prod.outlook.com (2603:10b6:3:13f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.19 via Frontend Transport; Tue, 31 Mar 2020 12:06:16 +0000 X-Originating-IP: [217.140.99.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 44dede57-002f-4a43-b689-08d7d56befce X-MS-TrafficTypeDiagnostic: VI1PR08MB3421:|VI1PR08MB3552: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-Forefront-PRVS: 0359162B6D X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB2765.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(376002)(346002)(366004)(396003)(39860400002)(136003)(2616005)(66946007)(44832011)(86362001)(6666004)(478600001)(6486002)(2906002)(54906003)(186003)(4326008)(26005)(16526019)(316002)(6916009)(235185007)(956004)(5660300002)(66616009)(66476007)(81156014)(8676002)(81166006)(66556008)(6496006)(52116002)(36756003)(8936002); DIR:OUT; SFP:1101; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: U6KVdCXGmvpFMjNpT+pRTCt+RmvlHM5RbnM7Rz2Cdul696KIUXnhtdnYYcoJ5Y/VDePcefKx4Xc9uifJBhsZ1KuqpZE7gw9Rbne+RLP0TQzGWCaeXSTeItZ5oeM2Az56bn5v0tZEofTZuct59SEW5ilbYiVUcIqfgBRioEhKgSNlIts7foTWiFrHOi9ubyroVtK6lGEw7gpYe4nlbbORmdBCzx86MK0GtaKP1fqoiTAo2/fZb/Ib6l3pIwz4QjUwk84FtXPnozFUwR6xwixDQqMsGjeh+pZj48qhc3CFne+lfYqw5ZmrL+fmKksYE+8wrjZy4X5g/eHjQPqzhxiid4CNaeH4Cqae5DDodh0lAKuAStrYdsBuEWsT45nkdZiqOeUQVl+G3kjRCKlYcH3lzAmqNEt/g5hPQ934RY+KIdWFu9R8x1XVmk64PZJYKAA0 X-MS-Exchange-AntiSpam-MessageData: Zos7+b+DwEsYr+xb3J11HATYZwN5RMoAUnqh2d+JUCZPVbfM9S7LpUdOcn7OzzD9BVu2IISlB2eZc1gmZRIbkwYnVhNwnsuU1VfzVDsUmJdJ8HKgIomR3OQzhZuJltesE65NcLRu9R3l9Q8Yz21Fkw== X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3421 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT038.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(10009020)(4636009)(376002)(346002)(39860400002)(396003)(136003)(46966005)(86362001)(336012)(450100002)(26005)(26826003)(186003)(5660300002)(16526019)(44832011)(4326008)(956004)(6496006)(8676002)(2616005)(8936002)(81156014)(54906003)(6862004)(81166006)(2906002)(70206006)(70586007)(36756003)(356004)(235185007)(316002)(478600001)(36906005)(66616009)(6486002)(47076004)(6666004)(82740400003); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 8d0b15a2-7bed-4713-70c0-08d7d56beb55 X-Forefront-PRVS: 0359162B6D X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Jpq6brmf/eZK6r1LOqXb4OS/8+YeYbOF1C6ktc9Qe9uZ3PGL5zPjBgnJSU4oS60+Z/LAthCrO/qUij6SakFjInqH0vsC9ZbRcDL+EUMJOkzJ5b2Idw554h7pCBQMrmirhlPpQ2xwiAwqd4LC3RjAOJKO+/tVNsH/Cd4Ag+oVBAmva3AH1t9kDmNB7d45qySAJ5052RQHA8hU4uVtBNHaiR98Yuf01VRTGwSy37C+ArXfKnNjOr/X7gDonW5uWs7b618htGXI33j08yw5VOlgCQ9MoWRlnKvszlRxi0OIAwqj8npjZOAqtekkF/taR8+ADJBV5jItq19EWRIXjT9mvWQe9B80BpuPbtlllrR0SxyHz7yymvG6E/psrVRvy8XrI1mtT0/1Lu4i5c5Y+8G7BxOrm5yYnQY+B7wF1HBjGtXsS0732rxBgKEJlVeRuHqknD1rojurxFg3pEqiM5L8pIiIkxoTKiRFLtrMcO75blqy+LWtbR95wpA64grZnQ9yr4GaNgau7qFI4/PRL5axbA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2020 12:06:25.6692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 44dede57-002f-4a43-b689-08d7d56befce X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3552 X-Spam-Status: No, score=-32.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 12:06:31 -0000 --=-=-= Content-Type: text/plain Hi all, Updated version of the patch addressing last comments. Regression clean, okay to apply? Bests Andrea gcc/jit/ChangeLog 2020-??-?? Andrea Corallo David Malcolm * docs/topics/compatibility.rst (LIBGCCJIT_ABI_13): New ABI tag plus add version paragraph. * libgccjit++.h (namespace gccjit::version): Add new namespace. * libgccjit.c (gcc_jit_version_major, gcc_jit_version_minor) (gcc_jit_version_patchlevel): New functions. * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_version): New macro. (gcc_jit_version_major, gcc_jit_version_minor) (gcc_jit_version_patchlevel): New functions. * libgccjit.map (LIBGCCJIT_ABI_13) New ABI tag. gcc/testsuite/ChangeLog 2020-??-?? Andrea Corallo * jit.dg/test-version.c: New testcase. * jit.dg/all-non-failing-tests.h: Add test-version.c. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Add-new-version-entry-point.patch >From 181082c1dfc02521f3f1b44c058af26b0884614a Mon Sep 17 00:00:00 2001 From: AndreaCorallo Date: Sun, 8 Mar 2020 13:46:33 +0000 Subject: [PATCH] Add new version entry point --- gcc/jit/docs/topics/compatibility.rst | 33 ++++++++++++++ gcc/jit/libgccjit++.h | 22 ++++++++++ gcc/jit/libgccjit.c | 46 ++++++++++++++++++++ gcc/jit/libgccjit.h | 16 +++++++ gcc/jit/libgccjit.map | 9 +++- gcc/testsuite/jit.dg/all-non-failing-tests.h | 10 +++++ gcc/testsuite/jit.dg/test-version.c | 26 +++++++++++ 7 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/jit.dg/test-version.c diff --git a/gcc/jit/docs/topics/compatibility.rst b/gcc/jit/docs/topics/compatibility.rst index a6faee0810e..0c0ce070d72 100644 --- a/gcc/jit/docs/topics/compatibility.rst +++ b/gcc/jit/docs/topics/compatibility.rst @@ -61,6 +61,28 @@ You can see the symbol tags provided by libgccjit.so using ``objdump``: LIBGCCJIT_ABI_0 [...snip...] +Programmatically checking version +*************** + +Client code can programmatically check libgccjit version using: + +.. function:: int gcc_jit_version_major (void) + + Return libgccjit major version. This is analogous to __GNUC__ in C code. + +.. function:: int gcc_jit_version_minor (void) + + Return libgccjit minor version. This is analogous to + __GNUC_MINOR__ in C code. + +.. function:: int gcc_jit_version_patchlevel (void) + + Return libgccjit patchlevel version. This is analogous to + __GNUC_PATCHLEVEL__ in C code. + +.. note:: These entry points has been added with ``LIBGCCJIT_ABI_13`` + (see below). + ABI symbol tags *************** @@ -182,3 +204,14 @@ entrypoints: -------------------- ``LIBGCCJIT_ABI_12`` covers the addition of :func:`gcc_jit_context_new_bitfield` + +``LIBGCCJIT_ABI_13`` +-------------------- +``LIBGCCJIT_ABI_13`` covers the addition of version functions via API +entrypoints: + + * :func:`gcc_jit_version_major` + + * :func:`gcc_jit_version_minor` + + * :func:`gcc_jit_version_patchlevel` diff --git a/gcc/jit/libgccjit++.h b/gcc/jit/libgccjit++.h index 82a62d614c5..69e67766640 100644 --- a/gcc/jit/libgccjit++.h +++ b/gcc/jit/libgccjit++.h @@ -49,6 +49,8 @@ namespace gccjit class timer; class auto_time; + namespace version {}; + /* Errors within the API become C++ exceptions of this class. */ class error { @@ -1913,6 +1915,26 @@ auto_time::~auto_time () m_timer.pop (m_item_name); } +namespace version +{ +inline int +major_v () +{ + return gcc_jit_version_major (); +} + +inline int +minor_v () +{ + return gcc_jit_version_minor (); +} + +inline int +patchlevel_v () +{ + return gcc_jit_version_patchlevel (); +} +} // namespace version } // namespace gccjit #endif /* #ifndef LIBGCCJIT_PLUS_PLUS_H */ diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h index 21a0dc09b03..1c5a12e9c01 100644 --- a/gcc/jit/libgccjit.h +++ b/gcc/jit/libgccjit.h @@ -1487,6 +1487,22 @@ gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt, size_t num_elements, gcc_jit_rvalue **elements); +#define LIBGCCJIT_HAVE_gcc_jit_version + +/* Functions to retrive libgccjit version. + Analogous to __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ in C code. + + These API entrypoints were added in LIBGCCJIT_ABI_13; you can test for their + presence using + #ifdef LIBGCCJIT_HAVE_gcc_jit_version + */ +extern int +gcc_jit_version_major (void); +extern int +gcc_jit_version_minor (void); +extern int +gcc_jit_version_patchlevel (void); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 83055fc297b..a29e9885e59 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -23,6 +23,8 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "timevar.h" #include "typed-splay-tree.h" +#include "cppbuiltin.h" +#include #include "libgccjit.h" #include "jit-recording.h" @@ -3175,3 +3177,47 @@ gcc_jit_context_new_rvalue_from_vector (gcc_jit_context *ctxt, as_vec_type, (gcc::jit::recording::rvalue **)elements); } + +/* A mutex around the cached state in parse_basever. + Ideally this would be within parse_basever, but the mutex is only needed + by libgccjit. */ + +static pthread_mutex_t version_mutex = PTHREAD_MUTEX_INITIALIZER; + +struct version_info +{ + /* Default constructor. Populate via parse_basever, + guarded by version_mutex. */ + version_info () + { + pthread_mutex_lock (&version_mutex); + parse_basever (&major, &minor, &patchlevel); + pthread_mutex_unlock (&version_mutex); + } + + int major; + int minor; + int patchlevel; +}; + + +extern int +gcc_jit_version_major (void) +{ + version_info vi; + return vi.major; +} + +extern int +gcc_jit_version_minor (void) +{ + version_info vi; + return vi.minor; +} + +extern int +gcc_jit_version_patchlevel (void) +{ + version_info vi; + return vi.patchlevel; +} diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map index 4514bd3aa33..6137dd4b4b0 100644 --- a/gcc/jit/libgccjit.map +++ b/gcc/jit/libgccjit.map @@ -179,4 +179,11 @@ LIBGCCJIT_ABI_11 { LIBGCCJIT_ABI_12 { global: gcc_jit_context_new_bitfield; -} LIBGCCJIT_ABI_11; \ No newline at end of file +} LIBGCCJIT_ABI_11; + +LIBGCCJIT_ABI_13 { + global: + gcc_jit_version_major; + gcc_jit_version_minor; + gcc_jit_version_patchlevel; +} LIBGCCJIT_ABI_12; \ No newline at end of file diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h b/gcc/testsuite/jit.dg/all-non-failing-tests.h index 0272e6f846f..9fb056fef7f 100644 --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h @@ -254,6 +254,13 @@ /* test-vector-types.cc: We don't use this, since it's C++. */ +/* test-version.c */ +#define create_code create_code_version +#define verify_code verify_code_version +#include "test-version.c" +#undef create_code +#undef verify_code + /* test-volatile.c */ #define create_code create_code_volatile #define verify_code verify_code_volatile @@ -372,6 +379,9 @@ const struct testcase testcases[] = { {"using_global", create_code_using_global, verify_code_using_global}, + {"version", + create_code_version, + verify_code_version}, {"volatile", create_code_volatile, verify_code_volatile} diff --git a/gcc/testsuite/jit.dg/test-version.c b/gcc/testsuite/jit.dg/test-version.c new file mode 100644 index 00000000000..4338a00018b --- /dev/null +++ b/gcc/testsuite/jit.dg/test-version.c @@ -0,0 +1,26 @@ +#include +#include + +#include "libgccjit.h" + +#include "harness.h" + +#ifndef LIBGCCJIT_HAVE_gcc_jit_version +#error LIBGCCJIT_HAVE_gcc_jit_version was not defined +#endif + +void +create_code (gcc_jit_context *ctxt, void *user_data) +{ + /* Do nothing. */ +} + +void +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) +{ + if (!gcc_jit_version_major ()) + fail ("Major version is zero"); + /* Minor and patchlevel can be zero. */ + gcc_jit_version_minor (); + gcc_jit_version_patchlevel (); +} -- 2.17.1 --=-=-=--