1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../LICENSE. */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2000-02-10 06:03:09 -08:00
|
|
|
/* Swap byte-order in 16, 32, and 64-bit integers or floats */
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
#ifndef _reverse_
|
|
|
|
#define _reverse_
|
|
|
|
|
2000-02-10 06:03:09 -08:00
|
|
|
#define Reverse_16(dst,src) { \
|
|
|
|
char * _p, * _q; \
|
|
|
|
char _a; \
|
|
|
|
_p = (char *) (src); \
|
|
|
|
_q = (char *) (dst); \
|
|
|
|
_a = _p[0]; \
|
|
|
|
_q[0] = _p[1]; \
|
|
|
|
_q[1] = _a; \
|
1995-05-04 03:15:53 -07:00
|
|
|
}
|
|
|
|
|
2000-02-10 06:03:09 -08:00
|
|
|
#define Reverse_32(dst,src) { \
|
|
|
|
char * _p, * _q; \
|
|
|
|
char _a, _b; \
|
|
|
|
_p = (char *) (src); \
|
|
|
|
_q = (char *) (dst); \
|
|
|
|
_a = _p[0]; \
|
|
|
|
_b = _p[1]; \
|
|
|
|
_q[0] = _p[3]; \
|
|
|
|
_q[1] = _p[2]; \
|
|
|
|
_q[3] = _a; \
|
|
|
|
_q[2] = _b; \
|
1995-05-04 03:15:53 -07:00
|
|
|
}
|
|
|
|
|
2000-02-10 06:03:09 -08:00
|
|
|
#define Reverse_64(dst,src) { \
|
|
|
|
char * _p, * _q; \
|
|
|
|
char _a, _b; \
|
|
|
|
_p = (char *) (src); \
|
|
|
|
_q = (char *) (dst); \
|
|
|
|
_a = _p[0]; \
|
|
|
|
_b = _p[1]; \
|
|
|
|
_q[0] = _p[7]; \
|
|
|
|
_q[1] = _p[6]; \
|
|
|
|
_q[7] = _a; \
|
|
|
|
_q[6] = _b; \
|
|
|
|
_a = _p[2]; \
|
|
|
|
_b = _p[3]; \
|
|
|
|
_q[2] = _p[5]; \
|
|
|
|
_q[3] = _p[4]; \
|
|
|
|
_q[5] = _a; \
|
|
|
|
_q[4] = _b; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
#endif /* _reverse_ */
|