]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/Include/sys/endian.h
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / Include / sys / endian.h
diff --git a/StdLib/Include/sys/endian.h b/StdLib/Include/sys/endian.h
deleted file mode 100644 (file)
index dfe013f..0000000
+++ /dev/null
@@ -1,309 +0,0 @@
-/** @file\r
-    Byte order related definitions and declarations.\r
-\r
-    Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
-    This program and the accompanying materials are licensed and made available\r
-    under the terms and conditions of the BSD License that accompanies this\r
-    distribution.  The full text of the license may be found at\r
-    http://opensource.org/licenses/bsd-license.\r
-\r
-    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-    Copyright (c) 1990, 1993\r
-    The Regents of the University of California.  All rights reserved.\r
-\r
-    Redistribution and use in source and binary forms, with or without\r
-    modification, are permitted provided that the following conditions\r
-    are met:\r
-      - Redistributions of source code must retain the above copyright\r
-        notice, this list of conditions and the following disclaimer.\r
-      - Redistributions in binary form must reproduce the above copyright\r
-        notice, this list of conditions and the following disclaimer in the\r
-        documentation and/or other materials provided with the distribution.\r
-      - Neither the name of the University nor the names of its contributors\r
-        may be used to endorse or promote products derived from this software\r
-        without specific prior written permission.\r
-\r
-    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
-    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
-    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
-    ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE\r
-    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
-    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
-    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
-    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
-    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
-    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
-    POSSIBILITY OF SUCH DAMAGE.\r
-\r
-    NetBSD: endian.h,v 1.24 2006/05/05 15:08:11 christos Exp\r
-    endian.h  8.1 (Berkeley) 6/11/93\r
-**/\r
-#ifndef _SYS_ENDIAN_H_\r
-#define _SYS_ENDIAN_H_\r
-\r
-#include  <sys/EfiCdefs.h>\r
-\r
-/*\r
- * Definitions for byte order, according to byte significance from low\r
- * address to high.\r
- */\r
-#define _LITTLE_ENDIAN  1234  /* LSB first: i386, vax */\r
-#define _BIG_ENDIAN     4321  /* MSB first: 68000, ibm, net */\r
-#define _PDP_ENDIAN     3412  /* LSB first in word, MSW first in long */\r
-\r
-\r
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)\r
-#ifndef _LOCORE\r
-\r
-/* C-family endian-ness definitions */\r
-\r
-#include  <sys/ansi.h>\r
-#include  <sys/types.h>\r
-\r
-#ifndef in_addr_t\r
-typedef __in_addr_t in_addr_t;\r
-#define in_addr_t __in_addr_t\r
-#endif\r
-\r
-#ifndef in_port_t\r
-typedef __in_port_t in_port_t;\r
-#define in_port_t __in_port_t\r
-#endif\r
-\r
-__BEGIN_DECLS\r
-uint32_t htonl(uint32_t) __attribute__((__const__));\r
-uint16_t htons(uint16_t) __attribute__((__const__));\r
-uint32_t ntohl(uint32_t) __attribute__((__const__));\r
-uint16_t ntohs(uint16_t) __attribute__((__const__));\r
-__END_DECLS\r
-\r
-#endif /* !_LOCORE */\r
-#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */\r
-\r
-\r
-#include  <machine/endian_machdep.h>\r
-\r
-/*\r
- * Define the order of 32-bit words in 64-bit words.\r
- */\r
-#if _BYTE_ORDER == _LITTLE_ENDIAN\r
-#define _QUAD_HIGHWORD 1\r
-#define _QUAD_LOWWORD 0\r
-#endif\r
-\r
-#if _BYTE_ORDER == _BIG_ENDIAN\r
-#define _QUAD_HIGHWORD 0\r
-#define _QUAD_LOWWORD 1\r
-#endif\r
-\r
-\r
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)\r
-/*\r
- *  Traditional names for byteorder.  These are defined as the numeric\r
- *  sequences so that third party code can "#define XXX_ENDIAN" and not\r
- *  cause errors.\r
- */\r
-#define LITTLE_ENDIAN 1234    /* LSB first: i386, vax */\r
-#define BIG_ENDIAN    4321    /* MSB first: 68000, ibm, net */\r
-#define PDP_ENDIAN    3412    /* LSB first in word, MSW first in long */\r
-#define BYTE_ORDER    _BYTE_ORDER\r
-\r
-#ifndef _LOCORE\r
-\r
-#include  <machine/bswap.h>\r
-\r
-/*\r
- * Macros for network/external number representation conversion.\r
- */\r
-#if BYTE_ORDER == BIG_ENDIAN && !defined(__lint__)\r
-#define ntohl(x)  (x)\r
-#define ntohs(x)  (x)\r
-#define htonl(x)  (x)\r
-#define htons(x)  (x)\r
-\r
-#define NTOHL(x)  (void) (x)\r
-#define NTOHS(x)  (void) (x)\r
-#define HTONL(x)  (void) (x)\r
-#define HTONS(x)  (void) (x)\r
-\r
-#else /* LITTLE_ENDIAN || !defined(__lint__) */\r
-\r
-#define ntohl(x)  bswap32((uint32_t)(x))\r
-#define ntohs(x)  bswap16((uint16_t)(x))\r
-#define htonl(x)  bswap32((uint32_t)(x))\r
-#define htons(x)  bswap16((uint16_t)(x))\r
-\r
-#define NTOHL(x)  (x) = ntohl((uint32_t)(x))\r
-#define NTOHS(x)  (x) = ntohs((uint16_t)(x))\r
-#define HTONL(x)  (x) = htonl((uint32_t)(x))\r
-#define HTONS(x)  (x) = htons((uint16_t)(x))\r
-#endif  /* LITTLE_ENDIAN || !defined(__lint__) */\r
-\r
-/*\r
- * Macros to convert to a specific endianness.\r
- */\r
-\r
-#if BYTE_ORDER == BIG_ENDIAN\r
-\r
-#define htobe16(x)  (x)\r
-#define htobe32(x)  (x)\r
-#define htobe64(x)  (x)\r
-#define htole16(x)  bswap16((uint16_t)(x))\r
-#define htole32(x)  bswap32((uint32_t)(x))\r
-#define htole64(x)  bswap64((uint64_t)(x))\r
-\r
-#define HTOBE16(x)  (void) (x)\r
-#define HTOBE32(x)  (void) (x)\r
-#define HTOBE64(x)  (void) (x)\r
-#define HTOLE16(x)  (x) = bswap16((uint16_t)(x))\r
-#define HTOLE32(x)  (x) = bswap32((uint32_t)(x))\r
-#define HTOLE64(x)  (x) = bswap64((uint64_t)(x))\r
-\r
-#else /* LITTLE_ENDIAN */\r
-\r
-#define htobe16(x)  bswap16((uint16_t)(x))\r
-#define htobe32(x)  bswap32((uint32_t)(x))\r
-#define htobe64(x)  bswap64((uint64_t)(x))\r
-#define htole16(x)  (x)\r
-#define htole32(x)  (x)\r
-#define htole64(x)  (x)\r
-\r
-#define HTOBE16(x)  (x) = bswap16((uint16_t)(x))\r
-#define HTOBE32(x)  (x) = bswap32((uint32_t)(x))\r
-#define HTOBE64(x)  (x) = bswap64((uint64_t)(x))\r
-#define HTOLE16(x)  (void) (x)\r
-#define HTOLE32(x)  (void) (x)\r
-#define HTOLE64(x)  (void) (x)\r
-\r
-#endif  /* LITTLE_ENDIAN */\r
-\r
-#define be16toh(x)  htobe16(x)\r
-#define be32toh(x)  htobe32(x)\r
-#define be64toh(x)  htobe64(x)\r
-#define le16toh(x)  htole16(x)\r
-#define le32toh(x)  htole32(x)\r
-#define le64toh(x)  htole64(x)\r
-\r
-#define BE16TOH(x)  HTOBE16(x)\r
-#define BE32TOH(x)  HTOBE32(x)\r
-#define BE64TOH(x)  HTOBE64(x)\r
-#define LE16TOH(x)  HTOLE16(x)\r
-#define LE32TOH(x)  HTOLE32(x)\r
-#define LE64TOH(x)  HTOLE64(x)\r
-\r
-/*\r
- * Routines to encode/decode big- and little-endian multi-octet values\r
- * to/from an octet stream.\r
- */\r
-\r
-static __inline void __unused\r
-be16enc(void *buf, uint16_t u)\r
-{\r
-  uint8_t *p = (uint8_t *)buf;\r
-\r
-  p[0] = (uint8_t)(((unsigned)u >> 8) & 0xff);\r
-  p[1] = (uint8_t)(u & 0xff);\r
-}\r
-\r
-static __inline void __unused\r
-le16enc(void *buf, uint16_t u)\r
-{\r
-  uint8_t *p = (uint8_t *)buf;\r
-\r
-  p[0] = (uint8_t)(u & 0xff);\r
-  p[1] = (uint8_t)(((unsigned)u >> 8) & 0xff);\r
-}\r
-\r
-static __inline uint16_t __unused\r
-be16dec(const void *buf)\r
-{\r
-  const uint8_t *p = (const uint8_t *)buf;\r
-\r
-  return ((p[0] << 8) | p[1]);\r
-}\r
-\r
-static __inline uint16_t __unused\r
-le16dec(const void *buf)\r
-{\r
-  const uint8_t *p = (const uint8_t *)buf;\r
-\r
-  return ((p[1] << 8) | p[0]);\r
-}\r
-\r
-static __inline void __unused\r
-be32enc(void *buf, uint32_t u)\r
-{\r
-  uint8_t *p = (uint8_t *)buf;\r
-\r
-  p[0] = (uint8_t)((u >> 24) & 0xff);\r
-  p[1] = (uint8_t)((u >> 16) & 0xff);\r
-  p[2] = (uint8_t)((u >> 8) & 0xff);\r
-  p[3] = (uint8_t)(u & 0xff);\r
-}\r
-\r
-static __inline void __unused\r
-le32enc(void *buf, uint32_t u)\r
-{\r
-  uint8_t *p = (uint8_t *)buf;\r
-\r
-  p[0] = (uint8_t)(u & 0xff);\r
-  p[1] = (uint8_t)((u >> 8) & 0xff);\r
-  p[2] = (uint8_t)((u >> 16) & 0xff);\r
-  p[3] = (uint8_t)((u >> 24) & 0xff);\r
-}\r
-\r
-static __inline uint32_t __unused\r
-be32dec(const void *buf)\r
-{\r
-  const uint8_t *p = (const uint8_t *)buf;\r
-\r
-  return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);\r
-}\r
-\r
-static __inline uint32_t __unused\r
-le32dec(const void *buf)\r
-{\r
-  const uint8_t *p = (const uint8_t *)buf;\r
-\r
-  return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);\r
-}\r
-\r
-static __inline void __unused\r
-be64enc(void *buf, uint64_t u)\r
-{\r
-  uint8_t *p = (uint8_t *)buf;\r
-\r
-  be32enc(p, (uint32_t)(u >> 32));\r
-  be32enc(p + 4, (uint32_t)(u & 0xffffffffULL));\r
-}\r
-\r
-static __inline void __unused\r
-le64enc(void *buf, uint64_t u)\r
-{\r
-  uint8_t *p = (uint8_t *)buf;\r
-\r
-  le32enc(p, (uint32_t)(u & 0xffffffffULL));\r
-  le32enc(p + 4, (uint32_t)(u >> 32));\r
-}\r
-\r
-static __inline uint64_t __unused\r
-be64dec(const void *buf)\r
-{\r
-  const uint8_t *p = (const uint8_t *)buf;\r
-\r
-  return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));\r
-}\r
-\r
-static __inline uint64_t __unused\r
-le64dec(const void *buf)\r
-{\r
-  const uint8_t *p = (const uint8_t *)buf;\r
-\r
-  return (le32dec(p) | ((uint64_t)le32dec(p + 4) << 32));\r
-}\r
-\r
-#endif /* !_LOCORE */\r
-#endif /* _XOPEN_SOURCE || _NETBSD_SOURCE */\r
-#endif /* !_SYS_ENDIAN_H_ */\r