From: "Chanho Min" <chanho.min@lge.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "'Geert Uytterhoeven'" <geert@linux-m68k.org>,
"'Bob Pearson'" <rpearson@systemfabricworks.com>,
"'Richard Weinberger'" <richard@nod.at>,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
"'Yann Collet'" <yann.collet.73@gmail.com>,
이경식 <kyungsik.lee@lge.com>,
'Linux/m68k' <linux-m68k@vger.kernel.org>,
'sparclinux' <sparclinux@vger.kernel.org>,
'Linux-Next' <linux-next@vger.kernel.org>
Subject: Re: [PATCH 1/2] lib: Add lz4 compressor module
Date: Fri, 26 Apr 2013 14:02:01 +0900 [thread overview]
Message-ID: <OF6B440C9E.4A0516C8-ON49257B59.001BA689-49257B59.001BA68A@lge.com> (raw)
In-Reply-To: <5175014e.487a420a.4c58.ffffe0b9SMTPIN_ADDED_BROKEN@mx.google.com>
>> gcc seems to define __builtin_clz as __clzsi2 in some architecture.
>> But, kernel doesn't link libgcc.a.
>> If kernel should use gcc's built-in function without libgcc.a,
>> do we need to port __clzsi2 to 'arch/*/lib/*'?
>
>This breaks alpha (gcc-4.4.4) as well. Can we please get this fixed
>promptly?
__clzsi2 can be implemented by using generic functions.
It can be overridden by linking arch-specific versions may not be implemented.
does this way look acceptable?
diff --git a/lib/Makefile b/lib/Makefile
index af79e8c..e17b3ee 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -23,7 +23,7 @@ lib-y += kobject.o klist.o
obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \
- gcd.o lcm.o list_sort.o uuid.o flex_array.o \
+ gcd.o lcm.o list_sort.o uuid.o flex_array.o clz.o\
bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o
obj-y += string_helpers.o
obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
diff --git a/lib/clz.c b/lib/clz.c
index e69de29..6794b83 100644
--- a/lib/clz.c
+++ b/lib/clz.c
@@ -0,0 +1,23 @@
+#include <linux/kernel.h>
+
+int __attribute__((weak)) __clzsi2(int val)
+{
+ return BITS_PER_LONG - fls(val);
+}
+EXPORT_SYMBOL(__clzsi2);
+
+#if BITS_PER_LONG == 32
+int __attribute__((weak)) __clzdi2(long val)
+{
+ return BITS_PER_LONG - fls((int)val);
+}
+EXPORT_SYMBOL(__clzdi2);
+#elif BITS_PER_LONG == 64
+int __attribute__((weak)) __clzdi2(long val)
+{
+ return BITS_PER_LONG - fls64((u64)val);
+}
+EXPORT_SYMBOL(__clzdi2);
+#else
+#error BITS_PER_LONG not 32 or 64
+#endif
next prev parent reply other threads:[~2013-04-26 5:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAOAMb1D8rokZpQpp6mEJw6KXcQq8fJUWBJoC5+ZfkNaE6WvAZA@mail.gmail.com>
2013-04-18 9:50 ` [PATCH 1/2] lib: Add lz4 compressor module Geert Uytterhoeven
[not found] ` <51750159.07d70e0a.5461.ffffec64SMTPIN_ADDED_BROKEN@mx.google.com>
2013-04-22 9:24 ` Geert Uytterhoeven
2013-04-22 21:29 ` Andrew Morton
[not found] ` <5175014e.487a420a.4c58.ffffe0b9SMTPIN_ADDED_BROKEN@mx.google.com>
2013-04-25 22:42 ` Andrew Morton
2013-04-26 5:02 ` Chanho Min [this message]
2013-04-26 5:51 ` Stephen Rothwell
2013-04-26 19:46 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=OF6B440C9E.4A0516C8-ON49257B59.001BA689-49257B59.001BA68A@lge.com \
--to=chanho.min@lge.com \
--cc=akpm@linux-foundation.org \
--cc=geert@linux-m68k.org \
--cc=kyungsik.lee@lge.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=richard@nod.at \
--cc=rpearson@systemfabricworks.com \
--cc=sparclinux@vger.kernel.org \
--cc=yann.collet.73@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).