diff mbox

[1/2] lib: Add lz4 compressor module

Message ID OF6B440C9E.4A0516C8-ON49257B59.001BA689-49257B59.001BA68A@lge.com
State Not Applicable
Delegated to: David Miller
Headers show

Commit Message

Chanho Min April 26, 2013, 5:02 a.m. UTC
>> 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?


--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Stephen Rothwell April 26, 2013, 5:51 a.m. UTC | #1
Hi,

On Fri, 26 Apr 2013 14:02:01 +0900 "Chanho Min" <chanho.min@lge.com> wrote:
>
> 
> @@ -0,0 +1,23 @@
> +#include <linux/kernel.h>
> +
> +int __attribute__((weak)) __clzsi2(int val)

We have __weak in <linux/compiler.h>
Andrew Morton April 26, 2013, 7:46 p.m. UTC | #2
On Fri, 26 Apr 2013 15:51:05 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:

> Hi,
> 
> On Fri, 26 Apr 2013 14:02:01 +0900 "Chanho Min" <chanho.min@lge.com> wrote:
> >
> > 
> > @@ -0,0 +1,23 @@
> > +#include <linux/kernel.h>
> > +
> > +int __attribute__((weak)) __clzsi2(int val)
> 
> We have __weak in <linux/compiler.h>

And lib/clz.c needs a few more includes, for EXPORT_SYMBOL,
BITS_PER_LONG maybe.

Plus a changelog and a signed-off-by, please.

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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