This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix several build warnings on sparc.


The 'val' argument to sparc's INTERNAL_SYSCALL_ERROR_P isn't used but
we get warnings since these macros are usually used by having the
syscall create the 'val' value and then feeding that into
INTERNAL_SYSCALL_ERROR_P as some architectures need this extra signal
to determine if an error happened or not.  Using powerpc as a guide
just hit it with "(void) val" and also make use of builtin_expect here
instead of at the call sites.

The sparc cpu frequency probing code uses ioctls on /dev/openprom, and
the strct passed in an out of this ioctl uses a variable length data
area that starts with a char[1] array.  We get strict aliasing
warnings because of the way we cast pointers to put and get integers
from there.  Use the special "'char *' aliases everything" exception
via helper functions to get around this.

The NPTL sem_post code for sparc uses atomic_increment_val() but the return
value is unused.  Simply use atomic_increment() and kill the unused local
variable.

Committed to master.

/

	* sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
	(set_obp_int): New function.
	(get_obp_int): New function.
	(__get_clockfreq_via_dev_openprom): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (INTERNAL_SYSCALL_ERROR_P): Avoid
	unused variable warnings on 'val' and use builtin_expect.
	(INLINE_SYSCALL): Don't wrap INTERNAL_SYSCALL_ERROR_P with builtin_expect.
	(INLINE_CLONE_SYSCALL): Likewise.

nptl/

	* sysdeps/unix/sysv/linux/sparc/sem_post.c (__new_sem_post): Use
	atomic_increment and remove unused local variable.
	(__old_sem_post): Likewise.
---
 ChangeLog                                          |   11 ++++++++
 nptl/ChangeLog                                     |    6 ++++
 nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c      |    9 +++---
 .../unix/sysv/linux/sparc/sparc64/get_clockfreq.c  |   27 +++++++++++++++----
 sysdeps/unix/sysv/linux/sparc/sysdep.h             |    7 +++--
 5 files changed, 47 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 165ed82..2b47391 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2012-03-06  David S. Miller  <davem@davemloft.net>
+
+	* sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
+	(set_obp_int): New function.
+	(get_obp_int): New function.
+	(__get_clockfreq_via_dev_openprom): Likewise.
+	* sysdeps/unix/sysv/linux/sparc/sysdep.h (INTERNAL_SYSCALL_ERROR_P): Avoid
+	unused variable warnings on 'val' and use builtin_expect.
+	(INLINE_SYSCALL): Don't wrap INTERNAL_SYSCALL_ERROR_P with builtin_expect.
+	(INLINE_CLONE_SYSCALL): Likewise.
+
 2012-03-05  David S. Miller  <davem@davemloft.net>
 
 	* sysdeps/sparc/fpu/libm-test-ulps: Update.
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 23040e4..57a9b10 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-06  David S. Miller  <davem@davemloft.net>
+
+	* sysdeps/unix/sysv/linux/sparc/sem_post.c (__new_sem_post): Use
+	atomic_increment and remove unused local variable.
+	(__old_sem_post): Likewise.
+
 2012-02-27  David S. Miller  <davem@davemloft.net>
 
 	* sysdeps/unix/sysv/linux/i386/bits/pthreadtypes.h: Don't refer to non-existing
