Source-Changes-HG archive

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

[src/trunk]: src/lib/libpthread Retire ifdef ERRORCHECK in pthread(3)



details:   https://anonhg.NetBSD.org/src/rev/c01faa27e1f5
branches:  trunk
changeset: 744538:c01faa27e1f5
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed Feb 05 11:05:10 2020 +0000

description:
Retire ifdef ERRORCHECK in pthread(3)

It is enabled unconditionally since 2003 and used only for rwlocks and
spinlocks.

LLVM sanitizers make assumptions that these checks are enabled always.

diffstat:

 lib/libpthread/pthread_int.h    |   3 +--
 lib/libpthread/pthread_rwlock.c |  14 ++------------
 lib/libpthread/pthread_spin.c   |  15 +++------------
 3 files changed, 6 insertions(+), 26 deletions(-)

diffs (168 lines):

diff -r 79828f638a69 -r c01faa27e1f5 lib/libpthread/pthread_int.h
--- a/lib/libpthread/pthread_int.h      Wed Feb 05 10:07:47 2020 +0000
+++ b/lib/libpthread/pthread_int.h      Wed Feb 05 11:05:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_int.h,v 1.100 2020/01/28 13:08:40 ad Exp $     */
+/*     $NetBSD: pthread_int.h,v 1.101 2020/02/05 11:05:10 kamil Exp $  */
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020
@@ -36,7 +36,6 @@
 #include <sys/tls.h>
 
 /* #define PTHREAD__DEBUG */
-#define ERRORCHECK
 
 #include "pthread_types.h"
 #include "pthread_queue.h"
diff -r 79828f638a69 -r c01faa27e1f5 lib/libpthread/pthread_rwlock.c
--- a/lib/libpthread/pthread_rwlock.c   Wed Feb 05 10:07:47 2020 +0000
+++ b/lib/libpthread/pthread_rwlock.c   Wed Feb 05 11:05:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_rwlock.c,v 1.38 2020/01/31 17:52:14 kamil Exp $ */
+/*     $NetBSD: pthread_rwlock.c,v 1.39 2020/02/05 11:05:10 kamil Exp $ */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_rwlock.c,v 1.38 2020/01/31 17:52:14 kamil Exp $");
+__RCSID("$NetBSD: pthread_rwlock.c,v 1.39 2020/02/05 11:05:10 kamil Exp $");
 
 #include <sys/types.h>
 #include <sys/lwpctl.h>
@@ -158,10 +158,8 @@
        pthread_t self;
        int error;
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid rwlock",
            ptr->ptr_magic == _PT_RWLOCK_MAGIC);
-#endif
 
        for (owner = (uintptr_t)ptr->ptr_owner;; owner = next) {
                /*
@@ -248,10 +246,8 @@
        if (__predict_false(__uselibcstub))
                return __libc_rwlock_tryrdlock_stub(ptr);
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid rwlock",
            ptr->ptr_magic == _PT_RWLOCK_MAGIC);
-#endif
 
        /*
         * Don't get a readlock if there is a writer or if there are waiting
@@ -283,10 +279,8 @@
        self = pthread__self();
        _DIAGASSERT(((uintptr_t)self & RW_FLAGMASK) == 0);
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid rwlock",
            ptr->ptr_magic == _PT_RWLOCK_MAGIC);
-#endif
 
        for (owner = (uintptr_t)ptr->ptr_owner;; owner = next) {
                /*
@@ -374,10 +368,8 @@
        if (__predict_false(__uselibcstub))
                return __libc_rwlock_trywrlock_stub(ptr);
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid rwlock",
            ptr->ptr_magic == _PT_RWLOCK_MAGIC);
-#endif
 
        self = pthread__self();
        _DIAGASSERT(((uintptr_t)self & RW_FLAGMASK) == 0);
@@ -453,10 +445,8 @@
        if (__predict_false(__uselibcstub))
                return __libc_rwlock_unlock_stub(ptr);
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid rwlock",
            ptr->ptr_magic == _PT_RWLOCK_MAGIC);
-#endif
 
 #ifndef PTHREAD__ATOMIC_IS_MEMBAR
        membar_exit();
diff -r 79828f638a69 -r c01faa27e1f5 lib/libpthread/pthread_spin.c
--- a/lib/libpthread/pthread_spin.c     Wed Feb 05 10:07:47 2020 +0000
+++ b/lib/libpthread/pthread_spin.c     Wed Feb 05 11:05:10 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_spin.c,v 1.7 2020/01/31 17:52:14 kamil Exp $   */
+/*     $NetBSD: pthread_spin.c,v 1.8 2020/02/05 11:05:10 kamil Exp $   */
 
 /*-
  * Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_spin.c,v 1.7 2020/01/31 17:52:14 kamil Exp $");
+__RCSID("$NetBSD: pthread_spin.c,v 1.8 2020/02/05 11:05:10 kamil Exp $");
 
 #include <sys/types.h>
 #include <sys/ras.h>
@@ -53,11 +53,10 @@
 pthread_spin_init(pthread_spinlock_t *lock, int pshared)
 {
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid pshared",
            pshared == PTHREAD_PROCESS_PRIVATE ||
            pshared == PTHREAD_PROCESS_SHARED);
-#endif
+
        lock->pts_magic = _PT_SPINLOCK_MAGIC;
 
        /*
@@ -75,13 +74,11 @@
 pthread_spin_destroy(pthread_spinlock_t *lock)
 {
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid spinlock",
            lock->pts_magic == _PT_SPINLOCK_MAGIC);
 
        if (!__SIMPLELOCK_UNLOCKED_P(&lock->pts_spin))
                return EBUSY;
-#endif
 
        lock->pts_magic = _PT_SPINLOCK_DEAD;
 
@@ -93,10 +90,8 @@
 {
        pthread_t self;
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid spinlock",
            lock->pts_magic == _PT_SPINLOCK_MAGIC);
-#endif
 
        self = pthread__self();
        while (pthread__spintrylock(self, &lock->pts_spin) == 0) {
@@ -111,10 +106,8 @@
 {
        pthread_t self;
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid spinlock",
            lock->pts_magic == _PT_SPINLOCK_MAGIC);
-#endif
 
        self = pthread__self();
        if (pthread__spintrylock(self, &lock->pts_spin) == 0)
@@ -127,10 +120,8 @@
 {
        pthread_t self;
 
-#ifdef ERRORCHECK
        pthread__error(EINVAL, "Invalid spinlock",
            lock->pts_magic == _PT_SPINLOCK_MAGIC);
-#endif
 
        self = pthread__self();
        pthread__spinunlock(self, &lock->pts_spin);



Home | Main Index | Thread Index | Old Index