xed-portability.h

Go to the documentation of this file.
00001 /*BEGIN_LEGAL 
00002 Intel Open Source License 
00003 
00004 Copyright (c) 2002-2011 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 
00054 XED_DLL_EXPORT xed_uint_t xed_strlen(const char* s);
00055 XED_DLL_EXPORT void xed_strcat(char* dst, const char* src);
00056 XED_DLL_EXPORT void xed_strcpy(char* dst, const char* src);
00057 
00060 XED_DLL_EXPORT int xed_strncpy(char* dst, const char* src,  int len);
00061 
00064 XED_DLL_EXPORT int xed_strncat(char* dst, const char* src,  int len);
00065 
00066 #if defined(__INTEL_COMPILER)
00067 # if defined(_WIN32) && defined(_MSC_VER)
00068 #   if _MSC_VER >= 1400
00069 #     define XED_MSVC8_OR_LATER 1
00070 #   endif
00071 # endif
00072 #endif
00073 
00074 /* recognize VC98 */
00075 #if !defined(__INTEL_COMPILER)
00076 # if defined(_WIN32) && defined(_MSC_VER)
00077 #   if _MSC_VER == 1200
00078 #     define XED_MSVC6 1
00079 #   endif
00080 # endif
00081 # if defined(_WIN32) && defined(_MSC_VER)
00082 #   if _MSC_VER == 1310
00083 #     define XED_MSVC7 1
00084 #   endif
00085 # endif
00086 # if defined(_WIN32) && defined(_MSC_VER)
00087 #   if _MSC_VER >= 1400
00088 #     define XED_MSVC8_OR_LATER 1
00089 #   endif
00090 #   if _MSC_VER == 1400
00091 #     define XED_MSVC8 1
00092 #   endif
00093 #   if _MSC_VER == 1500
00094 #     define XED_MSVC9 1
00095 #   endif
00096 #   if _MSC_VER >= 1500
00097 #     define XED_MSVC9_OR_LATER 1
00098 #   endif
00099 #   if _MSC_VER == 1600
00100 #     define XED_MSVC10 1
00101 #   endif
00102 #   if _MSC_VER >= 1600
00103 #     define XED_MSVC10_OR_LATER 1
00104 #   endif
00105 # endif
00106 #endif
00107 
00108 /* I've had compatibilty problems here so I'm using a trivial indirection */
00109 #if defined(__GNUC__)
00110 #  if defined(__CYGWIN__)
00111       /* cygwin's gcc 3.4.4 on windows  complains */
00112 #    define XED_FMT_X "%lx"
00113 #    define XED_FMT_08X "%08lx"
00114 #    define XED_FMT_D "%ld"
00115 #    define XED_FMT_U "%lu"
00116 #    define XED_FMT_9U "%9lu"
00117 #  else
00118 #    define XED_FMT_X "%x"
00119 #    define XED_FMT_08X "%08x"
00120 #    define XED_FMT_D "%d"
00121 #    define XED_FMT_U "%u"
00122 #    define XED_FMT_9U "%9u"
00123 #  endif
00124 #else
00125 #  define XED_FMT_X "%x"
00126 #  define XED_FMT_08X "%08x"
00127 #  define XED_FMT_D "%d"
00128 #  define XED_FMT_U "%u"
00129 #  define XED_FMT_9U "%9u"
00130 #endif
00131 
00132 #if defined(__GNUC__) && defined(__LP64__) && !defined(__APPLE__)
00133 # define XED_FMT_LX "%lx"
00134 # define XED_FMT_LU "%lu"
00135 # define XED_FMT_LU12 "%12lu"
00136 # define XED_FMT_LD "%ld"
00137 # define XED_FMT_LX16 "%016lx"
00138 # define XED_FMT_SIZET "%lu"
00139 #else
00140 # define XED_FMT_LX "%llx"
00141 # define XED_FMT_LU "%llu"
00142 # define XED_FMT_LU12 "%12llu"
00143 # define XED_FMT_LD "%lld"
00144 # define XED_FMT_LX16 "%016llx"
00145 # define XED_FMT_SIZET "%llu"
00146 #endif
00147 
00148 #if defined(__LP64__) || defined (_M_X64) 
00149 # define XED_64B 1
00150 #endif
00151 
00152 #if defined(_M_IA64)
00153 # define XED_IPF
00154 # define XED_FMT_SIZET "%lu"
00155 #endif
00156 
00157 #if defined(__GNUC__)    
00158      /* gcc4.2.x has a bug with c99/gnu99 inlining */
00159 #  if __GNUC__ == 4 && __GNUC_MINOR__ == 2
00160 #    define XED_INLINE inline
00161 #  else
00162 #    if __GNUC__ == 2
00163 #       define XED_INLINE 
00164 #    else 
00165 #       define XED_INLINE inline
00166 #    endif
00167 # endif
00168 # define XED_NORETURN __attribute__ ((noreturn))
00169 # if __GNUC__ == 2
00170 #   define XED_NOINLINE 
00171 # else
00172 #   define XED_NOINLINE __attribute__ ((noinline))
00173 # endif
00174 #else
00175 # define XED_INLINE __inline
00176 # if defined(XED_MSVC6)
00177 #   define XED_NOINLINE 
00178 # else
00179 #   define XED_NOINLINE __declspec(noinline)
00180 # endif
00181 # define XED_NORETURN __declspec(noreturn)
00182 #endif
00183 
00184 
00185 
00186 #define XED_MAX(a, b) (((a) > (b)) ? (a):(b))
00187 #define XED_MIN(a, b) (((a) < (b)) ? (a):(b))
00188 
00189 
00190 #endif  // _XED_PORTABILITY_H_
00191 
00193 //Local Variables:
00194 //pref: "../../xed-portability.c"
00195 //End:

Generated on Tue Nov 22 12:27:53 2011 for XED2 by  doxygen 1.4.6