linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Chanho Min <chanho.min@lge.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Darrick J. Wong" <djwong@us.ibm.com>,
	Bob Pearson <rpearson@systemfabricworks.com>,
	Richard Weinberger <richard@nod.at>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-crypto@vger.kernel.org,
	Yann Collet <yann.collet.73@gmail.com>,
	Kyungsik Lee <kyungsik.lee@lge.com>,
	Chanho Min <chanho0207@gmail.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: Thu, 18 Apr 2013 11:50:08 +0200	[thread overview]
Message-ID: <CAMuHMdXXoaQjb9sRK=X3gEDwqQBJcJQtaJbUGB8cJmteHSN3vQ@mail.gmail.com> (raw)
In-Reply-To: <CAOAMb1D8rokZpQpp6mEJw6KXcQq8fJUWBJoC5+ZfkNaE6WvAZA@mail.gmail.com>

On Thu, Mar 14, 2013 at 10:48 AM, Chanho Min <chanho.min@lge.com> wrote:
> +#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
> @@ -83,6 +130,14 @@ typedef struct _U64_S { u64 v; } U64_S;
>         } while (0)
>
>  #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

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!

sparc64-allmodconfig (http://kisskb.ellerman.id.au/kisskb/buildresult/8572790/):

ERROR: "__clzdi2" [lib/lz4/lz4hc_compress.ko] undefined!
ERROR: "__clzdi2" [lib/lz4/lz4_compress.ko] undefined!

sparc-allmodconfig (http://kisskb.ellerman.id.au/kisskb/buildresult/8572795/):

ERROR: "__clzdi2" [lib/lz4/lz4hc_compress.ko] undefined!
ERROR: "__clzdi2" [lib/lz4/lz4_compress.ko] undefined!

There may be more, hidden by build errors before reaching the link or modpost
phases.

The gmail-whitespace-damaged patch below fixes the m68k and sparc builds
for me, does this look acceptable?

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) \

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

       reply	other threads:[~2013-04-18  9:50 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 ` Geert Uytterhoeven [this message]
     [not found]   ` <51750159.07d70e0a.5461.ffffec64SMTPIN_ADDED_BROKEN@mx.google.com>
2013-04-22  9:24     ` [PATCH 1/2] lib: Add lz4 compressor module 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
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='CAMuHMdXXoaQjb9sRK=X3gEDwqQBJcJQtaJbUGB8cJmteHSN3vQ@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=akpm@linux-foundation.org \
    --cc=chanho.min@lge.com \
    --cc=chanho0207@gmail.com \
    --cc=djwong@us.ibm.com \
    --cc=herbert@gondor.apana.org.au \
    --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).