From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id E4215B0A4 for ; Wed, 16 Apr 2014 13:52:49 +0200 (CEST) Received: by mail-wg0-f45.google.com with SMTP id l18so10690099wgh.28 for ; Wed, 16 Apr 2014 04:52:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=8f6f7dkc3ofyF/FaMtgUyOkp3A/2I768P2hM0w65E6g=; b=HTt2wmjGP2e6xSlqhV5TSRNK+QT9QIW1+47B4cUkbO6xQotE8IvxqjlSZbHUtcBiJG pak3/Lq1J+JiyBl/+syLKGVWw+7BYU4VOQRDnJWkwxzusavVcZ/6/Ed2v3UEEjvObp43 SIaB7jkElVEFmDk064qyKKUsPyZTkFkMfLKeS6P92frZHXtumusVGZs7dMc+1eMjj05J /8roUj/1URO3V5MXCsKn2S13E5gz1KCFzx7MhFgASaMwQYucnUUEnJ1tNA6EPv2eKhLA Jm/C1VSrrOKKULiR3q7VJCpBxRJp1TRrmEMbF5vqhAf4gu3H3NjnveZXVq4iqk2gOpf9 Bcuw== X-Gm-Message-State: ALoCoQncE0dcVZUc3WXyeEZS2tGIACUySQuRiZb8MF9RATzKKngNp4OZ0YZLCBN3yLicETUWikCv X-Received: by 10.194.94.39 with SMTP id cz7mr1246379wjb.78.1397649170029; Wed, 16 Apr 2014 04:52:50 -0700 (PDT) Received: from xps13.localnet (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id f7sm13578881wjy.24.2014.04.16.04.52.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Apr 2014 04:52:49 -0700 (PDT) From: Thomas Monjalon To: Neil Horman Date: Wed, 16 Apr 2014 13:52:49 +0200 Message-ID: <1462763.GWB5SR3fGh@xps13> Organization: 6WIND User-Agent: KMail/4.12.4 (Linux/3.14.1-1-ARCH; KDE/4.12.4; x86_64; ; ) In-Reply-To: <1397585169-14537-4-git-send-email-nhorman@tuxdriver.com> References: <1397585169-14537-1-git-send-email-nhorman@tuxdriver.com> <1397585169-14537-4-git-send-email-nhorman@tuxdriver.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 03/15] pmd: Add PMD_REGISTER_DRIVER macro 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: Wed, 16 Apr 2014 11:52:50 -0000 2014-04-15 14:05, Neil Horman: > Rather than have each driver have to remember to add a constructor to it to > make sure its gets registered properly, wrap that process up in a macro to > make registration a one line affair. This also sets the stage for us to > make registration of vdev pmds and physical pmds a uniform process > > Signed-off-by: Neil Horman Could you explain why having a macro is better than an explicit constructor function? > +enum rte_pmd_driver_type { > + PMD_VDEV = 1 > +}; > + > +extern void rte_eal_nonpci_dev_init_register(const char *name, int > (*dev_initfn)(const char *, const char *)); +#define PMD_REGISTER_DRIVER(d, > t)\ > +void devinitfn_ ##d(void);\ > +void __attribute__((constructor, used)) devinitfn_ ##d(void)\ > +{\ > + enum rte_pmd_driver_type _t = (t);\ > + switch(_t)\ > + {\ > + case PMD_VDEV:\ > + rte_eal_vdev_driver_register(&d);\ > + break;\ > + };\ Are you sure this switch is needed? You are removing it in patch 7. If someone else think this macro is a good idea, or not, speak now :) -- Thomas