|
Packit |
6c4009 |
/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef _INTERNALTYPES_H
|
|
Packit |
6c4009 |
#define _INTERNALTYPES_H 1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <stdint.h>
|
|
Packit |
6c4009 |
#include <atomic.h>
|
|
Packit |
6c4009 |
#include <endian.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
struct pthread_attr
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* Scheduler parameters and priority. */
|
|
Packit |
6c4009 |
struct sched_param schedparam;
|
|
Packit |
6c4009 |
int schedpolicy;
|
|
Packit |
6c4009 |
/* Various flags like detachstate, scope, etc. */
|
|
Packit |
6c4009 |
int flags;
|
|
Packit |
6c4009 |
/* Size of guard area. */
|
|
Packit |
6c4009 |
size_t guardsize;
|
|
Packit |
6c4009 |
/* Stack handling. */
|
|
Packit |
6c4009 |
void *stackaddr;
|
|
Packit |
6c4009 |
size_t stacksize;
|
|
Packit |
6c4009 |
/* Affinity map. */
|
|
Packit |
6c4009 |
cpu_set_t *cpuset;
|
|
Packit |
6c4009 |
size_t cpusetsize;
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define ATTR_FLAG_DETACHSTATE 0x0001
|
|
Packit |
6c4009 |
#define ATTR_FLAG_NOTINHERITSCHED 0x0002
|
|
Packit |
6c4009 |
#define ATTR_FLAG_SCOPEPROCESS 0x0004
|
|
Packit |
6c4009 |
#define ATTR_FLAG_STACKADDR 0x0008
|
|
Packit |
6c4009 |
#define ATTR_FLAG_OLDATTR 0x0010
|
|
Packit |
6c4009 |
#define ATTR_FLAG_SCHED_SET 0x0020
|
|
Packit |
6c4009 |
#define ATTR_FLAG_POLICY_SET 0x0040
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Mutex attribute data structure. */
|
|
Packit |
6c4009 |
struct pthread_mutexattr
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* Identifier for the kind of mutex.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Bit 31 is set if the mutex is to be shared between processes.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
|
|
Packit |
6c4009 |
the type of the mutex. */
|
|
Packit |
6c4009 |
int mutexkind;
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Conditional variable attribute data structure. */
|
|
Packit |
6c4009 |
struct pthread_condattr
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* Combination of values:
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
Bit 0 : flag whether conditional variable will be
|
|
Packit |
6c4009 |
sharable between processes.
|
|
Packit |
6c4009 |
Bit 1-COND_CLOCK_BITS: Clock ID. COND_CLOCK_BITS is the number of bits
|
|
Packit |
6c4009 |
needed to represent the ID of the clock. */
|
|
Packit |
6c4009 |
int value;
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
#define COND_CLOCK_BITS 1
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Read-write lock variable attribute data structure. */
|
|
Packit |
6c4009 |
struct pthread_rwlockattr
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
int lockkind;
|
|
Packit |
6c4009 |
int pshared;
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Barrier data structure. See pthread_barrier_wait for a description
|
|
Packit |
6c4009 |
of how these fields are used. */
|
|
Packit |
6c4009 |
struct pthread_barrier
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
unsigned int in;
|
|
Packit |
6c4009 |
unsigned int current_round;
|
|
Packit |
6c4009 |
unsigned int count;
|
|
Packit |
6c4009 |
int shared;
|
|
Packit |
6c4009 |
unsigned int out;
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
/* See pthread_barrier_wait for a description. */
|
|
Packit |
6c4009 |
#define BARRIER_IN_THRESHOLD (UINT_MAX/2)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Barrier variable attribute data structure. */
|
|
Packit |
6c4009 |
struct pthread_barrierattr
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
int pshared;
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Thread-local data handling. */
|
|
Packit |
6c4009 |
struct pthread_key_struct
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
/* Sequence numbers. Even numbers indicated vacant entries. Note
|
|
Packit |
6c4009 |
that zero is even. We use uintptr_t to not require padding on
|
|
Packit |
6c4009 |
32- and 64-bit machines. On 64-bit machines it helps to avoid
|
|
Packit |
6c4009 |
wrapping, too. */
|
|
Packit |
6c4009 |
uintptr_t seq;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Destructor for the data. */
|
|
Packit |
6c4009 |
void (*destr) (void *);
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Check whether an entry is unused. */
|
|
Packit |
6c4009 |
#define KEY_UNUSED(p) (((p) & 1) == 0)
|
|
Packit |
6c4009 |
/* Check whether a key is usable. We cannot reuse an allocated key if
|
|
Packit |
6c4009 |
the sequence counter would overflow after the next destroy call.
|
|
Packit |
6c4009 |
This would mean that we potentially free memory for a key with the
|
|
Packit |
6c4009 |
same sequence. This is *very* unlikely to happen, A program would
|
|
Packit |
6c4009 |
have to create and destroy a key 2^31 times (on 32-bit platforms,
|
|
Packit |
6c4009 |
on 64-bit platforms that would be 2^63). If it should happen we
|
|
Packit |
6c4009 |
simply don't use this specific key anymore. */
|
|
Packit |
6c4009 |
#define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Handling of read-write lock data. */
|
|
Packit |
6c4009 |
// XXX For now there is only one flag. Maybe more in future.
|
|
Packit |
6c4009 |
#define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Semaphore variable structure. */
|
|
Packit |
6c4009 |
struct new_sem
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
#if __HAVE_64B_ATOMICS
|
|
Packit |
6c4009 |
/* The data field holds both value (in the least-significant 32 bits) and
|
|
Packit |
6c4009 |
nwaiters. */
|
|
Packit |
6c4009 |
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
Packit |
6c4009 |
# define SEM_VALUE_OFFSET 0
|
|
Packit |
6c4009 |
# elif __BYTE_ORDER == __BIG_ENDIAN
|
|
Packit |
6c4009 |
# define SEM_VALUE_OFFSET 1
|
|
Packit |
6c4009 |
# else
|
|
Packit |
6c4009 |
# error Unsupported byte order.
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
# define SEM_NWAITERS_SHIFT 32
|
|
Packit |
6c4009 |
# define SEM_VALUE_MASK (~(unsigned int)0)
|
|
Packit |
6c4009 |
uint64_t data;
|
|
Packit |
6c4009 |
int private;
|
|
Packit |
6c4009 |
int pad;
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define SEM_VALUE_SHIFT 1
|
|
Packit |
6c4009 |
# define SEM_NWAITERS_MASK ((unsigned int)1)
|
|
Packit |
6c4009 |
unsigned int value;
|
|
Packit |
6c4009 |
int private;
|
|
Packit |
6c4009 |
int pad;
|
|
Packit |
6c4009 |
unsigned int nwaiters;
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
struct old_sem
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
unsigned int value;
|
|
Packit |
6c4009 |
};
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Compatibility type for old conditional variable interfaces. */
|
|
Packit |
6c4009 |
typedef struct
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
pthread_cond_t *cond;
|
|
Packit |
6c4009 |
} pthread_cond_2_0_t;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* internaltypes.h */
|