文章详情

pthread所有结构类型

  /* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.

  This file is part of the GNU C Library.

  Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.

  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, write to the Free

  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA

  02111-1307 USA.  */

  #ifndef _BITS_PTHREADTYPES_H

  #define _BITS_PTHREADTYPES_H1

  #include <bits/wordsize.h>

  #if __WORDSIZE == 64

  # define __SIZEOF_PTHREAD_ATTR_T 56

  # define __SIZEOF_PTHREAD_MUTEX_T 40

  # define __SIZEOF_PTHREAD_MUTEXATTR_T 4

  # define __SIZEOF_PTHREAD_COND_T 48

  # define __SIZEOF_PTHREAD_CONDATTR_T 4

  # define __SIZEOF_PTHREAD_RWLOCK_T 56

  # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8

  # define __SIZEOF_PTHREAD_BARRIER_T 32

  # define __SIZEOF_PTHREAD_BARRIERATTR_T 4

  #else

  # define __SIZEOF_PTHREAD_ATTR_T 36

  # define __SIZEOF_PTHREAD_MUTEX_T 24

  # define __SIZEOF_PTHREAD_MUTEXATTR_T 4

  # define __SIZEOF_PTHREAD_COND_T 48

  # define __SIZEOF_PTHREAD_CONDATTR_T 4

  # define __SIZEOF_PTHREAD_RWLOCK_T 32

  # define __SIZEOF_PTHREAD_RWLOCKATTR_T 8

  # define __SIZEOF_PTHREAD_BARRIER_T 20

  # define __SIZEOF_PTHREAD_BARRIERATTR_T 4

  #endif

  /* Thread identifiers.  The structure of the attribute type is not

  exposed on purpose.  */

  typedef unsigned long int pthread_t;

  typedef union

  {

  char __size[__SIZEOF_PTHREAD_ATTR_T];

  long int __align;

  } pthread_attr_t;

  #if __WORDSIZE == 64

  typedef struct __pthread_internal_list

  {

  struct __pthread_internal_list *__prev;

  struct __pthread_internal_list *__next;

  } __pthread_list_t;

  #else

  typedef struct __pthread_internal_slist

  {

  struct __pthread_internal_slist *__next;

  } __pthread_slist_t;

  #endif

  /* Data structures for mutex handling.  The structure of the attribute

  type is not exposed on purpose.  */

  typedef union

  {

  struct __pthread_mutex_s

  {

  int __lock;

  unsigned int __count;

  int __owner;

  #if __WORDSIZE == 64

  unsigned int __nusers;

  #endif

  /* KIND must stay at this position in the structure to maintain

  binary compatibility.  */

  int __kind;

  #if __WORDSIZE == 64

  int __spins;

  __pthread_list_t __list;

  # define __PTHREAD_MUTEX_HAVE_PREV1

  #else

  unsigned int __nusers;

  __extension__ union

  {

  int __spins;

  __pthread_slist_t __list;

  };

  #endif

  } __data;

  char __size[__SIZEOF_PTHREAD_MUTEX_T];

  long int __align;

  } pthread_mutex_t;

  typedef union

  {

  char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];

  int __align;

  } pthread_mutexattr_t;

  

博聚网