layer2_helper.c
void _encode_64(uint64_t* data, uint8_t buf[])
{
	buf[0] = (uint8_t)((*data & 0xff00000000000000ULL) >> 56);
	buf[1] = (uint8_t)((*data & 0x00ff000000000000ULL) >> 48);
	buf[2] = (uint8_t)((*data & 0x0000ff0000000000ULL) >> 40);
	buf[3] = (uint8_t)((*data & 0x000000ff00000000ULL) >> 32);
	buf[4] = (uint8_t)((*data & 0x00000000ff000000ULL) >> 24);
	buf[5] = (uint8_t)((*data & 0x0000000000ff0000ULL) >> 16);
	buf[6] = (uint8_t)((*data & 0x000000000000ff00ULL) >> 8);
	buf[7] = (uint8_t)((*data & 0x00000000000000ffULL));
}
/* Worker functions to write words into a buffer in big endian format 
 * using generic C
 * 
 * A good C compiler will spot what is going on and use byte manipulation
 * instructions to get the right effect (functions declared static
 * to hint to compiler that code can be inlined)
 */
Worker functions to write words into a buffer in big endian format
using generic C

A good C compiler will spot what is going on and use byte manipulation
instructions to get the right effect (functions declared static
to hint to compiler that code can be inlined)
Worker functions to write words into a buffer in big endian format using generic C A good C compiler will spot what is going on and use byte manipulation instructions to get the right effect ( functions declared static to hint to compiler that code can be inlined )
void _encode_64(uint64_t* data, uint8_t buf[])
{
	buf[0] = (uint8_t)((*data & 0xff00000000000000ULL) >> 56);
	buf[1] = (uint8_t)((*data & 0x00ff000000000000ULL) >> 48);
	buf[2] = (uint8_t)((*data & 0x0000ff0000000000ULL) >> 40);
	buf[3] = (uint8_t)((*data & 0x000000ff00000000ULL) >> 32);
	buf[4] = (uint8_t)((*data & 0x00000000ff000000ULL) >> 24);
	buf[5] = (uint8_t)((*data & 0x0000000000ff0000ULL) >> 16);
	buf[6] = (uint8_t)((*data & 0x000000000000ff00ULL) >> 8);
	buf[7] = (uint8_t)((*data & 0x00000000000000ffULL));
}
void _encode_64 ( uint64_t * data , uint8_t buf [ ] ) { buf [ 0 ] = ( uint8_t ) ( ( * data & 0xff00000000000000ULL ) >> 56 ) ; buf [ 1 ] = ( uint8_t ) ( ( * data & 0x00ff000000000000ULL ) >> 48 ) ; buf [ 2 ] = ( uint8_t ) ( ( * data & 0x0000ff0000000000ULL ) >> 40 ) ; buf [ 3 ] = ( uint8_t ) ( ( * data & 0x000000ff00000000ULL ) >> 32 ) ; buf [ 4 ] = ( uint8_t ) ( ( * data & 0x00000000ff000000ULL ) >> 24 ) ; buf [ 5 ] = ( uint8_t ) ( ( * data & 0x0000000000ff0000ULL ) >> 16 ) ; buf [ 6 ] = ( uint8_t ) ( ( * data & 0x000000000000ff00ULL ) >> 8 ) ; buf [ 7 ] = ( uint8_t ) ( ( * data & 0x00000000000000ffULL ) ) ; }
Worker functions to write words into a buffer in big endian format
 using generic C
Worker functions to write words into a buffer in big endian format using generic C