This is Unofficial EPICS BASE Doxygen Site
osdWireFormat.h File Reference
#include <cstring>
#include "epicsEndian.h"
+ Include dependency graph for osdWireFormat.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<>
void WireGet< epicsFloat64 > (const epicsUInt8 *pWireSrc, epicsFloat64 &dst)
 
void WireGet (const epicsUInt8 *pWireSrc, epicsOldString &dst)
 
template<>
void WireSet< epicsFloat64 > (const epicsFloat64 &src, epicsUInt8 *pWireDst)
 
void WireSet (const epicsOldString &src, epicsUInt8 *pWireDst)
 
template<>
void AlignedWireGet< epicsUInt16 > (const epicsUInt16 &src, epicsUInt16 &dst)
 
template<>
void AlignedWireGet< epicsUInt32 > (const epicsUInt32 &src, epicsUInt32 &dst)
 
template<>
void AlignedWireGet< epicsFloat64 > (const epicsFloat64 &src, epicsFloat64 &dst)
 
template<>
void AlignedWireSet< epicsUInt16 > (const epicsUInt16 &src, epicsUInt16 &dst)
 
template<>
void AlignedWireSet< epicsUInt32 > (const epicsUInt32 &src, epicsUInt32 &dst)
 
template<>
void AlignedWireSet< epicsFloat64 > (const epicsFloat64 &src, epicsFloat64 &dst)
 

Function Documentation

template<>
void AlignedWireGet< epicsFloat64 > ( const epicsFloat64 src,
epicsFloat64 dst 
)
inline

Definition at line 155 of file osdWireFormat.h.

157 {
158  // copy through union here
159  // a) prevents over-aggressive optimization under strict aliasing rules
160  // b) doesnt preclude extra copy operation being optimized away
161  union Swapper {
162  epicsUInt32 _u[2];
163  epicsFloat64 _f;
164  };
165 # if EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG && EPICS_FLOAT_WORD_ORDER == EPICS_BYTE_ORDER
166  dst = src;
167 # elif EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_BIG
168  Swapper tmp;
169  tmp._f = src;
170  AlignedWireGet ( tmp._u[0], tmp._u[0] );
171  AlignedWireGet ( tmp._u[1], tmp._u[1] );
172  dst = tmp._f;
173 # elif EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_LITTLE
174  Swapper srcu, dstu;
175  srcu._f = src;
176  AlignedWireGet ( srcu._u[1], dstu._u[0] );
177  AlignedWireGet ( srcu._u[0], dstu._u[1] );
178  dst = dstu._f;
179 # else
180 # error unsupported floating point word order
181 # endif
182 }
double epicsFloat64
Definition: epicsTypes.h:49
void AlignedWireGet(const T &, T &)
unsigned int epicsUInt32
Definition: epicsTypes.h:43
template<>
void AlignedWireGet< epicsUInt16 > ( const epicsUInt16 src,
epicsUInt16 dst 
)
inline

Definition at line 129 of file osdWireFormat.h.

131 {
132 # if EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE
133  dst = byteSwap ( src );
134 # elif EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG
135  dst = src;
136 # else
137 # error unsupported endian type
138 # endif
139 }
epicsUInt16 byteSwap(const epicsUInt16 &src)
template<>
void AlignedWireGet< epicsUInt32 > ( const epicsUInt32 src,
epicsUInt32 dst 
)
inline

Definition at line 142 of file osdWireFormat.h.

144 {
145 # if EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE
146  dst = byteSwap ( src );
147 # elif EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG
148  dst = src;
149 # else
150 # error unsupported endian type
151 # endif
152 }
epicsUInt16 byteSwap(const epicsUInt16 &src)
template<>
void AlignedWireSet< epicsFloat64 > ( const epicsFloat64 src,
epicsFloat64 dst 
)
inline

Definition at line 211 of file osdWireFormat.h.

