From 4b2c85c0b9a04b0ca4e4d031a5b92b2160f17bc3 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 26 May 2008 17:02:55 +0000 Subject: [PATCH] * tst-typesizes.c: Explicitly check __SIZEOF_PTHREAD_* constants. David S. Miller --- nptl/ChangeLog | 7 ++++++- nptl/tst-typesizes.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/nptl/ChangeLog b/nptl/ChangeLog index a22016f..0ca98b8 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,5 +1,10 @@ +2008-05-26 Ulrich Drepper + + * tst-typesizes.c: Explicitly check __SIZEOF_PTHREAD_* constants. + 2008-05-20 Jakub Jelinek - David S. Miller + + David S. Miller * sysdeps/unix/sysv/linux/sparc/sparc64/Makefile: New file. diff --git a/nptl/tst-typesizes.c b/nptl/tst-typesizes.c index 17a1e29..545cee6 100644 --- a/nptl/tst-typesizes.c +++ b/nptl/tst-typesizes.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2005. @@ -21,6 +21,25 @@ #include #include +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) @@ -62,6 +81,14 @@ do_test (void) 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; } -- 2.7.4