mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 05:07:54 +00:00
2cf25b9825
Added a pthread specific swap buffer in both tc_read and tc_write. The buffer is resized if a thread tries to send a buffer larger than the current swap size. refs #187
46 lines
1.1 KiB
C
46 lines
1.1 KiB
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
|
|
|
|
struct SwapBuffer {
|
|
unsigned int size ;
|
|
char * swap_space ;
|
|
} ;
|
|
|
|
#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
|