Skip to content

Byte reading macros #4274

Closed
Closed
@ronald-cron-arm

Description

@ronald-cron-arm

Description

  • Type: Enhancement
  • Priority: Minor

Enhancement

Justification - why does the library need this feature?
To improve readability by saving horizontal and vertical space, see discussions in 3441.

Suggested enhancement
Define in a header file in library/ (common.h is a possibility) the following macros to read a byte from a larger integer type.

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

Define also once for all in the same header file the #define PUT_UINT32_LE(n,b,i) macro.

Then use the BYTE_x macros to replace the corresponding sequences in the library code (including the ones using (unsigned int) instead to (uint8_t) to cast).

The changes need to be back-ported to 2.16 but the macro definition cannot be put in a single common header and have to be redefined in each C header or file making use of them.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions