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 l3Fswap(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 l3Swap32(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 l3Swap16(uint16 in)
26 {
27  register uint16 x ;
28 
29  x = in ;
30 
31  return (x&0xFF00) >> 8 | (x&0xFF) << 8 ;
32 }
33 
34 void l3SwapBuffer(void *dest, void *src, unsigned int nDWords)
35 {
36  for (unsigned int i = 0; i<nDWords; i++) {
37  ((uint32 *)dest)[i] = swap32(((uint32 *)src)[i]);
38  }
39 }
40 
41 bool checkByteOrder(uint32 byte_order)
42 {
43  uint32 raw_format_order = 0x04030201;
44  return ( byte_order == raw_format_order );
45 }