21#define _ngcpp_swap (ngcppEndian != ngcppCOM_PROT_ENDIAN)
26static __inline__
void _byte_order(
void *buf,
int len,
int n)
52static __inline__
void ngcppPutValChar(
char *buf,
char value,
int *pos)
61static __inline__
void ngcppPutValShort(
char *buf,
int value,
int *pos)
63 short shortVal = (short)(value & 0xffff);
65 int len =
sizeof(tmp);
66 char *p = (
char *)(
void *)&shortVal;
67 memcpy(tmp, p, (
size_t)len);
68 _byte_order(tmp, len, len);
69 memcpy(buf + *pos, tmp, (
size_t)len);
76static __inline__
void ngcppPutValInt(
char *buf,
int value,
int *pos)
79 int len =
sizeof(tmp);
80 char *p = (
char *)(
void *)&value;
81 memcpy(tmp, p, (
size_t)len);
82 _byte_order(tmp, len, len);
83 memcpy(buf + *pos, tmp, (
size_t)len);
90static __inline__
void ngcppPutValFloat(
char *buf,
float value,
int *pos)
93 int len =
sizeof(tmp);
94 char *p = (
char *)(
void *)&value;
95 memcpy(tmp, p, (
size_t)len);
96 _byte_order(tmp, len, len);
97 memcpy(buf + *pos, tmp, (
size_t)len);
104static __inline__
void ngcppPutValDouble(
char *buf,
double value,
int *pos)
107 int len =
sizeof(tmp);
108 char *p = (
char *)(
void *)&value;
109 memcpy(tmp, p, (
size_t)len);
110 _byte_order(tmp, len, len);
111 memcpy(buf + *pos, tmp, (
size_t)len);
118static __inline__
char ngcppGetValChar(
char *buf,
int *pos)
129static __inline__
short ngcppGetValShort(
char *buf,
int *pos)
132 int len =
sizeof(short);
133 memcpy(&value, buf + *pos, (
size_t)len);
134 _byte_order(&value, len, len);
142static __inline__
int ngcppGetValInt(
char *buf,
int *pos)
145 int len =
sizeof(int);
146 memcpy(&value, buf + *pos, (
size_t)len);
147 _byte_order(&value, len, len);
155static __inline__
float ngcppGetValFloat(
char *buf,
int *pos)
158 int len =
sizeof(float);
159 memcpy(&value, buf + *pos, (
size_t)len);
160 _byte_order(&value, len, len);
168static __inline__
double ngcppGetValDouble(
char *buf,
int *pos)
171 int len =
sizeof(double);
172 memcpy(&value, buf + *pos, (
size_t)len);
173 _byte_order(&value, len, len);
181static __inline__
void _putVec(
char *buf,
const void *vec,
int size,
int *pos,
185 memcpy(buf + *pos, vec, (
size_t)len);
186 _byte_order(buf + *pos, len, bc);
193static __inline__
void _getVec(
char *buf,
void *vec,
int size,
int *pos,
197 memcpy(vec, buf + *pos, (
size_t)len);
198 _byte_order(vec, len, bc);
205#define ngcppPutVecChar(b,x,y,z) _putVec(b,x,y,z,1)
210#define ngcppPutVecShort(b,x,y,z) _putVec(b,x,y,z,2)
215#define ngcppPutVecInt(b,x,y,z) _putVec(b,x,y,z,4)
220#define ngcppPutVecFloat(b,x,y,z) _putVec(b,x,y,z,4)
225#define ngcppPutVecDouble(b,x,y,z) _putVec(b,x,y,z,8)
230#define ngcppGetVecChar(b,x,y,z) _getVec(b,x,y,z,1)
235#define ngcppGetVecShort(b,x,y,z) _getVec(b,x,y,z,2)
240#define ngcppGetVecInt(b,x,y,z) _getVec(b,x,y,z,4)
245#define ngcppGetVecFloat(b,x,y,z) _getVec(b,x,y,z,4)
250#define ngcppGetVecDouble(b,x,y,z) _getVec(b,x,y,z,8)
void ngcbSwap8(void *buffer, size_t length)
Definition ngcbMath.c:48
void ngcbSwap4(void *buffer, size_t length)
Definition ngcbMath.c:37
void ngcbSwap2(void *buffer, size_t length)
Definition ngcbMath.c:26
#define _ngcpp_swap
Definition ngcppCom.h:21