linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BTRFS-PROGS][PATCH] remove __attribute_const__ from raid6.c
@ 2013-02-02 20:13 Goffredo Baroncelli
  2013-02-03 15:56 ` Eric Sandeen
  0 siblings, 1 reply; 6+ messages in thread
From: Goffredo Baroncelli @ 2013-02-02 20:13 UTC (permalink / raw)
  To: Chris Mason; +Cc: linux-btrfs

Hi all,

I am playing with the new branch raid56-experimental. Unfortunately 
I was not able to compile the btrfs-progs tools because my gcc was unable 
to find '__attribute_const__':

[...]
raid6.c:48:1: error: unknown type name ‘__attribute_const__’
raid6.c:48:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘SHLBYTE’
raid6.c:60:1: error: unknown type name ‘__attribute_const__’
raid6.c:60:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘MASK’
[...]

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' 
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs 
--enable-languages=c,c++,go,fortran,objc,obj-c++ 
--prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id 
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext 
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object 
--enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic 
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu 
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5) 


The patch below fixed that:

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>

---

>From 761a0b05f04da6029fec2a3060e64135ccb3046e Mon Sep 17 00:00:00 2001
From: Goffredo Baroncelli <kreijack@inwind.it>
Date: Sat, 2 Feb 2013 21:10:20 +0100
Subject: [PATCH] =?UTF-8?q?Remove=20=E2=80=98=5F=5Fattribute=5Fconst=5F=5F=E2?=
 =?UTF-8?q?=80=99=20from=20raid6.c?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Remove ‘__attribute_const__’ from raid6.c otherwise gcc was unable
to compile it.
---
 raid6.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/raid6.c b/raid6.c
index 3a42bdf..a5a3dc3 100644
--- a/raid6.c
+++ b/raid6.c
@@ -45,7 +45,7 @@ typedef uint32_t unative_t;
  * The SHLBYTE() operation shifts each byte left by 1, *not*
  * rolling over into the next byte
  */
-static inline __attribute_const__ unative_t SHLBYTE(unative_t v)
+static inline unative_t SHLBYTE(unative_t v)
 {
 	unative_t vv;
 
@@ -57,7 +57,7 @@ static inline __attribute_const__ unative_t SHLBYTE(unative_t v)
  * The MASK() operation returns 0xFF in any byte for which the high
  * bit is 1, 0x00 for any byte for which the high bit is 0.
  */
-static inline __attribute_const__ unative_t MASK(unative_t v)
+static inline unative_t MASK(unative_t v)
 {
 	unative_t vv;
 
-- 
1.7.10.4





-- 
gpg @keyserver.linux.it: Goffredo Baroncelli (kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [BTRFS-PROGS][PATCH] remove __attribute_const__ from raid6.c
  2013-02-02 20:13 [BTRFS-PROGS][PATCH] remove __attribute_const__ from raid6.c Goffredo Baroncelli
@ 2013-02-03 15:56 ` Eric Sandeen
  2013-02-03 16:19   ` Eric Sandeen
  2013-02-03 17:01   ` David Sterba
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Sandeen @ 2013-02-03 15:56 UTC (permalink / raw)
  To: kreijack; +Cc: Chris Mason, linux-btrfs

On 2/2/13 2:13 PM, Goffredo Baroncelli wrote:
> Hi all,
> 
> I am playing with the new branch raid56-experimental. Unfortunately 
> I was not able to compile the btrfs-progs tools because my gcc was unable 
> to find '__attribute_const__':
> 
> [...]
> raid6.c:48:1: error: unknown type name ‘__attribute_const__’
> raid6.c:48:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘SHLBYTE’
> raid6.c:60:1: error: unknown type name ‘__attribute_const__’
> raid6.c:60:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘MASK’
> [...]

Something like this might be more in the spirit of the kernel code copy,
and will keep the annotations.  (I'm not sure why the kernel does it
this way, TBH).


From: Eric Sandeen <sandeen@redhat.com>

btrfs-progs: define __attribute_const__ in kerncompat.h

Without this we can't build userspace.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---


diff --git a/kerncompat.h b/kerncompat.h
index d60f722..8004f9e 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -126,6 +126,8 @@ static inline int mutex_is_locked(struct mutex *m)
 #define BITOP_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
 #define BITOP_WORD(nr)		((nr) / BITS_PER_LONG)
 
+#define __attribute_const__	__attribute__((const))
+
 /**
  * __set_bit - Set a bit in memory
  * @nr: the bit to set
diff --git a/raid6.c b/raid6.c
index 3a42bdf..ce0f655 100644
--- a/raid6.c
+++ b/raid6.c
@@ -19,6 +19,8 @@
  */
 #include <stdint.h>
 #include <unistd.h>
