From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [PATCH v3 26/31] arm64: Miscellaneous library functions Date: Fri, 7 Sep 2012 19:52:13 +0000 Message-ID: <201209071952.14309.arnd@arndb.de> References: <1347035226-18649-1-git-send-email-catalin.marinas@arm.com> <1347035226-18649-27-git-send-email-catalin.marinas@arm.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Return-path: Received: from moutng.kundenserver.de ([212.227.17.10]:61449 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752342Ab2IGTwR (ORCPT ); Fri, 7 Sep 2012 15:52:17 -0400 In-Reply-To: <1347035226-18649-27-git-send-email-catalin.marinas@arm.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Catalin Marinas Cc: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org On Friday 07 September 2012, Catalin Marinas wrote: > +/* > + * Use compiler builtins for simple inline operations. > + */ > +static inline unsigned long __ffs(unsigned long word) > +{ > + return __builtin_ffsl(word) - 1; > +} > + > +static inline int ffs(int x) > +{ > + return __builtin_ffs(x); > +} > + > +static inline unsigned long __fls(unsigned long word) > +{ > + return BITS_PER_LONG - 1 - __builtin_clzl(word); > +} > + > +static inline int fls(int x) > +{ > + return x ? sizeof(x) * BITS_PER_BYTE - __builtin_clz(x) : 0; > +} Still waiting for the generic version of these. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 From: arnd@arndb.de (Arnd Bergmann) Date: Fri, 7 Sep 2012 19:52:13 +0000 Subject: [PATCH v3 26/31] arm64: Miscellaneous library functions In-Reply-To: <1347035226-18649-27-git-send-email-catalin.marinas@arm.com> References: <1347035226-18649-1-git-send-email-catalin.marinas@arm.com> <1347035226-18649-27-git-send-email-catalin.marinas@arm.com> Message-ID: <201209071952.14309.arnd@arndb.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Friday 07 September 2012, Catalin Marinas wrote: > +/* > + * Use compiler builtins for simple inline operations. > + */ > +static inline unsigned long __ffs(unsigned long word) > +{ > + return __builtin_ffsl(word) - 1; > +} > + > +static inline int ffs(int x) > +{ > + return __builtin_ffs(x); > +} > + > +static inline unsigned long __fls(unsigned long word) > +{ > + return BITS_PER_LONG - 1 - __builtin_clzl(word); > +} > + > +static inline int fls(int x) > +{ > + return x ? sizeof(x) * BITS_PER_BYTE - __builtin_clz(x) : 0; > +} Still waiting for the generic version of these. Arnd