]>
Commit | Line | Data |
---|---|---|
83cbd279 | 1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2004, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | Module name:\r | |
13 | hton.h\r | |
14 | \r | |
15 | Abstract:\r | |
16 | Byte swapping macros.\r | |
17 | \r | |
18 | \r | |
19 | **/\r | |
20 | \r | |
21 | #ifndef _HTON_H_\r | |
22 | #define _HTON_H_\r | |
23 | \r | |
24 | //\r | |
25 | // Only Intel order functions are defined at this time.\r | |
26 | //\r | |
27 | #define HTONS(v) (UINT16) ((((v) << 8) & 0xff00) + (((v) >> 8) & 0x00ff))\r | |
28 | \r | |
29 | #define HTONL(v) \\r | |
30 | (UINT32) ((((v) << 24) & 0xff000000) + (((v) << 8) & 0x00ff0000) + (((v) >> 8) & 0x0000ff00) + (((v) >> 24) & 0x000000ff))\r | |
31 | \r | |
32 | #define HTONLL(v) swap64 (v)\r | |
33 | \r | |
34 | #define U8PTR(na) ((UINT8 *) &(na))\r | |
35 | \r | |
36 | #define NTOHS(ns) ((UINT16) (((*U8PTR (ns)) << 8) +*(U8PTR (ns) + 1)))\r | |
37 | \r | |
38 | #define NTOHL(ns) \\r | |
39 | ((UINT32) (((*U8PTR (ns)) << 24) + ((*(U8PTR (ns) + 1)) << 16) + ((*(U8PTR (ns) + 2)) << 8) +*(U8PTR (ns) + 3)))\r | |
40 | \r | |
41 | #endif /* _HTON_H_ */\r | |
42 | \r | |
43 | /* EOF - hton.h */\r |