diff options
| author | Frédéric Desbiens <[email protected]> | 2026-03-06 19:27:49 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-03-06 19:27:49 +0100 |
| commit | 3726d7906b4808bfec7855fc088e073199df9120 (patch) | |
| tree | 8789bfd03d1d49e1967e80d04aa4ff606fda43eb /utility | |
| parent | 4b6e8100d932a3a67b34c6eb17f84f3bffb9e2ae (diff) | |
| parent | c3259a216026372e3833dd8996a68f77e8595fbd (diff) | |
Merge pull request #510 from eclipse-threadx/devv6.5.0.202601_rel
Merge changes ahead of the v6.5.0.202601 release
Diffstat (limited to 'utility')
158 files changed, 3577 insertions, 4339 deletions
diff --git a/utility/benchmarks/thread_metric/thread_metric_readme.txt b/utility/benchmarks/thread_metric/thread_metric_readme.txt index 70896efb..044f7ee2 100644 --- a/utility/benchmarks/thread_metric/thread_metric_readme.txt +++ b/utility/benchmarks/thread_metric/thread_metric_readme.txt @@ -1,4 +1,4 @@ - Thread-Metric RTOS Test Suite + Thread-Metric RTOS Test Suite 1. Thread-Metric Test Suite @@ -6,46 +6,46 @@ The Thread-Metric test suite consists of 8 distinct RTOS tests that are designed to highlight commonly used aspects of an RTOS. The test measures the total number of RTOS events -that can be processed during a specific timer interval. A 30 -second time interval is recommended. +that can be processed during a specific timer interval. A 30 +second time interval is recommended. -1.1. Basic Processing Test +1.1. Basic Processing Test -This is the baseline test consisting of a single thread. This -should execute the same on every operating system. Test values -from testing with different RTOS products should be scaled +This is the baseline test consisting of a single thread. This +should execute the same on every operating system. Test values +from testing with different RTOS products should be scaled relative to the difference between the values of this test. 1.2. Cooperative Scheduling Test -This test consists of 5 threads created at the same priority that -voluntarily release control to each other in a round-robin fashion. -Each thread will increment its run counter and then relinquish to -the next thread. At the end of the test the counters will be verified -to make sure they are valid (should all be within 1 of the same -value). If valid, the numbers will be summed and presented as the +This test consists of 5 threads created at the same priority that +voluntarily release control to each other in a round-robin fashion. +Each thread will increment its run counter and then relinquish to +the next thread. At the end of the test the counters will be verified +to make sure they are valid (should all be within 1 of the same +value). If valid, the numbers will be summed and presented as the result of the cooperative scheduling test. 1.3. Preemptive Scheduling Test -This test consists of 5 threads that each have a unique priority. -In this test, all threads except the lowest priority thread are -left in a suspended state. The lowest priority thread will resume -the next highest priority thread. That thread will resume the -next highest priority thread and so on until the highest priority -thread executes. Each thread will increment its run count and then -call thread suspend. Eventually the processing will return to the -lowest priority thread, which is still in the middle of the thread -resume call. Once processing returns to the lowest priority thread, -it will increment its run counter and once again resume the next +This test consists of 5 threads that each have a unique priority. +In this test, all threads except the lowest priority thread are +left in a suspended state. The lowest priority thread will resume +the next highest priority thread. That thread will resume the +next highest priority thread and so on until the highest priority +thread executes. Each thread will increment its run count and then +call thread suspend. Eventually the processing will return to the +lowest priority thread, which is still in the middle of the thread +resume call. Once processing returns to the lowest priority thread, +it will increment its run counter and once again resume the next highest priority thread - starting the whole process over once again. 1.4. Interrupt Processing Test -This test consists of a single thread. The thread will cause an -interrupt (typically implemented as a trap), which will result in -a call to the interrupt handler. The interrupt handler will -increment a counter and then post to a semaphore. After the +This test consists of a single thread. The thread will cause an +interrupt (typically implemented as a trap), which will result in +a call to the interrupt handler. The interrupt handler will +increment a counter and then post to a semaphore. After the interrupt handler completes, processing returns to the test thread that initiated the interrupt. The thread then retrieves the semaphore set by the interrupt handler, increments a counter @@ -54,26 +54,26 @@ and then generates another interrupt. 1.5. Interrupt Preemption Processing Test This test is similar to the previous interrupt test. The big -difference is the interrupt handler in this test resumes a -higher priority thread, which causes thread preemption. +difference is the interrupt handler in this test resumes a +higher priority thread, which causes thread preemption. 1.6. Message Processing Test -This test consists of a thread sending a 16 byte message to a -queue and retrieving the same 16 byte message from the queue. -After the send/receive sequence is complete, the thread will +This test consists of a thread sending a 16 byte message to a +queue and retrieving the same 16 byte message from the queue. +After the send/receive sequence is complete, the thread will increment its run counter. 1.4. Synchronization Processing Test -This test consists of a thread getting a semaphore and then -immediately releasing it. After the get/put cycle completes, +This test consists of a thread getting a semaphore and then +immediately releasing it. After the get/put cycle completes, the thread will increment its run counter. 1.5. RTOS Memory allocation -This test consists of a thread allocating a 128-byte block and -releasing the same block. After the block is released, the thread +This test consists of a thread allocating a 128-byte block and +releasing the same block. After the block is released, the thread will increment its run counter. @@ -104,8 +104,8 @@ tm_message_processing_test.c Message exchange processing test tm_synchronization_processing_test.c Semaphore get/put processing test tm_memory_allocation_test.c Basic memory allocation test tm_porting_layer.h Port specific information, including - in-line assembly instruction to - cause an interrupt for the + in-line assembly instruction to + cause an interrupt for the interrupt processing tests tm_porting_layer_template.c Generic template for RTOS porting layer @@ -114,93 +114,93 @@ tm_porting_layer_threadx.c Specific porting layer source 2.1 Porting Layer -As for the porting layer defined in tm_porting_layer_template.c, this file contain -shell services of the generic RTOS services used by the actual tests. The -shell services provide the mapping between the tests and the underlying RTOS. -The following generic API's are required to map any RTOS to the performance +As for the porting layer defined in tm_porting_layer_template.c, this file contain +shell services of the generic RTOS services used by the actual tests. The +shell services provide the mapping between the tests and the underlying RTOS. +The following generic API's are required to map any RTOS to the performance measurement tests: void tm_initialize(void (*test_initialization_function)(void)); - This function is typically called by the application from its - main() function. It is responsible for providing all the RTOS - initialization, calling the test initialization function as + This function is typically called by the application from its + main() function. It is responsible for providing all the RTOS + initialization, calling the test initialization function as specified, and then starting the RTOS. int tm_thread_create(int thread_id, int priority, void (*entry_function)(void)); - This function creates a thread of the specified priority where 1 is - the highest and 16 is the lowest. If successful, TM_SUCCESS - returned. If an error occurs, TM_ERROR is returned. The created thread + This function creates a thread of the specified priority where 1 is + the highest and 16 is the lowest. If successful, TM_SUCCESS + returned. If an error occurs, TM_ERROR is returned. The created thread is not started. int tm_thread_resume(int thread_id); - This function resumes the previously created thread specified by + This function resumes the previously created thread specified by thread_id. If successful, a TM_SUCCESS is returned. int tm_thread_suspend(int thread_id); - This function suspend the previously created thread specified by + This function suspend the previously created thread specified by thread_id. If successful, a TM_SUCCESS is returned. void tm_thread_relinquish(void); - This function lets all other threads of same priority execute + This function lets all other threads of same priority execute before the calling thread runs again. void tm_thread_sleep(int seconds); - This function suspends the calling thread for the specified + This function suspends the calling thread for the specified number of seconds. int tm_queue_create(int queue_id); - This function creates a queue with a capacity to hold at least + This function creates a queue with a capacity to hold at least one 16-byte message. If successful, a TM_SUCCESS is returned. int tm_queue_send(int queue_id, unsigned long *message_ptr); - This function sends a message to the previously created queue. + This function sends a message to the previously created queue. If successful, a TM_SUCCESS is returned. int tm_queue_receive(int queue_id, unsigned long *message_ptr); - This function receives a message from the previously created + This function receives a message from the previously created queue. If successful, a TM_SUCCESS is returned. int tm_semaphore_create(int semaphore_id); - This function creates a binary semaphore. If successful, a + This function creates a binary semaphore. If successful, a TM_SUCCESS is returned. int tm_semaphore_get(int semaphore_id); - This function gets the previously created binary semaphore. + This function gets the previously created binary semaphore. If successful, a TM_SUCCESS is returned. int tm_semaphore_put(int semaphore_id); - This function puts the previously created binary semaphore. + This function puts the previously created binary semaphore. If successful, a TM_SUCCESS is returned. int tm_memory_pool_create(int pool_id); - This function creates a memory pool able to satisfy at least one + This function creates a memory pool able to satisfy at least one 128-byte block of memory. If successful, a TM_SUCCESS is returned. int tm_memory_pool_allocate(int pool_id, unsigned char **memory_ptr); - This function allocates a 128-byte block of memory from the - previously created memory pool. If successful, a TM_SUCCESS - is returned along with the pointer to the allocated memory + This function allocates a 128-byte block of memory from the + previously created memory pool. If successful, a TM_SUCCESS + is returned along with the pointer to the allocated memory in the "memory_ptr" variable. int tm_memory_pool_deallocate(int pool_id, unsigned char *memory_ptr); - This function releases the previously allocated 128-byte block - of memory. If successful, a TM_SUCCESS is returned. + This function releases the previously allocated 128-byte block + of memory. If successful, a TM_SUCCESS is returned. 2.2 Porting Requirements @@ -208,20 +208,20 @@ measurement tests: The following requirements are made in order to ensure fair benchmarks are achieved on each RTOS performing the test: - 1. Time period should be 30 seconds. This will ensure the printf + 1. Time period should be 30 seconds. This will ensure the printf processing in the reporting thread is insignificant. - 2. The porting layer services are implemented inside of + 2. The porting layer services are implemented inside of tm_porting_layer_[RTOS].c and NOT as macros. 3. The tm_thread_sleep service is implemented by a 10ms RTOS periodic interrupt source. - 4. Locking regions of the tests and/or the RTOS in cache is + 4. Locking regions of the tests and/or the RTOS in cache is not allowed. 5. The Interrupt Processing and Interrupt Preemption Processing tests - require an instruction that generates an interrupt. Please refer - to tm_porting_layer.h for an example implementation. + require an instruction that generates an interrupt. Please refer + to tm_porting_layer.h for an example implementation. diff --git a/utility/benchmarks/thread_metric/threadx_example/tm_porting_layer_threadx.c b/utility/benchmarks/thread_metric/threadx_example/tm_porting_layer_threadx.c index 405d9223..7490da44 100644 --- a/utility/benchmarks/thread_metric/threadx_example/tm_porting_layer_threadx.c +++ b/utility/benchmarks/thread_metric/threadx_example/tm_porting_layer_threadx.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Porting Layer (ThreadX Example) */ @@ -26,7 +27,7 @@ #endif -/* For smallest size, the ThreadX library and application code should be built +/* For smallest size, the ThreadX library and application code should be built with the following options defined (easiest to add in tx_port.h): #define TX_ENABLE_EXECUTION_CHANGE_NOTIFY @@ -110,7 +111,7 @@ void (*tm_initialization_function)(void); VOID tm_thread_entry(ULONG thread_input); -/* This function called from main performs basic RTOS initialization, +/* This function called from main performs basic RTOS initialization, calls the test initialization function, and then starts the RTOS function. */ void tm_initialize(void (*test_initialization_function)(void)) { @@ -119,13 +120,13 @@ void tm_initialize(void (*test_initialization_function)(void)) tm_initialization_function = test_initialization_function; /* Call the previously defined initialization function. */ - (tm_initialization_function)(); + (tm_initialization_function)(); } /* This function takes a thread ID and priority and attempts to create the - file in the underlying RTOS. Valid priorities range from 1 through 31, - where 1 is the highest priority and 31 is the lowest. If successful, + file in the underlying RTOS. Valid priorities range from 1 through 31, + where 1 is the highest priority and 31 is the lowest. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_thread_create(int thread_id, int priority, void (*entry_function)(void)) { @@ -197,7 +198,7 @@ void tm_thread_relinquish(void) /* This function suspends the specified thread for the specified number - of seconds. If successful, the function should return TM_SUCCESS. + of seconds. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ void tm_thread_sleep(int seconds) { @@ -216,7 +217,7 @@ UINT status; /* Create the specified queue with 16-byte messages. */ - status = tx_queue_create(&tm_queue_array[queue_id], "Thread-Metric test", TX_4_ULONG, + status = tx_queue_create(&tm_queue_array[queue_id], "Thread-Metric test", TX_4_ULONG, &tm_queue_memory_area[queue_id*TM_THREADX_QUEUE_SIZE], TM_THREADX_QUEUE_SIZE); /* Determine if the queue create was successful. */ @@ -227,7 +228,7 @@ UINT status; } -/* This function sends a 16-byte message to the specified queue. If successful, +/* This function sends a 16-byte message to the specified queue. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_queue_send(int queue_id, unsigned long *message_ptr) { @@ -246,7 +247,7 @@ UINT status; } -/* This function receives a 16-byte message from the specified queue. If successful, +/* This function receives a 16-byte message from the specified queue. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_queue_receive(int queue_id, unsigned long *message_ptr) { @@ -342,8 +343,8 @@ UINT status; } -/* This function allocates a 128 byte block from the specified memory pool. - If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR +/* This function allocates a 128 byte block from the specified memory pool. + If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_memory_pool_allocate(int pool_id, unsigned char **memory_ptr) { @@ -362,8 +363,8 @@ UINT status; } -/* This function releases a previously allocated 128 byte block from the specified - memory pool. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR +/* This function releases a previously allocated 128 byte block from the specified + memory pool. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_memory_pool_deallocate(int pool_id, unsigned char *memory_ptr) { diff --git a/utility/benchmarks/thread_metric/tm_api.h b/utility/benchmarks/thread_metric/tm_api.h index 85c8982c..74ac6b11 100644 --- a/utility/benchmarks/thread_metric/tm_api.h +++ b/utility/benchmarks/thread_metric/tm_api.h @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Application Interface (API) */ @@ -19,31 +20,25 @@ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* APPLICATION INTERFACE DEFINITION RELEASE */ -/* */ -/* tm_api.h PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ -/* This file defines the basic Application Interface (API) */ +/**************************************************************************/ +/* */ +/* APPLICATION INTERFACE DEFINITION RELEASE */ +/* */ +/* tm_api.h PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This file defines the basic Application Interface (API) */ /* implementation source code for the Thread-Metrics performance */ /* test suite. All service prototypes and data structure definitions */ -/* are defined in this file. */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ - +/* are defined in this file. */ +/* */ +/**************************************************************************/ + #ifndef TM_API_H #define TM_API_H diff --git a/utility/benchmarks/thread_metric/tm_basic_processing_test.c b/utility/benchmarks/thread_metric/tm_basic_processing_test.c index 27f3e48e..f1c4fa22 100644 --- a/utility/benchmarks/thread_metric/tm_basic_processing_test.c +++ b/utility/benchmarks/thread_metric/tm_basic_processing_test.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Basic Processing Test */ @@ -19,28 +20,22 @@ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* tm_basic_processing_test PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* tm_basic_processing_test PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ /* This file defines the basic test for determining board processing */ /* capabilities */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/**************************************************************************/ #include "tm_api.h" @@ -49,8 +44,8 @@ unsigned long tm_basic_processing_counter; -/* Test array. We will just do a series of calculations on the - test array to eat up processing bandwidth. The idea is that +/* Test array. We will just do a series of calculations on the + test array to eat up processing bandwidth. The idea is that all RTOSes should produce the same metric here if everything else is equal, e.g. processor speed, memory speed, etc. */ @@ -92,7 +87,7 @@ void tm_basic_processing_initialize(void) /* Resume thread 0. */ tm_thread_resume(0); - /* Create the reporting thread. It will preempt the other + /* Create the reporting thread. It will preempt the other threads and print out the test results. */ tm_thread_create(5, 2, tm_basic_processing_thread_report); tm_thread_resume(5); @@ -116,9 +111,9 @@ int i; while(1) { - /* Loop through the basic processing array, add the previous + /* Loop through the basic processing array, add the previous contents with the contents of the tm_basic_processing_counter - and xor the result with the previous value... just to eat + and xor the result with the previous value... just to eat up some time. */ for (i = 0; i < 1024; i++) { diff --git a/utility/benchmarks/thread_metric/tm_cooperative_scheduling_test.c b/utility/benchmarks/thread_metric/tm_cooperative_scheduling_test.c index b444c723..31d18c18 100644 --- a/utility/benchmarks/thread_metric/tm_cooperative_scheduling_test.c +++ b/utility/benchmarks/thread_metric/tm_cooperative_scheduling_test.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Cooperative Scheduling Test */ @@ -18,27 +19,21 @@ /**************************************************************************/ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* tm_cooperative_scheduling_test PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* tm_cooperative_scheduling_test PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ /* This file defines the cooperative scheduling test. */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/**************************************************************************/ #include "tm_api.h" @@ -99,7 +94,7 @@ void tm_cooperative_scheduling_initialize(void) tm_thread_resume(3); tm_thread_resume(4); - /* Create the reporting thread. It will preempt the other + /* Create the reporting thread. It will preempt the other threads and print out the test results. */ tm_thread_create(5, 2, tm_cooperative_thread_report); tm_thread_resume(5); @@ -112,7 +107,7 @@ void tm_cooperative_thread_0_entry(void) while(1) { - + /* Relinquish to all other threads at same priority. */ tm_thread_relinquish(); @@ -217,7 +212,7 @@ unsigned long average; /* Calculate the average of all the counters. */ average = total/5; - + /* WCC - integrity check */ printf("tm_cooperative_thread_0_counter: %d\n", tm_cooperative_thread_0_counter); printf("tm_cooperative_thread_1_counter: %d\n", tm_cooperative_thread_1_counter); @@ -226,15 +221,15 @@ unsigned long average; printf("tm_cooperative_thread_4_counter: %d\n", tm_cooperative_thread_4_counter); /* See if there are any errors. */ - if ((tm_cooperative_thread_0_counter < (average - 1)) || + if ((tm_cooperative_thread_0_counter < (average - 1)) || (tm_cooperative_thread_0_counter > (average + 1)) || - (tm_cooperative_thread_1_counter < (average - 1)) || + (tm_cooperative_thread_1_counter < (average - 1)) || (tm_cooperative_thread_1_counter > (average + 1)) || - (tm_cooperative_thread_2_counter < (average - 1)) || + (tm_cooperative_thread_2_counter < (average - 1)) || (tm_cooperative_thread_2_counter > (average + 1)) || - (tm_cooperative_thread_3_counter < (average - 1)) || + (tm_cooperative_thread_3_counter < (average - 1)) || (tm_cooperative_thread_3_counter > (average + 1)) || - (tm_cooperative_thread_4_counter < (average - 1)) || + (tm_cooperative_thread_4_counter < (average - 1)) || (tm_cooperative_thread_4_counter > (average + 1))) { diff --git a/utility/benchmarks/thread_metric/tm_interrupt_preemption_processing_test.c b/utility/benchmarks/thread_metric/tm_interrupt_preemption_processing_test.c index 3ed64a78..5b6aeec2 100644 --- a/utility/benchmarks/thread_metric/tm_interrupt_preemption_processing_test.c +++ b/utility/benchmarks/thread_metric/tm_interrupt_preemption_processing_test.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Interrupt Preemption Processing Test */ @@ -19,27 +20,21 @@ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* tm_interrupt_preemption_processing_test PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* tm_interrupt_preemption_processing_test PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ /* This file defines the preemptive scheduling test. */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/**************************************************************************/ #include "tm_api.h" @@ -97,14 +92,14 @@ void tm_interrupt_preemption_processing_initialize(void) /* Resume just thread 1. */ tm_thread_resume(1); - /* Create the reporting thread. It will preempt the other + /* Create the reporting thread. It will preempt the other threads and print out the test results. */ tm_thread_create(5, 2, tm_interrupt_preemption_thread_report); tm_thread_resume(5); } -/* Define the interrupt thread. This thread is resumed from the +/* Define the interrupt thread. This thread is resumed from the interrupt handler. It runs and suspends. */ void tm_interrupt_preemption_thread_0_entry(void) { @@ -115,7 +110,7 @@ void tm_interrupt_preemption_thread_0_entry(void) /* Increment this thread's counter. */ tm_interrupt_preemption_thread_0_counter++; - /* Suspend. This will allow the thread generating the + /* Suspend. This will allow the thread generating the interrupt to run again. */ tm_thread_suspend(0); } @@ -128,7 +123,7 @@ void tm_interrupt_preemption_thread_1_entry(void) while(1) { - /* Force an interrupt. The underlying RTOS must see that the + /* Force an interrupt. The underlying RTOS must see that the the interrupt handler is called from the appropriate software interrupt or trap. */ TM_CAUSE_INTERRUPT @@ -192,11 +187,11 @@ unsigned long average; average = total/3; /* See if there are any errors. */ - if ((tm_interrupt_preemption_thread_0_counter < (average - 1)) || + if ((tm_interrupt_preemption_thread_0_counter < (average - 1)) || (tm_interrupt_preemption_thread_0_counter > (average + 1)) || - (tm_interrupt_preemption_thread_1_counter < (average - 1)) || + (tm_interrupt_preemption_thread_1_counter < (average - 1)) || (tm_interrupt_preemption_thread_1_counter > (average + 1)) || - (tm_interrupt_preemption_handler_counter < (average - 1)) || + (tm_interrupt_preemption_handler_counter < (average - 1)) || (tm_interrupt_preemption_handler_counter > (average + 1))) { diff --git a/utility/benchmarks/thread_metric/tm_interrupt_processing_test.c b/utility/benchmarks/thread_metric/tm_interrupt_processing_test.c index 6591593e..69d156d9 100644 --- a/utility/benchmarks/thread_metric/tm_interrupt_processing_test.c +++ b/utility/benchmarks/thread_metric/tm_interrupt_processing_test.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Interrupt Processing Test */ @@ -18,27 +19,21 @@ /**************************************************************************/ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* tm_interrupt_processing_test PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* tm_interrupt_processing_test PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ /* This file defines the No-preemption interrupt processing test. */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/**************************************************************************/ #include "tm_api.h" @@ -87,14 +82,14 @@ void tm_interrupt_processing_initialize(void) /* Create thread that generates the interrupt at priority 10. */ tm_thread_create(0, 10, tm_interrupt_thread_0_entry); - /* Create a semaphore that will be posted from the interrupt + /* Create a semaphore that will be posted from the interrupt handler. */ tm_semaphore_create(0); /* Resume just thread 0. */ tm_thread_resume(0); - /* Create the reporting thread. It will preempt the other + /* Create the reporting thread. It will preempt the other threads and print out the test results. */ tm_thread_create(5, 2, tm_interrupt_thread_report); tm_thread_resume(5); @@ -118,13 +113,13 @@ int status; while(1) { - /* Force an interrupt. The underlying RTOS must see that the + /* Force an interrupt. The underlying RTOS must see that the the interrupt handler is called from the appropriate software interrupt or trap. */ TM_CAUSE_INTERRUPT /* We won't get back here until the interrupt processing is complete, - including the setting of the semaphore from the interrupt + including the setting of the semaphore from the interrupt handler. */ /* Pickup the semaphore set by the interrupt handler. */ @@ -189,9 +184,9 @@ unsigned long average; average = total/2; /* See if there are any errors. */ - if ((tm_interrupt_thread_0_counter < (average - 1)) || + if ((tm_interrupt_thread_0_counter < (average - 1)) || (tm_interrupt_thread_0_counter > (average + 1)) || - (tm_interrupt_handler_counter < (average - 1)) || + (tm_interrupt_handler_counter < (average - 1)) || (tm_interrupt_handler_counter > (average + 1))) { diff --git a/utility/benchmarks/thread_metric/tm_memory_allocation_test.c b/utility/benchmarks/thread_metric/tm_memory_allocation_test.c index 9e88861f..fc1c40d7 100644 --- a/utility/benchmarks/thread_metric/tm_memory_allocation_test.c +++ b/utility/benchmarks/thread_metric/tm_memory_allocation_test.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Memory Allocation Test */ @@ -18,27 +19,21 @@ /**************************************************************************/ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* tm_memory_allocation_test PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* tm_memory_allocation_test PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ /* This file defines the Message exchange processing test. */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/**************************************************************************/ #include "tm_api.h" @@ -86,7 +81,7 @@ void tm_memory_allocation_initialize(void) /* Create a memory pool. */ tm_memory_pool_create(0); - /* Create the reporting thread. It will preempt the other + /* Create the reporting thread. It will preempt the other threads and print out the test results. */ tm_thread_create(5, 2, tm_memory_allocation_thread_report); tm_thread_resume(5); diff --git a/utility/benchmarks/thread_metric/tm_message_processing_test.c b/utility/benchmarks/thread_metric/tm_message_processing_test.c index c709252b..f82da79e 100644 --- a/utility/benchmarks/thread_metric/tm_message_processing_test.c +++ b/utility/benchmarks/thread_metric/tm_message_processing_test.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Message Processing Test */ @@ -19,27 +20,21 @@ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* FUCTION RELEASE */ -/* */ -/* tm_message_processing_test PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/**************************************************************************/ +/* */ +/* FUCTION RELEASE */ +/* */ +/* tm_message_processing_test PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ /* Basic test for message exchange processing. */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/**************************************************************************/ #include "tm_api.h" @@ -89,7 +84,7 @@ void tm_message_processing_initialize(void) /* Create a queue for the message passing. */ tm_queue_create(0); - /* Create the reporting thread. It will preempt the other + /* Create the reporting thread. It will preempt the other threads and print out the test results. */ tm_thread_create(5, 2, tm_message_processing_thread_report); tm_thread_resume(5); @@ -107,7 +102,7 @@ void tm_message_processing_thread_0_entry(void) tm_message_sent[3] = 0x77778888; while(1) - { + { /* Send a message to the queue. */ tm_queue_send(0, tm_message_sent); diff --git a/utility/benchmarks/thread_metric/tm_porting_layer.h b/utility/benchmarks/thread_metric/tm_porting_layer.h index 3e9e2d63..ec1b7a26 100644 --- a/utility/benchmarks/thread_metric/tm_porting_layer.h +++ b/utility/benchmarks/thread_metric/tm_porting_layer.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -14,9 +15,9 @@ #include <stdio.h> -/* Define the TRAP instruction. This is used by the Interrupt Processing and Interrupt Preemption Processing tests. - The SVC instruction below is for Cortex-M architectures using IAR tools. This will likely need to be modified - for different processors and/or development tools. +/* Define the TRAP instruction. This is used by the Interrupt Processing and Interrupt Preemption Processing tests. + The SVC instruction below is for Cortex-M architectures using IAR tools. This will likely need to be modified + for different processors and/or development tools. Note also that for the Interrupt Processing test there is the assumption that the SVC ISR looks like: diff --git a/utility/benchmarks/thread_metric/tm_porting_layer_template.c b/utility/benchmarks/thread_metric/tm_porting_layer_template.c index c0460802..fcbc59a8 100644 --- a/utility/benchmarks/thread_metric/tm_porting_layer_template.c +++ b/utility/benchmarks/thread_metric/tm_porting_layer_template.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Porting Layer (Must be completed with RTOS specifics) */ @@ -24,7 +25,7 @@ #include "tm_api.h" -/* This function called from main performs basic RTOS initialization, +/* This function called from main performs basic RTOS initialization, calls the test initialization function, and then starts the RTOS function. */ void tm_initialize(void (*test_initialization_function)(void)) { @@ -33,8 +34,8 @@ void tm_initialize(void (*test_initialization_function)(void)) /* This function takes a thread ID and priority and attempts to create the - file in the underlying RTOS. Valid priorities range from 1 through 31, - where 1 is the highest priority and 31 is the lowest. If successful, + file in the underlying RTOS. Valid priorities range from 1 through 31, + where 1 is the highest priority and 31 is the lowest. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_thread_create(int thread_id, int priority, void (*entry_function)(void)) { @@ -67,7 +68,7 @@ void tm_thread_relinquish(void) /* This function suspends the specified thread for the specified number - of seconds. If successful, the function should return TM_SUCCESS. + of seconds. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ void tm_thread_sleep(int seconds) { @@ -83,7 +84,7 @@ int tm_queue_create(int queue_id) } -/* This function sends a 16-byte message to the specified queue. If successful, +/* This function sends a 16-byte message to the specified queue. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_queue_send(int queue_id, unsigned long *message_ptr) { @@ -91,7 +92,7 @@ int tm_queue_send(int queue_id, unsigned long *message_ptr) } -/* This function receives a 16-byte message from the specified queue. If successful, +/* This function receives a 16-byte message from the specified queue. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_queue_receive(int queue_id, unsigned long *message_ptr) { @@ -132,8 +133,8 @@ int tm_memory_pool_create(int pool_id) } -/* This function allocates a 128 byte block from the specified memory pool. - If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR +/* This function allocates a 128 byte block from the specified memory pool. + If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_memory_pool_allocate(int pool_id, unsigned char **memory_ptr) { @@ -141,8 +142,8 @@ int tm_memory_pool_allocate(int pool_id, unsigned char **memory_ptr) } -/* This function releases a previously allocated 128 byte block from the specified - memory pool. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR +/* This function releases a previously allocated 128 byte block from the specified + memory pool. If successful, the function should return TM_SUCCESS. Otherwise, TM_ERROR should be returned. */ int tm_memory_pool_deallocate(int pool_id, unsigned char *memory_ptr) { diff --git a/utility/benchmarks/thread_metric/tm_preemptive_scheduling_test.c b/utility/benchmarks/thread_metric/tm_preemptive_scheduling_test.c index 95ee4be8..ef3222f3 100644 --- a/utility/benchmarks/thread_metric/tm_preemptive_scheduling_test.c +++ b/utility/benchmarks/thread_metric/tm_preemptive_scheduling_test.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Preemptive Scheduling Test */ @@ -18,27 +19,21 @@ /**************************************************************************/ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* tm_preemptive_scheduling_test PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* tm_preemptive_scheduling_test PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ /* This file defines the preemptive scheduling test. */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/**************************************************************************/ #include "tm_api.h" @@ -103,7 +98,7 @@ void tm_preemptive_scheduling_initialize(void) /* Resume just thread 0. */ tm_thread_resume(0); - /* Create the reporting thread. It will preempt the other + /* Create the reporting thread. It will preempt the other threads and print out the test results. */ tm_thread_create(5, 2, tm_preemptive_thread_report); tm_thread_resume(5); @@ -245,15 +240,15 @@ unsigned long average; average = total/5; /* See if there are any errors. */ - if ((tm_preemptive_thread_0_counter < (average - 1)) || + if ((tm_preemptive_thread_0_counter < (average - 1)) || (tm_preemptive_thread_0_counter > (average + 1)) || - (tm_preemptive_thread_1_counter < (average - 1)) || + (tm_preemptive_thread_1_counter < (average - 1)) || (tm_preemptive_thread_1_counter > (average + 1)) || - (tm_preemptive_thread_2_counter < (average - 1)) || + (tm_preemptive_thread_2_counter < (average - 1)) || (tm_preemptive_thread_2_counter > (average + 1)) || - (tm_preemptive_thread_3_counter < (average - 1)) || + (tm_preemptive_thread_3_counter < (average - 1)) || (tm_preemptive_thread_3_counter > (average + 1)) || - (tm_preemptive_thread_4_counter < (average - 1)) || + (tm_preemptive_thread_4_counter < (average - 1)) || (tm_preemptive_thread_4_counter > (average + 1))) { diff --git a/utility/benchmarks/thread_metric/tm_synchronization_processing_test.c b/utility/benchmarks/thread_metric/tm_synchronization_processing_test.c index 103ad7ea..6fa2a187 100644 --- a/utility/benchmarks/thread_metric/tm_synchronization_processing_test.c +++ b/utility/benchmarks/thread_metric/tm_synchronization_processing_test.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ +/** */ /** Thread-Metric Component */ /** */ /** Synchronization Processing Test */ @@ -18,27 +19,21 @@ /**************************************************************************/ /**************************************************************************/ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* tm_synchronization_processing_test PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* tm_synchronization_processing_test PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ /* This file defines the Semaphore get/put processing test. */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 10-15-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/**************************************************************************/ #include "tm_api.h" @@ -86,7 +81,7 @@ void tm_synchronization_processing_initialize(void) /* Create a semaphore for the test. */ tm_semaphore_create(0); - /* Create the reporting thread. It will preempt the other + /* Create the reporting thread. It will preempt the other threads and print out the test results. */ tm_thread_create(5, 2, tm_synchronization_processing_thread_report); tm_thread_resume(5); diff --git a/utility/execution_profile_kit/smp_version/tx_execution_profile.c b/utility/execution_profile_kit/smp_version/tx_execution_profile.c index 3b5c05a2..735dbf14 100644 --- a/utility/execution_profile_kit/smp_version/tx_execution_profile.c +++ b/utility/execution_profile_kit/smp_version/tx_execution_profile.c @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -27,44 +28,44 @@ #include "tx_api.h" #include "tx_execution_profile.h" -/* The thread execution profile kit is designed to track thread execution time - based on the hardware timer defined by TX_EXECUTION_TIME_SOURCE and - TX_EXECUTION_MAX_TIME_SOURCE below. When the thread's total time reaches +/* The thread execution profile kit is designed to track thread execution time + based on the hardware timer defined by TX_EXECUTION_TIME_SOURCE and + TX_EXECUTION_MAX_TIME_SOURCE below. When the thread's total time reaches the maximum value, it remains there until the time is reset to 0 via a call - to tx_thread_execution_time_reset. There are several assumptions to the + to tx_thread_execution_time_reset. There are several assumptions to the operation of this kit, as follows: 1. In tx_port.h replace: - - #define TX_THREAD_EXTENSION_3" - + + #define TX_THREAD_EXTENSION_3" + with: - + #define TX_THREAD_EXTENSION_3 unsigned long long tx_thread_execution_time_total; \ - unsigned long tx_thread_execution_time_last_start; - + unsigned long tx_thread_execution_time_last_start; + Note: if 64-bit time source is present, the tx_thread_execution_time_last_start type should be unsigned long long. - 2. The TX_EXECUTION_TIME_SOURCE and TX_EXECUTION_MAX_TIME_SOURCE macros are + 2. The TX_EXECUTION_TIME_SOURCE and TX_EXECUTION_MAX_TIME_SOURCE macros are defined to utilize a local hardware time source. - + 3. ThreadX 5.4 (or later) is being used, with the assembly code enabled to call the following routines from assembly code: - + VOID _tx_execution_thread_enter(void); VOID _tx_execution_thread_exit(void); VOID _tx_execution_isr_enter(void); VOID _tx_execution_isr_exit(void); - - 4. The ThreadX library assembly code must be rebuilt with TX_ENABLE_EXECUTION_CHANGE_NOTIFY so - that these macros are expanded in the TX_THREAD structure and so the assembly code macros - are enabled to call the execution profile routines. + + 4. The ThreadX library assembly code must be rebuilt with TX_ENABLE_EXECUTION_CHANGE_NOTIFY so + that these macros are expanded in the TX_THREAD structure and so the assembly code macros + are enabled to call the execution profile routines. 5. Add tx_execution_profile.c to the application build. */ /* Externally reference several internal ThreadX variables. */ - + extern ULONG _tx_thread_system_state[TX_THREAD_SMP_MAX_CORES]; extern UINT _tx_thread_preempt_disable; extern TX_THREAD *_tx_thread_current_ptr[TX_THREAD_SMP_MAX_CORES]; @@ -83,11 +84,11 @@ EXECUTION_TIME _tx_execution_thread_time_total[TX_THREAD_SM and _tx_thread_context_restore are tracked by this utility. */ EXECUTION_TIME _tx_execution_isr_time_total[TX_THREAD_SMP_MAX_CORES]; -EXECUTION_TIME_SOURCE_TYPE _tx_execution_isr_time_last_start[TX_THREAD_SMP_MAX_CORES]; +EXECUTION_TIME_SOURCE_TYPE _tx_execution_isr_time_last_start[TX_THREAD_SMP_MAX_CORES]; /* Define the system idle time gathering information. For idle time that exceeds the range of the timer - source, another timer source may be needed. In addition, the total thread execution time added to the + source, another timer source may be needed. In addition, the total thread execution time added to the total ISR time, less the total system time is also a measure of idle time. */ EXECUTION_TIME _tx_execution_idle_time_total[TX_THREAD_SMP_MAX_CORES]; @@ -124,12 +125,6 @@ EXECUTION_TIME_SOURCE_TYPE _tx_execution_idle_time_last_start[TX_THREAD /* */ /* _tx_thread_schedule Thread scheduling */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 07-29-2022 William E. Lamie Initial Version 6.1.12 */ -/* */ /**************************************************************************/ VOID _tx_execution_thread_enter(void) { @@ -155,10 +150,10 @@ UINT core; /* This thread is being scheduled. Simply setup the last start time in the thread control block. */ thread_ptr -> tx_thread_execution_time_last_start = current_time; - + /* Pickup the last idle start time. */ last_start_time = _tx_execution_idle_time_last_start[core]; - + /* Determine if idle time is being measured. */ if (last_start_time) { @@ -166,34 +161,34 @@ UINT core; /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); - } + } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + (((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) - last_start_time)); } - + /* Pickup the total time. */ total_time = _tx_execution_idle_time_total[core]; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Now store back the total idle time. */ - _tx_execution_idle_time_total[core] = new_total_time; - + _tx_execution_idle_time_total[core] = new_total_time; + /* Disable the idle time measurement. */ _tx_execution_idle_time_last_start[core] = 0; } @@ -258,7 +253,7 @@ UINT core; /* Determine if there is a thread. */ if (thread_ptr) { - + /* Pickup the current time. */ current_time = TX_EXECUTION_TIME_SOURCE; @@ -271,17 +266,17 @@ UINT core; /* Clear the last start time. */ thread_ptr -> tx_thread_execution_time_last_start = 0; - + /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); - } + } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + (((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) - last_start_time)); } @@ -291,37 +286,37 @@ UINT core; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Store back the new total time. */ thread_ptr -> tx_thread_execution_time_total = new_total_time; - + /* Now accumulate this thread's execution time into the total thread execution time. */ new_total_time = _tx_execution_thread_time_total[core] + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < _tx_execution_thread_time_total[core]) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; - } + } /* Store back the new total time. */ _tx_execution_thread_time_total[core] = new_total_time; } - + /* Is the system now idle? */ if (_tx_thread_execute_ptr[core] == TX_NULL) { - + /* Yes, idle system. Pickup the start of idle time. */ _tx_execution_idle_time_last_start[core] = TX_EXECUTION_TIME_SOURCE; } @@ -381,7 +376,7 @@ UINT core; /* Pickup the core index. */ core = TX_SMP_CORE_ID; - /* Determine if this is the first interrupt. Nested interrupts are all treated as + /* Determine if this is the first interrupt. Nested interrupts are all treated as general interrupt processing. */ if (_tx_thread_system_state[core] == 1) { @@ -394,7 +389,7 @@ UINT core; /* Determine if a thread was interrupted. */ if (thread_ptr) { - + /* Pickup the last start time. */ last_start_time = thread_ptr -> tx_thread_execution_time_last_start; @@ -404,17 +399,17 @@ UINT core; /* Clear the last start time. */ thread_ptr -> tx_thread_execution_time_last_start = 0; - + /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); - } + } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + (((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) - last_start_time)); } @@ -424,72 +419,72 @@ UINT core; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Store back the new total time. */ thread_ptr -> tx_thread_execution_time_total = new_total_time; /* Now accumulate this thread's execution time into the total thread execution time. */ new_total_time = _tx_execution_thread_time_total[core] + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < _tx_execution_thread_time_total[core]) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; - } + } /* Store back the new total time. */ _tx_execution_thread_time_total[core] = new_total_time; } } - + /* Has idle time started? */ else if (_tx_execution_idle_time_last_start[core]) { - + /* Pickup the last idle start time. */ last_start_time = _tx_execution_idle_time_last_start[core]; - + /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); - } + } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + (((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) - last_start_time)); } - + /* Pickup the total time. */ total_time = _tx_execution_idle_time_total[core]; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Now store back the total idle time. */ - _tx_execution_idle_time_total[core] = new_total_time; - + _tx_execution_idle_time_total[core] = new_total_time; + /* Disable the idle time measurement. */ _tx_execution_idle_time_last_start[core] = 0; } @@ -552,7 +547,7 @@ UINT core; /* Pickup the core index. */ core = TX_SMP_CORE_ID; - /* Determine if this is the first interrupt. Nested interrupts are all treated as + /* Determine if this is the first interrupt. Nested interrupts are all treated as general interrupt processing. */ if (_tx_thread_system_state[core] == 1) { @@ -562,17 +557,17 @@ UINT core; /* Pickup the last start time. */ last_start_time = _tx_execution_isr_time_last_start[core]; - + /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + (((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) - last_start_time)); } @@ -582,18 +577,18 @@ UINT core; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Store back the new total time. */ _tx_execution_isr_time_total[core] = new_total_time; - + /* Pickup the current thread control block. */ thread_ptr = _tx_thread_current_ptr[core]; @@ -604,16 +599,16 @@ UINT core; /* Now determine if the thread will execution is going to occur immediately. */ if ((thread_ptr == _tx_thread_execute_ptr[core]) || (_tx_thread_preempt_disable)) { - + /* Yes, setup the thread last start time in the thread control block. */ thread_ptr -> tx_thread_execution_time_last_start = current_time; } } - + /* Determine if the system is now idle. */ if (_tx_thread_execute_ptr[core] == TX_NULL) { - + /* Yes, idle system. Pickup the start of idle time. */ _tx_execution_idle_time_last_start[core] = TX_EXECUTION_TIME_SOURCE; } @@ -710,8 +705,8 @@ UINT _tx_execution_thread_total_time_reset(void) { TX_INTERRUPT_SAVE_AREA - -TX_THREAD *thread_ptr; + +TX_THREAD *thread_ptr; UINT total_threads; UINT core; @@ -722,7 +717,7 @@ UINT core; /* Reset the total time for all cores. */ for (core = 0; core < TX_THREAD_SMP_MAX_CORES; core++) { - + _tx_execution_thread_time_total[core] = 0; } @@ -799,7 +794,7 @@ UINT core; /* Restore interrupts. */ TX_RESTORE - + /* Return success. */ return(TX_SUCCESS); } @@ -969,10 +964,10 @@ UINT core; *total_time = _tx_execution_thread_time_total[core]; } - + /* Restore interrupts. */ TX_RESTORE - + /* Return success. */ return(TX_SUCCESS); } @@ -1032,7 +1027,7 @@ UINT core; /* Return the total time. */ *total_time = _tx_execution_isr_time_total[core]; } - + /* Restore interrupts. */ TX_RESTORE @@ -1149,14 +1144,14 @@ UINT _tx_execution_core_thread_total_time_get(UINT core, EXECUTION_TIME *total_ /* Determine if the core is valid. */ if (core >= TX_THREAD_SMP_MAX_CORES) { - + /* Invalid core, return an error. */ return(TX_NOT_DONE); } /* Return the total thread time for the core. */ *total_time = _tx_execution_thread_time_total[core]; - + /* Return success. */ return(TX_SUCCESS); } @@ -1207,7 +1202,7 @@ UINT _tx_execution_core_isr_time_get(UINT core, EXECUTION_TIME *total_time) /* Determine if the core is valid. */ if (core >= TX_THREAD_SMP_MAX_CORES) { - + /* Invalid core, return an error. */ return(TX_NOT_DONE); } @@ -1264,7 +1259,7 @@ UINT _tx_execution_core_idle_time_get(UINT core, EXECUTION_TIME *total_time) /* Determine if the core is valid. */ if (core >= TX_THREAD_SMP_MAX_CORES) { - + /* Invalid core, return an error. */ return(TX_NOT_DONE); } diff --git a/utility/execution_profile_kit/smp_version/tx_execution_profile.h b/utility/execution_profile_kit/smp_version/tx_execution_profile.h index 1d1ac587..fee0e17c 100644 --- a/utility/execution_profile_kit/smp_version/tx_execution_profile.h +++ b/utility/execution_profile_kit/smp_version/tx_execution_profile.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -24,20 +25,20 @@ #define TX_EXECUTION_PROFILE_H -/* The thread execution profile kit is designed to track thread execution time - based on the hardware timer defined by TX_EXECUTION_TIME_SOURCE and - TX_EXECUTION_MAX_TIME_SOURCE below. When the thread's total time reaches +/* The thread execution profile kit is designed to track thread execution time + based on the hardware timer defined by TX_EXECUTION_TIME_SOURCE and + TX_EXECUTION_MAX_TIME_SOURCE below. When the thread's total time reaches the maximum value, it remains there until the time is reset to 0 via a call - to tx_thread_execution_time_reset. There are several assumptions to the + to tx_thread_execution_time_reset. There are several assumptions to the operation of this kit, as follows: 1. In tx_port.h replace: #define TX_THREAD_EXTENSION_3" with: #define TX_THREAD_EXTENSION_3 unsigned long long tx_thread_execution_time_total; \ - unsigned long tx_thread_execution_time_last_start; + unsigned long tx_thread_execution_time_last_start; - 2. The TX_EXECUTION_TIME_SOURCE and TX_EXECUTION_MAX_TIME_SOURCE macros are + 2. The TX_EXECUTION_TIME_SOURCE and TX_EXECUTION_MAX_TIME_SOURCE macros are defined to utilize a local hardware time source. 3. The following routines are called from assembly code: @@ -46,9 +47,9 @@ VOID _tx_execution_isr_enter(void); VOID _tx_execution_isr_exit(void); - 4. The ThreadX library must be rebuilt with TX_ENABLE_EXECUTION_CHANGE_NOTIFY so - that these macros are expanded in the TX_THREAD structure and so the assembly code macros - are enabled to call the execution profile routines. + 4. The ThreadX library must be rebuilt with TX_ENABLE_EXECUTION_CHANGE_NOTIFY so + that these macros are expanded in the TX_THREAD structure and so the assembly code macros + are enabled to call the execution profile routines. 5. Add tx_execution_profile.c to the application build. */ diff --git a/utility/execution_profile_kit/tx_execution_profile.c b/utility/execution_profile_kit/tx_execution_profile.c index 284e0ccd..e0427307 100644 --- a/utility/execution_profile_kit/tx_execution_profile.c +++ b/utility/execution_profile_kit/tx_execution_profile.c @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -49,15 +50,15 @@ 1. The TX_EXECUTION_TIME_SOURCE and TX_EXECUTION_MAX_TIME_SOURCE macros are defined to utilize a local hardware time source. - + 2. ThreadX 5.4 (or later) is being used, with the assembly code enabled to call the following routines from assembly code: - + VOID _tx_execution_thread_enter(void); VOID _tx_execution_thread_exit(void); VOID _tx_execution_isr_enter(void); VOID _tx_execution_isr_exit(void); - + 3. The ThreadX library assembly code must be rebuilt with TX_EXECUTION_PROFILE_ENABLE so that these macros are expanded in the TX_THREAD structure and so the assembly code macros are enabled to call the execution profile routines. @@ -66,7 +67,7 @@ /* Externally reference several internal ThreadX variables. */ - + extern ULONG _tx_thread_system_state; extern UINT _tx_thread_preempt_disable; extern TX_THREAD *_tx_thread_current_ptr; @@ -89,7 +90,7 @@ EXECUTION_TIME_SOURCE_TYPE _tx_execution_isr_time_last_start; /* Define the system idle time gathering information. For idle time that exceeds the range of the timer - source, another timer source may be needed. In addition, the total thread execution time added to the + source, another timer source may be needed. In addition, the total thread execution time added to the total ISR time, less the total system time is also a measure of idle time. */ EXECUTION_TIME _tx_execution_idle_time_total; @@ -132,12 +133,6 @@ ULONG _tx_execution_isr_nest_counter = 0; /* */ /* xxx xxx */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 04-25-2022 Scott Larson Initial Version 6.1.11 */ -/* */ /**************************************************************************/ VOID _tx_execution_initialize(void) { @@ -209,10 +204,10 @@ EXECUTION_TIME new_total_time; /* This thread is being scheduled. Simply setup the last start time in the thread control block. */ thread_ptr -> tx_thread_execution_time_last_start = current_time; - + /* Pickup the last idle start time. */ last_start_time = _tx_execution_idle_time_last_start; - + /* Determine if idle time is being measured. */ if (_tx_execution_idle_active) { @@ -220,34 +215,34 @@ EXECUTION_TIME new_total_time; /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + ((((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) + 1) - last_start_time)); } - + /* Pickup the total time. */ total_time = _tx_execution_idle_time_total; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Now store back the total idle time. */ _tx_execution_idle_time_total = new_total_time; - + /* Disable the idle time measurement. */ _tx_execution_idle_active = TX_FALSE; } @@ -311,7 +306,7 @@ EXECUTION_TIME delta_time; /* Determine if there is a thread. */ if (thread_ptr) { - + /* Pickup the current time. */ current_time = TX_EXECUTION_TIME_SOURCE; @@ -324,17 +319,17 @@ EXECUTION_TIME delta_time; /* Clear the last start time. */ thread_ptr -> tx_thread_execution_time_last_start = 0; - + /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); - } + } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + ((((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) + 1) - last_start_time)); } @@ -344,25 +339,25 @@ EXECUTION_TIME delta_time; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Store back the new total time. */ thread_ptr -> tx_thread_execution_time_total = new_total_time; - + /* Now accumulate this thread's execution time into the total thread execution time. */ new_total_time = _tx_execution_thread_time_total + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < _tx_execution_thread_time_total) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } @@ -454,7 +449,7 @@ EXECUTION_TIME delta_time; /* Determine if a thread was interrupted. */ if (thread_ptr) { - + /* Pickup the last start time. */ last_start_time = thread_ptr -> tx_thread_execution_time_last_start; @@ -464,17 +459,17 @@ EXECUTION_TIME delta_time; /* Clear the last start time. */ thread_ptr -> tx_thread_execution_time_last_start = 0; - + /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); - } + } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + ((((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) + 1) - last_start_time)); } @@ -484,72 +479,72 @@ EXECUTION_TIME delta_time; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Store back the new total time. */ thread_ptr -> tx_thread_execution_time_total = new_total_time; /* Now accumulate this thread's execution time into the total thread execution time. */ new_total_time = _tx_execution_thread_time_total + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < _tx_execution_thread_time_total) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; - } + } /* Store back the new total time. */ _tx_execution_thread_time_total = new_total_time; } } - + /* Has idle time started? */ else if (_tx_execution_idle_active) { - + /* Pickup the last idle start time. */ last_start_time = _tx_execution_idle_time_last_start; - + /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); - } + } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + ((((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) + 1) - last_start_time)); } - + /* Pickup the total time. */ total_time = _tx_execution_idle_time_total; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Now store back the total idle time. */ - _tx_execution_idle_time_total = new_total_time; - + _tx_execution_idle_time_total = new_total_time; + /* Disable the idle time measurement. */ _tx_execution_idle_active = TX_FALSE; } @@ -611,7 +606,7 @@ EXECUTION_TIME_SOURCE_TYPE current_time; EXECUTION_TIME delta_time; - /* Determine if this is the first interrupt. Nested interrupts are all treated as + /* Determine if this is the first interrupt. Nested interrupts are all treated as general interrupt processing. */ #ifdef TX_CORTEX_M_EPK if ((TX_THREAD_GET_SYSTEM_STATE()) && (_tx_execution_isr_nest_counter == 1)) @@ -625,17 +620,17 @@ EXECUTION_TIME delta_time; /* Pickup the last start time. */ last_start_time = _tx_execution_isr_time_last_start; - + /* Determine how to calculate the difference. */ if (current_time >= last_start_time) { - + /* Simply subtract. */ delta_time = (EXECUTION_TIME) (current_time - last_start_time); } else { - + /* Timer wrapped, compute the delta assuming incrementing time counter. */ delta_time = (EXECUTION_TIME) (current_time + (((EXECUTION_TIME_SOURCE_TYPE) TX_EXECUTION_MAX_TIME_SOURCE) - last_start_time)); } @@ -645,18 +640,18 @@ EXECUTION_TIME delta_time; /* Now compute the new total time. */ new_total_time = total_time + delta_time; - + /* Determine if a rollover on the total time is present. */ if (new_total_time < total_time) { - + /* Rollover. Set the total time to max value. */ new_total_time = (EXECUTION_TIME) TX_EXECUTION_MAX_TIME_SOURCE; } - + /* Store back the new total time. */ _tx_execution_isr_time_total = new_total_time; - + /* Pickup the current thread control block. */ thread_ptr = _tx_thread_current_ptr; @@ -667,22 +662,22 @@ EXECUTION_TIME delta_time; /* Now determine if the thread will execution is going to occur immediately. */ if ((thread_ptr == _tx_thread_execute_ptr) || (_tx_thread_preempt_disable)) { - + /* Yes, setup the thread last start time in the thread control block. */ thread_ptr -> tx_thread_execution_time_last_start = current_time; } } - + /* Determine if the system is now idle. */ if (_tx_thread_execute_ptr == TX_NULL) { - + /* Yes, idle system. Pickup the start of idle time. */ _tx_execution_idle_time_last_start = TX_EXECUTION_TIME_SOURCE; _tx_execution_idle_active = TX_TRUE; } } - + #ifdef TX_CORTEX_M_EPK /* Decrement the nested interrupt counter. */ _tx_execution_isr_nest_counter--; @@ -779,8 +774,8 @@ UINT _tx_execution_thread_total_time_reset(void) { TX_INTERRUPT_SAVE_AREA - -TX_THREAD *thread_ptr; + +TX_THREAD *thread_ptr; UINT total_threads; diff --git a/utility/execution_profile_kit/tx_execution_profile.h b/utility/execution_profile_kit/tx_execution_profile.h index 5bd34892..fa09ac2e 100644 --- a/utility/execution_profile_kit/tx_execution_profile.h +++ b/utility/execution_profile_kit/tx_execution_profile.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -24,14 +25,14 @@ #define TX_EXECUTION_PROFILE_H -/* The thread execution profile kit is designed to track thread execution time - based on the hardware timer defined by TX_EXECUTION_TIME_SOURCE and - TX_EXECUTION_MAX_TIME_SOURCE below. When the thread's total time reaches +/* The thread execution profile kit is designed to track thread execution time + based on the hardware timer defined by TX_EXECUTION_TIME_SOURCE and + TX_EXECUTION_MAX_TIME_SOURCE below. When the thread's total time reaches the maximum value, it remains there until the time is reset to 0 via a call - to tx_thread_execution_time_reset. There are several assumptions to the + to tx_thread_execution_time_reset. There are several assumptions to the operation of this kit, as follows: - 1. The TX_EXECUTION_TIME_SOURCE and TX_EXECUTION_MAX_TIME_SOURCE macros are + 1. The TX_EXECUTION_TIME_SOURCE and TX_EXECUTION_MAX_TIME_SOURCE macros are defined to utilize a local hardware time source. 2. The following routines are called from assembly code: @@ -40,8 +41,8 @@ VOID _tx_execution_isr_enter(void); VOID _tx_execution_isr_exit(void); - 3. The ThreadX library must be rebuilt with TX_EXECUTION_PROFILE_ENABLE so - the assembly code macros are enabled to call the execution profile routines. + 3. The ThreadX library must be rebuilt with TX_EXECUTION_PROFILE_ENABLE so + the assembly code macros are enabled to call the execution profile routines. 4. Add tx_execution_profile.c to the application build. */ diff --git a/utility/low_power/tx_low_power.c b/utility/low_power/tx_low_power.c index f9c07ee6..540a2bf8 100644 --- a/utility/low_power/tx_low_power.c +++ b/utility/low_power/tx_low_power.c @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -71,15 +72,6 @@ UINT tx_low_power_entered; /* */ /* _tx_thread_schedule Thread scheduling loop */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 03-02-2021 William E. Lamie Initial Version 6.1.5 */ -/* 04-02-2021 Scott Larson Modified comments and fixed */ -/* compiler warning, */ -/* resulting in version 6.1.6 */ -/* */ /**************************************************************************/ VOID tx_low_power_enter(VOID) { @@ -111,10 +103,10 @@ ULONG timers_active; Program the hardware timer source such that the next timer interrupt is equal to: tx_low_power_next_expiration*tick_frequency. In most applications, the tick_frequency is 10ms, but this is - completely application specific in ThreadX, typically set up + completely application specific in ThreadX, typically set up in tx_low_level_initialize. Note that in this situation, a low power clock must be used in order to wake up the CPU for the next timeout - event. Therefore an alternative clock must be programmed. + event. Therefore an alternative clock must be programmed. 2: There are no ThreadX timers active. tx_timer_get_next returns TX_FALSE. 2.a: application may choose not to keep the ThreadX internal tick count updated (define TX_LOW_POWER_TICKLESS), therefore no need @@ -142,7 +134,7 @@ ULONG timers_active; #endif /* TX_LOW_POWER_TIMER_SETUP */ - /* Set the flag indicating that low power has been entered. This + /* Set the flag indicating that low power has been entered. This flag is checked in tx_low_power_exit to determine if the logic used to adjust the ThreadX time is required. */ tx_low_power_entered = TX_TRUE; @@ -505,7 +497,7 @@ TX_TIMER_INTERNAL *temp_list_head; /* Now clear the current timer head pointer. */ *timer_list_head = TX_NULL; } - + /* Move to next timer entry. */ timer_list_head++; diff --git a/utility/low_power/tx_low_power.h b/utility/low_power/tx_low_power.h index 36c4b87a..f31cf5d2 100644 --- a/utility/low_power/tx_low_power.h +++ b/utility/low_power/tx_low_power.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -35,12 +36,6 @@ /* This file defines prototypes for the low-power timer additions */ /* required for sleep mode. */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 03-02-2021 William E. Lamie Initial Version 6.1.5 */ -/* */ /**************************************************************************/ #ifndef TX_LOW_POWER_H diff --git a/utility/rtos_compatibility_layers/FreeRTOS/FreeRTOS.h b/utility/rtos_compatibility_layers/FreeRTOS/FreeRTOS.h index 3245c8c6..18831299 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/FreeRTOS.h +++ b/utility/rtos_compatibility_layers/FreeRTOS/FreeRTOS.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -17,14 +18,6 @@ /** */ /**************************************************************************/ /**************************************************************************/ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 09-30-2020 William E. Lamie Initial Version 6.1 */ -/* 03-02-2021 Andres Mlinar Modified comment(s), fixed */ -/* interrupt macros, */ -/* resulting in version 6.1.5 */ /**************************************************************************/ #ifndef FREERTOS_H @@ -311,7 +304,7 @@ UINT _tx_thread_interrupt_disable(VOID); #elif defined(__ARMCC_VERSION) #define portENABLE_INTERRUPTS() __enable_irq() #else -VOID _tx_thread_interrupt_restore(UINT previous_posture); +VOID _tx_thread_interrupt_restore(UINT previous_posture); #define portENABLE_INTERRUPTS() _tx_thread_interrupt_restore(TX_INT_ENABLE) #endif #endif diff --git a/utility/rtos_compatibility_layers/FreeRTOS/config_template/FreeRTOSConfig.h b/utility/rtos_compatibility_layers/FreeRTOS/config_template/FreeRTOSConfig.h index d4a0df91..e31c0cdc 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/config_template/FreeRTOSConfig.h +++ b/utility/rtos_compatibility_layers/FreeRTOS/config_template/FreeRTOSConfig.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -17,15 +18,6 @@ /** */ /**************************************************************************/ /**************************************************************************/ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 09-30-2020 William E. Lamie Initial Version 6.1 */ -/* 10-31-2022 Scott Larson Change configSTACK_DEPTH_TYPE */ -/* to 32 bit instead of 16 bit, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ #ifndef FREERTOS_CONFIG_H diff --git a/utility/rtos_compatibility_layers/FreeRTOS/event_groups.h b/utility/rtos_compatibility_layers/FreeRTOS/event_groups.h index f034ea5a..67af88a2 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/event_groups.h +++ b/utility/rtos_compatibility_layers/FreeRTOS/event_groups.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -17,12 +18,6 @@ /** */ /**************************************************************************/ /**************************************************************************/ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 09-30-2020 William E. Lamie Initial Version 6.1 */ -/* */ /**************************************************************************/ #ifndef EVENT_GROUPS_H diff --git a/utility/rtos_compatibility_layers/FreeRTOS/queue.h b/utility/rtos_compatibility_layers/FreeRTOS/queue.h index 5d0695d3..9090b612 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/queue.h +++ b/utility/rtos_compatibility_layers/FreeRTOS/queue.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -17,12 +18,6 @@ /** */ /**************************************************************************/ /**************************************************************************/ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 09-30-2020 William E. Lamie Initial Version 6.1 */ -/* */ /**************************************************************************/ #ifndef QUEUE_H diff --git a/utility/rtos_compatibility_layers/FreeRTOS/readme.md b/utility/rtos_compatibility_layers/FreeRTOS/readme.md index 52936fee..172309af 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/readme.md +++ b/utility/rtos_compatibility_layers/FreeRTOS/readme.md @@ -48,7 +48,7 @@ For simplicity only a selected set of the usual configuration defines are suppor | configMAX_PRIORITIES | - | Maximum number of priorities. Must be less than or equal to the configured number of ThreadX priorities. | | configMINIMAL_STACK_SIZE | 512u | Minimum stack size, used as the stack size of the idle task if `TX_FREERTOS_IDLE_STACK` is not defined. | configTOTAL_HEAP_SIZE | - | Amount of internal memory allocated to the adaptation layer when creating FreeRTOS objects. Can be set to 0 to disable dynamic allocation. | -| INCLUDE_vTaskDelete | 1 | Set to 0 to disable the task delete API. When disabled the adaptation layer will not create the idle task to save resources. | +| INCLUDE_vTaskDelete | 1 | Set to 0 to disable the task delete API. When disabled the adaptation layer will not create the idle task to save resources. | | TX_FREERTOS_IDLE_STACK | 512u | Stack size of the idle task. | | TX_FREERTOS_ASSERT_FAIL | | Define to a macro invoked on internal assertion failures from within the adaptation layer | | configASSERT | | Define to a macro invoked for invalid arguments | @@ -148,16 +148,16 @@ The task API represents the core of the adaptation layer enabling creation and c | Name | Notes | |------|-------| | taskSCHEDULER_SUSPENDED -| taskSCHEDULER_NOT_STARTED -| taskSCHEDULER_RUNNING -| taskENTER_CRITICAL() -| taskEXIT_CRITICAL() -| taskENTER_CRITICAL_FROM_ISR() -| taskEXIT_CRITICAL_FROM_ISR() -| taskDISABLE_INTERRUPTS() -| taskENABLE_INTERRUPTS() -| tskIDLE_PRIORITY -| taskYIELD() +| taskSCHEDULER_NOT_STARTED +| taskSCHEDULER_RUNNING +| taskENTER_CRITICAL() +| taskEXIT_CRITICAL() +| taskENTER_CRITICAL_FROM_ISR() +| taskEXIT_CRITICAL_FROM_ISR() +| taskDISABLE_INTERRUPTS() +| taskENABLE_INTERRUPTS() +| tskIDLE_PRIORITY +| taskYIELD() | taskYIELD_FROM_ISR() | Has no effect, ThreadX will automatically pre-empt when a higher priority task is available to run upon returning from an ISR. | ### Functions @@ -171,18 +171,18 @@ The task API represents the core of the adaptation layer enabling creation and c | xTaskCreate() | uxTaskGetNumberOfTasks() | Only returns the number of task created by either `xTaskCreate()` or `xTaskcreateStatic()`. Task created internally by ThreadX or by the application using `tx_thread_create()` are not counted. | | vTaskDelete() -| vTaskDelay() +| vTaskDelay() | vTaskDelayUntil() | The implementation of `vTaskDelayUntil()` cannot perform a wait in an atomic fashion. As such there might be additional jitter when using this function with the adaptation layer. The implementation will, however, not accumulate any drift. | | xTaskGetCurrentTaskHandle() | This will only work when called from a task created by either `xTaskCreate()` or `xTaskcreateStatic()`. | | vTaskSuspend() -| vTaskResume() -| xTaskResumeFromISR() -| xTaskAbortDelay() -| uxTaskPriorityGet() -| uxTaskPriorityGetFromISR() -| vTaskPrioritySet() -| pcTaskGetName() -| eTaskGetState() +| vTaskResume() +| xTaskResumeFromISR() +| xTaskAbortDelay() +| uxTaskPriorityGet() +| uxTaskPriorityGetFromISR() +| vTaskPrioritySet() +| pcTaskGetName() +| eTaskGetState() | uxTaskGetStackHighWaterMark() | Not implemented. | | uxTaskGetStackHighWaterMark2() | Not implemented. | | xTaskCallApplicationTaskHook() | Not implemented. | @@ -197,68 +197,68 @@ Task notifications are fully implemented. | Name | Notes | |------|-------| -| xTaskNotifyGive() -| vTaskNotifyGiveFromISR() -| ulTaskNotifyTake() -| xTaskNotifyWait() -| xTaskNotify() -| xTaskNotifyFromISR() -| xTaskNotifyAndQuery() -| xTaskGenericNotify() -| xTaskNotifyAndQueryFromISR() -| xTaskGenericNotifyFromISR() -| xTaskNotifyStateClear() -| ulTaskNotifyValueClear() +| xTaskNotifyGive() +| vTaskNotifyGiveFromISR() +| ulTaskNotifyTake() +| xTaskNotifyWait() +| xTaskNotify() +| xTaskNotifyFromISR() +| xTaskNotifyAndQuery() +| xTaskGenericNotify() +| xTaskNotifyAndQueryFromISR() +| xTaskGenericNotifyFromISR() +| xTaskNotifyStateClear() +| ulTaskNotifyValueClear() ## Semaphore and Mutex Semaphores, either counting or binary as well as Mutexes are fully implemented. Mutexes under the adaptation layer cannot be taken or given from an ISR as this is not allowed in ThreadX as well as recent version of FreeRTOS. Due to differences between ThreadX and FreeRTOS it is possible that the ordering task wakeup may slightly differ. | Name | Notes | |------|-------| -| xSemaphoreCreateCounting() -| xSemaphoreCreateCountingStatic() -| xSemaphoreCreateBinary() -| xSemaphoreCreateBinaryStatic() -| xSemaphoreCreateMutex() -| xSemaphoreCreateMutexStatic() -| xSemaphoreCreateRecursiveMutex() -| xSemaphoreCreateRecursiveMutexStatic() -| vSemaphoreDelete() -| xSemaphoreTake() +| xSemaphoreCreateCounting() +| xSemaphoreCreateCountingStatic() +| xSemaphoreCreateBinary() +| xSemaphoreCreateBinaryStatic() +| xSemaphoreCreateMutex() +| xSemaphoreCreateMutexStatic() +| xSemaphoreCreateRecursiveMutex() +| xSemaphoreCreateRecursiveMutexStatic() +| vSemaphoreDelete() +| xSemaphoreTake() | xSemaphoreTakeFromISR() | It’s not possible to take a mutex from an ISR. | -| xSemaphoreTakeRecursive() -| xSemaphoreGive() -| xSemaphoreGiveFromISR() +| xSemaphoreTakeRecursive() +| xSemaphoreGive() +| xSemaphoreGiveFromISR() | xSemaphoreGiveRecursive() | It’s not possible to give a mutex from an ISR. | | uxSemaphoreGetCount() -| xSemaphoreGetMutexHolder() -| xSemaphoreGetMutexHolderFromISR() +| xSemaphoreGetMutexHolder() +| xSemaphoreGetMutexHolderFromISR() | vSemaphoreCreateBinary() | Not implemented since it’s marked as deprecated in the FreeRTOS documentation. | ## Queue -The FreeRTOS queue API is implemented with the help of ThreadX semaphores and is designed to mimic the behaviour of FreeRTOS queues. Due to differences between ThreadX and FreeRTOS it is possible that the ordering task wakeup may slightly differ. +The FreeRTOS queue API is implemented with the help of ThreadX semaphores and is designed to mimic the behaviour of FreeRTOS queues. Due to differences between ThreadX and FreeRTOS it is possible that the ordering task wakeup may slightly differ. | Name | Notes | |------|-------| | xQueueCreate() | | xQueueCreateStatic() | -| vQueueDelete() -| xQueueSend() -| xQueueSendFromISR() -| xQueueSendToBack() -| xQueueSendToBackFromISR() +| vQueueDelete() +| xQueueSend() +| xQueueSendFromISR() +| xQueueSendToBack() +| xQueueSendToBackFromISR() | xQueueSendToFront() | | xQueueSendToFrontFromISR() | | xQueueReceive() -| xQueueReceiveFromISR() +| xQueueReceiveFromISR() | xQueuePeek() | | xQueuePeekFromISR() | | uxQueueMessagesWaiting() | | uxQueueMessagesWaitingFromISR() | | uxQueueSpacesAvailable() | -| xQueueIsQueueEmptyFromISR() -| xQueueIsQueueFullFromISR() -| xQueueReset() +| xQueueIsQueueEmptyFromISR() +| xQueueIsQueueFullFromISR() +| xQueueReset() | xQueueOverwrite() | | xQueueOverwriteFromISR() | | pcQueueGetName() | Not implemented. | @@ -268,27 +268,27 @@ Queue sets are implemented with support for adding queues, semaphores and mutexe | Name | Notes | |------|-------| -| xQueueCreateSet() -| xQueueAddToSet() -| xQueueRemoveFromSet() -| xQueueSelectFromSet() -| xQueueSelectFromSetFromISR() +| xQueueCreateSet() +| xQueueAddToSet() +| xQueueRemoveFromSet() +| xQueueSelectFromSet() +| xQueueSelectFromSetFromISR() ## Event Group Event groups are implemented using ThreadX’s event flags. It is important to note however that `xEventGroupSync()` is not atomic. | Name | Notes| |------|-------| -| xEventGroupCreate() -| xEventGroupCreateStatic() -| vEventGroupDelete() -| xEventGroupWaitBits() -| xEventGroupSetBits() -| xEventGroupSetBitsFromISR() -| xEventGroupClearBits() -| xEventGroupClearBitsFromISR() -| xEventGroupGetBits() -| xEventGroupGetBitsFromISR() +| xEventGroupCreate() +| xEventGroupCreateStatic() +| vEventGroupDelete() +| xEventGroupWaitBits() +| xEventGroupSetBits() +| xEventGroupSetBitsFromISR() +| xEventGroupClearBits() +| xEventGroupClearBitsFromISR() +| xEventGroupGetBits() +| xEventGroupGetBitsFromISR() | xEventGroupSync() | Not atomic. | ## Timer @@ -296,25 +296,25 @@ The timer API is fully implemented except for the pend function all functionalit | Name | Notes | |------|-------| -| xTimerCreate() -| xTimerCreateStatic() -| xTimerDelete() -| xTimerIsTimerActive() -| xTimerStart() -| xTimerStop() -| xTimerChangePeriod() -| xTimerReset() -| xTimerStartFromISR() -| xTimerStopFromISR() -| xTimerChangePeriodFromISR() -| xTimerResetFromISR() -| pvTimerGetTimerID() -| vTimerSetTimerID() -| vTimerSetReloadMode() -| pcTimerGetName() -| xTimerGetPeriod() -| xTimerGetExpiryTime() -| uxTimerGetReloadMode() +| xTimerCreate() +| xTimerCreateStatic() +| xTimerDelete() +| xTimerIsTimerActive() +| xTimerStart() +| xTimerStop() +| xTimerChangePeriod() +| xTimerReset() +| xTimerStartFromISR() +| xTimerStopFromISR() +| xTimerChangePeriodFromISR() +| xTimerResetFromISR() +| pvTimerGetTimerID() +| vTimerSetTimerID() +| vTimerSetReloadMode() +| pcTimerGetName() +| xTimerGetPeriod() +| xTimerGetExpiryTime() +| uxTimerGetReloadMode() | xTimerPendFunctionCall() | Not implemented. | | xTimerPendFunctionCallFromISR() | Not implemented. | | xTimerGetTimerDaemonTaskHandle() | Not implemented. | diff --git a/utility/rtos_compatibility_layers/FreeRTOS/revision_history.txt b/utility/rtos_compatibility_layers/FreeRTOS/revision_history.txt index 1cbc90b6..8357c2a8 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/revision_history.txt +++ b/utility/rtos_compatibility_layers/FreeRTOS/revision_history.txt @@ -1,10 +1,10 @@ -Copyright (c) 2024 Microsoft Corporation - +Copyright (c) 2024 Microsoft Corporation + This program and the accompanying materials are made available under the terms of the MIT License which is available at https://opensource.org/licenses/MIT. - + SPDX-License-Identifier: MIT diff --git a/utility/rtos_compatibility_layers/FreeRTOS/semphr.h b/utility/rtos_compatibility_layers/FreeRTOS/semphr.h index c8341d34..9e5be62a 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/semphr.h +++ b/utility/rtos_compatibility_layers/FreeRTOS/semphr.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -17,12 +18,6 @@ /** */ /**************************************************************************/ /**************************************************************************/ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 09-30-2020 William E. Lamie Initial Version 6.1 */ -/* */ /**************************************************************************/ diff --git a/utility/rtos_compatibility_layers/FreeRTOS/task.h b/utility/rtos_compatibility_layers/FreeRTOS/task.h index f77dc7c5..33cee40f 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/task.h +++ b/utility/rtos_compatibility_layers/FreeRTOS/task.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -17,12 +18,6 @@ /** */ /**************************************************************************/ /**************************************************************************/ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 09-30-2020 William E. Lamie Initial Version 6.1 */ -/* */ /**************************************************************************/ #ifndef TASK_H diff --git a/utility/rtos_compatibility_layers/FreeRTOS/timers.h b/utility/rtos_compatibility_layers/FreeRTOS/timers.h index 9c94eb33..7e35d20e 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/timers.h +++ b/utility/rtos_compatibility_layers/FreeRTOS/timers.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -17,12 +18,6 @@ /** */ /**************************************************************************/ /**************************************************************************/ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 09-30-2020 William E. Lamie Initial Version 6.1 */ -/* */ /**************************************************************************/ #ifndef TIMERS_H diff --git a/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c b/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c index b400cf86..acac53cc 100644 --- a/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c +++ b/utility/rtos_compatibility_layers/FreeRTOS/tx_freertos.c @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -17,26 +18,6 @@ /** */ /**************************************************************************/ /**************************************************************************/ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 09-30-2020 William E. Lamie Initial Version 6.1 */ -/* 10-15-2021 William E. Lamie Modified comment(s), and */ -/* fixed compiler warnings, */ -/* resulting in version 6.1.7 */ -/* 01-31-2022 William E. Lamie Modified comment(s), and */ -/* fixed compiler warnings, */ -/* resulting in version 6.1.10 */ -/* 07-29-2022 Cindy Deng Added simple static scheduler */ -/* start flag, corrected stack */ -/* allocation size, */ -/* resulting in version 6.1.12 */ -/* 12-31-2023 Xiuwen Cai Modified comment(s), and */ -/* added check for overflow in */ -/* queue size calculation, */ -/* resulting in version 6.4.0 */ -/* */ /**************************************************************************/ #include <stdint.h> diff --git a/utility/rtos_compatibility_layers/OSEK/demo_osek.c b/utility/rtos_compatibility_layers/OSEK/demo_osek.c index 625282eb..2e104d31 100644 --- a/utility/rtos_compatibility_layers/OSEK/demo_osek.c +++ b/utility/rtos_compatibility_layers/OSEK/demo_osek.c @@ -51,7 +51,7 @@ TX_TIMER demo_isr_timer; VOID demo_isr_timer_entry(ULONG arg); -/* Main function. */ +/* Main function. */ int main() { @@ -67,8 +67,8 @@ CHAR * pointer; /* Put the first available address into character pointer. */ pointer = (CHAR * )free_memory; - - /* Setup hook pointers (optional). */ + + /* Setup hook pointers (optional). */ Application1.shutdown_hook_handler = ShutdownHook; Application1.pretask_hook_handler = PreTaskHook; Application1.posttask_hook_handler = PostTaskHook; @@ -77,7 +77,7 @@ CHAR * pointer; /* Initialize a pointer. */ osek_initialize(pointer,&Application1); - + /* Create the system counter */ SystemTimer = CreateCounter("SystemTimer", 0x7FFFFFFF, 2, 2, 0); DefineSystemCounter(SystemTimer); @@ -87,13 +87,13 @@ CHAR * pointer; /* Create an event. */ Event1 = CreateEvent(); - + /* Register Event1 to Task1. */ RegisterEventtoTask(Event1 , Task1); /* Create a resource. */ Resource1 = CreateResource("Resource1", STANDARD, 0); - + /* Register Resource1 to Task1. */ RegisterTasktoResource(Resource1, Task1); @@ -103,10 +103,10 @@ CHAR * pointer; /* Create a ThreadX timer to simulate an ISR. */ tx_timer_create(&demo_isr_timer, "Demo ISR timer", demo_isr_timer_entry, DemoISR, 1000, 1000, TX_AUTO_ACTIVATE); - + /* Start OSEK */ StartOS(OSDEFAULTAPPMODE); - + } /* Task body. */ diff --git a/utility/rtos_compatibility_layers/OSEK/os.h b/utility/rtos_compatibility_layers/OSEK/os.h index eda727b4..f88bfce7 100644 --- a/utility/rtos_compatibility_layers/OSEK/os.h +++ b/utility/rtos_compatibility_layers/OSEK/os.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -34,13 +35,6 @@ /* This file defines the constants, structures, etc. needed for the */ /* OSEK implementation. */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ #ifndef TX_OSEK_H diff --git a/utility/rtos_compatibility_layers/OSEK/osek_user.h b/utility/rtos_compatibility_layers/OSEK/osek_user.h index 27b73ecd..45f4d7b6 100644 --- a/utility/rtos_compatibility_layers/OSEK/osek_user.h +++ b/utility/rtos_compatibility_layers/OSEK/osek_user.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -34,12 +35,6 @@ /* This files contains user configurable compile time paramteres for */ /* the OSEK implementation. */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ #ifndef OSEK_USER_H diff --git a/utility/rtos_compatibility_layers/OSEK/threadx_osek_readme.txt b/utility/rtos_compatibility_layers/OSEK/threadx_osek_readme.txt index dd1e1209..6f19db6d 100644 --- a/utility/rtos_compatibility_layers/OSEK/threadx_osek_readme.txt +++ b/utility/rtos_compatibility_layers/OSEK/threadx_osek_readme.txt @@ -9,46 +9,46 @@ to the ThreadX readme file for installation instructions for ThreadX. 2. Building -Building the OSEK layer should be as simple as including the tx_osek.c and os.h file to +Building the OSEK layer should be as simple as including the tx_osek.c and os.h file to an existing ThreadX project, making sure that the location of the os.h header is in the -include paths. The OSEK layer requires that the ThreadX headers such as tx_api.h are +include paths. The OSEK layer requires that the ThreadX headers such as tx_api.h are reachable in the include paths as well. 3. Initialization -The OSEK layer initialization can be performed either from the tx_application_define() -during the ThreadX initialization or from a running ThreadX thread. It is strongly -recommended to initialize and start the OSEK layer as soon as possible. Once started -other ThreadX tasks and API call should not be used to prevent resource conflicts with +The OSEK layer initialization can be performed either from the tx_application_define() +during the ThreadX initialization or from a running ThreadX thread. It is strongly +recommended to initialize and start the OSEK layer as soon as possible. Once started +other ThreadX tasks and API call should not be used to prevent resource conflicts with OSEK. -The OSEK initialization has three phases. First the osek internal initialization which -must be performed before calling any other OSEK API functions, by calling +The OSEK initialization has three phases. First the osek internal initialization which +must be performed before calling any other OSEK API functions, by calling osek_initialize() passing it a pointer to the OSEK memory and the application structure. The size of the memory region passed to osek_initialize() must be set at compile time by adjusting the OSEK_MEMORY_SIZE define in osek_uart.h. -After having initialized the OSEK internally, the application can now create OSEK objects +After having initialized the OSEK internally, the application can now create OSEK objects and link or assigned them as needed. See below for a list of object creation functions. -Finally, after all the objects are created and configured the OSEK layer can be started -using StartOS(). Once started it is no longer possible to create or change any OSEK +Finally, after all the objects are created and configured the OSEK layer can be started +using StartOS(). Once started it is no longer possible to create or change any OSEK objects. 4. OSEK shutdown and restart -The OSEK layer can be shutdown using the standard OSEK API ShutdownOS(). As an extension -to the OSEK layer offers an osek_cleanup() function which can be used to cleanup and -reset the OSEK layer allowing a subsequent restart without having to reset the CPU. This +The OSEK layer can be shutdown using the standard OSEK API ShutdownOS(). As an extension +to the OSEK layer offers an osek_cleanup() function which can be used to cleanup and +reset the OSEK layer allowing a subsequent restart without having to reset the CPU. This is primarily intended for testing. 5. Hooks -The various hook routines available within OSEK can be set during initialization by -setting the various handler members of the APPLICATION_INFO structure passed to +The various hook routines available within OSEK can be set during initialization by +setting the various handler members of the APPLICATION_INFO structure passed to osek_initialize(). See the OSEK documentation for the signature of those hook functions. For example: @@ -62,15 +62,15 @@ For example: 6. Interrupts -As per the OSEK specification, category 1 ISRs are not affected by the OSEK layer +As per the OSEK specification, category 1 ISRs are not affected by the OSEK layer execution and are not allowed to call any of the OSEK API. Those ISR are configured and -processed just like any other interrupts under ThreadX. Category 2 ISR have to be +processed just like any other interrupts under ThreadX. Category 2 ISR have to be created using CreateISR() as well as being registered and enable like a category 1 ISR. In the body of the low level ISR process_ISR2() must be called with the return value of -the corresponding CreateISR() in argument. This will instruct the OSEK layer to schedule +the corresponding CreateISR() in argument. This will instruct the OSEK layer to schedule the category 2 ISR as soon as possible. -A category 2 ISR is made of two handlers, the one that process the hardware interrupt +A category 2 ISR is made of two handlers, the one that process the hardware interrupt and the OSEK ISR body. To define a category 2 ISR body use the standard ISR() macro as follows: @@ -104,7 +104,7 @@ void demo_isr_hardware_handler(void) 7. Implementation specific information -Since OSEK requires a static allocation methodology, the number of available OSEK object +Since OSEK requires a static allocation methodology, the number of available OSEK object has to be limited at compile time. By default the following limits apply: Maximum number of tasks: 32 @@ -121,10 +121,10 @@ Maximum task activation count: 8 8. Supported OSEK API -The ThreadX OSEK layer supports all the mandatory APIs specified in version 2.2.3 of +The ThreadX OSEK layer supports all the mandatory APIs specified in version 2.2.3 of the OSEK/VDK Operating System Specification. -Summary of the supported API, see the OSEK specification and tx_osek.c for the full +Summary of the supported API, see the OSEK specification and tx_osek.c for the full details of each API. TASK MANAGEMENT @@ -191,22 +191,22 @@ detailed description of each function. ---- CreateTask � Creates an OSEK task, the task is returned if successful. - TaskType CreateTask(CHAR *name, - void(*entry_function)(), - UINT priority, - UINT max_activation, - ULONG stack_size, - SCHEDULE policy, - AUTOSTART start, - UINT type, + TaskType CreateTask(CHAR *name, + void(*entry_function)(), + UINT priority, + UINT max_activation, + ULONG stack_size, + SCHEDULE policy, + AUTOSTART start, + UINT type, AppModeType mode); ---- CreateResource - Creates an OSEK resource, the resource is returned if successful. - ResourceType CreateResource(const CHAR *name, - StatusType type, + ResourceType CreateResource(const CHAR *name, + StatusType type, ResourceType linked_res); @@ -214,49 +214,49 @@ CreateResource - Creates an OSEK resource, the resource is returned if successfu RegisterTasktoResource - Registers a task to a resource. The resource will be accessible by the registered task. - StatusType RegisterTasktoResource(ResourceType Resource, + StatusType RegisterTasktoResource(ResourceType Resource, TaskType TaskID); ---- -CreateEvent - Creates an event, the created event is returned if successful. Note that +CreateEvent - Creates an event, the created event is returned if successful. Note that per the OSEK specification an absolute maximum of 32 events can be created. EventMaskType CreateEvent(void); ---- -RegisterEventtoTask - Register an event to a task. The event is now usable from that +RegisterEventtoTask - Register an event to a task. The event is now usable from that task. Note that an event can only be registered to a single task. - StatusType RegisterEventtoTask(EventType eventid, + StatusType RegisterEventtoTask(EventType eventid, TaskType TaskID); ---- CreateISR - Creates an ISR. - ISRType CreateISR(const CHAR *name, - void(*entry_function)(), - UINT category, + ISRType CreateISR(const CHAR *name, + void(*entry_function)(), + UINT category, ULONG stack_size); ---- -RegisterISRtoResource - Register an ISR to a resource. Note that ISR cannot be registered +RegisterISRtoResource - Register an ISR to a resource. Note that ISR cannot be registered to category 1 ISRS. - StatusType RegisterISRtoResource(ResourceType Resource, + StatusType RegisterISRtoResource(ResourceType Resource, ISRType ISRID); ---- CreateCounter - Creates a new counter. - CounterType CreateCounter(CHAR *name, - TickType max_allowed_value, - TickType ticks_per_base, - TickType min_cycle, + CounterType CreateCounter(CHAR *name, + TickType max_allowed_value, + TickType ticks_per_base, + TickType min_cycle, TickType start_value); ---- @@ -267,11 +267,11 @@ DefineSystemCounter - Assign a counter to be used as the system counter. --- CreateAlarm - Creates an alarm. -AlarmType CreateAlarm(CHAR *name, - CounterType cntr, - UINT action, - ULONG events, - TaskType task, - void (*callback)(), - UINT Startup, TickType Alarmtime, +AlarmType CreateAlarm(CHAR *name, + CounterType cntr, + UINT action, + ULONG events, + TaskType task, + void (*callback)(), + UINT Startup, TickType Alarmtime, TickType Cycle); diff --git a/utility/rtos_compatibility_layers/OSEK/tx_osek.c b/utility/rtos_compatibility_layers/OSEK/tx_osek.c index bf5f482c..fe778f32 100644 --- a/utility/rtos_compatibility_layers/OSEK/tx_osek.c +++ b/utility/rtos_compatibility_layers/OSEK/tx_osek.c @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -268,12 +269,6 @@ static StatusType ActivateISR(ISRType ISRID); /* */ /* Application */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ void StartOS(StatusType os_mode) { diff --git a/utility/rtos_compatibility_layers/posix/errno.h b/utility/rtos_compatibility_layers/posix/errno.h index 65077d9a..2b01c34c 100644 --- a/utility/rtos_compatibility_layers/posix/errno.h +++ b/utility/rtos_compatibility_layers/posix/errno.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -33,13 +34,6 @@ /* This file defines the constants, structures, etc.needed to */ /* implement the Evacuation Kit for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ #ifndef _ERRNO_H @@ -96,7 +90,7 @@ #define EDQUOT 213 -#define EEXIST 17 +#define EEXIST 17 #define EFAULT 214 diff --git a/utility/rtos_compatibility_layers/posix/fcntl.h b/utility/rtos_compatibility_layers/posix/fcntl.h index 8c362bec..db943625 100644 --- a/utility/rtos_compatibility_layers/posix/fcntl.h +++ b/utility/rtos_compatibility_layers/posix/fcntl.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -33,13 +34,6 @@ /* This file defines the constants, structures, etc.needed to */ /* implement the Evacuation Kit for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ #ifndef _FCNTL_H @@ -52,39 +46,39 @@ #define O_APPEND 0x0008 #define O_SYNC 0x0010 #define O_NONBLOCK 0x0080 -#define O_CREAT 0x0100 -#define O_TRUNC 0x0200 -#define O_EXCL 0x0400 -#define O_NOCTTY 0x0800 -#define FASYNC 0x1000 -#define O_LARGEFILE 0x2000 -#define O_DIRECT 0x8000 -#define O_DIRECTORY 0x10000 -#define O_NOFOLLOW 0x20000 +#define O_CREAT 0x0100 +#define O_TRUNC 0x0200 +#define O_EXCL 0x0400 +#define O_NOCTTY 0x0800 +#define FASYNC 0x1000 +#define O_LARGEFILE 0x2000 +#define O_DIRECT 0x8000 +#define O_DIRECTORY 0x10000 +#define O_NOFOLLOW 0x20000 #define O_NDELAY O_NONBLOCK -#define F_DUPFD 0 -#define F_GETFD 1 -#define F_SETFD 2 -#define F_GETFL 3 -#define F_SETFL 4 +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 #define F_GETLK 14 #define F_SETLK 6 #define F_SETLKW 7 -#define F_SETOWN 24 -#define F_GETOWN 23 -#define F_SETSIG 10 -#define F_GETSIG 11 +#define F_SETOWN 24 +#define F_GETOWN 23 +#define F_SETSIG 10 +#define F_GETSIG 11 -#define FD_CLOEXEC 1 +#define FD_CLOEXEC 1 -# define POSIX_FADV_NORMAL 0 -# define POSIX_FADV_RANDOM 1 -# define POSIX_FADV_SEQUENTIAL 2 -# define POSIX_FADV_WILLNEED 3 -# define POSIX_FADV_DONTNEED 4 +# define POSIX_FADV_NORMAL 0 +# define POSIX_FADV_RANDOM 1 +# define POSIX_FADV_SEQUENTIAL 2 +# define POSIX_FADV_WILLNEED 3 +# define POSIX_FADV_DONTNEED 4 # define POSIX_FADV_NOREUSE 5 /* no flock structure for Threadx at this time */ diff --git a/utility/rtos_compatibility_layers/posix/posix_demo.c b/utility/rtos_compatibility_layers/posix/posix_demo.c index 339ad9bb..7adeb9c3 100644 --- a/utility/rtos_compatibility_layers/posix/posix_demo.c +++ b/utility/rtos_compatibility_layers/posix/posix_demo.c @@ -94,7 +94,7 @@ struct sched_param param; queue_atrr.mq_maxmsg = 124; queue_atrr.mq_msgsize = MAX_MESSAGE_SIZE; - + /* Init POSIX Wrapper */ storage_ptr = (VOID*) posix_initialize(free_memory); @@ -107,54 +107,54 @@ struct sched_param param; pthread_attr_init(&ptattr2); pthread_attr_init(&ptattr3); pthread_attr_init(&ptattr4); - pthread_attr_init(&ptattr5); + pthread_attr_init(&ptattr5); /* Create a sched_param structure */ memset(¶m, 0, sizeof(param)); - + /* Now create all pthreads , firstly modify respective ptheread attribute with desired priority and stack start address and then create the pthread */ - + /* Create pthread 0. */ param.sched_priority = 10; pthread_attr_setschedparam(&ptattr0, ¶m); pthread_attr_setstackaddr(&ptattr0, storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_0, &ptattr0,pthread_0_entry,NULL); - + /* Create pthread 1. */ param.sched_priority = 15; pthread_attr_setschedparam(&ptattr1, ¶m); pthread_attr_setstackaddr(&ptattr1, (VOID*) storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_1, &ptattr1,pthread_1_entry,NULL); - + /* Create pthread 2. */ param.sched_priority = 20; pthread_attr_setschedparam(&ptattr2, ¶m); pthread_attr_setstackaddr(&ptattr2, (VOID*) storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_2, &ptattr2,pthread_2_entry,NULL); /* Create pthread 3. */ param.sched_priority = 25; pthread_attr_setschedparam(&ptattr3, ¶m); pthread_attr_setstackaddr(&ptattr3, (VOID*) storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_3, &ptattr3,pthread_3_entry,NULL); - + /* Create pthread 4. */ param.sched_priority = 30; pthread_attr_setschedparam(&ptattr4, ¶m); pthread_attr_setstackaddr(&ptattr4, (VOID*) storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_4, &ptattr4,pthread_4_entry,NULL); - + /* Create pthread 5. */ param.sched_priority = 5; pthread_attr_setschedparam(&ptattr5, ¶m); pthread_attr_setstackaddr(&ptattr5, (VOID*) storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_5, &ptattr5,pthread_5_entry,NULL); /* Create a Message queue. */ @@ -165,7 +165,7 @@ struct sched_param param; /* Create a Mutex */ pthread_mutex_init(&mutex1, NULL); - + } /* Define the test pthreads */ @@ -176,8 +176,8 @@ VOID *pthread_0_entry(VOID *pthread0_input) struct timespec thread_0_sleep_time={0,0}; - /* This pthread simply sits in while-forever-sleep loop */ - while(1) + /* This pthread simply sits in while-forever-sleep loop */ + while(1) { /* Increment the pthread counter.*/ pthread_0_counter++; @@ -197,13 +197,13 @@ INT pt1_status=0; VOID *pthread_1_entry(VOID *pthread1_input) { - + struct timespec thread_1_sleep_time={0,0}; /* This thread simply sends a messages to a queue shared by pthread 2. */ while(1) { - + /* Increment the thread counter. */ pthread_1_counter++; /* Send message to queue 0. */ @@ -229,7 +229,7 @@ INT pt2_status; VOID *pthread_2_entry(VOID *pthread2_input) { -CHAR msgr0[MAX_MESSAGE_SIZE]; +CHAR msgr0[MAX_MESSAGE_SIZE]; ULONG priority; struct timespec thread_2_sleep_time={0,0}; @@ -239,7 +239,7 @@ struct timespec thread_2_sleep_time={0,0}; /* Increment the thread counter. */ pthread_2_counter++; pt2_status = mq_receive(q_des,msgr0,MAX_MESSAGE_SIZE,&priority); - + if(pt2_status == ERROR) break; @@ -266,7 +266,7 @@ struct timespec thread_3_sleep_time={0,0}; /* Increment the thread counter. */ pthread_3_counter++; - /* Get the semaphore with suspension. */ + /* Get the semaphore with suspension. */ pt3_status = sem_wait(sem); /* Check status. */ diff --git a/utility/rtos_compatibility_layers/posix/posix_signal_nested_test.c b/utility/rtos_compatibility_layers/posix/posix_signal_nested_test.c index 70fb4887..6f5b6478 100644 --- a/utility/rtos_compatibility_layers/posix/posix_signal_nested_test.c +++ b/utility/rtos_compatibility_layers/posix/posix_signal_nested_test.c @@ -56,7 +56,7 @@ VOID tx_application_define(VOID *first_unused_memory) struct sched_param param; - + /* Init POSIX Wrapper */ storage_ptr = (VOID*) posix_initialize((VOID* )free_memory); @@ -68,15 +68,15 @@ struct sched_param param; /* Create a sched_param structure */ memset(¶m, 0, sizeof(param)); - + /* Now create all pthreads , firstly modify respective ptheread attribute with desired priority and stack start address and then create the pthread */ - + /* Create pthread 0. */ param.sched_priority = 10; pthread_attr_setschedparam(&ptattr0, ¶m); pthread_attr_setstackaddr(&ptattr0, storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_0, &ptattr0,pthread_0_entry,NULL); } @@ -100,7 +100,7 @@ VOID pthread_0_signal_handler13(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -108,7 +108,7 @@ VOID pthread_0_signal_handler13(int signo) /* Check for proper signal. */ if (signo != 13) { - + /* Call error handler. */ error_handler(); } @@ -125,7 +125,7 @@ VOID pthread_0_signal_handler14(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -133,7 +133,7 @@ VOID pthread_0_signal_handler14(int signo) /* Check for proper signal. */ if (signo != 14) { - + /* Call error handler. */ error_handler(); } @@ -153,7 +153,7 @@ VOID pthread_0_signal_handler15(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -161,7 +161,7 @@ VOID pthread_0_signal_handler15(int signo) /* Check for proper signal. */ if (signo != 15) { - + /* Call error handler. */ error_handler(); } @@ -202,18 +202,18 @@ VOID *pthread_0_entry(VOID *pthread0_input) if (pt0_status) error_handler(); - /* This pthread simply sits in while-forever-sleep loop */ - while(1) + /* This pthread simply sits in while-forever-sleep loop */ + while(1) { /* Increment the pthread counter.*/ pthread_0_counter++; /* Raise the signal. */ pt0_status = pthread_kill(pthread_0, 15); - + /* Check for errors. */ - if ((pt0_status) || - (pthread_0_counter != pthread_0_signal_counter15) || + if ((pt0_status) || + (pthread_0_counter != pthread_0_signal_counter15) || (pthread_0_counter != pthread_0_signal_counter14) || (pthread_0_counter != pthread_0_signal_counter13)) { diff --git a/utility/rtos_compatibility_layers/posix/posix_signal_resume_thread_test.c b/utility/rtos_compatibility_layers/posix/posix_signal_resume_thread_test.c index d2548056..90878158 100644 --- a/utility/rtos_compatibility_layers/posix/posix_signal_resume_thread_test.c +++ b/utility/rtos_compatibility_layers/posix/posix_signal_resume_thread_test.c @@ -66,7 +66,7 @@ VOID tx_application_define(VOID *first_unused_memory) struct sched_param param; - + /* Init POSIX Wrapper */ storage_ptr = (VOID*) posix_initialize((VOID*)free_memory); @@ -79,15 +79,15 @@ struct sched_param param; /* Create a sched_param structure */ memset(¶m, 0, sizeof(param)); - + /* Now create all pthreads , firstly modify respective ptheread attribute with desired priority and stack start address and then create the pthread */ - + /* Create pthread 0. */ param.sched_priority = 15; pthread_attr_setschedparam(&ptattr0, ¶m); pthread_attr_setstackaddr(&ptattr0, storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_0, &ptattr0,pthread_0_entry,NULL); @@ -95,7 +95,7 @@ struct sched_param param; param.sched_priority = 10; pthread_attr_setschedparam(&ptattr1, ¶m); pthread_attr_setstackaddr(&ptattr1, (VOID*) storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_1, &ptattr1,pthread_1_entry,NULL); @@ -124,7 +124,7 @@ VOID pthread_0_signal_handler13(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -132,7 +132,7 @@ VOID pthread_0_signal_handler13(int signo) /* Check for proper signal. */ if (signo != 13) { - + /* Call error handler. */ error_handler(); } @@ -152,7 +152,7 @@ VOID pthread_0_signal_handler14(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -160,7 +160,7 @@ VOID pthread_0_signal_handler14(int signo) /* Check for proper signal. */ if (signo != 14) { - + /* Call error handler. */ error_handler(); } @@ -180,7 +180,7 @@ VOID pthread_0_signal_handler15(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -188,7 +188,7 @@ VOID pthread_0_signal_handler15(int signo) /* Check for proper signal. */ if (signo != 15) { - + /* Call error handler. */ error_handler(); } @@ -230,30 +230,30 @@ VOID *pthread_0_entry(VOID *pthread0_input) error_handler(); - /* Get the semaphore with suspension. */ + /* Get the semaphore with suspension. */ pt0_status = sem_wait(sem); - /* This pthread simply sits in while-forever-sleep loop */ - while(1) + /* This pthread simply sits in while-forever-sleep loop */ + while(1) { /* Increment the pthread counter.*/ pthread_0_counter++; - /* Get the semaphore with suspension. */ + /* Get the semaphore with suspension. */ pt0_status = sem_wait(sem); /* Check for errors. */ - if ((pt0_status) || - (pthread_0_counter != pthread_0_signal_counter15) || + if ((pt0_status) || + (pthread_0_counter != pthread_0_signal_counter15) || (pthread_0_counter != pthread_0_signal_counter14) || (pthread_0_counter != pthread_0_signal_counter13)) { - + /* In this test, this thread should never resume! */ error_handler(); /* Break out of the loop. */ - break; + break; } } @@ -265,12 +265,12 @@ INT pt1_status=0; VOID *pthread_1_entry(VOID *pthread1_input) { - + /* This thread simply sends a messages to a queue shared by pthread 2. */ while(1) { - + /* Increment the thread counter. */ pthread_1_counter++; @@ -278,9 +278,9 @@ VOID *pthread_1_entry(VOID *pthread1_input) pt1_status = pthread_kill(pthread_0, 15); /* Check for errors. */ - if ((pt1_status) || + if ((pt1_status) || (pthread_0_counter != (pthread_1_counter+1)) || - (pthread_1_counter != pthread_0_signal_counter15) || + (pthread_1_counter != pthread_0_signal_counter15) || (pthread_1_counter != pthread_0_signal_counter14) || (pthread_1_counter != pthread_0_signal_counter13)) { @@ -289,7 +289,7 @@ VOID *pthread_1_entry(VOID *pthread1_input) break; } } - + return(&pt1_status); } diff --git a/utility/rtos_compatibility_layers/posix/posix_signal_self_send_test.c b/utility/rtos_compatibility_layers/posix/posix_signal_self_send_test.c index 24e86b95..bbeb419f 100644 --- a/utility/rtos_compatibility_layers/posix/posix_signal_self_send_test.c +++ b/utility/rtos_compatibility_layers/posix/posix_signal_self_send_test.c @@ -116,7 +116,7 @@ struct sched_param param; queue_atrr.mq_maxmsg = 124; queue_atrr.mq_msgsize = MAX_MESSAGE_SIZE; #endif - + /* Init POSIX Wrapper */ storage_ptr = (VOID*) posix_initialize((VOID*)free_memory); @@ -130,56 +130,56 @@ queue_atrr.mq_msgsize = MAX_MESSAGE_SIZE; pthread_attr_init(&ptattr2); pthread_attr_init(&ptattr3); pthread_attr_init(&ptattr4); - pthread_attr_init(&ptattr5); + pthread_attr_init(&ptattr5); #endif /* Create a sched_param structure */ memset(¶m, 0, sizeof(param)); - + /* Now create all pthreads , firstly modify respective ptheread attribute with desired priority and stack start address and then create the pthread */ - + /* Create pthread 0. */ param.sched_priority = 10; pthread_attr_setschedparam(&ptattr0, ¶m); pthread_attr_setstackaddr(&ptattr0, storage_ptr ); - storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (int *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_0, &ptattr0,pthread_0_entry,NULL); - + #if 0 /* Create pthread 1. */ param.sched_priority = 15; pthread_attr_setschedparam(&ptattr1, ¶m); pthread_attr_setstackaddr(&ptattr1, (VOID*) storage_ptr ); - storage_ptr = storage_ptr + DEMO_STACK_SIZE; + storage_ptr = storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_1, &ptattr1,pthread_1_entry,NULL); - + /* Create pthread 2. */ param.sched_priority = 20; pthread_attr_setschedparam(&ptattr2, ¶m); pthread_attr_setstackaddr(&ptattr2, (VOID*) storage_ptr ); - storage_ptr = storage_ptr + DEMO_STACK_SIZE; + storage_ptr = storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_2, &ptattr2,pthread_2_entry,NULL); /* Create pthread 3. */ param.sched_priority = 25; pthread_attr_setschedparam(&ptattr3, ¶m); pthread_attr_setstackaddr(&ptattr3, (VOID*) storage_ptr ); - storage_ptr = storage_ptr + DEMO_STACK_SIZE; + storage_ptr = storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_3, &ptattr3,pthread_3_entry,NULL); - + /* Create pthread 4. */ param.sched_priority = 30; pthread_attr_setschedparam(&ptattr4, ¶m); pthread_attr_setstackaddr(&ptattr4, (VOID*) storage_ptr ); - storage_ptr = storage_ptr + DEMO_STACK_SIZE; + storage_ptr = storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_4, &ptattr4,pthread_4_entry,NULL); - + /* Create pthread 5. */ param.sched_priority = 5; pthread_attr_setschedparam(&ptattr5, ¶m); pthread_attr_setstackaddr(&ptattr5, (VOID*) storage_ptr ); - storage_ptr = storage_ptr + DEMO_STACK_SIZE; + storage_ptr = storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_5, &ptattr5,pthread_5_entry,NULL); /* Create a Message queue. */ @@ -191,7 +191,7 @@ queue_atrr.mq_msgsize = MAX_MESSAGE_SIZE; /* Create a Mutex */ pthread_mutex_init(&mutex1, NULL); #endif - + } VOID error_handler(void) @@ -213,7 +213,7 @@ VOID pthread_0_signal_handler(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -221,7 +221,7 @@ VOID pthread_0_signal_handler(int signo) /* Check for proper signal. */ if (signo != 15) { - + /* Call error handler. */ error_handler(); } @@ -251,23 +251,23 @@ VOID *pthread_0_entry(VOID *pthread0_input) if (pt0_status) error_handler(); - /* This pthread simply sits in while-forever-sleep loop */ - while(1) + /* This pthread simply sits in while-forever-sleep loop */ + while(1) { /* Increment the pthread counter.*/ pthread_0_counter++; /* Raise the signal. */ pt0_status = pthread_kill(pthread_0, 15); - + /* Check for errors. */ if ((pt0_status) || (pthread_0_counter != pthread_0_signal_counter)) { error_handler(); break; } - -#if 0 + +#if 0 /* sleep for a while */ thread_0_sleep_time.tv_nsec = 999999999; thread_0_sleep_time.tv_sec = 4; @@ -288,13 +288,13 @@ INT pt1_status=0; VOID *pthread_1_entry(VOID *pthread1_input) { - + struct timespec thread_1_sleep_time={0,0}; /* This thread simply sends a messages to a queue shared by pthread 2. */ while(1) { - + /* Increment the thread counter. */ pthread_1_counter++; /* Send message to queue 0. */ @@ -320,7 +320,7 @@ INT pt2_status; VOID *pthread_2_entry(VOID *pthread2_input) { -CHAR msgr0[MAX_MESSAGE_SIZE]; +CHAR msgr0[MAX_MESSAGE_SIZE]; ULONG priority; struct timespec thread_2_sleep_time={0,0}; @@ -330,7 +330,7 @@ struct timespec thread_2_sleep_time={0,0}; /* Increment the thread counter. */ pthread_2_counter++; pt2_status = mq_receive(q_des,msgr0,MAX_MESSAGE_SIZE,&priority); - + if(pt2_status != 0) break; @@ -357,7 +357,7 @@ struct timespec thread_3_sleep_time={0,0}; /* Increment the thread counter. */ pthread_3_counter++; - /* Get the semaphore with suspension. */ + /* Get the semaphore with suspension. */ pt3_status = sem_wait(sem); /* Check status. */ diff --git a/utility/rtos_compatibility_layers/posix/posix_signal_sigmask_test.c b/utility/rtos_compatibility_layers/posix/posix_signal_sigmask_test.c index 2a7cf069..1f9c690b 100644 --- a/utility/rtos_compatibility_layers/posix/posix_signal_sigmask_test.c +++ b/utility/rtos_compatibility_layers/posix/posix_signal_sigmask_test.c @@ -61,7 +61,7 @@ VOID tx_application_define(VOID *first_unused_memory) struct sched_param param; - + /* Init POSIX Wrapper */ storage_ptr = (VOID*) posix_initialize((VOID*)free_memory); @@ -74,15 +74,15 @@ struct sched_param param; /* Create a sched_param structure */ memset(¶m, 0, sizeof(param)); - + /* Now create all pthreads , firstly modify respective ptheread attribute with desired priority and stack start address and then create the pthread */ - + /* Create pthread 0. */ param.sched_priority = 15; pthread_attr_setschedparam(&ptattr0, ¶m); pthread_attr_setstackaddr(&ptattr0, storage_ptr ); - storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_0, &ptattr0,pthread_0_entry,NULL); @@ -90,7 +90,7 @@ struct sched_param param; param.sched_priority = 10; pthread_attr_setschedparam(&ptattr1, ¶m); pthread_attr_setstackaddr(&ptattr1, (VOID*) storage_ptr ); - storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_1, &ptattr1,pthread_1_entry,NULL); } @@ -118,7 +118,7 @@ int status; called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -126,7 +126,7 @@ int status; /* Check for proper signal. */ if (signo != 13) { - + /* Call error handler. */ error_handler(); } @@ -138,11 +138,11 @@ int status; sigemptyset(&wait_set); sigaddset(&wait_set, 12); status = sigwait(&wait_set, &signal_received); - + /* Check for an error. */ if ((status) || (signal_received != 12)) { - + /* Call error handler. */ error_handler(); } @@ -161,7 +161,7 @@ int status; called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -169,7 +169,7 @@ int status; /* Check for proper signal. */ if (signo != 14) { - + /* Call error handler. */ error_handler(); } @@ -181,11 +181,11 @@ int status; sigemptyset(&wait_set); sigaddset(&wait_set, 13); status = sigwait(&wait_set, &signal_received); - + /* Check for an error. */ if ((status) || (signal_received != 13)) { - + /* Call error handler. */ error_handler(); } @@ -204,7 +204,7 @@ int status; called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -212,7 +212,7 @@ int status; /* Check for proper signal. */ if (signo != 15) { - + /* Call error handler. */ error_handler(); } @@ -224,11 +224,11 @@ int status; sigemptyset(&wait_set); sigaddset(&wait_set, 14); status = sigwait(&wait_set, &signal_received); - + /* Check for an error. */ if ((status) || (signal_received != 14)) { - + /* Call error handler. */ error_handler(); } @@ -242,7 +242,7 @@ VOID pthread_0_signal_handler16(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -250,7 +250,7 @@ VOID pthread_0_signal_handler16(int signo) /* Check for proper signal. */ if (signo != 16) { - + /* Call error handler. */ error_handler(); } @@ -304,7 +304,7 @@ int signal_received; sigemptyset(&new_mask); sigaddset(&new_mask, 15); pt0_status = pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); - + /* Check for error. */ if (pt0_status) error_handler(); @@ -313,21 +313,21 @@ int signal_received; sigemptyset(&new_mask); sigaddset(&new_mask, 16); pt0_status = pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); - + /* Check for error. */ if (pt0_status) error_handler(); /* Simply restore the signal for this first test. */ pt0_status = pthread_sigmask(SIG_SETMASK, &old_mask, &old_mask); - + /* Check for error. */ if (pt0_status) error_handler(); - + /* Now do it again, but set a signal when the signal is masked. */ pt0_status = pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); - + /* Check for error. */ if (pt0_status) error_handler(); @@ -338,7 +338,7 @@ int signal_received; /* Check for error. */ if (pt0_status) error_handler(); - + /* Now unblock this signal to trigger the actual activation of the signal. */ pt0_status = pthread_sigmask(SIG_UNBLOCK, &new_mask, &old_mask); @@ -348,7 +348,7 @@ int signal_received; /* Now do it all again, but perform a sigwait when the signal is masked and pending. */ pt0_status = pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); - + /* Check for error. */ if (pt0_status) error_handler(); @@ -363,23 +363,23 @@ int signal_received; /* Wait on signal 16. */ sigemptyset(&wait_set); sigaddset(&wait_set, 16); - + /* Now perform a sigwait on signal 16. */ pt0_status = sigwait(&wait_set, &signal_received); - + /* Check for error. */ if ((pt0_status) || (pthread_0_signal_counter16 != 2) || (signal_received != 16)) error_handler(); - + /* Now unblock this signal to trigger the actual activation of the signal. */ pt0_status = pthread_sigmask(SIG_UNBLOCK, &new_mask, &old_mask); - + /* Check for error. */ if (pt0_status) error_handler(); - /* This pthread simply sits in while-forever-sleep loop */ - while(1) + /* This pthread simply sits in while-forever-sleep loop */ + while(1) { /* Increment the pthread counter.*/ pthread_0_counter++; @@ -388,22 +388,22 @@ int signal_received; sigemptyset(&wait_set); sigaddset(&wait_set, 15); - /* Signal wait. */ + /* Signal wait. */ pt0_status = sigwait(&wait_set, &signal_received); /* Check for errors. */ - if ((pt0_status) || + if ((pt0_status) || (signal_received != 15) || - (pthread_0_counter != pthread_0_signal_counter15) || + (pthread_0_counter != pthread_0_signal_counter15) || (pthread_0_counter != pthread_0_signal_counter14) || (pthread_0_counter != pthread_0_signal_counter13)) { - + /* In this test, this thread should never resume! */ error_handler(); /* Break out of the loop. */ - break; + break; } } @@ -415,12 +415,12 @@ INT pt1_status=0; VOID *pthread_1_entry(VOID *pthread1_input) { - + /* This thread simply sends a messages to a queue shared by pthread 2. */ while(1) { - + /* Increment the thread counter. */ pthread_1_counter++; @@ -434,9 +434,9 @@ VOID *pthread_1_entry(VOID *pthread1_input) pt1_status += pthread_kill(pthread_0, 12); /* Check for errors. */ - if ((pt1_status) || + if ((pt1_status) || (pthread_0_counter != (pthread_1_counter+1)) || - (pthread_1_counter != pthread_0_signal_counter15) || + (pthread_1_counter != pthread_0_signal_counter15) || (pthread_1_counter != pthread_0_signal_counter14) || (pthread_1_counter != pthread_0_signal_counter13)) { @@ -445,6 +445,6 @@ VOID *pthread_1_entry(VOID *pthread1_input) break; } } - + return(&pt1_status); } diff --git a/utility/rtos_compatibility_layers/posix/posix_signal_sigwait_test.c b/utility/rtos_compatibility_layers/posix/posix_signal_sigwait_test.c index 80d6402a..aa459735 100644 --- a/utility/rtos_compatibility_layers/posix/posix_signal_sigwait_test.c +++ b/utility/rtos_compatibility_layers/posix/posix_signal_sigwait_test.c @@ -59,7 +59,7 @@ VOID tx_application_define(VOID *first_unused_memory) struct sched_param param; - + /* Init POSIX Wrapper */ storage_ptr = (VOID*) posix_initialize((VOID*)free_memory); @@ -72,15 +72,15 @@ struct sched_param param; /* Create a sched_param structure */ memset(¶m, 0, sizeof(param)); - + /* Now create all pthreads , firstly modify respective ptheread attribute with desired priority and stack start address and then create the pthread */ - + /* Create pthread 0. */ param.sched_priority = 15; pthread_attr_setschedparam(&ptattr0, ¶m); pthread_attr_setstackaddr(&ptattr0, storage_ptr ); - storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_0, &ptattr0,pthread_0_entry,NULL); @@ -88,7 +88,7 @@ struct sched_param param; param.sched_priority = 10; pthread_attr_setschedparam(&ptattr1, ¶m); pthread_attr_setstackaddr(&ptattr1, (VOID*) storage_ptr ); - storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_1, &ptattr1,pthread_1_entry,NULL); } @@ -116,7 +116,7 @@ int status; called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -124,7 +124,7 @@ int status; /* Check for proper signal. */ if (signo != 13) { - + /* Call error handler. */ error_handler(); } @@ -136,11 +136,11 @@ int status; sigemptyset(&wait_set); sigaddset(&wait_set, 12); status = sigwait(&wait_set, &signal_received); - + /* Check for an error. */ if ((status) || (signal_received != 12)) { - + /* Call error handler. */ error_handler(); } @@ -159,7 +159,7 @@ int status; called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -167,7 +167,7 @@ int status; /* Check for proper signal. */ if (signo != 14) { - + /* Call error handler. */ error_handler(); } @@ -179,11 +179,11 @@ int status; sigemptyset(&wait_set); sigaddset(&wait_set, 13); status = sigwait(&wait_set, &signal_received); - + /* Check for an error. */ if ((status) || (signal_received != 13)) { - + /* Call error handler. */ error_handler(); } @@ -202,7 +202,7 @@ int status; called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -210,7 +210,7 @@ int status; /* Check for proper signal. */ if (signo != 15) { - + /* Call error handler. */ error_handler(); } @@ -222,11 +222,11 @@ int status; sigemptyset(&wait_set); sigaddset(&wait_set, 14); status = sigwait(&wait_set, &signal_received); - + /* Check for an error. */ if ((status) || (signal_received != 14)) { - + /* Call error handler. */ error_handler(); } @@ -265,8 +265,8 @@ int signal_received; if (pt0_status) error_handler(); - /* This pthread simply sits in while-forever-sleep loop */ - while(1) + /* This pthread simply sits in while-forever-sleep loop */ + while(1) { /* Increment the pthread counter.*/ pthread_0_counter++; @@ -275,22 +275,22 @@ int signal_received; sigemptyset(&wait_set); sigaddset(&wait_set, 15); - /* Signal wait. */ + /* Signal wait. */ pt0_status = sigwait(&wait_set, &signal_received); /* Check for errors. */ - if ((pt0_status) || + if ((pt0_status) || (signal_received != 15) || - (pthread_0_counter != pthread_0_signal_counter15) || + (pthread_0_counter != pthread_0_signal_counter15) || (pthread_0_counter != pthread_0_signal_counter14) || (pthread_0_counter != pthread_0_signal_counter13)) { - + /* In this test, this thread should never resume! */ error_handler(); /* Break out of the loop. */ - break; + break; } } @@ -302,12 +302,12 @@ INT pt1_status=0; VOID *pthread_1_entry(VOID *pthread1_input) { - + /* This thread simply sends a messages to a queue shared by pthread 2. */ while(1) { - + /* Increment the thread counter. */ pthread_1_counter++; @@ -321,9 +321,9 @@ VOID *pthread_1_entry(VOID *pthread1_input) pt1_status += pthread_kill(pthread_0, 12); /* Check for errors. */ - if ((pt1_status) || + if ((pt1_status) || (pthread_0_counter != (pthread_1_counter+1)) || - (pthread_1_counter != pthread_0_signal_counter15) || + (pthread_1_counter != pthread_0_signal_counter15) || (pthread_1_counter != pthread_0_signal_counter14) || (pthread_1_counter != pthread_0_signal_counter13)) { @@ -332,7 +332,7 @@ VOID *pthread_1_entry(VOID *pthread1_input) break; } } - + return(&pt1_status); } diff --git a/utility/rtos_compatibility_layers/posix/posix_signal_suspended_thread_test.c b/utility/rtos_compatibility_layers/posix/posix_signal_suspended_thread_test.c index 723c80db..40d11eea 100644 --- a/utility/rtos_compatibility_layers/posix/posix_signal_suspended_thread_test.c +++ b/utility/rtos_compatibility_layers/posix/posix_signal_suspended_thread_test.c @@ -66,7 +66,7 @@ VOID tx_application_define(VOID *first_unused_memory) struct sched_param param; - + /* Init POSIX Wrapper */ storage_ptr = (VOID*) posix_initialize((VOID*)free_memory); @@ -79,15 +79,15 @@ struct sched_param param; /* Create a sched_param structure */ memset(¶m, 0, sizeof(param)); - + /* Now create all pthreads , firstly modify respective ptheread attribute with desired priority and stack start address and then create the pthread */ - + /* Create pthread 0. */ param.sched_priority = 15; pthread_attr_setschedparam(&ptattr0, ¶m); pthread_attr_setstackaddr(&ptattr0, storage_ptr ); - storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_0, &ptattr0,pthread_0_entry,NULL); @@ -95,7 +95,7 @@ struct sched_param param; param.sched_priority = 10; pthread_attr_setschedparam(&ptattr1, ¶m); pthread_attr_setstackaddr(&ptattr1, (VOID*) storage_ptr ); - storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; + storage_ptr = (UINT *) storage_ptr + DEMO_STACK_SIZE; pthread_create (&pthread_1, &ptattr1,pthread_1_entry,NULL); @@ -123,7 +123,7 @@ VOID pthread_0_signal_handler13(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -131,7 +131,7 @@ VOID pthread_0_signal_handler13(int signo) /* Check for proper signal. */ if (signo != 13) { - + /* Call error handler. */ error_handler(); } @@ -148,7 +148,7 @@ VOID pthread_0_signal_handler14(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -156,7 +156,7 @@ VOID pthread_0_signal_handler14(int signo) /* Check for proper signal. */ if (signo != 14) { - + /* Call error handler. */ error_handler(); } @@ -176,7 +176,7 @@ VOID pthread_0_signal_handler15(int signo) called from pthread 0. */ if (pthread_self() != pthread_0) { - + /* Call error handler. */ error_handler(); } @@ -184,7 +184,7 @@ VOID pthread_0_signal_handler15(int signo) /* Check for proper signal. */ if (signo != 15) { - + /* Call error handler. */ error_handler(); } @@ -226,16 +226,16 @@ VOID *pthread_0_entry(VOID *pthread0_input) error_handler(); - /* Get the semaphore with suspension. */ + /* Get the semaphore with suspension. */ pt0_status = sem_wait(sem); - /* This pthread simply sits in while-forever-sleep loop */ - while(1) + /* This pthread simply sits in while-forever-sleep loop */ + while(1) { /* Increment the pthread counter.*/ pthread_0_counter++; - /* Get the semaphore with suspension. */ + /* Get the semaphore with suspension. */ pt0_status = sem_wait(sem); /* In this test, this thread should never resume! */ @@ -244,9 +244,9 @@ VOID *pthread_0_entry(VOID *pthread0_input) /* Check for error condition. */ if (pt0_status) { - + /* Break out of the loop. */ - break; + break; } } @@ -258,12 +258,12 @@ INT pt1_status=0; VOID *pthread_1_entry(VOID *pthread1_input) { - + /* This thread simply sends a messages to a queue shared by pthread 2. */ while(1) { - + /* Increment the thread counter. */ pthread_1_counter++; @@ -271,9 +271,9 @@ VOID *pthread_1_entry(VOID *pthread1_input) pt1_status = pthread_kill(pthread_0, 15); /* Check for errors. */ - if ((pt1_status) || + if ((pt1_status) || (pthread_0_counter != 1) || - (pthread_1_counter != pthread_0_signal_counter15) || + (pthread_1_counter != pthread_0_signal_counter15) || (pthread_1_counter != pthread_0_signal_counter14) || (pthread_1_counter != pthread_0_signal_counter13)) { @@ -282,7 +282,7 @@ VOID *pthread_1_entry(VOID *pthread1_input) break; } } - + return(&pt1_status); } diff --git a/utility/rtos_compatibility_layers/posix/pthread.h b/utility/rtos_compatibility_layers/posix/pthread.h index bbd0761c..b248a38b 100644 --- a/utility/rtos_compatibility_layers/posix/pthread.h +++ b/utility/rtos_compatibility_layers/posix/pthread.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -33,13 +34,6 @@ /* This file defines the constants, structures, etc.needed to */ /* implement the Evacuation Kit for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ #ifndef _PTHREAD_H diff --git a/utility/rtos_compatibility_layers/posix/px_abs_time_to_rel_ticks.c b/utility/rtos_compatibility_layers/posix/px_abs_time_to_rel_ticks.c index 18a64e35..79a7b90f 100644 --- a/utility/rtos_compatibility_layers/posix/px_abs_time_to_rel_ticks.c +++ b/utility/rtos_compatibility_layers/posix/px_abs_time_to_rel_ticks.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -43,12 +44,6 @@ /* timespec structure into the relative number of timer ticks until */ /* that time will occur. */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ ULONG posix_abs_time_to_rel_ticks(struct timespec *abs_timeout) { @@ -57,7 +52,7 @@ ULONG posix_abs_time_to_rel_ticks(struct timespec *abs_timeout) current_ticks = tx_time_get(); /* convert ns to ticks (will lose any ns < 1 tick) */ ticks_ns = abs_timeout->tv_nsec / NANOSECONDS_IN_CPU_TICK; - /* + /* * if ns < 1 tick were lost, bump up to next tick so the delay is never * less than what was specified. */ diff --git a/utility/rtos_compatibility_layers/posix/px_clock_getres.c b/utility/rtos_compatibility_layers/posix/px_clock_getres.c index 80d16f66..5153500b 100644 --- a/utility/rtos_compatibility_layers/posix/px_clock_getres.c +++ b/utility/rtos_compatibility_layers/posix/px_clock_getres.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,51 +27,45 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* clock_getres PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* clock_getres PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This subroutine returns the Clock resolution of the Threadx real */ /* time clock in nanoseconds */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* clockid_t, tspec */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* error code */ /* */ -/* CALLS */ -/* */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* CALLS */ +/* */ +/* */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT clock_getres(clockid_t t, struct timespec * tspec) { - + if(t==CLOCK_REALTIME) { if(tspec) tspec->tv_nsec= NANOSECONDS_IN_CPU_TICK; return(OK); } else return(EINVAL); - + } diff --git a/utility/rtos_compatibility_layers/posix/px_clock_gettime.c b/utility/rtos_compatibility_layers/posix/px_clock_gettime.c index f7c96797..964c10c7 100644 --- a/utility/rtos_compatibility_layers/posix/px_clock_gettime.c +++ b/utility/rtos_compatibility_layers/posix/px_clock_gettime.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,49 +27,43 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* clock_gettime PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* clock_gettime PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This subroutine returns the time. The source of the time */ /* is the internal Threadx timer variable, which keeps track */ /* of the number of ticks of the Threadx timer ISR. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* clockid_t, tspec */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* error code */ /* */ -/* CALLS */ -/* */ +/* CALLS */ +/* */ /* tx_time_get ThreadX function */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT clock_gettime(clockid_t t, struct timespec * tspec) { ULONG tx_time; - + if(t==CLOCK_REALTIME) { tx_time=tx_time_get(); @@ -76,9 +71,9 @@ INT clock_gettime(clockid_t t, struct timespec * tspec) tspec->tv_sec = tx_time / CPU_TICKS_PER_SECOND; tspec->tv_nsec = (ULONG) ((tx_time - tspec->tv_sec*CPU_TICKS_PER_SECOND) * NANOSECONDS_IN_CPU_TICK); - + return(OK); } else return(EINVAL); - + } diff --git a/utility/rtos_compatibility_layers/posix/px_clock_settime.c b/utility/rtos_compatibility_layers/posix/px_clock_settime.c index 588de88f..70dbbe86 100644 --- a/utility/rtos_compatibility_layers/posix/px_clock_settime.c +++ b/utility/rtos_compatibility_layers/posix/px_clock_settime.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,50 +27,44 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* clock_settime PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* clock_settime PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This subroutine sets the internal Threadx timer tick variable */ /* to the time specificed in the tspec variable after conversion */ /* if tspec->tv_sec is 0 the clock with be set to the value of */ /* tspec->tv_nsec */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* clockid_t, tspec */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* error code */ /* */ -/* CALLS */ -/* */ +/* CALLS */ +/* */ /* tx_time_set ThreadX function */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT clock_settime(clockid_t t, const struct timespec * tspec) { ULONG tx_time; - + if(t==CLOCK_REALTIME) { tx_time=(ULONG)((tspec->tv_sec * CPU_TICKS_PER_SECOND) + (tspec->tv_nsec / NANOSECONDS_IN_CPU_TICK)); diff --git a/utility/rtos_compatibility_layers/posix/px_cond_broadcast.c b/utility/rtos_compatibility_layers/posix/px_cond_broadcast.c index b9c5faee..f9c8f151 100644 --- a/utility/rtos_compatibility_layers/posix/px_cond_broadcast.c +++ b/utility/rtos_compatibility_layers/posix/px_cond_broadcast.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,18 +27,18 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_cond_broadcast PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_cond_broadcast PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* These functions shall unblock all threads currently blocked on a */ /* specified condition variable cond. */ /* If more than one thread is blocked on a condition variable, */ @@ -53,20 +54,20 @@ /* calling pthread_cond_wait or pthread_cond_timedwait have associated */ /* with the condition variable during their waits; however, */ /* if predictable scheduling behavior is required, then that mutex */ -/* shall be locked by the thread calling pthread_cond_broadcast. */ +/* shall be locked by the thread calling pthread_cond_broadcast. */ /* The pthread_cond_broadcast function shall have no effect if there */ /* are no threads currently blocked on cond. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* cond condition variable */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* Ok if successful */ /* Error in case of any errors */ /* */ -/* CALLS */ +/* CALLS */ /* */ /* tx_semaphore_prioritize line up pthreads waiting at semaphore*/ /* tx_thread_identify to check which pthread? */ @@ -74,20 +75,14 @@ /* tx_semaphore_put ThreadX semaphore put service */ /* tx_thread_preemption_change to enable thread preemption */ /* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_cond_broadcast(pthread_cond_t *cond) { - + TX_SEMAPHORE *semaphore_ptr; TX_THREAD *thread; UINT status; @@ -96,13 +91,13 @@ UINT old_threshold,dummy; /* Get the condition variable's internal semaphore. */ - /* Simply convert the condition variable control block into a semaphore a cast */ + /* Simply convert the condition variable control block into a semaphore a cast */ semaphore_ptr = (&( cond->cond_semaphore )); sem_count = semaphore_ptr->tx_semaphore_suspended_count; if (!sem_count) return(OK); - + status = tx_semaphore_prioritize(semaphore_ptr); if ( status != TX_SUCCESS) @@ -111,17 +106,17 @@ UINT old_threshold,dummy; posix_set_pthread_errno(EINVAL); return(EINVAL); } - + /* get to know about current thread */ thread = tx_thread_identify(); /* Got the current thread , now raise its preemption threshold */ /* that way the current thread does not get descheduled when */ /* threads with higher priority are activated */ - tx_thread_preemption_change(thread,0,&old_threshold); + tx_thread_preemption_change(thread,0,&old_threshold); while( sem_count) - { + { status = tx_semaphore_put(semaphore_ptr); if ( status != TX_SUCCESS) diff --git a/utility/rtos_compatibility_layers/posix/px_cond_destroy.c b/utility/rtos_compatibility_layers/posix/px_cond_destroy.c index 54dd1eb7..efa99be1 100644 --- a/utility/rtos_compatibility_layers/posix/px_cond_destroy.c +++ b/utility/rtos_compatibility_layers/posix/px_cond_destroy.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,18 +26,18 @@ #include "pthread.h" /* Posix API */ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_cond_destroy PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_cond_destroy PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* The pthread_cond_destroy function shall destroy the given condition */ /* variable specified by cond; the object becomes, in effect, */ /* uninitialized. */ @@ -44,29 +45,23 @@ /* pthread_cond_init;referencing the object after it has been destroyed*/ /* returns error. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* cond condition variable object */ /* */ /* OUTPUT */ -/* */ +/* */ /* OK If successful */ -/* EINVAL If error */ +/* EINVAL If error */ /* */ -/* CALLS */ +/* CALLS */ /* */ /* tx_semaphore_delete Deletes a semaphore internal to */ /* to the cond variable */ /* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_cond_destroy(pthread_cond_t *cond) @@ -74,18 +69,18 @@ INT pthread_cond_destroy(pthread_cond_t *cond) TX_SEMAPHORE *semaphore_ptr; UINT status; - + if (cond->in_use == TX_FALSE) { posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { cond->in_use = TX_FALSE; /* Get the condition variable's internal semaphore. */ - /* Simply convert the Condition variable control block into a semaphore a cast */ + /* Simply convert the Condition variable control block into a semaphore a cast */ semaphore_ptr = (&( cond->cond_semaphore )); status = tx_semaphore_delete(semaphore_ptr); if (status != TX_SUCCESS) @@ -93,8 +88,8 @@ UINT status; posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } return(OK); - } + } } diff --git a/utility/rtos_compatibility_layers/posix/px_cond_init.c b/utility/rtos_compatibility_layers/posix/px_cond_init.c index e204a13f..b376132d 100644 --- a/utility/rtos_compatibility_layers/posix/px_cond_init.c +++ b/utility/rtos_compatibility_layers/posix/px_cond_init.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,18 +27,18 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_cond_init PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_cond_init PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall initialize the condition variable referenced by */ /* cond with attributes referenced by attr. If attr is NULL,the default*/ /* condition variable attributes shall be used; the effect is the same */ @@ -45,28 +46,22 @@ /* object. Upon successful initialization, the state of the condition */ /* variable shall become initialized. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* Nothing */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* cond condition variable object */ /* attr attributes */ /* */ -/* CALLS */ -/* */ +/* CALLS */ +/* */ /* tx_semaphore_create create a semaphore internal to */ -/* cond variable */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* cond variable */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr) @@ -74,11 +69,11 @@ INT pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr) TX_SEMAPHORE *semaphore_ptr; UINT status; - + cond->in_use = TX_TRUE; /* Get the condition variable's internal semaphore. */ - /* Simply convert the COndition variable control block into a semaphore a cast */ - semaphore_ptr = (&( cond->cond_semaphore )); + /* Simply convert the COndition variable control block into a semaphore a cast */ + semaphore_ptr = (&( cond->cond_semaphore )); /* Now create the internal semaphore for this cond variable */ status = tx_semaphore_create(semaphore_ptr,"csem",0); if (status != TX_SUCCESS) diff --git a/utility/rtos_compatibility_layers/posix/px_cond_signal.c b/utility/rtos_compatibility_layers/posix/px_cond_signal.c index 6d01a6e7..b1f4f285 100644 --- a/utility/rtos_compatibility_layers/posix/px_cond_signal.c +++ b/utility/rtos_compatibility_layers/posix/px_cond_signal.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,18 +27,18 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_cond_signal PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_cond_signal PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall unblock at least one of the threads that are */ /* blocked on the specified condition variable cond */ /* (if any threads are blocked on cond).If more than one thread is */ @@ -58,28 +59,22 @@ /* This function shall have no effect if there are no threads currently*/ /* blocked on cond. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* Nothing */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* Nothing */ /* */ -/* CALLS */ +/* CALLS */ /* */ /* tx_semaphore_prioritize line up pthreads waiting at semaphore*/ /* tx_semaphore_put ThreadX semaphore put service */ /* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_cond_signal(pthread_cond_t *cond) @@ -89,7 +84,7 @@ TX_SEMAPHORE *semaphore_ptr; UINT status; /* Get the condition variable's internal semaphore. */ - /* Simply convert the COndition variable control block into a semaphore a cast */ + /* Simply convert the COndition variable control block into a semaphore a cast */ semaphore_ptr = (&( cond->cond_semaphore )); if ( semaphore_ptr->tx_semaphore_suspended_count) { @@ -107,6 +102,6 @@ UINT status; posix_set_pthread_errno(EINVAL); return(EINVAL); } - } + } return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_cond_timedwait.c b/utility/rtos_compatibility_layers/posix/px_cond_timedwait.c index fd82c1d0..1b4660d4 100644 --- a/utility/rtos_compatibility_layers/posix/px_cond_timedwait.c +++ b/utility/rtos_compatibility_layers/posix/px_cond_timedwait.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,17 +27,17 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_cond_timedwait PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_cond_timedwait PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ /* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ +/* */ +/* DESCRIPTION */ /* */ /* This function shall block on a condition variable. They shall be */ /* called with mutex locked by the calling thread or undefined behavior*/ @@ -61,38 +62,32 @@ /* pthread_cond_wait operations on the same condition variable is */ /* undefined; that is, a condition variable becomes bound to a unique */ /* mutex when a thread waits on the condition variable, and this */ -/* (dynamic) binding shall end when the wait returns. */ +/* (dynamic) binding shall end when the wait returns. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* cond condition variable */ /* mutex mutex to be associated with condition */ /* variable */ /* abstime time interval for wait */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* OK if succesfull */ /* ERROR in case of any error */ /* */ -/* CALLS */ +/* CALLS */ /* */ /* pthread_mutex_unlock unlocks the mutex held by the caller */ /* tx_semaphore_get try to get sempaphore internal to cond */ /* tx_semaphore_prioritize prioritize all suspended pthreads */ /* pthread_mutex_lock lock the mutex */ /* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/**************************************************************************/ INT pthread_cond_timedwait(pthread_cond_t *cond,pthread_mutex_t *mutex, struct timespec *abstime) { @@ -107,11 +102,11 @@ TX_THREAD *thread; thread = tx_thread_identify(); /* Raise its preemption threshold so it does not get descheduled. */ - tx_thread_preemption_change(thread,0,&old_threshold); + tx_thread_preemption_change(thread,0,&old_threshold); pthread_mutex_unlock(mutex); semaphore_ptr = (&( cond->cond_semaphore )); - + wait_option = posix_abs_time_to_rel_ticks(abstime); status = tx_semaphore_get(semaphore_ptr, wait_option); @@ -139,6 +134,6 @@ TX_THREAD *thread; return(EINVAL); } pthread_mutex_lock(mutex); - + return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_cond_wait.c b/utility/rtos_compatibility_layers/posix/px_cond_wait.c index 0e05418e..fbbbcd76 100644 --- a/utility/rtos_compatibility_layers/posix/px_cond_wait.c +++ b/utility/rtos_compatibility_layers/posix/px_cond_wait.c @@ -1,17 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,17 +26,17 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_cond_wait PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_cond_wait PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ /* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ +/* */ +/* DESCRIPTION */ /* */ /* This function shall block on a condition variable. They shall be */ /* called with mutex locked by the calling thread or undefined behavior*/ @@ -58,37 +59,31 @@ /* pthread_cond_wait operations on the same condition variable is */ /* undefined; that is, a condition variable becomes bound to a unique */ /* mutex when a thread waits on the condition variable, and this */ -/* (dynamic) binding shall end when the wait returns. */ +/* (dynamic) binding shall end when the wait returns. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* cond condition variable */ /* mutex mutex to be associated with condition */ /* variable */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* OK if succesfull */ /* ERROR in case of any error */ /* */ -/* CALLS */ +/* CALLS */ /* */ /* pthread_mutex_unlock unlocks the mutex held by the caller */ /* tx_semaphore_get try to get sempaphore internal to cond */ /* tx_semaphore_prioritize prioritize all suspended pthreads */ /* pthread_mutex_lock lock the mutex */ /* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/**************************************************************************/ INT pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { @@ -101,7 +96,7 @@ TX_THREAD *thread; thread = tx_thread_identify(); /* Raise its preemption threshold so it does not get descheduled. */ - tx_thread_preemption_change(thread,0,&old_threshold); + tx_thread_preemption_change(thread,0,&old_threshold); pthread_mutex_unlock(mutex); @@ -128,7 +123,7 @@ TX_THREAD *thread; posix_set_pthread_errno(EINVAL); return(EINVAL); } - + pthread_mutex_lock(mutex); return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_error.c b/utility/rtos_compatibility_layers/posix/px_error.c index f7b93cbd..7d950e14 100644 --- a/utility/rtos_compatibility_layers/posix/px_error.c +++ b/utility/rtos_compatibility_layers/posix/px_error.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -56,51 +57,45 @@ /* */ /* POSIX internal code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID posix_error_handler(ULONG error_code) { while (error_code) { ; } } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_internal_error PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_internal_error PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function is invoked whenever an error is encountered */ -/* in the POSIX code. */ -/* */ -/* INPUT */ -/* */ -/* error_code Error code to handle */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* POSIX internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function is invoked whenever an error is encountered */ +/* in the POSIX code. */ +/* */ +/* INPUT */ +/* */ +/* error_code Error code to handle */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* POSIX internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ diff --git a/utility/rtos_compatibility_layers/posix/px_in_thread_context.c b/utility/rtos_compatibility_layers/posix/px_in_thread_context.c index a03d20a1..919ef2c6 100644 --- a/utility/rtos_compatibility_layers/posix/px_in_thread_context.c +++ b/utility/rtos_compatibility_layers/posix/px_in_thread_context.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -57,12 +58,6 @@ /* */ /* posix internal code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ ULONG posix_in_thread_context(VOID) { @@ -72,7 +67,7 @@ ULONG posix_in_thread_context(VOID) #ifndef TX_TIMER_PROCESS_IN_ISR extern TX_THREAD _tx_timer_thread; #endif - + /* Return TX_FALSE if any of the following are true: - we are in the scheduling loop (not in a thread); - we are in an ISR @@ -90,10 +85,10 @@ ULONG posix_in_thread_context(VOID) || (_tx_thread_system_state) /* In an ISR */ #ifndef TX_TIMER_PROCESS_IN_ISR /* Timer routine */ - || (_tx_thread_current_ptr == &_tx_timer_thread) + || (_tx_thread_current_ptr == &_tx_timer_thread) #endif ) - + { /* We are NOT in thread (thread) context. */ return (TX_FALSE); diff --git a/utility/rtos_compatibility_layers/posix/px_int.h b/utility/rtos_compatibility_layers/posix/px_int.h index f6d67ce4..1b0d085a 100644 --- a/utility/rtos_compatibility_layers/posix/px_int.h +++ b/utility/rtos_compatibility_layers/posix/px_int.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -33,15 +34,6 @@ /* This file defines the constants, structures, etc.needed to */ /* implement the Evacuation Kit for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Remove unneeded values, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ #ifndef _TX_PX_INT_H @@ -68,7 +60,7 @@ extern TX_THREAD * _tx_thread_execute_ptr; /* declares posix objects in the px_pth_init.c file */ #ifdef PX_OBJECT_INIT -#define PX_OBJECT_DECLARE +#define PX_OBJECT_DECLARE #else #define PX_OBJECT_DECLARE extern #endif @@ -93,7 +85,7 @@ PX_OBJECT_DECLARE TX_THREAD posix_system_manager; PX_OBJECT_DECLARE TX_BYTE_POOL posix_heap_byte_pool; /* Define a static pool of pthread Control Blocks (TCB). If more pthreades are - required the constant PTHREAD_THREADS_MAX (in tx_posix.h) may be modified. */ + required the constant PTHREAD_THREADS_MAX (in tx_posix.h) may be modified. */ PX_OBJECT_DECLARE POSIX_TCB ptcb_pool[PTHREAD_THREADS_MAX]; #if POSIX_MAX_QUEUES!= 0 @@ -123,11 +115,11 @@ PX_OBJECT_DECLARE pthread_mutexattr_t posix_default_mutex_attr; PX_OBJECT_DECLARE unsigned int posix_errno; - + /**************************************************************************/ /* Local prototypes */ /**************************************************************************/ -/* Define Evacuation Kit for POSIX function prototypes. */ +/* Define Evacuation Kit for POSIX function prototypes. */ INT posix_get_pthread_errno(pthread_t ptid); @@ -159,7 +151,7 @@ VOID posix_internal_error(ULONG error_code); VOID posix_error_handler(ULONG error_code); INT posix_memory_allocate(ULONG size, VOID **memory_ptr); - + INT posix_queue_delete(POSIX_MSG_QUEUE * q_ptr); VOID posix_putback_queue(TX_QUEUE * qid); diff --git a/utility/rtos_compatibility_layers/posix/px_internal_signal_dispatch.c b/utility/rtos_compatibility_layers/posix/px_internal_signal_dispatch.c index e7a7e4be..f23afb60 100644 --- a/utility/rtos_compatibility_layers/posix/px_internal_signal_dispatch.c +++ b/utility/rtos_compatibility_layers/posix/px_internal_signal_dispatch.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -61,12 +62,6 @@ /* */ /* Internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ void internal_signal_dispatch(ULONG id) { @@ -81,7 +76,7 @@ VOID (*handler)(int); /* Determine if the desired signal is valid. */ if (id > SIGRTMAX) { - + /* System error! */ posix_internal_error(444); return; @@ -108,7 +103,7 @@ VOID (*handler)(int); /* See if there is a signal handler setup for this signal. */ if (handler) { - + /* Yes, there is a signal handler - call it! */ (handler)((int) id); } @@ -120,47 +115,47 @@ VOID (*handler)(int); tx_event_flags_set(&(target_thread -> signals.signal_event_flags), ~(((ULONG) 1) << id), TX_AND); /* Now we need to clear this signal and terminate this signal handler thread. */ - + /* Disable interrupts. */ TX_DISABLE - + /* Clear this signal from the pending list. */ target_thread -> signals.signal_pending.signal_set = target_thread -> signals.signal_pending.signal_set & ~(((unsigned long) 1) << id); - + /* Decrement the signal nesting count. */ target_thread -> signals.signal_nesting_depth--; - + /* Is this the last nested signal leaving? */ if (target_thread -> signals.signal_nesting_depth == 0) { - + /* Clear the top signal thread link and resume the target thread. */ target_thread -> signals.top_signal_thread = NULL; - + /* Restore interrupts. */ TX_RESTORE - + /* Resume the target thread. */ tx_thread_resume((TX_THREAD *) target_thread); } else { - + /* Otherwise, there are more signal threads still active. */ - + /* Setup the new top signal thread pointer. */ target_thread -> signals.top_signal_thread = signal_thread -> signals.next_signal_thread; /* Restore interrupts. */ TX_RESTORE - + /* Resume the signal handler thread. */ tx_thread_resume((TX_THREAD *) signal_thread -> signals.next_signal_thread); } /* Now we need to mark this signal thread for destruction. */ posix_destroy_pthread(signal_thread,(VOID *) 0); - + /* Self-suspend the current signal thread. */ - tx_thread_suspend((TX_THREAD *) signal_thread); + tx_thread_suspend((TX_THREAD *) signal_thread); } diff --git a/utility/rtos_compatibility_layers/posix/px_memory_allocate.c b/utility/rtos_compatibility_layers/posix/px_memory_allocate.c index c30a6c0b..5024e8d1 100644 --- a/utility/rtos_compatibility_layers/posix/px_memory_allocate.c +++ b/utility/rtos_compatibility_layers/posix/px_memory_allocate.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -60,12 +61,6 @@ /* */ /* POSIX internal code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT posix_memory_allocate(ULONG size, VOID **memory_ptr) { @@ -84,7 +79,7 @@ INT retval; /* Attempt to allocate the desired memory from the POSIX heap. Do not wait - if memory isn't available, flag an error. */ retval = tx_byte_allocate((TX_BYTE_POOL *)&posix_heap_byte_pool, memory_ptr, - size, TX_NO_WAIT); + size, TX_NO_WAIT); /* Make sure the memory was obtained successfully. */ if (retval) @@ -95,5 +90,5 @@ INT retval; return(ERROR); } /* Return to caller. */ - return(retval); + return(retval); } diff --git a/utility/rtos_compatibility_layers/posix/px_memory_release.c b/utility/rtos_compatibility_layers/posix/px_memory_release.c index c071b97a..b028c47a 100644 --- a/utility/rtos_compatibility_layers/posix/px_memory_release.c +++ b/utility/rtos_compatibility_layers/posix/px_memory_release.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -58,22 +59,16 @@ /* */ /* POSIX internal code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID posix_memory_release(VOID * memory_ptr) { - /* Check if memory_ptr is part of the POSIX byte pool, - * if not just return */ - if (((CHAR *)memory_ptr >= - (CHAR *)&posix_heap_byte_pool.tx_byte_pool_start) || - ((CHAR *)memory_ptr <= - (CHAR *)posix_heap_byte_pool.tx_byte_pool_start + /* Check if memory_ptr is part of the POSIX byte pool, + * if not just return */ + if (((CHAR *)memory_ptr >= + (CHAR *)&posix_heap_byte_pool.tx_byte_pool_start) || + ((CHAR *)memory_ptr <= + (CHAR *)posix_heap_byte_pool.tx_byte_pool_start + posix_heap_byte_pool.tx_byte_pool_size)) { tx_byte_release(memory_ptr); } diff --git a/utility/rtos_compatibility_layers/posix/px_mq_arrange_msg.c b/utility/rtos_compatibility_layers/posix/px_mq_arrange_msg.c index 02649614..f72d0245 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_arrange_msg.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_arrange_msg.c @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -57,15 +58,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Modified comments, */ -/* fixed message swap logic, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ ULONG posix_arrange_msg(TX_QUEUE *Queue, ULONG *pMsgPrio) { @@ -115,7 +107,7 @@ ULONG posix_arrange_msg(TX_QUEUE *Queue, ULONG *pMsgPrio) /* copy FIFO order to the message */ minNo = *q_read; - + /* Found higher priority message. */ maxPrio = priority; @@ -131,10 +123,10 @@ ULONG posix_arrange_msg(TX_QUEUE *Queue, ULONG *pMsgPrio) /* copy number to the local variable. */ number2 = *q_read; - + /* Go to next message. */ q_read++; - + /* find the oldest of the messages in this priority level. */ if( number2 < minNo ) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_attr_init.c b/utility/rtos_compatibility_layers/posix/px_mq_attr_init.c index e06ec746..e79bd6a2 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_attr_init.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_attr_init.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -57,12 +58,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID posix_qattr_init(VOID) { @@ -70,7 +65,7 @@ VOID posix_qattr_init(VOID) struct mq_attr * q_attr; q_attr = &(posix_qattr_default); - + /* This queue is not currently in use. */ q_attr->mq_flags = MQ_FLAGS; q_attr->mq_maxmsg = MQ_MAXMSG; diff --git a/utility/rtos_compatibility_layers/posix/px_mq_close.c b/utility/rtos_compatibility_layers/posix/px_mq_close.c index 7bc067f5..69cfc2b9 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_close.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_close.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -60,24 +61,18 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT mq_close(mqd_t mqdes) { TX_INTERRUPT_SAVE_AREA -TX_QUEUE * Queue; +TX_QUEUE * Queue; POSIX_MSG_QUEUE * q_ptr; - /* Assign a temporary variable for clarity. */ - Queue = &(mqdes->f_data->queue); - q_ptr = (POSIX_MSG_QUEUE * )Queue; + /* Assign a temporary variable for clarity. */ + Queue = &(mqdes->f_data->queue); + q_ptr = (POSIX_MSG_QUEUE * )Queue; /* First, check for an invalid queue pointer. */ if ( (!q_ptr) || ( (q_ptr -> px_queue_id) != PX_QUEUE_ID)) @@ -119,7 +114,7 @@ POSIX_MSG_QUEUE * q_ptr; q_ptr ->open_count--; - /* Destroy the basic Queue is the ref count is zero and + /* Destroy the basic Queue is the ref count is zero and it is marked by unlink. */ if( (! q_ptr ->open_count ) && (q_ptr->unlink_flag == TX_TRUE)) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_create.c b/utility/rtos_compatibility_layers/posix/px_mq_create.c index 4b077bb0..dc9f0fc3 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_create.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_create.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -68,14 +69,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Add 64-bit support, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ POSIX_MSG_QUEUE * posix_mq_create (const CHAR * mq_name, struct mq_attr * msgq_attr) @@ -121,7 +114,7 @@ TX_QUEUE *TheQ; return(TX_NULL); } - /* Now create a ThreadX message queue. + /* Now create a ThreadX message queue. to store only the message pointer and message length. */ temp1 = tx_queue_create((&(posix_q->queue)), (CHAR *)mq_name, @@ -147,11 +140,11 @@ TX_QUEUE *TheQ; /* Restore maximum message length. */ posix_q->q_attr.mq_msgsize = msgq_attr->mq_msgsize; - /* Flags are stored in que descriptor structure and + /* Flags are stored in que descriptor structure and not in mq_att structure. */ - /* Create a byte pool for the queue. - Determine how much memory we need to store all messages in this queue. + /* Create a byte pool for the queue. + Determine how much memory we need to store all messages in this queue. 11 bytes are added to counter overhead as well as alignment problem if any. */ size = ( ((msgq_attr->mq_maxmsg) + 1) * (msgq_attr->mq_msgsize + 11) ); @@ -188,7 +181,7 @@ TX_QUEUE *TheQ; return(TX_NULL); } /* Put the queue back into the POSIX queue pool. */ - posix_putback_queue(TheQ); + posix_putback_queue(TheQ); /* User configuration error - not enough memory. */ posix_errno = EBADF; @@ -211,7 +204,7 @@ TX_QUEUE *TheQ; /* Restore interrupts. */ TX_RESTORE - /* Return ERROR.*/ + /* Return ERROR.*/ return(TX_NULL); } diff --git a/utility/rtos_compatibility_layers/posix/px_mq_find_queue.c b/utility/rtos_compatibility_layers/posix/px_mq_find_queue.c index 3e7c7863..2788cd19 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_find_queue.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_find_queue.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -56,12 +57,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ POSIX_MSG_QUEUE * posix_find_queue(const CHAR *mq_name) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_get_new_queue.c b/utility/rtos_compatibility_layers/posix/px_mq_get_new_queue.c index 6157bc6f..c9479806 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_get_new_queue.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_get_new_queue.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -58,24 +59,18 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ POSIX_MSG_QUEUE * posix_get_new_queue(ULONG maxnum) { -ULONG i; -POSIX_MSG_QUEUE *q_ptr; -VOID *bp; -INT retval; -ULONG size; +ULONG i; +POSIX_MSG_QUEUE *q_ptr; +VOID *bp; +INT retval; +ULONG size; - /* Determine how much memory we need for the queue. + /* Determine how much memory we need for the queue. The queue holds "maxnum" entries; each entry is 2 ULONG. */ size = (maxnum * (TX_4_ULONG * sizeof(ULONG))); @@ -91,14 +86,14 @@ ULONG size; /* try to find one that is not "in use". */ /* Search the queue pool for an available queue. */ for (i = 0, q_ptr = &(posix_queue_pool[0]); - i < POSIX_MAX_QUEUES; + i < POSIX_MAX_QUEUES; i++, q_ptr++) { /* Make sure the queue is not "in use". */ if (q_ptr->in_use == TX_FALSE) { /* This queue is now in use. */ - q_ptr->in_use = TX_TRUE; + q_ptr->in_use = TX_TRUE; /* Point to allocated memory. */ q_ptr->storage = bp; @@ -106,10 +101,10 @@ ULONG size; q_ptr->px_queue_id = PX_QUEUE_ID; /* Stop searching. */ - break; + break; } } - /* If we didn't find a free queue, free the allocated memory. */ + /* If we didn't find a free queue, free the allocated memory. */ if ( i >= POSIX_MAX_QUEUES) { posix_memory_release(bp); diff --git a/utility/rtos_compatibility_layers/posix/px_mq_get_queue_desc.c b/utility/rtos_compatibility_layers/posix/px_mq_get_queue_desc.c index b26883e2..f311b02f 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_get_queue_desc.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_get_queue_desc.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -58,12 +59,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ struct mq_des * posix_get_queue_des(POSIX_MSG_QUEUE * q_ptr) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_open.c b/utility/rtos_compatibility_layers/posix/px_mq_open.c index dbcb0b94..17bb7719 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_open.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_open.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -63,14 +64,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Update comparison with NULL, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ mqd_t mq_open(const CHAR * mqName, ULONG oflags,...) { @@ -81,7 +74,7 @@ struct mq_attr *q_attr; mode_t mode; va_list create_queue; ULONG len; -ULONG temp1; +ULONG temp1; len = strlen(mqName); if(len > PATH_MAX) @@ -134,16 +127,16 @@ ULONG temp1; return((struct mq_des *)ERROR); } - /* If q_attr is NULL then the default attributes of the struct + /* If q_attr is NULL then the default attributes of the struct mq_attr are used */ if(q_attr == NULL) { q_attr = &(posix_qattr_default); temp1 = q_attr->mq_maxmsg; - temp1= temp1 ; /* Just to keep complier happy */ + temp1= temp1 ; /* Just to keep complier happy */ } - /* Create a queue which returns posix queue if successful and + /* Create a queue which returns posix queue if successful and NULL if fails. */ if(!(posix_queue = posix_mq_create(mqName, q_attr))) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_priority_search.c b/utility/rtos_compatibility_layers/posix/px_mq_priority_search.c index 137db751..da7c5996 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_priority_search.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_priority_search.c @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -58,14 +59,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Add 64-bit support, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ ULONG posix_priority_search(mqd_t msgQId, ULONG priority) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_putback_queue.c b/utility/rtos_compatibility_layers/posix/px_mq_putback_queue.c index dd6ae866..e3d67cad 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_putback_queue.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_putback_queue.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -56,12 +57,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID posix_putback_queue(TX_QUEUE * qid) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_queue_delete.c b/utility/rtos_compatibility_layers/posix/px_mq_queue_delete.c index ce677daf..aeb79f98 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_queue_delete.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_queue_delete.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -59,12 +60,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT posix_queue_delete(POSIX_MSG_QUEUE * q_ptr) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_queue_init.c b/utility/rtos_compatibility_layers/posix/px_mq_queue_init.c index b8ba1935..2db344fc 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_queue_init.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_queue_init.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -57,12 +58,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID posix_queue_init(VOID) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_receive.c b/utility/rtos_compatibility_layers/posix/px_mq_receive.c index 8fac9832..bbc799a8 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_receive.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_receive.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -66,14 +67,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Add 64-bit support, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ ssize_t mq_receive( mqd_t mqdes, VOID * pMsg, size_t msgLen, ULONG *pMsgPrio) { @@ -88,9 +81,9 @@ VOID * msgbuf1; UCHAR * msgbuf2; VOID * message_source; - /* Assign a temporary variable for clarity. */ - Queue = &(mqdes->f_data->queue); - q_ptr = (POSIX_MSG_QUEUE * )mqdes->f_data; + /* Assign a temporary variable for clarity. */ + Queue = &(mqdes->f_data->queue); + q_ptr = (POSIX_MSG_QUEUE * )mqdes->f_data; /* First, check for an invalid queue pointer. */ if ((!q_ptr) || ( (q_ptr -> px_queue_id) != PX_QUEUE_ID)) @@ -139,7 +132,7 @@ VOID * message_source; else wait_option = TX_WAIT_FOREVER; - + /* Try to get a message from the message queue. */ /* Create a temporary buffer to get message pointer and message length. */ temp1 = posix_memory_allocate((sizeof(ULONG)) * TX_POSIX_MESSAGE_SIZE, (VOID**)&msgbuf1); @@ -163,12 +156,12 @@ VOID * message_source; /* All ok */ temp1 = OK; - break; + break; } case TX_DELETED: { - break; + break; } case TX_QUEUE_EMPTY: @@ -208,7 +201,7 @@ VOID * message_source; return(temp1); } } - + /* Assign a variable for clarity. */ my_ptr = ( ULONG *)msgbuf1; @@ -221,10 +214,10 @@ VOID * message_source; this_ptr = (CHAR *)(*my_ptr); length_of_message = *(++my_ptr); priority_of_message = *(++my_ptr); - + #endif message_source = (VOID *)this_ptr; - + /* Copy message into supplied buffer. */ msgbuf2 = (UCHAR *)pMsg; @@ -246,7 +239,7 @@ VOID * message_source; { *(msgbuf2++) = *((UCHAR *)(this_ptr++)); } - + temp1 = mycount; } @@ -261,12 +254,12 @@ VOID * message_source; return(ERROR); } - /* Copy message priority */ - if (pMsgPrio) + /* Copy message priority */ + if (pMsgPrio) { *pMsgPrio = priority_of_message; } - + /* All done */ return(length_of_message); } diff --git a/utility/rtos_compatibility_layers/posix/px_mq_reset_queue.c b/utility/rtos_compatibility_layers/posix/px_mq_reset_queue.c index 88aa4beb..4710509d 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_reset_queue.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_reset_queue.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -57,12 +58,6 @@ /* */ /* POSIX internal code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID posix_reset_queue(POSIX_MSG_QUEUE * q_ptr) { diff --git a/utility/rtos_compatibility_layers/posix/px_mq_send.c b/utility/rtos_compatibility_layers/posix/px_mq_send.c index e67af7d3..464af01f 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_send.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_send.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -67,22 +68,14 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Add 64-bit support, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ -INT mq_send( mqd_t mqdes, const CHAR * msg_ptr, size_t msg_len, +INT mq_send( mqd_t mqdes, const CHAR * msg_ptr, size_t msg_len, ULONG msg_prio ) { -TX_QUEUE *Queue; -UINT temp1; -POSIX_MSG_QUEUE *q_ptr; +TX_QUEUE *Queue; +UINT temp1; +POSIX_MSG_QUEUE *q_ptr; VOID *bp; UCHAR *source; UCHAR *destination; @@ -90,9 +83,9 @@ UCHAR *save_ptr; ULONG mycount; ULONG msg[TX_POSIX_MESSAGE_SIZE]; - /* Assign a temporary variable for clarity. */ - Queue = &(mqdes->f_data->queue); - q_ptr = (POSIX_MSG_QUEUE * )mqdes->f_data; + /* Assign a temporary variable for clarity. */ + Queue = &(mqdes->f_data->queue); + q_ptr = (POSIX_MSG_QUEUE * )mqdes->f_data; /* First, check for an invalid queue pointer. */ if ( (!q_ptr) || ( (q_ptr -> px_queue_id) != PX_QUEUE_ID)) @@ -104,9 +97,9 @@ ULONG msg[TX_POSIX_MESSAGE_SIZE]; /* Return ERROR. */ return(ERROR); } - /* Make sure if we're calling this routine from a ISR timeout - is set to zero. */ - if (!(tx_thread_identify())) + /* Make sure if we're calling this routine from a ISR timeout + is set to zero. */ + if (!(tx_thread_identify())) { /* POSIX doesn't have error for this, hence give default. */ posix_errno = EINTR ; @@ -166,7 +159,7 @@ ULONG msg[TX_POSIX_MESSAGE_SIZE]; return(ERROR); } - /* Now try to allocate memory to save the message from the + /* Now try to allocate memory to save the message from the queue's byte pool. */ temp1 = tx_byte_allocate((TX_BYTE_POOL * )&(q_ptr->vq_message_area), &bp, msg_len, TX_NO_WAIT); @@ -174,8 +167,8 @@ ULONG msg[TX_POSIX_MESSAGE_SIZE]; if (temp1 != TX_SUCCESS) { posix_internal_error(9999); - } - /* Got the memory , Setup source and destination pointers + } + /* Got the memory , Setup source and destination pointers Cast them in UCHAR as message length is in bytes. */ source = (UCHAR * ) msg_ptr; destination = (UCHAR * ) bp; diff --git a/utility/rtos_compatibility_layers/posix/px_mq_unlink.c b/utility/rtos_compatibility_layers/posix/px_mq_unlink.c index d755d02f..e3e5f683 100644 --- a/utility/rtos_compatibility_layers/posix/px_mq_unlink.c +++ b/utility/rtos_compatibility_layers/posix/px_mq_unlink.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -59,12 +60,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT mq_unlink(const CHAR * mqName) { diff --git a/utility/rtos_compatibility_layers/posix/px_mx_attr_destroy.c b/utility/rtos_compatibility_layers/posix/px_mx_attr_destroy.c index 692db80c..3a36b8ed 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_attr_destroy.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_attr_destroy.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,48 +27,42 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutexattr_destroy PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutexattr_destroy PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall destroy a mutex attributes object; the object */ /* becomes,in effect,uninitialized.A destroyed attr attributes object */ /* can be reinitialized using pthread_mutexattr_init(); */ -/* */ -/* */ -/* INPUT */ +/* */ +/* */ +/* INPUT */ /* */ /* attr Address of the mutex attributes */ -/* object to be destroyed. */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ +/* object to be destroyed. */ +/* */ +/* OUTPUT */ +/* */ +/* 0 If successful */ /* Value In case of any error or the results */ /* of referencing the object after it */ -/* has been destroyed. */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* has been destroyed. */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutexattr_destroy(pthread_mutexattr_t *attr) diff --git a/utility/rtos_compatibility_layers/posix/px_mx_attr_getprotocol.c b/utility/rtos_compatibility_layers/posix/px_mx_attr_getprotocol.c index 50a5572b..6526c155 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_attr_getprotocol.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_attr_getprotocol.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,46 +27,40 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutexattr_getprotocol PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutexattr_getprotocol PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall gets the mutex protocol attribute. */ /* The protocol of a mutex is contained in the protocol attribute. */ /* attributes. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Pointer to the mutex attributes */ /* protocol Pointer to return mutex protocol */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutexattr_getprotocol( pthread_mutexattr_t *attr, INT *protocol) diff --git a/utility/rtos_compatibility_layers/posix/px_mx_attr_getpshared.c b/utility/rtos_compatibility_layers/posix/px_mx_attr_getpshared.c index e3ea3df8..8621df8b 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_attr_getpshared.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_attr_getpshared.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,46 +27,40 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutexattr_getpshared PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutexattr_getpshared PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall gets the mutex protocol attribute. */ /* The protocol of a mutex is contained in the protocol attribute. */ /* attributes. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Pointer to the mutex attributes */ /* pshared Pointer to return mutex pshared attr */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutexattr_getpshared( pthread_mutexattr_t *attr, INT *pshared) diff --git a/utility/rtos_compatibility_layers/posix/px_mx_attr_gettype.c b/utility/rtos_compatibility_layers/posix/px_mx_attr_gettype.c index 7d391916..2b70d61e 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_attr_gettype.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_attr_gettype.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,46 +27,40 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutexattr_gettype PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutexattr_gettype PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall gets the mutex type attribute. */ /* The type of mutex is contained in the type attribute of the mutex */ /* attributes. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the mutex attributes */ /* type Pointer to return mutex type */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutexattr_gettype( pthread_mutexattr_t *attr, INT *type) diff --git a/utility/rtos_compatibility_layers/posix/px_mx_attr_initi.c b/utility/rtos_compatibility_layers/posix/px_mx_attr_initi.c index f9778997..dd41b9a2 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_attr_initi.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_attr_initi.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,45 +27,39 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutexattr_init PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutexattr_init PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function initializes a pthread mutex attributes object to */ /* default values, if the object is already created this call will */ /* return an error. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Pointer to a mutex attributes */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* posix_allocate_pthread_mutexattr Get a new mutexattr object */ +/* */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* posix_allocate_pthread_mutexattr Get a new mutexattr object */ /* set_default_mutexattr Set mutexattr with default values */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutexattr_init(pthread_mutexattr_t *attr) @@ -73,7 +68,7 @@ INT pthread_mutexattr_init(pthread_mutexattr_t *attr) TX_INTERRUPT_SAVE_AREA - /* Disable interrupts. */ + /* Disable interrupts. */ TX_DISABLE /* Check this attributes object exists ? */ diff --git a/utility/rtos_compatibility_layers/posix/px_mx_attr_setprotocol.c b/utility/rtos_compatibility_layers/posix/px_mx_attr_setprotocol.c index 52fa39ff..5654be6b 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_attr_setprotocol.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_attr_setprotocol.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,46 +27,40 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutexattr_setprotocol PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutexattr_setprotocol PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall sets the mutex protocol attribute. */ /* The protocol of a mutex is contained in the protocol attribute of */ /* the mutex attributes */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Pointer to the mutex attributes */ /* protocol mutex protocol */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, INT protocol) @@ -81,8 +76,8 @@ INT pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, INT protocol) else { if (protocol == PTHREAD_PRIO_INHERIT ) - { - attr->protocol = protocol; + { + attr->protocol = protocol; return(OK); } else diff --git a/utility/rtos_compatibility_layers/posix/px_mx_attr_setpshared.c b/utility/rtos_compatibility_layers/posix/px_mx_attr_setpshared.c index b1790e35..22b3d8c5 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_attr_setpshared.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_attr_setpshared.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,44 +27,38 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutexattr_setpshared PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutexattr_setpshared PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall sets the mutex pshared attribute. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Pointer to the mutex attributes */ /* pshared mutex pshared attr */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, INT pshared) @@ -79,8 +74,8 @@ INT pthread_mutexattr_setpshared (pthread_mutexattr_t *attr, INT pshared) else { if ((pshared == PTHREAD_PROCESS_PRIVATE)||(pshared == PTHREAD_PROCESS_SHARED) ) - { - attr->type = pshared; + { + attr->type = pshared; return(OK); } else diff --git a/utility/rtos_compatibility_layers/posix/px_mx_attr_settype.c b/utility/rtos_compatibility_layers/posix/px_mx_attr_settype.c index f5524b17..68184a3c 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_attr_settype.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_attr_settype.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,46 +27,40 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutexattr_settype PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutexattr_settype PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall sets the mutex type attribute. */ /* The type of mutex is contained in the type attribute of the mutex */ /* attributes. */ /* ***** Only PTHREAD_MUTEX_RECURSIVE type is supported ****** */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the mutex attributes */ /* type mutex type. */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutexattr_settype( pthread_mutexattr_t *attr, INT type) @@ -81,8 +76,8 @@ INT pthread_mutexattr_settype( pthread_mutexattr_t *attr, INT type) else { if (type == PTHREAD_MUTEX_RECURSIVE) - { - attr->type = type ; + { + attr->type = type ; return(OK); } else diff --git a/utility/rtos_compatibility_layers/posix/px_mx_destroy.c b/utility/rtos_compatibility_layers/posix/px_mx_destroy.c index 479b160c..804c48d9 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_destroy.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_destroy.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,46 +27,40 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutex_destroy PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutex_destroy PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall destroy the mutex object referenced by mutex; */ /* the mutex object becomes,in effect, uninitialized.A destroyed mutex */ /* object can be reinitialized using pthread_mutex_init() */ /* It shall be safe to destroy an initialized mutex that is unlocked. */ /* Attempting to destroy a locked mutex results in undefined behavior. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* mutex Address of the mutex */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* tx_mutex_delete ThreadX Mutex service */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* tx_mutex_delete ThreadX Mutex service */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutex_destroy(pthread_mutex_t *mutex) @@ -75,7 +70,7 @@ TX_INTERRUPT_SAVE_AREA TX_MUTEX *mutex_ptr; INT status,retval; - + /* Disable interrupts. */ TX_DISABLE @@ -85,7 +80,7 @@ INT status,retval; if (status == TX_SUCCESS) { mutex->in_use = TX_FALSE; - retval = OK; + retval = OK; } else { diff --git a/utility/rtos_compatibility_layers/posix/px_mx_init.c b/utility/rtos_compatibility_layers/posix/px_mx_init.c index 36821392..db4269d7 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_init.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_init.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,18 +27,18 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutex_init PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutex_init PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall init the mutex object referenced by mutex with */ /* attributes specified by attr. */ /* If attr is NULL, the default mutex attributes are used; the effect */ @@ -45,31 +46,25 @@ /* attributes object. Upon successful initialization,the state of the */ /* mutex becomes initialized and unlocked. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* mutex Pointer to a pthread mutex object */ /* attr Pointer to mutex attributes */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* posix_internal_error In case of some special errors */ +/* */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* posix_internal_error In case of some special errors */ /* posix_in_thread_context Check whether called from a thread */ -/* tx_mutex_create Create a ThreadX Mutex object */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* tx_mutex_create Create a ThreadX Mutex object */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutex_init(pthread_mutex_t *mutex ,pthread_mutexattr_t *attr) @@ -89,7 +84,7 @@ ULONG status,retval; posix_internal_error(444); } - /* Disable interrupts. */ + /* Disable interrupts. */ TX_DISABLE /* Check for any pthread_mutexattr_t suggested */ @@ -102,9 +97,9 @@ ULONG status,retval; { /* attributes passed , check for validity */ if (( (attr->in_use) == TX_FALSE)|| (attr->type!=PTHREAD_MUTEX_RECURSIVE)) - { + { /* attributes passed is not valid, return with an error */ - /* Restore interrupts. */ + /* Restore interrupts. */ TX_RESTORE posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); @@ -114,13 +109,13 @@ ULONG status,retval; mutex_ptr = (&(mutex->mutex_info)) ; - /* Now actually create the mutex */ + /* Now actually create the mutex */ status = tx_mutex_create(mutex_ptr, "PMTX", TX_INHERIT); - + if ( status == TX_SUCCESS) { mutex->in_use = TX_TRUE; - retval = OK; + retval = OK; } else { @@ -129,7 +124,7 @@ ULONG status,retval; posix_set_pthread_errno(EINVAL); retval = EINVAL; } - + TX_RESTORE - return(retval); + return(retval); } diff --git a/utility/rtos_compatibility_layers/posix/px_mx_lock.c b/utility/rtos_compatibility_layers/posix/px_mx_lock.c index 2754b6ac..226f2ea2 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_lock.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_lock.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,52 +27,46 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutex_lock PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutex_lock PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function locks the mutex object referenced. If the mutex is */ /* already locked, the calling thread shall block until the mutex */ /* becomes available. This operation shall return with the mutex object*/ /* referenced by mutex in the locked state with the calling thread as */ /* its owner. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* mutex Address of the mutex */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* tx_thread_identify Get calling thread's pointer */ -/* tx_mutex_get ThreadX Mutex Service */ /* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLS */ +/* */ +/* tx_thread_identify Get calling thread's pointer */ +/* tx_mutex_get ThreadX Mutex Service */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutex_lock(pthread_mutex_t *mutex ) { - + TX_MUTEX *mutex_ptr; TX_THREAD *thread_ptr; INT retval,status; @@ -91,7 +86,7 @@ INT retval,status; case TX_SUCCESS: retval = OK; break; - + default: posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); diff --git a/utility/rtos_compatibility_layers/posix/px_mx_set_default_mutexattr.c b/utility/rtos_compatibility_layers/posix/px_mx_set_default_mutexattr.c index d3a72e62..87d93ce0 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_set_default_mutexattr.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_set_default_mutexattr.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -27,41 +28,35 @@ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* set_default_mutexattr PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* set_default_mutexattr PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function sets default mutex attr w/ default information. */ -/* */ -/* INPUT */ -/* */ -/* mutexattr mutex attr object pointer */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Start-up code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* DESCRIPTION */ +/* */ +/* This function sets default mutex attr w/ default information. */ +/* */ +/* INPUT */ +/* */ +/* mutexattr mutex attr object pointer */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Start-up code */ /* */ /**************************************************************************/ VOID set_default_mutexattr(pthread_mutexattr_t *mutexattr) diff --git a/utility/rtos_compatibility_layers/posix/px_mx_timedlock.c b/utility/rtos_compatibility_layers/posix/px_mx_timedlock.c index 9e8b82ef..b08338ce 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_timedlock.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_timedlock.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,18 +27,18 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutex_timedlock PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutex_timedlock PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function locks the mutex object referenced. If the mutex is */ /* already locked, the calling thread shall block until the mutex */ /* becomes available as in the pthread_mutex_lock( ) function. If the */ @@ -47,31 +48,25 @@ /* referenced by mutex in the locked state with the calling thread as */ /* its owner. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* mutex Address of the mutex */ /* timespec Pointer to timespec structure which */ /* holds timeout period in clock ticks */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* tx_thread_identify Get calling thread's pointer */ -/* tx_mutex_get ThreadX Mutex Service */ /* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* tx_thread_identify Get calling thread's pointer */ +/* tx_mutex_get ThreadX Mutex Service */ +/* */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutex_timedlock(pthread_mutex_t *mutex, struct timespec *abs_timeout) diff --git a/utility/rtos_compatibility_layers/posix/px_mx_trylock.c b/utility/rtos_compatibility_layers/posix/px_mx_trylock.c index 3f10c5a7..b4ec642b 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_trylock.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_trylock.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,48 +27,42 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutex_trylock PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutex_trylock PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall be equivalent to pthread_mutex_lock(), except */ /* that if the mutex object referenced by mutex is currently locked */ /* (by any thread,including the current thread), the call shall return */ /* immediately. If the mutex type is PTHREAD_MUTEX_RECURSIVE and the */ /* mutex is currently owned by the calling thread,the mutex lock count */ /* shall be incremented by one and the pthread_mutex_trylock()function */ -/* shall immediately return success. */ +/* shall immediately return success. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* mutex Pointer to the mutex object */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ -/* Value In case of any error */ -/* */ -/* CALLS */ -/* */ -/* tx_mutex_get ThreadX Mutex get service. */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 If successful */ +/* Value In case of any error */ +/* */ +/* CALLS */ +/* */ +/* tx_mutex_get ThreadX Mutex get service. */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutex_trylock(pthread_mutex_t *mutex) @@ -81,13 +76,13 @@ INT retval,status; /* Try to get the mutex */ status = tx_mutex_get( mutex_ptr, TX_NO_WAIT); - + switch ( status) { case TX_SUCCESS: retval = OK; break; - + case TX_DELETED: posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); diff --git a/utility/rtos_compatibility_layers/posix/px_mx_unlock.c b/utility/rtos_compatibility_layers/posix/px_mx_unlock.c index 0f0b7504..eb5a730f 100644 --- a/utility/rtos_compatibility_layers/posix/px_mx_unlock.c +++ b/utility/rtos_compatibility_layers/posix/px_mx_unlock.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,18 +27,18 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_mutex_unlock PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_mutex_unlock PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function shall release the mutex object referenced by mutex. */ /* The manner in which a mutex is released is dependent upon the mutex */ /* type attribute. If there are threads blocked on the mutex object */ @@ -45,33 +46,27 @@ /* in the mutex becoming available,the scheduling policy shall */ /* determine which thread shall acquire the mutex. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* mutex Address of the mutex */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* tx_mutex_put ThreadX Mutex service */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* tx_mutex_put ThreadX Mutex service */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_mutex_unlock(pthread_mutex_t *mutex ) { - + TX_MUTEX *mutex_ptr; INT retval,status; @@ -84,7 +79,7 @@ INT retval,status; case TX_SUCCESS: retval = OK; break; - + case TX_MUTEX_ERROR: posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); diff --git a/utility/rtos_compatibility_layers/posix/px_nanosleep.c b/utility/rtos_compatibility_layers/posix/px_nanosleep.c index 1460c5cb..6d09e71f 100644 --- a/utility/rtos_compatibility_layers/posix/px_nanosleep.c +++ b/utility/rtos_compatibility_layers/posix/px_nanosleep.c @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -68,14 +69,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Fix bounds check, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ INT nanosleep(struct timespec *req, struct timespec *rem) { @@ -91,7 +84,7 @@ ULONG timer_ticks; return(ERROR); } - /* Add padding of 1 so that the thread will sleep no less than the specified time, + /* Add padding of 1 so that the thread will sleep no less than the specified time, except in the case that timer_ticks is ULONG_MAX */ if(timer_ticks != ULONG_MAX) { @@ -100,7 +93,7 @@ ULONG timer_ticks; /* Now call ThreadX thread sleep service. */ tx_thread_sleep(timer_ticks); - + /* Sleep completed. */ if (rem) { diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_destroy.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_destroy.c index b11fc26c..133f64e1 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_destroy.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_destroy.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,49 +27,43 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_destroy PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_destroy PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function destroys a pthread attributes object and allows the */ /* system to reclaim any resources associated with that pthread */ /* attributes object.This doesn't have an effect on any threads created*/ /* using this pthread attributes object. */ -/* */ -/* */ -/* INPUT */ +/* */ +/* */ +/* INPUT */ /* */ /* attr Address of the pthread attributes */ -/* object to be destroyed. */ -/* */ -/* OUTPUT */ -/* */ -/* 0 If successful */ +/* object to be destroyed. */ +/* */ +/* OUTPUT */ +/* */ +/* 0 If successful */ /* Value In case of any error or the results */ /* of referencing the object after it */ -/* has been destroyed. */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* has been destroyed. */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_destroy(pthread_attr_t *attr) diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_getdetachstate.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_getdetachstate.c index ed6fa3e6..a52464f4 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_getdetachstate.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_getdetachstate.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,52 +27,46 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_getdetachstate PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_getdetachstate PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function returns the detach state attribute from a pthread */ /* attributes object specified.The detach state of a thread indicates */ /* whether the system is allowed to free thread resources when the */ /* thread terminates. */ /* The detach state specifies one of: */ -/* PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE. */ +/* PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE. */ /* The default detach state (DEFAULT_DETACHSTATE) is: */ /* PTHREAD_CREATE_JOINABLE. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* detachstate Address of variable to contain the */ -/* returned detach state */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* returned detach state */ +/* */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_getdetachstate( pthread_attr_t *attr,INT *detachstate) @@ -83,7 +78,7 @@ INT pthread_attr_getdetachstate( pthread_attr_t *attr,INT *detachstate) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { *detachstate = attr->detach_state ; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_getinheritsched.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_getinheritsched.c index 336e1317..db1b1622 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_getinheritsched.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_getinheritsched.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,18 +27,18 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_getinheritsched PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_getinheritsched PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function returns the inheritsched attribute from the thread */ /* attributes object specified.The inheritsched attribute will be one */ /* of PTHREAD_EXPLICIT_SCHED or PTHREAD_INHERIT_SCHED. */ @@ -47,31 +48,25 @@ /* scheduling attributes when creating new threads. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* inheritsched Address of variable to contain the */ -/* returned inheritsched attribute */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* returned inheritsched attribute */ +/* */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_getinheritsched(pthread_attr_t *attr, INT *inheritsched) @@ -82,7 +77,7 @@ INT pthread_attr_getinheritsched(pthread_attr_t *attr, INT *inheritsched) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { *inheritsched = attr->inherit_sched ; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_getschedparam.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_getschedparam.c index 6fee2683..722a3178 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_getschedparam.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_getschedparam.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,47 +27,41 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_getschedparam PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_getschedparam PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function returns the scheduling parameters attribute from the */ /* pthread attributes object. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* sched_param Address of structure to contain the */ -/* returned scheduling parameters */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* returned scheduling parameters */ +/* */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_getschedparam(pthread_attr_t *attr,struct sched_param *param) @@ -77,7 +72,7 @@ INT pthread_attr_getschedparam(pthread_attr_t *attr,struct sched_param *param) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { param->sched_priority = attr->sched_attr.sched_priority; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_getschedpolicy.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_getschedpolicy.c index 1d752762..de0d6610 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_getschedpolicy.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_getschedpolicy.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,47 +26,41 @@ #include "pthread.h" /* Posix API */ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_getschedpolicy PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_getschedpolicy PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function returns the scheduling policy from the pthread */ /* attributes object. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* policy Address of variable to contain the */ -/* returned scheduling policy */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* returned scheduling policy */ +/* */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_getschedpolicy(pthread_attr_t *attr, INT *policy) @@ -76,7 +71,7 @@ INT pthread_attr_getschedpolicy(pthread_attr_t *attr, INT *policy) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { *policy = attr->sched_policy; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_getstack.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_getstack.c index 728c5380..44ac5058 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_getstack.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_getstack.c @@ -1,17 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,51 +26,45 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_getstack PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_getstack PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ /* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/* */ +/* DESCRIPTION */ +/* */ /* This function gets the thread creation stack attributes stackaddr */ /* and stacksize in the attr object. */ /* The stack attributes specify the area of storage to be used for the*/ /* created thread's stack. The base (lowest addressable byte) of the */ /* storage shall be stackaddr , and the size of the storage shall be */ -/* stacksize bytes. */ +/* stacksize bytes. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* stackaddr Pointer to hold Address of stack */ -/* stacksize Holds the stack size */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* stacksize Holds the stack size */ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/**************************************************************************/ INT pthread_attr_getstack( pthread_attr_t *attr,void **stackaddr, size_t *stacksize) { @@ -79,7 +74,7 @@ INT pthread_attr_getstack( pthread_attr_t *attr,void **stackaddr, posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { *stackaddr = attr->stack_address; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_getstackaddr.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_getstackaddr.c index b8c1345e..56c5769c 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_getstackaddr.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_getstackaddr.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,46 +26,40 @@ #include "pthread.h" /* Posix API */ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_getstackaddr PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_getstackaddr PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function returns the stack address associated with a pthread */ -/* attributes */ +/* attributes */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* stackaddr Address of variable to contain the */ -/* returned stack address */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* returned stack address */ +/* */ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_getstackaddr( pthread_attr_t *attr,void **stackaddr) diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_getstacksize.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_getstacksize.c index b25633b8..9f650e8a 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_getstacksize.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_getstacksize.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,47 +27,41 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_getstacksize PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_getstacksize PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function returns the stack size associated with a pthread */ /* The stacksize is the minimum stack size (in bytes) allocated for */ /* the created threads stack. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* stacksize Address of variable to contain the */ -/* returned stack size */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* returned stack size */ +/* */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize) @@ -78,7 +73,7 @@ INT pthread_attr_getstacksize(pthread_attr_t *attr, size_t *stacksize) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { *stacksize = attr->stack_size; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_init.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_init.c index 8bdb6d16..d2a1113c 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_init.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_init.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,45 +27,39 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_init PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_init PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function initializes a pthread attributes object to default */ /* values,if the object is already created this call will reinitialize */ -/* it else it will create a new attr object and initializes it. */ +/* it else it will create a new attr object and initializes it. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ /* set_default_pthread_attr to reset with defualt parameters */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_init(pthread_attr_t *attr) @@ -73,7 +68,7 @@ INT pthread_attr_init(pthread_attr_t *attr) TX_INTERRUPT_SAVE_AREA TX_DISABLE - + /* Check this attributes object exists ? */ if (attr->inuse == TX_FALSE) attr->inuse = TX_TRUE; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_setdetachstate.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_setdetachstate.c index 7ebc3bb6..a6c902cb 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_setdetachstate.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_setdetachstate.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,51 +27,45 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_setdetachstate PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_setdetachstate PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function sets the detach state attribute from a pthread */ /* attributes object specified.The detach state of a thread indicates */ /* whether the system is allowed to free thread resources when the */ /* thread terminates. */ /* The detach state specifies one of: */ -/* PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE. */ +/* PTHREAD_CREATE_DETACHED or PTHREAD_CREATE_JOINABLE. */ /* The default detach state (DEFAULT_DETACHSTATE) is: */ /* PTHREAD_CREATE_JOINABLE. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ -/* detachstate detach state to set */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* detachstate detach state to set */ +/* */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ @@ -82,7 +77,7 @@ INT pthread_attr_setdetachstate(pthread_attr_t *attr,INT detachstate) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { attr->detach_state = detachstate ; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_setinheritsched.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_setinheritsched.c index 7d2f6980..466daf36 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_setinheritsched.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_setinheritsched.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,18 +26,18 @@ #include "pthread.h" /* Posix API */ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_setinheritsched PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_setinheritsched PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function sets the inheritsched attribute from the thread */ /* attributes object specified.The inheritsched attribute will be one */ /* of PTHREAD_EXPLICIT_SCHED or PTHREAD_INHERIT_SCHED. */ @@ -46,30 +47,24 @@ /* scheduling attributes when creating new threads. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* inheritsched inheritsched attribute to set */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_setinheritsched(pthread_attr_t *attr, INT inheritsched) @@ -80,7 +75,7 @@ INT pthread_attr_setinheritsched(pthread_attr_t *attr, INT inheritsched) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { attr->inherit_sched = inheritsched ; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_setschedparam.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_setschedparam.c index ecc0e8de..7b2ed9e6 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_setschedparam.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_setschedparam.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,18 +27,18 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_setschedparam PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_setschedparam PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function sets the scheduling parameters attribute for the */ /* pthread attributes object. */ /* */ @@ -46,27 +47,21 @@ /* */ /* attr Address of the thread attributes */ /* sched_param Address of structure containing the */ -/* scheduling parameters to set */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* scheduling parameters to set */ +/* */ +/* */ +/* OUTPUT */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_setschedparam(pthread_attr_t *attr,struct sched_param *param) @@ -77,7 +72,7 @@ INT pthread_attr_setschedparam(pthread_attr_t *attr,struct sched_param *param) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } if (param->sched_priority == 0) { posix_errno = EINVAL; @@ -88,7 +83,7 @@ INT pthread_attr_setschedparam(pthread_attr_t *attr,struct sched_param *param) { attr->sched_attr.sched_priority = param->sched_priority; - } + } return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_setschedpolicyl.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_setschedpolicyl.c index cde63a7c..01b27ed7 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_setschedpolicyl.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_setschedpolicyl.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,47 +26,41 @@ #include "pthread.h" /* Posix API */ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_setschedpolicy PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_setschedpolicy PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function sets the scheduling policy from the pthread */ /* attributes object. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* policy variable holding the scheduling */ -/* policy to set */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* policy to set */ +/* */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_setschedpolicy(pthread_attr_t *attr, INT policy) @@ -76,7 +71,7 @@ INT pthread_attr_setschedpolicy(pthread_attr_t *attr, INT policy) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { attr->sched_policy = policy; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_setstack.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_setstack.c index 31c92b7f..def00736 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_setstack.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_setstack.c @@ -1,17 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,51 +26,45 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_setstack PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_setstack PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ /* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ +/* */ +/* DESCRIPTION */ +/* */ /* This function sets the thread creation stack attributes stackaddr */ /* and stacksize in the attr object. */ /* The stack attributes specify the area of storage to be used for the*/ /* created thread�s stack. The base (lowest addressable byte) of */ /* the storage shall be stackaddr , and the size of the storage shall */ -/* be stacksize bytes. */ +/* be stacksize bytes. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* stackaddr Address of stack */ -/* stacksize Holds the stack size */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* stacksize Holds the stack size */ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/**************************************************************************/ INT pthread_attr_setstack( pthread_attr_t *attr,void *stackaddr, size_t stacksize) { @@ -85,5 +80,5 @@ INT pthread_attr_setstack( pthread_attr_t *attr,void *stackaddr, attr->stack_address = stackaddr; /* This has got no effect */ attr->stack_size = stacksize; return(OK); - } + } } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_setstackaddr.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_setstackaddr.c index 533bc4a1..9e58e627 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_setstackaddr.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_setstackaddr.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,45 +27,39 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_setstackaddr PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_setstackaddr PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function sets the stack address associated with a pthread */ -/* attributes */ +/* attributes */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* stackaddr Address of variable to contain the */ -/* stack address to set */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* stack address to set */ +/* */ +/* OUTPUT */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_setstackaddr(pthread_attr_t *attr,void *stackaddr) @@ -76,7 +71,7 @@ INT pthread_attr_setstackaddr(pthread_attr_t *attr,void *stackaddr) posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); - } + } else { attr->stack_address = stackaddr; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_attr_setstacksize.c b/utility/rtos_compatibility_layers/posix/px_pth_attr_setstacksize.c index 66eda7a1..e63d19cf 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_attr_setstacksize.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_attr_setstacksize.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,46 +27,40 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_attr_setstacksize PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_attr_setstacksize PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function sets the stack size associated with a pthread attr */ /* The stacksize is the minimum stack size (in bytes) allocated for */ /* the created threads stack. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* attr Address of the thread attributes */ /* stacksize stack size */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) diff --git a/utility/rtos_compatibility_layers/posix/px_pth_cancel.c b/utility/rtos_compatibility_layers/posix/px_pth_cancel.c index 7e0c7a52..faaed386 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_cancel.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_cancel.c @@ -1,17 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -61,12 +62,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT pthread_cancel(pthread_t thread) { @@ -74,12 +69,12 @@ INT pthread_cancel(pthread_t thread) TX_THREAD *thread_ptr; POSIX_TCB *pthread_ptr; - - - - /* Get the thread identifier of the pthread to be canceled */ - thread_ptr = posix_tid2thread(thread); - + + + + /* Get the thread identifier of the pthread to be canceled */ + thread_ptr = posix_tid2thread(thread); + if( (thread_ptr->tx_thread_state == TX_COMPLETED) || (thread_ptr->tx_thread_state == TX_TERMINATED) ) { posix_errno = EINVAL; @@ -103,9 +98,9 @@ POSIX_TCB *pthread_ptr; } else if(pthread_ptr->cancel_type==PTHREAD_CANCEL_ASYNCHRONOUS ) { - /* Signal the housekeeping ThreadX thread to cancel (delete) the requested pthread now */ + /* Signal the housekeeping ThreadX thread to cancel (delete) the requested pthread now */ - posix_destroy_pthread(pthread_ptr,(VOID *)0); + posix_destroy_pthread(pthread_ptr,(VOID *)0); } else /* illegal value in pthread_ptr->cancel_type */ { @@ -114,6 +109,6 @@ POSIX_TCB *pthread_ptr; return(EINVAL); } - /* Indicate success. */ - return(OK); + /* Indicate success. */ + return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_create.c b/utility/rtos_compatibility_layers/posix/px_pth_create.c index a6322414..4f5f9095 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_create.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_create.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -72,15 +73,15 @@ /* or the system-imposed limit on */ /* the number of pthreads in */ /* a process PTHREAD_THREADS_MAX */ -/* would be exceeded. */ +/* would be exceeded. */ /* [EINVAL] value specified by attr is */ /* invalid. */ /* [EPERM] The caller does not have */ /* appropriate permission to set */ /* the required scheduling */ -/* parameters or scheduling policy*/ -/* */ -/* This call will not return an error code of [EINTR]*/ +/* parameters or scheduling policy*/ +/* */ +/* This call will not return an error code of [EINTR]*/ /* */ /* */ /* CALLS */ @@ -93,29 +94,20 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Add 64-bit support, */ -/* remove double parenthesis, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ INT pthread_create (pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void*),void *arg) -{ +{ TX_INTERRUPT_SAVE_AREA TX_THREAD *thread_ptr; -POSIX_TCB *pthread_ptr, *current_thread_ptr; +POSIX_TCB *pthread_ptr, *current_thread_ptr; INT status,retval; - + /* Make sure we're calling this routine from a thread context. */ if (!posix_in_thread_context()) { @@ -123,7 +115,7 @@ INT status,retval; posix_internal_error(444); } - /* Disable interrupts. */ + /* Disable interrupts. */ /* check for any pthread_t attr suggested */ @@ -136,25 +128,25 @@ INT status,retval; { /* Check attributes passed , check for validity */ if ( (attr->inuse) == TX_FALSE) - { + { /* attributes passed are not valid, return with an error */ - posix_errno = EINVAL; + posix_errno = EINVAL; posix_set_pthread_errno(EINVAL); return(EINVAL); } } - /* Get a pthread control block for this new pthread */ + /* Get a pthread control block for this new pthread */ TX_DISABLE - status = posix_allocate_pthread_t(&pthread_ptr); + status = posix_allocate_pthread_t(&pthread_ptr); TX_RESTORE - /* Make sure we got a Thread control block */ + /* Make sure we got a Thread control block */ if ((status == ERROR) || (!pthread_ptr)) { - /* Configuration/resource error. */ - return(EAGAIN); - } + /* Configuration/resource error. */ + return(EAGAIN); + } if(attr->inherit_sched==PTHREAD_INHERIT_SCHED) { @@ -187,17 +179,17 @@ INT status,retval; } /* Now set up pthread initial parameters */ - + pthread_ptr->entry_parameter = arg; pthread_ptr->start_routine = start_routine; /* Newly created pthread not joined by anybody! */ pthread_ptr->is_joined_by = TX_FALSE; pthread_ptr->joined_by_pthreadID =TX_FALSE; - /* Newly created pthread not yet joined to any other pthread */ - pthread_ptr->is_joined_to = TX_FALSE; + /* Newly created pthread not yet joined to any other pthread */ + pthread_ptr->is_joined_to = TX_FALSE; pthread_ptr->joined_to_pthreadID = TX_FALSE; - - + + /* Allow cancel */ pthread_ptr->cancel_state = PTHREAD_CANCEL_ENABLE; pthread_ptr->cancel_type = PTHREAD_CANCEL_DEFERRED; @@ -215,18 +207,18 @@ INT status,retval; /* problem allocating stack space */ if (status == ERROR) { - /* Configuration/resource error. */ - return(EAGAIN); + /* Configuration/resource error. */ + return(EAGAIN); } - + } /* Create an event flags group for sigwait. */ retval = tx_event_flags_create(&(pthread_ptr -> signals.signal_event_flags), "posix sigwait events"); - - /* Get the thread info from the TCB. */ - thread_ptr = posix_tcb2thread(pthread_ptr); - + + /* Get the thread info from the TCB. */ + thread_ptr = posix_tcb2thread(pthread_ptr); + /* Now actually create and start the thread. */ /* convert Posix priorities to Threadx priority */ retval += tx_thread_create(thread_ptr, @@ -238,27 +230,27 @@ INT status,retval; (TX_LOWEST_PRIORITY - pthread_ptr->current_priority + 1), (TX_LOWEST_PRIORITY - pthread_ptr->threshold + 1), pthread_ptr->time_slice, - TX_AUTO_START); - + TX_AUTO_START); + TX_THREAD_EXTENSION_PTR_SET(thread_ptr, pthread_ptr) - - /* See if ThreadX encountered an error */ + + /* See if ThreadX encountered an error */ if (retval) { - /* Internal error */ - posix_error_handler(3333); - retval = EACCES; + /* Internal error */ + posix_error_handler(3333); + retval = EACCES; } else { - /* Everything is fine. */ + /* Everything is fine. */ /* create a pthreadID by type casting POSIX_TCB into pthread_t */ pthread_ptr->pthreadID = (pthread_t )pthread_ptr; *thread = pthread_ptr->pthreadID ; - retval = OK; + retval = OK; } - - /* Everything worked fine if we got here */ - return(retval); + + /* Everything worked fine if we got here */ + return(retval); } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_detach.c b/utility/rtos_compatibility_layers/posix/px_pth_detach.c index 67569584..5f25a98c 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_detach.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_detach.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -48,11 +49,11 @@ /* Eventually, you should call pthread_join() or pthread_detach() for */ /* every thread that is created joinable (with a detachstate of */ /* PTHREAD_CREATE_JOINABLE)so that the system can reclaim all resources*/ -/* associated with the thread. Failure to join to or detach joinable */ +/* associated with the thread. Failure to join to or detach joinable */ /* threads will result in memory and other resource leaks until the */ /* process ends. If thread doesn't represent a valid undetached thread,*/ -/* pthread_detach() will return ESRCH. */ -/* */ +/* pthread_detach() will return ESRCH. */ +/* */ /* */ /* INPUT */ /* */ @@ -71,12 +72,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT pthread_detach(pthread_t thread) @@ -100,7 +95,7 @@ POSIX_TCB *pthread_ptr; return (EINVAL); } pthread_ptr->is_detached = TX_TRUE; - + TX_RESTORE return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_equal.c b/utility/rtos_compatibility_layers/posix/px_pth_equal.c index 314c3981..26397606 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_equal.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_equal.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -41,7 +42,7 @@ /* */ /* This function compares two pthread handles for equality. */ /* */ -/* */ +/* */ /* */ /* INPUT */ /* */ @@ -53,7 +54,7 @@ /* 0 The pthread handles do not refer to the */ /* same thread */ /* 1 The pthread handles refer to the same */ -/* thread */ +/* thread */ /* */ /* CALLS */ /* */ @@ -62,12 +63,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT pthread_equal(pthread_t thread1, pthread_t thread2) { diff --git a/utility/rtos_compatibility_layers/posix/px_pth_exit.c b/utility/rtos_compatibility_layers/posix/px_pth_exit.c index a072777e..d25a8ac0 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_exit.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_exit.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -48,9 +49,9 @@ /* at which time an implicit call to exit() occurs). */ /* The pthread_exit() function provides an interface similar to exit()*/ /* but on a per-thread basis. */ -/* */ -/* pthread_exit() does not return. */ -/* */ +/* */ +/* pthread_exit() does not return. */ +/* */ /* */ /* INPUT */ /* value_ptr exit parameter */ @@ -66,12 +67,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID pthread_exit(void *value_ptr) { @@ -79,15 +74,15 @@ VOID pthread_exit(void *value_ptr) TX_THREAD *thread_ptr; POSIX_TCB *pthread_ptr; - /* Get the thread identifier of the currently running thread */ - thread_ptr = tx_thread_identify(); + /* Get the thread identifier of the currently running thread */ + thread_ptr = tx_thread_identify(); /* get posix TCB for this pthread */ pthread_ptr = (POSIX_TCB *)thread_ptr; - - /* Signal the housekeeping ThreadX thread to delete the requested pthread */ - posix_destroy_pthread(pthread_ptr,value_ptr); - /* Indicate success. */ - return; + /* Signal the housekeeping ThreadX thread to delete the requested pthread */ + posix_destroy_pthread(pthread_ptr,value_ptr); + + /* Indicate success. */ + return; } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_getcanceltype.c b/utility/rtos_compatibility_layers/posix/px_pth_getcanceltype.c index bec5c512..63362e2b 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_getcanceltype.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_getcanceltype.c @@ -1,16 +1,17 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -24,17 +25,17 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_getcanceltype PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_getcanceltype PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ /* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ +/* */ +/* DESCRIPTION */ /* */ /* The pthread_fetcancelstate()function shall atomically both get the */ /* calling thread�s cancelability type to the indicated type and */ @@ -42,31 +43,25 @@ /* by oldtype. Legal values for type are PTHREAD_CANCEL_DEFERRED and */ /* PTHREAD_CANCEL_ASYNCHRONOUS. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* type New cancelability type to be set */ /* oldtype Pointer to old cancelability type */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/**************************************************************************/ INT pthread_getcanceltype (INT type, INT *oldtype) { TX_INTERRUPT_SAVE_AREA @@ -75,12 +70,12 @@ TX_THREAD *thread_ptr; POSIX_TCB *pthread_ptr; /* First check for validity of the new cancel type to be set */ - if ( ( type == PTHREAD_CANCEL_DEFERRED ) || ( type == PTHREAD_CANCEL_ASYNCHRONOUS ) ) + if ( ( type == PTHREAD_CANCEL_DEFERRED ) || ( type == PTHREAD_CANCEL_ASYNCHRONOUS ) ) { TX_DISABLE - /* Get the thread identifier of the currently running thread */ - thread_ptr = tx_thread_identify(); + /* Get the thread identifier of the currently running thread */ + thread_ptr = tx_thread_identify(); /* get posix TCB for this pthread */ pthread_ptr = (POSIX_TCB *)thread_ptr; *oldtype = pthread_ptr->cancel_type; @@ -96,4 +91,4 @@ POSIX_TCB *pthread_ptr; posix_set_pthread_errno(EINVAL); return(EINVAL); } -} +} diff --git a/utility/rtos_compatibility_layers/posix/px_pth_getschedparam.c b/utility/rtos_compatibility_layers/posix/px_pth_getschedparam.c index b0b0c920..b21345b5 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_getschedparam.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_getschedparam.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,48 +27,42 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_getschedparam PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_getschedparam PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function returns the scheduling parameters attribute from the */ /* pthread TCB. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* thread POSIX thread ID */ /* policy Address of the scheduling policy */ /* sched_param Address of structure to contain the */ -/* returned scheduling parameters */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* returned scheduling parameters */ +/* */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_getschedparam(pthread_t thread, INT *policy, struct sched_param *param) @@ -81,7 +76,7 @@ INT pthread_getschedparam(pthread_t thread, INT *policy, struct sched_param *par if(thread_tcb==NULL) { return(ESRCH); - } + } else { *policy=thread_tcb->sched_policy; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_init.c b/utility/rtos_compatibility_layers/posix/px_pth_init.c index 2a35474b..5d2f36ad 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_init.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_init.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -43,16 +44,16 @@ /* */ /* DESCRIPTION */ /* */ -/* Verify that the control block belongs to a POSIX thread and not */ -/* a ThreadX thread */ +/* Verify that the control block belongs to a POSIX thread and not */ +/* a ThreadX thread */ /* */ /* INPUT */ /* */ -/* thread_ptr Pointer to a thread control block */ +/* thread_ptr Pointer to a thread control block */ /* */ /* OUTPUT */ /* */ -/* TX_FALSE if not POSIX thread. TX_TRUE if POSIX thread. */ +/* TX_FALSE if not POSIX thread. TX_TRUE if POSIX thread. */ /* */ /* CALLS */ /* */ @@ -62,58 +63,52 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ static INT is_posix_thread(TX_THREAD *thread_ptr) { if (((POSIX_TCB *)thread_ptr < ptcb_pool) || ((POSIX_TCB *)thread_ptr > &ptcb_pool[PTHREAD_THREADS_MAX - 1])) { - return TX_FALSE; + return TX_FALSE; } - return TX_TRUE; + return TX_TRUE; } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_pthread_init PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_pthread_init PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function sets up / configures / initializes all the */ -/* pthread Control Blocks that we define at compile-time in order to */ -/* ensure that there is sufficient memory. */ -/* */ -/* INPUT */ -/* */ -/* None */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* posix_reset_pthread_t Reset a task control block */ -/* */ -/* CALLED BY */ -/* */ -/* Start-up code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function sets up / configures / initializes all the */ +/* pthread Control Blocks that we define at compile-time in order to */ +/* ensure that there is sufficient memory. */ +/* */ +/* INPUT */ +/* */ +/* None */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* posix_reset_pthread_t Reset a task control block */ +/* */ +/* CALLED BY */ +/* */ +/* Start-up code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -122,47 +117,47 @@ static INT is_posix_thread(TX_THREAD *thread_ptr) VOID posix_pthread_init(VOID) { -ULONG index; +ULONG index; - /* Loop through array of TCBs and initialize each one. */ + /* Loop through array of TCBs and initialize each one. */ for (index = 0; index < PTHREAD_THREADS_MAX; index++) { - posix_reset_pthread_t(&(ptcb_pool[index])); + posix_reset_pthread_t(&(ptcb_pool[index])); } } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_reset_pthread_t PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_reset_pthread_t PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function resets a pthread w/ default information. */ -/* */ -/* INPUT */ -/* */ -/* ptcb pthread control block pointer */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Start-up code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function resets a pthread w/ default information. */ +/* */ +/* INPUT */ +/* */ +/* ptcb pthread control block pointer */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Start-up code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -170,44 +165,44 @@ ULONG index; /**************************************************************************/ VOID posix_reset_pthread_t (POSIX_TCB *ptcb) { - /* Indicate this entry is not in use. */ - ptcb->in_use = TX_FALSE; + /* Indicate this entry is not in use. */ + ptcb->in_use = TX_FALSE; } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_copy_pthread_attr PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_copy_pthread_attr PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function copies pthread attributes from a pthread_attr object */ -/* to a pthread TCB */ -/* */ -/* INPUT */ -/* */ -/* attr pthread attr object pointer */ -/* pthread_ptr target pthread TCB */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Start-up code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* to a pthread TCB */ +/* */ +/* INPUT */ +/* */ +/* attr pthread attr object pointer */ +/* pthread_ptr target pthread TCB */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Start-up code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -219,50 +214,50 @@ ULONG index; pthread_ptr->current_priority = attr->sched_attr.sched_priority ; pthread_ptr->detach_state = attr->detach_state ; pthread_ptr->inherit_sched = attr->inherit_sched ; - pthread_ptr->orig_priority = attr->sched_attr.sched_priority ; + pthread_ptr->orig_priority = attr->sched_attr.sched_priority ; pthread_ptr->sched_attr.sched_priority= attr->sched_attr.sched_priority ; pthread_ptr->pthread_flags = attr->pthread_flags ; pthread_ptr->sched_policy = attr->sched_policy; pthread_ptr->stack_size = attr->stack_size ; pthread_ptr->stack_address = attr->stack_address; - + return; } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_allocate_pthread_t PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_allocate_pthread_t PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function attempts to allocate memory for a pthread stack and */ -/* a POSIX pthread Control Block (PTCB). */ -/* */ -/* INPUT */ -/* */ -/* stack_size Requested task stack size */ -/* tcb_ptr Pointer to tcb pointer */ -/* */ -/* OUTPUT */ -/* */ -/* Completion Status */ -/* */ -/* CALLS */ -/* */ -/* Nothing */ -/* */ -/* CALLED BY */ -/* */ -/* POSIX internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function attempts to allocate memory for a pthread stack and */ +/* a POSIX pthread Control Block (PTCB). */ +/* */ +/* INPUT */ +/* */ +/* stack_size Requested task stack size */ +/* tcb_ptr Pointer to tcb pointer */ +/* */ +/* OUTPUT */ +/* */ +/* Completion Status */ +/* */ +/* CALLS */ +/* */ +/* Nothing */ +/* */ +/* CALLED BY */ +/* */ +/* POSIX internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -271,84 +266,84 @@ ULONG index; INT posix_allocate_pthread_t(POSIX_TCB **ptcb_ptr) { -POSIX_TCB *ptcb; -ULONG index; +POSIX_TCB *ptcb; +ULONG index; - /* Assume the worst. */ - *ptcb_ptr = (POSIX_TCB *)0; + /* Assume the worst. */ + *ptcb_ptr = (POSIX_TCB *)0; - /* This next search is optimized for simplicity, not speed. */ - for (index = 0, ptcb = ptcb_pool; - index < PTHREAD_THREADS_MAX; + /* This next search is optimized for simplicity, not speed. */ + for (index = 0, ptcb = ptcb_pool; + index < PTHREAD_THREADS_MAX; index++, ptcb++) { - /* Is this guy in use? If not, we can use it. */ + /* Is this guy in use? If not, we can use it. */ if (ptcb->in_use == TX_FALSE) { - /* This pTCB is now in use. */ - ptcb->in_use = TX_TRUE; + /* This pTCB is now in use. */ + ptcb->in_use = TX_TRUE; - /* Stop searching. */ - break; + /* Stop searching. */ + break; } - } /* for each POSIX Thread Control Block */ + } /* for each POSIX Thread Control Block */ - /* Did we search all pTCBs and come up empty? */ + /* Did we search all pTCBs and come up empty? */ if (index == PTHREAD_THREADS_MAX) { - /* No more pTCBs available - user configuration error. */ - return(ERROR); + /* No more pTCBs available - user configuration error. */ + return(ERROR); } else { /* Make sure the signal handler information is cleared when the new TCB is allocated. */ memset(&(ptcb -> signals), 0, sizeof(signal_info)); - - /* Found one. */ - *ptcb_ptr = ptcb; + + /* Found one. */ + *ptcb_ptr = ptcb; } return(OK); } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_thread_wrapper PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_thread_wrapper PORTABLE C */ /* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* Every thread that is modeling a ThreadX thread has this routine as */ +/* DESCRIPTION */ +/* */ +/* Every thread that is modeling a ThreadX thread has this routine as */ /* its entry point.This routine simply calls the pthread entry routine */ -/* with its sole argument passed in pthread-create(). */ -/* */ -/* The main purpose of this function is to mimic the pthread interface */ -/* which allows 1 argument to be passed to the entry point of a thread */ -/* */ -/* INPUT */ -/* */ -/* pthread_ptr pthread control block pointer */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* *(pthread_start_routine) Application pthread entry */ -/* */ -/* CALLED BY */ -/* */ -/* POSIX only (internal) */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* with its sole argument passed in pthread-create(). */ +/* */ +/* The main purpose of this function is to mimic the pthread interface */ +/* which allows 1 argument to be passed to the entry point of a thread */ +/* */ +/* INPUT */ +/* */ +/* pthread_ptr pthread control block pointer */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* *(pthread_start_routine) Application pthread entry */ +/* */ +/* CALLED BY */ +/* */ +/* POSIX only (internal) */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -365,48 +360,48 @@ VOID *value_ptr; /* The input argument is really a pointer to the pthread's control block */ TX_THREAD_EXTENSION_PTR_GET(pthread_ptr, POSIX_TCB, pthr_ptr) - /* Invoke the pthread start routine with appropriate arguments */ + /* Invoke the pthread start routine with appropriate arguments */ value_ptr = (pthread_ptr->start_routine)((VOID *)pthread_ptr->entry_parameter); - - /* In ThreadX, when a thread returns from its entry point, it enters the */ - /* "completed" state, which is basically an infinite suspension. */ + + /* In ThreadX, when a thread returns from its entry point, it enters the */ + /* "completed" state, which is basically an infinite suspension. */ /* now use pthread_exit call to end this pthread */ pthread_exit(value_ptr); } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_thread2tcb PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_thread2tcb PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function converts a ThreadX thread identifier into */ -/* a posix pthread control block (TCB) */ -/* */ -/* INPUT */ -/* */ -/* thread_ptr Thread pointer */ -/* */ -/* OUTPUT */ -/* */ -/* pthread pthread Task control block */ -/* */ -/* CALLS */ -/* */ -/* posix_internal_error Internal error */ -/* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function converts a ThreadX thread identifier into */ +/* a posix pthread control block (TCB) */ +/* */ +/* INPUT */ +/* */ +/* thread_ptr Thread pointer */ +/* */ +/* OUTPUT */ +/* */ +/* pthread pthread Task control block */ +/* */ +/* CALLS */ +/* */ +/* posix_internal_error Internal error */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -415,62 +410,62 @@ VOID *value_ptr; POSIX_TCB *posix_thread2tcb(TX_THREAD *thread_ptr) { -POSIX_TCB *p_tcb; +POSIX_TCB *p_tcb; - /* Make sure we were called from a thread. */ + /* Make sure we were called from a thread. */ if (!thread_ptr) { - /* Not called from a thread - error! */ - posix_internal_error(333); + /* Not called from a thread - error! */ + posix_internal_error(333); } - /* Make sure thread is a POSIX thread else following case is illegal. */ + /* Make sure thread is a POSIX thread else following case is illegal. */ if (!is_posix_thread(thread_ptr)) { - /* Not called from a POSIX thread - error! */ - return NULL; + /* Not called from a POSIX thread - error! */ + return NULL; } /* We can do this because the Thread information is intentionally */ /* located as the first field in the structure. */ - p_tcb = (POSIX_TCB *)thread_ptr; + p_tcb = (POSIX_TCB *)thread_ptr; - /* All done. */ - return(p_tcb); + /* All done. */ + return(p_tcb); } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_tcb2thread PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_tcb2thread PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function converts a POSIX TCB into ThreadX thread */ -/* */ -/* */ -/* INPUT */ -/* */ -/* pthread_ptr pthread TCB */ -/* */ -/* OUTPUT */ -/* */ -/* thread ThreadX thread */ -/* */ -/* CALLS */ -/* */ -/* posix_internal_error Internal error */ -/* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function converts a POSIX TCB into ThreadX thread */ +/* */ +/* */ +/* INPUT */ +/* */ +/* pthread_ptr pthread TCB */ +/* */ +/* OUTPUT */ +/* */ +/* thread ThreadX thread */ +/* */ +/* CALLS */ +/* */ +/* posix_internal_error Internal error */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -479,55 +474,55 @@ POSIX_TCB *p_tcb; TX_THREAD *posix_tcb2thread (POSIX_TCB *pthread_ptr) { -TX_THREAD *thread; +TX_THREAD *thread; - /* Make sure we don't have a NULL pointer. */ + /* Make sure we don't have a NULL pointer. */ if (pthread_ptr) { - /* Simply convert the TCB to a Thread via a cast */ - thread = (&(pthread_ptr->thread_info )); + /* Simply convert the TCB to a Thread via a cast */ + thread = (&(pthread_ptr->thread_info )); } else { - thread = ((TX_THREAD *)0); + thread = ((TX_THREAD *)0); } - return(thread); + return(thread); } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_thread2tid PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_thread2tid PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function converts a ThreadX thread identifier into */ -/* posix thread ID */ -/* */ -/* INPUT */ -/* */ -/* thread_ptr Thread pointer */ -/* */ -/* OUTPUT */ -/* */ -/* thread_ID thread_ID */ -/* */ -/* CALLS */ -/* */ -/* posix_internal_error Internal error */ -/* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function converts a ThreadX thread identifier into */ +/* posix thread ID */ +/* */ +/* INPUT */ +/* */ +/* thread_ptr Thread pointer */ +/* */ +/* OUTPUT */ +/* */ +/* thread_ID thread_ID */ +/* */ +/* CALLS */ +/* */ +/* posix_internal_error Internal error */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -539,54 +534,54 @@ TX_THREAD *thread; pthread_t thread_ID; POSIX_TCB *p_tcb; - /* Make sure we were called from a thread. */ + /* Make sure we were called from a thread. */ if (!thread_ptr) { - /* Not called from a thread - error! */ - posix_internal_error(222); + /* Not called from a thread - error! */ + posix_internal_error(222); } /* Get the TCB for this pthread */ p_tcb = posix_thread2tcb(thread_ptr); - thread_ID = p_tcb->pthreadID; + thread_ID = p_tcb->pthreadID; - /* All done. */ - return(thread_ID); + /* All done. */ + return(thread_ID); } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_tid2thread PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_tid2thread PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function converts a posix thread ID into a thread. */ -/* */ -/* INPUT */ -/* */ -/* tid Thread ID */ -/* */ -/* OUTPUT */ -/* */ -/* thread_ptr Thread pointer */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function converts a posix thread ID into a thread. */ +/* */ +/* INPUT */ +/* */ +/* tid Thread ID */ +/* */ +/* OUTPUT */ +/* */ +/* thread_ptr Thread pointer */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -595,56 +590,56 @@ POSIX_TCB *p_tcb; TX_THREAD *posix_tid2thread(pthread_t ptid) { -TX_THREAD *thread; +TX_THREAD *thread; POSIX_TCB *pthread; - /* Make sure we don't have a NULL TID. */ + /* Make sure we don't have a NULL TID. */ if (ptid) { - /* convert the pthread ID to a pThread TCB */ + /* convert the pthread ID to a pThread TCB */ pthread = posix_tid2tcb(ptid); - /* convert the pthread TCB to a pThread TCB */ + /* convert the pthread TCB to a pThread TCB */ thread= posix_tcb2thread(pthread); } else { - thread = ((TX_THREAD *)0); + thread = ((TX_THREAD *)0); } - return(thread); + return(thread); } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_tid2tcb PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_tid2tcb PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function converts a posix thread ID into a posix pthread TCB */ -/* */ -/* INPUT */ -/* */ -/* tid Thread ID */ -/* */ -/* OUTPUT */ -/* */ -/* pthread_ptr pthread pointer */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function converts a posix thread ID into a posix pthread TCB */ +/* */ +/* INPUT */ +/* */ +/* tid Thread ID */ +/* */ +/* OUTPUT */ +/* */ +/* pthread_ptr pthread pointer */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -655,52 +650,52 @@ POSIX_TCB *pthread; POSIX_TCB *pthread; - /* Make sure we don't have a NULL TID. */ + /* Make sure we don't have a NULL TID. */ if (ptid) - /* Simply convert the thread ID to a pthread TCB via a cast */ - pthread = (POSIX_TCB *)ptid; + /* Simply convert the thread ID to a pthread TCB via a cast */ + pthread = (POSIX_TCB *)ptid; else pthread = ((POSIX_TCB *)0); - - return(pthread); + + return(pthread); } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_destroy_pthread PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_destroy_pthread PORTABLE C */ /* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function performs internal cleanup and housekeeping */ -/* when a pthread exits. */ -/* */ -/* INPUT */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function performs internal cleanup and housekeeping */ +/* when a pthread exits. */ +/* */ +/* INPUT */ +/* */ /* pthread_ptr pointer to TCB of the pthread */ -/* to be deleted */ -/* */ -/* OUTPUT */ -/* */ +/* to be deleted */ +/* */ +/* OUTPUT */ +/* */ /* OK If successful */ -/* ERROR If fails */ -/* */ -/* CALLS */ -/* */ -/* tx_queue_send Send to system mgr queue */ -/* posix_internal_error Internal error handling */ -/* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* ERROR If fails */ +/* */ +/* CALLS */ +/* */ +/* tx_queue_send Send to system mgr queue */ +/* posix_internal_error Internal error handling */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -714,7 +709,7 @@ POSIX_TCB *pthread; ULONG request[WORK_REQ_SIZE]; UINT status; - /* Build the request. */ + /* Build the request. */ #ifdef TX_64_BIT request[0] = (ULONG)((ALIGN_TYPE)pthread_ptr >> 32); @@ -727,59 +722,59 @@ UINT status; #endif /* Send a message to the SysMgr supervisor thread, asking it to delete */ - /* the pthread. Since the SysMgr supervisor thread is the highest */ - /* possible priority, this routine will be preempted when we */ - /* post the message to the SysMgr's work queue. */ - - status = tx_queue_send(&posix_work_queue, request, TX_NO_WAIT); - /* This should always succeed. */ + /* the pthread. Since the SysMgr supervisor thread is the highest */ + /* possible priority, this routine will be preempted when we */ + /* post the message to the SysMgr's work queue. */ + + status = tx_queue_send(&posix_work_queue, request, TX_NO_WAIT); + /* This should always succeed. */ if (status != TX_SUCCESS) { - posix_internal_error(1001); + posix_internal_error(1001); } - + /* Return the pthread's TCB to the pool of available TCB's. */ posix_reset_pthread_t(pthread_ptr); } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_do_pthread_delete PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_do_pthread_delete PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function deletes the pthread and reclaims the stack memory. */ -/* Also it resumes any pthread joined to this exiting pthread. */ -/* */ -/* INPUT */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function deletes the pthread and reclaims the stack memory. */ +/* Also it resumes any pthread joined to this exiting pthread. */ +/* */ +/* INPUT */ +/* */ /* pthread_ptr pointer to TCB of the pthread */ -/* to be deleted */ -/* */ -/* OUTPUT */ -/* */ +/* to be deleted */ +/* */ +/* OUTPUT */ +/* */ /* OK If successful */ -/* ERROR If fails */ -/* */ -/* CALLS */ -/* */ -/* tx_thread_terminate Terminate ThreadX thread */ -/* tx_thread_delete Delete the ThreadX thread */ -/* posix_memory_release Release the task's stack */ -/* posix_free_tcb Free pthread control block */ -/* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* ERROR If fails */ +/* */ +/* CALLS */ +/* */ +/* tx_thread_terminate Terminate ThreadX thread */ +/* tx_thread_delete Delete the ThreadX thread */ +/* posix_memory_release Release the task's stack */ +/* posix_free_tcb Free pthread control block */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -792,45 +787,45 @@ TX_INTERRUPT_SAVE_AREA POSIX_TCB *joined_pthread_ptr; TX_THREAD *thread_ptr,*thread1_ptr; -pthread_t joined_pthread_ID; -ULONG status; +pthread_t joined_pthread_ID; +ULONG status; TX_DISABLE /* preserve the thread's return value regardless */ pthread_ptr->value_ptr = value_ptr; - + if ( pthread_ptr->is_joined_by == TX_TRUE) { joined_pthread_ID = pthread_ptr->joined_by_pthreadID ; joined_pthread_ptr = posix_tid2tcb(joined_pthread_ID); - + joined_pthread_ptr->is_joined_to = TX_FALSE; joined_pthread_ptr->joined_to_pthreadID =TX_FALSE; - + thread_ptr = (TX_THREAD *)joined_pthread_ptr; - + /* Now resume the suspended pthread joined to this pthread */ tx_thread_resume(thread_ptr); - } + } /* Terminate the pthread's ThreadX thread. */ thread1_ptr = posix_tcb2thread(pthread_ptr); - status = tx_thread_terminate(thread1_ptr); + status = tx_thread_terminate(thread1_ptr); if (status != TX_SUCCESS) { - posix_internal_error(2244); + posix_internal_error(2244); } - - /* Delete the pthread's ThreadX thread. */ - status = tx_thread_delete(&(pthread_ptr->thread_info)); + + /* Delete the pthread's ThreadX thread. */ + status = tx_thread_delete(&(pthread_ptr->thread_info)); if (status != TX_SUCCESS) { - posix_internal_error(2255); + posix_internal_error(2255); } /* Free the memory allocated for pthread's stack allocated from the posix heap */ /* if the memory was not from the posix heap this call has no effect */ /* it will be the user's responsibility to manage such memory */ - - posix_memory_release(pthread_ptr->stack_address); + + posix_memory_release(pthread_ptr->stack_address); /* Determine if this thread is NOT a signal handler thread. If this is the case, delete the event flag group. */ @@ -841,62 +836,62 @@ ULONG status; tx_event_flags_delete(&(pthread_ptr -> signals.signal_event_flags)); } - /* Return the pthread's TCB to the pool of available TCB's. */ - pthread_ptr->in_use = TX_FALSE; + /* Return the pthread's TCB to the pool of available TCB's. */ + pthread_ptr->in_use = TX_FALSE; TX_RESTORE - - /* All done. */ - return; + + /* All done. */ + return; } -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_set_pthread_errno PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_set_pthread_errno PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function sets the pthread error number. */ -/* Each pthread has got its very own erron number. */ -/* */ -/* INPUT */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function sets the pthread error number. */ +/* Each pthread has got its very own erron number. */ +/* */ +/* INPUT */ +/* */ /* errno_set error number to set */ -/* */ -/* */ -/* OUTPUT */ -/* */ +/* */ +/* */ +/* OUTPUT */ +/* */ /* OK Always return successful */ -/* */ -/* CALLS */ -/* */ -/* tx_thread_identify get calling ThreadX thread */ /* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* CALLS */ +/* */ +/* tx_thread_identify get calling ThreadX thread */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ /* */ /**************************************************************************/ INT posix_set_pthread_errno(ULONG errno_set) -{ +{ TX_THREAD *thread_ptr; POSIX_TCB *pthread_ptr; - /* Get the thread identifier of the currently running thread */ - thread_ptr = tx_thread_identify(); + /* Get the thread identifier of the currently running thread */ + thread_ptr = tx_thread_identify(); /* get posix TCB for this pthread */ pthread_ptr = (POSIX_TCB *)thread_ptr; /* Set the error number */ @@ -904,43 +899,43 @@ POSIX_TCB *pthread_ptr; /* Always return success!*/ return(OK); -} +} -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_get_pthread_errno PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_get_pthread_errno PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function gets the erron number for a pthread. */ -/* Each pthread has got its very own erron number. */ -/* */ -/* INPUT */ -/* */ +/* DESCRIPTION */ +/* */ +/* This function gets the erron number for a pthread. */ +/* Each pthread has got its very own erron number. */ +/* */ +/* INPUT */ +/* */ /* ptid pthread id */ -/* */ -/* */ -/* OUTPUT */ -/* */ +/* */ +/* */ +/* OUTPUT */ +/* */ /* error_number error number for the pthread */ /* ERROR In case of any error */ -/* */ -/* CALLS */ -/* */ -/* tx_thread_identify get calling ThreadX thread */ /* */ -/* CALLED BY */ -/* */ -/* posix internal code */ -/* */ -/* RELEASE HISTORY */ -/* */ +/* CALLS */ +/* */ +/* tx_thread_identify get calling ThreadX thread */ +/* */ +/* CALLED BY */ +/* */ +/* posix internal code */ +/* */ +/* RELEASE HISTORY */ +/* */ /* DATE NAME DESCRIPTION */ /* */ /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ @@ -964,7 +959,7 @@ POSIX_TCB *pthread_ptr; error_number = pthread_ptr->perrno; else error_number = ERROR; - + TX_RESTORE return(error_number); } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_join.c b/utility/rtos_compatibility_layers/posix/px_pth_join.c index 10a9302e..461ab617 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_join.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_join.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -51,12 +52,12 @@ /* Eventually, you should call pthread_join() or pthread_detach() for */ /* every thread that is created joinable (with a detachstate of */ /* PTHREAD_CREATE_JOINABLE)so that the system can reclaim all resources*/ -/* associated with the thread. Failure to join to or detach joinable */ +/* associated with the thread. Failure to join to or detach joinable */ /* threads will result in memory and other resource leaks until the */ /* process ends. If thread doesn't represent a valid undetached thread,*/ -/* pthread_detach() will return ESRCH. */ -/* */ -/* Note: this function must be called from a POSIX context; if it is */ +/* pthread_detach() will return ESRCH. */ +/* */ +/* Note: this function must be called from a POSIX context; if it is */ /* called from ThreadX context an error is returned. */ /* */ /* INPUT */ @@ -77,12 +78,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT pthread_join(pthread_t thread, VOID **value_ptr) @@ -93,9 +88,9 @@ INT pthread_join(pthread_t thread, VOID **value_ptr) TX_THREAD *target_thread; - /* Get the TCB for the currently running pthread */ + /* Get the TCB for the currently running pthread */ current_ptr = posix_thread2tcb(tx_thread_identify()); - + /* Make sure that a TCB was returned. */ if (!current_ptr) { @@ -136,7 +131,7 @@ INT pthread_join(pthread_t thread, VOID **value_ptr) /* but target pthread is already terminated */ /* return the return value of the terminated thread */ target_ptr = posix_tid2tcb(thread); - if(value_ptr)*value_ptr = target_ptr->value_ptr; + if(value_ptr)*value_ptr = target_ptr->value_ptr; return(OK); } @@ -176,9 +171,9 @@ INT pthread_join(pthread_t thread, VOID **value_ptr) TX_RESTORE /* Now calling pthread will suspend itself and wait till target pthread exits */ - tx_thread_suspend ( &(current_ptr->thread_info)); + tx_thread_suspend ( &(current_ptr->thread_info)); /* target pthread exited and thus current pthread will resume now */ /* store return value if value_ptr is valid */ - if(value_ptr)*value_ptr = target_ptr->value_ptr; + if(value_ptr)*value_ptr = target_ptr->value_ptr; return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_kill.c b/utility/rtos_compatibility_layers/posix/px_pth_kill.c index b112a4b2..30bf54d6 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_kill.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_kill.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -68,15 +69,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Remove double parenthesis, */ -/* update argument type, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ int pthread_kill(ALIGN_TYPE thread_id, int sig) { @@ -101,7 +93,7 @@ UINT retval; /* Determine if the desired signal is valid. */ if ((sig < 0) || (sig > SIGRTMAX)) { - + /* Return an error. */ posix_set_pthread_errno(EINVAL); return(ERROR); @@ -126,9 +118,9 @@ UINT retval; /* See if there is a signal handler setup for this signal. */ if (!handler) { - + /* No handler, just set/clear the event flags to handle the sigwait condition. */ - + /* Set the event flag corresponding the signal. */ tx_event_flags_set(&(target_thread -> signals.signal_event_flags), (((ULONG) 1) << sig), TX_OR); @@ -142,7 +134,7 @@ UINT retval; /* Now, let's look to see if the same signal is already pending. */ if (target_thread -> signals.signal_pending.signal_set & (((unsigned long) 1) << sig)) { - + /* Yes, the same signal is already pending, just return. */ return(OK); } @@ -150,17 +142,17 @@ UINT retval; /* Now determine if the thread's signals are masked by pthread_sigmask. */ if (target_thread -> signals.signal_mask.signal_set & (((unsigned long) 1) << sig)) { - - /* Yes, simply set the pending bit so we know that the signal must be activated later when the + + /* Yes, simply set the pending bit so we know that the signal must be activated later when the signal mask for this signal is cleared. */ target_thread -> signals.signal_pending.signal_set = target_thread -> signals.signal_pending.signal_set | (((unsigned long) 1) << sig); return(OK); } /* At this point we know that we need to create a new signal handler thread for processing this signal. */ - - /* Get a pthread control block for this new signal pthread */ - + + /* Get a pthread control block for this new signal pthread */ + /* Disable interrupts for protection. */ TX_DISABLE @@ -168,12 +160,12 @@ UINT retval; _tx_thread_preempt_disable++; /* Allocate a POSIX thread control block. */ - status = posix_allocate_pthread_t(&new_signal_thread); + status = posix_allocate_pthread_t(&new_signal_thread); /* Restore interrupts. */ TX_RESTORE - - /* Make sure we got a new thread control block */ + + /* Make sure we got a new thread control block */ if ((status == ERROR) || (!new_signal_thread)) { @@ -186,10 +178,10 @@ UINT retval; /* Restore interrupts. */ TX_RESTORE - /* Configuration/resource error. */ + /* Configuration/resource error. */ posix_set_pthread_errno(EAGAIN); - return(ERROR); - } + return(ERROR); + } /* Inherit the stack size for the new signal thread. */ new_signal_thread -> stack_size = target_thread -> stack_size ; @@ -200,10 +192,10 @@ UINT retval; /* problem allocating stack space */ if (status == ERROR) { - + /* Mark the previously allocated control block as available. */ new_signal_thread -> in_use = FALSE; - + /* Disable interrupts. */ TX_DISABLE @@ -213,11 +205,11 @@ UINT retval; /* Restore interrupts. */ TX_RESTORE - /* Configuration/resource error. */ + /* Configuration/resource error. */ posix_set_pthread_errno(EAGAIN); - return(ERROR); - } - + return(ERROR); + } + /* Inherit scheduling attributes from base thread. */ new_signal_thread -> current_priority = target_thread -> current_priority ; new_signal_thread -> detach_state = target_thread -> detach_state ; @@ -228,7 +220,7 @@ UINT retval; new_signal_thread -> sched_policy = target_thread -> sched_policy; new_signal_thread -> is_joined_by = TX_FALSE; new_signal_thread -> joined_by_pthreadID = TX_FALSE; - new_signal_thread -> is_joined_to = TX_FALSE; + new_signal_thread -> is_joined_to = TX_FALSE; new_signal_thread -> joined_to_pthreadID = TX_FALSE; new_signal_thread -> cancel_state = PTHREAD_CANCEL_ENABLE; new_signal_thread -> cancel_type = PTHREAD_CANCEL_DEFERRED; @@ -244,7 +236,7 @@ UINT retval; /* Mark the new thread as a signal thread, clear signal info, and setup links. */ new_signal_thread -> signals.signal_handler = TRUE; new_signal_thread -> signals.signal_nesting_depth = target_thread -> signals.signal_nesting_depth; - new_signal_thread -> signals.signal_pending.signal_set = target_thread -> signals.signal_pending.signal_set; + new_signal_thread -> signals.signal_pending.signal_set = target_thread -> signals.signal_pending.signal_set; new_signal_thread -> signals.saved_thread_state = ((TX_THREAD *) target_thread) -> tx_thread_state; new_signal_thread -> signals.base_thread_ptr = target_thread; new_signal_thread -> signals.next_signal_thread = target_thread -> signals.top_signal_thread; @@ -262,9 +254,9 @@ UINT retval; (TX_LOWEST_PRIORITY - new_signal_thread -> current_priority + 1), (TX_LOWEST_PRIORITY - new_signal_thread -> current_priority + 1), new_signal_thread -> time_slice, - TX_AUTO_START); + TX_AUTO_START); - /* See if ThreadX encountered an error */ + /* See if ThreadX encountered an error */ if (retval) { @@ -273,10 +265,10 @@ UINT retval; /* Release the stack memory. */ posix_memory_release(new_signal_thread -> stack_address); - + /* Mark the previously allocated control block as available. */ new_signal_thread -> in_use = FALSE; - + /* Disable interrupts. */ TX_DISABLE @@ -286,10 +278,10 @@ UINT retval; /* Restore interrupts. */ TX_RESTORE - /* Internal error */ - posix_error_handler(3333); + /* Internal error */ + posix_error_handler(3333); posix_set_pthread_errno(EACCES); - return(ERROR); + return(ERROR); } /* Disable interrupts. */ @@ -304,13 +296,13 @@ UINT retval; /* Restore interrupts. */ TX_RESTORE - + /* Suspend the base thread so that it doesn't run again until all the signals have been processed. */ tx_thread_suspend((TX_THREAD *) target_thread); } else if (new_signal_thread -> signals.next_signal_thread) { - + /* Restore interrupts. */ TX_RESTORE @@ -322,7 +314,7 @@ UINT retval; /* Check for a preemption condition. */ _tx_thread_system_preempt_check(); - + /* Return success! */ return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_once.c b/utility/rtos_compatibility_layers/posix/px_pth_once.c index 8b140971..6c6288ba 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_once.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_once.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -65,12 +66,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT pthread_once (pthread_once_t * once_control, VOID (*init_routine) (VOID)) { @@ -84,7 +79,7 @@ INT pthread_once (pthread_once_t * once_control, VOID (*init_routine) (VOID)) } else { - if ( once_control->state==PTH_ONCE_DONE) + if ( once_control->state==PTH_ONCE_DONE) { result = 0; } @@ -106,7 +101,7 @@ INT pthread_once (pthread_once_t * once_control, VOID (*init_routine) (VOID)) once_control->state=PTH_ONCE_DONE; } - /* enable preemption */ + /* enable preemption */ tx_thread_preemption_change( tx_thread_identify(),old_treshold, &temp); if (once_control->state==PTH_ONCE_STARTED) diff --git a/utility/rtos_compatibility_layers/posix/px_pth_self.c b/utility/rtos_compatibility_layers/posix/px_pth_self.c index d4499afb..fd876459 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_self.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_self.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -41,8 +42,8 @@ /* */ /* This function returns thread ID of the calling pthread . */ /* */ -/* */ -/* */ +/* */ +/* */ /* */ /* INPUT */ /* */ @@ -59,35 +60,29 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ pthread_t pthread_self(VOID) { TX_THREAD *thread_ptr; -pthread_t thread_ID; +pthread_t thread_ID; - /* Get the thread identifier of the currently running thread */ - thread_ptr = tx_thread_identify(); + /* Get the thread identifier of the currently running thread */ + thread_ptr = tx_thread_identify(); - /* Convert thread identifier to posix thread ID */ - - thread_ID = posix_thread2tid(thread_ptr); + /* Convert thread identifier to posix thread ID */ + + thread_ID = posix_thread2tid(thread_ptr); /* Determine if this thread is actually the signal thread helper. */ if (((POSIX_TCB *) thread_ptr) -> signals.signal_handler) { - + /* Yes, override the thread_ID with the non-signal thread ID. */ thread_ID = (pthread_t) ((POSIX_TCB *) thread_ptr) -> signals.base_thread_ptr; } - /* All done. */ - return(thread_ID); + /* All done. */ + return(thread_ID); } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_set_default_pthread_attr.c b/utility/rtos_compatibility_layers/posix/px_pth_set_default_pthread_attr.c index ad8d306e..b1964206 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_set_default_pthread_attr.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_set_default_pthread_attr.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,41 +26,35 @@ #include "pthread.h" /* Posix API */ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* set_default_pthread_attr PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* set_default_pthread_attr PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ -/* This function sets default pthread attr w/ default information. */ -/* */ -/* INPUT */ -/* */ -/* attr pthread attr object pointer */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Start-up code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* DESCRIPTION */ +/* */ +/* This function sets default pthread attr w/ default information. */ +/* */ +/* INPUT */ +/* */ +/* attr pthread attr object pointer */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* Start-up code */ /* */ /**************************************************************************/ VOID set_default_pthread_attr(pthread_attr_t *attr) diff --git a/utility/rtos_compatibility_layers/posix/px_pth_setcancelstate.c b/utility/rtos_compatibility_layers/posix/px_pth_setcancelstate.c index 824c0888..55d2a008 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_setcancelstate.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_setcancelstate.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,16 +27,16 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_setcancelstate PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_setcancelstate PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ /* William E. Lamie, Microsoft Corporation */ -/* */ +/* */ /* DESCRIPTION */ /* */ /* The pthread_setcancelstate()function shall atomically both set the */ @@ -44,31 +45,25 @@ /* by oldstate.Legal values for state are PTHREAD_CANCEL_ENABLE and */ /* PTHREAD_CANCEL_DISABLE. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* state New cancelability state to be set */ /* oldstate Pointer to old cancelability state */ -/* */ -/* OUTPUT */ /* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/**************************************************************************/ INT pthread_setcancelstate (INT state, INT *oldstate) { @@ -78,12 +73,12 @@ TX_THREAD *thread_ptr; POSIX_TCB *pthread_ptr; /* First check for validity of the new cancel state to be set */ - if ( (state == PTHREAD_CANCEL_ENABLE) || (state == PTHREAD_CANCEL_DISABLE) ) + if ( (state == PTHREAD_CANCEL_ENABLE) || (state == PTHREAD_CANCEL_DISABLE) ) { TX_DISABLE - /* Get the thread identifier of the currently running thread */ - thread_ptr = tx_thread_identify(); + /* Get the thread identifier of the currently running thread */ + thread_ptr = tx_thread_identify(); /* get posix TCB for this pthread */ pthread_ptr = (POSIX_TCB *)thread_ptr; *oldstate = pthread_ptr->cancel_state; @@ -99,4 +94,4 @@ POSIX_TCB *pthread_ptr; posix_set_pthread_errno(EINVAL); return (EINVAL); } -} +} diff --git a/utility/rtos_compatibility_layers/posix/px_pth_setcanceltype.c b/utility/rtos_compatibility_layers/posix/px_pth_setcanceltype.c index 73fa0623..0d403a08 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_setcanceltype.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_setcanceltype.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,17 +27,17 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_setcanceltype PORTABLE C */ -/* 6.1.7 */ -/* AUTHOR */ -/* */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_setcanceltype PORTABLE C */ +/* 6.1.7 */ +/* AUTHOR */ +/* */ /* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ +/* */ +/* DESCRIPTION */ /* */ /* The pthread_setcancelstate()function shall atomically both get the */ /* calling thread's cancelability type to the indicated type and */ @@ -44,31 +45,25 @@ /* by oldtype. Legal values for type are PTHREAD_CANCEL_DEFERRED and */ /* PTHREAD_CANCEL_ASYNCHRONOUS. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* type New cancelability type to be set */ /* oldtype Pointer to old cancelability type */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ -/**************************************************************************/ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ +/* None */ +/* */ +/* CALLED BY */ +/* */ +/* Application Code */ +/* */ +/**************************************************************************/ INT pthread_setcanceltype (INT type, INT *oldtype) { TX_INTERRUPT_SAVE_AREA @@ -77,12 +72,12 @@ TX_THREAD *thread_ptr; POSIX_TCB *pthread_ptr; /* First check for validity of the new cancel type to be set */ - if ( ( type == PTHREAD_CANCEL_DEFERRED ) || ( type == PTHREAD_CANCEL_ASYNCHRONOUS ) ) + if ( ( type == PTHREAD_CANCEL_DEFERRED ) || ( type == PTHREAD_CANCEL_ASYNCHRONOUS ) ) { TX_DISABLE - /* Get the thread identifier of the currently running thread */ - thread_ptr = tx_thread_identify(); + /* Get the thread identifier of the currently running thread */ + thread_ptr = tx_thread_identify(); /* get posix TCB for this pthread */ pthread_ptr = (POSIX_TCB *)thread_ptr; *oldtype = pthread_ptr->cancel_type; @@ -98,4 +93,4 @@ POSIX_TCB *pthread_ptr; posix_set_pthread_errno(EINVAL); return(EINVAL); } -} +} diff --git a/utility/rtos_compatibility_layers/posix/px_pth_setschedparam.c b/utility/rtos_compatibility_layers/posix/px_pth_setschedparam.c index ec4067c1..9970b900 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_setschedparam.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_setschedparam.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,50 +27,44 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_setschedparam PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_setschedparam PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This function changes the scheduling parameters of a pthread. */ /* */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* thread POSIX thread ID */ /* policy Address of the thread attributes */ /* sched_param Address of structure to contain the */ -/* returned scheduling parameters */ -/* */ -/* */ -/* OUTPUT */ -/* */ -/* 0 if successful */ -/* Value in case of any error */ -/* */ -/* CALLS */ -/* */ +/* returned scheduling parameters */ +/* */ +/* */ +/* OUTPUT */ +/* */ +/* 0 if successful */ +/* Value in case of any error */ +/* */ +/* CALLS */ +/* */ /* posix_tid2tcb */ /* posix_tcb2thread */ /* tx_thread_priority_change */ /* */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ INT pthread_setschedparam(pthread_t thread, INT policy, const struct sched_param *param) diff --git a/utility/rtos_compatibility_layers/posix/px_pth_sigmask.c b/utility/rtos_compatibility_layers/posix/px_pth_sigmask.c index 9838fda3..8957f0ae 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_sigmask.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_sigmask.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -63,15 +64,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Update pthread_kill argument */ -/* cast, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ int pthread_sigmask(int how, const sigset_t *newmask, sigset_t *oldmask) @@ -90,7 +82,7 @@ ULONG reissue_flag; /* Check for a valid how parameter. */ if ((how != SIG_BLOCK) && (how != SIG_SETMASK) & (how != SIG_UNBLOCK)) { - + /* Return an error. */ posix_set_pthread_errno(EINVAL); return(EINVAL); @@ -99,7 +91,7 @@ ULONG reissue_flag; /* Check for valid signal masks. */ if ((newmask == NULL) || (oldmask == NULL)) { - + /* Return an error. */ posix_set_pthread_errno(EINVAL); return(EINVAL); @@ -121,7 +113,7 @@ ULONG reissue_flag; /* Determine if the current thread is a signal handler thread. */ if (base_thread -> signals.signal_handler) { - + /* Pickup target thread. */ base_thread = base_thread -> signals.base_thread_ptr; } @@ -132,7 +124,7 @@ ULONG reissue_flag; /* Now process based on how the mask is to be changed. */ if (how == SIG_BLOCK) { - + /* Simply set the mask to block the signal(s). */ base_thread -> signals.signal_mask.signal_set = base_thread -> signals.signal_mask.signal_set | newmask -> signal_set; } @@ -145,17 +137,17 @@ ULONG reissue_flag; /* Now modify the singal mask correspondingly. */ if (how == SIG_UNBLOCK) { - + /* Clear only the signals specified in the new signal mask. */ base_thread -> signals.signal_mask.signal_set = base_thread -> signals.signal_mask.signal_set & ~(newmask -> signal_set); } else { - + /* Simply set the signal mask to the new signal mask value. */ base_thread -> signals.signal_mask.signal_set = newmask -> signal_set; } - + /* Now determine if there are any signals that need to be activated. */ released_signals = blocked_signals & ~(base_thread -> signals.signal_mask.signal_set); @@ -168,34 +160,34 @@ ULONG reissue_flag; /* Temporarily disable preemption. */ _tx_thread_preempt_disable++; - + /* Restore interrupts. */ TX_RESTORE - + /* Set the reissue flag to false. */ reissue_flag = TX_FALSE; - + /* Loop to process all the blocked signals. */ signal_number = 0; while ((released_signals) && (signal_number < 32)) { - + /* Determine if this signal was released. */ if (released_signals & 1) { - + /* Yes, this signal was released. We need to make it active again. */ - + /* Clear the pending bit so the pthread_kill call will not discard the signal (signals are not queued in this implementation). */ base_thread -> signals.signal_pending.signal_set = base_thread -> signals.signal_pending.signal_set & ~(((unsigned long) 1) << signal_number); /* Call pthread_kill to reissue the signal. */ pthread_kill((ALIGN_TYPE) base_thread, signal_number); - + /* Set the reissue flag. */ reissue_flag = TX_TRUE; } - + /* Look for next signal. */ released_signals = released_signals >> 1; signal_number++; @@ -206,22 +198,22 @@ ULONG reissue_flag; /* Release preemption. */ _tx_thread_preempt_disable--; - + /* Restore interrupts. */ TX_RESTORE /* Check for a preemption condition. */ _tx_thread_system_preempt_check(); - + /* Determine if the reissue flag is set. */ if (reissue_flag == TX_TRUE) { /* Relinquish to allow signal thread at same priority to run before we return. */ - _tx_thread_relinquish(); + _tx_thread_relinquish(); } } - } + } /* Setup return mask. */ oldmask -> signal_set = previous_mask; diff --git a/utility/rtos_compatibility_layers/posix/px_pth_testcancel.c b/utility/rtos_compatibility_layers/posix/px_pth_testcancel.c index 6e84dd32..e64729df 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_testcancel.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_testcancel.c @@ -1,17 +1,18 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -62,29 +63,23 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID pthread_testcancel(VOID) { POSIX_TCB *pthread_ptr; - - /* Get the thread identifier of the calling pthread */ - pthread_ptr = posix_tid2tcb(pthread_self()); + + /* Get the thread identifier of the calling pthread */ + pthread_ptr = posix_tid2tcb(pthread_self()); /* Check if thread was created with cancel enable */ if ( (pthread_ptr->cancel_state == PTHREAD_CANCEL_ENABLE) && (pthread_ptr->cancel_type==PTHREAD_CANCEL_DEFERRED) && (pthread_ptr->cancel_request==TRUE) ) { - - /* Signal the housekeeping ThreadX thread to cancel (delete) this pthread */ + + /* Signal the housekeeping ThreadX thread to cancel (delete) this pthread */ posix_destroy_pthread(pthread_ptr,(VOID *)0); } } diff --git a/utility/rtos_compatibility_layers/posix/px_pth_yield.c b/utility/rtos_compatibility_layers/posix/px_pth_yield.c index 20113844..a6c17278 100644 --- a/utility/rtos_compatibility_layers/posix/px_pth_yield.c +++ b/utility/rtos_compatibility_layers/posix/px_pth_yield.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,45 +27,39 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* pthread_yield PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* pthread_yield PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This subroutine forces the calling thread to relinquish use of its */ /* processor,and to wait in the run queue before it is scheduled again.*/ /* If the run queue is empty when this subroutine is called, the */ /* calling thread is immediately rescheduled. */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* Nothing */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* None */ /* */ -/* CALLS */ -/* */ -/* posix_internal_error posix internal error function */ +/* CALLS */ +/* */ +/* posix_internal_error posix internal error function */ /* tx_thread_relinquish ThreadX function */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ VOID pthread_yield(VOID) diff --git a/utility/rtos_compatibility_layers/posix/px_px_initialize.c b/utility/rtos_compatibility_layers/posix/px_px_initialize.c index 94ea3a06..0ad147a0 100644 --- a/utility/rtos_compatibility_layers/posix/px_px_initialize.c +++ b/utility/rtos_compatibility_layers/posix/px_px_initialize.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -27,8 +28,8 @@ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -77,12 +78,6 @@ /* */ /* POSIX internal code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ static VOID posix_memory_init(VOID * posix_heap_ptr) { @@ -94,7 +89,7 @@ INT retval; retval = tx_byte_pool_create((TX_BYTE_POOL *)&posix_heap_byte_pool, "POSIX HEAP", posix_heap_ptr, - POSIX_HEAP_SIZE_IN_BYTES); + POSIX_HEAP_SIZE_IN_BYTES); /* Make sure the byte pool was created successfully. */ if (retval) @@ -146,11 +141,11 @@ INT retval; static VOID posix_semaphore_init(VOID) { -ULONG i; -sem_t *sem_ptr; +ULONG i; +sem_t *sem_ptr; /* Start at the front of the pool. */ - sem_ptr = &(posix_sem_pool[0]); + sem_ptr = &(posix_sem_pool[0]); for (i = 0; i < SEM_NSEMS_MAX; i++, sem_ptr++) { @@ -219,20 +214,20 @@ VOID *posix_initialize(VOID * posix_memory) UCHAR *pointer; - /* Setup temporary memory pointer, so we can start allocating - space for the posix data structures. The important thing to + /* Setup temporary memory pointer, so we can start allocating + space for the posix data structures. The important thing to remember here is that the system thread's stack, the region0 memory, and the queue are allocated sequentially from the address specified by posix_memory. */ pointer = (UCHAR *)posix_memory; - - /* Start up the System Manager thread. */ + + /* Start up the System Manager thread. */ tx_thread_create(&posix_system_manager, "POSIX System Manager", posix_system_manager_entry, 0, pointer, POSIX_SYSTEM_STACK_SIZE, SYSMGR_PRIORITY, SYSMGR_THRESHOLD, - TX_NO_TIME_SLICE, TX_AUTO_START); - + TX_NO_TIME_SLICE, TX_AUTO_START); + pointer = pointer + POSIX_SYSTEM_STACK_SIZE; /* Set up a memory "heap" used internally by the POSIX. */ @@ -243,11 +238,11 @@ UCHAR *pointer; /* Create the work item message queue. */ tx_queue_create(&posix_work_queue, "POSIX work queue", WORK_REQ_SIZE, pointer, WORK_QUEUE_DEPTH*WORK_REQ_SIZE); - + pointer = pointer + (WORK_QUEUE_DEPTH * WORK_REQ_SIZE); - /* Initialize static pool of pthreads Control blocks. */ - posix_pthread_init(); + /* Initialize static pool of pthreads Control blocks. */ + posix_pthread_init(); /* Create a default pthread_attr */ set_default_pthread_attr(&posix_default_pthread_attr); @@ -264,7 +259,7 @@ UCHAR *pointer; /* Set up a pool of semaphores used internally by the POSIX. */ posix_semaphore_init(); #endif - + /* Create a default mutex_attr */ set_default_mutexattr(&posix_default_mutex_attr); diff --git a/utility/rtos_compatibility_layers/posix/px_sched_get_prio.c b/utility/rtos_compatibility_layers/posix/px_sched_get_prio.c index af2ec4c4..253622d7 100644 --- a/utility/rtos_compatibility_layers/posix/px_sched_get_prio.c +++ b/utility/rtos_compatibility_layers/posix/px_sched_get_prio.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -58,12 +59,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ diff --git a/utility/rtos_compatibility_layers/posix/px_sched_yield.c b/utility/rtos_compatibility_layers/posix/px_sched_yield.c index fc2297bf..870a2572 100644 --- a/utility/rtos_compatibility_layers/posix/px_sched_yield.c +++ b/utility/rtos_compatibility_layers/posix/px_sched_yield.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -61,12 +62,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT sched_yield(VOID) { diff --git a/utility/rtos_compatibility_layers/posix/px_sem_close.c b/utility/rtos_compatibility_layers/posix/px_sem_close.c index c695000d..8beb79a2 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_close.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_close.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -60,12 +61,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT sem_close(sem_t * sem) { diff --git a/utility/rtos_compatibility_layers/posix/px_sem_destroy.c b/utility/rtos_compatibility_layers/posix/px_sem_destroy.c index 7f5db2fe..8cdbe619 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_destroy.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_destroy.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -60,12 +61,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT sem_destroy(sem_t *sem) { @@ -76,7 +71,7 @@ INT sem_destroy(sem_t *sem) result = EINVAL; /* general error */ } - else + else { if(sem->sem.tx_semaphore_suspended_count > 0 ) result = EBUSY; else result = NO_ERROR; diff --git a/utility/rtos_compatibility_layers/posix/px_sem_find_sem.c b/utility/rtos_compatibility_layers/posix/px_sem_find_sem.c index c8e3c85b..ada7fe37 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_find_sem.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_find_sem.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -58,14 +59,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 08-02-2021 Scott Larson Removed unneeded semicolon, */ -/* resulting in version 6.1.8 */ -/* */ /**************************************************************************/ sem_t* posix_find_sem(const CHAR * name) { diff --git a/utility/rtos_compatibility_layers/posix/px_sem_get_new_sem.c b/utility/rtos_compatibility_layers/posix/px_sem_get_new_sem.c index 0a7e56a0..e5e9239f 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_get_new_sem.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_get_new_sem.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -57,12 +58,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ TX_SEMAPHORE * posix_get_new_sem(VOID) { @@ -85,7 +80,7 @@ sem_t *sem_ptr; if (sem_ptr->in_use == TX_FALSE) { - /* Found one! */ + /* Found one! */ tx_sem = MAKE_TX_SEM(sem_ptr); /* This semaphore is now in use. */ diff --git a/utility/rtos_compatibility_layers/posix/px_sem_getvalue.c b/utility/rtos_compatibility_layers/posix/px_sem_getvalue.c index 0e751697..291c59d0 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_getvalue.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_getvalue.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -60,12 +61,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT sem_getvalue(sem_t * sem,ULONG * sval) { @@ -74,7 +69,7 @@ TX_INTERRUPT_SAVE_AREA TX_SEMAPHORE *TheSem; - /* get ThreadX semaphore. */ + /* get ThreadX semaphore. */ TheSem = (TX_SEMAPHORE *)sem; /* First, check for an invalid semaphore pointer. */ diff --git a/utility/rtos_compatibility_layers/posix/px_sem_init.c b/utility/rtos_compatibility_layers/posix/px_sem_init.c index 48cab2ea..532491e6 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_init.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_init.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -60,12 +61,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT sem_init(sem_t *sem , INT pshared, UINT value) { @@ -76,7 +71,7 @@ INT sem_init(sem_t *sem , INT pshared, UINT value) result = EINVAL; /* general error */ } - else + else { if(tx_semaphore_create(&(sem->sem),"",value)) result = EINVAL; else diff --git a/utility/rtos_compatibility_layers/posix/px_sem_open.c b/utility/rtos_compatibility_layers/posix/px_sem_open.c index 18ef1462..ad9468a8 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_open.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_open.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -64,21 +65,13 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Update comparison with NULL, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ sem_t * sem_open(const CHAR * name, ULONG oflag, ...) { TX_INTERRUPT_SAVE_AREA -TX_SEMAPHORE *TheSem; +TX_SEMAPHORE *TheSem; sem_t *semid; ULONG retval; ULONG len; @@ -92,7 +85,7 @@ mode_t mode; { /* return POSIX error. */ posix_internal_error(444); - + /* return error. */ return (( sem_t * )SEM_FAILED); } @@ -134,7 +127,7 @@ mode_t mode; posix_set_pthread_errno(ENOENT); /* Return the SEM_FAILED error. */ - return(( sem_t * )SEM_FAILED); + return(( sem_t * )SEM_FAILED); } if( (oflag == O_CREAT) || ( (oflag & (O_CREAT|O_EXCL )) == (O_CREAT|O_EXCL) ) ) { @@ -206,7 +199,7 @@ mode_t mode; posix_sem->refCnt = value; /* Give the caller the semaphore ID. */ - semid = (sem_t * )TheSem; + semid = (sem_t * )TheSem; /* Restore interrupts. */ TX_RESTORE diff --git a/utility/rtos_compatibility_layers/posix/px_sem_post.c b/utility/rtos_compatibility_layers/posix/px_sem_post.c index 0b72935d..a1164a0d 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_post.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_post.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -58,12 +59,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT sem_post(sem_t * sem) { diff --git a/utility/rtos_compatibility_layers/posix/px_sem_reset.c b/utility/rtos_compatibility_layers/posix/px_sem_reset.c index 2a663e74..0d94e269 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_reset.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_reset.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -56,12 +57,6 @@ /* */ /* POSIX internal Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID posix_sem_reset(sem_t *sem ) { diff --git a/utility/rtos_compatibility_layers/posix/px_sem_set_sem_name.c b/utility/rtos_compatibility_layers/posix/px_sem_set_sem_name.c index 2f40abae..f662bfca 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_set_sem_name.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_set_sem_name.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -57,12 +58,6 @@ /* */ /* POSIX internal code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ VOID posix_set_sem_name(sem_t * sem, CHAR *name) { diff --git a/utility/rtos_compatibility_layers/posix/px_sem_trywait.c b/utility/rtos_compatibility_layers/posix/px_sem_trywait.c index db482a7d..04a9afeb 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_trywait.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_trywait.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -60,12 +61,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT sem_trywait(sem_t * sem) { diff --git a/utility/rtos_compatibility_layers/posix/px_sem_unlink.c b/utility/rtos_compatibility_layers/posix/px_sem_unlink.c index 7bba322b..92ec02a0 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_unlink.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_unlink.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -60,14 +61,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Remove double parenthesis, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ INT sem_unlink(const CHAR * name) { @@ -96,7 +89,7 @@ ULONG len; posix_set_pthread_errno(ENOENT); /* Return Error. */ - return(ERROR); + return(ERROR); } if(sem) diff --git a/utility/rtos_compatibility_layers/posix/px_sem_wait.c b/utility/rtos_compatibility_layers/posix/px_sem_wait.c index a7f510f2..f1be786d 100644 --- a/utility/rtos_compatibility_layers/posix/px_sem_wait.c +++ b/utility/rtos_compatibility_layers/posix/px_sem_wait.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -59,12 +60,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ INT sem_wait( sem_t * sem ) { diff --git a/utility/rtos_compatibility_layers/posix/px_sig_addset.c b/utility/rtos_compatibility_layers/posix/px_sig_addset.c index b94db0a6..a0e657c8 100644 --- a/utility/rtos_compatibility_layers/posix/px_sig_addset.c +++ b/utility/rtos_compatibility_layers/posix/px_sig_addset.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -59,12 +60,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ int sigaddset(sigset_t *set, int signo) { @@ -72,7 +67,7 @@ int sigaddset(sigset_t *set, int signo) /* Determine if the desired signal is valid. */ if ((signo < 0) || (signo > SIGRTMAX)) { - + /* Return an error. */ posix_set_pthread_errno(EINVAL); return(ERROR); @@ -82,5 +77,5 @@ int sigaddset(sigset_t *set, int signo) set -> signal_set = set -> signal_set | (((ULONG) 1) << signo); /* Return success! */ - return(OK); + return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_sig_delset.c b/utility/rtos_compatibility_layers/posix/px_sig_delset.c index a2867781..eb2943d3 100644 --- a/utility/rtos_compatibility_layers/posix/px_sig_delset.c +++ b/utility/rtos_compatibility_layers/posix/px_sig_delset.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -59,12 +60,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ int sigdelset(sigset_t *set, int signo) { @@ -72,7 +67,7 @@ int sigdelset(sigset_t *set, int signo) /* Determine if the desired signal is valid. */ if ((signo < 0) || (signo > SIGRTMAX)) { - + /* Return an error. */ posix_set_pthread_errno(EINVAL); return(EINVAL); @@ -82,5 +77,5 @@ int sigdelset(sigset_t *set, int signo) set -> signal_set = set -> signal_set & ~(((unsigned long) 1) << signo); /* Return success! */ - return(OK); + return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_sig_emptyset.c b/utility/rtos_compatibility_layers/posix/px_sig_emptyset.c index 8cc92aa9..3bf716df 100644 --- a/utility/rtos_compatibility_layers/posix/px_sig_emptyset.c +++ b/utility/rtos_compatibility_layers/posix/px_sig_emptyset.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -57,12 +58,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ int sigemptyset(sigset_t *set) { @@ -70,7 +65,7 @@ int sigemptyset(sigset_t *set) /* Is there a pointer. */ if (!set) { - + /* Return an error. */ posix_set_pthread_errno(EINVAL); return(ERROR); diff --git a/utility/rtos_compatibility_layers/posix/px_sig_fillset.c b/utility/rtos_compatibility_layers/posix/px_sig_fillset.c index 46447ff8..d769a6e8 100644 --- a/utility/rtos_compatibility_layers/posix/px_sig_fillset.c +++ b/utility/rtos_compatibility_layers/posix/px_sig_fillset.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -58,12 +59,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ int sigfillset(sigset_t *set) { @@ -71,7 +66,7 @@ int sigfillset(sigset_t *set) /* Is there a pointer. */ if (!set) { - + /* Return an error. */ posix_set_pthread_errno(EINVAL); return(ERROR); diff --git a/utility/rtos_compatibility_layers/posix/px_sig_signal.c b/utility/rtos_compatibility_layers/posix/px_sig_signal.c index 7cbdd012..d086adce 100644 --- a/utility/rtos_compatibility_layers/posix/px_sig_signal.c +++ b/utility/rtos_compatibility_layers/posix/px_sig_signal.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -61,12 +62,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ int signal(int signo, void (*func)(int)) { @@ -85,7 +80,7 @@ POSIX_TCB *current_thread; /* Determine if the desired signal is valid. */ if ((signo < 0) || (signo > SIGRTMAX)) { - + /* Return an error. */ posix_set_pthread_errno(EINVAL); return(ERROR); @@ -93,10 +88,10 @@ POSIX_TCB *current_thread; /* Now pickup the current thread pointer. */ current_thread = (POSIX_TCB *) tx_thread_identify(); - + /* Now index into the array of signal handlers and insert this one. */ current_thread -> signals.signal_func[signo] = func; - + /* Return success! */ return(OK); } diff --git a/utility/rtos_compatibility_layers/posix/px_sig_wait.c b/utility/rtos_compatibility_layers/posix/px_sig_wait.c index 92294a73..35ea6531 100644 --- a/utility/rtos_compatibility_layers/posix/px_sig_wait.c +++ b/utility/rtos_compatibility_layers/posix/px_sig_wait.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /**************************************************************************/ /**************************************************************************/ @@ -63,12 +64,6 @@ /* */ /* Application Code */ /* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ int sigwait(const sigset_t *set, int *sig) { @@ -99,7 +94,7 @@ POSIX_TCB *base_thread; /* Determine if the current thread is a signal handler thread. */ if (base_thread -> signals.signal_handler) { - + /* Pickup target thread. */ base_thread = base_thread -> signals.base_thread_ptr; } @@ -114,9 +109,9 @@ POSIX_TCB *base_thread; /* Are there any. */ if (pending_signals) { - + /* Yes, there are signals being masked currently that would satisfy this request. */ - + /* Save the current mask. */ saved_mask = base_thread -> signals.signal_mask.signal_set; @@ -125,31 +120,31 @@ POSIX_TCB *base_thread; /* Call pthread_sigmask to temporarily unblock these signals which will release them as well. */ pthread_sigmask(SIG_UNBLOCK, set, &original_set); - + /* Now determine if the changed mask is still in effect, i.e., there wasn't a pthread_sigmask call from any subsequent signal handlers. */ if (base_thread -> signals.signal_mask.signal_set == changed_mask) { - + /* Yes, restore the previous signal mask. */ base_thread -> signals.signal_mask.signal_set = saved_mask; } - + /* Derived the signal number from the bit map. */ TX_LOWEST_SET_BIT_CALCULATE(pending_signals, signal_number); - + /* Return the signal number. */ *sig = (int) signal_number; - + /* Return success! */ return(OK); } - + /* Determine if there are any signals that have to be temporarily cleared. */ if (base_thread -> signals.signal_mask.signal_set & set -> signal_set) { - + /* Yes, there are signals being masked needed to satisfy this request. */ - + /* Save the current mask. */ saved_mask = base_thread -> signals.signal_mask.signal_set; @@ -159,14 +154,14 @@ POSIX_TCB *base_thread; /* Apply the changed signal mask. */ base_thread -> signals.signal_mask.signal_set = changed_mask; } - + /* Suspend on the signal specified by the input. */ status = tx_event_flags_get(&(base_thread -> signals.signal_event_flags), (ULONG) set -> signal_set, TX_OR_CLEAR, &signal_bit_map, TX_WAIT_FOREVER); /* Determine if we need to restore the signal mask. */ if ((saved_mask) && (changed_mask == base_thread -> signals.signal_mask.signal_set)) { - + /* Yes, the signal mask should be restored. */ base_thread -> signals.signal_mask.signal_set = saved_mask; } @@ -174,19 +169,19 @@ POSIX_TCB *base_thread; /* Check for successful status. */ if (status == TX_SUCCESS) { - + /* Derived the signal number from the bit map. */ TX_LOWEST_SET_BIT_CALCULATE(signal_bit_map, signal_number); - + /* Return the signal number. */ *sig = (int) signal_number; - + /* Return success! */ return(OK); } else { - + /* Return error! */ return(EINVAL); } diff --git a/utility/rtos_compatibility_layers/posix/px_sleep.c b/utility/rtos_compatibility_layers/posix/px_sleep.c index 1ed878f4..87eda03e 100644 --- a/utility/rtos_compatibility_layers/posix/px_sleep.c +++ b/utility/rtos_compatibility_layers/posix/px_sleep.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -26,49 +27,43 @@ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* sleep PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* sleep PORTABLE C */ /* 6.1.7 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ +/* DESCRIPTION */ /* */ /* This function shall cause the calling thread to be suspended from */ /* execution until either the number of realtime seconds specified by */ -/* the argument seconds has elapsed */ +/* the argument seconds has elapsed */ /* */ -/* INPUT */ +/* INPUT */ /* */ /* seconds Is the number of real-time (as opposed */ /* to CPU-time) seconds to suspend the */ /* calling thread. */ /* */ -/* OUTPUT */ -/* */ +/* OUTPUT */ +/* */ /* number of seconds remaining to sleep */ /* A nonzero value indicates sleep was */ /* interrupted. Zero is successful */ /* completion */ /* */ /* */ -/* CALLS */ +/* CALLS */ /* */ /* tx_thread_sleep ThreadX thread sleep service */ -/* */ -/* CALLED BY */ -/* */ -/* Application Code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ +/* CALLED BY */ +/* */ +/* Application Code */ /* */ /**************************************************************************/ UINT sleep(ULONG seconds) @@ -90,7 +85,7 @@ UINT temp1, temp2, diff, result; result = ((seconds * CPU_TICKS_PER_SECOND) - diff); } - return (result/CPU_TICKS_PER_SECOND); - + return (result/CPU_TICKS_PER_SECOND); + } diff --git a/utility/rtos_compatibility_layers/posix/px_system_manager.c b/utility/rtos_compatibility_layers/posix/px_system_manager.c index ef24202b..92b71414 100644 --- a/utility/rtos_compatibility_layers/posix/px_system_manager.c +++ b/utility/rtos_compatibility_layers/posix/px_system_manager.c @@ -1,18 +1,19 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ /**************************************************************************/ /**************************************************************************/ -/** */ -/** POSIX wrapper for THREADX */ +/** */ +/** POSIX wrapper for THREADX */ /** */ /** */ /** */ @@ -25,46 +26,38 @@ #include "pthread.h" /* Posix API */ #include "px_int.h" /* Posix helper functions */ -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* posix_system_manager_entry PORTABLE C */ +/**************************************************************************/ +/* */ +/* FUNCTION RELEASE */ +/* */ +/* posix_system_manager_entry PORTABLE C */ /* 6.2.0 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ -/* DESCRIPTION */ -/* */ +/* DESCRIPTION */ +/* */ /* This is the System Manager thread for the POSIX> The system */ /* manager thread cleans up terminated threads and releases */ /* the stack memory associated with the thread */ -/* */ -/* INPUT */ -/* */ -/* input Not used */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ /* */ -/* tx_queue_receive Receive system request */ +/* INPUT */ +/* */ +/* input Not used */ +/* */ +/* OUTPUT */ +/* */ +/* None */ +/* */ +/* CALLS */ +/* */ +/* tx_queue_receive Receive system request */ /* posix_do_pthread_delete Delete a pthread */ /* */ -/* CALLED BY */ -/* */ -/* Start-up code */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ +/* CALLED BY */ /* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Add 64-bit support, */ -/* resulting in version 6.2.0 */ +/* Start-up code */ /* */ /**************************************************************************/ VOID posix_system_manager_entry(ULONG input) @@ -79,18 +72,18 @@ VOID *value_ptr; /* Avoid compiler warning. */ TX_PARAMETER_NOT_USED(input); - /* Loop forever, waiting for work requests. */ + /* Loop forever, waiting for work requests. */ while(1) { /* Wait forever for the next work request. */ status = tx_queue_receive(&posix_work_queue, &request, TX_WAIT_FOREVER); - /* Make sure we didn't encounter any trouble. */ + /* Make sure we didn't encounter any trouble. */ if (status != TX_SUCCESS) { /* Get the next message. */ continue; } - + #ifdef TX_64_BIT pthread_ptr = (POSIX_TCB *)((((ALIGN_TYPE)request[0]) << 32) | request[1]); value_ptr = (VOID *)((((ALIGN_TYPE)request[2]) << 32) | request[3]); @@ -101,7 +94,7 @@ VOID *value_ptr; /* Delete the pthread */ posix_do_pthread_delete(pthread_ptr, value_ptr); - + } /* System Manager forever loop */ } diff --git a/utility/rtos_compatibility_layers/posix/readme_release_history.txt b/utility/rtos_compatibility_layers/posix/readme_release_history.txt index 2eb4eaa0..fe6ea047 100644 --- a/utility/rtos_compatibility_layers/posix/readme_release_history.txt +++ b/utility/rtos_compatibility_layers/posix/readme_release_history.txt @@ -1,4 +1,4 @@ - + px_abs_time_to_rel_ticks.c Casted size_t to ULONG. px_clock_gettime.c Casted size_t to ULONG. @@ -12,18 +12,18 @@ tx_posix.h Reduced default object pool sizes, added posix_initialize prototype. Improved default stack size symbol name - px_memory_release.c When thread completes and posix_do_pthread_delete() is called, - posix_memory_release() returns with error if stack was not + px_memory_release.c When thread completes and posix_do_pthread_delete() is called, + posix_memory_release() returns with error if stack was not allocated from the posix pool but rather stack is a static array. - px_mq_open.c Fixed bug to handle a NULL attribute in mq_open(). + px_mq_open.c Fixed bug to handle a NULL attribute in mq_open(). px_pth_create.c Call to pthread_create() with pthread_attr_t set to NULL or with the default values as set by pthread_attr_init() has unexpected behavior. Fixed by adding code to use defaults. - px_pth_init.c Fixed memory leak when threads are released or killed by - calling posix_reset_pthread after posix_destroy_pthread() + px_pth_init.c Fixed memory leak when threads are released or killed by + calling posix_reset_pthread after posix_destroy_pthread() which was not returning memory to the TCB pool Fixed bug when trying to join threads from ThreadX context when diff --git a/utility/rtos_compatibility_layers/posix/readme_threadx_posix.txt b/utility/rtos_compatibility_layers/posix/readme_threadx_posix.txt index 5aeb5d52..d9321396 100644 --- a/utility/rtos_compatibility_layers/posix/readme_threadx_posix.txt +++ b/utility/rtos_compatibility_layers/posix/readme_threadx_posix.txt @@ -12,17 +12,17 @@ ThreadX primitives and bypasses basic ThreadX error checking. 1.1 POSIX Compliancy Wrapper Source -The Wrapper source code is designed for simplicity and is comprised of separate source -files for most functions. Including the supplied pthread.h file will import +The Wrapper source code is designed for simplicity and is comprised of separate source +files for most functions. Including the supplied pthread.h file will import all the necessary POSIX constants and subroutine prototypes. 1.2 POSIX Compliancy Wrapper Documentation This document itself serves as a POSIX Compliancy Wrapper User Guide by -providing an overview of the porting process, including various caveats and -pitfalls to watch out for. In addition, each covered POSIX call is documented, -including information about supported/unsupported options, limitations, deviations, +providing an overview of the porting process, including various caveats and +pitfalls to watch out for. In addition, each covered POSIX call is documented, +including information about supported/unsupported options, limitations, deviations, and suggestions on how to work-around any limitations. @@ -31,32 +31,32 @@ and suggestions on how to work-around any limitations. The POSIX Compliancy Wrapper is easily installed by adding the the posix library to your current application build. Make sure your application build references the same header files as the ones the posix library has been built with. -The file pthread.h must be included in your application source where POSIX +The file pthread.h must be included in your application source where POSIX calls are required. Since the POSIX compliancy wrapper does not cover the complete standard, not all prototypes are provided. Most notably is the header file tx_px_time.h. 2.1 Initialization -The POSIX Compliancy Wrapper requires that a special initialization function is called +The POSIX Compliancy Wrapper requires that a special initialization function is called prior to accessing any POSIX calls. The function to call and its prototype is: VOID *posix_initialize(VOID * posix_memory); This function is usually called from the application specific ThreadX -initialization routine, tx_application_define(). The memory pointer supplied -to posix_initialize must be a contiguouis reserved section of memory +initialization routine, tx_application_define(). The memory pointer supplied +to posix_initialize must be a contiguouis reserved section of memory that has at least the following number of bytes: POSIX_SYSTEM_STACK_SIZE + TX_REGION0_SIZE_IN_BYTES + /* Region0 size */ (WORK_QUEUE_DEPTH * WORK_REQ_SIZE) + /* system queue size */ - POSIX_HEAP_SIZE_IN_BYTES + POSIX_HEAP_SIZE_IN_BYTES These equates are defined in tx_posix.h. The following additional equates -define the number of POSIX objects supported by the POSIX Wrapper (default +define the number of POSIX objects supported by the POSIX Wrapper (default value is shown): SEM_NSEMS_MAX 100 /* simultaneous POSIX semaphores */ @@ -77,7 +77,7 @@ value is shown): POSIX mutexes sported. */ -The function posix_initialize will return a pointer to the next free +The function posix_initialize will return a pointer to the next free available memory location for the application. @@ -119,7 +119,7 @@ INT sem_destroy(sem_t *sem); /***********************************************************************/ INT sched_yield(VOID); -INT pthread_create (pthread_t *thread, +INT pthread_create (pthread_t *thread, pthread_attr_t *attr, VOID *(*start_routine)(VOID*),VOID *arg); INT pthread_detach(pthread_t thread); @@ -220,35 +220,35 @@ throughout the Wrapper, as follows: posix_error_handler posix_internal_error -In general these routines are called when basic usage errors occur. These -routines may also be used as a place to catch errors that are not detected if the -application source is not checking the return status. The default processing for each of +In general these routines are called when basic usage errors occur. These +routines may also be used as a place to catch errors that are not detected if the +application source is not checking the return status. The default processing for each of these is a simple spin loop. Most functions can provide an error number. The means by which each function -provides its error numbers is specified in its description. Some functions -provide the error number in a variable accessed through the symbol posix_errno. -While other functions return an error number directly as the function value. Functions -return a value of zero to indicate success. If more than one error occurs in -processing a function call, any one of the possible errors may be returned, as the order +provides its error numbers is specified in its description. Some functions +provide the error number in a variable accessed through the symbol posix_errno. +While other functions return an error number directly as the function value. Functions +return a value of zero to indicate success. If more than one error occurs in +processing a function call, any one of the possible errors may be returned, as the order of detection is undefined. Some functions may return [ENOSYS] suggesting that an attempt was made to use a function that is not available in this implementation. -Each pthread has its own error number, which can be obtained through a +Each pthread has its own error number, which can be obtained through a function call: INT posix_get_pthread_errno(pthread_t ptid) -This call will return the last generated error code for the pthread having +This call will return the last generated error code for the pthread having ptid as an ID. 5.1 POSIX Compliancy Wrapper Limitations Due to performance and architecture issues, this POSIX Compliancy Wrapper -does not support all the POSIX calls. A summary of the POSIX Compliancy +does not support all the POSIX calls. A summary of the POSIX Compliancy Wrapper limitations is as follows: � Configuration @@ -288,8 +288,8 @@ Following calls are implemented with some limitations: space becomes available in that queue, the message with the highest priority will be unblocked. THIS FEATURE IS NOT IMPLEMENTED. - b.) If a message is sent (or received) to a queue with out opening the named - queue, in such a case mqdes (message queue descriptor) pointer is + b.) If a message is sent (or received) to a queue with out opening the named + queue, in such a case mqdes (message queue descriptor) pointer is invalid and may result in erratic behavior. 3.) mq_receive() @@ -323,11 +323,11 @@ Following calls are implemented with some limitations: 7.) Thread Cancelation pthread cancelation cleanup handlers are not supported which means -pthread_cleanup_push( ) and pthread_cleanup_pop( ) functions are not +pthread_cleanup_push( ) and pthread_cleanup_pop( ) functions are not implemented. When the pthread_cancel( ) function is called the target thread is canceled -with immediate effect. (provided cancelability is enabled for the target +with immediate effect. (provided cancelability is enabled for the target pthread) The cancelation processing in the target thread shall run asynchronously @@ -337,7 +337,7 @@ with respect to the ailing thread returning from pthread_cancel( ). No attributes are supported for condition variable in this implementation. 9.) pthreads suspended by nanosleep() and sleep() calls can not be awakened -by signals, once in the suspension both these calls will complete the +by signals, once in the suspension both these calls will complete the suspension period. 10.) pthread_once (pthread_once_t * once_control, VOID (*init_routine) (VOID)) @@ -347,8 +347,8 @@ There is no provision if the init_routine contains a cancellation point. 6.0 Demonstration System The file posix_demo.c contains a demonstration system that utilizes POSIX -calls. This Demo application will demonstrate some of the basic POSIX -calls. This demo application should be used as an example of how to integrate the POSIX +calls. This Demo application will demonstrate some of the basic POSIX +calls. This demo application should be used as an example of how to integrate the POSIX Compliancy Wrapper into your application. diff --git a/utility/rtos_compatibility_layers/posix/sched.h b/utility/rtos_compatibility_layers/posix/sched.h index 3a150170..2f37b05c 100644 --- a/utility/rtos_compatibility_layers/posix/sched.h +++ b/utility/rtos_compatibility_layers/posix/sched.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -33,20 +34,13 @@ /* This file defines the constants, structures, etc.needed to */ /* implement the Evacuation Kit for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ #ifndef _SCHED_H #define _SCHED_H -struct sched_param +struct sched_param { INT sched_priority; }; diff --git a/utility/rtos_compatibility_layers/posix/signal.h b/utility/rtos_compatibility_layers/posix/signal.h index 72722c67..0da4adea 100644 --- a/utility/rtos_compatibility_layers/posix/signal.h +++ b/utility/rtos_compatibility_layers/posix/signal.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -33,23 +34,13 @@ /* This file defines the constants, structures, etc.needed to */ /* implement signals functionality for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Update pthread_kill argument */ -/* type, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ #ifndef _SIGNAL_H #define _SIGNAL_H -/* The POSIX wrapper for ThreadX supports a maximum of 32 signals, from 0 +/* The POSIX wrapper for ThreadX supports a maximum of 32 signals, from 0 through 31, inclusive. In this implemenation, signals are NOT queued. */ @@ -87,15 +78,15 @@ typedef struct signal_info_struct UINT signal_handler; /* This is a flag. If TRUE, this thread is being used as a signal handler. If FALSE, it is a regular thread. */ UINT signal_nesting_depth; /* A positive value indicates the level of nested signal handling the POSIX thread is currently processing. */ - sigset_t signal_pending; /* Bit map of signals pending. */ - sigset_t signal_mask; /* Signal mask, bit blocks the signal until cleared. */ + sigset_t signal_pending; /* Bit map of signals pending. */ + sigset_t signal_mask; /* Signal mask, bit blocks the signal until cleared. */ UINT saved_thread_state; /* Saved ThreadX state of the POSIX thread, at the time of the first signal. */ - struct pthread_control_block *base_thread_ptr; /* Pointer to the thread associated with the signal. */ - struct pthread_control_block *top_signal_thread; /* Pointer to the top (most recent) signal thread. */ - struct pthread_control_block *next_signal_thread; /* Pointer to the next most recent signal thread. */ - void (*signal_func[MAX_SIGNALS])(int); /* Array of signal handlers for this thread. */ - TX_EVENT_FLAGS_GROUP signal_event_flags; /* ThreadX event flag group used for sigwait */ - + struct pthread_control_block *base_thread_ptr; /* Pointer to the thread associated with the signal. */ + struct pthread_control_block *top_signal_thread; /* Pointer to the top (most recent) signal thread. */ + struct pthread_control_block *next_signal_thread; /* Pointer to the next most recent signal thread. */ + void (*signal_func[MAX_SIGNALS])(int); /* Array of signal handlers for this thread. */ + TX_EVENT_FLAGS_GROUP signal_event_flags; /* ThreadX event flag group used for sigwait */ + } signal_info; diff --git a/utility/rtos_compatibility_layers/posix/time.h b/utility/rtos_compatibility_layers/posix/time.h index 51f30be9..9fabdec5 100644 --- a/utility/rtos_compatibility_layers/posix/time.h +++ b/utility/rtos_compatibility_layers/posix/time.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -34,13 +35,6 @@ /* implement time related functionality for the Evacuation Kit */ /* for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ #ifndef _TX_PX_TIME_H @@ -53,7 +47,7 @@ typedef ULONG time_t; typedef INT clockid_t; -struct timespec +struct timespec { time_t tv_sec; /* time in terms of seconds */ ULONG tv_nsec; /* remaining time in terms of nano seconds*/ @@ -62,7 +56,7 @@ struct timespec struct itimerspec { struct timespec it_interval ; /* Timer period. */ - struct timespec it_value; /* Timer expiration. */ + struct timespec it_value; /* Timer expiration. */ }; #define CLOCK_REALTIME 1 diff --git a/utility/rtos_compatibility_layers/posix/tx_posix.h b/utility/rtos_compatibility_layers/posix/tx_posix.h index 88986402..ce533dd8 100644 --- a/utility/rtos_compatibility_layers/posix/tx_posix.h +++ b/utility/rtos_compatibility_layers/posix/tx_posix.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -33,16 +34,6 @@ /* This file defines the constants, structures, etc.needed to */ /* implement the Evacuation Kit for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* 10-31-2022 Scott Larson Update WORK_REQ_SIZE value, */ -/* update pthread_t typedef, */ -/* resulting in version 6.2.0 */ -/* */ /**************************************************************************/ #ifndef TX_POSIX @@ -84,15 +75,15 @@ #endif */ -/* Define the system configuration constants for the Evacuation Kit for - POSIX Users.This is where the number of system objects +/* Define the system configuration constants for the Evacuation Kit for + POSIX Users.This is where the number of system objects (pthreads, message queues, semaphores etc.)are defined. */ /************************************************************************/ /* SYSTEM CONFIGURATION PARAMETERS */ /************************************************************************/ -/* Define the maximum number of simultaneous POSIX semaphores +/* Define the maximum number of simultaneous POSIX semaphores supported. */ #define SEM_NSEMS_MAX 16 @@ -103,14 +94,14 @@ #define SEM_VALUE_MAX 100 /* Define the maximum number of simultaneous POSIX message queues supported. */ - + #define POSIX_MAX_QUEUES 16 /* Define the maximum number of simultaneous POSIX pthreads supported. */ #define PTHREAD_THREADS_MAX 16 /* Define the maximum number of simultaneous POSIX mutexes supported. */ - + #define POSIX_MAX_MUTEX 16 /* Define the maximum length of name of message queue. */ @@ -131,8 +122,8 @@ /* Define number of CPU ticks per second */ -#define CPU_TICKS_PER_SECOND 100 /* assuming 10 mSec tick */ -#define NANOSECONDS_IN_CPU_TICK 10000000 /* assuming 10 mSec tick */ +#define CPU_TICKS_PER_SECOND 100 /* assuming 10 mSec tick */ +#define NANOSECONDS_IN_CPU_TICK 10000000 /* assuming 10 mSec tick */ /* Define queue control specific data definitions. */ @@ -146,7 +137,7 @@ /************************************************************************/ #define POSIX_STACK_PADDING 1024 #define POSIX_SYSTEM_STACK_SIZE 1024 -#define POSIX_PTHREAD_STACK_SIZE 1024 +#define POSIX_PTHREAD_STACK_SIZE 1024 /************************************************************************/ /* ARCHITECTURE DEFINITIONS */ @@ -172,9 +163,9 @@ #define MIN_STACKSIZE_POWERPC 2048 -/************************************************************************/ -/* MISCELLANEOUS CONSTANTS */ -/************************************************************************/ +/************************************************************************/ +/* MISCELLANEOUS CONSTANTS */ +/************************************************************************/ /* Requests/commands to SysMgr task. */ #define SYSMGR_DELETE_TASK 0 @@ -183,7 +174,7 @@ #define PTHREAD_NAME_LEN 4 #define PTHREAD_CREATE_DETACHED 1 -#define PTHREAD_CREATE_JOINABLE 0 +#define PTHREAD_CREATE_JOINABLE 0 /* scheduler related constants */ @@ -224,9 +215,9 @@ enum pth_once_state { PTH_ONCE_CANCELLED = 0x3 }; -/************************************************************************/ -/* ERROR CODES (those defined outside of POSIX) */ -/************************************************************************/ +/************************************************************************/ +/* ERROR CODES (those defined outside of POSIX) */ +/************************************************************************/ #ifdef ERROR #undef ERROR @@ -277,14 +268,14 @@ typedef ULONG BOOL; typedef struct pthread_attr_obj { ULONG pthread_flags; - INT detach_state; + INT detach_state; INT inherit_sched; INT sched_policy; struct sched_param sched_attr; VOID *stack_address; ULONG stack_size; INT inuse; -} pthread_attr_t; +} pthread_attr_t; typedef INT ssize_t ; /* this should be pulled in from sys\types.h */ @@ -297,24 +288,24 @@ typedef ULONG mode_t; typedef struct pthread_control_block { - /* This pthread's ThreadX TCB. */ + /* This pthread's ThreadX TCB. */ TX_THREAD thread_info; /* This pthread's unique identifier */ pthread_t pthreadID; /* To check if posix Pthread is in use. */ UINT in_use; /* All pthread attributes contained in the a pthread_attr_t object */ - ULONG pthread_flags; - INT detach_state; + ULONG pthread_flags; + INT detach_state; INT inherit_sched; INT sched_policy; struct sched_param sched_attr; VOID *stack_address; ULONG stack_size; INT cancel_state; - INT cancel_type; + INT cancel_type; /* Identifier of the target thread to which this pthread is joined */ - pthread_t joined_to_pthreadID; + pthread_t joined_to_pthreadID; /* Identifier of the caller thread which has joined to this thread*/ pthread_t joined_by_pthreadID; /* To check if posix pthread is joined to any other pthread */ @@ -325,16 +316,16 @@ typedef struct pthread_control_block UINT is_detached; /* Value returned by the terminating thread which is joined to this thread */ VOID *value_ptr; - /* Define the original pthread priority. */ + /* Define the original pthread priority. */ ULONG orig_priority; - /* Define the current pthread priority. */ + /* Define the current pthread priority. */ ULONG current_priority; - /* Define the pthread's pre-emption threshold. */ + /* Define the pthread's pre-emption threshold. */ ULONG threshold; - /* Define the pthread's timeslice. */ + /* Define the pthread's timeslice. */ ULONG time_slice; /* specify pthread start routine */ - VOID *(*start_routine)(VOID *); + VOID *(*start_routine)(VOID *); /* specify argument for start up routine */ ULONG *entry_parameter; /* to hold error code for this pthread */ @@ -353,15 +344,15 @@ typedef struct pthread_mutex_attr_obj INT protocol; INT pshared; INT in_use; - + } pthread_mutexattr_t; /* Define POSIX mutex structure. */ typedef struct pthread_mutex_control_block { - /* This mutex's ThreadX Control block */ - TX_MUTEX mutex_info; + /* This mutex's ThreadX Control block */ + TX_MUTEX mutex_info; /* This mutex's attributes */ INT type; /* Is this Mutex object is in use? */ @@ -381,7 +372,7 @@ struct mq_attr ULONG mq_msgsize; /* Flags are ignored as these are passed separately in open(). */ ULONG mq_flags; -}; +}; /* Define POSIX message queue structure. */ typedef struct msg_que @@ -410,17 +401,17 @@ typedef struct msg_que /* Define Queue Descriptor. */ typedef struct mq_des { - /* Queue FLAGS. */ + /* Queue FLAGS. */ ULONG f_flag; /* message Queue structure. */ POSIX_MSG_QUEUE * f_data; - + } *mqd_t; /* STRUCTURES RELATED TO POSIX SEMAPHORES */ -typedef struct POSIX_SEMAPHORE_STRUCT +typedef struct POSIX_SEMAPHORE_STRUCT { /* ThreadX semaphore. */ TX_SEMAPHORE sem; @@ -439,23 +430,23 @@ typedef struct POSIX_SEMAPHORE_STRUCT } sem_t; -typedef sem_t *SEM_ID; +typedef sem_t *SEM_ID; typedef struct pthread_cond_obj { - /* This pthread condition variable's internal counting Semaphore */ + /* This pthread condition variable's internal counting Semaphore */ TX_SEMAPHORE cond_semaphore; - + INT type; INT in_use; - + } pthread_cond_t; typedef struct pthread_condattr_obj { /* INT type; */ INT in_use; - + } pthread_condattr_t; @@ -478,10 +469,10 @@ extern unsigned int posix_errno; VOID *posix_initialize(VOID * posix_memory); -/* Define POSIX API function prototypes. */ +/* Define POSIX API function prototypes. */ INT mq_send(mqd_t mqdes, const char * msg_ptr, - size_t msg_len,ULONG msg_prio ); + size_t msg_len,ULONG msg_prio ); ssize_t mq_receive(mqd_t mqdes, VOID *pMsg, size_t msgLen, ULONG *pMsgPrio ); INT mq_unlink(const char * mqName); @@ -497,7 +488,7 @@ INT sem_wait( sem_t * sem ); INT sem_init(sem_t *sem , INT pshared, UINT value); INT sem_destroy(sem_t *sem); -INT pthread_create (pthread_t *thread, pthread_attr_t *attr, +INT pthread_create (pthread_t *thread, pthread_attr_t *attr, VOID *(*start_routine)(VOID*),VOID *arg); INT pthread_detach(pthread_t thread); INT pthread_join(pthread_t thread, VOID **value_ptr); diff --git a/utility/rtos_compatibility_layers/posix/tx_px_time.h b/utility/rtos_compatibility_layers/posix/tx_px_time.h index fcd80338..cf0476f0 100644 --- a/utility/rtos_compatibility_layers/posix/tx_px_time.h +++ b/utility/rtos_compatibility_layers/posix/tx_px_time.h @@ -1,10 +1,11 @@ /*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * + * Copyright (c) 2024 Microsoft Corporation + * Copyright (c) 2026-present Eclipse ThreadX contributors + * * This program and the accompanying materials are made available under the * terms of the MIT License which is available at * https://opensource.org/licenses/MIT. - * + * * SPDX-License-Identifier: MIT **************************************************************************/ @@ -34,13 +35,6 @@ /* implement time related functionality for the Evacuation Kit */ /* for POSIX Users (POSIX) */ /* */ -/* */ -/* RELEASE HISTORY */ -/* */ -/* DATE NAME DESCRIPTION */ -/* */ -/* 06-02-2021 William E. Lamie Initial Version 6.1.7 */ -/* */ /**************************************************************************/ #ifndef _TX_PX_TIME_H @@ -52,7 +46,7 @@ typedef ULONG time_t; #endif -struct timespec +struct timespec { ULONG timeout_value; /* time in terms of CPU ticks */ time_t tv_sec; /* time in terms of Seconds */ |
