From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH] replaced O(n^2) sort in sort_by_physaddr() with qsort() from standard library Date: Wed, 17 Dec 2014 15:27:23 +0100 Message-ID: <1667884.VTnHUhe7ya@xps13> References: <1418823077-9129-1-git-send-email-rolette@infiniteio.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev-VfR2kkLFssw@public.gmane.org To: Jay Rolette Return-path: In-Reply-To: <1418823077-9129-1-git-send-email-rolette-bIuJOMs36aleGPcbtGPokg@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" Hi Jay, Please read http://dpdk.org/dev#send for submission guidelines. A description of why you do it would be welcome in the commit log. > +static int > +cmp_physaddr(const void *a, const void *b) > +{ > +#ifndef RTE_ARCH_PPC_64 > + const struct hugepage_file *p1 = (const struct hugepage_file *)a; > + const struct hugepage_file *p2 = (const struct hugepage_file *)b; > +#else > + // PowerPC needs memory sorted in reverse order from x86 Comments shall be C-style (/* */). > + const struct hugepage_file *p1 = (const struct hugepage_file *)b; > + const struct hugepage_file *p2 = (const struct hugepage_file *)a; > +#endif > + if (p1->physaddr < p2->physaddr) > + return -1; > + else if (p1->physaddr > p2->physaddr) > + return 1; > + else > + return 0; > +} One of the goal of EAL is to avoid #ifdef. So that function would probably be better located in lib/librte_eal/common/include/arch/* with different implemenations depending of the architecture. -- Thomas