]> git.sur5r.net Git - freertos/blob - FreeRTOS-Labs/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX_internal.h
Add the Labs projects provided in the V10.2.1_191129 zip file.
[freertos] / FreeRTOS-Labs / Demo / FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator / lib / FreeRTOS-Plus-POSIX / include / FreeRTOS_POSIX_internal.h
1 /*\r
2  * Amazon FreeRTOS POSIX V1.1.0\r
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\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
11  *\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
14  *\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
21  *\r
22  * http://aws.amazon.com/freertos\r
23  * http://www.FreeRTOS.org\r
24  */\r
25 \r
26 #ifndef _FREERTOS_POSIX_INTERNAL_H_\r
27 #define _FREERTOS_POSIX_INTERNAL_H_\r
28 \r
29 /**\r
30  * @file FreeRTOS_POSIX_internal.h\r
31  * @brief Internal structs and initializers for FreeRTOS+POSIX.\r
32  */\r
33 \r
34 /* Amazon FreeRTOS includes. */\r
35 #include "iot_doubly_linked_list.h"\r
36 \r
37 /**\r
38  * @brief Mutex attribute object.\r
39  */\r
40 #if posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1\r
41     typedef struct pthread_mutexattr_internal\r
42     {\r
43         int iType; /**< Mutex type. */\r
44     } pthread_mutexattr_internal_t;\r
45 #endif\r
46 \r
47 #if posixconfigENABLE_PTHREAD_MUTEX_T == 1\r
48 \r
49 /**\r
50  * @brief Mutex.\r
51  */\r
52     typedef struct pthread_mutex_internal\r
53     {\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
59 \r
60 /**\r
61  * @brief Compile-time initializer of pthread_mutex_internal_t.\r
62  */\r
63     #define FREERTOS_POSIX_MUTEX_INITIALIZER \\r
64     ( ( ( pthread_mutex_internal_t )         \\r
65     {                                        \\r
66         .xIsInitialized = pdFALSE,           \\r
67         .xMutex = { { 0 } },                 \\r
68         .xTaskOwner = NULL,                  \\r
69         .xAttr = { .iType = 0 }              \\r
70     }                                        \\r
71         )                                    \\r
72     )\r
73 #endif /* if posixconfigENABLE_PTHREAD_MUTEX_T == 1 */\r
74 \r
75 #if posixconfigENABLE_PTHREAD_COND_T == 1\r
76 \r
77 /**\r
78  * @brief Condition variable.\r
79  */\r
80     typedef struct pthread_cond_internal\r
81     {\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
86 \r
87 /**\r
88  * @brief Compile-time initializer of pthread_cond_internal_t.\r
89  */\r
90 \r
91     #define FREERTOS_POSIX_COND_INITIALIZER \\r
92     ( ( ( pthread_cond_internal_t )         \\r
93     {                                       \\r
94         .xIsInitialized = pdFALSE,          \\r
95         .xCondWaitSemaphore = { { 0 } },    \\r
96         .iWaitingThreads = 0                \\r
97     }                                       \\r
98         )                                   \\r
99     )\r
100 \r
101 #endif /* if posixconfigENABLE_PTHREAD_COND_T == 1 */\r
102 \r
103 #if posixconfigENABLE_SEM_T == 1\r
104 \r
105 /**\r
106  * @brief Semaphore type.\r
107  */\r
108     typedef struct\r
109     {\r
110         StaticSemaphore_t xSemaphore; /**< FreeRTOS semaphore. */\r
111         int value;                    /**< POSIX semaphore count. */\r
112     } sem_internal_t;\r
113 #endif /* if posixconfigENABLE_SEM_T == 1 */\r
114 \r
115 #if posixconfigENABLE_PTHREAD_BARRIER_T == 1\r
116 \r
117 /**\r
118  * @brief Barrier object.\r
119  */\r
120     typedef struct pthread_barrier_internal\r
121     {\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
128 \r
129 #endif /* _FREERTOS_POSIX_INTERNAL_H_ */\r