xed-portability.h

Go to the documentation of this file.
00001 /*BEGIN_LEGAL 
00002 Intel Open Source License 
00003 
00004 Copyright (c) 2002-2012 Intel Corporation. All rights reserved.
00005  
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are
00008 met:
00009 
00010 Redistributions of source code must retain the above copyright notice,
00011 this list of conditions and the following disclaimer.  Redistributions
00012 in binary form must reproduce the above copyright notice, this list of
00013 conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.  Neither the name of
00015 the Intel Corporation nor the names of its contributors may be used to
00016 endorse or promote products derived from this software without
00017 specific prior written permission.
00018  
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00022 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
00023 ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00024 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00025 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00026 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00027 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00028 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00029 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 END_LEGAL */
00033 
00034 #ifndef _XED_PORTABILITY_H_
00035 # define _XED_PORTABILITY_H_
00036 # include "xed-types.h"
00037 
00038 #if defined(__FreeBSD__)
00039 # define XED_BSD
00040 #endif
00041 #if defined(__linux__)
00042 # define XED_LINUX
00043 #endif
00044 #if defined(_MSC_VER)
00045 # define XED_WINDOWS
00046 #endif
00047 #if defined(__APPLE__)
00048 # define XED_MAC
00049 #endif
00050 
00051 #define XED_STATIC_CAST(x,y) ((x) (y))
00052 #define XED_REINTERPRET_CAST(x,y) ((x) (y))
00053 #define XED_CAST(x,y) ((x) (y))
00054 
00055 XED_DLL_EXPORT xed_uint_t xed_strlen(const char* s);
00056 XED_DLL_EXPORT void xed_strcat(char* dst, const char* src);
00057 XED_DLL_EXPORT void xed_strcpy(char* dst, const char* src);
00058 
00061 XED_DLL_EXPORT int xed_strncpy(char* dst, const char* src,  int len);
00062 
00065 XED_DLL_EXPORT int xed_strncat(char* dst, const char* src,  int len);
00066 
00067 #if defined(__INTEL_COMPILER)
00068 # if defined(_WIN32) && defined(_MSC_VER)
00069 #   if _MSC_VER >= 1400
00070 #     define XED_MSVC8_OR_LATER 1
00071 #   endif
00072 # endif
00073 #endif
00074 
00075 /* recognize VC98 */
00076 #if !defined(__INTEL_COMPILER)
00077 # if defined(_WIN32) && defined(_MSC_VER)
00078 #   if _MSC_VER == 1200
00079 #     define XED_MSVC6 1
00080 #   endif
00081 # endif
00082 # if defined(_WIN32) && defined(_MSC_VER)
00083 #   if _MSC_VER == 1310
00084 #     define XED_MSVC7 1
00085 #   endif
00086 # endif
00087 # if defined(_WIN32) && defined(_MSC_VER)
00088 #   if _MSC_VER >= 1400
00089 #     define XED_MSVC8_OR_LATER 1
00090 #   endif
00091 #   if _MSC_VER == 1400
00092 #     define XED_MSVC8 1
00093 #   endif
00094 #   if _MSC_VER == 1500
00095 #     define XED_MSVC9 1
00096 #   endif
00097 #   if _MSC_VER >= 1500
00098 #     define XED_MSVC9_OR_LATER 1
00099 #   endif
00100 #   if _MSC_VER == 1600
00101 #     define XED_MSVC10 1
00102 #   endif
00103 #   if _MSC_VER >= 1600
00104 #     define XED_MSVC10_OR_LATER 1
00105 #   endif
00106 # endif
00107 #endif
00108 
00109 /* I've had compatibilty problems here so I'm using a trivial indirection */
00110 #if defined(__GNUC__)
00111 #  if defined(__CYGWIN__)
00112       /* cygwin's gcc 3.4.4 on windows  complains */
00113 #    define XED_FMT_X "%lx"
00114 #    define XED_FMT_08X "%08lx"
00115 #    define XED_FMT_D "%ld"
00116 #    define XED_FMT_U "%lu"
00117 #    define XED_FMT_9U "%9lu"
00118 #  else
00119 #    define XED_FMT_X "%x"
00120 #    define XED_FMT_08X "%08x"
00121 #    define XED_FMT_D "%d"
00122 #    define XED_FMT_U "%u"
00123 #    define XED_FMT_9U "%9u"
00124 #  endif
00125 #else
00126 #  define XED_FMT_X "%x"
00127 #  define XED_FMT_08X "%08x"
00128 #  define XED_FMT_D "%d"
00129 #  define XED_FMT_U "%u"
00130 #  define XED_FMT_9U "%9u"
00131 #endif
00132 
00133 #if defined(__GNUC__) && defined(__LP64__) && !defined(__APPLE__)
00134 # define XED_FMT_LX "%lx"
00135 # define XED_FMT_LU "%lu"
00136 # define XED_FMT_LU12 "%12lu"
00137 # define XED_FMT_LD "%ld"
00138 # define XED_FMT_LX16 "%016lx"
00139 # define XED_FMT_SIZET "%lu"
00140 #else
00141 # define XED_FMT_LX "%llx"
00142 # define XED_FMT_LU "%llu"
00143 # define XED_FMT_LU12 "%12llu"
00144 # define XED_FMT_LD "%lld"
00145 # define XED_FMT_LX16 "%016llx"
00146 # define XED_FMT_SIZET "%llu"
00147 #endif
00148 
00149 #if defined(__LP64__) || defined (_M_X64) 
00150 # define XED_64B 1
00151 #endif
00152 
00153 #if defined(_M_IA64)
00154 # define XED_IPF
00155 # define XED_FMT_SIZET "%lu"
00156 #endif
00157 
00158 #if defined(__GNUC__)    
00159      /* gcc4.2.x has a bug with c99/gnu99 inlining */
00160 #  if __GNUC__ == 4 && __GNUC_MINOR__ == 2
00161 #    define XED_INLINE inline
00162 #  else
00163 #    if __GNUC__ == 2
00164 #       define XED_INLINE 
00165 #    else 
00166 #       define XED_INLINE inline
00167 #    endif
00168 # endif
00169 # define XED_NORETURN __attribute__ ((noreturn))
00170 # if __GNUC__ == 2
00171 #   define XED_NOINLINE 
00172 # else
00173 #   define XED_NOINLINE __attribute__ ((noinline))
00174 # endif
00175 #else
00176 # define XED_INLINE __inline
00177 # if defined(XED_MSVC6)
00178 #   define XED_NOINLINE 
00179 # else
00180 #   define XED_NOINLINE __declspec(noinline)
00181 # endif
00182 # define XED_NORETURN __declspec(noreturn)
00183 #endif
00184 
00185 
00186 
00187 #define XED_MAX(a, b) (((a) > (b)) ? (a):(b))
00188 #define XED_MIN(a, b) (((a) < (b)) ? (a):(b))
00189 
00190 
00191 #endif  // _XED_PORTABILITY_H_
00192 
00194 //Local Variables:
00195 //pref: "../../xed-portability.c"
00196 //End:

Generated on Wed Aug 8 00:23:42 2012 for XED2 by  doxygen 1.4.6