Skip to content

Conversation

@ayedm1
Copy link
Owner

@ayedm1 ayedm1 commented Jan 14, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 14, 2026 08:55
Copy link

Copilot AI left a 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_H guards 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.h that 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.

@ayedm1 ayedm1 marked this pull request as ready for review January 14, 2026 09:05
@ayedm1 ayedm1 requested a review from Copilot January 14, 2026 09:09
Copy link

Copilot AI left a 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)
Copy link

Copilot AI Jan 14, 2026

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.

Suggested change
#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)

Copilot uses AI. Check for mistakes.
#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)
Copy link

Copilot AI Jan 14, 2026

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.

Suggested change
#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)

Copilot uses AI. Check for mistakes.
#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)
Copy link

Copilot AI Jan 14, 2026

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.

Suggested change
#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)

Copilot uses AI. Check for mistakes.
/* 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))
Copy link

Copilot AI Jan 14, 2026

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.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

Test Results

3 030 tests   3 030 ✔️  32m 2s ⏱️
     17 suites         0 💤
     17 files           0

Results for commit 7ae0d65.

@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Health
core.src 96% 92%
usbx_device_classes.src 97% 91%
usbx_host_classes.src 97% 93%
Summary 97% (7607 / 7873) 92% (3378 / 3661)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants