Compare commits
8 Commits
v6.4.3.202
...
coding-con
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
738d0a8228 | ||
|
|
4b6e8100d9 | ||
|
|
a9b31c3102 | ||
|
|
5c58767c5d | ||
|
|
d24ef8db37 | ||
|
|
44fadf7143 | ||
|
|
a9558def77 | ||
|
|
c09b444792 |
80
CODINGCONVENTIONS.md
Normal file
80
CODINGCONVENTIONS.md
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# Eclipse ThreadX Coding Conventions
|
||||||
|
_Version: 2026.01-DRAFT_
|
||||||
|
|
||||||
|
All ThreadX software conforms to a strict set of coding conventions.
|
||||||
|
|
||||||
|
## 1. C coding conventions
|
||||||
|
Versions of ThreadX 6.0 and greater follow the MISRA-C:2004 and MISRA C:2012 coding conventions.
|
||||||
|
|
||||||
|
### 1.1. ThreadX File Names
|
||||||
|
All ThreadX C file names take the form `tx_x.c` where `x` represents the component name (e.g., `tx_thread_create.c` contains the function `_tx_thread_create`). Component specification file names take the form `tx_x.h` (e.g., `tx_thread.h`). These naming conventions distinguish ThreadX files from all other application source files.
|
||||||
|
|
||||||
|
### 1.2. ThreadX Name Space
|
||||||
|
All ThreadX functions and global data have a leading `_tx` in their name. This keeps ThreadX global symbols separate from the application symbols and in one contiguous area of the load map created by the linker.
|
||||||
|
|
||||||
|
### 1.3. ThreadX Constant Names
|
||||||
|
All ThreadX constants have the form `TX_NAME` or `TX_C_NAME` and are comprised of capital letters, numerals, and underscores. System constants defined in `tx_api.h` or `tx_port.h` take the form `TX_NAME` (e.g., `TX_SUCCESS`). Component constants defined in component specification files take the form `TX_x_NAME` where `x` represents the capitalized entire component name (e.g., `TX_INITIALIZE_IN_PROGRESS`).
|
||||||
|
|
||||||
|
### 1.4. ThreadX Struct and Typedef Names
|
||||||
|
ThreadX C structure and typedef names are similar to component-specific constant names. System-wide typedefs have the form `TX_X_NAME`, where `x` is the capitalized component name (e.g., `TX_QUEUE`). Component-specific typedefs are contained in `tx_api.h`. Primitive data types like `UINT`, `ULONG`, and `VOID` do not require the leading `TX` modifier and are defined in `tx_port.h`.
|
||||||
|
|
||||||
|
#### 1.4.1 ThreadX Member Names
|
||||||
|
Structure member names are all lower case and take the form `tx_x_name` where `x` is the entire component name (e.g., `tx_thread_id` in the `TX_THREAD` structure).
|
||||||
|
|
||||||
|
### 1.5. ThreadX Global Data Names
|
||||||
|
Each component has a small amount of global C data elements. These elements are lower-case and have the form `_tx_x_name` (e.g., `_tx_thread_current_ptr`).
|
||||||
|
|
||||||
|
### 1.6. ThreadX Local Data Names
|
||||||
|
Readability is the primary requirement for local data elements defined inside ThreadX C functions. Frequently used elements are typically assigned the register modifier if supported by the target compiler.
|
||||||
|
|
||||||
|
### 1.7. ThreadX Function Names
|
||||||
|
All component function names have the form `_tx_x_name` in lower-case, where `x` represents the entire component name (e.g., `_tx_thread_create`).
|
||||||
|
|
||||||
|
### 1.8. Source Code Indentation
|
||||||
|
The standard indentation increment is four spaces. Tab characters are avoided to make the source code less sensitive to text editors.
|
||||||
|
|
||||||
|
### 1.9. Comments
|
||||||
|
Each C statement in the ThreadX source code generally has a meaningful comment. Each source file contains a standardised header as described below.
|
||||||
|
|
||||||
|
|
||||||
|
## 2. Assembly coding conventions
|
||||||
|
|
||||||
|
### 2.1. TBD
|
||||||
|
|
||||||
|
|
||||||
|
## 3.0. File headers
|
||||||
|
ThreadX file headers are made of two distinct sections.
|
||||||
|
|
||||||
|
The first section states the copyright owners of the code found in the file, and states the applicable license. The MIT license applies to the vast majority of the files making up ThreadX. It is mandatory to include the applicable SPDX license identifier.
|
||||||
|
|
||||||
|
The second section describes the ThreadX component the files belongs to.
|
||||||
|
|
||||||
|
Below is a sample file header.
|
||||||
|
|
||||||
|
```
|
||||||
|
/***************************************************************************
|
||||||
|
* Copyright (c) 2024 Microsoft Corporation
|
||||||
|
* Copyright (c) 2026 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
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************/
|
||||||
|
/**************************************************************************/
|
||||||
|
/** */
|
||||||
|
/** ThreadX Component */
|
||||||
|
/** */
|
||||||
|
/** Block Pool */
|
||||||
|
/** */
|
||||||
|
/**************************************************************************/
|
||||||
|
/**************************************************************************/
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -148,9 +148,9 @@ extern "C" {
|
|||||||
#define AZURE_RTOS_THREADX
|
#define AZURE_RTOS_THREADX
|
||||||
#define THREADX_MAJOR_VERSION 6
|
#define THREADX_MAJOR_VERSION 6
|
||||||
#define THREADX_MINOR_VERSION 4
|
#define THREADX_MINOR_VERSION 4
|
||||||
#define THREADX_PATCH_VERSION 3
|
#define THREADX_PATCH_VERSION 5
|
||||||
#define THREADX_BUILD_VERSION 202503
|
#define THREADX_BUILD_VERSION 202504
|
||||||
#define THREADX_HOTFIX_VERSION ''
|
#define THREADX_HOTFIX_VERSION ' '
|
||||||
|
|
||||||
/* Define the following symbol for backward compatibility */
|
/* Define the following symbol for backward compatibility */
|
||||||
#define EL_PRODUCT_THREADX
|
#define EL_PRODUCT_THREADX
|
||||||
|
|||||||
@@ -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
|
* This program and the accompanying materials are made available under the
|
||||||
* terms of the MIT License which is available at
|
* terms of the MIT License which is available at
|
||||||
* https://opensource.org/licenses/MIT.
|
* https://opensource.org/licenses/MIT.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
@@ -135,9 +135,10 @@ extern "C" {
|
|||||||
#ifndef TX_BYTE_POOL_MULTIPLE_BLOCK_SEARCH
|
#ifndef TX_BYTE_POOL_MULTIPLE_BLOCK_SEARCH
|
||||||
#define TX_BYTE_POOL_MULTIPLE_BLOCK_SEARCH 20
|
#define TX_BYTE_POOL_MULTIPLE_BLOCK_SEARCH 20
|
||||||
#endif
|
#endif
|
||||||
#ifndef TX_BTYE_POOL_DELAY_VALUE
|
|
||||||
|
#ifndef TX_BYTE_POOL_DELAY_VALUE
|
||||||
#define TX_BYTE_POOL_DELAY_VALUE 3
|
#define TX_BYTE_POOL_DELAY_VALUE 3
|
||||||
#endif
|
#endif /* TX_BYTE_POOL_DELAY_VALUE */
|
||||||
|
|
||||||
|
|
||||||
/* Define basic constants for the ThreadX kernel. */
|
/* Define basic constants for the ThreadX kernel. */
|
||||||
@@ -149,9 +150,9 @@ extern "C" {
|
|||||||
#define AZURE_RTOS_THREADX
|
#define AZURE_RTOS_THREADX
|
||||||
#define THREADX_MAJOR_VERSION 6
|
#define THREADX_MAJOR_VERSION 6
|
||||||
#define THREADX_MINOR_VERSION 4
|
#define THREADX_MINOR_VERSION 4
|
||||||
#define THREADX_PATCH_VERSION 3
|
#define THREADX_PATCH_VERSION 5
|
||||||
#define THREADX_BUILD_VERSION 202503
|
#define THREADX_BUILD_VERSION 202504
|
||||||
#define THREADX_HOTFIX_VERSION ''
|
#define THREADX_HOTFIX_VERSION ' '
|
||||||
|
|
||||||
|
|
||||||
/* Define the following symbol for backward compatibility */
|
/* Define the following symbol for backward compatibility */
|
||||||
@@ -659,7 +660,7 @@ typedef struct TX_THREAD_STRUCT
|
|||||||
ULONG tx_thread_suspension_sequence;
|
ULONG tx_thread_suspension_sequence;
|
||||||
|
|
||||||
#if defined(TX_ENABLE_RANDOM_NUMBER_STACK_FILLING) && defined(TX_ENABLE_STACK_CHECKING)
|
#if defined(TX_ENABLE_RANDOM_NUMBER_STACK_FILLING) && defined(TX_ENABLE_STACK_CHECKING)
|
||||||
|
|
||||||
/* Define the random stack fill number. This can be used to detect stack overflow. */
|
/* Define the random stack fill number. This can be used to detect stack overflow. */
|
||||||
ULONG tx_thread_stack_fill_value;
|
ULONG tx_thread_stack_fill_value;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7751,7 +7751,7 @@ UINT index;
|
|||||||
if (index >= OSEK_MAX_COUNTERS)
|
if (index >= OSEK_MAX_COUNTERS)
|
||||||
{
|
{
|
||||||
/* No more Counters available - user configuration error. */
|
/* No more Counters available - user configuration error. */
|
||||||
return ((CounterType) E_OS_SYS_STACK);
|
return ((CounterType) 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Found one. */
|
/* Found one. */
|
||||||
|
|||||||
Reference in New Issue
Block a user