22#define _ngcpp_swap (ngcppEndian != ngcppCOM_PROT_ENDIAN)
27static __inline__
void _byte_order(
void *buf,
int len,
int n)
53static __inline__
void ngcppPutValChar(
char *buf,
char value,
int *pos)
62static __inline__
void ngcppPutValShort(
char *buf,
int value,
int *pos)
64 short shortVal = (short)(value & 0xffff);
66 int len =
sizeof(tmp);
67 char *p = (
char *)(
void *)&shortVal;
68 memcpy(tmp, p, (
size_t)len);
69 _byte_order(tmp, len, len);
70 memcpy(buf + *pos, tmp, (
size_t)len);
77static __inline__
void ngcppPutValInt(
char *buf,
int value,
int *pos)
80 int len =
sizeof(tmp);
81 char *p = (
char *)(
void *)&value;
82 memcpy(tmp, p, (
size_t)len);
83 _byte_order(tmp, len, len);
84 memcpy(buf + *pos, tmp, (
size_t)len);
91static __inline__
void ngcppPutValFloat(
char *buf,
float value,
int *pos)
94 int len =
sizeof(tmp);
95 char *p = (
char *)(
void *)&value;
96 memcpy(tmp, p, (
size_t)len);
97 _byte_order(tmp, len, len);
98 memcpy(buf + *pos, tmp, (
size_t)len);
105static __inline__
void ngcppPutValDouble(
char *buf,
double value,
int *pos)
108 int len =
sizeof(tmp);
109 char *p = (
char *)(
void *)&value;
110 memcpy(tmp, p, (
size_t)len);
111 _byte_order(tmp, len, len);
112 memcpy(buf + *pos, tmp, (
size_t)len);
119static __inline__
char ngcppGetValChar(
char *buf,
int *pos)
130static __inline__
short ngcppGetValShort(
char *buf,
int *pos)
133 int len =
sizeof(short);
134 memcpy(&value, buf + *pos, (
size_t)len);
135 _byte_order(&value, len, len);
143static __inline__
int ngcppGetValInt(
char *buf,
int *pos)
146 int len =
sizeof(int);
147 memcpy(&value, buf + *pos, (
size_t)len);
148 _byte_order(&value, len, len);
156static __inline__
float ngcppGetValFloat(
char *buf,
int *pos)
159 int len =
sizeof(float);
160 memcpy(&value, buf + *pos, (
size_t)len);
161 _byte_order(&value, len, len);
169static __inline__
double ngcppGetValDouble(
char *buf,
int *pos)
172 int len =
sizeof(double);
173 memcpy(&value, buf + *pos, (
size_t)len);
174 _byte_order(&value, len, len);
182static __inline__
void _putVec(
char *buf,
const void *vec,
int size,
int *pos,
186 memcpy(buf + *pos, vec, (
size_t)len);
187 _byte_order(buf + *pos, len, bc);
194static __inline__
void _getVec(
char *buf,
void *vec,
int size,
int *pos,
198 memcpy(vec, buf + *pos, (
size_t)len);
199 _byte_order(vec, len, bc);
206#define ngcppPutVecChar(b,x,y,z) _putVec(b,x,y,z,1)
211#define ngcppPutVecShort(b,x,y,z) _putVec(b,x,y,z,2)
216#define ngcppPutVecInt(b,x,y,z) _putVec(b,x,y,z,4)
221#define ngcppPutVecFloat(b,x,y,z) _putVec(b,x,y,z,4)
226#define ngcppPutVecDouble(b,x,y,z) _putVec(b,x,y,z,8)
231#define ngcppGetVecChar(b,x,y,z) _getVec(b,x,y,z,1)
236#define ngcppGetVecShort(b,x,y,z) _getVec(b,x,y,z,2)
241#define ngcppGetVecInt(b,x,y,z) _getVec(b,x,y,z,4)
246#define ngcppGetVecFloat(b,x,y,z) _getVec(b,x,y,z,4)
251#define ngcppGetVecDouble(b,x,y,z) _getVec(b,x,y,z,8)
void ngcbSwap8(void *buffer, size_t length)
Definition ngcbMath.c:49
void ngcbSwap4(void *buffer, size_t length)
Definition ngcbMath.c:38
void ngcbSwap2(void *buffer, size_t length)
Definition ngcbMath.c:27
#define _ngcpp_swap
Definition ngcppCom.h:22