From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id 10DDE2B91 for ; Thu, 2 Jun 2016 09:10:39 +0200 (CEST) Received: by mail-wm0-f50.google.com with SMTP id a20so54831914wma.1 for ; Thu, 02 Jun 2016 00:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=i4Tfz/bznb5UU0Swr6pQ5sSuAabYBNG+3+CXczZCyiQ=; b=sS0g2lTM6UI+jRVqZ92YFE1Jy47nsRwhGDM6C0PUgVeIEdRagCrIDVT47OVWQCi0dg Z6vSNeOdRLBdMOiQGnwWhnpvMnS1I8orf3Wao3Bq3dLBMj+4kA8RifaSDCgAyfZl/E8+ CSqZ+cAxPF5U58JTPvuSPjr0xMbeRMytRGFmiESSIYMtCviMrVeUrDYiShfszkX5QPVt W3/5NP8ydYjUmSoz+odwGFj/sDfFUmpc2oY/tVqxXRWu+D6RF0qkK763B48mhL0okBuo FfTxBDlgYanp3SQ7VIPKPAQ3IeycPaIEilEGlfG+sbMeOyTuxxziGq//ASDbMtV8/zzq xWsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=i4Tfz/bznb5UU0Swr6pQ5sSuAabYBNG+3+CXczZCyiQ=; b=Pl0cGwgpN1x/OfXgDhEHJsbt0ynmBFDLwBNV0qWfyId9QH0GyfbbwniE+h6sEmzgBR pa6gVQfXRbIt3ztpGVb5WVnsOjTu07xe0KGviUSY26qRyIUcat+L1ZM1wfxlGpdkgCkL Zy7ua1xbcM39rXmI+GsSH0/JM1C7d1Q2wjYthwTw2e6V1fGQq09JtoiFl7ANRd46zXYN 8b/WLK8o678gFstPE205LY75uOwpN0vhgwUWfOhSXhGBWQ+nQvsFZgoPQDDIlzMdq4HG 1cj20SmcHBROfhrsPVwtMi1ILQzoq5w8fTviyK4wWhmjciChMN+xxRZ3O/n8ivMwFTem KrMw== X-Gm-Message-State: ALyK8tLL6WgJGF/D+EMV5MWkOgvwecoJcQnUcqD9NpHqApgNGunV5JGzZ3TWvZ/fzTZZ5fDn X-Received: by 10.28.102.196 with SMTP id a187mr6736944wmc.99.1464851438866; Thu, 02 Jun 2016 00:10:38 -0700 (PDT) Received: from [137.194.56.56] (eduroam-0-56.enst.fr. [137.194.56.56]) by smtp.gmail.com with ESMTPSA id i1sm49546429wjm.12.2016.06.02.00.10.37 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Jun 2016 00:10:38 -0700 (PDT) To: Jianbo Liu References: <1464663966-8122-1-git-send-email-jianbo.liu@linaro.org> <574DE5D6.2040001@6wind.com> Cc: Jerin Jacob , dev@dpdk.org From: Olivier MATZ Message-ID: <574FDBED.8050003@6wind.com> Date: Thu, 2 Jun 2016 09:10:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] mbuf: extend rte_mbuf_prefetch_part* to support more prefetching methods X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jun 2016 07:10:39 -0000 Hi Jianbo, On 06/01/2016 05:29 AM, Jianbo Liu wrote: >> enum rte_mbuf_prefetch_type { >> > PREFETCH0, >> > PREFETCH1, >> > ... >> > }; >> > >> > static inline void >> > rte_mbuf_prefetch_part1(enum rte_mbuf_prefetch_type type, >> > struct rte_mbuf *m) >> > { >> > switch (type) { >> > case PREFETCH0: >> > rte_prefetch0(&m->cacheline0); >> > break; >> > case PREFETCH1: >> > rte_prefetch1(&m->cacheline0); >> > break; >> > ... >> > } >> > > How about adding these to forbid the illegal use of this macro? > enum rte_mbuf_prefetch_type { > ENUM_prefetch0, > ENUM_prefetch1, > ... > }; > > #define RTE_MBUF_PREFETCH_PART1(type, m) \ > if (ENUM_##type == ENUM_prefretch0) \ > rte_prefetch0(&(m)->cacheline0); \ > else if (ENUM_##type == ENUM_prefetch1) \ > rte_prefetch1(&(m)->cacheline0); \ > .... > As Stephen stated, a static inline is better than a macro, mainly because it is understood by the compiler instead of beeing a dumb code replacement. Any reason why you would prefer a macro in that case? Regards Olivier