]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
nptl: Change tst-typesizes to _Static_assert
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 16 Oct 2017 14:25:35 +0000 (12:25 -0200)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 7 Nov 2017 11:48:37 +0000 (09:48 -0200)
Instead of rely on runtime check to assure correct pthread types
size a better strategy would use _Static_assert to trigger an error
on build time (and thus allowing to check to potentially ABI breakage
on cross-compiling make check).

This patch moves nptl/tst-typesizes.c to libpthread build time on
each specific initialization routine and also remove some runtime
redundant asserts for the same type sizes.

Checked on x86_64-linux-gnu and with a build check for all affected
ABIs (aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf,
hppa-linux-gnu, i686-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu, mips64-linux-gnu, mips64-n32-linux-gnu,
mips-linux-gnu, powerpc64le-linux-gnu, powerpc-linux-gnu,
s390-linux-gnu, s390x-linux-gnu, sh4-linux-gnu, sparc64-linux-gnu,
sparcv9-linux-gnu, tilegx-linux-gnu, tilegx-linux-gnu-x32,
tilepro-linux-gnu, x86_64-linux-gnu, and x86_64-linux-x32).

* nptl/pthreadP.h (ASSERT_TYPE_SIZE, ASSERT_PTHREAD_INTERNAL_SIZE):
New macros.
* nptl/pthread_attr_init.c (__pthread_mutex_init): Add build time
checks for expected input type size.
* nptl/pthread_barrier_init.c (__pthread_barrier_init): Likewise.
* nptl/pthread_barrierattr_init.c (pthread_barrierattr_init):
Likewise.
* nptl/pthread_cond_init.c (__pthread_cond_init): Likewise.
* nptl/pthread_condattr_init.c (__pthread_condattr_init): Likewise.
* nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise.
* nptl/pthread_mutexattr_init.c (__pthread_mutexattr_init): Likewise.
* nptl/pthread_rwlock_init.c (__pthread_rwlock_init): Likewise.
* nptl/pthread_rwlockattr_init.c (pthread_rwlockattr_init): Likewise.
* nptl/sem_init.c (__new_sem_init, __old_sem_init): Likewise
* nptl/pthread_attr_destroy.c (__pthread_attr_destroy): Remove
superflous runtime assert check.
* nptl/pthread_attr_getaffinity.c (__pthread_attr_getaffinity_new):
Likewise.
* nptl/pthread_attr_getdetachstate.c (__pthread_attr_getdetachstate):
Likewise.
* nptl/pthread_attr_getguardsize.c (pthread_attr_getguardsize):
Likewise.
* nptl/pthread_attr_getinheritsched.c (__pthread_attr_getinheritsched):
Likewise.
* nptl/pthread_attr_getschedparam.c (__pthread_attr_getschedparam):
Likewise.
* nptl/pthread_attr_getschedpolicy.c (__pthread_attr_getschedpolicy):
Likewise.
* nptl/pthread_attr_getscope.c (__pthread_attr_getscope): Likewise.
* nptl/pthread_attr_getstack.c (__pthread_attr_getstack): Likewise.
* nptl/pthread_attr_getstackaddr.c (__pthread_attr_getstackaddr):
Likewise.
* nptl/pthread_attr_getstacksize.c (__pthread_attr_getstacksize):
Likewise.
* nptl/pthread_attr_setaffinity.c (__pthread_attr_setaffinity_new):
Likewise.
* nptl/pthread_attr_setdetachstate.c (__pthread_attr_setdetachstate):
Likewise.
* nptl/pthread_attr_setguardsize.c (pthread_attr_setguardsize):
Likewise.
* nptl/pthread_attr_setinheritsched.c
(__pthread_attr_setinheritsched): Likewise.
* nptl/pthread_attr_setschedparam.c (__pthread_attr_setschedparam):
Likewise.
* nptl/pthread_attr_setschedpolicy.c (__pthread_attr_setschedpolicy):
Likewise.
* nptl/pthread_attr_setscope.c (__pthread_attr_setscope): Likewise.
* nptl/pthread_attr_setstack.c (__pthread_attr_setstack,
__old_pthread_attr_setstack): Likewise.
* nptl/pthread_attr_setstackaddr.c (__pthread_attr_setstackaddr):
Likewise.
* nptl/pthread_attr_setstacksize.c (__pthread_attr_setstacksize):
Likewise.
* nptl/pthread_getattr_default_np.c (pthread_getattr_default_np):
Likewise.
* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
* nptl/pthread_setattr_default_np.c (pthread_setattr_default_np):
Likewise.
* nptl/tst-typesizes.c: Remove file.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
37 files changed:
ChangeLog
nptl/pthreadP.h
nptl/pthread_attr_destroy.c
nptl/pthread_attr_getaffinity.c
nptl/pthread_attr_getdetachstate.c
nptl/pthread_attr_getguardsize.c
nptl/pthread_attr_getinheritsched.c
nptl/pthread_attr_getschedparam.c
nptl/pthread_attr_getschedpolicy.c
nptl/pthread_attr_getscope.c
nptl/pthread_attr_getstack.c
nptl/pthread_attr_getstackaddr.c
nptl/pthread_attr_getstacksize.c
nptl/pthread_attr_init.c
nptl/pthread_attr_setaffinity.c
nptl/pthread_attr_setdetachstate.c
nptl/pthread_attr_setguardsize.c
nptl/pthread_attr_setinheritsched.c
nptl/pthread_attr_setschedparam.c
nptl/pthread_attr_setschedpolicy.c
nptl/pthread_attr_setscope.c
nptl/pthread_attr_setstack.c
nptl/pthread_attr_setstackaddr.c
nptl/pthread_attr_setstacksize.c
nptl/pthread_barrier_init.c
nptl/pthread_barrierattr_init.c
nptl/pthread_cond_init.c
nptl/pthread_condattr_init.c
nptl/pthread_getattr_default_np.c
nptl/pthread_mutex_init.c
nptl/pthread_mutex_lock.c
nptl/pthread_mutexattr_init.c
nptl/pthread_rwlock_init.c
nptl/pthread_rwlockattr_init.c
nptl/pthread_setattr_default_np.c
nptl/sem_init.c
nptl/tst-typesizes.c [deleted file]