213 {
214  // copy through union here
215  // a) prevents over-aggressive optimization under strict aliasing rules
216  // b) doesnt preclude extra copy operation being optimized away
217  union Swapper {
218  epicsUInt32 _u[2];
219  epicsFloat64 _f;
220  };
221 # if EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG && EPICS_FLOAT_WORD_ORDER == EPICS_BYTE_ORDER
222  dst = src;
223 # elif EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_BIG
224  Swapper tmp;
225  tmp._f = src;
226  AlignedWireSet ( tmp._u[0], tmp._u[0] );
227  AlignedWireSet ( tmp._u[1], tmp._u[1] );
228  dst = tmp._f;
229 # elif EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_LITTLE
230  Swapper srcu, dstu;
231  srcu._f = src;
232  AlignedWireSet ( srcu._u[1], dstu._u[0] );
233  AlignedWireSet ( srcu._u[0], dstu._u[1] );
234  dst = dstu._f;
235 # else
236 # error unsupported floating point word order
237 # endif
238 }
void AlignedWireSet(const T &, T &)
double epicsFloat64
Definition: epicsTypes.h:49
unsigned int epicsUInt32
Definition: epicsTypes.h:43
template<>
void AlignedWireSet< epicsUInt16 > ( const epicsUInt16 src,
epicsUInt16 dst 
)
inline

Definition at line 186 of file osdWireFormat.h.

187 {
188 # if EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE
189  dst = byteSwap ( src );
190 # elif EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG
191  dst = src;
192 # else
193 # error undefined endian type
194 # endif
195 }
epicsUInt16 byteSwap(const epicsUInt16 &src)
template<>
void AlignedWireSet< epicsUInt32 > ( const epicsUInt32 src,
epicsUInt32 dst 
)
inline

Definition at line 198 of file osdWireFormat.h.

200 {
201 # if EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE
202  dst = byteSwap ( src );
203 # elif EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG
204  dst = src;
205 # else
206 # error undefined endian type
207 # endif
208 }
epicsUInt16 byteSwap(const epicsUInt16 &src)
void WireGet ( const epicsUInt8 pWireSrc,
epicsOldString dst 
)
inline

Definition at line 83 of file osdWireFormat.h.

85 {
86  memcpy ( dst, pWireSrc, sizeof ( dst ) );
87 }
template<>
void WireGet< epicsFloat64 > ( const epicsUInt8 pWireSrc,
epicsFloat64 dst 
)
inline

Definition at line 53 of file osdWireFormat.h.

55 {
56  // copy through union here
57  // a) prevents over-aggressive optimization under strict aliasing rules
58  // b) doesnt preclude extra copy operation being optimized away
59  union {
60  epicsFloat64 _f;
61  epicsUInt32 _u[2];
62  } tmp;
63 # if EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_LITTLE
64  WireGet ( pWireSrc, tmp._u[1] );
65  WireGet ( pWireSrc + 4, tmp._u[0] );
66 # elif EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_BIG
67  WireGet ( pWireSrc, tmp._u[0] );
68  WireGet ( pWireSrc + 4, tmp._u[1] );
69 # else
70 # error unsupported floating point word order
71 # endif
72  dst = tmp._f;
73 }
double epicsFloat64
Definition: epicsTypes.h:49
unsigned int epicsUInt32
Definition: epicsTypes.h:43
void WireGet(const epicsUInt8 *pWireSrc, epicsOldString &dst)
Definition: osdWireFormat.h:83
void WireSet ( const epicsOldString src,
epicsUInt8 pWireDst 
)
inline

Definition at line 121 of file osdWireFormat.h.

123 {
124  memcpy ( pWireDst, src, sizeof ( src ) );
125 }
template<>
void WireSet< epicsFloat64 > ( const epicsFloat64 src,
epicsUInt8 pWireDst 
)
inline

Definition at line 91 of file osdWireFormat.h.

93 {
94  // copy through union here
95  // a) prevents over-aggressive optimization under strict aliasing rules
96  // b) doesnt preclude extra copy operation being optimized away
97  union {
98  epicsFloat64 _f;
99  epicsUInt32 _u[2];
100  } tmp;
101  tmp._f = src;
102 # if EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_LITTLE
103  WireSet ( tmp._u[1], pWireDst );
104  WireSet ( tmp._u[0], pWireDst + 4 );
105 # elif EPICS_FLOAT_WORD_ORDER == EPICS_ENDIAN_BIG
106  WireSet ( tmp._u[0], pWireDst );
107  WireSet ( tmp._u[1], pWireDst + 4 );
108 # else
109 # error unsupported floating point word order
110 # endif
111 }
double epicsFloat64
Definition: epicsTypes.h:49
unsigned int epicsUInt32
Definition: epicsTypes.h:43
void WireSet(const epicsOldString &src, epicsUInt8 *pWireDst)