evio  6.0
 All Data Structures Files Functions Variables Typedefs Macros Groups
swap routines

These routines handle swapping the endianness (little <-> big) of evio data. More...

Macros

#define EVIO_SWAP64(x)
 
#define EVIO_SWAP32(x)
 
#define EVIO_SWAP16(x)
 
#define EVIO_TO_64_BITS(low, high)
 Calculate a 64 bit result from 2 32 bit inputs. More...
 

Functions

int evioIsLocalHostBigEndian ()
 Is the local host big endian? More...
 
uint64_t evioToLongWord (uint32_t word1, uint32_t word2, int needToSwap)
 Take 2, 32 bit words and change that into a 64 bit word, taking endianness and swapping into account. More...
 
void evioSwapFileHeaderV6 (uint32_t *header)
 Swap an evio version 6 file header in place (but not the following index arrary, etc). More...
 
void evioSwapRecordHeaderV6 (uint32_t *header)
 Swap an evio version 6 record header in place (but not the following index arrary, etc). More...
 
void evioswap (uint32_t *buf, int tolocal, uint32_t *dest)
 Routine to swap the endianness of an evio event (bank). More...
 
uint32_tswap_int32_t (uint32_t *data, unsigned int length, uint32_t *dest)
 This routine swaps a buffer of 32 bit integers. More...
 
uint64_tswap_int64_t (uint64_t *data, unsigned int length, uint64_t *dest)
 This routine swaps a buffer of 64 bit integers. More...
 
uint16_tswap_int16_t (uint16_t *data, unsigned int length, uint16_t *dest)
 This routine swaps a buffer of 16 bit integers. More...
 

Detailed Description

These routines handle swapping the endianness (little <-> big) of evio data.

Macro Definition Documentation

#define EVIO_SWAP16 (   x)
Value:
( (((x) >> 8) & 0x00FF) | \
(((x) << 8) & 0xFF00) )

Referenced by swap_int16_t().

#define EVIO_SWAP32 (   x)
Value:
( (((x) >> 24) & 0x000000FF) | \
(((x) >> 8) & 0x0000FF00) | \
(((x) << 8) & 0x00FF0000) | \
(((x) << 24) & 0xFF000000) )

Referenced by evioToLongWord(), evPrintBuffer(), evRead(), evReadNoCopy(), evReadRandom(), and swap_int32_t().

#define EVIO_SWAP64 (   x)
Value:
( (((x) >> 56) & 0x00000000000000FFL) | \
(((x) >> 40) & 0x000000000000FF00L) | \
(((x) >> 24) & 0x0000000000FF0000L) | \
(((x) >> 8) & 0x00000000FF000000L) | \
(((x) << 8) & 0x000000FF00000000L) | \
(((x) << 24) & 0x0000FF0000000000L) | \
(((x) << 40) & 0x00FF000000000000L) | \
(((x) << 56) & 0xFF00000000000000L) )

Referenced by swap_int64_t().

#define EVIO_TO_64_BITS (   low,
  high 
)
Value:
((((uint64_t) low) & 0xffffffffL) && \
((((uint64_t) high) << 32)))
UINT64 uint64_t
Definition: msinttypes.h:63

Calculate a 64 bit result from 2 32 bit inputs.

Referenced by evioToLongWord().

Function Documentation

int evioIsLocalHostBigEndian ( )

Is the local host big endian?

Returns
1 if the local host is big endian, else 0.

Referenced by evioToLongWord().

void evioswap ( uint32_t buf,
int  tolocal,
uint32_t dest 
)

Routine to swap the endianness of an evio event (bank).

Parameters
bufbuffer of evio event data to be swapped
tolocalif 0 buf contains data of same endian as local host, else buf has data of opposite endian
destbuffer to place swapped data into. If this is NULL, then dest = buf.

Referenced by evRead(), evReadNoCopy(), and evReadRandom().

void evioSwapFileHeaderV6 ( uint32_t header)

Swap an evio version 6 file header in place (but not the following index arrary, etc).

Nothing done for NULL arg.

Parameters
headerpointer to header

References EV_HDSIZ_V6, and swap_int32_t().

void evioSwapRecordHeaderV6 ( uint32_t header)

Swap an evio version 6 record header in place (but not the following index arrary, etc).

Nothing done for NULL arg.

Parameters
headerpointer to header

References EV_HDSIZ_V6, and swap_int32_t().

uint64_t evioToLongWord ( uint32_t  word1,
uint32_t  word2,
int  needToSwap 
)

Take 2, 32 bit words and change that into a 64 bit word, taking endianness and swapping into account.

Parameters
word1word which occurs first in memory being read
word2word which occurs second in memory being read
needToSwaptrue if word arguments are of an endian opposite to this host
Returns
64 bit word comprised of 2, 32 bit words

References EVIO_SWAP32, EVIO_TO_64_BITS, and evioIsLocalHostBigEndian().

uint16_t* swap_int16_t ( uint16_t data,
unsigned int  length,
uint16_t dest 
)

This routine swaps a buffer of 16 bit integers.

Parameters
datapointer to data to be swapped
lengthnumber of 16 bit ints to be swapped
destpointer to where swapped data is to be copied to. If NULL, the data is swapped in place.
Returns
pointer to beginning of swapped data

References EVIO_SWAP16.

uint32_t* swap_int32_t ( uint32_t data,
unsigned int  length,
uint32_t dest 
)

This routine swaps a buffer of 32 bit integers.

Parameters
datapointer to data to be swapped
lengthnumber of 32 bit ints to be swapped
destpointer to where swapped data is to be copied to. If NULL, the data is swapped in place.
Returns
pointer to beginning of swapped data

References EVIO_SWAP32.

Referenced by evioSwapFileHeaderV6(), and evioSwapRecordHeaderV6().

uint64_t* swap_int64_t ( uint64_t data,
unsigned int  length,
uint64_t dest 
)

This routine swaps a buffer of 64 bit integers.

Parameters
datapointer to data to be swapped
lengthnumber of 64 bit ints to be swapped
destpointer to where swapped data is to be copied to. If NULL, the data is swapped in place.
Returns
pointer to beginning of swapped data

References EVIO_SWAP64.