2 Intel Open Source License
4 Copyright (c) 2002-2007 Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are
10 Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer. Redistributions
12 in binary form must reproduce the above copyright notice, this list of
13 conditions and the following disclaimer in the documentation and/or
14 other materials provided with the distribution. Neither the name of
15 the Intel Corporation nor the names of its contributors may be used to
16 endorse or promote products derived from this software without
17 specific prior written permission.
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
23 ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 /// @file xed-portability.h
32 /// @author Mark Charney <mark.charney@intel.com>
34 #ifndef _XED_PORTABILITY_H_
35 # define _XED_PORTABILITY_H_
36 # include <xed/xed-types.h>
38 #define STATIC_CAST(x,y) ((x) (y))
39 #define REINTERPRET_CAST(x,y) ((x) (y))
41 XED_DLL_EXPORT xed_uint_t xed_strlen(const char* s);
42 XED_DLL_EXPORT void xed_strcat(char* dst, const char* src);
43 XED_DLL_EXPORT void xed_strcpy(char* dst, const char* src);
44 /// returns the number of bytes remaining for the next use of #xed_strncpy() or #xed_strncat() .
45 XED_DLL_EXPORT int xed_strncpy(char* dst, const char* src, int len);
46 /// returns the number of bytes remaining for the next use of #xed_strncpy() or #xed_strncat() .
47 XED_DLL_EXPORT int xed_strncat(char* dst, const char* src, int len);
51 #if !defined(__INTEL_COMPILER)
52 # if defined(_WIN32) && defined(_MSC_VER)
57 # if defined(_WIN32) && defined(_MSC_VER)
62 # if defined(_WIN32) && defined(_MSC_VER)
69 /* I've had compatibilty problems here so I'm using a trivial indirection */
71 # if defined(__CYGWIN__)
72 /* cygwin's gcc 3.4.4 on windows complains */
73 # define XED_FMT_X "%lx"
74 # define XED_FMT_08X "%08lx"
75 # define XED_FMT_D "%ld"
76 # define XED_FMT_U "%lu"
77 # define XED_FMT_9U "%9lu"
79 # define XED_FMT_X "%x"
80 # define XED_FMT_08X "%08x"
81 # define XED_FMT_D "%d"
82 # define XED_FMT_U "%u"
83 # define XED_FMT_9U "%9u"
86 # define XED_FMT_X "%x"
87 # define XED_FMT_08X "%08x"
88 # define XED_FMT_D "%d"
89 # define XED_FMT_U "%u"
90 # define XED_FMT_9U "%9u"
93 #if defined(__GNUC__) && defined(__LP64__) && !defined(__APPLE__)
94 # define XED_FMT_LX "%lx"
95 # define XED_FMT_LU "%lu"
96 # define XED_FMT_LD "%ld"
97 # define XED_FMT_LX16 "%016lx"
99 # define XED_FMT_LX "%llx"
100 # define XED_FMT_LU "%llu"
101 # define XED_FMT_LD "%lld"
102 # define XED_FMT_LX16 "%016llx"
107 # define XED_FMT_SIZET "%ld"
109 # define XED_FMT_SIZET "%d"
112 #if defined(__GNUC__)
113 # define XED_INLINE inline
114 # define XED_NORETURN __attribute__ ((noreturn))
116 # define XED_NOINLINE
118 # define XED_NOINLINE __attribute__ ((noinline))
121 # define XED_INLINE __inline
122 # if defined(XED_MSVC6)
123 # define XED_NOINLINE
125 # define XED_NOINLINE __declspec(noinline)
127 # define XED_NORETURN __declspec(noreturn)
130 #endif // _XED_PORTABILITY_H_
132 ////////////////////////////////////////////////////////////////////////////
134 //pref: "../../xed-portability.c"