From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6A806A09E4; Thu, 28 Jan 2021 12:01:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B4964067C; Thu, 28 Jan 2021 12:01:03 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id F29244067A for ; Thu, 28 Jan 2021 12:01:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611831660; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ED1gnfzSEiWqVHLeCbxzZjA0Gnef0WgiV+L9PezEI7M=; b=MCtIpK4cTLwjMwB8Rb0LKarqdmhepOSPLiLL0KY3ExiHXv8WHp8rL9wE/y1G5GOHV1yRM0 4Hg4ROGpNBPGJnNgdM6jZRu4MVWPQuX5c7B+hqgDohxoD7PYjkLnTsfyIdGQq7jrfzMIgD COnH7Sfqupr+Nw+Fj6kXC1zIt+v+KPU= Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-4QRn5snMOdemDE2wgO5eKQ-1; Thu, 28 Jan 2021 06:00:58 -0500 X-MC-Unique: 4QRn5snMOdemDE2wgO5eKQ-1 Received: by mail-ua1-f71.google.com with SMTP id o24so1378941uap.15 for ; Thu, 28 Jan 2021 03:00:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ED1gnfzSEiWqVHLeCbxzZjA0Gnef0WgiV+L9PezEI7M=; b=uPtGhPHhyPjU1hiu17gtl3rtrtu9ZpeWchz6xGTYoEQy0Iw1Sk1/jJSg5FXFJw69Y8 h4/bSZSIboeUvD2IuIguPU0R6EObtwKB2ScXc93tlWEIZk8QeP4rBUEiSg31TJ2x6AoX hQ4sLV+mNVzbNLpHQIFq9IxWsRVnHqe3yZ7QOZJtcqRxz0MQyTBRWtmEwGdTQXaCVTIq RdRMOjcj5r0DoJwI6gyKo9NdsS5ucyaf9fHgFak7thSDB6PgDChJ8iFtlZdOn2nbszQz AR/17PTEGW3mXLGT4udQHdVFAtfrudn1vV6PPPuEBPtWThpnOwfJFSMOMKn9XWz02yYR B70w== X-Gm-Message-State: AOAM532AH/ZwX3dCtyV8UfVauuk72Z+nu56AgaaRStdOXfic7+bzuFVm xAVKHpEP/7cwdkzpOlRKs4vHkKe3qZqhMTNsP0q8RtiaCWRxJxp9GtVGGHaK//NrHbv3QwSrgWb eSuJEscHOH140HJqRrk4= X-Received: by 2002:ac5:cf1e:: with SMTP id y30mr6106942vke.18.1611831658009; Thu, 28 Jan 2021 03:00:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGftnq25ohLSBA433fpWcl/6KEpx0ms+9ORKkrCak5/G/E8WdQC/NH7LN1gjiFmxAX/FrFbOuQ0ypMMQM16Es= X-Received: by 2002:ac5:cf1e:: with SMTP id y30mr6106935vke.18.1611831657803; Thu, 28 Jan 2021 03:00:57 -0800 (PST) MIME-Version: 1.0 References: <20210114110606.21142-1-bruce.richardson@intel.com> <20210127173330.1671341-1-bruce.richardson@intel.com> <20210127173330.1671341-3-bruce.richardson@intel.com> In-Reply-To: <20210127173330.1671341-3-bruce.richardson@intel.com> From: David Marchand Date: Thu, 28 Jan 2021 12:00:46 +0100 Message-ID: To: Bruce Richardson Cc: dev , "Wang, Haiyue" , Ray Kinsella , Neil Horman Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH v6 2/8] eal: fix error attribute use for clang X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Jan 27, 2021 at 6:33 PM Bruce Richardson wrote: > > Clang does not have an "error" attribute for functions, so for marking > internal functions we need to check for the error attribute, and provide > a fallback if it is not present. For clang, we can use "diagnose_if" > attribute, similarly checking for its presence before use. > > Fixes: fba5af82adc8 ("eal: add internal ABI tag definition") > Cc: haiyue.wang@intel.com Cc: stable@dpdk.org > > Signed-off-by: Bruce Richardson > --- > lib/librte_eal/include/rte_compat.h | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/include/rte_compat.h b/lib/librte_eal/include/rte_compat.h > index 4cd8f68d68..c30f072aa3 100644 > --- a/lib/librte_eal/include/rte_compat.h > +++ b/lib/librte_eal/include/rte_compat.h > @@ -19,12 +19,18 @@ __attribute__((section(".text.experimental"))) > > #endif > > -#ifndef ALLOW_INTERNAL_API > +#if !defined ALLOW_INTERNAL_API && __has_attribute(error) /* For GCC */ > > #define __rte_internal \ > __attribute__((error("Symbol is not public ABI"), \ > section(".text.internal"))) > > +#elif !defined ALLOW_INTERNAL_API && __has_attribute(diagnose_if) /* For clang */ > + > +#define __rte_internal \ > +__attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \ > +section(".text.internal"))) > + If the compiler has neither error or diagnose_if support, an internal API can be called without ALLOW_INTERNAL_API. I prefer a build error complaining on an unknown attribute rather than silence a check. I.e. #ifndef ALLOW_INTERNAL_API #if __has_attribute(diagnose_if) /* For clang */ #define __rte_internal \ __attribute__((diagnose_if(1, "Symbol is not public ABI", "error"), \ section(".text.internal"))) #else #define __rte_internal \ __attribute__((error("Symbol is not public ABI"), \ section(".text.internal"))) #endif #else /* ALLOW_INTERNAL_API */ #define __rte_internal \ section(".text.internal"))) #endif -- David Marchand