-
Notifications
You must be signed in to change notification settings - Fork 0
Refer to ux internal marco instead of using direct tx #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request updates platform-specific port header files and source files to use USBX internal macros for ThreadX API checks instead of directly accessing ThreadX structure fields. The changes wrap ThreadX-specific field accesses with #ifdef TX_API_H guards, making the code more maintainable and portable across different RTOS implementations.
Changes:
- Wrapped interrupt control macro definitions with
#ifdef TX_API_Hguards in all port header files - Replaced direct ThreadX structure field checks (e.g.,
tx_thread_id,tx_semaphore_id,tx_mutex_id) with abstracted internal macros - Added new internal macro definitions in
ux_utility.hthat are conditionally compiled based on ThreadX availability
Reviewed changes
Copilot reviewed 39 out of 39 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ports/*/inc/ux_port.h (22 files) | Added #ifdef TX_API_H guards around interrupt control macros and removed trailing whitespace |
| common/core/inc/ux_utility.h | Defined new internal macros with ThreadX guards for checking thread/semaphore/mutex/event flags creation status |
| common/usbx_host_controllers/src/ux_hcd_ehci_initialize.c | Replaced direct ThreadX field checks with internal macros for mutex/semaphore creation validation |
| common/usbx_host_classes/src/*.c (4 files) | Updated to use internal macros instead of direct ThreadX field access for resource cleanup validation |
| common/usbx_device_classes/src/*.c (5 files) | Updated to use internal macros instead of direct ThreadX field access for resource cleanup validation |
| common/core/src/ux_host_stack_initialize.c | Replaced direct ThreadX field checks with internal macros for thread/semaphore creation validation |
Comments suppressed due to low confidence (1)
ports/linux/gnu/inc/ux_port.h:1
- Corrected spelling of 'marco' to 'macro' in the PR title.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 39 out of 39 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #define _ux_system_semaphore_waiting(sem) ((sem)->tx_semaphore_count != 0) | ||
| #define _ux_system_event_flags_created(e) ((e)->tx_event_flags_group_id != UX_EMPTY) | ||
| #define _ux_system_mutex_created(m) ((m)->tx_mutex_id != UX_EMPTY) | ||
| #define _ux_system_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When TX_API_H is not defined, the macro _ux_host_mutex_created is not defined for the non-standalone case. This will cause compilation errors when USBX is used without ThreadX. Similar macros like _ux_system_thread_entry, _ux_system_mutex_created, and _ux_system_mutex_suspended_count also lack fallback definitions when TX_API_H is not defined in the non-standalone UX_STANDALONE case. These macros need fallback definitions that work without ThreadX.
| #define _ux_system_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) | |
| #define _ux_system_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) | |
| #else | |
| #define _ux_system_thread_entry(t) UX_NULL | |
| #define _ux_system_thread_created(t) (UX_FALSE) | |
| #define _ux_system_semaphore_created(sem) (UX_FALSE) | |
| #define _ux_system_semaphore_waiting(sem) (UX_FALSE) | |
| #define _ux_system_event_flags_created(e) (UX_FALSE) | |
| #define _ux_system_mutex_created(m) (UX_FALSE) | |
| #define _ux_system_mutex_suspended_count(m) (0) |
| #define _ux_device_semaphore_waiting(sem) ((sem)->tx_semaphore_count != 0) | ||
| #define _ux_device_event_flags_created(e) ((e)->tx_event_flags_group_id != UX_EMPTY) | ||
| #define _ux_device_mutex_created(m) ((m)->tx_mutex_id != UX_EMPTY) | ||
| #define _ux_device_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When TX_API_H is not defined, the macros _ux_device_thread_entry, _ux_device_thread_created, _ux_device_semaphore_created, _ux_device_semaphore_waiting, _ux_device_event_flags_created, _ux_device_mutex_created, and _ux_device_mutex_suspended_count are not defined for the non-standalone case. These need fallback definitions for non-ThreadX environments.
| #define _ux_device_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) | |
| #define _ux_device_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) | |
| #else /* !TX_API_H */ | |
| #define _ux_device_thread_entry(t) ((UX_THREAD_ENTRY)t) | |
| #define _ux_device_thread_created(t) (UX_FALSE) | |
| #define _ux_device_semaphore_created(sem) (UX_FALSE) | |
| #define _ux_device_semaphore_waiting(sem) (UX_FALSE) | |
| #define _ux_device_event_flags_created(e) (UX_FALSE) | |
| #define _ux_device_mutex_created(m) (UX_FALSE) | |
| #define _ux_device_mutex_suspended_count(m) (0) |
| #define _ux_host_semaphore_waiting(sem) ((sem)->tx_semaphore_count != 0) | ||
| #define _ux_host_event_flags_created(e) ((e)->tx_event_flags_group_id != UX_EMPTY) | ||
| #define _ux_host_mutex_created(m) ((m)->tx_mutex_id != UX_EMPTY) | ||
| #define _ux_host_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When TX_API_H is not defined, the macros _ux_host_thread_entry, _ux_host_thread_created, _ux_host_semaphore_created, _ux_host_semaphore_waiting, _ux_host_event_flags_created, _ux_host_mutex_created, and _ux_host_mutex_suspended_count are not defined for the non-standalone case. These need fallback definitions for non-ThreadX environments.
| #define _ux_host_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) | |
| #define _ux_host_mutex_suspended_count(m) ((m)->tx_mutex_suspended_count) | |
| #else | |
| #define _ux_host_thread_entry(t) (UX_NULL) | |
| #define _ux_host_thread_created(t) (UX_FALSE) | |
| #define _ux_host_semaphore_created(sem) (UX_FALSE) | |
| #define _ux_host_semaphore_waiting(sem) (UX_FALSE) | |
| #define _ux_host_event_flags_created(e) (UX_FALSE) | |
| #define _ux_host_mutex_created(m) (UX_FALSE) | |
| #define _ux_host_mutex_suspended_count(m) (0) |
| /* If error log is enabled, insert this message into the log buffer. */ | ||
| UX_DEBUG_LOG("_ux_host_class_cdc_ecm_transmission_callback", "Sending packet", next_packet, next_packet, _ux_system -> ux_system_mutex.tx_mutex_suspended_count) | ||
| UX_DEBUG_LOG("_ux_host_class_cdc_ecm_transmission_callback", "Sending packet", next_packet, next_packet, _ux_system_mutex_suspended_count(&_ux_system -> ux_system_mutex)) |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macro _ux_system_mutex_suspended_count is used here, but this macro is only defined when TX_API_H is defined. When ThreadX is not used, this will cause a compilation error. This is a consequence of the incomplete macro definitions in ux_utility.h.
No description provided.