Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Use anonymous union for ptm_ceiling and old _...



details:   https://anonhg.NetBSD.org/src/rev/f6d025877b79
branches:  trunk
changeset: 346529:f6d025877b79
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sun Jul 17 13:49:43 2016 +0000

description:
Use anonymous union for ptm_ceiling and old __pthread_spin_t field to
maintain backward compatibility and fix hppa build.  hppa has an non-
integer type __pthread_spin_t

diffstat:

 lib/libpthread/pthread_mutex.c |  10 +++++-----
 lib/libpthread/pthread_types.h |  11 +++++++----
 2 files changed, 12 insertions(+), 9 deletions(-)

diffs (76 lines):

diff -r 0ecc21b2b17c -r f6d025877b79 lib/libpthread/pthread_mutex.c
--- a/lib/libpthread/pthread_mutex.c    Sun Jul 17 12:56:12 2016 +0000
+++ b/lib/libpthread/pthread_mutex.c    Sun Jul 17 13:49:43 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_mutex.c,v 1.61 2016/07/16 12:58:11 skrll Exp $ */
+/*     $NetBSD: pthread_mutex.c,v 1.62 2016/07/17 13:49:43 skrll Exp $ */
 
 /*-
  * Copyright (c) 2001, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_mutex.c,v 1.61 2016/07/16 12:58:11 skrll Exp $");
+__RCSID("$NetBSD: pthread_mutex.c,v 1.62 2016/07/17 13:49:43 skrll Exp $");
 
 #include <sys/types.h>
 #include <sys/lwpctl.h>
@@ -796,7 +796,7 @@
 int
 pthread_mutex_getprioceiling(const pthread_mutex_t *ptm, int *ceil) 
 {
-       *ceil = (unsigned int)ptm->ptm_ceiling;
+       *ceil = ptm->ptm_ceiling;
        return 0;
 }
 
@@ -807,9 +807,9 @@
 
        error = pthread_mutex_lock(ptm);
        if (error == 0) {
-               *old_ceil = (unsigned int)ptm->ptm_ceiling;
+               *old_ceil = ptm->ptm_ceiling;
                /*check range*/
-               ptm->ptm_ceiling = (unsigned char)ceil;
+               ptm->ptm_ceiling = ceil;
                pthread_mutex_unlock(ptm);
        }
        return error;
diff -r 0ecc21b2b17c -r f6d025877b79 lib/libpthread/pthread_types.h
--- a/lib/libpthread/pthread_types.h    Sun Jul 17 12:56:12 2016 +0000
+++ b/lib/libpthread/pthread_types.h    Sun Jul 17 13:49:43 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_types.h,v 1.18 2016/07/03 14:24:58 christos Exp $      */
+/*     $NetBSD: pthread_types.h,v 1.19 2016/07/17 13:49:43 skrll Exp $ */
 
 /*-
  * Copyright (c) 2001, 2008 The NetBSD Foundation, Inc.
@@ -115,7 +115,10 @@
 #ifdef __CPU_SIMPLE_LOCK_PAD
        uint8_t         ptm_pad1[3];
 #endif
-       __pthread_spin_t ptm_ceiling;
+       union {
+               unsigned char ptm_ceiling;
+               __pthread_spin_t ptm_unused;
+       };
 #ifdef __CPU_SIMPLE_LOCK_PAD
        uint8_t         ptm_pad2[3];
 #endif
@@ -131,13 +134,13 @@
 #ifdef __CPU_SIMPLE_LOCK_PAD
 #define _PTHREAD_MUTEX_INITIALIZER { _PT_MUTEX_MAGIC,                  \
                                    __SIMPLELOCK_UNLOCKED, { 0, 0, 0 }, \
-                                   __SIMPLELOCK_UNLOCKED, { 0, 0, 0 }, \
+                                   { 0 }, { 0, 0, 0 },                 \
                                    NULL, NULL, 0, NULL                 \
                                  }
 #else
 #define _PTHREAD_MUTEX_INITIALIZER { _PT_MUTEX_MAGIC,                  \
                                    __SIMPLELOCK_UNLOCKED,              \
-                                   __SIMPLELOCK_UNLOCKED,              \
+                                   { 0 } ,                             \
                                    NULL, NULL, 0, NULL                 \
                                  }
 #endif /* __CPU_SIMPLE_LOCK_PAD */



Home | Main Index | Thread Index | Old Index