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