index 6715f677b68dbaf535418ba1ac7667745976a18e..d5cc4303daeb3021938303298a68730d4d83aac1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,65 @@
 2017-11-07  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+       * nptl/pthreadP.h (ASSERT_TYPE_SIZE, ASSERT_PTHREAD_INTERNAL_SIZE):
+       New macros.
+       * nptl/pthread_attr_init.c (__pthread_mutex_init): Add build time
+       checks for expected input type size.
+       * nptl/pthread_barrier_init.c (__pthread_barrier_init): Likewise.
+       * nptl/pthread_barrierattr_init.c (pthread_barrierattr_init):
+       Likewise.
+       * nptl/pthread_cond_init.c (__pthread_cond_init): Likewise.
+       * nptl/pthread_condattr_init.c (__pthread_condattr_init): Likewise.
+       * nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise.
+       * nptl/pthread_mutexattr_init.c (__pthread_mutexattr_init): Likewise.
+       * nptl/pthread_rwlock_init.c (__pthread_rwlock_init): Likewise.
+       * nptl/pthread_rwlockattr_init.c (pthread_rwlockattr_init): Likewise.
+       * nptl/sem_init.c (__new_sem_init, __old_sem_init): Likewise
+       * nptl/pthread_attr_destroy.c (__pthread_attr_destroy): Remove
+       superflous runtime assert check.
+       * nptl/pthread_attr_getaffinity.c (__pthread_attr_getaffinity_new):
+       Likewise.
+       * nptl/pthread_attr_getdetachstate.c (__pthread_attr_getdetachstate):
+       Likewise.
+       * nptl/pthread_attr_getguardsize.c (pthread_attr_getguardsize):
+       Likewise.
+       * nptl/pthread_attr_getinheritsched.c (__pthread_attr_getinheritsched):
+       Likewise.
+       * nptl/pthread_attr_getschedparam.c (__pthread_attr_getschedparam):
+       Likewise.
+       * nptl/pthread_attr_getschedpolicy.c (__pthread_attr_getschedpolicy):
+       Likewise.
+       * nptl/pthread_attr_getscope.c (__pthread_attr_getscope): Likewise.
+       * nptl/pthread_attr_getstack.c (__pthread_attr_getstack): Likewise.
+       * nptl/pthread_attr_getstackaddr.c (__pthread_attr_getstackaddr):
+       Likewise.
+       * nptl/pthread_attr_getstacksize.c (__pthread_attr_getstacksize):
+       Likewise.
+       * nptl/pthread_attr_setaffinity.c (__pthread_attr_setaffinity_new):
+       Likewise.
+       * nptl/pthread_attr_setdetachstate.c (__pthread_attr_setdetachstate):
+       Likewise.
+       * nptl/pthread_attr_setguardsize.c (pthread_attr_setguardsize):
+       Likewise.
+       * nptl/pthread_attr_setinheritsched.c
+       (__pthread_attr_setinheritsched): Likewise.
+       * nptl/pthread_attr_setschedparam.c (__pthread_attr_setschedparam):
+       Likewise.
+       * nptl/pthread_attr_setschedpolicy.c (__pthread_attr_setschedpolicy):
+       Likewise.
+       * nptl/pthread_attr_setscope.c (__pthread_attr_setscope): Likewise.
+       * nptl/pthread_attr_setstack.c (__pthread_attr_setstack,
+       __old_pthread_attr_setstack): Likewise.
+       * nptl/pthread_attr_setstackaddr.c (__pthread_attr_setstackaddr):
+       Likewise.
+       * nptl/pthread_attr_setstacksize.c (__pthread_attr_setstacksize):
+       Likewise.
+       * nptl/pthread_getattr_default_np.c (pthread_getattr_default_np):
+       Likewise.
+       * nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
+       * nptl/pthread_setattr_default_np.c (pthread_setattr_default_np):
+       Likewise.
+       * nptl/tst-typesizes.c: Remove file.
+
        * nptl/pthreadP.h (ASSERT_PTHREAD_STRING,
        ASSERT_PTHREAD_INTERNAL_OFFSET): New macro.
        * nptl/pthread_mutex_init.c (__pthread_mutex_init): Add build time