+#include "kerncompat.h"
+
 /*
  * This is the C data type to use
  */




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [BTRFS-PROGS][PATCH] remove __attribute_const__ from raid6.c
  2013-02-03 15:56 ` Eric Sandeen
@ 2013-02-03 16:19   ` Eric Sandeen
  2013-02-03 17:01   ` David Sterba
  1 sibling, 0 replies; 6+ messages in thread
From: Eric Sandeen @ 2013-02-03 16:19 UTC (permalink / raw)
  To: kreijack; +Cc: Chris Mason, linux-btrfs

On 2/3/13 9:56 AM, Eric Sandeen wrote:
> On 2/2/13 2:13 PM, Goffredo Baroncelli wrote:
>> Hi all,
>>
>> I am playing with the new branch raid56-experimental. Unfortunately 
>> I was not able to compile the btrfs-progs tools because my gcc was unable 
>> to find '__attribute_const__':
>>
>> [...]
>> raid6.c:48:1: error: unknown type name ‘__attribute_const__’
>> raid6.c:48:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘SHLBYTE’
>> raid6.c:60:1: error: unknown type name ‘__attribute_const__’
>> raid6.c:60:45: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘MASK’
>> [...]
> 
> Something like this might be more in the spirit of the kernel code copy,
> and will keep the annotations.  (I'm not sure why the kernel does it
> this way, TBH).

Meh, that doesn't compile either, will look later, sorry.

-Eric

> 
> From: Eric Sandeen <sandeen@redhat.com>
> 
> btrfs-progs: define __attribute_const__ in kerncompat.h
> 
> Without this we can't build userspace.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> 
> diff --git a/kerncompat.h b/kerncompat.h
> index d60f722..8004f9e 100644
> --- a/kerncompat.h
> +++ b/kerncompat.h
> @@ -126,6 +126,8 @@ static inline int mutex_is_locked(struct mutex *m)
>  #define BITOP_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
>  #define BITOP_WORD(nr)		((nr) / BITS_PER_LONG)
>  
> +#define __attribute_const__	__attribute__((const))
> +
>  /**
>   * __set_bit - Set a bit in memory
>   * @nr: the bit to set
> diff --git a/raid6.c b/raid6.c
> index 3a42bdf..ce0f655 100644
> --- a/raid6.c
> +++ b/raid6.c
> @@ -19,6 +19,8 @@
>   */
>  #include <stdint.h>
>  #include <unistd.h>
> +#include "kerncompat.h"
> +
>  /*
>   * This is the C data type to use
>   */
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [BTRFS-PROGS][PATCH] remove __attribute_const__ from raid6.c
  2013-02-03 15:56 ` Eric Sandeen
  2013-02-03 16:19   ` Eric Sandeen
@ 2013-02-03 17:01   ` David Sterba
  2013-02-03 17:34     ` [PATCH] btrfs-progs: include kerncompat.h in raid6.c, define __attribute_const__ Eric Sandeen
  1 sibling, 1 reply; 6+ messages in thread
From: David Sterba @ 2013-02-03 17:01 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: kreijack, Chris Mason, linux-btrfs

On Sun, Feb 03, 2013 at 09:56:08AM -0600, Eric Sandeen wrote:
> +#define __attribute_const__	__attribute__((const))

__attribute__((__const__))

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] btrfs-progs: include kerncompat.h in raid6.c, define __attribute_const__
  2013-02-03 17:01   ` David Sterba
@ 2013-02-03 17:34     ` Eric Sandeen
  2013-02-03 17:41       ` Chris Mason
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Sandeen @ 2013-02-03 17:34 UTC (permalink / raw)
  To: kreijack, Chris Mason, linux-btrfs

raid6.c was failing to build for Goffredo and me due to
__attribute_const__ being undefined.

Define it in kerncompat.h and include that; this also makes
sure BITS_PER_LONG is defined for raid6.c, prior to this it 
was not defined, at least in my build.

Finally, redefine BITS_PER_LONG in a way that it can be
tested in the preprocessor macro.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/kerncompat.h b/kerncompat.h
index d60f722..1e7b7d3 100644
--- a/kerncompat.h
+++ b/kerncompat.h
@@ -36,7 +36,7 @@
 #define gfp_t int
 #define get_cpu_var(p) (p)
 #define __get_cpu_var(p) (p)
-#define BITS_PER_LONG (sizeof(long) * 8)
+#define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
 #define __GFP_BITS_SHIFT 20
 #define __GFP_BITS_MASK ((int)((1 << __GFP_BITS_SHIFT) - 1))
 #define GFP_KERNEL 0
@@ -126,6 +126,8 @@ static inline int mutex_is_locked(struct mutex *m)
 #define BITOP_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
 #define BITOP_WORD(nr)		((nr) / BITS_PER_LONG)
 
+#define __attribute_const__	__attribute__((__const__))
+
 /**
  * __set_bit - Set a bit in memory
  * @nr: the bit to set
diff --git a/raid6.c b/raid6.c
index 3a42bdf..ce0f655 100644
--- a/raid6.c
+++ b/raid6.c
@@ -19,6 +19,8 @@
  */
 #include <stdint.h>
 #include <unistd.h>
+#include "kerncompat.h"
+
 /*
  * This is the C data type to use
  */



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] btrfs-progs: include kerncompat.h in raid6.c, define __attribute_const__
  2013-02-03 17:34     ` [PATCH] btrfs-progs: include kerncompat.h in raid6.c, define __attribute_const__ Eric Sandeen
@ 2013-02-03 17:41       ` Chris Mason
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Mason @ 2013-02-03 17:41 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: kreijack@inwind.it, Chris Mason, linux-btrfs

On Sun, Feb 03, 2013 at 10:34:27AM -0700, Eric Sandeen wrote:
> raid6.c was failing to build for Goffredo and me due to
> __attribute_const__ being undefined.

Thanks, I've pushed this along with an extra #ifndef into the raid56
experimental branch.

-chris

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-02-03 17:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-02 20:13 [BTRFS-PROGS][PATCH] remove __attribute_const__ from raid6.c Goffredo Baroncelli
2013-02-03 15:56 ` Eric Sandeen
2013-02-03 16:19   ` Eric Sandeen
2013-02-03 17:01   ` David Sterba
2013-02-03 17:34     ` [PATCH] btrfs-progs: include kerncompat.h in raid6.c, define __attribute_const__ Eric Sandeen
2013-02-03 17:41       ` Chris Mason

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