ARM common standard c library inlines and wrapper macros.
More...
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
|
| #define | malloc_assert(x) |
| | malloc x object and assert it
|
| |
| #define | strclr_full(s) |
| | Clear string s (full content)
|
| |
| #define | printExpr(e) |
| | Print expression e and it's result e using printf.
|
| |
| #define | sprintExpr(s, e) |
| | Print expression e and it's result e to s string.
|
| |
| #define | snprintExpr(s, n, e) |
| | Print expression e and it's result e with max n characters to s string.
|
| |
| #define | verbInstr(i) |
| | Print instruction i using printf and execute it.
|
| |
| #define | sverbInstr(s, i) |
| | Print instruction i to s string and execute it.
|
| |
| #define | snverbInstr(s, n, i) |
| | Print instruction i to s string with max n characters and execute it.
|
| |
| #define | verbInc(x) |
| | Increment example on x using puts.
|
| |
| #define | verbDec(x) |
| | Decrement example on x using puts.
|
| |
ARM common standard c library inlines and wrapper macros.
- Author
- SMFSW
- Copyright
- MIT (c) 2017-2026, SMFSW
- MISRA C:2012 Deviations
Header scope deviation has been granted for following rules:
Rule-18.4 - Advisory: +/- operators on pointer type (misra-c2012-18.4)
Header scope legitimate use derogation authorized for:
Rule-21.6 - Required: Use of <stdio.h> (misra-c2012-21.6)
Justification: Some of the following functions are sprintf like oriented extensions to standard library.
Rule-17.1 - Required: Use of <starg.h> (misra-c2012-17.1)
Justification: Legitimate use of variadic parameters received, passed to printf like function call.
Rule-20.7 - Required: Enclosed macro parameters expansion (misra-c2012-20.7)
Justification: Use of STR catenate macro in macros expansion.
◆ malloc_assert
| #define malloc_assert |
( |
| x | ) |
|
Value:((x) = malloc(sizeof(*(x))), assert((x)))
malloc x object and assert it
◆ printExpr
Value:(printf(
"%s = %d\r\n",
STR(e), (e)))
#define STR(s)
Stringify s expression.
Definition arm_preprocess.h:48
Print expression e and it's result e using printf.
◆ snprintExpr
| #define snprintExpr |
( |
| s, |
|
|
| n, |
|
|
| e ) |
Value:(snprintf((s), (n),
"%s = %d\r\n",
STR(e), (e)))
Print expression e and it's result e with max n characters to s string.
◆ snverbInstr
| #define snverbInstr |
( |
| s, |
|
|
| n, |
|
|
| i ) |
Value:(snprintf((s), (n),
STR(i)), (i))
Print instruction i to s string with max n characters and execute it.
◆ sprintExpr
| #define sprintExpr |
( |
| s, |
|
|
| e ) |
Value:(sprintf((s),
"%s = %d\r\n",
STR(e), (e)))
Print expression e and it's result e to s string.
◆ strclr_full
Value:
#define charNull
Null Char.
Definition arm_macros.h:26
Clear string s (full content)
- Warning
- Only works with char arrays, do not use on pointer to char array
◆ sverbInstr
| #define sverbInstr |
( |
| s, |
|
|
| i ) |
Value:(sprintf((s),
STR(i)), (i))
Print instruction i to s string and execute it.
◆ verbDec
Value:(puts(
"Decrementing " STR(x)), (x)--)
Decrement example on x using puts.
◆ verbInc
Value:(puts(
"Incrementing " STR(x)), (x)++)
Increment example on x using puts.
◆ verbInstr
Value:
Print instruction i using printf and execute it.
◆ get_current_heap_address()
| const void * get_current_heap_address |
( |
void | | ) |
|
|
inline |
Get current heap address pointer.
- Note
- Can be useful to get heap value when testing for potential memory leaks
- MISRA C:2012 Deviations
- Local legitimate use derogation authorized for:
Rule-11.6 - Required: pointer to void cast to arithmetic (misra-c2012-11.6)
Justification: Intended to identify potential memory leaks in case of dynamic allocation use.
- Warning
- Shall not cast returned value to
void* (allowing to write anything to the pointed content)
- Returns
- Pointer to current heap address
◆ get_current_heap_address_int()
| uintPTR_t get_current_heap_address_int |
( |
void | | ) |
|
|
inline |
Get current heap address.
- Note
- Address is returned as integer (returning released pointer value would cause a warning from compiler) Use get_current_heap_address to get current heap address under the form of
void* pointer
- MISRA C:2012 Deviations
- Local legitimate use derogation authorized for:
Rule-11.6 - Required: pointer to void cast to arithmetic (misra-c2012-11.6)
Rule-21.3 - Required: dynamic allocation (misra-c2012-21.3)
Justification: Intended to identify potential memory leaks in case of dynamic allocation use.
- Returns
- Integer value of current heap address
◆ str_add_cr()
Append carriage return char at the end of string (char array)
- Note
- As of C library, use strn_add_cr to ensure resulting
s string won't exceed given length
- Parameters
-
| [in,out] | s | - Pointer to char array |
- Returns
- Pointer to resulting string (char array)
◆ str_add_crlf()
Append carriage return and line feed chars at the end of string (char array)
- Note
- As of C library, use strn_add_crlf to ensure resulting
s string won't exceed given length
- Parameters
-
| [in,out] | s | - Pointer to char array |
- Returns
- Pointer to resulting string (char array)
◆ str_add_lf()
Append line feed char at the end of string (char array)
- Note
- As of C library, use strn_add_lf to ensure resulting
s string won't exceed given length
- Parameters
-
| [in,out] | s | - Pointer to char array |
- Returns
- Pointer to resulting string (char array)
◆ str_add_tab()
Append tab char at the end of string (char array)
- Note
- As of C library, use strn_add_tab to ensure resulting
s string won't exceed given length
- Parameters
-
| [in,out] | s | - Pointer to char array |
- Returns
- Pointer to resulting string (char array)
◆ strclr()
| void strclr |
( |
CHAR *const | s | ) |
|
|
inline |
Fast clear string (char array)
- Parameters
-
| [in,out] | s | - pointer to char array |
◆ strn_add_cr()
Append carriage return char at the end of sized string (char array)
- Parameters
-
| [in,out] | s | - Pointer to char array |
| [in] | len | - Length of char array s |
- Returns
- Pointer to resulting string (char array)
◆ strn_add_crlf()
Append carriage return and line feed chars at the end of sized string (char array)
- Parameters
-
| [in,out] | s | - Pointer to char array |
| [in] | len | - Length of char array s |
- Returns
- Pointer to resulting string (char array)
◆ strn_add_lf()
Append line feed char at the end of sized string (char array)
- Parameters
-
| [in,out] | s | - Pointer to char array |
| [in] | len | - Length of char array s |
- Returns
- Pointer to resulting string (char array)
◆ strn_add_tab()
Append tab char at the end of sized string (char array)
- Parameters
-
| [in,out] | s | - Pointer to char array |
| [in] | len | - Length of char array s |
- Returns
- Pointer to resulting string (char array)
◆ strncat_sz()
Append string at the end of sized string (char array)
- Note
- A little safer to use than
strncat to keep s un-corrupted
- Parameters
-
| [in,out] | s | - Pointer to char array |
| [in] | s2 | - Pointer to char array to catenate at the end of s |
| [in] | size | - Length of char array s |
- Returns
- Pointer to resulting string (char array)