Geant4 Cross Reference |
1 /* internal.h 1 /* internal.h 2 2 3 Internal definitions used by Expat. This i 3 Internal definitions used by Expat. This is not needed to compile 4 client code. 4 client code. 5 5 6 The following calling convention macros are 6 The following calling convention macros are defined for frequently 7 called functions: 7 called functions: 8 8 9 FASTCALL - Used for those internal funct 9 FASTCALL - Used for those internal functions that have a simple 10 body and a low number of argu 10 body and a low number of arguments and local variables. 11 11 12 PTRCALL - Used for functions called tho 12 PTRCALL - Used for functions called though function pointers. 13 13 14 PTRFASTCALL - Like PTRCALL, but for low num 14 PTRFASTCALL - Like PTRCALL, but for low number of arguments. 15 15 16 inline - Used for selected internal fu 16 inline - Used for selected internal functions for which inlining 17 may improve performance on so 17 may improve performance on some platforms. 18 18 19 Note: Use of these macros is based on judge 19 Note: Use of these macros is based on judgement, not hard rules, 20 and therefore subject to change. 20 and therefore subject to change. 21 __ __ 21 __ __ _ 22 ___\ \/ /_ __ __ _| 22 ___\ \/ /_ __ __ _| |_ 23 / _ \\ /| '_ \ / _` | 23 / _ \\ /| '_ \ / _` | __| 24 | __// \| |_) | (_| | 24 | __// \| |_) | (_| | |_ 25 \___/_/\_\ .__/ \__,_| 25 \___/_/\_\ .__/ \__,_|\__| 26 |_| XML parse 26 |_| XML parser 27 27 28 Copyright (c) 2002-2003 Fred L. Drake, Jr. 28 Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> 29 Copyright (c) 2002-2006 Karl Waclawek <karl 29 Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net> 30 Copyright (c) 2003 Greg Stein <gstein@ 30 Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net> 31 Copyright (c) 2016-2022 Sebastian Pipping < 31 Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org> 32 Copyright (c) 2018 Yury Gribov <tetra2 32 Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com> 33 Copyright (c) 2019 David Loffredo <lof 33 Copyright (c) 2019 David Loffredo <loffredo@steptools.com> 34 Licensed under the MIT license: 34 Licensed under the MIT license: 35 35 36 Permission is hereby granted, free of cha 36 Permission is hereby granted, free of charge, to any person obtaining 37 a copy of this software and associat 37 a copy of this software and associated documentation files (the 38 "Software"), to deal in the Software w 38 "Software"), to deal in the Software without restriction, including 39 without limitation the rights to use, c 39 without limitation the rights to use, copy, modify, merge, publish, 40 distribute, sublicense, and/or sell copies 40 distribute, sublicense, and/or sell copies of the Software, and to permit 41 persons to whom the Software is furnish 41 persons to whom the Software is furnished to do so, subject to the 42 following conditions: 42 following conditions: 43 43 44 The above copyright notice and this permis 44 The above copyright notice and this permission notice shall be included 45 in all copies or substantial portions of th 45 in all copies or substantial portions of the Software. 46 46 47 THE SOFTWARE IS PROVIDED "AS IS", WIT 47 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 48 EXPRESS OR IMPLIED, INCLUDING BUT NOT L 48 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 49 MERCHANTABILITY, FITNESS FOR A PARTICULAR P 49 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 50 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HO 50 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 51 DAMAGES OR OTHER LIABILITY, WHETHER IN AN 51 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 52 OTHERWISE, ARISING FROM, OUT OF OR IN CONNE 52 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 53 USE OR OTHER DEALINGS IN THE SOFTWARE. 53 USE OR OTHER DEALINGS IN THE SOFTWARE. 54 */ 54 */ 55 55 56 #if defined(__GNUC__) && defined(__i386__) && 56 #if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__) 57 /* We'll use this version by default only wher 57 /* We'll use this version by default only where we know it helps. 58 58 59 regparm() generates warnings on Solaris box 59 regparm() generates warnings on Solaris boxes. See SF bug #692878. 60 60 61 Instability reported with egcs on a RedHat 61 Instability reported with egcs on a RedHat Linux 7.3. 62 Let's comment out: 62 Let's comment out: 63 #define FASTCALL __attribute__((stdcall, re 63 #define FASTCALL __attribute__((stdcall, regparm(3))) 64 and let's try this: 64 and let's try this: 65 */ 65 */ 66 # define FASTCALL __attribute__((regparm(3))) 66 # define FASTCALL __attribute__((regparm(3))) 67 # define PTRFASTCALL __attribute__((regparm(3 67 # define PTRFASTCALL __attribute__((regparm(3))) 68 #endif 68 #endif 69 69 70 /* Using __fastcall seems to have an unexpecte 70 /* Using __fastcall seems to have an unexpected negative effect under 71 MS VC++, especially for function pointers, 71 MS VC++, especially for function pointers, so we won't use it for 72 now on that platform. It may be reconsidere 72 now on that platform. It may be reconsidered for a future release 73 if it can be made more effective. 73 if it can be made more effective. 74 Likely reason: __fastcall on Windows is lik 74 Likely reason: __fastcall on Windows is like stdcall, therefore 75 the compiler cannot perform stack optimizat 75 the compiler cannot perform stack optimizations for call clusters. 76 */ 76 */ 77 77 78 /* Make sure all of these are defined if they 78 /* Make sure all of these are defined if they aren't already. */ 79 79 80 #ifndef FASTCALL 80 #ifndef FASTCALL 81 # define FASTCALL 81 # define FASTCALL 82 #endif 82 #endif 83 83 84 #ifndef PTRCALL 84 #ifndef PTRCALL 85 # define PTRCALL 85 # define PTRCALL 86 #endif 86 #endif 87 87 88 #ifndef PTRFASTCALL 88 #ifndef PTRFASTCALL 89 # define PTRFASTCALL 89 # define PTRFASTCALL 90 #endif 90 #endif 91 91 92 #ifndef XML_MIN_SIZE 92 #ifndef XML_MIN_SIZE 93 # if ! defined(__cplusplus) && ! defined(inli 93 # if ! defined(__cplusplus) && ! defined(inline) 94 # ifdef __GNUC__ 94 # ifdef __GNUC__ 95 # define inline __inline 95 # define inline __inline 96 # endif /* __GNUC__ */ 96 # endif /* __GNUC__ */ 97 # endif 97 # endif 98 #endif /* XML_MIN_SIZE */ 98 #endif /* XML_MIN_SIZE */ 99 99 100 #ifdef __cplusplus 100 #ifdef __cplusplus 101 # define inline inline 101 # define inline inline 102 #else 102 #else 103 # ifndef inline 103 # ifndef inline 104 # define inline 104 # define inline 105 # endif 105 # endif 106 #endif 106 #endif 107 107 108 #include <limits.h> // ULONG_MAX 108 #include <limits.h> // ULONG_MAX 109 109 110 #if defined(_WIN32) 110 #if defined(_WIN32) \ 111 && (! defined(__USE_MINGW_ANSI_STDIO) 111 && (! defined(__USE_MINGW_ANSI_STDIO) \ 112 || (1 - __USE_MINGW_ANSI_STDIO - 1 == 112 || (1 - __USE_MINGW_ANSI_STDIO - 1 == 0)) 113 # define EXPAT_FMT_ULL(midpart) "%" midpart " 113 # define EXPAT_FMT_ULL(midpart) "%" midpart "I64u" 114 # if defined(_WIN64) // Note: modifiers "td" 114 # if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW 115 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" m 115 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d" 116 # define EXPAT_FMT_SIZE_T(midpart) "%" midp 116 # define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u" 117 # else 117 # else 118 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" m 118 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d" 119 # define EXPAT_FMT_SIZE_T(midpart) "%" midp 119 # define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u" 120 # endif 120 # endif 121 #else 121 #else 122 # define EXPAT_FMT_ULL(midpart) "%" midpart " 122 # define EXPAT_FMT_ULL(midpart) "%" midpart "llu" 123 # if ! defined(ULONG_MAX) 123 # if ! defined(ULONG_MAX) 124 # error Compiler did not define ULONG_MAX f 124 # error Compiler did not define ULONG_MAX for us 125 # elif ULONG_MAX == 18446744073709551615u // 125 # elif ULONG_MAX == 18446744073709551615u // 2^64-1 126 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" m 126 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld" 127 # define EXPAT_FMT_SIZE_T(midpart) "%" midp 127 # define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu" 128 # else 128 # else 129 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" m 129 # define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d" 130 # define EXPAT_FMT_SIZE_T(midpart) "%" midp 130 # define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u" 131 # endif 131 # endif 132 #endif 132 #endif 133 133 134 #ifndef UNUSED_P 134 #ifndef UNUSED_P 135 # define UNUSED_P(p) (void)p 135 # define UNUSED_P(p) (void)p 136 #endif 136 #endif 137 137 138 /* NOTE BEGIN If you ever patch these defaults 138 /* NOTE BEGIN If you ever patch these defaults to greater values 139 for non-attack XML payload in yo 139 for non-attack XML payload in your environment, 140 please file a bug report with li 140 please file a bug report with libexpat. Thank you! 141 */ 141 */ 142 #define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION 142 #define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \ 143 100.0f 143 100.0f 144 #define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION 144 #define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \ 145 8388608 // 8 MiB, 2^23 145 8388608 // 8 MiB, 2^23 146 /* NOTE END */ 146 /* NOTE END */ 147 147 148 #include "expat.h" // so we can use type XML_P 148 #include "expat.h" // so we can use type XML_Parser below 149 149 150 #ifdef __cplusplus 150 #ifdef __cplusplus 151 extern "C" { 151 extern "C" { 152 #endif 152 #endif 153 153 154 void _INTERNAL_trim_to_complete_utf8_character 154 void _INTERNAL_trim_to_complete_utf8_characters(const char *from, 155 155 const char **fromLimRef); 156 156 157 #if defined(XML_DTD) 157 #if defined(XML_DTD) 158 unsigned long long testingAccountingGetCountBy 158 unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser); 159 unsigned long long testingAccountingGetCountBy 159 unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser); 160 const char *unsignedCharToPrintable(unsigned c 160 const char *unsignedCharToPrintable(unsigned char c); 161 #endif 161 #endif 162 162 163 #ifdef __cplusplus 163 #ifdef __cplusplus 164 } 164 } 165 #endif 165 #endif 166 166