sarmfsw: SMFSW Toolbox (desinged for ARM / compatible with other 8b/16b/32b platforms) 4.0rc
SMFSW collection of miscellaneous functions \& macros (desinged for ARM / compatible with other 8b/16b/32b platforms)
Loading...
Searching...
No Matches
arm_inlines_stdclib.h File Reference

ARM common standard c library inlines and wrapper macros. More...

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
Include dependency graph for arm_inlines_stdclib.h:
This graph shows which files directly or indirectly include this file:

Macros

#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.
 

Functions

uintPTR_t get_current_heap_address_int (void)
 Get current heap address.
 
const void * get_current_heap_address (void)
 Get current heap address pointer.
 
CHARstrncat_sz (CHAR *const __RESTRICT s, const CHAR *const __RESTRICT s2, const size_t size)
 Append string at the end of sized string (char array)
 
void strclr (CHAR *const s)
 Fast clear string (char array)
 
CHARstr_add_tab (CHAR *const __RESTRICT s)
 Append tab char at the end of string (char array)
 
CHARstr_add_cr (CHAR *const __RESTRICT s)
 Append carriage return char at the end of string (char array)
 
CHARstr_add_lf (CHAR *const __RESTRICT s)
 Append line feed char at the end of string (char array)
 
CHARstr_add_crlf (CHAR *const __RESTRICT s)
 Append carriage return and line feed chars at the end of string (char array)
 
CHARstrn_add_tab (CHAR *const __RESTRICT s, const size_t len)
 Append tab char at the end of sized string (char array)
 
CHARstrn_add_cr (CHAR *const __RESTRICT s, const size_t len)
 Append carriage return char at the end of sized string (char array)
 
CHARstrn_add_lf (CHAR *const __RESTRICT s, const size_t len)
 Append line feed char at the end of sized string (char array)
 
CHARstrn_add_crlf (CHAR *const __RESTRICT s, const size_t len)
 Append carriage return and line feed chars at the end of sized string (char array)
 

Detailed Description

ARM common standard c library inlines and wrapper macros.

Author
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.

Macro Definition Documentation

◆ malloc_assert

#define malloc_assert ( x)
Value:
((x) = malloc(sizeof(*(x))), assert((x)))

malloc x object and assert it

◆ printExpr

#define printExpr ( e)
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

#define strclr_full ( s)
Value:
(memset(s, charNull, sizeof(s)))
#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

#define verbDec ( x)
Value:
(puts("Decrementing " STR(x)), (x)--)

Decrement example on x using puts.

◆ verbInc

#define verbInc ( x)
Value:
(puts("Incrementing " STR(x)), (x)++)

Increment example on x using puts.

◆ verbInstr

#define verbInstr ( i)
Value:
(printf(STR(i)), (i))

Print instruction i using printf and execute it.

Function Documentation

◆ 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
Here is the call graph for this function:

◆ 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
Here is the caller graph for this function:

◆ str_add_cr()

CHAR * str_add_cr ( CHAR *const __RESTRICT s)
inline

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()

CHAR * str_add_crlf ( CHAR *const __RESTRICT s)
inline

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()

CHAR * str_add_lf ( CHAR *const __RESTRICT s)
inline

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()

CHAR * str_add_tab ( CHAR *const __RESTRICT s)
inline

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()

CHAR * strn_add_cr ( CHAR *const __RESTRICT s,
const size_t len )
inline

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)
Here is the call graph for this function:

◆ strn_add_crlf()

CHAR * strn_add_crlf ( CHAR *const __RESTRICT s,
const size_t len )
inline

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)
Here is the call graph for this function:

◆ strn_add_lf()

CHAR * strn_add_lf ( CHAR *const __RESTRICT s,
const size_t len )
inline

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)
Here is the call graph for this function:

◆ strn_add_tab()

CHAR * strn_add_tab ( CHAR *const __RESTRICT s,
const size_t len )
inline

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)
Here is the call graph for this function:

◆ strncat_sz()

CHAR * strncat_sz ( CHAR *const __RESTRICT s,
const CHAR *const __RESTRICT s2,
const size_t size )
inline

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)
Here is the caller graph for this function: