StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
L3swap.cxx
1 #include "L3swap.h"
2 
3 #include <netinet/in.h>
4 
5 float fswap(float swapped)
6 {
7  unsigned int* uintptr = (unsigned int*) &swapped;
8  unsigned int uintvar = ntohl(*uintptr);
9  float* floatvar = (float*)&uintvar;
10  return *floatvar;
11 }
12 
13 UINT32 swap32(UINT32 in)
14 {
15  register UINT32 x ;
16  x = in ;
17 
18  return (x&0xff000000) >> 24 | \
19  (x&0x00ff0000) >> 8 | \
20  (x&0x0000ff00) << 8 | \
21  (x&0x000000ff) << 24;
22 }
23 
24 
25 UINT16 swap16(UINT16 in)
26 {
27  register UINT16 x ;
28 
29  x = in ;
30 
31  return (x&0xFF00) >> 8 | (x&0xFF) << 8 ;
32 }
33 
34 bool checkByteOrder(UINT32 byte_order)
35 {
36  return ( byte_order == DAQ_RAW_FORMAT_ORDER );
37 }