]> begriffs open source - cmsis-freertos/blob - Source/portable/ThirdParty/GCC/Posix/portmacro.h
Update sources to FreeRTOS-Kernel V10.5.1
[cmsis-freertos] / Source / portable / ThirdParty / GCC / Posix / portmacro.h
1 /*
2  * FreeRTOS Kernel V10.5.1
3  * Copyright 2020 Cambridge Consultants Ltd.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * https://www.FreeRTOS.org
25  * https://github.com/FreeRTOS
26  *
27  */
28
29
30 #ifndef PORTMACRO_H
31 #define PORTMACRO_H
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #include <limits.h>
38
39 /*-----------------------------------------------------------
40  * Port specific definitions.
41  *
42  * The settings in this file configure FreeRTOS correctly for the
43  * given hardware and compiler.
44  *
45  * These settings should not be altered.
46  *-----------------------------------------------------------
47  */
48
49 /* Type definitions. */
50 #define portCHAR                char
51 #define portFLOAT               float
52 #define portDOUBLE              double
53 #define portLONG                long
54 #define portSHORT               short
55 #define portSTACK_TYPE  unsigned long
56 #define portBASE_TYPE   long
57 #define portPOINTER_SIZE_TYPE intptr_t
58
59 typedef portSTACK_TYPE StackType_t;
60 typedef long BaseType_t;
61 typedef unsigned long UBaseType_t;
62
63 typedef unsigned long TickType_t;
64 #define portMAX_DELAY ( TickType_t ) ULONG_MAX
65
66 #define portTICK_TYPE_IS_ATOMIC 1
67
68 /*-----------------------------------------------------------*/
69
70 /* Architecture specifics. */
71 #define portSTACK_GROWTH                        ( -1 )
72 #define portHAS_STACK_OVERFLOW_CHECKING ( 1 )
73 #define portTICK_PERIOD_MS                      ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
74 #define portTICK_RATE_MICROSECONDS      ( ( portTickType ) 1000000 / configTICK_RATE_HZ )
75 #define portBYTE_ALIGNMENT                      8
76 /*-----------------------------------------------------------*/
77
78 /* Scheduler utilities. */
79 extern void vPortYield( void );
80
81 #define portYIELD() vPortYield()
82
83 #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) vPortYield()
84 #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
85 /*-----------------------------------------------------------*/
86
87 /* Critical section management. */
88 extern void vPortDisableInterrupts( void );
89 extern void vPortEnableInterrupts( void );
90 #define portSET_INTERRUPT_MASK()        ( vPortDisableInterrupts() )
91 #define portCLEAR_INTERRUPT_MASK()      ( vPortEnableInterrupts() )
92
93 extern portBASE_TYPE xPortSetInterruptMask( void );
94 extern void vPortClearInterruptMask( portBASE_TYPE xMask );
95
96 extern void vPortEnterCritical( void );
97 extern void vPortExitCritical( void );
98 #define portSET_INTERRUPT_MASK_FROM_ISR()               xPortSetInterruptMask()
99 #define portCLEAR_INTERRUPT_MASK_FROM_ISR(x)    vPortClearInterruptMask(x)
100 #define portDISABLE_INTERRUPTS()                                portSET_INTERRUPT_MASK()
101 #define portENABLE_INTERRUPTS()                                 portCLEAR_INTERRUPT_MASK()
102 #define portENTER_CRITICAL()                                    vPortEnterCritical()
103 #define portEXIT_CRITICAL()                                             vPortExitCritical()
104
105 /*-----------------------------------------------------------*/
106
107 extern void vPortThreadDying( void *pxTaskToDelete, volatile BaseType_t *pxPendYield );
108 extern void vPortCancelThread( void *pxTaskToDelete );
109 #define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) vPortThreadDying( ( pvTaskToDelete ), ( pxPendYield ) )
110 #define portCLEAN_UP_TCB( pxTCB )       vPortCancelThread( pxTCB )
111 /*-----------------------------------------------------------*/
112
113 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
114 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
115 /*-----------------------------------------------------------*/
116
117 /*
118  * Tasks run in their own pthreads and context switches between them
119  * are always a full memory barrier. ISRs are emulated as signals
120  * which also imply a full memory barrier.
121  *
122  * Thus, only a compilier barrier is needed to prevent the compiler
123  * reordering.
124  */
125 #define portMEMORY_BARRIER() __asm volatile( "" ::: "memory" )
126
127 extern unsigned long ulPortGetRunTime( void );
128 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() /* no-op */
129 #define portGET_RUN_TIME_COUNTER_VALUE()         ulPortGetRunTime()
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* PORTMACRO_H */