2 * Amazon FreeRTOS POSIX V1.1.0
\r
3 * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://aws.amazon.com/freertos
\r
23 * http://www.FreeRTOS.org
\r
26 #ifndef _FREERTOS_POSIX_INTERNAL_H_
\r
27 #define _FREERTOS_POSIX_INTERNAL_H_
\r
30 * @file FreeRTOS_POSIX_internal.h
\r
31 * @brief Internal structs and initializers for FreeRTOS+POSIX.
\r
34 /* Amazon FreeRTOS includes. */
\r
35 #include "iot_doubly_linked_list.h"
\r
38 * @brief Mutex attribute object.
\r
40 #if posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1
\r
41 typedef struct pthread_mutexattr_internal
\r
43 int iType; /**< Mutex type. */
\r
44 } pthread_mutexattr_internal_t;
\r
47 #if posixconfigENABLE_PTHREAD_MUTEX_T == 1
\r
52 typedef struct pthread_mutex_internal
\r
54 BaseType_t xIsInitialized; /**< Set to pdTRUE if this mutex is initialized, pdFALSE otherwise. */
\r
55 StaticSemaphore_t xMutex; /**< FreeRTOS mutex. */
\r
56 TaskHandle_t xTaskOwner; /**< Owner; used for deadlock detection and permission checks. */
\r
57 pthread_mutexattr_internal_t xAttr; /**< Mutex attributes. */
\r
58 } pthread_mutex_internal_t;
\r
61 * @brief Compile-time initializer of pthread_mutex_internal_t.
\r
63 #define FREERTOS_POSIX_MUTEX_INITIALIZER \
\r
64 ( ( ( pthread_mutex_internal_t ) \
\r
66 .xIsInitialized = pdFALSE, \
\r
67 .xMutex = { { 0 } }, \
\r
68 .xTaskOwner = NULL, \
\r
69 .xAttr = { .iType = 0 } \
\r
73 #endif /* if posixconfigENABLE_PTHREAD_MUTEX_T == 1 */
\r
75 #if posixconfigENABLE_PTHREAD_COND_T == 1
\r
78 * @brief Condition variable.
\r
80 typedef struct pthread_cond_internal
\r
82 BaseType_t xIsInitialized; /**< Set to pdTRUE if this condition variable is initialized, pdFALSE otherwise. */
\r
83 StaticSemaphore_t xCondWaitSemaphore; /**< Threads block on this semaphore in pthread_cond_wait. */
\r
84 unsigned iWaitingThreads; /**< The number of threads currently waiting on this condition variable. */
\r
85 } pthread_cond_internal_t;
\r
88 * @brief Compile-time initializer of pthread_cond_internal_t.
\r
91 #define FREERTOS_POSIX_COND_INITIALIZER \
\r
92 ( ( ( pthread_cond_internal_t ) \
\r
94 .xIsInitialized = pdFALSE, \
\r
95 .xCondWaitSemaphore = { { 0 } }, \
\r
96 .iWaitingThreads = 0 \
\r
101 #endif /* if posixconfigENABLE_PTHREAD_COND_T == 1 */
\r
103 #if posixconfigENABLE_SEM_T == 1
\r
106 * @brief Semaphore type.
\r
110 StaticSemaphore_t xSemaphore; /**< FreeRTOS semaphore. */
\r
111 int value; /**< POSIX semaphore count. */
\r
113 #endif /* if posixconfigENABLE_SEM_T == 1 */
\r
115 #if posixconfigENABLE_PTHREAD_BARRIER_T == 1
\r
118 * @brief Barrier object.
\r
120 typedef struct pthread_barrier_internal
\r
122 unsigned uThreadCount; /**< Current number of threads that have entered barrier. */
\r
123 unsigned uThreshold; /**< The count argument of pthread_barrier_init. */
\r
124 StaticSemaphore_t xThreadCountSemaphore; /**< Prevents more than uThreshold threads from exiting pthread_barrier_wait at once. */
\r
125 StaticEventGroup_t xBarrierEventGroup; /**< FreeRTOS event group that blocks to wait on threads entering barrier. */
\r
126 } pthread_barrier_internal_t;
\r
127 #endif /* if posixconfigENABLE_PTHREAD_BARRIER_T == 1 */
\r
129 #endif /* _FREERTOS_POSIX_INTERNAL_H_ */
\r