index ae1b88143b700791323b344a56aa9fcd21364865..1cc80b6e3a36da61bff97995eca2140ff88517d9 100644 (file)
@@ -639,6 +639,14 @@ check_stacksize_attr (size_t st)
   return EINVAL;
 }
 
+#define ASSERT_TYPE_SIZE(type, size)                                   \
+  _Static_assert (sizeof (type) == size,                               \
+                 "sizeof (" #type ") != " #size)
+
+#define ASSERT_PTHREAD_INTERNAL_SIZE(type, internal)                   \
+  _Static_assert (sizeof ((type) { 0 }).__size >= sizeof (internal),   \
+                 "sizeof (" #type ".__size) < sizeof (" #internal ")")
+
 #define ASSERT_PTHREAD_STRING(x) __STRING (x)
 #define ASSERT_PTHREAD_INTERNAL_OFFSET(type, member, offset)           \
   _Static_assert (offsetof (type, member) == offset,                   \
index a9ce51edd40f4bdbd2281d034d8a3737bd8d37bf..cdcdb4a988a09487206803285edf878323d83833 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
@@ -28,7 +27,6 @@ __pthread_attr_destroy (pthread_attr_t *attr)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
 #if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)
index b9d041ac60a396820123faf556ad0bd255361a5b..57ab56d3fefb7679832e61211d43239bfdbf3a68 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include <pthreadP.h>
 #include <string.h>
@@ -32,7 +31,6 @@ __pthread_attr_getaffinity_new (const pthread_attr_t *attr, size_t cpusetsize,
 {
   const struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (const struct pthread_attr *) attr;
 
   if (iattr->cpuset != NULL)
index 803a553bdc180243d51241bc8e6650e49f0f537c..0246ca81a4edf9d909474eb9def3ccec9f63248a 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include "pthreadP.h"
 
 
@@ -25,7 +24,6 @@ __pthread_attr_getdetachstate (const pthread_attr_t *attr, int *detachstate)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   *detachstate = (iattr->flags & ATTR_FLAG_DETACHSTATE
index b71be6c74eb017f68b6bc965240e86ef51a4a2a3..d6e01c7ef3eede0290ecbe35e28d34dc6af37971 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include "pthreadP.h"
 
 
@@ -25,7 +24,6 @@ pthread_attr_getguardsize (const pthread_attr_t *attr, size_t *guardsize)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   *guardsize = iattr->guardsize;
index 2dec2302d6ffee5d695a8bb642233d5d819542f5..1dc00ce2e7326e1bb218c635c093b45cc54daeb6 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include "pthreadP.h"
 
 
@@ -25,7 +24,6 @@ __pthread_attr_getinheritsched (const pthread_attr_t *attr, int *inherit)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Store the current values.  */
index 34f94089fef645e377aa71a4105aff28a88f9f62..86d07098056ab2e27bb95294bf3414dfe517f873 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <string.h>
 #include "pthreadP.h"
 
@@ -27,7 +26,6 @@ __pthread_attr_getschedparam (const pthread_attr_t *attr,
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Copy the current values.  */
index 65ed4176c7f927cb2435e0cf600d01f37576e268..f9f69be1f35209ebe6b51e17666125620ec4b812 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include "pthreadP.h"
 
 
@@ -25,7 +24,6 @@ __pthread_attr_getschedpolicy (const pthread_attr_t *attr, int *policy)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Store the current values.  */
index 7b36d6ad648c049805b747264fa8530d6107b712..ba5b5e393a889faa27e3198d6d89f0d72cc3cce5 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include "pthreadP.h"
 
 
@@ -25,7 +24,6 @@ __pthread_attr_getscope (const pthread_attr_t *attr, int *scope)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Store the current values.  */
index 79c78c63ea972c1e072139356367f30396cd78c5..9a80bfeeb93f2291807e0409d3b6433f884410c7 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include "pthreadP.h"
 
 
@@ -26,7 +25,6 @@ __pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr,
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Store the result.  */
index 69f0a7d97e6da65d1301dfebf3d91ebc5b346ff7..ef1a6333b85cf574d9b7c02e6f0b9fdd2dc59001 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include "pthreadP.h"
 
@@ -26,7 +25,6 @@ __pthread_attr_getstackaddr (const pthread_attr_t *attr, void **stackaddr)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Some code assumes this function to work even if no stack address
index 9f24d4df3978fa7f0f2f350ebe6143440b60645d..d9893cd3f2c7986d0bf99d565f197d0d6844539c 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include "pthreadP.h"
 
 
@@ -25,7 +24,6 @@ __pthread_attr_getstacksize (const pthread_attr_t *attr, size_t *stacksize)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   size_t size = iattr->stacksize;
index 77998ea9ac96d7f2937e57a74c7e9c1a25b3e150..eceaf85dbf0d7816721076ae1bc34c7f60bb8564 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
@@ -34,12 +33,14 @@ __pthread_attr_init_2_1 (pthread_attr_t *attr)
 {
   struct pthread_attr *iattr;
 
+  ASSERT_TYPE_SIZE (pthread_attr_t, __SIZEOF_PTHREAD_ATTR_T);
+  ASSERT_PTHREAD_INTERNAL_SIZE (pthread_attr_t, struct pthread_attr);
+
   /* Many elements are initialized to zero so let us do it all at
      once.  This also takes care of clearing the bytes which are not
      internally used.  */
   memset (attr, '\0', __SIZEOF_PTHREAD_ATTR_T);
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Default guard size specified by the standard.  */
index 497512eb9c2dde033c63834d755f0c05664542cf..f68449653b1e4b2afa45466d3c37377a82fc9beb 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdlib.h>
@@ -31,7 +30,6 @@ __pthread_attr_setaffinity_new (pthread_attr_t *attr, size_t cpusetsize,
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   if (cpuset == NULL || cpusetsize == 0)
index c6fb1bfc93917414bf09343b86917e97f22bd218..2659ce79f1e4064565a3940247f5b17ad8390320 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include "pthreadP.h"
 
@@ -26,7 +25,6 @@ __pthread_attr_setdetachstate (pthread_attr_t *attr, int detachstate)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Catch invalid values.  */
index 3927793da52402d96308862d5ddfc27db7c421d3..108b4a55c52c79b3adb9cc197dac169160e7e677 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include "pthreadP.h"
 
 
@@ -25,7 +24,6 @@ pthread_attr_setguardsize (pthread_attr_t *attr, size_t guardsize)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Note that we don't round the value here.  The standard requires
index 69a6335d2595c24364930f072651686229d0fa32..97aeb8d662beffcd86df7753c5999440c5fb3292 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include "pthreadP.h"
 
@@ -26,7 +25,6 @@ __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Catch invalid values.  */
index e38d1d8f0cce0772f50ecbfad700d832943a06b9..3eef9ad98fff44ae867299d4879300506418c721 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include <string.h>
 #include "pthreadP.h"
@@ -26,7 +25,6 @@ int
 __pthread_attr_setschedparam (pthread_attr_t *attr,
                              const struct sched_param *param)
 {
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   struct pthread_attr *iattr = (struct pthread_attr *) attr;
 
   int ret = check_sched_priority_attr (param->sched_priority,
index 868696d9508b9a567ba89e063a1699c4e93e5fc7..4f7c9b07d6c8a976a500506345d822ddf1ddb1bd 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include "pthreadP.h"
 
@@ -26,7 +25,6 @@ __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Catch invalid values.  */
index e0fd1dd9bd95f6a3684ed992a6de4a2a750049c5..bca0ffb3bfa0fb7969d1969ea45cf9762213a5ef 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include "pthreadP.h"
 
@@ -26,7 +25,6 @@ __pthread_attr_setscope (pthread_attr_t *attr, int scope)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Catch invalid values.  */
index e4f8b2956f1b9f3b62d0c4230e8626ff371a3ab8..cb558f5ae7e952be7b930e6b06adf604ad7a2a3a 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include "pthreadP.h"
@@ -33,7 +32,6 @@ __pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr,
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Catch invalid sizes.  */
@@ -71,7 +69,6 @@ __old_pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr,
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Catch invalid sizes.  */
index ac16f941c604a363a8192404789acc938d3b95f6..78370d85364efbd98f25c9b7a1148c8e4d92351d 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include "pthreadP.h"
 
@@ -30,7 +29,6 @@ __pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr)
   EXTRA_PARAM_CHECKS;
 #endif
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   iattr->stackaddr = stackaddr;
index 4c0abace902ac31cb5003a4c4bc9742bc0f90919..ed8999fa52858e3fc3eec9685971ffe28a7f88e5 100644 (file)
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include "pthreadP.h"
@@ -31,7 +30,6 @@ __pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Catch invalid sizes.  */
@@ -58,7 +56,6 @@ __old_pthread_attr_setstacksize (pthread_attr_t *attr, size_t stacksize)
 {
   struct pthread_attr *iattr;
 
-  assert (sizeof (*attr) >= sizeof (struct pthread_attr));
   iattr = (struct pthread_attr *) attr;
 
   /* Catch invalid sizes.  */
index 9c851fbb32bac826a8e6e3c7e3447cfcccf501f7..bdbd10c14a16ad7b525f2aac0ac05f1a5d14ae02 100644 (file)
@@ -32,6 +32,10 @@ int
 __pthread_barrier_init (pthread_barrier_t *barrier,
                        const pthread_barrierattr_t *attr, unsigned int count)
 {
+  ASSERT_TYPE_SIZE (pthread_barrier_t, __SIZEOF_PTHREAD_BARRIER_T);
+  ASSERT_PTHREAD_INTERNAL_SIZE (pthread_barrier_t,
+                               struct pthread_barrier);
+
   struct pthread_barrier *ibarrier;
 
   /* XXX EINVAL is not specified by POSIX as a possible error code for COUNT
index 796652ebe2312d1ec045e6c8bb52e3c83fb8d008..81a6f5c38887d1d86755941a5be8eb1d7de11085 100644 (file)
 int
 pthread_barrierattr_init (pthread_barrierattr_t *attr)
 {
+  ASSERT_TYPE_SIZE (pthread_barrierattr_t, __SIZEOF_PTHREAD_BARRIERATTR_T);
+  ASSERT_PTHREAD_INTERNAL_SIZE (pthread_barrierattr_t,
+                               struct pthread_barrierattr);
+
   ((struct pthread_barrierattr *) attr)->pshared = PTHREAD_PROCESS_PRIVATE;
 
   return 0;
index 0387f00ad0516d53b1abe5c4b5bcc2f1f79ea3bc..d23cdb13169372c8c41529cb123a166ba63567b5 100644 (file)
@@ -26,6 +26,8 @@
 int
 __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *cond_attr)
 {
+  ASSERT_TYPE_SIZE (pthread_cond_t, __SIZEOF_PTHREAD_COND_T);
+
   struct pthread_condattr *icond_attr = (struct pthread_condattr *) cond_attr;
 
   memset (cond, 0, sizeof (pthread_cond_t));
index 47bcc8bfdeec705671d79713863614a4b18e577b..0896abecef58a19c8f9a9b1dd6e08c8f98e8bc0f 100644 (file)
 int
 __pthread_condattr_init (pthread_condattr_t *attr)
 {
+  ASSERT_TYPE_SIZE (pthread_condattr_t, __SIZEOF_PTHREAD_CONDATTR_T);
+  ASSERT_PTHREAD_INTERNAL_SIZE (pthread_condattr_t,
+                               struct pthread_condattr);
+
   struct pthread_condattr *iattr = (struct pthread_condattr *) attr;
   /* Default is not pshared and CLOCK_REALTIME.  */
   iattr-> value = CLOCK_REALTIME << 1;
index 771c06b386574d8d23a96daf8d3fea91e400948e..3357b7319b573682a379f1e6fffd76c66fff638d 100644 (file)
 #include <errno.h>
 #include <stdlib.h>
 #include <pthreadP.h>
-#include <assert.h>
 
 int
 pthread_getattr_default_np (pthread_attr_t *out)
 {
   struct pthread_attr *real_out;
 
-  assert (sizeof (*out) >= sizeof (struct pthread_attr));
   real_out = (struct pthread_attr *) out;
 
   lll_lock (__default_pthread_attr_lock, LLL_PRIVATE);
index e1f911bf29b6544ad4471c6f6d82ec953241c285..a965722791777593fd9ee6904543fb8ea4ffc6d7 100644 (file)
@@ -58,7 +58,8 @@ __pthread_mutex_init (pthread_mutex_t *mutex,
 {
   const struct pthread_mutexattr *imutexattr;
 
-  assert (sizeof (pthread_mutex_t) <= __SIZEOF_PTHREAD_MUTEX_T);
+  ASSERT_TYPE_SIZE (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T);
+
   ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__nusers,
                                  __PTHREAD_MUTEX_NUSERS_OFFSET);
   ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__kind,
index 7f8254ba33c7721da082af9361a0f48f13c351a4..1acbe43005187ad8041929e40e79af452e847380 100644 (file)
@@ -62,8 +62,6 @@ static int __pthread_mutex_lock_full (pthread_mutex_t *mutex)
 int
 __pthread_mutex_lock (pthread_mutex_t *mutex)
 {
-  assert (sizeof (mutex->__size) >= sizeof (mutex->__data));
-
   unsigned int type = PTHREAD_MUTEX_TYPE_ELISION (mutex);
 
   LIBC_PROBE (mutex_entry, 1, mutex);
index dcad522ae8a54f602a47d13e0252faa5ad9181a2..63ade028f5cbd3b06b0f27feed44d0066997e9ed 100644 (file)
 int
 __pthread_mutexattr_init (pthread_mutexattr_t *attr)
 {
+  ASSERT_TYPE_SIZE (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T);
+  ASSERT_PTHREAD_INTERNAL_SIZE (pthread_mutexattr_t,
+                               struct pthread_mutexattr);
+
   if (sizeof (struct pthread_mutexattr) != sizeof (pthread_mutexattr_t))
     memset (attr, '\0', sizeof (*attr));
 
index 764ba110fbf50a726570b7f4c5fe7d56c042c6fd..c64e49fffdb9d80517e78858e59b65c160915e05 100644 (file)
@@ -32,6 +32,8 @@ int
 __pthread_rwlock_init (pthread_rwlock_t *rwlock,
                       const pthread_rwlockattr_t *attr)
 {
+  ASSERT_TYPE_SIZE (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T);
+
   const struct pthread_rwlockattr *iattr;
 
   iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_rwlockattr;
index 8d90647db043b53b38902d078b2b611a524c0e19..32a33cdd6e173eaec4d0c36dd2fa504403eed696 100644 (file)
 int
 pthread_rwlockattr_init (pthread_rwlockattr_t *attr)
 {
+  ASSERT_TYPE_SIZE (pthread_rwlockattr_t, __SIZEOF_PTHREAD_RWLOCKATTR_T);
+  ASSERT_PTHREAD_INTERNAL_SIZE (pthread_rwlockattr_t,
+                               struct pthread_rwlockattr);
+
   struct pthread_rwlockattr *iattr;
 
   iattr = (struct pthread_rwlockattr *) attr;
index dd1b6fc915f42c92746b0c3f294a746f2fab0ab0..2fb787db00fa01d3773dc73e37da8e429bc62274 100644 (file)
@@ -19,7 +19,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <pthreadP.h>
-#include <assert.h>
 #include <string.h>
 
 
@@ -30,7 +29,6 @@ pthread_setattr_default_np (const pthread_attr_t *in)
   struct pthread_attr attrs;
   int ret;
 
-  assert (sizeof (*in) >= sizeof (struct pthread_attr));
   real_in = (struct pthread_attr *) in;
 
   /* Catch invalid values.  */
index b9b839cd64ee79aa30b247b06bbeb79dacf474b6..87cadeb3af6236d75e6b184f6b5c800ee8e4ff2e 100644 (file)
@@ -27,6 +27,8 @@
 int
 __new_sem_init (sem_t *sem, int pshared, unsigned int value)
 {
+  ASSERT_PTHREAD_INTERNAL_SIZE (sem_t, struct new_sem);
+
   /* Parameter sanity check.  */
   if (__glibc_unlikely (value > SEM_VALUE_MAX))
     {
@@ -68,6 +70,8 @@ int
 attribute_compat_text_section
 __old_sem_init (sem_t *sem, int pshared, unsigned int value)
 {
+  ASSERT_PTHREAD_INTERNAL_SIZE (sem_t, struct new_sem);
+
   /* Parameter sanity check.  */
   if (__glibc_unlikely (value > SEM_VALUE_MAX))
     {
diff --git a/nptl/tst-typesizes.c b/nptl/tst-typesizes.c
deleted file mode 100644 (file)
index 78ed773..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright (C) 2005-2017 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@redhat.com>, 2005.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <stdio.h>
-#include <pthreadP.h>
-#include <semaphore.h>
-
-static const struct
-{
-  const char *name;
-  size_t expected;
-  size_t is;
-} types[] =
-  {
-#define T(t, c) \
-    { #t, c, sizeof (t) }
-    T (pthread_attr_t, __SIZEOF_PTHREAD_ATTR_T),
-    T (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T),
-    T (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T),
-    T (pthread_cond_t, __SIZEOF_PTHREAD_COND_T),
-    T (pthread_condattr_t, __SIZEOF_PTHREAD_CONDATTR_T),
-    T (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T),
-    T (pthread_rwlockattr_t, __SIZEOF_PTHREAD_RWLOCKATTR_T),
-    T (pthread_barrier_t, __SIZEOF_PTHREAD_BARRIER_T),
-    T (pthread_barrierattr_t, __SIZEOF_PTHREAD_BARRIERATTR_T)
-  };
-
-static int
-do_test (void)
-{
-  int result = 0;
-
-#define TEST_TYPE(name) \
-  printf ("%s: ", #name);                                                    \
-  if (sizeof (name) != sizeof (((name *) 0)->__size))                        \
-    {                                                                        \
-      printf ("expected %zu, is %zu\n",                                              \
-             sizeof (((name *) 0)->__size), sizeof (name));                  \
-      result = 1;                                                            \
-    }                                                                        \
-  else                                                                       \
-    puts ("OK")
-
-  TEST_TYPE (pthread_mutex_t);
-  TEST_TYPE (pthread_cond_t);
-  TEST_TYPE (pthread_rwlock_t);
-
-#define TEST_TYPE2(name, internal)                                           \
-  printf ("%s: ", #name);                                                    \
-  if (sizeof (((name *) 0)->__size) < sizeof (internal))                     \
-    {                                                                        \
-      printf ("expected %zu, is %zu\n",                                              \
-             sizeof (((name *) 0)->__size), sizeof (internal));              \
-      result = 1;                                                            \
-    }                                                                        \
-  else                                                                       \
-    puts ("OK")
-
-  TEST_TYPE2 (pthread_attr_t, struct pthread_attr);
-  TEST_TYPE2 (pthread_mutexattr_t, struct pthread_mutexattr);
-  TEST_TYPE2 (pthread_condattr_t, struct pthread_condattr);
-  TEST_TYPE2 (pthread_rwlockattr_t, struct pthread_rwlockattr);
-  TEST_TYPE2 (pthread_barrier_t, struct pthread_barrier);
-  TEST_TYPE2 (pthread_barrierattr_t, struct pthread_barrierattr);
-  TEST_TYPE2 (sem_t, struct new_sem);
-  TEST_TYPE2 (sem_t, struct old_sem);
-
-  for (size_t i = 0; i < sizeof (types) / sizeof (types[0]); ++i)
-    if (types[i].expected != types[i].is)
-      {
-       printf ("%s: expected %zu, is %zu\n",
-               types[i].name, types[i].expected, types[i].is);
-       result = 1;
-      }
-
-  return result;
-}
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"