+++ /dev/null
-/** @file\r
- Common declarations and definitions for Standard C Library headers.\r
-\r
- This header consolidates definitions and declarations for compiler specific\r
- features in one place in order to assist in making the remainder of the\r
- library as compiler independent as possible.\r
-\r
- Certain macro and type definitions are required to be provided by several\r
- different headers. In order to avoid having multiple definitions, and the\r
- attendant risk of having the definitions get out of sync, they are defined in\r
- this header.\r
-\r
- Note that MdePkg/Include/Base.h is automatically included and will bring\r
- processor architecture specific definitions along with it.\r
-\r
- Throughout the library, the following macros are used instead of keywords so\r
- that the library can be easily tuned for different compilers.\r
- __inline Defined to the appropriate keyword or not defined.\r
- __func__ Defined to __FUNC__, __FUNCTION__, or NULL as appropriate.\r
- __restrict Defined to nothing for VC++ or to restrict for GCC and C99 compliant compilers.\r
-\r
- This file and its contents are inspired by the <sys/cdefs.h> files in Berkeley\r
- Unix. They have been re-implemented to be specific to the EFI environment.\r
-\r
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials are licensed and made available under\r
- the terms and conditions of the BSD License that accompanies this distribution.\r
- 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
- Portions Copyright (c) 1991, 1993\r
- The Regents of the University of California. All rights reserved.\r
-\r
- Portions of this code are derived from software contributed to Berkeley by\r
- Berkeley Software Design, Inc.\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
- 1. Redistributions of source code must retain the above copyright\r
- notice, this list of conditions and the following disclaimer.\r
- 2. 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
- 3. 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- 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 REGENTS OR CONTRIBUTORS BE LIABLE\r
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- SUCH DAMAGE.\r
-**/\r
-#ifndef _EFI_CDEFS_H\r
-#define _EFI_CDEFS_H\r
-\r
-/*\r
-* Macro to test if we're using a GNU C compiler of a specific vintage\r
-* or later, for e.g. features that appeared in a particular version\r
-* of GNU C. Usage:\r
-*\r
-* #if __GNUC_PREREQ__(major, minor)\r
-* ...cool feature...\r
-* #else\r
-* ...delete feature...\r
-* #endif\r
-*/\r
-#ifdef __GNUC__\r
-#define __GNUC_PREREQ__(x, y) \\r
-((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \\r
- (__GNUC__ > (x)))\r
-\r
-#define DONT_USE_STRONG_WEAK_ALIAS 1\r
-\r
-#else\r
-#define __GNUC_PREREQ__(x, y) 0\r
-#endif\r
-\r
-#include <sys/featuretest.h>\r
-//#include <machine/_EfiCdefs.h>\r
-#ifdef __PE32__\r
-#include <sys/_EfiCdefs_PE32.h>\r
-#else\r
-#include <sys/cdefs_aout.h>\r
-#endif\r
-\r
-/* NULL is defined by the automatic inclusion of Base.h by the build tools. */\r
-\r
-#ifdef __GNUC__\r
- #define _EFI_SIZE_T_ __SIZE_TYPE__ /* sizeof() */\r
- #define _EFI_WCHAR_T __WCHAR_TYPE__\r
- #define _EFI_WINT_T __WINT_TYPE__\r
- //#define _EFI_WINT_MIN (0)\r
- //#define _EFI_WINT_MAX (0xFFFF)\r
- #define _EFI_PTRDIFF_T_ __PTRDIFF_TYPE__ /* ptr1 - ptr2 --- Must be same size as size_t */\r
-\r
-#else\r
-#define _EFI_SIZE_T_ UINTN /* sizeof() */\r
-#define _EFI_WCHAR_T UINT16\r
-#define _EFI_WINT_T INT32\r
- //#define _EFI_WINT_MIN (-2147483647) /* wint_t */\r
- //#define _EFI_WINT_MAX ( 2147483647) /* wint_t */\r
- #define _EFI_PTRDIFF_T_ INTN /* ptr1 - ptr2 --- Must be same size as size_t */\r
-#endif /* __GNUC__ */\r
-\r
-#define _EFI_CLOCK_T UINT64\r
-#define _EFI_TIME_T INT32\r
-\r
-#if defined(__cplusplus)\r
-#define __BEGIN_DECLS extern "C" {\r
-#define __END_DECLS }\r
-#define __static_cast(x,y) static_cast<x>(y)\r
-#else\r
-#define __BEGIN_DECLS\r
-#define __END_DECLS\r
-#define __static_cast(x,y) (x)y\r
-#endif\r
-\r
- /*\r
- * The __CONCAT macro is used to concatenate parts of symbol names, e.g.\r
- * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.\r
- * The __CONCAT macro is a bit tricky -- make sure you don't put spaces\r
- * in between its arguments. __CONCAT can also concatenate double-quoted\r
- * strings produced by the __STRING macro, but this only works with ANSI C.\r
- */\r
-\r
-#define ___STRING(x) __STRING(x)\r
-#define ___CONCAT(x,y) __CONCAT(x,y)\r
-#define __CONCAT(x,y) x ## y\r
-#define __STRING(x) #x\r
-\r
-#define __const CONST\r
-#define __signed signed\r
-#define __volatile volatile\r
-\r
-#if __STDC__ || defined(__cplusplus)\r
- #if defined(__cplusplus)\r
- #define __inline inline /* convert to C++ keyword */\r
- #else\r
- #if defined(_MSC_VER) || (!defined(__GNUC__) && !defined(__lint__))\r
- #define __inline /* delete C99 keyword */\r
- #endif /* !__GNUC__ && !__lint__ */\r
- #endif /* !__cplusplus */\r
-#endif /* !(__STDC__ || __cplusplus) */\r
-\r
-/* Used in NetBSD for internal auditing of the source tree. */\r
-#define __aconst\r
-\r
- /*\r
- * The following macro is used to remove const cast-away warnings\r
- * from gcc -Wcast-qual; it should be used with caution because it\r
- * can hide valid errors; in particular most valid uses are in\r
- * situations where the API requires it, not to cast away string\r
- * constants. We don't use *intptr_t on purpose here and we are\r
- * explicit about unsigned long so that we don't have additional\r
- * dependencies.\r
- */\r
-#define __UNCONST(a) ((void *)(a))\r
-//#define __UNCONST(a) ((void *)(PHYSICAL_ADDRESS)(const void *)(a))\r
-\r
- /*\r
- * The following macro is used to remove the volatile cast-away warnings\r
- * from gcc -Wcast-qual; as above it should be used with caution\r
- * because it can hide valid errors or warnings. Valid uses include\r
- * making it possible to pass a volatile pointer to memset().\r
- * For the same reasons as above, we use unsigned long and not intptr_t.\r
- */\r
-#define __UNVOLATILE(a) ((void *)(PHYSICAL_ADDRESS)(volatile void *)(a))\r
-\r
- /*\r
- * GCC2 provides __extension__ to suppress warnings for various GNU C\r
- * language extensions under "-ansi -pedantic".\r
- */\r
-#if !__GNUC_PREREQ__(2, 0)\r
-#define __extension__ /* delete __extension__ if non-gcc or gcc1 */\r
-#endif\r
-\r
- /*\r
- * GCC1 and some versions of GCC2 declare dead (non-returning) and\r
- * pure (no side effects) functions using "volatile" and "const";\r
- * unfortunately, these then cause warnings under "-ansi -pedantic".\r
- * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of\r
- * these work for GNU C++ (modulo a slight glitch in the C++ grammar\r
- * in the distribution version of 2.5.5).\r
- */\r
-#if !__GNUC_PREREQ__(2, 5)\r
-#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */\r
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\r
-#define __dead __volatile\r
-#define __pure __const\r
-#endif\r
-#endif\r
-\r
- /* Delete pseudo-keywords wherever they are not available or needed. */\r
-#ifndef __dead\r
-#define __dead\r
-#define __pure\r
-#endif\r
-\r
-#if __GNUC_PREREQ__(2, 7)\r
-#define __unused __attribute__((__unused__))\r
-#define __noreturn __attribute__((__noreturn__))\r
-#else\r
-#define __unused /* delete */\r
-#define __noreturn /* delete */\r
-#endif\r
-\r
-#if __GNUC_PREREQ__(3, 1)\r
-#define __used __attribute__((__used__))\r
-#else\r
-#define __used __unused\r
-#endif\r
-\r
-#if __GNUC_PREREQ__(2, 7)\r
-#define __packed __attribute__((__packed__))\r
-#define __aligned(x) __attribute__((__aligned__(x)))\r
-#define __section(x) __attribute__((__section__(x)))\r
-#elif defined(__lint__)\r
-#define __packed /* delete */\r
-#define __aligned(x) /* delete */\r
-#define __section(x) /* delete */\r
-#else\r
-#define __packed error: no __packed for this compiler\r
-#define __aligned(x) error: no __aligned for this compiler\r
-#define __section(x) error: no __section for this compiler\r
-#endif\r
-\r
-/*\r
-* C99 defines the restrict type qualifier keyword, which was made available\r
-* in GCC 2.92.\r
-*/\r
-#if __STDC_VERSION__ >= 199901L\r
- #define __restrict restrict\r
-#else\r
- #if defined(_MSC_VER) || !__GNUC_PREREQ__(2, 92)\r
- #define __restrict /* delete __restrict when not supported */\r
- #endif\r
-#endif\r
-\r
-/*\r
-* C99 defines __func__ predefined identifier, which was made available\r
-* in GCC 2.95.\r
-*/\r
-#if !(__STDC_VERSION__ >= 199901L)\r
- #if defined(_MSC_VER)\r
- #define __func__ __FUNCTION__ /* Use the MS-specific predefined macro */\r
- #elif __GNUC_PREREQ__(2, 6)\r
- #define __func__ __PRETTY_FUNCTION__\r
- #elif __GNUC_PREREQ__(2, 4)\r
- #define __func__ __FUNCTION__\r
- #else\r
- #define __func__ ""\r
- #endif\r
-#endif /* !(__STDC_VERSION__ >= 199901L) */\r
-\r
-#define __RENAME(x)\r
-\r
- /*\r
- * A barrier to stop the optimizer from moving code or assume live\r
- * register values. This is gcc specific, the version is more or less\r
- * arbitrary, might work with older compilers.\r
- */\r
-#if __GNUC_PREREQ__(2, 95)\r
-#define __insn_barrier() __asm __volatile("":::"memory")\r
-#else\r
-#define __insn_barrier() /* */\r
-#endif\r
-\r
- /*\r
- * GNU C version 2.96 adds explicit branch prediction so that\r
- * the CPU back-end can hint the processor and also so that\r
- * code blocks can be reordered such that the predicted path\r
- * sees a more linear flow, thus improving cache behavior, etc.\r
- *\r
- * The following two macros provide us with a way to use this\r
- * compiler feature. Use __predict_true() if you expect the expression\r
- * to evaluate to true, and __predict_false() if you expect the\r
- * expression to evaluate to false.\r
- *\r
- * A few notes about usage:\r
- *\r
- * * Generally, __predict_false() error condition checks (unless\r
- * you have some _strong_ reason to do otherwise, in which case\r
- * document it), and/or __predict_true() `no-error' condition\r
- * checks, assuming you want to optimize for the no-error case.\r
- *\r
- * * Other than that, if you don't know the likelihood of a test\r
- * succeeding from empirical or other `hard' evidence, don't\r
- * make predictions.\r
- *\r
- * * These are meant to be used in places that are run `a lot'.\r
- * It is wasteful to make predictions in code that is run\r
- * seldomly (e.g. at subsystem initialization time) as the\r
- * basic block reordering that this affects can often generate\r
- * larger code.\r
- */\r
-#if __GNUC_PREREQ__(2, 96)\r
-#define __predict_true(exp) __builtin_expect((exp) != 0, 1)\r
-#define __predict_false(exp) __builtin_expect((exp) != 0, 0)\r
-#else\r
-#define __predict_true(exp) (exp)\r
-#define __predict_false(exp) (exp)\r
-#endif\r
-\r
-/* find least significant bit that is set */\r
-#define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask))\r
-\r
-#define __SHIFTOUT(__x, __mask) (((__x) & (__mask)) / __LOWEST_SET_BIT(__mask))\r
-#define __SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask))\r
-#define __SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask))\r
-\r
-#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */\r
-\r
- /* VC++, by default, defines wchar_t as an intrinsic type, equivalent to\r
- unsigned short. This conflicts which Standard C Library\r
- implementations which try to define wchar_t.\r
- Make sure that this behavior has been turned off by using\r
- /Zc:wchar_t- on the command line.\r
- */\r
- #ifdef _NATIVE_WCHAR_T_DEFINED\r
- #error You must specify /Zc:wchar_t- to the compiler to turn off intrinsic wchar_t.\r
- #endif\r
-\r
- /* Get rid of pre-defined macros that are misleading in this environment. */\r
- #undef _WIN32\r
- #undef _WIN64\r
-\r
- // Keep compiler quiet about casting from smaller to larger types\r
- #pragma warning ( disable : 4306 )\r
-\r
- #define __STDC__ 1\r
- #define __STDC_VERSION__ 199409L\r
- #define __STDC_HOSTED__ 1\r
-\r
-#endif /* defined(_MSC_VER) */\r
-extern int _fltused; // VC++ requires this if you use floating point. KEEP for all compilers.\r
-\r
-#define _Bool BOOLEAN\r
-#define _DIAGASSERT(e)\r
-\r
-// Types used to replace long so that it will have constant length regardless of compiler.\r
-typedef INT32 LONG32;\r
-typedef UINT32 ULONG32;\r
-typedef INT64 LONG64;\r
-typedef UINT64 ULONG64;\r
-\r
-typedef INTN EFI_LONG_T;\r
-typedef UINTN EFI_ULONG_T;\r
-\r
-/* These types reflect the compiler's size for long */\r
-#if defined(__GNUC__)\r
- #if __GNUC_PREREQ__(4,4)\r
- /* GCC 4.4 or later */\r
- typedef INTN LONGN;\r
- typedef UINTN ULONGN;\r
- #else\r
- /* minGW gcc variant */\r
- typedef INT32 LONGN;\r
- typedef UINT32 ULONGN;\r
- #endif /* __GNUC_PREREQ__(4,4) */\r
-#else /* NOT GCC */\r
- /* Microsoft or Intel compilers */\r
- typedef INT32 LONGN;\r
- typedef UINT32 ULONGN;\r
-#endif /* defined(__GNUC__) */\r
-\r
-#endif /* _EFI_CDEFS_H */\r