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