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.
This commit is contained in:
kamil 2020-02-05 11:05:10 +00:00
parent 0263ce38fb
commit 91719d9fbd
3 changed files with 6 additions and 26 deletions

View File

@ -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"

View File

@ -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__rwlock_rdlock(pthread_rwlock_t *ptr, const struct timespec *ts)
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 @@ pthread_rwlock_tryrdlock(pthread_rwlock_t *ptr)
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 @@ pthread__rwlock_wrlock(pthread_rwlock_t *ptr, const struct timespec *ts)
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 @@ pthread_rwlock_trywrlock(pthread_rwlock_t *ptr)
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 @@ pthread_rwlock_unlock(pthread_rwlock_t *ptr)
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();

View File

@ -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 @@ int
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 @@ int
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_spin_lock(pthread_spinlock_t *lock)
{
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_spin_trylock(pthread_spinlock_t *lock)
{
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_spin_unlock(pthread_spinlock_t *lock)
{
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);