2007-03-20 17:51:12 +01:00
|
|
|
/********************************************************************************
|
2011-03-31 03:42:50 +02:00
|
|
|
* include/pthread.h
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2017-03-26 18:35:23 +02:00
|
|
|
* Copyright (C) 2007-2009, 2011-2012, 2015-2017 Gregory Nutt. All rights reserved.
|
2012-04-04 15:01:14 +02:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
2008-01-30 22:59:12 +01:00
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
2007-02-18 00:21:28 +01:00
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2007-03-20 17:51:12 +01:00
|
|
|
********************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2011-03-31 03:42:50 +02:00
|
|
|
#ifndef __INCLUDE_PTHREAD_H
|
|
|
|
#define __INCLUDE_PTHREAD_H
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/********************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2007-03-20 17:51:12 +01:00
|
|
|
********************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-11-03 01:21:46 +01:00
|
|
|
#include <nuttx/config.h> /* Default settings */
|
|
|
|
#include <nuttx/compiler.h> /* Compiler settings, noreturn_function */
|
2009-12-15 00:32:23 +01:00
|
|
|
|
2016-11-03 01:21:46 +01:00
|
|
|
#include <sys/types.h> /* Needed for general types */
|
|
|
|
#include <sys/prctl.h> /* Needed by pthread_[set|get]name_np */
|
2012-12-21 22:30:33 +01:00
|
|
|
|
2016-11-03 01:21:46 +01:00
|
|
|
#include <stdint.h> /* C99 fixed width integer types */
|
|
|
|
#include <stdbool.h> /* C99 boolean types */
|
|
|
|
#include <unistd.h> /* For getpid */
|
|
|
|
#include <signal.h> /* Needed for sigset_t, includes this file */
|
|
|
|
#include <time.h> /* Needed for struct timespec */
|
|
|
|
|
|
|
|
#include <nuttx/semaphore.h> /* For sem_t and SEM_PRIO_* defines */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/********************************************************************************
|
2014-09-28 18:15:33 +02:00
|
|
|
* Pre-processor Definitions
|
2007-03-20 17:51:12 +01:00
|
|
|
********************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Standard POSIX switches */
|
|
|
|
|
|
|
|
#ifndef _POSIX_THREADS
|
2012-12-21 22:30:33 +01:00
|
|
|
# define _POSIX_THREADS
|
2007-02-18 00:21:28 +01:00
|
|
|
#endif
|
2012-12-21 22:30:33 +01:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
#ifndef _POSIX_THREAD_ATTR_STACKSIZE
|
2012-12-21 22:30:33 +01:00
|
|
|
# define _POSIX_THREAD_ATTR_STACKSIZE
|
2007-02-18 00:21:28 +01:00
|
|
|
#endif
|
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
/* Values for the process shared (pshared) attribute */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
#define PTHREAD_PROCESS_PRIVATE 0
|
|
|
|
#define PTHREAD_PROCESS_SHARED 1
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-05-31 19:13:08 +02:00
|
|
|
/* Values for the mutext type attribute:
|
|
|
|
*
|
|
|
|
* PTHREAD_MUTEX_NORMAL: This type of mutex does not detect deadlock. A thread
|
|
|
|
* attempting to relock this mutex without first unlocking it will deadlock.
|
|
|
|
* Attempting to unlock a mutex locked by a different thread results in undefined
|
2014-04-13 22:32:20 +02:00
|
|
|
* behavior. Attempting to unlock an unlocked mutex results in undefined behavior.
|
2008-05-31 19:13:08 +02:00
|
|
|
* PTHREAD_MUTEX_ERRORCHECK
|
|
|
|
* This type of mutex provides error checking. A thread attempting to relock this
|
|
|
|
* mutex without first unlocking it will return with an error. A thread attempting
|
|
|
|
* to unlock a mutex which another thread has locked will return with an error. A
|
|
|
|
* thread attempting to unlock an unlocked mutex will return with an error.
|
|
|
|
* PTHREAD_MUTEX_RECURSIVE
|
|
|
|
* A thread attempting to relock this mutex without first unlocking it will succeed
|
|
|
|
* in locking the mutex. The relocking deadlock which can occur with mutexes of type
|
|
|
|
* PTHREAD_MUTEX_NORMAL cannot occur with this type of mutex. Multiple locks of this
|
|
|
|
* mutex require the same number of unlocks to release the mutex before another thread
|
|
|
|
* can acquire the mutex. A thread attempting to unlock a mutex which another thread
|
|
|
|
* has locked will return with an error. A thread attempting to unlock an unlocked
|
2014-04-13 22:32:20 +02:00
|
|
|
* mutex will return with an error.
|
2008-05-31 19:13:08 +02:00
|
|
|
* PTHREAD_MUTEX_DEFAULT
|
|
|
|
* An implementation is allowed to map this mutex to one of the other mutex types.
|
|
|
|
*/
|
|
|
|
|
2016-11-05 18:06:52 +01:00
|
|
|
#define PTHREAD_MUTEX_NORMAL 0
|
|
|
|
#define PTHREAD_MUTEX_ERRORCHECK 1
|
|
|
|
#define PTHREAD_MUTEX_RECURSIVE 2
|
|
|
|
#define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL
|
2008-05-31 19:13:08 +02:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
/* Valid ranges for the pthread stacksize attribute */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
#define PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN
|
|
|
|
#define PTHREAD_STACK_DEFAULT CONFIG_PTHREAD_STACK_DEFAULT
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
/* Values for the pthread inheritsched attribute */
|
|
|
|
|
|
|
|
#define PTHREAD_INHERIT_SCHED 0
|
|
|
|
#define PTHREAD_EXPLICIT_SCHED 1
|
|
|
|
|
2016-11-03 01:21:46 +01:00
|
|
|
/* Default priority */
|
2007-03-24 00:22:22 +01:00
|
|
|
|
|
|
|
#define PTHREAD_DEFAULT_PRIORITY 100
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-12-09 14:23:00 +01:00
|
|
|
/* Cancellation states used by pthread_setcancelstate() */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
#define PTHREAD_CANCEL_ENABLE (0)
|
|
|
|
#define PTHREAD_CANCEL_DISABLE (1)
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-12-09 14:23:00 +01:00
|
|
|
/* Cancellation types used by pthread_setcanceltype() */
|
|
|
|
|
|
|
|
#define PTHREAD_CANCEL_DEFERRED (0)
|
|
|
|
#define PTHREAD_CANCEL_ASYNCHRONOUS (1)
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
/* Thread return value when a pthread is canceled */
|
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
#define PTHREAD_CANCELED ((FAR void*)ERROR)
|
|
|
|
|
|
|
|
/* Used to initialize a pthread_once_t */
|
|
|
|
|
2009-12-15 00:32:23 +01:00
|
|
|
#define PTHREAD_ONCE_INIT (false)
|
2007-03-24 00:22:22 +01:00
|
|
|
|
|
|
|
/* This is returned by pthread_wait. It must not match any errno in errno.h */
|
|
|
|
|
|
|
|
#define PTHREAD_BARRIER_SERIAL_THREAD 0x1000
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-11-03 01:21:46 +01:00
|
|
|
/* Values for protocol mutex attribute */
|
2016-11-02 16:05:18 +01:00
|
|
|
|
|
|
|
#define PTHREAD_PRIO_NONE SEM_PRIO_NONE
|
|
|
|
#define PTHREAD_PRIO_INHERIT SEM_PRIO_INHERIT
|
|
|
|
#define PTHREAD_PRIO_PROTECT SEM_PRIO_PROTECT
|
|
|
|
|
2017-03-27 02:37:24 +02:00
|
|
|
/* Values for robust argument of pthread_mutexattr_get/setrobust
|
|
|
|
*
|
|
|
|
* PTHREAD_MUTEX_STALLED - No special actions are taken if the owner of the
|
|
|
|
* mutex is terminated while holding the mutex lock. This can lead to
|
|
|
|
* deadlocks if no other thread can unlock the mutex. This is the standard
|
|
|
|
* default value (NuttX permits you to override that default behavior
|
|
|
|
* with a configuration option).
|
|
|
|
*
|
|
|
|
* PTHREAD_MUTEX_ROBUST - If the process containing the owning thread of a
|
|
|
|
* robust mutex terminates while holding the mutex lock, the next thread
|
|
|
|
* that acquires the mutex will be notified about the termination by the
|
|
|
|
* return value EOWNERDEAD from the locking function. If the owning thread
|
|
|
|
* of a robust mutex terminates while holding the mutex lock, the next
|
|
|
|
* thread that attempts to acquire the mutex may be notified about the
|
|
|
|
* termination by the return value EOWNERDEAD. The notified thread can
|
|
|
|
* then attempt to make the state protected by the mutex consistent again,
|
|
|
|
* and if successful can mark the mutex state as consistent by calling
|
|
|
|
* pthread_mutex_consistent(). After a subsequent successful call to
|
|
|
|
* pthread_mutex_unlock(), the mutex lock will be released and can be used
|
|
|
|
* normally by other threads. If the mutex is unlocked without a call to
|
|
|
|
* pthread_mutex_consistent(), it will be in a permanently unusable state
|
|
|
|
* and all attempts to lock the mutex will fail with the error
|
|
|
|
* ENOTRECOVERABLE. The only permissible operation on such a mutex is
|
|
|
|
* pthread_mutex_destroy().
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PTHREAD_MUTEX_STALLED 0
|
|
|
|
#define PTHREAD_MUTEX_ROBUST 1
|
|
|
|
|
2017-03-26 20:46:57 +02:00
|
|
|
/* Values for struct pthread_mutex_s flags. These are non-standard and
|
|
|
|
* intended only for internal use within the OS.
|
|
|
|
*/
|
|
|
|
|
2017-03-27 02:37:24 +02:00
|
|
|
#define _PTHREAD_MFLAGS_ROBUST (1 << 0) /* Robust (NORMAL) mutex */
|
|
|
|
#define _PTHREAD_MFLAGS_INCONSISTENT (1 << 1) /* Mutex is in an inconsistent state */
|
2017-03-27 16:50:45 +02:00
|
|
|
#define _PTHREAD_MFLAGS_NRECOVERABLE (1 << 2) /* Inconsistent mutex has been unlocked */
|
2017-03-26 20:46:57 +02:00
|
|
|
|
2012-04-26 17:00:35 +02:00
|
|
|
/* Definitions to map some non-standard, BSD thread management interfaces to
|
|
|
|
* the non-standard Linux-like prctl() interface. Since these are simple
|
2015-06-16 16:27:38 +02:00
|
|
|
* mappings to prctl, they will return 0 on success and -1 on failure with the
|
2016-06-11 22:40:07 +02:00
|
|
|
* error number in errno. This is an inconsistency with the pthread interfaces.
|
2012-04-26 17:00:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define pthread_setname_np(thread, name) \
|
|
|
|
prctl((int)PR_SET_NAME, (char*)name, (int)thread)
|
2014-04-13 22:32:20 +02:00
|
|
|
|
2012-04-26 17:00:35 +02:00
|
|
|
#define pthread_getname_np(thread, name) \
|
|
|
|
prctl((int)PR_GET_NAME, (char*)name, (int)thread)
|
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/********************************************************************************
|
2015-08-03 19:01:41 +02:00
|
|
|
* Public Type Definitions
|
2007-03-20 17:51:12 +01:00
|
|
|
********************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2012-12-21 22:30:33 +01:00
|
|
|
extern "C"
|
|
|
|
{
|
2007-02-18 00:21:28 +01:00
|
|
|
#endif
|
|
|
|
|
2011-03-31 03:42:50 +02:00
|
|
|
/* pthread-specific types */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2015-12-30 20:20:31 +01:00
|
|
|
typedef int pthread_key_t;
|
|
|
|
#define __PTHREAD_KEY_T_DEFINED 1
|
|
|
|
|
|
|
|
typedef FAR void *pthread_addr_t;
|
|
|
|
#define __PTHREAD_ADDR_T_DEFINED 1
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
typedef pthread_addr_t (*pthread_startroutine_t)(pthread_addr_t);
|
2013-03-16 18:37:40 +01:00
|
|
|
typedef pthread_startroutine_t pthread_func_t;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2009-03-09 00:33:41 +01:00
|
|
|
struct pthread_attr_s
|
2007-02-18 00:21:28 +01:00
|
|
|
{
|
2015-07-23 21:16:32 +02:00
|
|
|
uint8_t priority; /* Priority of the pthread */
|
|
|
|
uint8_t policy; /* Pthread scheduler policy */
|
2015-07-23 21:26:41 +02:00
|
|
|
uint8_t inheritsched; /* Inherit parent priority/policy? */
|
2015-07-23 21:16:32 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_SPORADIC
|
2015-07-23 21:26:41 +02:00
|
|
|
uint8_t low_priority; /* Low scheduling priority */
|
2015-07-23 21:16:32 +02:00
|
|
|
uint8_t max_repl; /* Maximum pending replenishments */
|
|
|
|
#endif
|
|
|
|
|
2016-02-20 00:33:35 +01:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
cpu_set_t affinity; /* Set of permitted CPUs for the thread */
|
|
|
|
#endif
|
|
|
|
|
2018-08-23 17:48:53 +02:00
|
|
|
FAR void *stackaddr; /* Address of memory to be used as stack */
|
2015-07-23 21:16:32 +02:00
|
|
|
size_t stacksize; /* Size of the stack allocated for the pthread */
|
|
|
|
|
|
|
|
#ifdef CONFIG_SCHED_SPORADIC
|
|
|
|
struct timespec repl_period; /* Replenishment period */
|
|
|
|
struct timespec budget; /* Initial budget */
|
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
2015-12-30 20:20:31 +01:00
|
|
|
|
2009-03-09 00:33:41 +01:00
|
|
|
typedef struct pthread_attr_s pthread_attr_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_ATTR_T_DEFINED 1
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-02-20 23:39:56 +01:00
|
|
|
typedef pid_t pthread_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_T_DEFINED 1
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
typedef int pthread_condattr_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_CONDATTR_T_DEFINED 1
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
struct pthread_cond_s
|
|
|
|
{
|
|
|
|
sem_t sem;
|
|
|
|
};
|
2015-12-30 20:20:31 +01:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
typedef struct pthread_cond_s pthread_cond_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_COND_T_DEFINED 1
|
|
|
|
|
2015-02-25 03:26:42 +01:00
|
|
|
#define PTHREAD_COND_INITIALIZER {SEM_INITIALIZER(0)}
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
struct pthread_mutexattr_s
|
|
|
|
{
|
2017-03-27 02:37:24 +02:00
|
|
|
uint8_t pshared : 1; /* PTHREAD_PROCESS_PRIVATE or PTHREAD_PROCESS_SHARED */
|
2016-11-02 16:05:18 +01:00
|
|
|
#ifdef CONFIG_PRIORITY_INHERITANCE
|
2017-03-27 02:37:24 +02:00
|
|
|
uint8_t proto : 2; /* See PTHREAD_PRIO_* definitions */
|
2016-11-02 16:05:18 +01:00
|
|
|
#endif
|
2017-03-27 17:08:14 +02:00
|
|
|
#ifdef CONFIG_PTHREAD_MUTEX_TYPES
|
2017-03-27 02:37:24 +02:00
|
|
|
uint8_t type : 2; /* Type of the mutex. See PTHREAD_MUTEX_* definitions */
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_PTHREAD_MUTEX_BOTH
|
|
|
|
uint8_t robust : 1; /* PTHREAD_MUTEX_STALLED or PTHREAD_MUTEX_ROBUST */
|
2008-05-31 19:13:08 +02:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
2015-12-30 20:20:31 +01:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
typedef struct pthread_mutexattr_s pthread_mutexattr_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_MUTEXATTR_T_DEFINED 1
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
struct pthread_mutex_s
|
|
|
|
{
|
2017-03-27 01:37:28 +02:00
|
|
|
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
2017-03-26 20:46:57 +02:00
|
|
|
/* Supports a singly linked list */
|
|
|
|
|
|
|
|
FAR struct pthread_mutex_s *flink;
|
2017-03-27 01:37:28 +02:00
|
|
|
#endif
|
2017-03-26 20:46:57 +02:00
|
|
|
|
|
|
|
/* Payload */
|
|
|
|
|
2016-11-02 16:05:18 +01:00
|
|
|
sem_t sem; /* Semaphore underlying the implementation of the mutex */
|
2017-03-26 20:46:57 +02:00
|
|
|
pid_t pid; /* ID of the holder of the mutex */
|
2017-03-27 01:37:28 +02:00
|
|
|
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
2017-03-26 22:04:07 +02:00
|
|
|
uint8_t flags; /* See _PTHREAD_MFLAGS_* */
|
2017-03-27 01:37:28 +02:00
|
|
|
#endif
|
2017-03-27 17:08:14 +02:00
|
|
|
#ifdef CONFIG_PTHREAD_MUTEX_TYPES
|
2016-11-02 16:05:18 +01:00
|
|
|
uint8_t type; /* Type of the mutex. See PTHREAD_MUTEX_* definitions */
|
2017-03-26 20:46:57 +02:00
|
|
|
int16_t nlocks; /* The number of recursive locks held */
|
2008-05-31 19:13:08 +02:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
2015-12-30 20:20:31 +01:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
typedef struct pthread_mutex_s pthread_mutex_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_MUTEX_T_DEFINED 1
|
2008-05-31 19:13:08 +02:00
|
|
|
|
2017-03-28 17:07:32 +02:00
|
|
|
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
|
|
|
# ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
|
|
|
|
# define __PTHREAD_MUTEX_DEFAULT_FLAGS 0
|
|
|
|
# else
|
|
|
|
# define __PTHREAD_MUTEX_DEFAULT_FLAGS _PTHREAD_MFLAGS_ROBUST
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_PTHREAD_MUTEX_TYPES) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
|
|
|
|
# define PTHREAD_MUTEX_INITIALIZER {NULL, SEM_INITIALIZER(1), -1, \
|
|
|
|
__PTHREAD_MUTEX_DEFAULT_FLAGS, \
|
|
|
|
PTHREAD_MUTEX_DEFAULT, 0}
|
|
|
|
#elif defined(CONFIG_PTHREAD_MUTEX_TYPES)
|
|
|
|
# define PTHREAD_MUTEX_INITIALIZER {SEM_INITIALIZER(1), -1, \
|
|
|
|
PTHREAD_MUTEX_DEFAULT, 0}
|
|
|
|
#elif !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
|
|
|
|
# define PTHREAD_MUTEX_INITIALIZER {NULL, SEM_INITIALIZER(1), -1,\
|
|
|
|
__PTHREAD_MUTEX_DEFAULT_FLAGS}
|
2008-05-31 19:13:08 +02:00
|
|
|
#else
|
2017-03-28 17:07:32 +02:00
|
|
|
# define PTHREAD_MUTEX_INITIALIZER {SEM_INITIALIZER(1), -1}
|
2008-05-31 19:13:08 +02:00
|
|
|
#endif
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
struct pthread_barrierattr_s
|
|
|
|
{
|
|
|
|
int pshared;
|
|
|
|
};
|
2015-12-30 20:20:31 +01:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
typedef struct pthread_barrierattr_s pthread_barrierattr_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_BARRIERATTR_T_DEFINED 1
|
2007-03-24 00:22:22 +01:00
|
|
|
|
|
|
|
struct pthread_barrier_s
|
|
|
|
{
|
|
|
|
sem_t sem;
|
|
|
|
unsigned int count;
|
|
|
|
};
|
2015-12-30 20:20:31 +01:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
typedef struct pthread_barrier_s pthread_barrier_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_BARRIER_T_DEFINED 1
|
2007-03-24 00:22:22 +01:00
|
|
|
|
2009-12-15 00:32:23 +01:00
|
|
|
typedef bool pthread_once_t;
|
2015-12-30 20:20:31 +01:00
|
|
|
#define __PTHREAD_ONCE_T_DEFINED 1
|
2007-03-24 00:22:22 +01:00
|
|
|
|
2017-04-07 15:03:00 +02:00
|
|
|
struct pthread_rwlock_s
|
|
|
|
{
|
|
|
|
pthread_mutex_t lock;
|
|
|
|
pthread_cond_t cv;
|
|
|
|
unsigned int num_readers;
|
|
|
|
unsigned int num_writers;
|
2017-04-07 23:45:24 +02:00
|
|
|
bool write_in_progress;
|
2017-04-07 15:03:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct pthread_rwlock_s pthread_rwlock_t;
|
|
|
|
|
|
|
|
typedef int pthread_rwlockattr_t;
|
|
|
|
|
|
|
|
#define PTHREAD_RWLOCK_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, \
|
|
|
|
PTHREAD_COND_INITIALIZER, \
|
2017-04-08 20:34:08 +02:00
|
|
|
0, 0, false}
|
2017-04-07 15:03:00 +02:00
|
|
|
|
2016-12-08 16:27:13 +01:00
|
|
|
#ifdef CONFIG_PTHREAD_CLEANUP
|
|
|
|
/* This type describes the pthread cleanup callback (non-standard) */
|
|
|
|
|
|
|
|
typedef CODE void (*pthread_cleanup_t)(FAR void *arg);
|
|
|
|
#endif
|
|
|
|
|
2016-02-20 01:13:06 +01:00
|
|
|
/* Forward references */
|
2007-03-20 17:51:12 +01:00
|
|
|
|
|
|
|
struct sched_param; /* Defined in sched.h */
|
|
|
|
|
|
|
|
/********************************************************************************
|
2015-08-03 19:01:41 +02:00
|
|
|
* Public Function Prototypes
|
2007-03-20 17:51:12 +01:00
|
|
|
********************************************************************************/
|
2007-03-24 00:22:22 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* Initializes a thread attributes object (attr) with default values for all of
|
|
|
|
* the individual attributes used by a given implementation.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_attr_init(FAR pthread_attr_t *attr);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* An attributes object can be deleted when it is no longer needed. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_attr_destroy(pthread_attr_t *attr);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* Set or obtain the default scheduling algorithm */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_attr_setschedpolicy(FAR pthread_attr_t *attr, int policy);
|
2014-09-08 14:21:48 +02:00
|
|
|
int pthread_attr_getschedpolicy(FAR const pthread_attr_t *attr, int *policy);
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_attr_setschedparam(FAR pthread_attr_t *attr,
|
|
|
|
FAR const struct sched_param *param);
|
2014-09-08 14:21:48 +02:00
|
|
|
int pthread_attr_getschedparam(FAR const pthread_attr_t *attr,
|
2012-12-21 22:30:33 +01:00
|
|
|
FAR struct sched_param *param);
|
|
|
|
int pthread_attr_setinheritsched(FAR pthread_attr_t *attr,
|
|
|
|
int inheritsched);
|
|
|
|
int pthread_attr_getinheritsched(FAR const pthread_attr_t *attr,
|
|
|
|
FAR int *inheritsched);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-19 22:57:07 +01:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* Set or obtain thread affinity attributes */
|
|
|
|
|
|
|
|
int pthread_attr_setaffinity_np(FAR pthread_attr_t *attr,
|
|
|
|
size_t cpusetsize,
|
|
|
|
FAR const cpu_set_t *cpuset);
|
|
|
|
int pthread_attr_getaffinity_np(FAR const pthread_attr_t *attr,
|
|
|
|
size_t cpusetsize, cpu_set_t *cpuset);
|
|
|
|
#endif
|
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* Set or obtain the default stack size */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_attr_setstacksize(FAR pthread_attr_t *attr, long stacksize);
|
2014-09-08 14:21:48 +02:00
|
|
|
int pthread_attr_getstacksize(FAR const pthread_attr_t *attr, long *stackaddr);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2018-08-23 17:48:53 +02:00
|
|
|
/* Set or obtain stack address and size */
|
|
|
|
|
|
|
|
int pthread_attr_setstack(FAR pthread_attr_t *attr,
|
|
|
|
FAR void *stackaddr, long stacksize);
|
|
|
|
int pthread_attr_getstack(FAR pthread_attr_t *attr,
|
|
|
|
FAR void **stackaddr, FAR long *stacksize);
|
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* To create a thread object and runnable thread, a routine must be specified
|
|
|
|
* as the new thread's start routine. An argument may be passed to this
|
|
|
|
* routine, as an untyped address; an untyped address may also be returned as
|
|
|
|
* the routine's value. An attributes object may be used to specify details
|
|
|
|
* about the kind of thread being created.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-09-08 14:21:48 +02:00
|
|
|
int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
|
2012-12-21 22:30:33 +01:00
|
|
|
pthread_startroutine_t startroutine, pthread_addr_t arg);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread object may be "detached" to specify that the return value and
|
|
|
|
* completion status will not be requested.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_detach(pthread_t thread);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread may terminate it's own execution or the execution of another
|
|
|
|
* thread.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
void pthread_exit(pthread_addr_t value) noreturn_function;
|
|
|
|
int pthread_cancel(pthread_t thread);
|
|
|
|
int pthread_setcancelstate(int state, FAR int *oldstate);
|
2016-12-09 14:23:00 +01:00
|
|
|
int pthread_setcanceltype(int type, FAR int *oldtype);
|
2012-12-21 22:30:33 +01:00
|
|
|
void pthread_testcancel(void);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-12-08 16:27:13 +01:00
|
|
|
/* A thread may set up cleanup functions to execut when the thread exits or
|
|
|
|
* is canceled.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_PTHREAD_CLEANUP
|
|
|
|
void pthread_cleanup_pop(int execute);
|
|
|
|
void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg);
|
|
|
|
#endif
|
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread can await termination of another thread and retrieve the return
|
|
|
|
* value of the thread.
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_join(pthread_t thread, FAR pthread_addr_t *value);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread may tell the scheduler that its processor can be made available. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
void pthread_yield(void);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread may obtain a copy of its own thread handle. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-02-20 23:39:56 +01:00
|
|
|
#define pthread_self() ((pthread_t)getpid())
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* Compare two thread IDs. */
|
2007-03-16 23:44:04 +01:00
|
|
|
|
2015-06-16 16:27:38 +02:00
|
|
|
#define pthread_equal(t1,t2) ((t1) == (t2))
|
2007-03-16 23:44:04 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* Thread scheduling parameters */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_getschedparam(pthread_t thread, FAR int *policy,
|
|
|
|
FAR struct sched_param *param);
|
|
|
|
int pthread_setschedparam(pthread_t thread, int policy,
|
|
|
|
FAR const struct sched_param *param);
|
|
|
|
int pthread_setschedprio(pthread_t thread, int prio);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2016-02-20 21:57:05 +01:00
|
|
|
#ifdef CONFIG_SMP
|
2016-02-19 22:57:07 +01:00
|
|
|
/* Thread affinity */
|
|
|
|
|
|
|
|
int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize,
|
|
|
|
FAR const cpu_set_t *cpuset);
|
|
|
|
int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize,
|
|
|
|
FAR cpu_set_t *cpuset);
|
|
|
|
#endif
|
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* Thread-specific Data Interfaces */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_key_create(FAR pthread_key_t *key,
|
|
|
|
CODE void (*destructor)(FAR void*));
|
2014-09-08 14:21:48 +02:00
|
|
|
int pthread_setspecific(pthread_key_t key, FAR const void *value);
|
2012-12-21 22:30:33 +01:00
|
|
|
FAR void *pthread_getspecific(pthread_key_t key);
|
|
|
|
int pthread_key_delete(pthread_key_t key);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* Create, operate on, and destroy mutex attributes. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_mutexattr_init(FAR pthread_mutexattr_t *attr);
|
|
|
|
int pthread_mutexattr_destroy(FAR pthread_mutexattr_t *attr);
|
2014-09-08 14:21:48 +02:00
|
|
|
int pthread_mutexattr_getpshared(FAR const pthread_mutexattr_t *attr,
|
2012-12-21 22:30:33 +01:00
|
|
|
FAR int *pshared);
|
|
|
|
int pthread_mutexattr_setpshared(FAR pthread_mutexattr_t *attr,
|
|
|
|
int pshared);
|
|
|
|
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type);
|
|
|
|
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
|
2016-11-05 18:06:52 +01:00
|
|
|
int pthread_mutexattr_getprotocol(FAR const pthread_mutexattr_t *attr,
|
|
|
|
FAR int *protocol);
|
|
|
|
int pthread_mutexattr_setprotocol(FAR pthread_mutexattr_t *attr,
|
|
|
|
int protocol);
|
2017-03-27 02:37:24 +02:00
|
|
|
int pthread_mutexattr_getrobust(FAR const pthread_mutexattr_t *attr,
|
|
|
|
FAR int *robust);
|
|
|
|
int pthread_mutexattr_setrobust(FAR pthread_mutexattr_t *attr,
|
|
|
|
int robust);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* The following routines create, delete, lock and unlock mutexes. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_mutex_init(FAR pthread_mutex_t *mutex,
|
2014-09-08 14:21:48 +02:00
|
|
|
FAR const pthread_mutexattr_t *attr);
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_mutex_destroy(FAR pthread_mutex_t *mutex);
|
|
|
|
int pthread_mutex_lock(FAR pthread_mutex_t *mutex);
|
|
|
|
int pthread_mutex_trylock(FAR pthread_mutex_t *mutex);
|
|
|
|
int pthread_mutex_unlock(FAR pthread_mutex_t *mutex);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2017-03-27 01:37:28 +02:00
|
|
|
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
2017-03-26 18:35:23 +02:00
|
|
|
/* Make sure that the pthread mutex is in a consistent state */
|
|
|
|
|
|
|
|
int pthread_mutex_consistent(FAR pthread_mutex_t *mutex);
|
2017-03-27 01:37:28 +02:00
|
|
|
#endif
|
2017-03-26 18:35:23 +02:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* Operations on condition variables */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_condattr_init(FAR pthread_condattr_t *attr);
|
|
|
|
int pthread_condattr_destroy(FAR pthread_condattr_t *attr);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread can create and delete condition variables. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-09-08 14:21:48 +02:00
|
|
|
int pthread_cond_init(FAR pthread_cond_t *cond, FAR const pthread_condattr_t *attr);
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_cond_destroy(FAR pthread_cond_t *cond);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread can signal to and broadcast on a condition variable. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_cond_broadcast(FAR pthread_cond_t *cond);
|
|
|
|
int pthread_cond_signal(FAR pthread_cond_t *cond);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread can wait for a condition variable to be signalled or broadcast. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-20 17:51:12 +01:00
|
|
|
/* A thread can perform a timed wait on a condition variable. */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_cond_timedwait(FAR pthread_cond_t *cond,
|
|
|
|
FAR pthread_mutex_t *mutex,
|
|
|
|
FAR const struct timespec *abstime);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
/* Barrier attributes */
|
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_barrierattr_destroy(FAR pthread_barrierattr_t *attr);
|
|
|
|
int pthread_barrierattr_init(FAR pthread_barrierattr_t *attr);
|
|
|
|
int pthread_barrierattr_getpshared(FAR const pthread_barrierattr_t *attr,
|
|
|
|
FAR int *pshared);
|
|
|
|
int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr,
|
|
|
|
int pshared);
|
2007-03-24 00:22:22 +01:00
|
|
|
|
|
|
|
/* Barriers */
|
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_barrier_destroy(FAR pthread_barrier_t *barrier);
|
|
|
|
int pthread_barrier_init(FAR pthread_barrier_t *barrier,
|
2017-04-07 15:03:00 +02:00
|
|
|
FAR const pthread_barrierattr_t *attr,
|
|
|
|
unsigned int count);
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_barrier_wait(FAR pthread_barrier_t *barrier);
|
2007-03-24 00:22:22 +01:00
|
|
|
|
|
|
|
/* Pthread initialization */
|
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_once(FAR pthread_once_t *once_control,
|
2007-03-24 00:22:22 +01:00
|
|
|
CODE void (*init_routine)(void));
|
|
|
|
|
2017-04-07 15:03:00 +02:00
|
|
|
/* Pthread rwlock */
|
|
|
|
|
|
|
|
int pthread_rwlock_destroy(FAR pthread_rwlock_t *rw_lock);
|
|
|
|
int pthread_rwlock_init(FAR pthread_rwlock_t *rw_lock,
|
|
|
|
FAR const pthread_rwlockattr_t *attr);
|
|
|
|
int pthread_rwlock_rdlock(pthread_rwlock_t *lock);
|
|
|
|
int pthread_rwlock_timedrdlock(FAR pthread_rwlock_t *lock,
|
|
|
|
FAR const struct timespec *abstime);
|
|
|
|
int pthread_rwlock_tryrdlock(FAR pthread_rwlock_t *lock);
|
|
|
|
int pthread_rwlock_wrlock(FAR pthread_rwlock_t *lock);
|
|
|
|
int pthread_rwlock_timedwrlock(FAR pthread_rwlock_t *lock,
|
|
|
|
FAR const struct timespec *abstime);
|
|
|
|
int pthread_rwlock_trywrlock(FAR pthread_rwlock_t *lock);
|
|
|
|
int pthread_rwlock_unlock(FAR pthread_rwlock_t *lock);
|
|
|
|
|
2007-03-24 00:22:22 +01:00
|
|
|
/* Pthread signal management APIs */
|
|
|
|
|
2012-12-21 22:30:33 +01:00
|
|
|
int pthread_kill(pthread_t thread, int sig);
|
|
|
|
int pthread_sigmask(int how, FAR const sigset_t *set, FAR sigset_t *oset);
|
2007-03-24 00:22:22 +01:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-12-30 22:01:14 +01:00
|
|
|
/********************************************************************************
|
|
|
|
* Minimal Type Definitions
|
|
|
|
********************************************************************************/
|
|
|
|
|
2015-12-30 20:20:31 +01:00
|
|
|
#else /* __INCLUDE_PTHREAD_H */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2015-12-31 16:05:35 +01:00
|
|
|
/* Avoid circular dependencies by assuring that simple type definitions are
|
|
|
|
* available in any inclusion ordering.
|
2015-12-30 20:20:31 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_KEY_T_DEFINED
|
|
|
|
typedef int pthread_key_t;
|
|
|
|
# define __PTHREAD_KEY_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_ADDR_T_DEFINED
|
|
|
|
typedef FAR void *pthread_addr_t;
|
|
|
|
# define __PTHREAD_ADDR_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_ATTR_T_DEFINED
|
|
|
|
struct pthread_attr_s;
|
|
|
|
typedef struct pthread_attr_s pthread_attr_t;
|
|
|
|
# define __PTHREAD_ATTR_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_T_DEFINED
|
|
|
|
typedef pid_t pthread_t;
|
|
|
|
# define __PTHREAD_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_CONDATTR_T_DEFINED
|
|
|
|
typedef int pthread_condattr_t;
|
|
|
|
# define __PTHREAD_CONDATTR_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_COND_T_DEFINED
|
|
|
|
struct pthread_cond_s;
|
|
|
|
typedef struct pthread_cond_s pthread_cond_t;
|
|
|
|
# define __PTHREAD_COND_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_MUTEXATTR_T_DEFINED
|
|
|
|
struct pthread_mutexattr_s;
|
|
|
|
typedef struct pthread_mutexattr_s pthread_mutexattr_t;
|
|
|
|
# define __PTHREAD_MUTEXATTR_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_MUTEX_T_DEFINED
|
|
|
|
struct pthread_mutex_s;
|
|
|
|
typedef struct pthread_mutex_s pthread_mutex_t;
|
|
|
|
# define __PTHREAD_MUTEX_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_BARRIERATTR_T_DEFINED
|
|
|
|
struct pthread_barrierattr_s;
|
|
|
|
typedef struct pthread_barrierattr_s pthread_barrierattr_t;
|
|
|
|
# define __PTHREAD_BARRIERATTR_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_BARRIER_T_DEFINED
|
|
|
|
struct pthread_barrier_s;
|
|
|
|
typedef struct pthread_barrier_s pthread_barrier_t;
|
|
|
|
# define __PTHREAD_BARRIER_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PTHREAD_ONCE_T_DEFINED
|
|
|
|
typedef bool pthread_once_t;
|
|
|
|
# define __PTHREAD_ONCE_T_DEFINED 1
|
|
|
|
#endif
|
|
|
|
|
2011-03-31 03:42:50 +02:00
|
|
|
#endif /* __INCLUDE_PTHREAD_H */
|