xref: /freebsd/contrib/expat/lib/expat_external.h (revision d6eb98610fa65663bf0df4574b7cb2c5c4ffda71)
1 /*
2                             __  __            _
3                          ___\ \/ /_ __   __ _| |_
4                         / _ \\  /| '_ \ / _` | __|
5                        |  __//  \| |_) | (_| | |_
6                         \___/_/\_\ .__/ \__,_|\__|
7                                  |_| XML parser
8 
9    Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10    Copyright (c) 2000-2017 Expat development team
11    Licensed under the MIT license:
12 
13    Permission is  hereby granted,  free of charge,  to any  person obtaining
14    a  copy  of  this  software   and  associated  documentation  files  (the
15    "Software"),  to  deal in  the  Software  without restriction,  including
16    without  limitation the  rights  to use,  copy,  modify, merge,  publish,
17    distribute, sublicense, and/or sell copies of the Software, and to permit
18    persons  to whom  the Software  is  furnished to  do so,  subject to  the
19    following conditions:
20 
21    The above copyright  notice and this permission notice  shall be included
22    in all copies or substantial portions of the Software.
23 
24    THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
25    EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
26    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
27    NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
28    DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
29    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
30    USE OR OTHER DEALINGS IN THE SOFTWARE.
31 */
32 
33 #ifndef Expat_External_INCLUDED
34 #define Expat_External_INCLUDED 1
35 
36 /* External API definitions */
37 
38 #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
39 # define XML_USE_MSC_EXTENSIONS 1
40 #endif
41 
42 /* Expat tries very hard to make the API boundary very specifically
43    defined.  There are two macros defined to control this boundary;
44    each of these can be defined before including this header to
45    achieve some different behavior, but doing so it not recommended or
46    tested frequently.
47 
48    XMLCALL    - The calling convention to use for all calls across the
49                 "library boundary."  This will default to cdecl, and
50                 try really hard to tell the compiler that's what we
51                 want.
52 
53    XMLIMPORT  - Whatever magic is needed to note that a function is
54                 to be imported from a dynamically loaded library
55                 (.dll, .so, or .sl, depending on your platform).
56 
57    The XMLCALL macro was added in Expat 1.95.7.  The only one which is
58    expected to be directly useful in client code is XMLCALL.
59 
60    Note that on at least some Unix versions, the Expat library must be
61    compiled with the cdecl calling convention as the default since
62    system headers may assume the cdecl convention.
63 */
64 #ifndef XMLCALL
65 # if defined(_MSC_VER)
66 #  define XMLCALL __cdecl
67 # elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
68 #  define XMLCALL __attribute__((cdecl))
69 # else
70 /* For any platform which uses this definition and supports more than
71    one calling convention, we need to extend this definition to
72    declare the convention used on that platform, if it's possible to
73    do so.
74 
75    If this is the case for your platform, please file a bug report
76    with information on how to identify your platform via the C
77    pre-processor and how to specify the same calling convention as the
78    platform's malloc() implementation.
79 */
80 #  define XMLCALL
81 # endif
82 #endif  /* not defined XMLCALL */
83 
84 
85 #if !defined(XML_STATIC) && !defined(XMLIMPORT)
86 # ifndef XML_BUILDING_EXPAT
87 /* using Expat from an application */
88 
89 #  ifdef XML_USE_MSC_EXTENSIONS
90 #   define XMLIMPORT __declspec(dllimport)
91 #  endif
92 
93 # endif
94 #endif  /* not defined XML_STATIC */
95 
96 #if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
97 # define XMLIMPORT __attribute__ ((visibility ("default")))
98 #endif
99 
100 /* If we didn't define it above, define it away: */
101 #ifndef XMLIMPORT
102 # define XMLIMPORT
103 #endif
104 
105 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
106 # define XML_ATTR_MALLOC __attribute__((__malloc__))
107 #else
108 # define XML_ATTR_MALLOC
109 #endif
110 
111 #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
112 # define XML_ATTR_ALLOC_SIZE(x)  __attribute__((__alloc_size__(x)))
113 #else
114 # define XML_ATTR_ALLOC_SIZE(x)
115 #endif
116 
117 #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
118 
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122 
123 #ifdef XML_UNICODE_WCHAR_T
124 # ifndef XML_UNICODE
125 #  define XML_UNICODE
126 # endif
127 # if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
128 #  error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
129 # endif
130 #endif
131 
132 #ifdef XML_UNICODE     /* Information is UTF-16 encoded. */
133 # ifdef XML_UNICODE_WCHAR_T
134 typedef wchar_t XML_Char;
135 typedef wchar_t XML_LChar;
136 # else
137 typedef unsigned short XML_Char;
138 typedef char XML_LChar;
139 # endif /* XML_UNICODE_WCHAR_T */
140 #else                  /* Information is UTF-8 encoded. */
141 typedef char XML_Char;
142 typedef char XML_LChar;
143 #endif /* XML_UNICODE */
144 
145 #ifdef XML_LARGE_SIZE  /* Use large integers for file/stream positions. */
146 # if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
147 typedef __int64 XML_Index;
148 typedef unsigned __int64 XML_Size;
149 # else
150 typedef long long XML_Index;
151 typedef unsigned long long XML_Size;
152 # endif
153 #else
154 typedef long XML_Index;
155 typedef unsigned long XML_Size;
156 #endif /* XML_LARGE_SIZE */
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* not Expat_External_INCLUDED */
163