[Uclinux-h8-devel] GCC-3.4 support for bitops.h

Back to archive index

Kazu Hirata kazu****@cs*****
2004年 1月 27日 (火) 03:04:01 JST


こんにちは。

gcc の開発版で uClinux を compile したら色々と error 出てきました。
とりあえず、明白なところから patch をお送りします。

gcc-3.4.0 では変数と一対一の関係が無い左辺値が警告されるようになりま
す。例えば、

  (a ? b : c) = 3;

や

  long *p;
  :
  (unsigned char *) p += 3;

というのはだめです。gcc-3.5.0 からは警告どころか、しっかりと error に
なります。これは長いこと GCC の (おそらく隠し) 拡張機能だったのですが、
GCC 内部での maintenance 性が悪いとか何とかでこういう運びとなりました。

あと、gcc-3.[45] とは関係はないのですが、bit 操作命令の bit 位置指定に 
"g" を使うと、stack とかに入った operand を渡されるかもしれません。と
いうわけで、"r" を使わなければなりません。

佐藤様、できましたら 2.6 の方への反映も宣しくお願いします。

Kazu Hirata

Index: arch/h8300/platform/h8300h/ints.c
===================================================================
RCS file: /cvsroot/uclinux-h8/uClinux-2.4.x/arch/h8300/platform/h8300h/ints.c,v
retrieving revision 1.18
diff -u -r1.18 ints.c
--- arch/h8300/platform/h8300h/ints.c	16 Jan 2004 12:38:55 -0000	1.18
+++ arch/h8300/platform/h8300h/ints.c	26 Jan 2004 07:26:01 -0000
@@ -141,7 +141,8 @@
 		irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
 	else {
 		irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t));
-		(unsigned long)irq_handle |= 0x80000000UL;
+		irq_handle = ((irq_handler_t *)
+			      ((unsigned long) irq_handle | 0x80000000UL));
 	}
 
 	if (irq_handle == NULL)
Index: arch/h8300/platform/h8300h/ptrace_h8300h.c
===================================================================
RCS file: /cvsroot/uclinux-h8/uClinux-2.4.x/arch/h8300/platform/h8300h/ptrace_h8300h.c,v
retrieving revision 1.1
diff -u -r1.1 ptrace_h8300h.c
--- arch/h8300/platform/h8300h/ptrace_h8300h.c	12 Dec 2003 17:23:04 -0000	1.1
+++ arch/h8300/platform/h8300h/ptrace_h8300h.c	26 Jan 2004 07:26:01 -0000
@@ -64,7 +64,7 @@
 {
 	if((long)child->thread.breakinfo.addr != -1L) {
 		*child->thread.breakinfo.addr = child->thread.breakinfo.inst;
-		(long)child->thread.breakinfo.addr = -1L;
+		child->thread.breakinfo.addr = (unsigned short *) (long) -1L;
 	}
 }
 
@@ -259,11 +259,11 @@
 		if (!offsetlength(inst)) {
 			/* Bcc xx:8 */
 			if (((inst & 0xff00) == 0x5500) || isbranch((inst & 0x0f00) >> 8, ccr))
-				(unsigned char *)nextpc += (signed char)(inst & 0xff);
+				nextpc = (unsigned short *) ((unsigned char *) nextpc + (signed char)(inst & 0xff));
 		} else {
 			/* Bcc xx:16 */
 			if ((inst == 0x5c00) || isbranch((inst & 0x00f0) >> 4, ccr))
-				(unsigned char *)nextpc += (signed short)(*nextpc);
+				nextpc = (unsigned short *) (signed short)(*nextpc);
 			nextpc++;  /* adjust offset */
 		}
 	}
Index: include/asm-h8300/bitops.h
===================================================================
RCS file: /cvsroot/uclinux-h8/uClinux-2.4.x/include/asm-h8300/bitops.h,v
retrieving revision 1.20
diff -u -r1.20 bitops.h
--- include/asm-h8300/bitops.h	16 Jan 2004 15:13:50 -0000	1.20
+++ include/asm-h8300/bitops.h	26 Jan 2004 17:40:05 -0000
@@ -73,7 +73,7 @@
 	{								   \
 		__asm__(OP " %w1,%0"					   \
 			:"+m"(*b_addr)					   \
-			:"g"(nr),"m"(*b_addr));				   \
+			:"r"(nr),"m"(*b_addr));				   \
 	}								   \
 }
 
@@ -141,7 +141,7 @@
         char ccrsave = 0;                                                  \
 	volatile unsigned char *a;                                         \
                                                                            \
-	a = (volatile unsigned char *)addr += ((nr >> 3) ^ 3);             \
+	a = (volatile unsigned char *)addr + ((nr >> 3) ^ 3);              \
 	if(__builtin_constant_p(nr) == 0) {                                \
 		__asm__("stc ccr,%w2\n\t"                                  \
 			"orc #0x80,ccr\n\t"                                \
@@ -152,7 +152,7 @@
 			"1:\n\t"                                           \
 			"ldc %w2,ccr"                                      \
 			: "=r"(retval),"+m"(*a),"+r"(ccrsave)              \
-			: "0" (retval),"1" (*a),"g"(nr & 7)                \
+			: "0" (retval),"1" (*a),"r"(nr & 7)                \
 			: "memory");                                       \
 		return retval;                                             \
 	} else {                                                           \
@@ -192,7 +192,7 @@
 	int retval = 0;                                                    \
 	volatile unsigned char *a;                                         \
                                                                            \
-	a = (volatile unsigned char *)addr += ((nr >> 3) ^ 3);             \
+	a = (volatile unsigned char *)addr + ((nr >> 3) ^ 3);              \
 	if(__builtin_constant_p(nr) == 0) {                                \
 		__asm__("btst %w4,%1\n\t"                                  \
 			OP " %w4,%1\n\t"                                   \
@@ -200,7 +200,7 @@
 			"inc.l #1,%0\n"                                    \
 			"1:\n\t"                                           \
 			: "=r"(retval),"+m"(*a)                            \
-			: "0" (retval),"1" (*a),"g"(nr & 7)                \
+			: "0" (retval),"1" (*a),"r"(nr & 7)                \
 			: "memory");                                       \
 		return retval;                                             \
 	} else {                                                           \



Uclinux-h8-devel メーリングリストの案内
Back to archive index