32 #ifndef _QORE_BITOPTS_H
34 #define _QORE_BITOPTS_H
38 static inline int64 i8LSB(int64 i);
39 static inline int i4LSB(
int i);
40 static inline short i2LSB(
short i);
42 static inline int64 LSBi8(int64 i);
43 static inline int LSBi4(
int i);
44 static inline short LSBi2(
short i);
46 static inline int64 i8MSB(int64 i);
47 static inline int64 MSBi8(int64 i);
55 DLLLOCAL
void swap(
char *ibuf) {
68 static inline int64 swapi8(int64 i) {
69 char *ibuf = (
char *)&i;
76 static inline double swapf8(
double f) {
77 char *ibuf = (
char *)&f;
89 DLLLOCAL
void swap(
char *ibuf) {
98 static inline int swapi4(
int i) {
99 char *ibuf = (
char *)&i;
106 static inline float swapf4(
float f) {
107 char *ibuf = (
char *)&f;
118 DLLLOCAL
void swap(
char *ibuf) {
125 static inline short swapi2(
short i) {
126 char *ibuf = (
char *)&i;
132 #ifdef WORDS_BIGENDIAN
133 static inline int64 i8LSB(int64 i) {
137 static inline int i4LSB(
int i) {
141 static inline short i2LSB(
short i) {
145 static inline int64 LSBi8(int64 i) {
149 static inline int LSBi4(
int i) {
153 static inline short LSBi2(
short i) {
157 static inline int64 i8MSB(int64 i) {
return i; }
158 static inline int64 MSBi8(int64 i) {
return i; }
160 static inline double f8LSB(
double f) {
164 static inline float f4LSB(
float f) {
168 static inline double LSBf8(
double f) {
172 static inline float LSBf4(
float f) {
176 static inline double f8MSB(
double f) {
return f; }
177 static inline double MSBf8(
double f) {
return f; }
178 static inline float f4MSB(
float f) {
return f; }
179 static inline float MSBf4(
float f) {
return f; }
181 #else // definitions for little endian machines below
183 static inline int64 i8LSB(int64 i) {
return i; }
184 static inline int i4LSB(
int i) {
return i; }
185 static inline short i2LSB(
short i) {
return i; }
187 static inline int64 LSBi8(int64 i) {
return i; }
188 static inline int LSBi4(
int i) {
return i; }
189 static inline short LSBi2(
short i) {
return i; }
191 static inline int64 i8MSB(int64 i) {
195 static inline int64 MSBi8(int64 i) {
199 static inline double f8LSB(
double f) {
return f; }
200 static inline float f4LSB(
float f) {
return f; }
202 static inline double LSBf8(
double f) {
return f; }
203 static inline float LSBf4(
float f) {
return f; }
205 static inline double f8MSB(
double f) {
209 static inline double MSBf8(
double f) {
213 static inline float f4MSB(
float f) {
217 static inline float MSBf4(
float f) {
used to swap byte order of 8-byte values
Definition: qore_bitopts.h:50
used to swap 2-byte integers
Definition: qore_bitopts.h:114
used to swap byte order of 4-byte values
Definition: qore_bitopts.h:84