From mboxrd@z Thu Jan 1 00:00:00 1970 From: "=?EUC-KR?B?uc7C+cij?=" Subject: Re: [PATCH] lib: add weak __clzsi2()/__clzdi2() functions Date: Thu, 2 May 2013 09:58:02 +0900 Message-ID: References: <1367214005-14302-1-git-send-email-chanho.min@lge.com> <20130430144605.1a99a7397702b332ee818fc8@linux-foundation.org> Reply-To: "=?EUC-KR?B?uc7C+cij?=" Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <20130430144605.1a99a7397702b332ee818fc8@linux-foundation.org> Sender: linux-m68k-owner@vger.kernel.org To: Geert Uytterhoeven Cc: Andrew Morton , =?EUC-KR?B?wMyw5r3E?= , Yann Collet , Bob Pearson , Richard Weinberger , linux-kernel@vger.kernel.org, sparclinux , Linux/m68k , Linux-Next List-Id: linux-next.vger.kernel.org >No, the link errors are for __ctzdi2, not __clzdi2. >__ctzdi2 can be implemented using __ffs(). >> How's about we stop using __builtin_ctz[ll]() altogether? Use N-fls()? > >That was my first suggestion ;-) > Do we remove existing __builtin_ct[l]z? Some architecture's __builtin_clz will be more optimized than N-fls IMHO, This is not only about __builtin- but also supporting another libgcc functions in kernel. Some future user may need __clz[t]s[d]i2 symbol also. >> btw, this: >> >> int __weak __clzsi2(int val) >> { >> return BITS_PER_LONG - fls(val); >> } >> >> looks wrong. It will give a different result for 32- and 64-bit. > >Indeed. It should be hardcoded 32. > I will re-work this for 64-bit, and ctz also. Thanks Chanho Min