Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
swap_bank.h
Go to the documentation of this file.
1 
2 
3 // This contains code for byte swapping EVIO banks. The code
4 // is mostly copied from HDEVIO, but modified to just print
5 // any errors rather than use the error flag/message system
6 // built into HDEVIO. It can therefore be used outside of
7 // HDEVIO.
8 
9 
10 #include <stdint.h>
11 
12 #undef swap64
13 #undef swap32
14 #undef swap16
15 #undef swap_block
16 
17 // ----- Stolen from evio.h -----------
18 #define swap64(x) ( (((x) >> 56) & 0x00000000000000FFL) | \
19  (((x) >> 40) & 0x000000000000FF00L) | \
20  (((x) >> 24) & 0x0000000000FF0000L) | \
21  (((x) >> 8) & 0x00000000FF000000L) | \
22  (((x) << 8) & 0x000000FF00000000L) | \
23  (((x) << 24) & 0x0000FF0000000000L) | \
24  (((x) << 40) & 0x00FF000000000000L) | \
25  (((x) << 56) & 0xFF00000000000000L) )
26 
27 #define swap32(x) ( (((x) >> 24) & 0x000000FF) | \
28  (((x) >> 8) & 0x0000FF00) | \
29  (((x) << 8) & 0x00FF0000) | \
30  (((x) << 24) & 0xFF000000) )
31 
32 #define swap16(x) ( (((x) >> 8) & 0x00FF) | \
33  (((x) << 8) & 0xFF00) )
34 //---------------------------------------
35 
36 
37 uint32_t swap_bank(uint32_t *outbuff, uint32_t *inbuff, uint32_t len);
38 uint32_t swap_tagsegment(uint32_t *outbuff, uint32_t *inbuff, uint32_t len);
39 uint32_t swap_segment(uint32_t *outbuff, uint32_t *inbuff, uint32_t len);
40 
41 
42 //---------------------------------
43 // swap_block
44 //---------------------------------
45 inline void swap_block(uint16_t *inbuff, uint16_t len, uint16_t *outbuff)
46 {
47  for(uint32_t i=0; i<len; i++, inbuff++, outbuff++){
48  *outbuff = swap16(*inbuff);
49  }
50 }
51 
52 //---------------------------------
53 // swap_block
54 //---------------------------------
55 inline void swap_block(uint32_t *inbuff, uint32_t len, uint32_t *outbuff)
56 {
57  for(uint32_t i=0; i<len; i++, inbuff++, outbuff++){
58  *outbuff = swap32(*inbuff);
59  }
60 }
61 
62 //---------------------------------
63 // swap_block
64 //---------------------------------
65 inline void swap_block(uint64_t *inbuff, uint64_t len, uint64_t *outbuff)
66 {
67  for(uint32_t i=0; i<len; i++, inbuff++, outbuff++){
68  *outbuff = swap64(*inbuff);
69  }
70 }
71 
uint32_t swap_bank(uint32_t *outbuff, uint32_t *inbuff, uint32_t len)
Definition: swap_bank.cc:15
#define swap64(x)
Definition: swap_bank.h:18
#define swap32(x)
Definition: swap_bank.h:27
void swap_block(uint16_t *inbuff, uint16_t len, uint16_t *outbuff)
Definition: swap_bank.h:45
uint32_t swap_tagsegment(uint32_t *outbuff, uint32_t *inbuff, uint32_t len)
Definition: swap_bank.cc:102
uint32_t swap_segment(uint32_t *outbuff, uint32_t *inbuff, uint32_t len)
Definition: swap_bank.cc:152
#define swap16(x)
Definition: swap_bank.h:32