DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

udi_endian_swap(3udi)


Byte-swap multiple data items

SYNOPSIS

#include <udi.h>

void udi_endian_swap (

	const void *src,

	void *dst,

	udi_ubit8_t swap_size,

	udi_ubit8_t stride,

	udi_ubit16_t rep_count );
 

ARGUMENTS src points to a memory area across which byte swapping will be performed, as defined below.

dst points to a memory area into which the results of the byte-swap will be placed. This memory area must be at least the size of the memory area pointed to by src. src and dst may be the same, but if not, the memory areas must be non-overlapping.

swap_size is the size, in bytes, of each element to be byte-swapped. swap_size must be a power-of-two which is less than or equal to stride.

stride is the number of bytes by which to increment src between repetitions.

rep_count is the number of swap_size byte-swaps to perform.

DESCRIPTION The udi_endian_swap function generates rep_count byte-swapping copies from src to dst, of swap_size bytes each. Between each repetition src is incremented by stride to obtain the next element to be swapped. Only the memory actually byte-swapped into dst will be changed as a result of this call.

If swap_size is 1, and src is equal to dst, this function acts as a no-op. If swap_size is 1, and src is not equal to dst, this function performs a copy.

EXAMPLES If the driver has an array of structures that need to be endian translated, it can call udi_endian_swap once for each type of multi-byte field in the structure, setting src to point to the address of the field in the zeroth element of the array (e.g. &array[0]->my_field), swap_size to the size of the field, stride to the size of the structure, and rep_count to the number of elements in the array.

RefereNCES UDI_ENDIAN_SWAP_ARRAY


UDI Core Specification Contents