2 * Copyright 2008, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without 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 COPYRIGHT
23 * OWNER OR 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.
32 #ifndef _PORTABILITY_H
33 #define _PORTABILITY_H
39 # include "win/port_win.h"
41 # include <sys/types.h>
43 #endif /*NACL_WINDOWS*/
46 #include "osx/port_osx.h"
49 // MSVC supports "inline" only in C++
51 # define INLINE __inline
53 # define INLINE inline
58 # define DLLEXPORT __declspec(dllexport)
62 # define DLLEXPORT __attribute__ ((visibility("default")))
64 # error "what platform?"
69 # define UNREFERENCED_PARAMETER(P) (P)
71 # define UNREFERENCED_PARAMETER(P) do { ; } while (0)
75 # define NORETURN __declspec(noreturn)
77 # define NORETURN __attribute__((noreturn)) /* assumes gcc */
78 # define _cdecl /* empty */
82 # define THREAD __declspec(thread)
84 # define THREAD __thread
89 Per C99 7.8.14, define __STDC_CONSTANT_MACROS before including <stdint.h>
90 to get the INTn_C and UINTn_C macros for integer constants. It's difficult
91 to guarantee any specific ordering of header includes, so it's difficult to
92 guarantee that the INTn_C macros can be defined by including <stdint.h> at
93 any specific point. Provide GG_INTn_C macros instead.
96 #define GG_INT8_C(x) (x)
97 #define GG_INT16_C(x) (x)
98 #define GG_INT32_C(x) (x)
99 #define GG_INT64_C(x) GG_LONGLONG(x)
101 #define GG_UINT8_C(x) (x ## U)
102 #define GG_UINT16_C(x) (x ## U)
103 #define GG_UINT32_C(x) (x ## U)
104 #define GG_UINT64_C(x) GG_ULONGLONG(x)
107 #define SNPRINTF _snprintf
109 #define SNPRINTF snprintf
113 * printf macros for size_t, in the style of inttypes.h. this is
114 * needed since the windows compiler does not understand %zd etc.
117 # define __PRIS_PREFIX
119 # define __PRIS_PREFIX "z"
122 #define PRIdS __PRIS_PREFIX "d"
123 #define PRIxS __PRIS_PREFIX "x"
124 #define PRIuS __PRIS_PREFIX "u"
125 #define PRIXS __PRIS_PREFIX "X"
126 #define PRIoS __PRIS_PREFIX "o"
128 #endif // _PORTABILITY_H