xref: /freebsd/contrib/expat/lib/internal.h (revision 6b2c1e49da284f28ec7b52f7c031474087e37104)
15bb6a25fSPoul-Henning Kamp /* internal.h
25bb6a25fSPoul-Henning Kamp 
35bb6a25fSPoul-Henning Kamp    Internal definitions used by Expat.  This is not needed to compile
45bb6a25fSPoul-Henning Kamp    client code.
55bb6a25fSPoul-Henning Kamp 
6220ed979SColeman Kane    The following calling convention macros are defined for frequently
7220ed979SColeman Kane    called functions:
85bb6a25fSPoul-Henning Kamp 
9220ed979SColeman Kane    FASTCALL    - Used for those internal functions that have a simple
10220ed979SColeman Kane                  body and a low number of arguments and local variables.
115bb6a25fSPoul-Henning Kamp 
12220ed979SColeman Kane    PTRCALL     - Used for functions called though function pointers.
13220ed979SColeman Kane 
14220ed979SColeman Kane    PTRFASTCALL - Like PTRCALL, but for low number of arguments.
15220ed979SColeman Kane 
16220ed979SColeman Kane    inline      - Used for selected internal functions for which inlining
175bb6a25fSPoul-Henning Kamp                  may improve performance on some platforms.
18220ed979SColeman Kane 
19220ed979SColeman Kane    Note: Use of these macros is based on judgement, not hard rules,
20220ed979SColeman Kane          and therefore subject to change.
210a48773fSEric van Gyzen                             __  __            _
220a48773fSEric van Gyzen                          ___\ \/ /_ __   __ _| |_
230a48773fSEric van Gyzen                         / _ \\  /| '_ \ / _` | __|
240a48773fSEric van Gyzen                        |  __//  \| |_) | (_| | |_
250a48773fSEric van Gyzen                         \___/_/\_\ .__/ \__,_|\__|
260a48773fSEric van Gyzen                                  |_| XML parser
270a48773fSEric van Gyzen 
280a48773fSEric van Gyzen    Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
290a48773fSEric van Gyzen    Copyright (c) 2000-2017 Expat development team
300a48773fSEric van Gyzen    Licensed under the MIT license:
310a48773fSEric van Gyzen 
320a48773fSEric van Gyzen    Permission is  hereby granted,  free of charge,  to any  person obtaining
330a48773fSEric van Gyzen    a  copy  of  this  software   and  associated  documentation  files  (the
340a48773fSEric van Gyzen    "Software"),  to  deal in  the  Software  without restriction,  including
350a48773fSEric van Gyzen    without  limitation the  rights  to use,  copy,  modify, merge,  publish,
360a48773fSEric van Gyzen    distribute, sublicense, and/or sell copies of the Software, and to permit
370a48773fSEric van Gyzen    persons  to whom  the Software  is  furnished to  do so,  subject to  the
380a48773fSEric van Gyzen    following conditions:
390a48773fSEric van Gyzen 
400a48773fSEric van Gyzen    The above copyright  notice and this permission notice  shall be included
410a48773fSEric van Gyzen    in all copies or substantial portions of the Software.
420a48773fSEric van Gyzen 
430a48773fSEric van Gyzen    THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
440a48773fSEric van Gyzen    EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
450a48773fSEric van Gyzen    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
460a48773fSEric van Gyzen    NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
470a48773fSEric van Gyzen    DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
480a48773fSEric van Gyzen    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
490a48773fSEric van Gyzen    USE OR OTHER DEALINGS IN THE SOFTWARE.
505bb6a25fSPoul-Henning Kamp */
515bb6a25fSPoul-Henning Kamp 
52220ed979SColeman Kane #if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__)
53220ed979SColeman Kane /* We'll use this version by default only where we know it helps.
54220ed979SColeman Kane 
55220ed979SColeman Kane    regparm() generates warnings on Solaris boxes.   See SF bug #692878.
56220ed979SColeman Kane 
57220ed979SColeman Kane    Instability reported with egcs on a RedHat Linux 7.3.
58220ed979SColeman Kane    Let's comment out:
59220ed979SColeman Kane    #define FASTCALL __attribute__((stdcall, regparm(3)))
60220ed979SColeman Kane    and let's try this:
615bb6a25fSPoul-Henning Kamp */
62220ed979SColeman Kane #  define FASTCALL __attribute__((regparm(3)))
63220ed979SColeman Kane #  define PTRFASTCALL __attribute__((regparm(3)))
645bb6a25fSPoul-Henning Kamp #endif
655bb6a25fSPoul-Henning Kamp 
66220ed979SColeman Kane /* Using __fastcall seems to have an unexpected negative effect under
67220ed979SColeman Kane    MS VC++, especially for function pointers, so we won't use it for
68220ed979SColeman Kane    now on that platform. It may be reconsidered for a future release
69220ed979SColeman Kane    if it can be made more effective.
70220ed979SColeman Kane    Likely reason: __fastcall on Windows is like stdcall, therefore
71220ed979SColeman Kane    the compiler cannot perform stack optimizations for call clusters.
72220ed979SColeman Kane */
73220ed979SColeman Kane 
74220ed979SColeman Kane /* Make sure all of these are defined if they aren't already. */
75220ed979SColeman Kane 
765bb6a25fSPoul-Henning Kamp #ifndef FASTCALL
775bb6a25fSPoul-Henning Kamp #  define FASTCALL
785bb6a25fSPoul-Henning Kamp #endif
795bb6a25fSPoul-Henning Kamp 
80220ed979SColeman Kane #ifndef PTRCALL
81220ed979SColeman Kane #  define PTRCALL
82220ed979SColeman Kane #endif
83220ed979SColeman Kane 
84220ed979SColeman Kane #ifndef PTRFASTCALL
85220ed979SColeman Kane #  define PTRFASTCALL
86220ed979SColeman Kane #endif
87220ed979SColeman Kane 
885bb6a25fSPoul-Henning Kamp #ifndef XML_MIN_SIZE
895bb6a25fSPoul-Henning Kamp #  if ! defined(__cplusplus) && ! defined(inline)
905bb6a25fSPoul-Henning Kamp #    ifdef __GNUC__
915bb6a25fSPoul-Henning Kamp #      define inline __inline
925bb6a25fSPoul-Henning Kamp #    endif /* __GNUC__ */
935bb6a25fSPoul-Henning Kamp #  endif
945bb6a25fSPoul-Henning Kamp #endif /* XML_MIN_SIZE */
955bb6a25fSPoul-Henning Kamp 
965bb6a25fSPoul-Henning Kamp #ifdef __cplusplus
975bb6a25fSPoul-Henning Kamp #  define inline inline
985bb6a25fSPoul-Henning Kamp #else
995bb6a25fSPoul-Henning Kamp #  ifndef inline
1005bb6a25fSPoul-Henning Kamp #    define inline
1015bb6a25fSPoul-Henning Kamp #  endif
1025bb6a25fSPoul-Henning Kamp #endif
103be8aff81SXin LI 
104be8aff81SXin LI #ifndef UNUSED_P
105*6b2c1e49SXin LI #  define UNUSED_P(p) (void)p
106be8aff81SXin LI #endif
107be8aff81SXin LI 
108be8aff81SXin LI #ifdef __cplusplus
109be8aff81SXin LI extern "C" {
110be8aff81SXin LI #endif
111be8aff81SXin LI 
112*6b2c1e49SXin LI #ifdef XML_ENABLE_VISIBILITY
113*6b2c1e49SXin LI #  if XML_ENABLE_VISIBILITY
114*6b2c1e49SXin LI __attribute__((visibility("default")))
115*6b2c1e49SXin LI #  endif
116*6b2c1e49SXin LI #endif
117be8aff81SXin LI void
118*6b2c1e49SXin LI _INTERNAL_trim_to_complete_utf8_characters(const char *from,
119*6b2c1e49SXin LI                                            const char **fromLimRef);
120be8aff81SXin LI 
121be8aff81SXin LI #ifdef __cplusplus
122be8aff81SXin LI }
123be8aff81SXin LI #endif
124