trick/trick_source/trick_utils/comm/include/trick_byteswap.h
Alex Lin 14a75508a3 Cleaning up once include variables and copyright cleanup.
Changed all header file once include variables to follow the same naming
convention and not start with any underscores.  Also deleted old
incorrect copyright notices.  Also removed $Id: tags from all files.

Fixes #14.  Fixes #22.
2015-03-23 16:03:14 -05:00

41 lines
1003 B
C

/*
PURPOSE: (Byte swapping.)
REFERENCES: (Copied from ISP and changed names, added float and long swaps)
PROGRAMMERS: (((Jane Falgout) (LinCom) (5/98) (--) (--)))
ICG: (No)
*/
#ifndef TRICK_BYTESWAP_H
#define TRICK_BYTESWAP_H
#define TRICK_BIG_ENDIAN (char)0x00
#define TRICK_LITTLE_ENDIAN (char)0x01
#ifdef __cplusplus
extern "C" {
#endif
double trick_byteswap_double(double input);
float trick_byteswap_float(float input);
long trick_byteswap_long(long input);
int trick_byteswap_int(int input);
short trick_byteswap_short(short input);
#ifdef __cplusplus
}
#endif
#define TRICK_GET_BYTE_ORDER(IND) \
{ \
union { \
long l; \
char c[sizeof(long)]; \
} un; \
un.l = 1; \
if (un.c[sizeof(long)-1] == 1) \
IND = TRICK_BIG_ENDIAN; \
else \
IND = TRICK_LITTLE_ENDIAN; \
}
#endif