Bug 1374012 - Update to Expat 2.2.1. Part 11: Changes to defines for various compilers. r=erahm, a=RyanVM
authorPeter Van der Beken <peterv@propagandism.org>
Thu, 27 Dec 2018 15:13:19 +0000
changeset 509237 125bfbac214de9348e5df75e074ff4e50934a92f
parent 509236 a203268c32a672cd31d674656d695c3ff2002600
child 509238 c2810f74aef7a7c2413d9d89286c9e2d707d3457
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm, RyanVM
bugs1374012
milestone65.0
Bug 1374012 - Update to Expat 2.2.1. Part 11: Changes to defines for various compilers. r=erahm, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D14450
parser/expat/lib/expat_external.h
parser/expat/lib/internal.h
parser/expat/lib/winconfig.h
parser/expat/lib/xmlparse.c
parser/expat/lib/xmlrole.c
parser/expat/lib/xmltok.c
parser/expat/lib/xmltok_impl.c
parser/expat/lib/xmltok_ns.c
--- a/parser/expat/lib/expat_external.h
+++ b/parser/expat/lib/expat_external.h
@@ -29,19 +29,19 @@
    The XMLCALL macro was added in Expat 1.95.7.  The only one which is
    expected to be directly useful in client code is XMLCALL.
 
    Note that on at least some Unix versions, the Expat library must be
    compiled with the cdecl calling convention as the default since
    system headers may assume the cdecl convention.
 */
 #ifndef XMLCALL
-#if defined(XML_USE_MSC_EXTENSIONS)
+#if defined(_MSC_VER)
 #define XMLCALL __cdecl
-#elif defined(__GNUC__) && defined(__i386)
+#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
 #define XMLCALL __attribute__((cdecl))
 #else
 /* For any platform which uses this definition and supports more than
    one calling convention, we need to extend this definition to
    declare the convention used on that platform, if it's possible to
    do so.
 
    If this is the case for your platform, please file a bug report
@@ -60,31 +60,37 @@
 
 #ifdef XML_USE_MSC_EXTENSIONS
 #define XMLIMPORT __declspec(dllimport)
 #endif
 
 #endif
 #endif  /* not defined XML_STATIC */
 
+#if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
+#define XMLIMPORT __attribute__ ((visibility ("default")))
+#endif
 
 /* If we didn't define it above, define it away: */
 #ifndef XMLIMPORT
 #define XMLIMPORT
 #endif
 
 
 #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 #ifdef XML_UNICODE_WCHAR_T
-#define XML_UNICODE
+# define XML_UNICODE
+# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
+#  error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
+# endif
 #endif
 
 /* BEGIN MOZILLA CHANGE (typedef XML_Char to char16_t) */
 #if 0
 
 #ifdef XML_UNICODE     /* Information is UTF-16 encoded. */
 #ifdef XML_UNICODE_WCHAR_T
 typedef wchar_t XML_Char;
--- a/parser/expat/lib/internal.h
+++ b/parser/expat/lib/internal.h
@@ -15,17 +15,17 @@
 
    inline      - Used for selected internal functions for which inlining
                  may improve performance on some platforms.
 
    Note: Use of these macros is based on judgement, not hard rules,
          and therefore subject to change.
 */
 
