From patchwork Mon Jan 13 00:28:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 1221905 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108625-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=P7eO4tBb; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47wvZm1Vtpz9s4Y for ; Mon, 13 Jan 2020 11:28:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=RCP aQvQKFcbwXonjKod6wAE5j/YP+iOhVEhbjtpjkVRGKW62Pb1wYTlWoGEfYZl0JU4 q6wSjvroe6WsFHanojsf903udBWtSBaZYz7SrAZoayoB4s8A/MS6Hj70sgpih0gQ EGU4CZICDTdFvg1oXFfFbYOBrVwZLF/DpW1wIgYc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=2dIkoJ4uL mKI7oJYVLBg2fwwgDE=; b=P7eO4tBbZ95pZU3fuDca0sqPjiKZV8s6NFg2CNwgw CcrpBh2sHJqFTPxaSMG3MONnc6M08yX/xHrNBRc4lZ1bC6F/06sf3Fc42TAam3TG /5z+54g4WE9+wnN4NNNRVRB0wIp0CfKKqRg+Rkt6Jge2hNg88TvLctAHNWEkySpB x0= Received: (qmail 119361 invoked by alias); 13 Jan 2020 00:28:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 118973 invoked by uid 89); 13 Jan 2020 00:28:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=744, HContent-Transfer-Encoding:8bit X-HELO: hera.aquilenet.fr From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd, commited] htl: Add type sizes in bits/pthreadtypes-arch.h and check them Date: Mon, 13 Jan 2020 01:28:19 +0100 Message-Id: <20200113002819.692290-1-samuel.thibault@ens-lyon.org> MIME-Version: 1.0 --- sysdeps/htl/pt-attr-init.c | 2 ++ sysdeps/htl/pt-barrier-init.c | 2 ++ sysdeps/htl/pt-barrierattr-init.c | 2 ++ sysdeps/htl/pt-cond-init.c | 2 ++ sysdeps/htl/pt-condattr-init.c | 2 ++ sysdeps/htl/pt-mutex-init.c | 2 ++ sysdeps/htl/pt-mutexattr-init.c | 2 ++ sysdeps/htl/pt-once.c | 2 ++ sysdeps/htl/pt-rwlock-init.c | 2 ++ sysdeps/htl/pt-rwlockattr-init.c | 2 ++ sysdeps/htl/pthreadP.h | 4 ++++ sysdeps/i386/htl/bits/pthreadtypes-arch.h | 14 ++++++++++++++ sysdeps/mach/hurd/htl/pt-mutex-init.c | 2 ++ sysdeps/mach/hurd/htl/pt-mutexattr-init.c | 2 ++ 14 files changed, 42 insertions(+) diff --git a/sysdeps/htl/pt-attr-init.c b/sysdeps/htl/pt-attr-init.c index 29111763fa..7b20204cd7 100644 --- a/sysdeps/htl/pt-attr-init.c +++ b/sysdeps/htl/pt-attr-init.c @@ -22,6 +22,8 @@ int __pthread_attr_init (pthread_attr_t *attr) { + ASSERT_TYPE_SIZE (pthread_attr_t, __SIZEOF_PTHREAD_ATTR_T); + *attr = __pthread_default_attr; return 0; } diff --git a/sysdeps/htl/pt-barrier-init.c b/sysdeps/htl/pt-barrier-init.c index f8befde66d..2197618238 100644 --- a/sysdeps/htl/pt-barrier-init.c +++ b/sysdeps/htl/pt-barrier-init.c @@ -26,6 +26,8 @@ int pthread_barrier_init (pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count) { + ASSERT_TYPE_SIZE (pthread_barrier_t, __SIZEOF_PTHREAD_BARRIER_T); + if (count == 0) return EINVAL; diff --git a/sysdeps/htl/pt-barrierattr-init.c b/sysdeps/htl/pt-barrierattr-init.c index ddda87d1c8..a0d0e3a98f 100644 --- a/sysdeps/htl/pt-barrierattr-init.c +++ b/sysdeps/htl/pt-barrierattr-init.c @@ -22,6 +22,8 @@ int pthread_barrierattr_init (pthread_barrierattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_barrierattr_t, __SIZEOF_PTHREAD_BARRIERATTR_T); + *attr = __pthread_default_barrierattr; return 0; } diff --git a/sysdeps/htl/pt-cond-init.c b/sysdeps/htl/pt-cond-init.c index 3ba1f11881..c5330b5931 100644 --- a/sysdeps/htl/pt-cond-init.c +++ b/sysdeps/htl/pt-cond-init.c @@ -25,6 +25,8 @@ int __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t * attr) { + ASSERT_TYPE_SIZE (pthread_cond_t, __SIZEOF_PTHREAD_COND_T); + *cond = (pthread_cond_t) __PTHREAD_COND_INITIALIZER; if (attr == NULL diff --git a/sysdeps/htl/pt-condattr-init.c b/sysdeps/htl/pt-condattr-init.c index 9018490ab0..90f5d1b6d6 100644 --- a/sysdeps/htl/pt-condattr-init.c +++ b/sysdeps/htl/pt-condattr-init.c @@ -22,6 +22,8 @@ int __pthread_condattr_init (pthread_condattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_condattr_t, __SIZEOF_PTHREAD_CONDATTR_T); + *attr = __pthread_default_condattr; return 0; } diff --git a/sysdeps/htl/pt-mutex-init.c b/sysdeps/htl/pt-mutex-init.c index e20d44c64c..c59bd8a3f5 100644 --- a/sysdeps/htl/pt-mutex-init.c +++ b/sysdeps/htl/pt-mutex-init.c @@ -28,6 +28,8 @@ _pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { *mutex = (pthread_mutex_t) __PTHREAD_MUTEX_INITIALIZER; + ASSERT_TYPE_SIZE (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T); + if (attr == NULL || memcmp (attr, &__pthread_default_mutexattr, sizeof (*attr)) == 0) /* The default attributes. */ diff --git a/sysdeps/htl/pt-mutexattr-init.c b/sysdeps/htl/pt-mutexattr-init.c index c9681863ed..a96e52dedf 100644 --- a/sysdeps/htl/pt-mutexattr-init.c +++ b/sysdeps/htl/pt-mutexattr-init.c @@ -22,6 +22,8 @@ int __pthread_mutexattr_init (pthread_mutexattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T); + *attr = __pthread_default_mutexattr; return 0; } diff --git a/sysdeps/htl/pt-once.c b/sysdeps/htl/pt-once.c index b818ca4d24..0581f7bd6c 100644 --- a/sysdeps/htl/pt-once.c +++ b/sysdeps/htl/pt-once.c @@ -24,6 +24,8 @@ int __pthread_once (pthread_once_t *once_control, void (*init_routine) (void)) { + ASSERT_TYPE_SIZE (pthread_once_t, __SIZEOF_PTHREAD_ONCE_T); + atomic_full_barrier (); if (once_control->__run == 0) { diff --git a/sysdeps/htl/pt-rwlock-init.c b/sysdeps/htl/pt-rwlock-init.c index d79b018f3a..0cba0764be 100644 --- a/sysdeps/htl/pt-rwlock-init.c +++ b/sysdeps/htl/pt-rwlock-init.c @@ -24,6 +24,8 @@ int _pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T); + *rwlock = (pthread_rwlock_t) __PTHREAD_RWLOCK_INITIALIZER; if (attr == NULL diff --git a/sysdeps/htl/pt-rwlockattr-init.c b/sysdeps/htl/pt-rwlockattr-init.c index 721e5ec555..bbc7b87990 100644 --- a/sysdeps/htl/pt-rwlockattr-init.c +++ b/sysdeps/htl/pt-rwlockattr-init.c @@ -22,6 +22,8 @@ int pthread_rwlockattr_init (pthread_rwlockattr_t *attr) { + ASSERT_TYPE_SIZE (pthread_rwlockattr_t, __SIZEOF_PTHREAD_RWLOCKATTR_T); + *attr = __pthread_default_rwlockattr; return 0; } diff --git a/sysdeps/htl/pthreadP.h b/sysdeps/htl/pthreadP.h index 30e074c1d0..af0154538a 100644 --- a/sysdeps/htl/pthreadP.h +++ b/sysdeps/htl/pthreadP.h @@ -74,4 +74,8 @@ hidden_proto (__pthread_setspecific) hidden_proto (_pthread_mutex_init) #endif +#define ASSERT_TYPE_SIZE(type, size) \ + _Static_assert (sizeof (type) == size, \ + "sizeof (" #type ") != " #size) + #endif /* pthreadP.h */ diff --git a/sysdeps/i386/htl/bits/pthreadtypes-arch.h b/sysdeps/i386/htl/bits/pthreadtypes-arch.h index 39d8ff3f8e..17568fb536 100644 --- a/sysdeps/i386/htl/bits/pthreadtypes-arch.h +++ b/sysdeps/i386/htl/bits/pthreadtypes-arch.h @@ -19,4 +19,18 @@ #ifndef _BITS_PTHREADTYPES_ARCH_H #define _BITS_PTHREADTYPES_ARCH_H 1 +#define __SIZEOF_PTHREAD_MUTEX_T 32 +#define __SIZEOF_PTHREAD_ATTR_T 32 +#define __SIZEOF_PTHREAD_RWLOCK_T 28 +#define __SIZEOF_PTHREAD_BARRIER_T 24 +#define __SIZEOF_PTHREAD_MUTEXATTR_T 16 +#define __SIZEOF_PTHREAD_COND_T 20 +#define __SIZEOF_PTHREAD_CONDATTR_T 8 +#define __SIZEOF_PTHREAD_RWLOCKATTR_T 4 +#define __SIZEOF_PTHREAD_BARRIERATTR_T 4 +#define __SIZEOF_PTHREAD_ONCE_T 8 + +#define __LOCK_ALIGNMENT +#define __ONCE_ALIGNMENT + #endif /* bits/pthreadtypes.h */ diff --git a/sysdeps/mach/hurd/htl/pt-mutex-init.c b/sysdeps/mach/hurd/htl/pt-mutex-init.c index 4665bfaf5f..6b804116a5 100644 --- a/sysdeps/mach/hurd/htl/pt-mutex-init.c +++ b/sysdeps/mach/hurd/htl/pt-mutex-init.c @@ -34,6 +34,8 @@ static const pthread_mutexattr_t dfl_attr = { int _pthread_mutex_init (pthread_mutex_t *mtxp, const pthread_mutexattr_t *attrp) { + ASSERT_TYPE_SIZE (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T); + if (attrp == NULL) attrp = &dfl_attr; diff --git a/sysdeps/mach/hurd/htl/pt-mutexattr-init.c b/sysdeps/mach/hurd/htl/pt-mutexattr-init.c index f659a51c28..569ed11c9c 100644 --- a/sysdeps/mach/hurd/htl/pt-mutexattr-init.c +++ b/sysdeps/mach/hurd/htl/pt-mutexattr-init.c @@ -33,6 +33,8 @@ static const pthread_mutexattr_t dfl_attr = { int __pthread_mutexattr_init (pthread_mutexattr_t *attrp) { + ASSERT_TYPE_SIZE (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T); + *attrp = dfl_attr; return 0; }