source: Sophya/trunk/FrEROS/AnaLC/swapbytes.h@ 3308

Last change on this file since 3308 was 3308, checked in by ansari, 18 years ago

Creation du module AnaLC (lecture suivi EROS avec SOPHYA) dans la base
SOPHYA - cmv+reza 22/08/2007

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1/* Macro pour faire des bytes-swap */
2/* CMV+Reza Fev 98 */
3
4#ifndef SWAPBYTES_H_SEEN
5#define SWAPBYTES_H_SEEN
6
7/* Les arguments des define sont consideres comme pointeur */
8
9#define Swap_Bytes8(_x8_) \
10{ \
11 uint_8 _tmp_ = *(uint_8*)(_x8_); \
12 *(uint_8*)(_x8_) = ((_tmp_ >> (7*8)) & 0x000000FF) | \
13 ((_tmp_ >> (5*8)) & 0x0000FF00) | \
14 ((_tmp_ >> (3*8)) & 0x00FF0000) | \
15 ((_tmp_ >> (1*8)) & 0xFF000000) | \
16 ((_tmp_ & 0xFF000000) << (1*8)) | \
17 ((_tmp_ & 0x00FF0000) << (3*8)) | \
18 ((_tmp_ & 0x0000FF00) << (5*8)) | \
19 ((_tmp_ & 0x000000FF) << (7*8)); \
20}
21
22
23#define Swap_Bytes4(_x4_) \
24{ \
25 uint_4 _tmp_ = *(uint_4*)(_x4_); \
26 *(uint_4*)(_x4_) = ((_tmp_ >> 24) & 0x000000FF) | \
27 ((_tmp_ >> 8) & 0x0000FF00) | \
28 ((_tmp_ & 0x0000FF00) << 8) | \
29 ((_tmp_ & 0x000000FF) << 24); \
30}
31
32
33#define Swap_Bytes2(_x2_) \
34{ \
35 uint_2 _tmp_ = *(uint_2*)(_x2_); \
36 *(uint_2*)(_x2_) = ((_tmp_ >> 8) & 0x00FF) | \
37 ((_tmp_ & 0x00FF) << 8); \
38}
39
40#endif
Note: See TracBrowser for help on using the repository browser.