From patchwork Mon Aug 6 22:21:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 954256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-483273-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="lWZq3v/E"; dkim-atps=neutral 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 41ksZH2JdHz9s3x for ; Tue, 7 Aug 2018 08:21:41 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=bAJlpnzev9cZ6keeb6UTS27DsUuirejg/u7pQIBYPTfY3tkJ0m wofCacK78+v24gL09vG8rkZkFAo1h5YD9SKoo3SUfLvnscTIayXqrG1wSdFvGBqg iz4RIUXngAZGiR1bZR+ITr18YWpyanbhkkiwV/vue6e18d88d8ECo6jUo= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=bRCMav8Rk5+9b9ywOFfneLdwjEA=; b=lWZq3v/E500tnT/PDZbA LfB6uesTtS0ZL1KJjpn4+eqEA0sjh7h8rQBIMT6pyds33xQoHvlFOSoIpfSEVIh2 EDPR1wzcAGoPClcIMyYzBW9TeWJGnuMTsIGPZnkhzFUQBt+n3hXma+tciRAC8CBk Y5mHYUzmneU9UJnJfknqWEA= Received: (qmail 31408 invoked by alias); 6 Aug 2018 22:21:35 -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 31373 invoked by uid 89); 6 Aug 2018 22:21:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=Put, accelerator X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 06 Aug 2018 22:21:32 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BDD47AD49; Mon, 6 Aug 2018 22:21:30 +0000 (UTC) Date: Tue, 7 Aug 2018 00:21:31 +0200 From: Tom de Vries To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek Subject: [committed][libgomp, nvptx] Minimize lifetime of CUDA_ONE_CALL defines Message-ID: <20180806222131.5sr6453kwbbs46lu@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170912 (1.9.0) X-IsSubscribed: yes Hi, This patch makes sure that the lifetimes of the CUDA_ONE_CALL macro (which is defined twice in plugin-nvptx.c) are minimized, to make it obvious that the definitions are used only in the lib-cuda.def include. Build on x86_64 with nvptx accelerator and reg-tested libgomp. Committed to trunk. Thanks, - Tom [libgomp, nvptx] Minimize lifetime of CUDA_ONE_CALL defines 2018-08-06 Tom de Vries * plugin/plugin-nvptx.c (struct cuda_lib_s, init_cuda_lib): Put CUDA_ONE_CALL defines right before the cuda-lib.def include, and the corresponding undefs right after. --- libgomp/plugin/plugin-nvptx.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index cc465b4addb2..2e72a6379eb9 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -52,10 +52,13 @@ #if PLUGIN_NVPTX_DYNAMIC # include -# define CUDA_ONE_CALL(call) \ - __typeof (call) *call; struct cuda_lib_s { + +# define CUDA_ONE_CALL(call) \ + __typeof (call) *call; #include "cuda-lib.def" +# undef CUDA_ONE_CALL + } cuda_lib; /* -1 if init_cuda_lib has not been called yet, false @@ -74,18 +77,19 @@ init_cuda_lib (void) cuda_lib_inited = false; if (h == NULL) return false; -# undef CUDA_ONE_CALL + # define CUDA_ONE_CALL(call) CUDA_ONE_CALL_1 (call) # define CUDA_ONE_CALL_1(call) \ cuda_lib.call = dlsym (h, #call); \ if (cuda_lib.call == NULL) \ return false; #include "cuda-lib.def" +# undef CUDA_ONE_CALL +# undef CUDA_ONE_CALL_1 + cuda_lib_inited = true; return true; } -# undef CUDA_ONE_CALL -# undef CUDA_ONE_CALL_1 # define CUDA_CALL_PREFIX cuda_lib. #else # define CUDA_CALL_PREFIX