-#if defined(__GNUC__) && defined(__i386__)
+#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
 /* We'll use this version by default only where we know it helps.
 
    regparm() generates warnings on Solaris boxes.   See SF bug #692878.
 
    Instability reported with egcs on a RedHat Linux 7.3.
    Let's comment out:
    #define FASTCALL __attribute__((stdcall, regparm(3)))
    and let's try this:
new file mode 100644
--- /dev/null
+++ b/parser/expat/lib/winconfig.h
@@ -0,0 +1,54 @@
+/*================================================================
+** Copyright 2000, Clark Cooper
+** All rights reserved.
+**
+** This is free software. You are permitted to copy, distribute, or modify
+** it under the terms of the MIT/X license (contained in the COPYING file
+** with this distribution.)
+*/
+
+#ifndef WINCONFIG_H
+#define WINCONFIG_H
+
+/* BEGIN MOZILLA CHANGE (don't define WIN32_LEAN_AND_MEAN if it was already set) */
+#ifdef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN_WAS_SET
+#undef WIN32_LEAN_AND_MEAN
+#endif
+/* END MOZILLA CHANGE */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+
+/* BEGIN MOZILLA CHANGE (redefine WIN32_LEAN_AND_MEAN if it was already set) */
+#ifdef WIN32_LEAN_AND_MEAN_WAS_SET
+#define WIN32_LEAN_AND_MEAN
+#undef WIN32_LEAN_AND_MEAN_WAS_SET
+#endif
+/* END MOZILLA CHANGE */
+
+#include <memory.h>
+#include <string.h>
+
+
+#if defined(HAVE_EXPAT_CONFIG_H)  /* e.g. MinGW */
+# include <expat_config.h>
+#else  /* !defined(HAVE_EXPAT_CONFIG_H) */
+
+
+#define XML_NS 1
+#define XML_DTD 1
+#define XML_CONTEXT_BYTES 1024
+
+/* we will assume all Windows platforms are little endian */
+#define BYTEORDER 1234
+
+/* Windows has memmove() available. */
+#define HAVE_MEMMOVE
+
+
+#endif /* !defined(HAVE_EXPAT_CONFIG_H) */
+
+
+#endif /* ndef WINCONFIG_H */
--- a/parser/expat/lib/xmlparse.c
+++ b/parser/expat/lib/xmlparse.c
@@ -18,25 +18,21 @@
 #else
 #include <sys/time.h>                   /* gettimeofday() */
 #include <sys/types.h>                  /* getpid() */
 #include <unistd.h>                     /* getpid() */
 #endif
 
 #define XML_BUILDING_EXPAT 1
 
-#ifdef COMPILED_FROM_DSP
+#ifdef _WIN32
 #include "winconfig.h"
-#elif defined(MACOS_CLASSIC)
-#include "macconfig.h"
-#elif defined(__amigaos4__)
-#include "amigaconfig.h"
 #elif defined(HAVE_EXPAT_CONFIG_H)
 #include <expat_config.h>
-#endif /* ndef COMPILED_FROM_DSP */
+#endif /* ndef _WIN32 */
 
 #include "ascii.h"
 #include "expat.h"
 #include "siphash.h"
 
 #ifdef XML_UNICODE
 #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
 #define XmlConvert XmlUtf16Convert
--- a/parser/expat/lib/xmlrole.c
+++ b/parser/expat/lib/xmlrole.c
@@ -1,25 +1,21 @@
 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
    See the file COPYING for copying permission.
 */
 
 #include <stddef.h>
 
-#ifdef COMPILED_FROM_DSP
+#ifdef _WIN32
 #include "winconfig.h"
-#elif defined(MACOS_CLASSIC)
-#include "macconfig.h"
-#elif defined(__amigaos4__)
-#include "amigaconfig.h"
 #else
 #ifdef HAVE_EXPAT_CONFIG_H
 #include <expat_config.h>
 #endif
-#endif /* ndef COMPILED_FROM_DSP */
+#endif /* ndef _WIN32 */
 
 #include "expat_external.h"
 #include "internal.h"
 #include "xmlrole.h"
 #include "ascii.h"
 
 /* Doesn't check:
 
--- a/parser/expat/lib/xmltok.c
+++ b/parser/expat/lib/xmltok.c
@@ -1,25 +1,21 @@
 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
    See the file COPYING for copying permission.
 */
 
 #include <stddef.h>
 
-#ifdef COMPILED_FROM_DSP
+#ifdef _WIN32
 #include "winconfig.h"
-#elif defined(MACOS_CLASSIC)
-#include "macconfig.h"
-#elif defined(__amigaos4__)
-#include "amigaconfig.h"
 #else
 #ifdef HAVE_EXPAT_CONFIG_H
 #include <expat_config.h>
 #endif
-#endif /* ndef COMPILED_FROM_DSP */
+#endif /* ndef _WIN32 */
 
 #include "expat_external.h"
 #include "internal.h"
 #include "xmltok.h"
 #include "nametab.h"
 
 #ifdef XML_DTD
 #define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok)
@@ -290,17 +286,19 @@ sb_charMatches(const ENCODING *enc, cons
   return *p == c;
 }
 #else
 /* c is an ASCII character */
 #define CHAR_MATCHES(enc, p, c) (*(p) == c)
 #endif
 
 #define PREFIX(ident) normal_ ## ident
+#define XML_TOK_IMPL_C
 #include "xmltok_impl.c"
