Back to index

glibc  2.9
tst-initializers1.c
Go to the documentation of this file.
00001 /* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 /* We test the code undef conditions outside of glibc.  */
00021 #undef _LIBC
00022 
00023 #include <pthread.h>
00024 
00025 pthread_mutex_t mtx_normal = PTHREAD_MUTEX_INITIALIZER;
00026 pthread_mutex_t mtx_recursive = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
00027 pthread_mutex_t mtx_errorchk = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
00028 pthread_mutex_t mtx_adaptive = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
00029 pthread_rwlock_t rwl_normal = PTHREAD_RWLOCK_INITIALIZER;
00030 pthread_rwlock_t rwl_writer
00031   = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
00032 pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
00033 
00034 int
00035 main (void)
00036 {
00037   if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP)
00038     return 1;
00039   if (mtx_recursive.__data.__kind != PTHREAD_MUTEX_RECURSIVE_NP)
00040     return 2;
00041   if (mtx_errorchk.__data.__kind != PTHREAD_MUTEX_ERRORCHECK_NP)
00042     return 3;
00043   if (mtx_adaptive.__data.__kind != PTHREAD_MUTEX_ADAPTIVE_NP)
00044     return 4;
00045   if (rwl_normal.__data.__flags != PTHREAD_RWLOCK_PREFER_READER_NP)
00046     return 5;
00047   if (rwl_writer.__data.__flags
00048       != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
00049     return 6;
00050   /* <bits/libc-lock.h> __libc_rwlock_init definition for libc.so
00051      relies on PTHREAD_RWLOCK_INITIALIZER being all zeros.  If
00052      that ever changes, <bits/libc-lock.h> needs updating.  */
00053   size_t i;
00054   for (i = 0; i < sizeof (rwl_normal); i++)
00055     if (((char *) &rwl_normal)[i] != '\0')
00056       return 7;
00057   return 0;
00058 }