1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** ThreadX Component                                                     */
17 /**                                                                       */
18 /**   Port Specific                                                       */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  PORT SPECIFIC C INFORMATION                            RELEASE        */
27 /*                                                                        */
28 /*    tx_port.h                                           Linux/GNU       */
29 /*                                                           6.3.0        */
30 /*                                                                        */
31 /*  AUTHOR                                                                */
32 /*                                                                        */
33 /*    William E. Lamie, Microsoft Corporation                             */
34 /*                                                                        */
35 /*  DESCRIPTION                                                           */
36 /*                                                                        */
37 /*    This file contains data type definitions that make the ThreadX      */
38 /*    real-time kernel function identically on a variety of different     */
39 /*    processor architectures.  For example, the size or number of bits   */
40 /*    in an "int" data type vary between microprocessor architectures and */
41 /*    even C compilers for the same microprocessor.  ThreadX does not     */
42 /*    directly use native C data types.  Instead, ThreadX creates its     */
43 /*    own special types that can be mapped to actual data types by this   */
44 /*    file to guarantee consistency in the interface and functionality.   */
45 /*                                                                        */
46 /*  RELEASE HISTORY                                                       */
47 /*                                                                        */
48 /*    DATE              NAME                      DESCRIPTION             */
49 /*                                                                        */
50 /*  09-30-2020     William E. Lamie         Initial Version 6.1           */
51 /*  10-15-2021     William E. Lamie         Modified comment(s), added    */
52 /*                                            symbol ULONG64_DEFINED,     */
53 /*                                            resulting in version 6.1.9  */
54 /*  04-25-2022     William E. Lamie         Modified comment(s), removed  */
55 /*                                            useless definition,         */
56 /*                                            resulting in version 6.1.11 */
57 /*  10-31-2023     Yanwu Cai                Modified comment(s), fixed    */
58 /*                                            compile warnings,           */
59 /*                                            resulting in version 6.3.0  */
60 /*                                                                        */
61 /**************************************************************************/
62 
63 #ifndef TX_PORT_H
64 #define TX_PORT_H
65 
66 
67 #define TX_MAX_PRIORITIES                       32
68 /* #define TX_MISRA_ENABLE  */
69 
70 
71 /* #define TX_INLINE_INITIALIZATION */
72 
73 /* #define TX_NOT_INTERRUPTABLE  */
74 /* #define TX_TIMER_PROCESS_IN_ISR */
75 /* #define TX_REACTIVATE_INLINE */
76 /* #define TX_DISABLE_STACK_FILLING */
77 /* #define TX_ENABLE_STACK_CHECKING */
78 /* #define TX_DISABLE_PREEMPTION_THRESHOLD */
79 /* #define TX_DISABLE_REDUNDANT_CLEARING */
80 /* #define TX_DISABLE_NOTIFY_CALLBACKS */
81 /* #define TX_INLINE_THREAD_RESUME_SUSPEND */
82 /* #define TX_ENABLE_EVENT_TRACE */
83 
84 
85 /* For MISRA, define enable performance info. Also, for MISRA TX_DISABLE_NOTIFY_CALLBACKS should not be defined.  */
86 
87 
88 /* #define TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
89 #define TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO
90 #define TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
91 #define TX_MUTEX_ENABLE_PERFORMANCE_INFO
92 #define TX_QUEUE_ENABLE_PERFORMANCE_INFO
93 #define TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO
94 #define TX_THREAD_ENABLE_PERFORMANCE_INFO
95 #define TX_TIMER_ENABLE_PERFORMANCE_INFO */
96 
97 
98 
99 /* Determine if the optional ThreadX user define file should be used.  */
100 
101 #ifdef TX_INCLUDE_USER_DEFINE_FILE
102 
103 
104 /* Yes, include the user defines in tx_user.h. The defines in this file may
105    alternately be defined on the command line.  */
106 
107 #include "tx_user.h"
108 #endif
109 
110 
111 /* Define compiler library include files.  */
112 
113 #include <stdlib.h>
114 #include <string.h>
115 #include <stdint.h>
116 #ifndef __USE_POSIX199309
117 #define __USE_POSIX199309
118 #include <pthread.h>
119 #include <semaphore.h>
120 #include <time.h>
121 #undef __USE_POSIX199309
122 #else /* __USE_POSIX199309 */
123 #include <pthread.h>
124 #include <semaphore.h>
125 #include <time.h>
126 #endif /* __USE_POSIX199309 */
127 
128 
129 /* Define ThreadX basic types for this port.  */
130 
131 typedef void                                    VOID;
132 typedef char                                    CHAR;
133 typedef unsigned char                           UCHAR;
134 typedef int                                     INT;
135 typedef unsigned int                            UINT;
136 #if defined(__x86_64__) && __x86_64__
137 typedef int                                     LONG;
138 typedef unsigned int                            ULONG;
139 #else /* __x86_64__ */
140 typedef long                                    LONG;
141 typedef unsigned long                           ULONG;
142 #endif /* __x86_64__ */
143 typedef short                                   SHORT;
144 typedef unsigned short                          USHORT;
145 typedef uint64_t                                ULONG64;
146 #define ULONG64_DEFINED
147 
148 /* Override the alignment type to use 64-bit alignment and storage for pointers.  */
149 
150 #if defined(__x86_64__) && __x86_64__
151 #define ALIGN_TYPE_DEFINED
152 typedef unsigned long long                      ALIGN_TYPE;
153 
154 /* Override the free block marker for byte pools to be a 64-bit constant.   */
155 
156 #define TX_BYTE_BLOCK_FREE                      ((ALIGN_TYPE) 0xFFFFEEEEFFFFEEEE)
157 #endif
158 
159 /* Define automated coverage test extensions...  These are required for the
160    ThreadX regression test.  */
161 
162 typedef unsigned int    TEST_FLAG;
163 extern TEST_FLAG        threadx_byte_allocate_loop_test;
164 extern TEST_FLAG        threadx_byte_release_loop_test;
165 extern TEST_FLAG        threadx_mutex_suspension_put_test;
166 extern TEST_FLAG        threadx_mutex_suspension_priority_test;
167 #ifndef TX_TIMER_PROCESS_IN_ISR
168 extern TEST_FLAG        threadx_delete_timer_thread;
169 #endif
170 
171 extern void             abort_and_resume_byte_allocating_thread(void);
172 extern void             abort_all_threads_suspended_on_mutex(void);
173 extern void             suspend_lowest_priority(void);
174 #ifndef TX_TIMER_PROCESS_IN_ISR
175 extern void             delete_timer_thread(void);
176 #endif
177 extern TEST_FLAG        test_stack_analyze_flag;
178 extern TEST_FLAG        test_initialize_flag;
179 extern TEST_FLAG        test_forced_mutex_timeout;
180 
181 
182 #ifdef TX_REGRESSION_TEST
183 
184 /* Define extension macros for automated coverage tests.  */
185 
186 
187 #define TX_BYTE_ALLOCATE_EXTENSION              if (threadx_byte_allocate_loop_test == ((TEST_FLAG) 1))         \
188                                                 {                                                               \
189                                                     pool_ptr -> tx_byte_pool_owner =  TX_NULL;                  \
190                                                     threadx_byte_allocate_loop_test = ((TEST_FLAG) 0);          \
191                                                 }
192 
193 #define TX_BYTE_RELEASE_EXTENSION               if (threadx_byte_release_loop_test == ((TEST_FLAG) 1))          \
194                                                 {                                                               \
195                                                     threadx_byte_release_loop_test = ((TEST_FLAG) 0);           \
196                                                     abort_and_resume_byte_allocating_thread();                  \
197                                                 }
198 
199 #define TX_MUTEX_PUT_EXTENSION_1                if (threadx_mutex_suspension_put_test == ((TEST_FLAG) 1))       \
200                                                 {                                                               \
201                                                     threadx_mutex_suspension_put_test = ((TEST_FLAG) 0);        \
202                                                     abort_all_threads_suspended_on_mutex();                     \
203                                                 }
204 
205 
206 #define TX_MUTEX_PUT_EXTENSION_2                if (test_forced_mutex_timeout == ((TEST_FLAG) 1))               \
207                                                 {                                                               \
208                                                     test_forced_mutex_timeout = ((TEST_FLAG) 0);                \
209                                                     _tx_thread_wait_abort(mutex_ptr -> tx_mutex_suspension_list); \
210                                                 }
211 
212 
213 #define TX_MUTEX_PRIORITY_CHANGE_EXTENSION      if (threadx_mutex_suspension_priority_test == ((TEST_FLAG) 1))  \
214                                                 {                                                               \
215                                                     threadx_mutex_suspension_priority_test = ((TEST_FLAG) 0);   \
216                                                     suspend_lowest_priority();                                  \
217                                                 }
218 
219 #ifndef TX_TIMER_PROCESS_IN_ISR
220 
221 #define TX_TIMER_INITIALIZE_EXTENSION(a)        if (threadx_delete_timer_thread == ((TEST_FLAG) 1))             \
222                                                 {                                                               \
223                                                     threadx_delete_timer_thread = ((TEST_FLAG) 0);              \
224                                                     delete_timer_thread();                                      \
225                                                     (a) =  ((UINT) 1);                                          \
226                                                 }
227 
228 #endif
229 
230 #define TX_THREAD_STACK_ANALYZE_EXTENSION       if (test_stack_analyze_flag == ((TEST_FLAG) 1))                 \
231                                                 {                                                               \
232                                                     thread_ptr -> tx_thread_id =  ((TEST_FLAG) 0);              \
233                                                     test_stack_analyze_flag =     ((TEST_FLAG) 0);              \
234                                                 }                                                               \
235                                                 else if (test_stack_analyze_flag == ((TEST_FLAG) 2))            \
236                                                 {                                                               \
237                                                     stack_ptr =  thread_ptr -> tx_thread_stack_start;           \
238                                                     test_stack_analyze_flag =     ((TEST_FLAG) 0);              \
239                                                 }                                                               \
240                                                 else if (test_stack_analyze_flag == ((TEST_FLAG) 3))            \
241                                                 {                                                               \
242                                                     *stack_ptr =  TX_STACK_FILL;                                \
243                                                     test_stack_analyze_flag =     ((TEST_FLAG) 0);              \
244                                                 }                                                               \
245                                                 else                                                            \
246                                                 {                                                               \
247                                                     test_stack_analyze_flag =     ((TEST_FLAG) 0);              \
248                                                 }
249 
250 #define TX_INITIALIZE_KERNEL_ENTER_EXTENSION    if (test_initialize_flag == ((TEST_FLAG) 1))                    \
251                                                 {                                                               \
252                                                     test_initialize_flag =  ((TEST_FLAG) 0);                    \
253                                                     return;                                                     \
254                                                 }
255 
256 #endif
257 
258 
259 
260 /* Add Linux debug insert prototype.  */
261 
262 void    _tx_linux_debug_entry_insert(char *action, char *file, unsigned long line);
263 
264 #ifndef TX_LINUX_DEBUG_ENABLE
265 
266 /* If Linux debug is not enabled, turn logging into white-space.  */
267 
268 #define _tx_linux_debug_entry_insert(a, b, c)
269 
270 #endif
271 
272 
273 
274 /* Define the TX_MEMSET macro to remove library reference.  */
275 
276 #ifndef TX_MISRA_ENABLE
277 #define TX_MEMSET(a,b,c)                        {                                       \
278                                                 UCHAR *ptr;                             \
279                                                 UCHAR value;                            \
280                                                 UINT  i, size;                          \
281                                                     ptr =    (UCHAR *) ((VOID *) a);    \
282                                                     value =  (UCHAR) b;                 \
283                                                     size =   (UINT) c;                  \
284                                                     for (i = 0; i < size; i++)          \
285                                                     {                                   \
286                                                         *ptr++ =  value;                \
287                                                     }                                   \
288                                                 }
289 #endif
290 
291 
292 /* Define the priority levels for ThreadX.  Legal values range
293    from 32 to 1024 and MUST be evenly divisible by 32.  */
294 
295 #ifndef TX_MAX_PRIORITIES
296 #define TX_MAX_PRIORITIES                       32
297 #endif
298 
299 
300 /* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during
301    thread creation is less than this value, the thread create call will return an error.  */
302 
303 #ifndef TX_MINIMUM_STACK
304 #define TX_MINIMUM_STACK                        200         /* Minimum stack size for this port */
305 #endif
306 
307 
308 /* Define the system timer thread's default stack size and priority.  These are only applicable
309    if TX_TIMER_PROCESS_IN_ISR is not defined.  */
310 
311 #ifndef TX_TIMER_THREAD_STACK_SIZE
312 #define TX_TIMER_THREAD_STACK_SIZE              400         /* Default timer thread stack size - Not used in Linux port!  */
313 #endif
314 
315 #ifndef TX_TIMER_THREAD_PRIORITY
316 #define TX_TIMER_THREAD_PRIORITY                0           /* Default timer thread priority    */
317 #endif
318 
319 
320 /* Define various constants for the ThreadX  port.  */
321 
322 #define TX_INT_DISABLE                          1           /* Disable interrupts               */
323 #define TX_INT_ENABLE                           0           /* Enable interrupts                */
324 
325 
326 /* Define the clock source for trace event entry time stamp. The following two item are port specific.
327    For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
328    source constants would be:
329 
330 #define TX_TRACE_TIME_SOURCE                    *((ULONG *) 0x0a800024)
331 #define TX_TRACE_TIME_MASK                      0x0000FFFFUL
332 
333 */
334 
335 #ifndef TX_MISRA_ENABLE
336 #ifndef TX_TRACE_TIME_SOURCE
337 #define TX_TRACE_TIME_SOURCE                    ((ULONG) (_tx_linux_time_stamp.tv_nsec));
338 #endif
339 #else
340 ULONG   _tx_misra_time_stamp_get(VOID);
341 #define TX_TRACE_TIME_SOURCE                    _tx_misra_time_stamp_get()
342 #endif
343 
344 #ifndef TX_TRACE_TIME_MASK
345 #define TX_TRACE_TIME_MASK                      0xFFFFFFFFUL
346 #endif
347 
348 
349 /* Define the port-specific trace extension to pickup the Windows timer.  */
350 
351 #define TX_TRACE_PORT_EXTENSION                 clock_gettime(CLOCK_REALTIME, &_tx_linux_time_stamp);
352 
353 
354 /* Define the port specific options for the _tx_build_options variable. This variable indicates
355    how the ThreadX library was built.  */
356 
357 #define TX_PORT_SPECIFIC_BUILD_OPTIONS          0
358 
359 
360 /* Define the in-line initialization constant so that modules with in-line
361    initialization capabilities can prevent their initialization from being
362    a function call.  */
363 
364 #ifdef TX_MISRA_ENABLE
365 #define TX_DISABLE_INLINE
366 #else
367 #define TX_INLINE_INITIALIZATION
368 #endif
369 
370 
371 /* Define the Linux-specific initialization code that is expanded in the generic source.  */
372 
373 void    _tx_initialize_start_interrupts(void);
374 
375 #define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION                       _tx_initialize_start_interrupts();
376 
377 
378 /* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
379    disabled. When the following is defined, ThreadX thread stack checking is enabled.  If stack
380    checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
381    define is negated, thereby forcing the stack fill which is necessary for the stack checking
382    logic.  */
383 
384 #ifndef TX_MISRA_ENABLE
385 #ifdef TX_ENABLE_STACK_CHECKING
386 #undef TX_DISABLE_STACK_FILLING
387 #endif
388 #endif
389 
390 
391 /* Define the TX_THREAD control block extensions for this port. The main reason
392    for the multiple macros is so that backward compatibility can be maintained with
393    existing ThreadX kernel awareness modules.  */
394 
395 #define TX_THREAD_EXTENSION_0                                               pthread_t   tx_thread_linux_thread_id; \
396                                                                             sem_t       tx_thread_linux_thread_run_semaphore; \
397                                                                             UINT        tx_thread_linux_suspension_type; \
398                                                                             UINT        tx_thread_linux_int_disabled_flag;
399 
400 #define TX_THREAD_EXTENSION_1                                               VOID       *tx_thread_extension_ptr;
401 #define TX_THREAD_EXTENSION_2
402 #define TX_THREAD_EXTENSION_3
403 
404 
405 /* Define the port extensions of the remaining ThreadX objects.  */
406 
407 #define TX_BLOCK_POOL_EXTENSION
408 #define TX_BYTE_POOL_EXTENSION
409 #define TX_EVENT_FLAGS_GROUP_EXTENSION
410 #define TX_MUTEX_EXTENSION
411 #define TX_QUEUE_EXTENSION
412 #define TX_SEMAPHORE_EXTENSION
413 #define TX_TIMER_EXTENSION
414 
415 
416 /* Define the user extension field of the thread control block.  Nothing
417    additional is needed for this port so it is defined as white space.  */
418 
419 #ifndef TX_THREAD_USER_EXTENSION
420 #define TX_THREAD_USER_EXTENSION
421 #endif
422 
423 
424 /* Define the macros for processing extensions in tx_thread_create, tx_thread_delete,
425    tx_thread_shell_entry, and tx_thread_terminate.  */
426 
427 
428 #define TX_THREAD_CREATE_EXTENSION(thread_ptr)
429 #define TX_THREAD_DELETE_EXTENSION(thread_ptr)
430 #define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
431 #define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
432 
433 
434 /* Define the ThreadX object creation extensions for the remaining objects.  */
435 
436 #define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr)
437 #define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr)
438 #define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
439 #define TX_MUTEX_CREATE_EXTENSION(mutex_ptr)
440 #define TX_QUEUE_CREATE_EXTENSION(queue_ptr)
441 #define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr)
442 #define TX_TIMER_CREATE_EXTENSION(timer_ptr)
443 
444 
445 /* Define the ThreadX object deletion extensions for the remaining objects.  */
446 
447 #define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
448 #define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
449 #define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
450 #define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
451 #define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
452 #define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
453 #define TX_TIMER_DELETE_EXTENSION(timer_ptr)
454 
455 struct TX_THREAD_STRUCT;
456 
457 /* Define post completion processing for tx_thread_delete, so that the Linux thread resources are properly removed.  */
458 
459 void _tx_thread_delete_port_completion(struct TX_THREAD_STRUCT *thread_ptr, UINT tx_saved_posture);
460 #define TX_THREAD_DELETE_PORT_COMPLETION(thread_ptr) _tx_thread_delete_port_completion(thread_ptr, tx_saved_posture);
461 
462 /* Define post completion processing for tx_thread_reset, so that the Linux thread resources are properly removed.  */
463 
464 void _tx_thread_reset_port_completion(struct TX_THREAD_STRUCT *thread_ptr, UINT tx_saved_posture);
465 #define TX_THREAD_RESET_PORT_COMPLETION(thread_ptr) _tx_thread_reset_port_completion(thread_ptr, tx_saved_posture);
466 
467 #if defined(__x86_64__) && __x86_64__
468 /* Define the ThreadX object deletion extensions for the remaining objects.  */
469 
470 #define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
471 #define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
472 #define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
473 #define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
474 #define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
475 #define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
476 #define TX_TIMER_DELETE_EXTENSION(timer_ptr)
477 
478 /* Define the internal timer extension to also hold the thread pointer such that _tx_thread_timeout
479    can figure out what thread timeout to process.  */
480 
481 #define TX_TIMER_INTERNAL_EXTENSION             VOID    *tx_timer_internal_extension_ptr;
482 
483 
484 /* Define the thread timeout setup logic in _tx_thread_create.  */
485 
486 #define TX_THREAD_CREATE_TIMEOUT_SETUP(t)    (t) -> tx_thread_timer.tx_timer_internal_timeout_function =    &(_tx_thread_timeout);            \
487                                              (t) -> tx_thread_timer.tx_timer_internal_timeout_param =       0;                                \
488                                              (t) -> tx_thread_timer.tx_timer_internal_extension_ptr =       (VOID *) (t);
489 
490 
491 /* Define the thread timeout pointer setup in _tx_thread_timeout.  */
492 
493 #define TX_THREAD_TIMEOUT_POINTER_SETUP(t)   (t) =  (TX_THREAD *) _tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr;
494 #endif /* __x86_64__ */
495 
496 
497 /* Define ThreadX interrupt lockout and restore macros for protection on
498    access of critical kernel information.  The restore interrupt macro must
499    restore the interrupt posture of the running thread prior to the value
500    present prior to the disable macro.  In most cases, the save area macro
501    is used to define a local function save area for the disable and restore
502    macros.  */
503 
504 UINT   _tx_thread_interrupt_disable(void);
505 VOID   _tx_thread_interrupt_restore(UINT previous_posture);
506 
507 #define TX_INTERRUPT_SAVE_AREA      UINT    tx_saved_posture;
508 
509 #ifndef TX_LINUX_DEBUG_ENABLE
510 #define TX_DISABLE                          tx_saved_posture =   _tx_thread_interrupt_disable();
511 #define TX_RESTORE                          _tx_thread_interrupt_restore(tx_saved_posture);
512 #else
513 #define TX_DISABLE                          _tx_linux_debug_entry_insert("DISABLE", __FILE__, __LINE__); \
514                                             tx_saved_posture =   _tx_thread_interrupt_disable();
515 
516 #define TX_RESTORE                          _tx_linux_debug_entry_insert("RESTORE", __FILE__, __LINE__); \
517                                             _tx_thread_interrupt_restore(tx_saved_posture);
518 #endif /* TX_LINUX_DEBUG_ENABLE */
519 #define tx_linux_mutex_lock(p)              pthread_mutex_lock(&p)
520 #define tx_linux_mutex_unlock(p)            pthread_mutex_unlock(&p)
521 #define tx_linux_mutex_recursive_unlock(p)  {\
522                                                 int _recursive_count = (int)tx_linux_mutex_recursive_count;\
523                                                 while(_recursive_count)\
524                                                 {\
525                                                     pthread_mutex_unlock(&p);\
526                                                     _recursive_count--;\
527                                                 }\
528                                             }
529 #define tx_linux_mutex_recursive_count      _tx_linux_mutex.__data.__count
530 #define tx_linux_sem_post(p)                tx_linux_mutex_lock(_tx_linux_mutex);\
531                                             sem_post(p);\
532                                             tx_linux_mutex_unlock(_tx_linux_mutex)
533 #define tx_linux_sem_post_nolock(p)         sem_post(p)
534 #define tx_linux_sem_wait(p)                sem_wait(p)
535 
536 
537 /* Define the interrupt lockout macros for each ThreadX object.  */
538 
539 #define TX_BLOCK_POOL_DISABLE               TX_DISABLE
540 #define TX_BYTE_POOL_DISABLE                TX_DISABLE
541 #define TX_EVENT_FLAGS_GROUP_DISABLE        TX_DISABLE
542 #define TX_MUTEX_DISABLE                    TX_DISABLE
543 #define TX_QUEUE_DISABLE                    TX_DISABLE
544 #define TX_SEMAPHORE_DISABLE                TX_DISABLE
545 
546 
547 /* Define the version ID of ThreadX.  This may be utilized by the application.  */
548 
549 #ifdef TX_THREAD_INIT
550 CHAR                            _tx_version_id[] =
551                                     "Copyright (c) Microsoft Corporation * ThreadX Linux/gcc Version 6.3.0 *";
552 #else
553 extern  CHAR                    _tx_version_id[];
554 #endif
555 
556 
557 /* Define externals for the Linux port of ThreadX.  */
558 
559 extern pthread_mutex_t                          _tx_linux_mutex;
560 extern sem_t                                    _tx_linux_semaphore;
561 extern sem_t                                    _tx_linux_semaphore_no_idle;
562 extern ULONG                                    _tx_linux_global_int_disabled_flag;
563 extern struct timespec                          _tx_linux_time_stamp;
564 extern __thread int                             _tx_linux_threadx_thread;
565 
566 /* Define functions for linux thread. */
567 void    _tx_linux_thread_suspend(pthread_t thread_id);
568 void    _tx_linux_thread_resume(pthread_t thread_id);
569 void    _tx_linux_thread_init(void);
570 
571 #ifndef TX_LINUX_MEMORY_SIZE
572 #define TX_LINUX_MEMORY_SIZE                    64000
573 #endif
574 
575 /* Define priorities of pthreads. */
576 
577 #define TX_LINUX_PRIORITY_SCHEDULE              (3)
578 #define TX_LINUX_PRIORITY_ISR                   (2)
579 #define TX_LINUX_PRIORITY_USER_THREAD           (1)
580 
581 #endif
582 
583