blob: 4c9e5eabdee2ce09b3754ed36b1fbd56fc25e25e [file] [log] [blame]
Fred Drake31d485c2004-08-03 07:06:22 +00001/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
3*/
4
Thomas Wouters0e3f5912006-08-11 14:57:12 +00005#ifndef Expat_External_INCLUDED
6#define Expat_External_INCLUDED 1
7
Fred Drake31d485c2004-08-03 07:06:22 +00008/* External API definitions */
9
Benjamin Peterson091d0172014-02-04 10:10:55 -050010/* Namespace external symbols to allow multiple libexpat version to
11 co-exist. */
12#include "pyexpatns.h"
13
Gregory P. Smith7c6309c2012-07-14 14:12:35 -070014#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
Fred Drake31d485c2004-08-03 07:06:22 +000015#define XML_USE_MSC_EXTENSIONS 1
16#endif
17
18/* Expat tries very hard to make the API boundary very specifically
19 defined. There are two macros defined to control this boundary;
20 each of these can be defined before including this header to
21 achieve some different behavior, but doing so it not recommended or
22 tested frequently.
23
24 XMLCALL - The calling convention to use for all calls across the
25 "library boundary." This will default to cdecl, and
26 try really hard to tell the compiler that's what we
27 want.
28
29 XMLIMPORT - Whatever magic is needed to note that a function is
30 to be imported from a dynamically loaded library
31 (.dll, .so, or .sl, depending on your platform).
32
33 The XMLCALL macro was added in Expat 1.95.7. The only one which is
34 expected to be directly useful in client code is XMLCALL.
35
36 Note that on at least some Unix versions, the Expat library must be
37 compiled with the cdecl calling convention as the default since
38 system headers may assume the cdecl convention.
39*/
40#ifndef XMLCALL
Gregory P. Smith7c6309c2012-07-14 14:12:35 -070041#if defined(_MSC_VER)
Fred Drake31d485c2004-08-03 07:06:22 +000042#define XMLCALL __cdecl
Gregory P. Smith7c6309c2012-07-14 14:12:35 -070043#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
Fred Drake31d485c2004-08-03 07:06:22 +000044#define XMLCALL __attribute__((cdecl))
45#else
46/* For any platform which uses this definition and supports more than
47 one calling convention, we need to extend this definition to
48 declare the convention used on that platform, if it's possible to
49 do so.
50
51 If this is the case for your platform, please file a bug report
52 with information on how to identify your platform via the C
53 pre-processor and how to specify the same calling convention as the
54 platform's malloc() implementation.
55*/
56#define XMLCALL
57#endif
58#endif /* not defined XMLCALL */
59
60
61#if !defined(XML_STATIC) && !defined(XMLIMPORT)
62#ifndef XML_BUILDING_EXPAT
63/* using Expat from an application */
64
65#ifdef XML_USE_MSC_EXTENSIONS
66#define XMLIMPORT __declspec(dllimport)
67#endif
68
69#endif
70#endif /* not defined XML_STATIC */
71
Victor Stinner23ec4b52017-06-15 00:54:36 +020072#if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
73#define XMLIMPORT __attribute__ ((visibility ("default")))
74#endif
Thomas Wouters0e3f5912006-08-11 14:57:12 +000075
Fred Drake31d485c2004-08-03 07:06:22 +000076/* If we didn't define it above, define it away: */
77#ifndef XMLIMPORT
78#define XMLIMPORT
79#endif
80
Victor Stinner23ec4b52017-06-15 00:54:36 +020081#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
82#define XML_ATTR_MALLOC __attribute__((__malloc__))
83#else
84#define XML_ATTR_MALLOC
85#endif
86
87#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
88#define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
89#else
90#define XML_ATTR_ALLOC_SIZE(x)
91#endif
Fred Drake31d485c2004-08-03 07:06:22 +000092
93#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
94
95#ifdef __cplusplus
96extern "C" {
97#endif
98
99#ifdef XML_UNICODE_WCHAR_T
Victor Stinner5ff71322017-06-21 14:39:22 +0200100# define XML_UNICODE
101# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
102# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
103# endif
Fred Drake31d485c2004-08-03 07:06:22 +0000104#endif
105
106#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
107#ifdef XML_UNICODE_WCHAR_T
108typedef wchar_t XML_Char;
109typedef wchar_t XML_LChar;
110#else
111typedef unsigned short XML_Char;
112typedef char XML_LChar;
113#endif /* XML_UNICODE_WCHAR_T */
114#else /* Information is UTF-8 encoded. */
115typedef char XML_Char;
116typedef char XML_LChar;
117#endif /* XML_UNICODE */
Thomas Wouters0e3f5912006-08-11 14:57:12 +0000118
119#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
120#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
121typedef __int64 XML_Index;
122typedef unsigned __int64 XML_Size;
123#else
124typedef long long XML_Index;
125typedef unsigned long long XML_Size;
126#endif
127#else
128typedef long XML_Index;
129typedef unsigned long XML_Size;
130#endif /* XML_LARGE_SIZE */
131
132#ifdef __cplusplus
133}
134#endif
135
136#endif /* not Expat_External_INCLUDED */