xed-portability.h

Go to the documentation of this file.
00001 /*BEGIN_LEGAL 
00002 Intel Open Source License 
00003 
00004 Copyright (c) 2002-2009 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 #define STATIC_CAST(x,y) ((x) (y))
00039 #define REINTERPRET_CAST(x,y) ((x) (y))
00040 
00041 XED_DLL_EXPORT xed_uint_t xed_strlen(const char* s);
00042 XED_DLL_EXPORT void xed_strcat(char* dst, const char* src);
00043 XED_DLL_EXPORT void xed_strcpy(char* dst, const char* src);
00045 XED_DLL_EXPORT int xed_strncpy(char* dst, const char* src,  int len);
00047 XED_DLL_EXPORT int xed_strncat(char* dst, const char* src,  int len);
00048 
00049 
00050 /* recognize VC98 */
00051 #if !defined(__INTEL_COMPILER)
00052 # if defined(_WIN32) && defined(_MSC_VER)
00053 #   if _MSC_VER == 1200
00054 #     define XED_MSVC6 1
00055 #   endif
00056 # endif
00057 # if defined(_WIN32) && defined(_MSC_VER)
00058 #   if _MSC_VER == 1310
00059 #     define XED_MSVC7 1
00060 #   endif
00061 # endif
00062 # if defined(_WIN32) && defined(_MSC_VER)
00063 #   if _MSC_VER >= 1400
00064 #     define XED_MSVC8_OR_LATER 1
00065 #   endif
00066 #   if _MSC_VER == 1400
00067 #     define XED_MSVC8 1
00068 #   endif
00069 #   if _MSC_VER == 1500
00070 #     define XED_MSVC9 1
00071 #   endif
00072 # endif
00073 #endif
00074 
00075 /* I've had compatibilty problems here so I'm using a trivial indirection */
00076 #if defined(__GNUC__)
00077 #  if defined(__CYGWIN__)
00078       /* cygwin's gcc 3.4.4 on windows  complains */
00079 #    define XED_FMT_X "%lx"
00080 #    define XED_FMT_08X "%08lx"
00081 #    define XED_FMT_D "%ld"
00082 #    define XED_FMT_U "%lu"
00083 #    define XED_FMT_9U "%9lu"
00084 #  else
00085 #    define XED_FMT_X "%x"
00086 #    define XED_FMT_08X "%08x"
00087 #    define XED_FMT_D "%d"
00088 #    define XED_FMT_U "%u"
00089 #    define XED_FMT_9U "%9u"
00090 #  endif
00091 #else
00092 #  define XED_FMT_X "%x"
00093 #  define XED_FMT_08X "%08x"
00094 #  define XED_FMT_D "%d"
00095 #  define XED_FMT_U "%u"
00096 #  define XED_FMT_9U "%9u"
00097 #endif
00098 
00099 #if defined(__GNUC__) && defined(__LP64__) && !defined(__APPLE__)
00100 # define XED_FMT_LX "%lx"
00101 # define XED_FMT_LU "%lu"
00102 # define XED_FMT_LU12 "%12lu"
00103 # define XED_FMT_LD "%ld"
00104 # define XED_FMT_LX16 "%016lx"
00105 #else
00106 # define XED_FMT_LX "%llx"
00107 # define XED_FMT_LU "%llu"
00108 # define XED_FMT_LU12 "%12llu"
00109 # define XED_FMT_LD "%lld"
00110 # define XED_FMT_LX16 "%016llx"
00111 #endif
00112 
00113 #if defined(_M_IA64)
00114 # define XED_IPF
00115 # define XED_FMT_SIZET "%ld"
00116 #else
00117 # define XED_FMT_SIZET "%d"
00118 #endif
00119 
00120 #if defined(__GNUC__) 
00121 # define XED_INLINE inline
00122 # define XED_NORETURN __attribute__ ((noreturn))
00123 # if __GNUC__ == 2
00124 #   define XED_NOINLINE 
00125 # else
00126 #   define XED_NOINLINE __attribute__ ((noinline))
00127 # endif
00128 #else
00129 # define XED_INLINE __inline
00130 # if defined(XED_MSVC6)
00131 #   define XED_NOINLINE 
00132 # else
00133 #   define XED_NOINLINE __declspec(noinline)
00134 # endif
00135 # define XED_NORETURN __declspec(noreturn)
00136 #endif
00137 
00138 
00139 
00140 #define XED_MAX(a, b) (((a) > (b)) ? (a):(b))
00141 #define XED_MIN(a, b) (((a) < (b)) ? (a):(b))
00142 
00143 #if defined(__LP64__) || defined (_M_X64) 
00144 # define XED_64B 1
00145 #endif
00146 
00147 #endif  // _XED_PORTABILITY_H_
00148 
00150 //Local Variables:
00151 //pref: "../../xed-portability.c"
00152 //End:

Generated on Tue Dec 15 03:23:59 2009 for XED2 by  doxygen 1.4.6