Message ID | CAMuHMdXXoaQjb9sRK=X3gEDwqQBJcJQtaJbUGB8cJmteHSN3vQ@mail.gmail.com |
---|---|
State | Not Applicable |
Delegated to: | David Miller |
Headers | show |
On Mon, Apr 22, 2013 at 11:22 AM, Chanho Min <chanho.min@lge.com> wrote: >>> +#define HTYPE const u8* >>> + >>> +#ifdef __BIG_ENDIAN >>> +#define LZ4_NBCOMMONBYTES(val) (__builtin_clz(val) >> 3) >>> +#else >>> +#define LZ4_NBCOMMONBYTES(val) (__builtin_ctz(val) >> 3) >>> +#endif >> >>It seems at least m68k and sparc don't have the __builtin_clz() functions: >> >>m68k-allmodconfig (http://kisskb.ellerman.id.au/kisskb/buildresult/8572593/): >> >>ERROR: "__clzsi2" [lib/lz4/lz4hc_compress.ko] undefined! >>ERROR: "__clzsi2" [lib/lz4/lz4_compress.ko] undefined! > > 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/*'? That's another option. So far no one used __builtin_c[lt]z in generic code. We always used __fls and __ffs. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- 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
On Mon, 22 Apr 2013 11:24:21 +0200 Geert Uytterhoeven <geert@linux-m68k.org> wrote: > On Mon, Apr 22, 2013 at 11:22 AM, Chanho Min <chanho.min@lge.com> wrote: > >>> +#define HTYPE const u8* > >>> + > >>> +#ifdef __BIG_ENDIAN > >>> +#define LZ4_NBCOMMONBYTES(val) (__builtin_clz(val) >> 3) > >>> +#else > >>> +#define LZ4_NBCOMMONBYTES(val) (__builtin_ctz(val) >> 3) > >>> +#endif > >> > >>It seems at least m68k and sparc don't have the __builtin_clz() functions: > >> > >>m68k-allmodconfig (http://kisskb.ellerman.id.au/kisskb/buildresult/8572593/): > >> > >>ERROR: "__clzsi2" [lib/lz4/lz4hc_compress.ko] undefined! > >>ERROR: "__clzsi2" [lib/lz4/lz4_compress.ko] undefined! > > > > 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/*'? > > That's another option. Without having seen the patch .... Yes, if we fix it this way then we also fix it for future callers of __builtin_clz(). -- 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
On Mon, 22 Apr 2013 18:22:18 +0900 "Chanho Min" <chanho.min@lge.com> wrote: > >> +#define HTYPE const u8* > >> + > >> +#ifdef __BIG_ENDIAN > >> +#define LZ4_NBCOMMONBYTES(val) (__builtin_clz(val) >> 3) > >> +#else > >> +#define LZ4_NBCOMMONBYTES(val) (__builtin_ctz(val) >> 3) > >> +#endif > > > >It seems at least m68k and sparc don't have the __builtin_clz() functions: > > > >m68k-allmodconfig (http://kisskb.ellerman.id.au/kisskb/buildresult/8572593/): > > > >ERROR: "__clzsi2" [lib/lz4/lz4hc_compress.ko] undefined! > >ERROR: "__clzsi2" [lib/lz4/lz4_compress.ko] undefined! > > 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? -- 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 --git a/lib/lz4/lz4defs.h b/lib/lz4/lz4defs.h index abcecdc..81d3251 100644 --- a/lib/lz4/lz4defs.h +++ b/lib/lz4/lz4defs.h @@ -107,12 +107,6 @@ typedef struct _U64_S { u64 v; } U64_S; } while (0) #define HTYPE u32 -#ifdef __BIG_ENDIAN -#define LZ4_NBCOMMONBYTES(val) (__builtin_clzll(val) >> 3) -#else -#define LZ4_NBCOMMONBYTES(val) (__builtin_ctzll(val) >> 3) -#endif - #else /* 32-bit */ #define STEPSIZE 4 @@ -132,12 +126,12 @@ typedef struct _U64_S { u64 v; } U64_S; #define LZ4_SECURECOPY LZ4_WILDCOPY #define HTYPE const u8* -#ifdef __BIG_ENDIAN -#define LZ4_NBCOMMONBYTES(val) (__builtin_clz(val) >> 3) -#else -#define LZ4_NBCOMMONBYTES(val) (__builtin_ctz(val) >> 3) #endif +#ifdef __BIG_ENDIAN +#define LZ4_NBCOMMONBYTES(val) (((STEPSIZE * 8) - 1 - __fls(val)) >> 3) +#else +#define LZ4_NBCOMMONBYTES(val) (__ffs(val) >> 3) #endif #define LZ4_READ_LITTLEENDIAN_16(d, s, p) \