1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Implement byte reading macros into library/

To improve readability by saving horizontal and vertical space.
Removed unecessary & 0xFF.
Byte reading macros implemented in library/common.h, All files
containing "& 0xff" were modified.
Comments/Documentation not yet added to the macro definitions.

Fixes #4274

Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
This commit is contained in:
Joe Subbiani
2021-06-22 15:51:53 +01:00
parent 3480e77a20
commit ba486b0084
7 changed files with 41 additions and 24 deletions

View File

@ -50,4 +50,21 @@
#define MBEDTLS_STATIC_TESTABLE static
#endif
/** Allow library to access its structs' private members.
*
* Although structs defined in header files are publicly available,
* their members are private and should not be accessed by the user.
*/
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
/** Byte Reading Macros
*
* To tidy up code and save horizontal and vertical space, use byte
* reading macros to cast
*/
#define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) )
#define BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff ) )
#define BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) )
#define BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) )
#endif /* MBEDTLS_LIBRARY_COMMON_H */