Amazon FreeRTOS: POSIX
Return to main page ↑
FreeRTOS_POSIX_internal.h
Go to the documentation of this file.
1 /*
2  * Amazon FreeRTOS POSIX V1.1.0
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
26 #ifndef _FREERTOS_POSIX_INTERNAL_H_
27 #define _FREERTOS_POSIX_INTERNAL_H_
28 
34 /* Amazon FreeRTOS includes. */
35 #include "iot_doubly_linked_list.h"
36 
40 #if posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1
41  typedef struct pthread_mutexattr_internal
42  {
43  int iType;
44  } pthread_mutexattr_internal_t;
45 #endif
46 
47 #if posixconfigENABLE_PTHREAD_MUTEX_T == 1
48 
52  typedef struct pthread_mutex_internal
53  {
54  BaseType_t xIsInitialized;
55  StaticSemaphore_t xMutex;
56  TaskHandle_t xTaskOwner;
57  pthread_mutexattr_internal_t xAttr;
58  } pthread_mutex_internal_t;
59 
63  #define FREERTOS_POSIX_MUTEX_INITIALIZER \
64  ( ( ( pthread_mutex_internal_t ) \
65  { \
66  .xIsInitialized = pdFALSE, \
67  .xMutex = { { 0 } }, \
68  .xTaskOwner = NULL, \
69  .xAttr = { .iType = 0 } \
70  } \
71  ) \
72  )
73 #endif /* if posixconfigENABLE_PTHREAD_MUTEX_T == 1 */
74 
75 #if posixconfigENABLE_PTHREAD_COND_T == 1
76 
80  typedef struct pthread_cond_internal
81  {
82  BaseType_t xIsInitialized;
83  StaticSemaphore_t xCondWaitSemaphore;
84  unsigned iWaitingThreads;
85  } pthread_cond_internal_t;
86 
91  #define FREERTOS_POSIX_COND_INITIALIZER \
92  ( ( ( pthread_cond_internal_t ) \
93  { \
94  .xIsInitialized = pdFALSE, \
95  .xCondWaitSemaphore = { { 0 } }, \
96  .iWaitingThreads = 0 \
97  } \
98  ) \
99  )
100 
101 #endif /* if posixconfigENABLE_PTHREAD_COND_T == 1 */
102 
103 #if posixconfigENABLE_SEM_T == 1
104 
108  typedef struct
109  {
110  StaticSemaphore_t xSemaphore;
111  int value;
112  } sem_internal_t;
113 #endif /* if posixconfigENABLE_SEM_T == 1 */
114 
115 #if posixconfigENABLE_PTHREAD_BARRIER_T == 1
116 
120  typedef struct pthread_barrier_internal
121  {
122  unsigned uThreadCount;
123  unsigned uThreshold;
124  StaticSemaphore_t xThreadCountSemaphore;
125  StaticEventGroup_t xBarrierEventGroup;
126  } pthread_barrier_internal_t;
127 #endif /* if posixconfigENABLE_PTHREAD_BARRIER_T == 1 */
128 
129 #endif /* _FREERTOS_POSIX_INTERNAL_H_ */