+#undef XML_TOK_IMPL_C
 
 #undef MINBPC
 #undef BYTE_TYPE
 #undef BYTE_TO_ASCII
 #undef CHAR_MATCHES
 #undef IS_NAME_CHAR
 #undef IS_NAME_CHAR_MINBPC
 #undef IS_NMSTRT_CHAR
@@ -773,17 +771,19 @@ little2_isNmstrtMin(const ENCODING *enc,
 #define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
 #define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p)
 #define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
 #define IS_NAME_CHAR(enc, p, n) 0
 #define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
 #define IS_NMSTRT_CHAR(enc, p, n) (0)
 #define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
 
+#define XML_TOK_IMPL_C
 #include "xmltok_impl.c"
+#undef XML_TOK_IMPL_C
 
 #undef MINBPC
 #undef BYTE_TYPE
 #undef BYTE_TO_ASCII
 #undef CHAR_MATCHES
 #undef IS_NAME_CHAR
 #undef IS_NAME_CHAR_MINBPC
 #undef IS_NMSTRT_CHAR
@@ -912,17 +912,19 @@ big2_isNmstrtMin(const ENCODING *enc, co
 #define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
 #define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p)
 #define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
 #define IS_NAME_CHAR(enc, p, n) 0
 #define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
 #define IS_NMSTRT_CHAR(enc, p, n) (0)
 #define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
 
+#define XML_TOK_IMPL_C
 #include "xmltok_impl.c"
+#undef XML_TOK_IMPL_C
 
 #undef MINBPC
 #undef BYTE_TYPE
 #undef BYTE_TO_ASCII
 #undef CHAR_MATCHES
 #undef IS_NAME_CHAR
 #undef IS_NAME_CHAR_MINBPC
 #undef IS_NMSTRT_CHAR
@@ -1709,26 +1711,30 @@ initScan(const ENCODING * const *encodin
   }
   *encPtr = encodingTable[INIT_ENC_INDEX(enc)];
   return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
 }
 
 
 #define NS(x) x
 #define ns(x) x
+#define XML_TOK_NS_C
 #include "xmltok_ns.c"
+#undef XML_TOK_NS_C
 #undef NS
 #undef ns
 
 #ifdef XML_NS
 
 #define NS(x) x ## NS
 #define ns(x) x ## _ns
 
+#define XML_TOK_NS_C
 #include "xmltok_ns.c"
+#undef XML_TOK_NS_C
 
 #undef NS
 #undef ns
 
 ENCODING *
 XmlInitUnknownEncodingNS(void *mem,
                          int *table,
                          CONVERTER convert,
--- a/parser/expat/lib/xmltok_impl.c
+++ b/parser/expat/lib/xmltok_impl.c
@@ -1,12 +1,15 @@
 /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
    See the file COPYING for copying permission.
 */
 
+/* This file is included! */
+#ifdef XML_TOK_IMPL_C
+
 #ifndef IS_INVALID_CHAR
 #define IS_INVALID_CHAR(enc, ptr, n) (0)
 #endif
 
 #define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
     case BT_LEAD ## n: \
       if (end - ptr < n) \
         return XML_TOK_PARTIAL_CHAR; \
@@ -1768,8 +1771,9 @@ PREFIX(updatePosition)(const ENCODING *e
 #undef DO_LEAD_CASE
 #undef MULTIBYTE_CASES
 #undef INVALID_CASES
 #undef CHECK_NAME_CASE
 #undef CHECK_NAME_CASES
 #undef CHECK_NMSTRT_CASE
 #undef CHECK_NMSTRT_CASES
 
+#endif /* XML_TOK_IMPL_C */
--- a/parser/expat/lib/xmltok_ns.c
+++ b/parser/expat/lib/xmltok_ns.c
@@ -1,8 +1,15 @@
+/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+*/
+
+/* This file is included! */
+#ifdef XML_TOK_NS_C
+
 const ENCODING *
 NS(XmlGetUtf8InternalEncoding)(void)
 {
   return &ns(internal_utf8_encoding).enc;
 }
 
 const ENCODING *
 NS(XmlGetUtf16InternalEncoding)(void)
@@ -99,8 +106,10 @@ NS(XmlParseXmlDecl)(int isGeneralTextEnt
                         end,
                         badPtr,
                         versionPtr,
                         versionEndPtr,
                         encodingName,
                         encoding,
                         standalone);
 }
+
+#endif /* XML_TOK_NS_C */