xref: /freebsd/contrib/expat/lib/expat_external.h (revision 1c05a6ea6b849ff95e539c31adea887c644a6a01)
1 /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
2    See the file COPYING for copying permission.
3 */
4 
5 #ifndef Expat_External_INCLUDED
6 #define Expat_External_INCLUDED 1
7 
8 /* External API definitions */
9 
10 #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
11 #define XML_USE_MSC_EXTENSIONS 1
12 #endif
13 
14 /* Expat tries very hard to make the API boundary very specifically
15    defined.  There are two macros defined to control this boundary;
16    each of these can be defined before including this header to
17    achieve some different behavior, but doing so it not recommended or
18    tested frequently.
19 
20    XMLCALL    - The calling convention to use for all calls across the
21                 "library boundary."  This will default to cdecl, and
22                 try really hard to tell the compiler that's what we
23                 want.
24 
25    XMLIMPORT  - Whatever magic is needed to note that a function is
26                 to be imported from a dynamically loaded library
27                 (.dll, .so, or .sl, depending on your platform).
28 
29    The XMLCALL macro was added in Expat 1.95.7.  The only one which is
30    expected to be directly useful in client code is XMLCALL.
31 
32    Note that on at least some Unix versions, the Expat library must be
33    compiled with the cdecl calling convention as the default since
34    system headers may assume the cdecl convention.
35 */
36 #ifndef XMLCALL
37 #if defined(_MSC_VER)
38 #define XMLCALL __cdecl
39 #elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
40 #define XMLCALL __attribute__((cdecl))
41 #else
42 /* For any platform which uses this definition and supports more than
43    one calling convention, we need to extend this definition to
44    declare the convention used on that platform, if it's possible to
45    do so.
46 
47    If this is the case for your platform, please file a bug report
48    with information on how to identify your platform via the C
49    pre-processor and how to specify the same calling convention as the
50    platform's malloc() implementation.
51 */
52 #define XMLCALL
53 #endif
54 #endif  /* not defined XMLCALL */
55 
56 
57 #if !defined(XML_STATIC) && !defined(XMLIMPORT)
58 #ifndef XML_BUILDING_EXPAT
59 /* using Expat from an application */
60 
61 #ifdef XML_USE_MSC_EXTENSIONS
62 #define XMLIMPORT __declspec(dllimport)
63 #endif
64 
65 #endif
66 #endif  /* not defined XML_STATIC */
67 
68 #if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
69 #define XMLIMPORT __attribute__ ((visibility ("default")))
70 #endif
71 
72 /* If we didn't define it above, define it away: */
73 #ifndef XMLIMPORT
74 #define XMLIMPORT
75 #endif
76 
77 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
78 #define XML_ATTR_MALLOC __attribute__((__malloc__))
79 #else
80 #define XML_ATTR_MALLOC
81 #endif
82 
83 #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
84 #define XML_ATTR_ALLOC_SIZE(x)  __attribute__((__alloc_size__(x)))
85 #else
86 #define XML_ATTR_ALLOC_SIZE(x)
87 #endif
88 
89 #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
90 
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94 
95 #ifdef XML_UNICODE_WCHAR_T
96 #define XML_UNICODE
97 #endif
98 
99 #ifdef XML_UNICODE     /* Information is UTF-16 encoded. */
100 #ifdef XML_UNICODE_WCHAR_T
101 typedef wchar_t XML_Char;
102 typedef wchar_t XML_LChar;
103 #else
104 typedef unsigned short XML_Char;
105 typedef char XML_LChar;
106 #endif /* XML_UNICODE_WCHAR_T */
107 #else                  /* Information is UTF-8 encoded. */
108 typedef char XML_Char;
109 typedef char XML_LChar;
110 #endif /* XML_UNICODE */
111 
112 #ifdef XML_LARGE_SIZE  /* Use large integers for file/stream positions. */
113 #if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
114 typedef __int64 XML_Index;
115 typedef unsigned __int64 XML_Size;
116 #else
117 typedef long long XML_Index;
118 typedef unsigned long long XML_Size;
119 #endif
120 #else
121 typedef long XML_Index;
122 typedef unsigned long XML_Size;
123 #endif /* XML_LARGE_SIZE */
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* not Expat_External_INCLUDED */
130