From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60065.outbound.protection.outlook.com [40.107.6.65]) by sourceware.org (Postfix) with ESMTPS id 37453395A054; Wed, 18 Mar 2020 22:51:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 37453395A054 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=HX+78oboAqijPyisEgUwqIq/TYlX7feqlR5EM8+egCo=; b=ery813X8hpJnITR/E/b6pYsK+swaU04YcmVJfrfQ+unKY0wldg2E+tb1CKXhbTtWlSuIcAvJUEsOtfuqVP9+YOnK1zhEIMMjjP0dmKOmf/A5RRCH1FwAr41JJ038+O5dTOrGcOz1iM1KmbmTTN+bvrtHXtHRmca+A/aDpccvnVE= Received: from AM6P193CA0067.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::44) by DB6PR0801MB2054.eurprd08.prod.outlook.com (2603:10a6:4:77::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18; Wed, 18 Mar 2020 22:51:48 +0000 Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8e:cafe::d9) by AM6P193CA0067.outlook.office365.com (2603:10a6:209:8e::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.21 via Frontend Transport; Wed, 18 Mar 2020 22:51:48 +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 VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Wed, 18 Mar 2020 22:51:47 +0000 Received: ("Tessian outbound 88ba19940385:v48"); Wed, 18 Mar 2020 22:51:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e77dd63490029bd2 X-CR-MTA-TID: 64aa7808 Received: from e921790bd78d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3781551C-FE63-4998-8297-F58A4A06C499.1; Wed, 18 Mar 2020 22:51:41 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e921790bd78d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 18 Mar 2020 22:51:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NK3hyRJW5ieRWxlJN/Oa9Byr7uA1ObloQZ2w4N4sgzRTMzrRj72+sWMyHQAzcSBWqfIlh6lC+b5XCSMAHUMgQC2eSQ7wd3CR4xil36b/ggtIvdQqLLBqTyKFH6WQ5D2VVtJCn7+bwYA3vuwvoVIfiB7+KmlXKXnmI8JzhM8BX6Sg743AL+iaqR1wIWjBZRBhBVNphXFdyaqnvdP6LIgoANaWZqEjclbgvJ3fTh4rpa1AZBeYtBJhHV23ZmLSahOud2ZaGVzamegtGX1KcfkxsnyivnsbQhhgmk75FvH/CM5t5NRBAe4kpdxAv5BgJFCaREtb1C8511C2EsDn4lpdTA== 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=HX+78oboAqijPyisEgUwqIq/TYlX7feqlR5EM8+egCo=; b=KI5fOPDere6zIQ26jmCSO+FEb2O9s3BEwALlgviwszaUzxn0HYjlQr9GFemZULmXcQ4YlQQ91tJoLapwa8hJ0Un/MneaGurg0XvKYd5G4X5H79mQyXc60aZAtBMGIUz9p6sT/kHtQHg1HYAzM38AK7EWD+oUiQ/fd8eLlCb+sGsbkAbn/Cb/HNGZwXXtungzPnNW9laolj9NI4KFCphFM+bzDunUqV95pDKpMZ3oWMGNCmwvih+VrRnYbzexJ3Aa9U0oKILL/POc/iJlPkHKV4Ab9EtoFjhI9vGSqNoH8jzONMil6vkybRhzVTHNPF5gAgrg+9jkKng7wIn77M7IEw== 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=HX+78oboAqijPyisEgUwqIq/TYlX7feqlR5EM8+egCo=; b=ery813X8hpJnITR/E/b6pYsK+swaU04YcmVJfrfQ+unKY0wldg2E+tb1CKXhbTtWlSuIcAvJUEsOtfuqVP9+YOnK1zhEIMMjjP0dmKOmf/A5RRCH1FwAr41JJ038+O5dTOrGcOz1iM1KmbmTTN+bvrtHXtHRmca+A/aDpccvnVE= 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 VI1PR08MB3136.eurprd08.prod.outlook.com (52.133.14.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.22; Wed, 18 Mar 2020 22:51:39 +0000 Received: from VI1PR08MB2765.eurprd08.prod.outlook.com ([fe80::8413:fc03:8c5a:5ed6]) by VI1PR08MB2765.eurprd08.prod.outlook.com ([fe80::8413:fc03:8c5a:5ed6%3]) with mapi id 15.20.2814.021; Wed, 18 Mar 2020 22:51:39 +0000 From: Andrea Corallo To: gcc-patches@gcc.gnu.org Cc: "jit@gcc.gnu.org" , "dmalcolm@redhat.com" , nd Subject: Re: [PATCH V3][gcc] libgccjit: introduce version entry points References: Date: Wed, 18 Mar 2020 23:51:36 +0100 In-Reply-To: (Andrea Corallo's message of "Thu, 16 Jan 2020 11:11:31 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Content-Type: multipart/mixed; boundary="=-=-=" X-ClientProxiedBy: LO2P265CA0162.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::30) 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 LO2P265CA0162.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Wed, 18 Mar 2020 22:51:38 +0000 X-Originating-IP: [217.140.99.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 82a2e8dc-8647-4060-5792-08d7cb8ef06d X-MS-TrafficTypeDiagnostic: VI1PR08MB3136:|DB6PR0801MB2054: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-Forefront-PRVS: 03468CBA43 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(366004)(376002)(39860400002)(136003)(346002)(199004)(86362001)(5660300002)(235185007)(66616009)(2906002)(66476007)(478600001)(16526019)(186003)(316002)(26005)(54906003)(81166006)(66556008)(8676002)(36756003)(52116002)(44832011)(956004)(6916009)(6496006)(81156014)(8936002)(6486002)(2616005)(4326008)(66946007); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3136; H:VI1PR08MB2765.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; 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: jfqyjr0Ql22lDu3w5e+cqEzGJHd6d5l5pfN2ycd6D1TmbXea24NlGCLQ+g3oesZ1ZfwjJanRMugmxp+fEDxPNLUog+KzxydQbrHTnZcfwXzoulqKm3Du1KF8tsKvNCCxjph3zWBw/WXuqI7v1MZxPMB8hvQIglfGOqsLxA2u9yWE4h7DKbeKWYessF7VwO1X0pRLp4YuhRHB+qUoXyE7p4R87Y2WUGVUzzLgWmwrdC8eF4FhXDzMAHea1k3Sf+iHBEmz+jukqFcvMkIBd711GKpk5ywrZms/CMnfFevHwUy2zdanHO+U+LV7wV2wEYizUujx0jcLQy+pqIALVsGch1t7v99DmLMZCMS+GbybobnQdp0QgLZTBVNEmuJPhzX96GwaLCe/MZJqYkQAAOeuzA203+UgXH0FogMPX95hRueJvnoeBz90ow6xZUDHeVba X-MS-Exchange-AntiSpam-MessageData: jS/ua3F2ZgyLSa8w64nXmkF0j7uYrsb86ov8baNtLoNp36JxVLnvUZCF+7Gn3YMkt1Bbfeqj3tE01FkmJ7Z+nNN94/wjEMCt2qNg3nL7w70hhz0BDecPH2Kv1jfbJPObFTCildVJhRwLdhxrsjguEQ== X-MS-Exchange-Transport-Forked: True X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3136 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(376002)(136003)(396003)(346002)(199004)(46966005)(5660300002)(6486002)(70206006)(8676002)(81156014)(6496006)(6916009)(956004)(336012)(2616005)(47076004)(186003)(16526019)(26005)(356004)(44832011)(235185007)(8936002)(450100002)(70586007)(36756003)(81166006)(2906002)(66616009)(86362001)(478600001)(316002)(36906005)(26826003)(4326008)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0801MB2054; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Pass; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 585a8058-b539-416b-5392-08d7cb8eeb18 X-Forefront-PRVS: 03468CBA43 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lExzC9TFqwaOc7ttyNvDgRrsCqYd+NUz3Tlm7VZf54bvol1gfTWVl/9R2Nl6XBUjOEItE7HzAIFbBqhfAq+Rtl2LMG2VP97YnIRHoaa+BG9qI1sagzG6EYztDlQiDQNbMZM7ajSYc/resaeWFEE5pX2QJc80YBb0ENKK2LqTV7ugkXFoJVJRpFhGRSuLcWuBABeSIViozrFOjzP/tkHz0E/gdshOQjZI6rGfiv03cHyOd4kVT+k8KVwjwHLd17fxrvEpepPHu5mLQ/vsfU+ovos/5oCrWkXS3fRqz+jewPKOx5Wd4WdYtgf4Ssv4GtafYVIvlMqY4VVM65yOCWHUBJirHg6MzH0PKfMBpyHAjil2x3nbMK4dxUjBN5Vsg1xtwVLf1K2+025dQQZAgw9e7PvapYfXEfvx3/rpfUtAv4PUqGioac0MginlfItIgaICe+qAsVpiPsVnDDkFvHFNfTGiV5dXe0idSFsIXYogihw67ngbvPlqQu1e5erLkVBkagaaBcECpN3YxmYYoVSkEg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2020 22:51:47.4215 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82a2e8dc-8647-4060-5792-08d7cb8ef06d 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: DB6PR0801MB2054 X-Spam-Status: No, score=-25.0 required=5.0 tests=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, 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: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Mar 2020 22:51:52 -0000 --=-=-= Content-Type: text/plain Hi all, Updated version of the patch mainly addressing comments on the concurrency issues. I came to the conclusions that the caching should be done in the function that we decide to be thread safe. However I haven't touched parse_basever in any direction in the hope of having this still in stage4. As result I've mostly applied the mutex solution. 'make check-jit' runs clean 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 ad86baf8472c6684aed9b62652922a83e147952a 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 | 7 +++ gcc/testsuite/jit.dg/test-version.c | 26 +++++++++++ 7 files changed, 158 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..cba4ac51cc9 100644 --- a/gcc/testsuite/jit.dg/all-non-failing-tests.h +++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h @@ -8,6 +8,13 @@ hooks provided by each test case. */ #define COMBINED_TEST +/* 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-accessing-bitfield.c */ #define create_code create_code_accessing_bitfield #define verify_code verify_code_accessing_bitfield 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 --=-=-=--