Blame nptl/tst-initializers1.c

Packit Service 82fcde
/* Copyright (C) 2005-2018 Free Software Foundation, Inc.
Packit Service 82fcde
   This file is part of the GNU C Library.
Packit Service 82fcde
   Contributed by Jakub Jelinek <jakub@redhat.com>, 2005.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 82fcde
   modify it under the terms of the GNU Lesser General Public
Packit Service 82fcde
   License as published by the Free Software Foundation; either
Packit Service 82fcde
   version 2.1 of the License, or (at your option) any later version.
Packit Service 82fcde
Packit Service 82fcde
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 82fcde
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 82fcde
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 82fcde
   Lesser General Public License for more details.
Packit Service 82fcde
Packit Service 82fcde
   You should have received a copy of the GNU Lesser General Public
Packit Service 82fcde
   License along with the GNU C Library; if not, see
Packit Service 82fcde
   <http://www.gnu.org/licenses/>.  */
Packit Service 82fcde
Packit Service 82fcde
/* We test the code undef conditions outside of glibc.  */
Packit Service 82fcde
#undef _LIBC
Packit Service 82fcde
Packit Service 82fcde
#include <pthread.h>
Packit Service 82fcde
Packit Service 82fcde
pthread_mutex_t mtx_normal = PTHREAD_MUTEX_INITIALIZER;
Packit Service 82fcde
pthread_mutex_t mtx_recursive = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
Packit Service 82fcde
pthread_mutex_t mtx_errorchk = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP;
Packit Service 82fcde
pthread_mutex_t mtx_adaptive = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
Packit Service 82fcde
pthread_rwlock_t rwl_normal = PTHREAD_RWLOCK_INITIALIZER;
Packit Service 82fcde
pthread_rwlock_t rwl_writer
Packit Service 82fcde
  = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP;
Packit Service 82fcde
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
Packit Service 82fcde
Packit Service 82fcde
static int
Packit Service 82fcde
do_test (void)
Packit Service 82fcde
{
Packit Service 82fcde
  if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP)
Packit Service 82fcde
    return 1;
Packit Service 82fcde
  if (mtx_recursive.__data.__kind != PTHREAD_MUTEX_RECURSIVE_NP)
Packit Service 82fcde
    return 2;
Packit Service 82fcde
  if (mtx_errorchk.__data.__kind != PTHREAD_MUTEX_ERRORCHECK_NP)
Packit Service 82fcde
    return 3;
Packit Service 82fcde
  if (mtx_adaptive.__data.__kind != PTHREAD_MUTEX_ADAPTIVE_NP)
Packit Service 82fcde
    return 4;
Packit Service 82fcde
  if (rwl_normal.__data.__flags != PTHREAD_RWLOCK_PREFER_READER_NP)
Packit Service 82fcde
    return 5;
Packit Service 82fcde
  if (rwl_writer.__data.__flags
Packit Service 82fcde
      != PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP)
Packit Service 82fcde
    return 6;
Packit Service 82fcde
  /* <libc-lock.h> __libc_rwlock_init definition for libc.so
Packit Service 82fcde
     relies on PTHREAD_RWLOCK_INITIALIZER being all zeros.  If
Packit Service 82fcde
     that ever changes, <libc-lock.h> needs updating.  */
Packit Service 82fcde
  size_t i;
Packit Service 82fcde
  for (i = 0; i < sizeof (rwl_normal); i++)
Packit Service 82fcde
    if (((char *) &rwl_normal)[i] != '\0')
Packit Service 82fcde
      return 7;
Packit Service 82fcde
  return 0;
Packit Service 82fcde
}
Packit Service 82fcde
Packit Service 82fcde
#define TEST_FUNCTION do_test ()
Packit Service 82fcde
#include "../test-skeleton.c"