diff --git a/nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c b/nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c
index 0b82992..28e06f6 100644
--- a/nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c
+++ b/nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c
@@ -30,7 +30,7 @@ __new_sem_post (sem_t *sem)
 {
   struct sparc_new_sem *isem = (struct sparc_new_sem *) sem;
 
-  int nr = atomic_increment_val (&isem->value);
+  atomic_increment (&isem->value);
   atomic_full_barrier ();
   if (isem->nwaiters > 0)
     {
@@ -53,10 +53,11 @@ attribute_compat_text_section
 __old_sem_post (sem_t *sem)
 {
   struct sparc_old_sem *isem = (struct sparc_old_sem *) sem;
+  int err;
 
-  int nr = atomic_increment_val (&isem->value);
-  int err = lll_futex_wake (&isem->value, 1,
-			    isem->private ^ FUTEX_PRIVATE_FLAG);
+  atomic_increment (&isem->value);
+  err = lll_futex_wake (&isem->value, 1,
+			isem->private ^ FUTEX_PRIVATE_FLAG);
   if (__builtin_expect (err, 0) < 0)
     {
       __set_errno (-err);
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c b/sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
index e181d9d..ba44a61 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
@@ -154,6 +154,22 @@ __get_clockfreq_via_proc_openprom (void)
   return result;
 }
 
+static void set_obp_int (struct openpromio *op, int val)
+{
+  char *cp = op->oprom_array;
+  int *ip = (int *) cp;
+
+  *ip = val;
+}
+
+static int get_obp_int (struct openpromio *op)
+{
+  char *cp = op->oprom_array;
+  int *ip = (int *) cp;
+
+  return *ip;
+}
+
 static hp_timing_t
 __get_clockfreq_via_dev_openprom (void)
 {
@@ -171,11 +187,11 @@ __get_clockfreq_via_dev_openprom (void)
 
       obp_cmd->oprom_size =
 	sizeof (obp_buf) - sizeof (unsigned int);
-      *(int *) obp_cmd->oprom_array = 0;
+      set_obp_int (obp_cmd, 0);
       ret = ioctl (obp_dev_fd, OPROMCHILD, (char *) obp_cmd);
       if (ret == 0)
 	{
-	  int cur_node = *(int *) obp_cmd->oprom_array;
+	  int cur_node = get_obp_int (obp_cmd);
 
 	  while (cur_node != 0 && cur_node != -1)
 	    {
@@ -190,15 +206,14 @@ __get_clockfreq_via_dev_openprom (void)
 		  strcpy (obp_cmd->oprom_array, "clock-frequency");
 		  ret = ioctl (obp_dev_fd, OPROMGETPROP, (char *) obp_cmd);
 		  if (ret == 0)
-		    result =
-		      (hp_timing_t) *(unsigned int *) obp_cmd->oprom_array;
+		    result = (hp_timing_t) get_obp_int (obp_cmd);
 		}
 	      obp_cmd->oprom_size = sizeof (obp_buf) - sizeof (unsigned int);
-	      *(int *) obp_cmd->oprom_array = cur_node;
+	      set_obp_int (obp_cmd, cur_node);
 	      ret = ioctl (obp_dev_fd, OPROMNEXT, (char *) obp_cmd);
 	      if (ret < 0)
 		break;
-	      cur_node = *(int *)obp_cmd->oprom_array;
+	      cur_node = get_obp_int (obp_cmd);
 	    }
 	}
     }
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 336c853..30144b9 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -23,7 +23,7 @@
 #define INLINE_SYSCALL(name, nr, args...) 				\
 ({	INTERNAL_SYSCALL_DECL(err);  					\
 	unsigned int resultvar = INTERNAL_SYSCALL(name, err, nr, args);	\
-	if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, err), 0)) \
+	if (INTERNAL_SYSCALL_ERROR_P (resultvar, err))			\
 	  {		     			       		   	\
 	    __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err));	\
 	    resultvar = 0xffffffff;			    		\
@@ -44,7 +44,8 @@
   inline_syscall##nr(__SYSCALL_STRING, err, name, args)
 
 #undef INTERNAL_SYSCALL_ERROR_P
-#define INTERNAL_SYSCALL_ERROR_P(val, err) ((err) != 0)
+#define INTERNAL_SYSCALL_ERROR_P(val, err) \
+  ((void) (val), __builtin_expect((err) != 0, 0))
 
 #undef INTERNAL_SYSCALL_ERRNO
 #define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
@@ -152,7 +153,7 @@
 			  "0" (__g1), "1" (__o0), "2" (__o1),		\
 			  "r" (__o2), "r" (__o3), "r" (__o4) :		\
 			  __SYSCALL_CLOBBERS);				\
-	if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (__o0, __g1), 0)) \
+	if (INTERNAL_SYSCALL_ERROR_P (__o0, __g1))			\
 	  {		     			       		   	\
 	    __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1));		\
 	    __o0 = -1L;			    				\
-- 
1.7.6.401.g6a319


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]