summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
Diffstat (limited to 'external')
-rw-r--r--external/gcc3_specific/makefile.mk87
-rw-r--r--external/glibc-2.1.3.patch210
-rw-r--r--external/glibc/makefile.mk70
-rw-r--r--external/mingwheaders/makefile.mk210
-rw-r--r--external/mingwheaders/mingw_atl_headers.patch1654
-rw-r--r--external/mingwheaders/mingw_headers.patch2130
-rw-r--r--external/prj/build.lst5
-rw-r--r--external/prj/d.lst67
-rw-r--r--external/unowinreg/README2
9 files changed, 4435 insertions, 0 deletions
diff --git a/external/gcc3_specific/makefile.mk b/external/gcc3_specific/makefile.mk
new file mode 100644
index 000000000000..dd84b5327234
--- /dev/null
+++ b/external/gcc3_specific/makefile.mk
@@ -0,0 +1,87 @@
+PRJ=..
+PRJNAME=external
+TARGET=gcc3_specific
+
+# ------------------------------------------------------------------
+.INCLUDE: settings.mk
+# ------------------------------------------------------------------
+
+
+.IF "$(BUILD_SPECIAL)"==""
+
+.IF "$(GUI)" == "WNT"
+
+.IF "$(COM)" == "GCC"
+
+.IF "$(MINGW_SHARED_GCCLIB)" == "YES"
+MINGWGCCDLL=$(BIN)$/$(MINGW_GCCDLL)
+.ENDIF
+
+.IF "$(MINGW_SHARED_GXXLIB)" == "YES"
+MINGWGXXDLL=$(BIN)$/$(MINGW_GXXDLL)
+.ENDIF
+
+all : $(BIN)$/mingwm10.dll $(MINGWGCCDLL) $(MINGWGXXDLL)
+
+$(BIN)$/mingwm10.dll :
+ $(COPY) -p $(COMPATH)$/bin$/mingwm10.dll $(BIN)$/
+
+.IF "$(MINGW_SHARED_GCCLIB)" == "YES"
+$(MINGWGCCDLL) :
+ $(COPY) -p $(COMPATH)$/bin$/$(MINGW_GCCDLL) $(BIN)$/
+.ENDIF
+
+.IF "$(MINGW_SHARED_GXXLIB)" == "YES"
+$(MINGWGXXDLL) :
+ $(COPY) -p $(COMPATH)$/bin$/$(MINGW_GXXDLL) $(BIN)$/
+.ENDIF
+
+.ENDIF
+
+.ELSE
+
+.IF "$(SYSTEM_STDLIBS)" != "YES" && "$(COMID)"=="gcc3"
+
+.IF "$(OS)"!="MACOSX"
+.IF "$(OS)"!="FREEBSD"
+.IF "$(OS)"!="NETBSD"
+.IF "$(OS)"!="OPENBSD"
+
+.EXPORT : CC
+
+.IF "$(OS)"=="AIX"
+
+all .SEQUENTIAL : $(LB)$/libstdc++.a $(LB)$/libgcc_s.a
+
+$(LB)$/libstdc++.a :
+ $(GCCINSTLIB) libstdc++.a $(LB)
+
+$(LB)$/libgcc_s.a :
+ $(GCCINSTLIB) libgcc_s.a $(LB)
+
+.ELSE
+
+all .SEQUENTIAL : $(LB)$/libstdc++.so.$(SHORTSTDCPP3) $(LB)$/libgcc_s.so.$(SHORTSTDC3)
+
+
+$(LB)$/libstdc++.so.$(SHORTSTDCPP3) :
+ $(GCCINSTLIB) libstdc++.so.$(SHORTSTDCPP3) $(LB)
+
+$(LB)$/libgcc_s.so.$(SHORTSTDC3) :
+ $(GCCINSTLIB) libgcc_s.so.$(SHORTSTDC3) $(LB)
+
+.ENDIF
+
+.ENDIF
+.ENDIF
+.ENDIF
+.ENDIF
+
+.ENDIF
+
+.ENDIF
+.ENDIF # "$(BUILD_SPECIAL)"==""
+
+
+.INCLUDE: target.mk
+
diff --git a/external/glibc-2.1.3.patch b/external/glibc-2.1.3.patch
new file mode 100644
index 000000000000..dddc22a3e009
--- /dev/null
+++ b/external/glibc-2.1.3.patch
@@ -0,0 +1,210 @@
+--- misc/glibc-2.1.3/posix/config.h Mon Mar 31 09:43:50 2008
++++ misc/build/glibc-2.1.3/posix/config.h Mon Mar 31 09:43:26 2008
+@@ -1 +1,42 @@
+-dummy
++/*************************************************************************
++ *
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * Copyright 2000, 2010 Oracle and/or its affiliates.
++ *
++ * OpenOffice.org - a multi-platform office productivity suite
++ *
++ * This file is part of OpenOffice.org.
++ *
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
++ *
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
++ *
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org. If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
++ *
++ ************************************************************************/
++
++#ifdef WNT
++#include <stdlib.h>
++#define getenv getenv
++#endif
++
++
++#if defined(MACOSX)
++//Workaround for MACOS
++#define getopt my_neues_getopt
++#define opterr my_neues_opterr
++#define optind my_neues_optind
++#define optopt my_neues_optopt
++#endif
++
++
+--- misc/glibc-2.1.3/posix/getopt.h Sun Aug 27 16:11:33 2000
++++ misc/build/glibc-2.1.3/posix/getopt.h Mon Mar 31 09:42:01 2008
+@@ -137,6 +137,19 @@
+ # endif /* __GNU_LIBRARY__ */
+
+ # ifndef __need_getopt
++# ifdef __MINGW32__
++extern int getopt_long (int ___argc, char *const *___argv, const char *__shortopts,
++ const struct option *__longopts, int *__longind);
++extern int getopt_long_only (int ___argc, char *const *___argv,
++ const char *__shortopts,
++ const struct option *__longopts, int *__longind);
++
++/* Internal only. Users should not call this directly. */
++extern int _getopt_internal (int ___argc, char *const *___argv,
++ const char *__shortopts,
++ const struct option *__longopts, int *__longind,
++ int __long_only);
++# else
+ extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts,
+ const struct option *__longopts, int *__longind);
+ extern int getopt_long_only (int __argc, char *const *__argv,
+@@ -148,6 +161,7 @@
+ const char *__shortopts,
+ const struct option *__longopts, int *__longind,
+ int __long_only);
++# endif
+ # endif
+ #else /* not __STDC__ */
+ extern int getopt ();
+--- misc/glibc-2.1.3/posix/makefile.mk Mon Mar 31 09:43:50 2008
++++ misc/build/glibc-2.1.3/posix/makefile.mk Mon Mar 31 09:43:38 2008
+@@ -1 +1,70 @@
+-dummy
++#*************************************************************************
++#
++# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++#
++# Copyright 2000, 2010 Oracle and/or its affiliates.
++#
++# OpenOffice.org - a multi-platform office productivity suite
++#
++# This file is part of OpenOffice.org.
++#
++# OpenOffice.org is free software: you can redistribute it and/or modify
++# it under the terms of the GNU Lesser General Public License version 3
++# only, as published by the Free Software Foundation.
++#
++# OpenOffice.org is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++# GNU Lesser General Public License version 3 for more details
++# (a copy is included in the LICENSE file that accompanied this code).
++#
++# You should have received a copy of the GNU Lesser General Public License
++# version 3 along with OpenOffice.org. If not, see
++# <http://www.openoffice.org/license.html>
++# for a copy of the LGPLv3 License.
++#
++#*************************************************************************
++
++PRJ=..$/..$/..$/..$/..
++
++PRJNAME=external
++TARGET=gnu_getopt
++LIBTARGET=NO
++
++EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
++
++SOLARINC+=-I..
++
++# --- Settings -----------------------------------------------------
++
++.INCLUDE : settings.mk
++
++CDEFS+=-DHAVE_STRING_H -DHAVE_CONFIG_H
++
++# --- Files --------------------------------------------------------
++
++.IF "$(HAVE_GETOPT)" != "YES"
++OBJFILES= $(OBJ)$/getopt.obj \
++ $(OBJ)$/getopt1.obj
++
++LIB1TARGET=$(SLB)$/$(TARGET).lib
++LIB1ARCHIV=$(LB)$/lib$(TARGET).a
++LIB1OBJFILES=$(OBJFILES)
++.ENDIF
++
++.IF "$(HAVE_READDIR_R)" != "YES" && "$(OS)" != "WNT"
++TARGET2=gnu_readdir_r
++OBJFILES+= $(OBJ)$/readdir_r.obj
++LIB2TARGET=$(SLB)$/$(TARGET2).lib
++LIB2ARCHIV=$(LB)$/lib$(TARGET2).a
++LIB2OBJFILES= $(OBJ)$/readdir_r.obj
++.ENDIF
++
++.IF "$(HAVE_READDIR_R)" == "YES" && "$(HAVE_GETOPT)" == "YES"
++@all:
++ @echo "Nothing to do here.
++.ENDIF
++
++# --- Targets ------------------------------------------------------
++
++.INCLUDE : target.mk
+--- misc/glibc-2.1.3/posix/readdir_r.c Mon Mar 31 09:43:50 2008
++++ misc/build/glibc-2.1.3/posix/readdir_r.c Mon Mar 31 09:42:01 2008
+@@ -1 +1,56 @@
+-dummy
++/* Copyright (C) 1991,92,93,94,95,96,97,98,99,2000 Free Software Foundation, Inc.
++ This file is part of the GNU C Library.
++
++ The GNU C Library is free software; you can redistribute it and/or
++ modify it under the terms of the GNU Library General Public License as
++ published by the Free Software Foundation; either version 2 of the
++ License, or (at your option) any later version.
++
++ The GNU C Library is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++ Library General Public License for more details.
++
++ You should have received a copy of the GNU Library General Public
++ License along with the GNU C Library; see the file COPYING.LIB. If not,
++ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
++ Boston, MA 02111-1307, USA. */
++
++#include <errno.h>
++#include <limits.h>
++#include <stddef.h>
++#include <string.h>
++#include <dirent.h>
++#include <unistd.h>
++#include <sys/types.h>
++#include <assert.h>
++
++#ifndef __READDIR_R
++# define __READDIR_R readdir_r
++# define DIRENT_TYPE struct dirent
++#endif
++
++/* Read a directory entry from DIRP. */
++int
++__READDIR_R (DIR *dirp, DIRENT_TYPE *entry, DIRENT_TYPE **result)
++{
++ DIRENT_TYPE *dp;
++ size_t reclen;
++
++ errno = 0;
++ /* call our non-reentrant counterpart to get the information */
++ dp = readdir(dirp);
++
++ /* copy the result into entry */
++ if (dp != NULL) {
++ reclen = dp->d_reclen; /* This might be NetBSD-specific
++ * Add #ifdef's if anything else needed */
++ *result = memcpy(entry, dp, reclen);
++ } else {
++ *result = NULL;
++ }
++
++ return dp != NULL ? 0 : errno ? errno : 0;
++}
++
++
diff --git a/external/glibc/makefile.mk b/external/glibc/makefile.mk
new file mode 100644
index 000000000000..04e2ff5b99bd
--- /dev/null
+++ b/external/glibc/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=external
+TARGET=getopt
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(HAVE_GETOPT)" != "YES" || "$(HAVE_READDIR_R)" != "YES"
+TARFILE_NAME=glibc-2.1.3-stub
+TARFILE_MD5=4a660ce8466c9df01f19036435425c3a
+TARFILE_ROOTDIR=glibc-2.1.3
+ADDITIONAL_FILES=posix$/makefile.mk posix$/config.h
+.IF "$(HAVE_READDIR_R)" != "YES"
+ADDITIONAL_FILES += posix$/readdir_r.c
+.ENDIF
+
+PATCH_FILES=$(PRJ)$/glibc-2.1.3.patch
+
+#CONFIGURE_DIR=glibc-2.1.3/posix
+CONFIGURE_ACTION=
+
+BUILD_DIR=posix
+BUILD_ACTION=dmake $(MFLAGS) $(CALLMACROS)
+
+OUT2INC= \
+ posix/getopt.h \
+ posix/config.h
+
+.ELSE
+@all:
+ @echo "Nothing to do here."
+.ENDIF
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : set_ext.mk
+.INCLUDE : target.mk
+.INCLUDE : tg_ext.mk
+
diff --git a/external/mingwheaders/makefile.mk b/external/mingwheaders/makefile.mk
new file mode 100644
index 000000000000..ccfc9587462c
--- /dev/null
+++ b/external/mingwheaders/makefile.mk
@@ -0,0 +1,210 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..
+PRJNAME=external
+TARGET=mingwheaders
+
+.INCLUDE : settings.mk
+
+.IF "$(OS)$(COM)" == "WNTGCC"
+
+# Cygwin and MinGW use different directories for the W32API headers
+.IF "$(USE_MINGW)" == "cygwin"
+MINGW_INCLUDE_DIR=$/usr$/include/mingw/
+MINGW_W32API_INCLUDE_DIR=$/usr$/include/w32api/
+MINGW_W32API_LIB_DIR=$/usr$/include/w32api/
+.ELSE
+MINGW_INCLUDE_DIR=$(COMPATH)$/include/
+MINGW_W32API_INCLUDE_DIR=$(COMPATH)$/include/
+MINGW_W32API_LIB_DIR=$(COMPATH)$/lib/
+.ENDIF
+
+SYS_INCLUDE_DIR=$(MINGW_INCLUDE_DIR)$/sys/
+
+PSDK_INCLUDE_DIR=$(PSDK_HOME)$/include$/
+
+ATL_INCLUDE_DIR=$(PSDK_HOME)$/include$/atl$/
+
+DIRECTXSDK_INCLUDE_DIR=$(DIRECTXSDK_HOME)$/include$/
+
+FILES_TO_COPY_FROM_MINGW= \
+ excpt.h \
+ tchar.h
+
+FILES_TO_COPY_FROM_W32API= \
+ amvideo.h \
+ basetyps.h \
+ objidl.h \
+ specstrings.h \
+ uxtheme.h \
+ winbase.h \
+ windef.h \
+ wininet.h \
+ winver.h \
+ wtypes.h
+
+FILES_TO_COPY_FROM_SYS= \
+ stat.h
+
+FILES_TO_COPY_FROM_PSDK= \
+ adoctint.h \
+ adodef.h \
+ adoguids.h \
+ adoint.h \
+ bcrypt.h \
+ commctrl.h \
+ control.h \
+ dispex.h \
+ filter.h \
+ gdiplusbitmap.h \
+ gdiplusbrush.h \
+ gdiplusenums.h \
+ gdiplusfont.h \
+ gdiplusheaders.h \
+ gdiplusimageattributes.h \
+ gdiplusimaging.h \
+ gdiplusmatrix.h \
+ gdipluspath.h \
+ gdipluspen.h \
+ gdiplusregion.h \
+ gdiplusstringformat.h \
+ imm.h \
+ imagehlp.h \
+ mapiwin.h \
+ msdasc.h \
+ msi.h \
+ msiquery.h \
+ multimon.h \
+ ntquery.h \
+ oaidl.h \
+ ocidl.h \
+ oleauto.h \
+ olectl.h \
+ oledb.h \
+ oleidl.h \
+ propidl.h \
+ propkeydef.h \
+ propsys.h \
+ propvarutil.h \
+ shlobj.h \
+ shobjidl.h \
+ shtypes.h \
+ sspi.h \
+ strmif.h \
+ strsafe.h \
+ structuredquery.h \
+ urlmon.h \
+ wincrypt.h \
+ winerror.h \
+ wingdi.h \
+ wintrust.h \
+ winuser.h \
+ wspiapi.h \
+ exdispid.h \
+ dshow.h \
+ gdiplus.h \
+ msxml.h \
+ ncrypt.h \
+ shlguid.h \
+ transact.h
+
+.IF "$(DISABLE_ATL)"==""
+MINGWHEADER_ATL_PATCH_TARGET=$(MISC)$/mingwheader_atl_patch
+MINGWHEADER_ATL_COPY_TARGET=$(MISC)$/mingwheader_atl_copy
+FILES_TO_COPY_FROM_ATL= \
+ atlbase.h \
+ atlcom.h \
+ atlconv.h \
+ atlctl.h \
+ atlwin.h \
+ statreg.h
+.ENDIF
+
+FILES_TO_COPY_FROM_DIRECTXSDK= \
+ d3dtypes.h \
+ d3dx9core.h \
+ d3dx9math.h \
+ d3dx9math.inl \
+ dxtrans.h \
+ d3dx9.h
+
+$(MISC)$/mingwheader_patch_all : $(MISC)$/mingwheader_patch $(MINGWHEADER_ATL_PATCH_TARGET) $(LB)$/libmsvcrt.a
+
+$(MISC)$/mingwheader_patch : $(MISC)$/mingwheader_copy
+ patch -bd $(MISC)$/mingw -p0 -N -f -Z <mingw_headers.patch
+ $(TOUCH) $(MISC)$/mingwheader_patch
+
+.IF "$(DISABLE_ATL)"==""
+$(MINGWHEADER_ATL_PATCH_TARGET) : $(MINGWHEADER_ATL_COPY_TARGET)
+ patch -bd $(MISC)$/mingw -p0 -N -f -Z <mingw_atl_headers.patch
+ $(TOUCH) $(MINGWHEADER_ATL_PATCH_TARGET)
+.ENDIF
+
+$(MISC)$/mingwheader_copy:
+ $(MKDIRHIER) $(MISC)$/mingw$/include
+ $(MKDIRHIER) $(MISC)$/mingw$/include/sys
+ $(COPY) $(FILES_TO_COPY_FROM_MINGW:^$(MINGW_INCLUDE_DIR)) $(MISC)$/mingw$/include
+ $(COPY) $(FILES_TO_COPY_FROM_W32API:^$(MINGW_W32API_INCLUDE_DIR)) $(MISC)$/mingw$/include
+ $(COPY) $(FILES_TO_COPY_FROM_SYS:^$(SYS_INCLUDE_DIR)) $(MISC)$/mingw$/include$/sys
+ $(COPY) $(FILES_TO_COPY_FROM_PSDK:^$(PSDK_INCLUDE_DIR)) $(MISC)$/mingw$/include
+ $(COPY) $(FILES_TO_COPY_FROM_DIRECTXSDK:^$(DIRECTXSDK_INCLUDE_DIR)) $(MISC)$/mingw$/include
+ $(TOUCH) $(MISC)$/mingwheader_copy
+
+.IF "$(DISABLE_ATL)"==""
+$(MINGWHEADER_ATL_COPY_TARGET):
+ $(MKDIRHIER) $(MISC)$/mingw$/include/atl
+ $(COPY) $(FILES_TO_COPY_FROM_ATL:^$(ATL_INCLUDE_DIR)) $(MISC)$/mingw$/include$/atl
+ $(TOUCH) $(MINGWHEADER_ATL_COPY_TARGET)
+.ENDIF
+
+$(LB)$/libmsvcrt.a:
+.IF "$(USE_MINGW)" == "cygwin"
+ $(COPY) $(COMPATH)$/lib/mingw/libmsvcrt.a $(LB)$/libmsvcrt_orig.a
+.ELSE
+ $(COPY) $(COMPATH)$/lib/libmsvcrt.a $(LB)$/libmsvcrt_orig.a
+.ENDIF
+ cd $(LB) && ar -x libmsvcrt_orig.a ofmt_stub.o
+ ar -d $(LB)$/libmsvcrt_orig.a ofmt_stub.o
+ nm -g --defined-only $(LB)$/libmsvcrt_orig.a > $(MISC)$/msvcrt.nm
+ echo EXPORTS > $(MISC)$/msvcrt.def
+ sed -ne 's/.* T _//p' $(MISC)$/msvcrt.nm | sort >> $(MISC)$/msvcrt.def
+ -sed -ne 's/.* I __imp__//p' $(MISC)$/msvcrt.nm | sort | diff - $(MISC)$/msvcrt.def | \
+ sed -ne 's/^< \(.*\)$/\1 DATA/p' > $(MISC)$/msvcrtdata.def
+ cat $(MISC)$/msvcrtdata.def >> $(MISC)$/msvcrt.def
+ dlltool --dllname msvcrt.dll --input-def=$(MISC)$/msvcrt.def --kill-at --output-lib=$(LB)$/libmsvcrt.a
+ cd $(LB) && ar -rs libmsvcrt.a ofmt_stub.o
+
+clean:
+ -$(RM) $(MISC)$/mingw$/include$/*.h
+ -$(RM) $(MISC)$/mingwheader_copy
+ -$(RM) $(MISC)$/mingwheader_patch
+
+.ENDIF
+
+.INCLUDE : target.mk
+
diff --git a/external/mingwheaders/mingw_atl_headers.patch b/external/mingwheaders/mingw_atl_headers.patch
new file mode 100644
index 000000000000..bbcbb84fd233
--- /dev/null
+++ b/external/mingwheaders/mingw_atl_headers.patch
@@ -0,0 +1,1654 @@
+--- include/atl/atlbase.h.orig 2005-04-14 17:54:32.000000000 +0900
++++ include/atl/atlbase.h 2007-12-23 14:38:02.467500000 +0900
+@@ -10,6 +10,9 @@
+
+ #ifndef __ATLBASE_H__
+ #define __ATLBASE_H__
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #ifndef __cplusplus
+ #error ATL requires C++ compilation (use a .cpp suffix)
+@@ -73,19 +76,47 @@
+ #define _ATL_TYPELIB_INDEX_LENGTH 10
+ #define _ATL_QUOTES_SPACE 2
+
+-#pragma pack(push, _ATL_PACKING)
++#pragma pack(push, 8)
+
+ #if defined(_ATL_DLL)
+ #pragma comment(lib, "atl.lib")
+ #endif
+
+-extern "C" const __declspec(selectany) GUID LIBID_ATLLib = {0x44EC0535,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
+-extern "C" const __declspec(selectany) CLSID CLSID_Registrar = {0x44EC053A,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
+-extern "C" const __declspec(selectany) IID IID_IRegistrar = {0x44EC053B,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
+-extern "C" const __declspec(selectany) IID IID_IAxWinHostWindow = {0xb6ea2050,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
+-extern "C" const __declspec(selectany) IID IID_IAxWinAmbientDispatch = {0xb6ea2051,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
+-extern "C" const __declspec(selectany) IID IID_IInternalConnection = {0x72AD0770,0x6A9F,0x11d1,{0xBC,0xEC,0x00,0x60,0x08,0x8F,0x44,0x4E}};
+-extern "C" const __declspec(selectany) IID IID_IDocHostUIHandlerDispatch = {0x425B5AF0,0x65F1,0x11d1,{0x96,0x11,0x00,0x00,0xF8,0x1E,0x0D,0x0D}};
++#define __uuidof(I) IID_##I
++
++#include <excpt.h>
++
++namespace ATL
++{
++inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
++{
++ return (
++ ((unsigned long *) &rguid1)[0] == ((unsigned long *) &rguid2)[0] &&
++ ((unsigned long *) &rguid1)[1] == ((unsigned long *) &rguid2)[1] &&
++ ((unsigned long *) &rguid1)[2] == ((unsigned long *) &rguid2)[2] &&
++ ((unsigned long *) &rguid1)[3] == ((unsigned long *) &rguid2)[3]);
++}
++}
++
++#ifdef _INIT_ATL_COMMON_VARS
++extern "C" const GUID LIBID_ATLLib = {0x44EC0535,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
++extern "C" const CLSID CLSID_Registrar = {0x44EC053A,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
++extern "C" const IID IID_IRegistrar = {0x44EC053B,0x400F,0x11D0,{0x9D,0xCD,0x00,0xA0,0xC9,0x03,0x91,0xD3}};
++extern "C" const IID IID_IAxWinHostWindow = {0xb6ea2050,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
++extern "C" const IID IID_IAxWinAmbientDispatch = {0xb6ea2051,0x48a,0x11d1,{0x82,0xb9,0x0,0xc0,0x4f,0xb9,0x94,0x2e}};
++extern "C" const IID IID_IInternalConnection = {0x72AD0770,0x6A9F,0x11d1,{0xBC,0xEC,0x00,0x60,0x08,0x8F,0x44,0x4E}};
++extern "C" const IID IID_IDocHostUIHandlerDispatch = {0x425B5AF0,0x65F1,0x11d1,{0x96,0x11,0x00,0x00,0xF8,0x1E,0x0D,0x0D}};
++#else
++extern "C" {
++extern const GUID LIBID_ATLLib;
++extern const CLSID CLSID_Registrar;
++extern const IID IID_IRegistrar;
++extern const IID IID_IAxWinHostWindow;
++extern const IID IID_IAxWinAmbientDispatch;
++extern const IID IID_IInternalConnection;
++extern const IID IID_IDocHostUIHandlerDispatch;
++}
++#endif
+
+ #ifndef _ATL_DLL_IMPL
+ namespace ATL
+@@ -135,7 +166,7 @@
+ IUnknown* p = NULL;
+ if (pfnGetClassObject == NULL)
+ return S_OK;
+- HRESULT hRes = pfnGetClassObject(pfnCreateInstance, IID_IUnknown, (LPVOID*) &p);
++ HRESULT hRes = pfnGetClassObject((LPVOID)pfnCreateInstance, IID_IUnknown, (LPVOID*) &p);
+ if (SUCCEEDED(hRes))
+ hRes = CoRegisterClassObject(*pclsid, p, dwClsContext, dwFlags, &dwRegister);
+ if (p != NULL)
+@@ -284,13 +315,15 @@
+ };
+ #pragma pack(pop)
+
+-PVOID __stdcall __AllocStdCallThunk(VOID);
+-VOID __stdcall __FreeStdCallThunk(PVOID);
++//PVOID __stdcall __AllocStdCallThunk(VOID);
++//VOID __stdcall __FreeStdCallThunk(PVOID);
+
+-#define AllocStdCallThunk() __AllocStdCallThunk()
+-#define FreeStdCallThunk(p) __FreeStdCallThunk(p)
++//#define AllocStdCallThunk() __AllocStdCallThunk()
++//#define FreeStdCallThunk(p) __FreeStdCallThunk(p)
+
+-#pragma comment(lib, "atlthunk.lib")
++//#pragma comment(lib, "atlthunk.lib")
++#define AllocStdCallThunk() HeapAlloc(GetProcessHeap(),0,sizeof(_stdcallthunk))
++#define FreeStdCallThunk(p) HeapFree(GetProcessHeap(), 0, p)
+
+ #elif defined (_M_AMD64)
+ #pragma pack(push,2)
+@@ -465,7 +498,7 @@
+ return( HRESULT_FROM_WIN32( nError ) );
+ }
+
+-inline void __declspec(noreturn) _AtlRaiseException( DWORD dwExceptionCode, DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE )
++inline void _AtlRaiseException( DWORD dwExceptionCode, DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE )
+ {
+ RaiseException( dwExceptionCode, dwExceptionFlags, 0, NULL );
+ }
+@@ -658,6 +691,7 @@
+ class _NoAddRefReleaseOnCComPtr : public T
+ {
+ private:
++ _NoAddRefReleaseOnCComPtr();
+ STDMETHOD_(ULONG, AddRef)()=0;
+ STDMETHOD_(ULONG, Release)()=0;
+ };
+@@ -781,6 +815,7 @@
+ {
+ return AtlAdvise(p, pUnk, iid, pdw);
+ }
++#if 0
+ HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+ {
+ ATLASSERT(p == NULL);
+@@ -801,11 +836,12 @@
+ ATLASSERT(pp != NULL && *pp == NULL);
+ return p->QueryInterface(__uuidof(Q), (void**)pp);
+ }
++#endif
+ T* p;
+ };
+
+
+-template <class T, const IID* piid = &__uuidof(T)>
++template <class T, const IID* piid>
+ class CComQIPtr
+ {
+ public:
+@@ -933,6 +969,7 @@
+ {
+ return AtlAdvise(p, pUnk, iid, pdw);
+ }
++#if 0
+ HRESULT CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
+ {
+ ATLASSERT(p == NULL);
+@@ -953,6 +990,7 @@
+ ATLASSERT(pp != NULL && *pp == NULL);
+ return p->QueryInterface(__uuidof(Q), (void**)pp);
+ }
++#endif
+ T* p;
+ };
+
+@@ -1087,12 +1125,14 @@
+ hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(IUnknown), (void**)&p);
+ return hr;
+ }
++#if 0
+ template <class Q>
+ HRESULT QueryInterface(Q** pp)
+ {
+ ATLASSERT(pp != NULL && *pp == NULL);
+ return p->QueryInterface(__uuidof(Q), (void**)pp);
+ }
++#endif
+ IUnknown* p;
+ };
+
+@@ -1257,21 +1297,26 @@
+ LeaveCriticalSection(&m_sec);
+ return S_OK;
+ }
++ static void _InitHandler(void *pData, LPEXCEPTION_POINTERS ep)
++ {
++ HRESULT &hRes=*reinterpret_cast<HRESULT*>(pData);
++ if (STATUS_NO_MEMORY == ep->ExceptionRecord->ExceptionCode)
++ hRes = E_OUTOFMEMORY;
++ else
++ hRes = E_FAIL;
++ }
+ HRESULT Init() throw()
+ {
+ HRESULT hRes = S_OK;
+- __try
+- {
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0)
++ {
++ _sehandler.Set(_sejmpbuf, &hRes, reinterpret_cast<__SEHandler::PF>(EXCEPTION_EXECUTE_HANDLER), _InitHandler);
+ InitializeCriticalSection(&m_sec);
+- }
++ }
+ // structured exception may be raised in low memory situations
+- __except(EXCEPTION_EXECUTE_HANDLER)
+- {
+- if (STATUS_NO_MEMORY == GetExceptionCode())
+- hRes = E_OUTOFMEMORY;
+- else
+- hRes = E_FAIL;
+- }
++ _sehandler.Reset();
+ return hRes;
+ }
+
+@@ -2799,10 +2844,19 @@
+
+
+ class CComModule;
+-__declspec(selectany) CComModule* _pModule=NULL;
++#ifdef _INIT_ATL_COMMON_VARS
++CComModule* _pModule=NULL;
++#else
++extern CComModule* _pModule;
++#endif
++
+
+ // {B62F5910-6528-11d1-9611-0000F81E0D0D}
+-_declspec(selectany) GUID GUID_ATLVer30 = { 0xb62f5910, 0x6528, 0x11d1, { 0x96, 0x11, 0x0, 0x0, 0xf8, 0x1e, 0xd, 0xd } };
++#ifdef _INIT_ATL_COMMON_VARS
++GUID GUID_ATLVer30 = { 0xb62f5910, 0x6528, 0x11d1, { 0x96, 0x11, 0x0, 0x0, 0xf8, 0x1e, 0xd, 0xd } };
++#else
++extern GUID GUID_ATLVer30;
++#endif
+
+ class CComModule : public _ATL_MODULE
+ {
+@@ -4286,7 +4340,9 @@
+
+ #endif
+
+-__declspec(selectany) GUID CComModule::m_libid = {0x0,0x0,0x0,{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}};
++#ifdef _INIT_ATL_COMMON_VARS
++GUID CComModule::m_libid = {0x0,0x0,0x0,{0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}};
++#endif
+
+ #ifdef _ATL_STATIC_REGISTRY
+ #define UpdateRegistryFromResource UpdateRegistryFromResourceS
+@@ -4355,7 +4411,9 @@
+ LONG m_nLockCnt;
+ };
+
+-__declspec(selectany) UINT CComApartment::ATL_CREATE_OBJECT = 0;
++#ifdef _INIT_ATL_COMMON_VARS
++UINT CComApartment::ATL_CREATE_OBJECT = 0;
++#endif
+
+ class CComSimpleThreadAllocator
+ {
+@@ -5855,6 +5913,10 @@
+ }
+
+ }
++ static int _Except(void *pThis, LPEXCEPTION_POINTERS lpEP)
++ {
++ return reinterpret_cast<CVirtualBuffer *>(pThis)->Except(lpEP);
++ }
+ void Seek(int nElement)
+ {
+ if(nElement < 0 || nElement >= m_nMaxElements)
+@@ -5866,41 +5928,53 @@
+ {
+ if(nElement < 0 || nElement >= m_nMaxElements)
+ _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED);
+- __try
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0)
+ {
++ _sehandler.Set(_sejmpbuf, this, _Except);
+ T* p = &m_pBase[nElement];
+ *p = Element;
+ m_pTop = p > m_pTop ? p : m_pTop;
+ }
+- __except(Except(GetExceptionInformation()))
++ else
+ {
+ }
++ _sehandler.Reset();
+
+ }
+ template <class Q>
+ void WriteBulk(Q& helper)
+ {
+- __try
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0)
+ {
++ _sehandler.Set(_sejmpbuf, this, _Except);
+ m_pCurrent = helper(m_pBase);
+ m_pTop = m_pCurrent > m_pTop ? m_pCurrent : m_pTop;
+ }
+- __except(Except(GetExceptionInformation()))
++ else
+ {
+ }
++ _sehandler.Reset();
+ }
+ void Write(const T& Element)
+ {
+ if (m_pCurrent < &m_pBase[m_nMaxElements]) {
+- __try
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0)
+ {
++ _sehandler.Set(_sejmpbuf, this, _Except);
+ *m_pCurrent = Element;
+ m_pCurrent++;
+ m_pTop = m_pCurrent > m_pTop ? m_pCurrent : m_pTop;
+ }
+- __except(Except(GetExceptionInformation()))
++ else
+ {
+ }
++ _sehandler.Reset();
+ }
+ }
+ T& Read()
+@@ -5910,14 +5984,18 @@
+ operator BSTR()
+ {
+ BSTR bstrTemp = NULL ;
+- __try
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0)
+ {
++ _sehandler.Set(_sejmpbuf, this, _Except);
+ bstrTemp = SysAllocStringByteLen((char*) m_pBase,
+ (UINT) ((BYTE*)m_pTop - (BYTE*)m_pBase));
+ }
+- __except(Except(GetExceptionInformation()))
++ else
+ {
+ }
++ _sehandler.Reset();
+ return bstrTemp;
+ }
+ const T& operator[](int nElement) const
+@@ -6336,6 +6414,11 @@
+ //Although these functions are big, they are only used once in a module
+ //so we should make them inline.
+
++ATLINLINE int atlmoduleinitfilter(void *, LPEXCEPTION_POINTERS ep)
++{
++ return ep->ExceptionRecord->ExceptionCode == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
++}
++
+ ATLINLINE ATLAPI AtlModuleInit(_ATL_MODULE* pM, _ATL_OBJMAP_ENTRY* p, HINSTANCE h)
+ {
+ ATLASSERT(pM != NULL);
+@@ -6352,32 +6435,43 @@
+ pM->m_hInst = pM->m_hInstTypeLib = pM->m_hInstResource = h;
+ pM->m_nLockCnt=0L;
+ pM->m_hHeap = NULL;
+- __try {
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0) {
++ _sehandler.Set(_sejmpbuf, NULL, atlmoduleinitfilter);
+ InitializeCriticalSection(&pM->m_csTypeInfoHolder);
+- } __except (GetExceptionCode() == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
++ } else {
+ ZeroMemory(&pM->m_csTypeInfoHolder, sizeof(pM->m_csTypeInfoHolder));
+- return STATUS_NO_MEMORY;
++ _sehandler.Reset();
++ return STATUS_NO_MEMORY;
+ }
++ _sehandler.Reset();
+
+- __try {
++ if (__builtin_setjmp(_sejmpbuf) == 0) {
++ _sehandler.Set(_sejmpbuf, NULL, atlmoduleinitfilter);
+ InitializeCriticalSection(&pM->m_csWindowCreate);
+- } __except (GetExceptionCode() == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
++ } else {
+ DeleteCriticalSection(&pM->m_csTypeInfoHolder);
+ ZeroMemory(&pM->m_csWindowCreate, sizeof(pM->m_csWindowCreate));
+ ZeroMemory(&pM->m_csTypeInfoHolder, sizeof(pM->m_csTypeInfoHolder));
++ _sehandler.Reset();
+ return STATUS_NO_MEMORY;
+ }
++ _sehandler.Reset();
+
+- __try {
++ if (__builtin_setjmp(_sejmpbuf) == 0) {
++ _sehandler.Set(_sejmpbuf, NULL, atlmoduleinitfilter);
+ InitializeCriticalSection(&pM->m_csObjMap);
+- } __except (GetExceptionCode() == STATUS_NO_MEMORY ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
++ } else {
+ DeleteCriticalSection(&pM->m_csWindowCreate);
+ DeleteCriticalSection(&pM->m_csTypeInfoHolder);
+ ZeroMemory(&pM->m_csObjMap, sizeof(pM->m_csObjMap));
+ ZeroMemory(&pM->m_csWindowCreate, sizeof(pM->m_csWindowCreate));
+ ZeroMemory(&pM->m_csTypeInfoHolder, sizeof(pM->m_csTypeInfoHolder));
++ _sehandler.Reset();
+ return STATUS_NO_MEMORY;
+ }
++ _sehandler.Reset();
+ #ifdef _ATL_DLL_IMPL
+ if (pM->cbSize > _nAtlModuleVer21Size)
+ #endif
+@@ -6450,6 +6544,11 @@
+ return hRes;
+ }
+
++ATLINLINE void atlfinalleavecriticalsection(void *pData)
++{
++ LeaveCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(pData));
++}
++
+ ATLINLINE ATLAPI AtlModuleGetClassObject(_ATL_MODULE* pM, REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+ {
+ ATLASSERT(pM != NULL);
+@@ -6473,15 +6572,15 @@
+ if (pEntry->pCF == NULL)
+ {
+ EnterCriticalSection(&pM->m_csObjMap);
+- __try
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0)
+ {
++ _sehandler.Set(_sejmpbuf, &pM->m_csObjMap, EXCEPTION_CONTINUE_SEARCH, NULL, atlfinalleavecriticalsection);
+ if (pEntry->pCF == NULL)
+- hRes = pEntry->pfnGetClassObject(pEntry->pfnCreateInstance, IID_IUnknown, (LPVOID*)&pEntry->pCF);
+- }
+- __finally
+- {
+- LeaveCriticalSection(&pM->m_csObjMap);
++ hRes = pEntry->pfnGetClassObject((void *)(pEntry->pfnCreateInstance), IID_IUnknown, (LPVOID*)&pEntry->pCF);
+ }
++ _sehandler.Reset();
+ }
+ if (pEntry->pCF != NULL)
+ hRes = pEntry->pCF->QueryInterface(riid, ppv);
+--- include/atl/atlcom.h.orig 2005-04-14 17:54:32.000000000 +0900
++++ include/atl/atlcom.h 2007-12-03 22:43:54.833375000 +0900
+@@ -10,6 +10,9 @@
+
+ #ifndef __ATLCOM_H__
+ #define __ATLCOM_H__
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #ifndef __cplusplus
+ #error ATL requires C++ compilation (use a .cpp suffix)
+@@ -19,7 +22,10 @@
+ #error atlcom.h requires atlbase.h to be included first
+ #endif
+
+-#pragma pack(push, _ATL_PACKING)
++#include <algorithm>
++using ::std::min;
++
++#pragma pack(push, 8)
+
+ EXTERN_C const IID IID_ITargetFrame;
+
+@@ -2191,19 +2197,23 @@
+ // override it in your class and call each base class' version of this
+ #define BEGIN_COM_MAP(x) public: \
+ typedef x _ComMapClass; \
++ static void _CacheFinal(void *pData)\
++ {\
++ reinterpret_cast<_ComMapClass*>(pData)->Unlock();\
++ }\
+ static HRESULT WINAPI _Cache(void* pv, REFIID iid, void** ppvObject, DWORD_PTR dw)\
+ {\
+ _ComMapClass* p = (_ComMapClass*)pv;\
+ p->Lock();\
+ HRESULT hRes = E_FAIL; \
+- __try \
++ jmp_buf _sejmpbuf; \
++ __SEHandler _sehandler; \
++ if (__builtin_setjmp(_sejmpbuf) == 0) \
+ { \
++ _sehandler.Set(_sejmpbuf, p, EXCEPTION_CONTINUE_SEARCH, NULL, _CacheFinal);\
+ hRes = CComObjectRootBase::_Cache(pv, iid, ppvObject, dw);\
+ } \
+- __finally \
+- { \
+- p->Unlock();\
+- } \
++ _sehandler.Reset();\
+ return hRes;\
+ }\
+ IUnknown* _GetRawUnknown() \
+@@ -2339,7 +2349,7 @@
+ return( pMap ); }
+
+ #define BEGIN_OBJECT_MAP(x) static _ATL_OBJMAP_ENTRY x[] = {
+-#define END_OBJECT_MAP() {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}};
++#define END_OBJECT_MAP() {NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}};
+ #define OBJECT_ENTRY(clsid, class) {&clsid, class::UpdateRegistry, class::_ClassFactoryCreatorClass::CreateInstance, class::_CreatorClass::CreateInstance, NULL, 0, class::GetObjectDescription, class::GetCategoryMap, class::ObjectMain },
+ #define OBJECT_ENTRY_NON_CREATEABLE(class) {&CLSID_NULL, class::UpdateRegistry, NULL, NULL, NULL, 0, NULL, class::GetCategoryMap, class::ObjectMain },
+
+@@ -2492,9 +2502,9 @@
+ public:
+ typedef ThreadModel _ThreadModel;
+ #ifdef OLD_ATL_CRITSEC_CODE
+- typename typedef _ThreadModel::AutoCriticalSection _CritSec;
++ typedef typename _ThreadModel::AutoCriticalSection _CritSec;
+ #else
+- typename typedef _ThreadModel::AutoDeleteCriticalSection _AutoDelCritSec;
++ typedef typename _ThreadModel::AutoDeleteCriticalSection _AutoDelCritSec;
+ #endif /* OLD_ATL_CRITSEC_CODE */
+ typedef CComObjectLockT<_ThreadModel> ObjectLock;
+
+@@ -2638,8 +2648,8 @@
+ // Set refcount to 1 to protect destruction
+ ~CComObject()
+ {
+- m_dwRef = 1L;
+- FinalRelease();
++ this->m_dwRef = 1L;
++ this->FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(_GetRawUnknown());
+ #endif
+@@ -2647,22 +2657,24 @@
+ }
+ //If InternalAddRef or InternalRelease is undefined then your class
+ //doesn't derive from CComObjectRoot
+- STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
++ STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
+ STDMETHOD_(ULONG, Release)()
+ {
+- ULONG l = InternalRelease();
++ ULONG l = this->InternalRelease();
+ if (l == 0)
+ delete this;
+ return l;
+ }
+ //if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
+ STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
+- {return _InternalQueryInterface(iid, ppvObject);}
++ {return this->_InternalQueryInterface(iid, ppvObject);}
++#if 0
+ template <class Q>
+ HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
+ {
+ return QueryInterface(__uuidof(Q), (void**)pp);
+ }
++#endif
+
+ static HRESULT WINAPI CreateInstance(CComObject<Base>** pp);
+ };
+@@ -2719,8 +2731,8 @@
+ #endif /* OLD_ATL_CRITSEC_CODE */
+ ~CComObjectCached()
+ {
+- m_dwRef = 1L;
+- FinalRelease();
++ this->m_dwRef = 1L;
++ this->FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(_GetRawUnknown());
+ #endif
+@@ -2729,14 +2741,14 @@
+ //doesn't derive from CComObjectRoot
+ STDMETHOD_(ULONG, AddRef)()
+ {
+- ULONG l = InternalAddRef();
++ ULONG l = this->InternalAddRef();
+ if (l == 2)
+ _Module.Lock();
+ return l;
+ }
+ STDMETHOD_(ULONG, Release)()
+ {
+- ULONG l = InternalRelease();
++ ULONG l = this->InternalRelease();
+ if (l == 0)
+ delete this;
+ else if (l == 1)
+@@ -2745,7 +2757,7 @@
+ }
+ //if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
+ STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
+- {return _InternalQueryInterface(iid, ppvObject);}
++ {return this->_InternalQueryInterface(iid, ppvObject);}
+ #ifndef OLD_ATL_CRITSEC_CODE
+ CComGlobalsThreadModel::AutoDeleteCriticalSection m_csCached;
+ #endif /* OLD_ATL_CRITSEC_CODE */
+@@ -2762,8 +2774,8 @@
+ // Set refcount to 1 to protect destruction
+ ~CComObjectNoLock()
+ {
+- m_dwRef = 1L;
+- FinalRelease();
++ this->m_dwRef = 1L;
++ this->FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(_GetRawUnknown());
+ #endif
+@@ -2771,17 +2783,17 @@
+
+ //If InternalAddRef or InternalRelease is undefined then your class
+ //doesn't derive from CComObjectRoot
+- STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
++ STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
+ STDMETHOD_(ULONG, Release)()
+ {
+- ULONG l = InternalRelease();
++ ULONG l = this->InternalRelease();
+ if (l == 0)
+ delete this;
+ return l;
+ }
+ //if _InternalQueryInterface is undefined then you forgot BEGIN_COM_MAP
+ STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
+- {return _InternalQueryInterface(iid, ppvObject);}
++ {return this->_InternalQueryInterface(iid, ppvObject);}
+ };
+
+ // It is possible for Base not to derive from CComObjectRoot
+@@ -2794,14 +2806,14 @@
+ CComObjectGlobal(void* = NULL)
+ {
+ #ifndef OLD_ATL_CRITSEC_CODE
+- m_hResFinalConstruct = _AtlInitialConstruct();
++ m_hResFinalConstruct = this->_AtlInitialConstruct();
+ if (SUCCEEDED(m_hResFinalConstruct))
+ #endif /* OLD_ATL_CRITSEC_CODE */
+- m_hResFinalConstruct = FinalConstruct();
++ m_hResFinalConstruct = this->FinalConstruct();
+ }
+ ~CComObjectGlobal()
+ {
+- FinalRelease();
++ this->FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(_GetRawUnknown());
+ #endif
+@@ -2810,7 +2822,7 @@
+ STDMETHOD_(ULONG, AddRef)() {return _Module.Lock();}
+ STDMETHOD_(ULONG, Release)(){return _Module.Unlock();}
+ STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
+- {return _InternalQueryInterface(iid, ppvObject);}
++ {return this->_InternalQueryInterface(iid, ppvObject);}
+ HRESULT m_hResFinalConstruct;
+ };
+
+@@ -2824,14 +2836,14 @@
+ CComObjectStack(void* = NULL)
+ {
+ #ifndef OLD_ATL_CRITSEC_CODE
+- m_hResFinalConstruct = _AtlInitialConstruct();
++ m_hResFinalConstruct = this->_AtlInitialConstruct();
+ if (SUCCEEDED(m_hResFinalConstruct))
+ #endif /* OLD_ATL_CRITSEC_CODE */
+- m_hResFinalConstruct = FinalConstruct();
++ m_hResFinalConstruct = this->FinalConstruct();
+ }
+ ~CComObjectStack()
+ {
+- FinalRelease();
++ this->FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(_GetRawUnknown());
+ #endif
+@@ -2850,6 +2862,8 @@
+ {
+ public:
+ typedef Base _BaseClass;
++ using Base::_GetRawUnknown;
++ using Base::m_pOuterUnknown;
+ CComContainedObject(void* pv) {m_pOuterUnknown = (IUnknown*)pv;}
+ #ifdef _ATL_DEBUG_INTERFACES
+ ~CComContainedObject()
+@@ -2859,20 +2873,22 @@
+ }
+ #endif
+
+- STDMETHOD_(ULONG, AddRef)() {return OuterAddRef();}
+- STDMETHOD_(ULONG, Release)() {return OuterRelease();}
++ STDMETHOD_(ULONG, AddRef)() {return this->OuterAddRef();}
++ STDMETHOD_(ULONG, Release)() {return this->OuterRelease();}
+ STDMETHOD(QueryInterface)(REFIID iid, void ** ppvObject)
+ {
+- HRESULT hr = OuterQueryInterface(iid, ppvObject);
++ HRESULT hr = this->OuterQueryInterface(iid, ppvObject);
+ if (FAILED(hr) && _GetRawUnknown() != m_pOuterUnknown)
+- hr = _InternalQueryInterface(iid, ppvObject);
++ hr = this->_InternalQueryInterface(iid, ppvObject);
+ return hr;
+ }
++#if 0
+ template <class Q>
+ HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
+ {
+ return QueryInterface(__uuidof(Q), (void**)pp);
+ }
++#endif
+ //GetControllingUnknown may be virtual if the Base class has declared
+ //DECLARE_GET_CONTROLLING_UNKNOWN()
+ IUnknown* GetControllingUnknown()
+@@ -2915,18 +2931,18 @@
+ // override it in your class and call each base class' version of this
+ HRESULT FinalConstruct()
+ {
+- CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
++ CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
+ return m_contained.FinalConstruct();
+ }
+ void FinalRelease()
+ {
+- CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
++ CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
+ m_contained.FinalRelease();
+ }
+ // Set refcount to 1 to protect destruction
+ ~CComAggObject()
+ {
+- m_dwRef = 1L;
++ this->m_dwRef = 1L;
+ FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(this);
+@@ -2934,10 +2950,10 @@
+ _Module.Unlock();
+ }
+
+- STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
++ STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
+ STDMETHOD_(ULONG, Release)()
+ {
+- ULONG l = InternalRelease();
++ ULONG l = this->InternalRelease();
+ if (l == 0)
+ delete this;
+ return l;
+@@ -2959,11 +2975,13 @@
+ hRes = m_contained._InternalQueryInterface(iid, ppvObject);
+ return hRes;
+ }
++#if 0
+ template <class Q>
+ HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
+ {
+ return QueryInterface(__uuidof(Q), (void**)pp);
+ }
++#endif
+ static HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, CComAggObject<contained>** pp)
+ {
+ _ATL_VALIDATE_OUT_POINTER(pp);
+@@ -3023,21 +3041,21 @@
+ // override it in your class and call each base class' version of this
+ HRESULT FinalConstruct()
+ {
+- InternalAddRef();
+- CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
++ this->InternalAddRef();
++ CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
+ HRESULT hr = m_contained.FinalConstruct();
+- InternalRelease();
++ this->InternalRelease();
+ return hr;
+ }
+ void FinalRelease()
+ {
+- CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
++ CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
+ m_contained.FinalRelease();
+ }
+ // Set refcount to 1 to protect destruction
+ ~CComPolyObject()
+ {
+- m_dwRef = 1L;
++ this->m_dwRef = 1L;
+ FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(this);
+@@ -3045,10 +3063,10 @@
+ _Module.Unlock();
+ }
+
+- STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
++ STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
+ STDMETHOD_(ULONG, Release)()
+ {
+- ULONG l = InternalRelease();
++ ULONG l = this->InternalRelease();
+ if (l == 0)
+ delete this;
+ return l;
+@@ -3072,11 +3090,13 @@
+ hRes = m_contained._InternalQueryInterface(iid, ppvObject);
+ return hRes;
+ }
++#if 0
+ template <class Q>
+ HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp)
+ {
+ return QueryInterface(__uuidof(Q), (void**)pp);
+ }
++#endif
+ static HRESULT WINAPI CreateInstance(LPUNKNOWN pUnkOuter, CComPolyObject<contained>** pp)
+ {
+ _ATL_VALIDATE_OUT_POINTER(pp);
+@@ -3111,27 +3131,28 @@
+ class CComTearOffObject : public Base
+ {
+ public:
++ using Base::m_pOwner;
+ CComTearOffObject(void* pv)
+ {
+ ATLASSERT(m_pOwner == NULL);
+- m_pOwner = reinterpret_cast<CComObject<Base::_OwnerClass>*>(pv);
++ m_pOwner = reinterpret_cast<CComObject<typename Base::_OwnerClass>*>(pv);
+ m_pOwner->AddRef();
+ }
+ // Set refcount to 1 to protect destruction
+ ~CComTearOffObject()
+ {
+- m_dwRef = 1L;
+- FinalRelease();
++ this->m_dwRef = 1L;
++ this->FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(_GetRawUnknown());
+ #endif
+ m_pOwner->Release();
+ }
+
+- STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
++ STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
+ STDMETHOD_(ULONG, Release)()
+ {
+- ULONG l = InternalRelease();
++ ULONG l = this->InternalRelease();
+ if (l == 0)
+ delete this;
+ return l;
+@@ -3150,27 +3171,27 @@
+ public:
+ typedef contained _BaseClass;
+ CComCachedTearOffObject(void* pv) :
+- m_contained(((contained::_OwnerClass*)pv)->GetControllingUnknown())
++ m_contained(((typename contained::_OwnerClass*)pv)->GetControllingUnknown())
+ {
+ ATLASSERT(m_contained.m_pOwner == NULL);
+- m_contained.m_pOwner = reinterpret_cast<CComObject<contained::_OwnerClass>*>(pv);
++ m_contained.m_pOwner = reinterpret_cast<CComObject<typename contained::_OwnerClass>*>(pv);
+ }
+ //If you get a message that this call is ambiguous then you need to
+ // override it in your class and call each base class' version of this
+ HRESULT FinalConstruct()
+ {
+- CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
++ CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalConstruct();
+ return m_contained.FinalConstruct();
+ }
+ void FinalRelease()
+ {
+- CComObjectRootEx<contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
++ CComObjectRootEx<typename contained::_ThreadModel::ThreadModelNoCS>::FinalRelease();
+ m_contained.FinalRelease();
+ }
+ // Set refcount to 1 to protect destruction
+ ~CComCachedTearOffObject()
+ {
+- m_dwRef = 1L;
++ this->m_dwRef = 1L;
+ FinalRelease();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.DeleteNonAddRefThunk(this);
+@@ -3178,10 +3199,10 @@
+ }
+
+
+- STDMETHOD_(ULONG, AddRef)() {return InternalAddRef();}
++ STDMETHOD_(ULONG, AddRef)() {return this->InternalAddRef();}
+ STDMETHOD_(ULONG, Release)()
+ {
+- ULONG l = InternalRelease();
++ ULONG l = this->InternalRelease();
+ if (l == 0)
+ delete this;
+ return l;
+@@ -3260,7 +3281,9 @@
+ {
+ public:
+ typedef license _LicenseClass;
+- typedef CComClassFactory2<license> _ComMapClass;
++ using license::IsLicenseValid;
++ using license::GetLicenseKey;
++// typedef CComClassFactory2<license> _ComMapClass;
+ BEGIN_COM_MAP(CComClassFactory2<license>)
+ COM_INTERFACE_ENTRY(IClassFactory)
+ COM_INTERFACE_ENTRY(IClassFactory2)
+@@ -3297,7 +3320,7 @@
+ if (ppvObject == NULL)
+ return E_POINTER;
+ *ppvObject = NULL;
+- if ( ((bstrKey != NULL) && !VerifyLicenseKey(bstrKey)) ||
++ if ( ((bstrKey != NULL) && !this->VerifyLicenseKey(bstrKey)) ||
+ ((bstrKey == NULL) && !IsLicenseValid()) )
+ return CLASS_E_NOTLICENSED;
+ if ((pUnkOuter != NULL) && !InlineIsEqualUnknown(riid))
+@@ -3363,7 +3386,7 @@
+ if (pUnkOuter != NULL)
+ hRes = CLASS_E_NOAGGREGATION;
+ else
+- hRes = _Module.CreateInstance(m_pfnCreateInstance, riid, ppvObj);
++ hRes = _Module.CreateInstance((LPVOID)m_pfnCreateInstance, riid, ppvObj);
+ }
+ return hRes;
+ }
+@@ -3454,6 +3477,7 @@
+ lpszHelpFile, iid, hRes);
+ }
+ #endif
++#if 0
+ template <class Q>
+ static HRESULT CreateInstance(IUnknown* punkOuter, Q** pp)
+ {
+@@ -3464,6 +3488,7 @@
+ {
+ return T::_CreatorClass::CreateInstance(NULL, __uuidof(Q), (void**) pp);
+ }
++#endif
+ };
+
+ // ATL doesn't support multiple LCID's at the same time
+@@ -3651,7 +3676,7 @@
+ {
+ CComPtr<ITypeInfo> spInfo(spTypeInfo);
+ CComPtr<ITypeInfo2> spTypeInfo2;
+- if (SUCCEEDED(spTypeInfo->QueryInterface(&spTypeInfo2)))
++ if (SUCCEEDED(spTypeInfo->QueryInterface(IID_ITypeInfo2, (void**)&spTypeInfo2)))
+ spInfo = spTypeInfo2;
+
+ m_pInfo = spInfo.Detach();
+@@ -3760,6 +3785,9 @@
+ /////////////////////////////////////////////////////////////////////////////
+ // IDispEventImpl
+
++template <class T>
++struct _ATL_EVENT_ENTRY;
++
+ #ifdef _ATL_DLL
+ ATLAPI AtlGetObjectSourceInterface(IUnknown* punkObj, GUID* plibid, IID* piid, unsigned short* pdwMajor, unsigned short* pdwMinor);
+ #else
+@@ -3909,16 +3937,17 @@
+ #else
+
+ #pragma warning(disable:4740) // flow in/out of inline disables global opts
+-inline void __declspec(naked) __stdcall CComStdCallThunkHelper()
++inline void __stdcall CComStdCallThunkHelper()
+ {
+- __asm
+- {
+- mov eax, [esp+4]; // get pThunk
+- mov edx, [eax+4]; // get the pThunk->pThis
+- mov [esp+4], edx; // replace pThunk with pThis
+- mov eax, [eax+8]; // get pThunk->pfn
+- jmp eax; // jump pfn
+- };
++ asm(
++ " movl $8(%ebp), %eax\n" // get pThunk
++ " movl $4(%eax), edx\n" // get the pThunk->pThis
++ " movl %edx, $8(%ebp)\n" // replace pThunk with pThis
++ " movl $8(%eax), %eax\n" // get pThunk->pfn
++ " movl %ebp, %esp\n"
++ " popl %ebp\n"
++ " jmp %eax" // jump pfn
++ );
+ }
+ #pragma warning(default:4740)
+ #endif
+@@ -3985,6 +4014,7 @@
+ class ATL_NO_VTABLE IDispEventSimpleImpl : public _IDispEventLocator<nID, pdiid>
+ {
+ public:
++ using _IDispEventLocator<nID, pdiid>::m_dwEventCookie;
+ STDMETHOD(_LocDEQueryInterface)(REFIID riid, void ** ppvObject)
+ {
+ _ATL_VALIDATE_OUT_POINTER(ppvObject);
+@@ -3992,7 +4022,7 @@
+ if (InlineIsEqualGUID(riid, *pdiid) ||
+ InlineIsEqualUnknown(riid) ||
+ InlineIsEqualGUID(riid, IID_IDispatch) ||
+- InlineIsEqualGUID(riid, m_iid))
++ InlineIsEqualGUID(riid, this->m_iid))
+ {
+ *ppvObject = this;
+ AddRef();
+@@ -4186,6 +4216,10 @@
+ {
+ public:
+ typedef tihclass _tihclass;
++ using IDispEventSimpleImpl<nID, T, pdiid>::m_libid;
++ using IDispEventSimpleImpl<nID, T, pdiid>::m_iid;
++ using IDispEventSimpleImpl<nID, T, pdiid>::m_wMajorVerNum;
++ using IDispEventSimpleImpl<nID, T, pdiid>::m_wMinorVerNum;
+
+ IDispEventImpl()
+ {
+@@ -4475,6 +4509,11 @@
+ }
+ };
+
++template <class Base, const IID* piid, class T, class Copy, class ThreadModel = CComObjectThreadModel>
++class ATL_NO_VTABLE CComEnum;
++template <class Base, const IID* piid, class T, class Copy, class CollType, class ThreadModel = CComObjectThreadModel>
++class ATL_NO_VTABLE CComEnumOnSTL;
++
+
+ /////////////////////////////////////////////////////////////////////////////
+ // CComEnumImpl
+@@ -4746,7 +4785,7 @@
+ return S_OK;
+ }
+
+-template <class Base, const IID* piid, class T, class Copy, class ThreadModel = CComObjectThreadModel>
++template <class Base, const IID* piid, class T, class Copy, class ThreadModel>
+ class ATL_NO_VTABLE CComEnum :
+ public CComEnumImpl<Base, piid, T, Copy>,
+ public CComObjectRootEx< ThreadModel >
+@@ -4868,7 +4907,7 @@
+ return hRes;
+ }
+
+-template <class Base, const IID* piid, class T, class Copy, class CollType, class ThreadModel = CComObjectThreadModel>
++template <class Base, const IID* piid, class T, class Copy, class CollType, class ThreadModel>
+ class ATL_NO_VTABLE CComEnumOnSTL :
+ public IEnumOnSTLImpl<Base, piid, T, Copy, CollType>,
+ public CComObjectRootEx< ThreadModel >
+@@ -4901,7 +4940,7 @@
+ return E_INVALIDARG;
+ HRESULT hr = E_FAIL;
+ Index--;
+- CollType::iterator iter = m_coll.begin();
++ typename CollType::iterator iter = m_coll.begin();
+ while (iter != m_coll.end() && Index > 0)
+ {
+ iter++;
+@@ -5314,7 +5353,7 @@
+ if (InlineIsEqualGUID(riid, IID_IConnectionPoint) || InlineIsEqualUnknown(riid))
+ {
+ *ppvObject = this;
+- AddRef();
++ this->AddRef();
+ #ifdef _ATL_DEBUG_INTERFACES
+ _Module.AddThunk((IUnknown**)ppvObject, _T("IConnectionPointImpl"), riid);
+ #endif // _ATL_DEBUG_INTERFACES
+--- include/atl/atlconv.h.orig 2005-04-14 17:54:32.000000000 +0900
++++ include/atl/atlconv.h 2007-12-31 07:29:34.759750000 +0900
+@@ -10,6 +10,9 @@
+
+ #ifndef __ATLCONV_H__
+ #define __ATLCONV_H__
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #ifndef __cplusplus
+ #error ATL requires C++ compilation (use a .cpp suffix)
+@@ -30,7 +33,11 @@
+ // Following code is to avoid alloca causing a stack overflow.
+ // It is intended for use from the _ATL_SAFE_ALLOCA macros
+ // or Conversion macros.
+-__declspec(selectany) DWORD _Atlosplatform = 0;
++#ifdef _INIT_ATL_COMMON_VARS
++DWORD _Atlosplatform = 0;
++#else
++extern DWORD _Atlosplatform;
++#endif
+ inline BOOL _AtlGetVersionEx()
+ {
+ OSVERSIONINFO osi;
+@@ -156,8 +163,11 @@
+ #pragma prefast(suppress:515, "Atlresetstkoflw is the same as resetstkoflw")
+
+ // Verifies if sufficient space is available on the stack.
+-inline bool _AtlVerifyStackAvailable(SIZE_T Size)
++inline bool _AtlVerifyStackAvailable(SIZE_T /*Size*/)
+ {
++#if 1
++ return false;
++#else
+ bool bStackAvailable = true;
+
+ __try
+@@ -173,6 +183,7 @@
+ _Atlresetstkoflw();
+ }
+ return bStackAvailable;
++#endif
+ }
+
+ #pragma prefast(pop)
+@@ -281,15 +292,15 @@
+
+ #ifdef _CONVERSION_USES_THREAD_LOCALE
+ #ifndef _DEBUG
+- #define USES_CONVERSION int _convert; _convert; UINT _acp = GetACP(); _acp; LPCWSTR _lpw; _lpw; LPCSTR _lpa; _lpa
++ #define USES_CONVERSION int _convert; (void)_convert; UINT _acp = GetACP(); (void)_acp; LPCWSTR _lpw; (void)_lpw; LPCSTR _lpa; (void)_lpa
+ #else
+- #define USES_CONVERSION int _convert = 0; _convert; UINT _acp = GetACP(); _acp; LPCWSTR _lpw = NULL; _lpw; LPCSTR _lpa = NULL; _lpa
++ #define USES_CONVERSION int _convert = 0; (void)_convert; UINT _acp = GetACP(); (void)_acp; LPCWSTR _lpw = NULL; (void)_lpw; LPCSTR _lpa = NULL; (void)_lpa
+ #endif
+ #else
+ #ifndef _DEBUG
+- #define USES_CONVERSION int _convert; _convert; UINT _acp = CP_ACP; _acp; LPCWSTR _lpw; _lpw; LPCSTR _lpa; _lpa
++ #define USES_CONVERSION int _convert; (void)_convert; UINT _acp = CP_ACP; (void)_acp; LPCWSTR _lpw; (void)_lpw; LPCSTR _lpa; (void)_lpa
+ #else
+- #define USES_CONVERSION int _convert = 0; _convert; UINT _acp = CP_ACP; _acp; LPCWSTR _lpw = NULL; _lpw; LPCSTR _lpa = NULL; _lpa
++ #define USES_CONVERSION int _convert = 0; (void)_convert; UINT _acp = CP_ACP; (void)_acp; LPCWSTR _lpw = NULL; (void)_lpw; LPCSTR _lpa = NULL; (void)_lpa
+ #endif
+ #endif
+
+--- include/atl/atlctl.h.orig 2005-04-14 17:54:32.000000000 +0900
++++ include/atl/atlctl.h 2009-04-19 13:31:15.146000000 +0900
+@@ -10,6 +10,9 @@
+
+ #ifndef __ATLCTL_H__
+ #define __ATLCTL_H__
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #ifndef __cplusplus
+ #error ATL requires C++ compilation (use a .cpp suffix)
+@@ -57,7 +60,7 @@
+ namespace ATL
+ {
+
+-#pragma pack(push, _ATL_PACKING)
++#pragma pack(push, 8)
+
+ // Forward declarations
+ //
+@@ -142,7 +145,9 @@
+ CComControlBase(HWND& h) : m_hWndCD(h)
+ {
+ memset(this, 0, sizeof(CComControlBase));
+- m_phWndCD = &h;
++ // previous element of m_hWndCD in this class is m_rcPos
++ *reinterpret_cast<HWND **>(reinterpret_cast<DWORD>(reinterpret_cast<char *>(&m_rcPos)+sizeof(m_rcPos)+(__alignof__(m_hWndCD)-1))&(-(__alignof__(m_hWndCD))))=&h;
++// m_phWndCD = &h;
+ m_sizeExtent.cx = 2*2540;
+ m_sizeExtent.cy = 2*2540;
+ m_sizeNatural = m_sizeExtent;
+@@ -530,13 +535,13 @@
+ SIZE m_sizeNatural; //unscaled size in himetric
+ SIZE m_sizeExtent; //current extents in himetric
+ RECT m_rcPos; // position in pixels
+-#pragma warning(disable: 4510 4610) // unnamed union
+- union
+- {
++//#pragma warning(disable: 4510 4610) // unnamed union
++// union
++// {
+ HWND& m_hWndCD;
+- HWND* m_phWndCD;
+- };
+-#pragma warning(default: 4510 4610)
++// HWND* m_phWndCD;
++// };
++//#pragma warning(default: 4510 4610)
+ union
+ {
+ // m_nFreezeEvents is the only one actually used
+@@ -1362,7 +1367,7 @@
+ class ATL_NO_VTABLE CComControl : public CComControlBase, public WinBase
+ {
+ public:
+- CComControl() : CComControlBase(m_hWnd) {}
++ CComControl() : CComControlBase(this->m_hWnd) {}
+ HRESULT FireOnRequestEdit(DISPID dispID)
+ {
+ T* pT = static_cast<T*>(this);
+@@ -1401,6 +1406,8 @@
+ class CComCompositeControl : public CComControl< T, CAxDialogImpl< T > >
+ {
+ public:
++ using CComControl< T, CAxDialogImpl< T > >::m_hWnd;
++ using CComControl< T, CAxDialogImpl< T > >::GetNextDlgTabItem;
+ CComCompositeControl()
+ {
+ m_hbrBackground = NULL;
+@@ -1429,7 +1436,7 @@
+ m_hbrBackground = NULL;
+ }
+ OLE_COLOR clr;
+- HRESULT hr = GetAmbientBackColor(clr);
++ HRESULT hr = this->GetAmbientBackColor(clr);
+ if (SUCCEEDED(hr))
+ {
+ COLORREF rgb;
+@@ -1443,7 +1450,7 @@
+ {
+ CAxWindow wnd(hwnd);
+ CComPtr<IAxWinAmbientDispatch> spDispatch;
+- wnd.QueryHost(&spDispatch);
++ wnd.QueryHost(IID_IAxWinAmbientDispatch, (void**)&spDispatch);
+ if (spDispatch != NULL)
+ spDispatch->put_BackColor((OLE_COLOR)l);
+ return TRUE;
+@@ -1458,10 +1465,10 @@
+ }
+ HWND Create(HWND hWndParent, RECT& /*rcPos*/, LPARAM dwInitParam = NULL)
+ {
+- CComControl< T, CAxDialogImpl< T > >::Create(hWndParent, dwInitParam);
++ this->Create(hWndParent, dwInitParam);
+ SetBackgroundColorFromAmbient();
+ if (m_hWnd != NULL)
+- ShowWindow(SW_SHOWNOACTIVATE);
++ this->ShowWindow(SW_SHOWNOACTIVATE);
+ return m_hWnd;
+ }
+ BOOL CalcExtent(SIZE& size)
+@@ -1488,7 +1495,7 @@
+ return FALSE;
+ // find a direct child of the dialog from the window that has focus
+ HWND hWndCtl = ::GetFocus();
+- if (IsChild(hWndCtl) && ::GetParent(hWndCtl) != m_hWnd)
++ if (this->IsChild(hWndCtl) && ::GetParent(hWndCtl) != m_hWnd)
+ {
+ do
+ {
+@@ -1546,7 +1553,7 @@
+ break;
+ }
+
+- return IsDialogMessage(pMsg);
++ return this->IsDialogMessage(pMsg);
+ }
+ HRESULT IOleInPlaceObject_InPlaceDeactivate(void)
+ {
+@@ -1563,7 +1570,7 @@
+ }
+ virtual HRESULT OnDraw(ATL_DRAWINFO& di)
+ {
+- if(!m_bInPlaceActive)
++ if(!this->m_bInPlaceActive)
+ {
+ HPEN hPen = (HPEN)::GetStockObject(BLACK_PEN);
+ HBRUSH hBrush = (HBRUSH)::GetStockObject(GRAY_BRUSH);
+@@ -1626,7 +1633,7 @@
+ }
+ STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
+ {
+- dispid;
++ (void)dispid;
+ ATLTRACE2(atlTraceControls,2,_T("IOleControlImpl::OnAmbientPropertyChange\n"));
+ ATLTRACE2(atlTraceControls,2,_T(" -- DISPID = %d (%d)\n"), dispid);
+ return S_OK;
+@@ -2905,7 +2912,7 @@
+ ATLTRACE2(atlTraceControls,2,_T("~CBindStatusCallback\n"));
+ }
+
+- STDMETHOD(OnStartBinding)(DWORD dwReserved, IBinding *pBinding)
++ STDMETHOD(OnStartBinding)(DWORD /*dwReserved*/, IBinding *pBinding)
+ {
+ ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnStartBinding\n"));
+ m_spBinding = pBinding;
+@@ -2923,19 +2930,19 @@
+ return S_OK;
+ }
+
+- STDMETHOD(OnLowResource)(DWORD reserved)
++ STDMETHOD(OnLowResource)(DWORD /*reserved*/)
+ {
+ ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnLowResource"));
+ return S_OK;
+ }
+
+- STDMETHOD(OnProgress)(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
++ STDMETHOD(OnProgress)(ULONG /*ulProgress*/, ULONG /*ulProgressMax*/, ULONG /*ulStatusCode*/, LPCWSTR /*szStatusText*/)
+ {
+ ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnProgress"));
+ return S_OK;
+ }
+
+- STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR szError)
++ STDMETHOD(OnStopBinding)(HRESULT /*hresult*/, LPCWSTR /*szError*/)
+ {
+ ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnStopBinding\n"));
+ (m_pT->*m_pFunc)(this, NULL, 0);
+@@ -2962,7 +2969,7 @@
+ return S_OK;
+ }
+
+- STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
++ STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC */*pformatetc*/, STGMEDIUM *pstgmed)
+ {
+ ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnDataAvailable\n"));
+ HRESULT hr = S_OK;
+@@ -3005,7 +3012,7 @@
+ return hr;
+ }
+
+- STDMETHOD(OnObjectAvailable)(REFIID riid, IUnknown *punk)
++ STDMETHOD(OnObjectAvailable)(REFIID /*riid*/, IUnknown */*punk*/)
+ {
+ ATLTRACE2(atlTraceControls,2,_T("CBindStatusCallback::OnObjectAvailable"));
+ return S_OK;
+--- include/atl/atlwin.h.orig 2005-04-14 17:54:32.000000000 +0900
++++ include/atl/atlwin.h 2007-12-31 07:29:28.525375000 +0900
+@@ -10,6 +10,9 @@
+
+ #ifndef __ATLWIN_H__
+ #define __ATLWIN_H__
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #ifndef __cplusplus
+ #error ATL requires C++ compilation (use a .cpp suffix)
+@@ -99,6 +102,8 @@
+ #else
+ #define CWndClassInfo CWndClassInfoA
+ #endif
++template <DWORD t_dwStyle = 0, DWORD t_dwExStyle = 0> class CWinTraits;
++typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0> CControlWinTraits;
+ template <class T, class TBase = CWindow, class TWinTraits = CControlWinTraits> class CWindowImpl;
+ template <class T, class TBase = CWindow> class CDialogImpl;
+ #ifndef _ATL_NO_HOSTING
+@@ -658,6 +663,13 @@
+ ATLASSERT(::IsWindow(m_hWnd));
+ return ::GetDlgItemText(m_hWnd, nID, lpStr, nMaxCount);
+ }
++
++ HWND GetDlgItem(int nID) const
++ {
++ ATLASSERT(::IsWindow(m_hWnd));
++ return ::GetDlgItem(m_hWnd, nID);
++ }
++
+ BOOL GetDlgItemText(int nID, BSTR& bstrText) const
+ {
+ ATLASSERT(::IsWindow(m_hWnd));
+@@ -847,12 +859,6 @@
+ return (int)::SetWindowLong(m_hWnd, GWL_ID, nID);
+ }
+
+- HWND GetDlgItem(int nID) const
+- {
+- ATLASSERT(::IsWindow(m_hWnd));
+- return ::GetDlgItem(m_hWnd, nID);
+- }
+-
+ // Alert Functions
+
+ BOOL FlashWindow(BOOL bInvert)
+@@ -1319,7 +1325,9 @@
+ }
+ };
+
+-_declspec(selectany) RECT CWindow::rcDefault = { CW_USEDEFAULT, CW_USEDEFAULT, 0, 0 };
++#ifdef _INIT_ATL_COMMON_VARS
++RECT CWindow::rcDefault = { CW_USEDEFAULT, CW_USEDEFAULT, 0, 0 };
++#endif
+
+ /////////////////////////////////////////////////////////////////////////////
+ // CAxWindow - client side for an ActiveX host window
+@@ -1330,6 +1338,7 @@
+ class CAxWindowT : public TBase
+ {
+ public:
++ using TBase::m_hWnd;
+ // Constructors
+ CAxWindowT(HWND hWnd = NULL) : TBase(hWnd)
+ { }
+@@ -1439,11 +1448,13 @@
+ hr = spUnk->QueryInterface(iid, ppUnk);
+ return hr;
+ }
++#if 0
+ template <class Q>
+ HRESULT QueryHost(Q** ppUnk)
+ {
+ return QueryHost(__uuidof(Q), (void**)ppUnk);
+ }
++#endif
+ HRESULT QueryControl(REFIID iid, void** ppUnk)
+ {
+ ATLASSERT(ppUnk != NULL);
+@@ -1459,11 +1470,13 @@
+ hr = spUnk->QueryInterface(iid, ppUnk);
+ return hr;
+ }
++#if 0
+ template <class Q>
+ HRESULT QueryControl(Q** ppUnk)
+ {
+ return QueryControl(__uuidof(Q), (void**)ppUnk);
+ }
++#endif
+ HRESULT SetExternalDispatch(IDispatch* pDisp)
+ {
+ HRESULT hr;
+@@ -1521,12 +1534,12 @@
+ BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
+ { \
+ BOOL bHandled = TRUE; \
+- hWnd; \
+- uMsg; \
+- wParam; \
+- lParam; \
+- lResult; \
+- bHandled; \
++ (void)hWnd; \
++ (void)uMsg; \
++ (void)wParam; \
++ (void)lParam; \
++ (void)lResult; \
++ (void)bHandled; \
+ switch(dwMsgMapID) \
+ { \
+ case 0:
+@@ -1750,7 +1763,7 @@
+
+ // search for an empty one
+
+- for(i = 0; i < m_aChainEntry.GetSize(); i++)
++ for(int i = 0; i < m_aChainEntry.GetSize(); i++)
+ {
+ if(m_aChainEntry[i] == NULL)
+ {
+@@ -1841,7 +1854,7 @@
+ /////////////////////////////////////////////////////////////////////////////
+ // CWinTraits - Defines various default values for a window
+
+-template <DWORD t_dwStyle = 0, DWORD t_dwExStyle = 0>
++template <DWORD t_dwStyle, DWORD t_dwExStyle>
+ class CWinTraits
+ {
+ public:
+@@ -1855,7 +1868,7 @@
+ }
+ };
+
+-typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0> CControlWinTraits;
++//typedef CWinTraits<WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0> CControlWinTraits;
+ typedef CWinTraits<WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE> CFrameWinTraits;
+ typedef CWinTraits<WS_OVERLAPPEDWINDOW | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_MDICHILD> CMDIChildWinTraits;
+
+@@ -1882,6 +1895,7 @@
+ class ATL_NO_VTABLE CWindowImplRoot : public TBase, public CMessageMap
+ {
+ public:
++ using TBase::GetDlgItem;
+ CWndProcThunk m_thunk;
+ const MSG* m_pCurrentMsg;
+
+@@ -1892,7 +1906,7 @@
+ ~CWindowImplRoot()
+ {
+ #ifdef _DEBUG
+- if(m_hWnd != NULL) // should be cleared in WindowProc
++ if(this->m_hWnd != NULL) // should be cleared in WindowProc
+ {
+ ATLTRACE2(atlTraceWindowing, 0, _T("ERROR - Object deleted before window was destroyed\n"));
+ ATLASSERT(FALSE);
+@@ -2017,6 +2031,8 @@
+ class ATL_NO_VTABLE CWindowImplBaseT : public CWindowImplRoot< TBase >
+ {
+ public:
++ using CWindowImplRoot< TBase >::m_hWnd;
++ using CWindowImplRoot< TBase >::m_thunk;
+ WNDPROC m_pfnSuperWindowProc;
+
+ CWindowImplBaseT() : m_pfnSuperWindowProc(::DefWindowProc)
+@@ -2049,7 +2065,7 @@
+
+ LRESULT DefWindowProc()
+ {
+- const MSG* pMsg = m_pCurrentMsg;
++ const MSG* pMsg = this->m_pCurrentMsg;
+ LRESULT lRes = 0;
+ if (pMsg != NULL)
+ lRes = DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam);
+@@ -2091,7 +2107,7 @@
+ if(pOldProc != StartWindowProc)
+ ATLTRACE2(atlTraceWindowing, 0, _T("Subclassing through a hook discarded.\n"));
+ #else
+- pOldProc; // avoid unused warning
++ (void)pOldProc; // avoid unused warning
+ #endif
+ return pProc(hWnd, uMsg, wParam, lParam);
+ }
+@@ -2219,6 +2235,7 @@
+ class ATL_NO_VTABLE CWindowImpl : public CWindowImplBaseT< TBase, TWinTraits >
+ {
+ public:
++ using CWindowImplBaseT< TBase, TWinTraits >::StartWindowProc;
+ DECLARE_WND_CLASS(NULL)
+
+ HWND Create(HWND hWndParent, RECT& rcPos, LPCTSTR szWindowName = NULL,
+@@ -2226,8 +2243,8 @@
+ UINT nID = 0, LPVOID lpCreateParam = NULL)
+ {
+ if (T::GetWndClassInfo().m_lpszOrigName == NULL)
+- T::GetWndClassInfo().m_lpszOrigName = GetWndClassName();
+- ATOM atom = T::GetWndClassInfo().Register(&m_pfnSuperWindowProc);
++ T::GetWndClassInfo().m_lpszOrigName = this->GetWndClassName();
++ ATOM atom = T::GetWndClassInfo().Register(&(this->m_pfnSuperWindowProc));
+
+ dwStyle = T::GetWndStyle(dwStyle);
+ dwExStyle = T::GetWndExStyle(dwExStyle);
+@@ -2244,6 +2261,7 @@
+ class ATL_NO_VTABLE CDialogImplBaseT : public CWindowImplRoot< TBase >
+ {
+ public:
++ using CWindowImplRoot< TBase >::m_hWnd;
+ virtual DLGPROC GetDialogProc()
+ {
+ return DialogProc;
+@@ -2344,6 +2362,9 @@
+ class ATL_NO_VTABLE CDialogImpl : public CDialogImplBaseT< TBase >
+ {
+ public:
++ using CDialogImplBaseT< TBase >::m_hWnd;
++ using CDialogImplBaseT< TBase >::m_thunk;
++ typedef CDialogImplBaseT< TBase > CDialogImplBase_Class;
+ #ifdef _DEBUG
+ bool m_bModal;
+ CDialogImpl() : m_bModal(false) { }
+@@ -2422,6 +2443,8 @@
+ class ATL_NO_VTABLE CAxDialogImpl : public CDialogImplBaseT< TBase >
+ {
+ public:
++ using CDialogImplBaseT< TBase >::m_hWnd;
++ using CDialogImplBaseT< TBase >::m_thunk;
+ #ifdef _DEBUG
+ bool m_bModal;
+ CAxDialogImpl() : m_bModal(false) { }
+@@ -2515,6 +2538,8 @@
+ class CContainedWindowT : public TBase
+ {
+ public:
++ using TBase::m_hWnd;
++ using TBase::GetWndClassName;
+ CWndProcThunk m_thunk;
+ LPCTSTR m_lpszClassName;
+ WNDPROC m_pfnSuperWindowProc;
+@@ -2536,7 +2561,7 @@
+ { }
+
+ CContainedWindowT(CMessageMap* pObject, DWORD dwMsgMapID = 0)
+- : m_lpszClassName(TBase::GetWndClassName()),
++ : m_lpszClassName(GetWndClassName()),
+ m_pfnSuperWindowProc(::DefWindowProc),
+ m_pObject(pObject), m_dwMsgMapID(dwMsgMapID),
+ m_pCurrentMsg(NULL)
+@@ -2666,7 +2691,7 @@
+ LPCTSTR szWindowName = NULL, DWORD dwStyle = 0, DWORD dwExStyle = 0,
+ UINT nID = 0, LPVOID lpCreateParam = NULL)
+ {
+- m_lpszClassName = TBase::GetWndClassName();
++ m_lpszClassName = GetWndClassName();
+ m_pfnSuperWindowProc = ::DefWindowProc;
+ m_pObject = pObject;
+ m_dwMsgMapID = dwMsgMapID;
+@@ -2959,8 +2984,11 @@
+ {
+
+ ::EnterCriticalSection(&pM->m_csWindowCreate);
+- __try
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0)
+ {
++ _sehandler.Set(_sejmpbuf, &pM->m_csWindowCreate, EXCEPTION_CONTINUE_SEARCH, NULL, atlfinalleavecriticalsection);
+ if(p->m_atom == 0)
+ {
+ HINSTANCE hInst = pM->m_hInst;
+@@ -2979,7 +3007,7 @@
+ if(!::GetClassInfoExA(_Module.GetModuleInstance(), p->m_lpszOrigName, &wc))
+ {
+ fFail = TRUE;
+- __leave;
++ __builtin_longjmp(_sejmpbuf, 1);
+ }
+ }
+ memcpy(&p->m_wc, &wc, sizeof(WNDCLASSEX));
+@@ -3011,10 +3039,7 @@
+ p->m_atom = ::RegisterClassExA(&p->m_wc);
+ }
+ }
+- __finally
+- {
+- ::LeaveCriticalSection(&pM->m_csWindowCreate);
+- }
++ _sehandler.Reset();
+ }
+
+ if (fFail)
+@@ -3038,8 +3063,11 @@
+ if (p->m_atom == 0)
+ {
+ ::EnterCriticalSection(&pM->m_csWindowCreate);
+- __try
++ jmp_buf _sejmpbuf;
++ __SEHandler _sehandler;
++ if (__builtin_setjmp(_sejmpbuf) == 0)
+ {
++ _sehandler.Set(_sejmpbuf, &pM->m_csWindowCreate, EXCEPTION_CONTINUE_SEARCH, NULL, atlfinalleavecriticalsection);
+ if(p->m_atom == 0)
+ {
+ HINSTANCE hInst = pM->m_hInst;
+@@ -3058,7 +3086,7 @@
+ if(!::GetClassInfoExW(_Module.GetModuleInstance(), p->m_lpszOrigName, &wc))
+ {
+ fFail = TRUE;
+- __leave;
++ __builtin_longjmp(_sejmpbuf, -1);
+ }
+ }
+ memcpy(&p->m_wc, &wc, sizeof(WNDCLASSEX));
+@@ -3090,10 +3118,7 @@
+ p->m_atom = ::RegisterClassExW(&p->m_wc);
+ }
+ }
+- __finally
+- {
+- ::LeaveCriticalSection(&pM->m_csWindowCreate);
+- }
++ _sehandler.Reset();
+ }
+
+ if (fFail)
+--- include/atl/statreg.h.orig 2005-04-14 17:54:34.000000000 +0900
++++ include/atl/statreg.h 2006-09-18 20:05:01.468750000 +0900
+@@ -573,15 +573,16 @@
+ return hRes;
+ }
+
+-__declspec(selectany) LPCTSTR CRegParser::rgszNeverDelete[] = //Component Catagories
++#ifdef _INIT_ATL_COMMON_VARS
++LPCTSTR CRegParser::rgszNeverDelete[] = //Component Catagories
+ {
+ _T("CLSID"), _T("TYPELIB")
+ };
+
+-__declspec(selectany) const int CRegParser::cbNeverDelete = sizeof(rgszNeverDelete) / sizeof(LPCTSTR*);
+-__declspec(selectany) const int CRegParser::MAX_VALUE=4096;
+-__declspec(selectany) const int CRegParser::MAX_TYPE=MAX_VALUE;
+-
++const int CRegParser::cbNeverDelete = sizeof(rgszNeverDelete) / sizeof(LPCTSTR*);
++const int CRegParser::MAX_VALUE=4096;
++const int CRegParser::MAX_TYPE=MAX_VALUE;
++#endif
+
+ inline BOOL CRegParser::VTFromRegType(LPCTSTR szValueType, VARTYPE& vt)
+ {
diff --git a/external/mingwheaders/mingw_headers.patch b/external/mingwheaders/mingw_headers.patch
new file mode 100644
index 000000000000..22995bf19773
--- /dev/null
+++ b/external/mingwheaders/mingw_headers.patch
@@ -0,0 +1,2130 @@
+--- include/crtdbg.h.orig 2006-09-18 01:21:38.968750000 +0900
++++ include/crtdbg.h 2006-09-02 23:12:50.109375000 +0900
+@@ -0,0 +1,11 @@
++#ifndef _CRTDBG_H
++#define _CRTDBG_H
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
++
++#ifndef _ASSERTE
++#define _ASSERTE(expr) ((void)0)
++#endif
++
++#endif
+--- include/excpt.h.orig 2009-01-11 04:32:43.000000000 +0900
++++ include/excpt.h 2009-08-21 09:21:56.000000000 +0900
+@@ -16,8 +16,11 @@
+
+ /* All the headers include this file. */
+ #include <_mingw.h>
++#include <setjmp.h>
++#include <stdarg.h>
+
+ #include <windef.h>
++#include <winbase.h>
+
+ /*
+ * NOTE: The constants structs and typedefs below should be defined in the
+@@ -52,7 +55,7 @@
+ * The type of function that is expected as an exception handler to be
+ * installed with __try1.
+ */
+-typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)
++typedef EXCEPTION_DISPOSITION (* PEXCEPTION_HANDLER)
+ (struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
+
+ /*
+@@ -93,8 +96,122 @@
+ __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
+ : : : "%eax");
+
++WINBASEAPI
++VOID
++WINAPI
++RtlUnwind (
++ IN PVOID TargetFrame OPTIONAL,
++ IN PVOID TargetIp OPTIONAL,
++ IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
++ IN PVOID ReturnValue
++ );
+ #ifdef __cplusplus
+ }
++
++class __SEHandler
++{
++ public:
++ __SEHandler() {}
++ ~__SEHandler() {}
++ typedef int (*PF)(void *, LPEXCEPTION_POINTERS);
++ typedef void (*PH)(void *, LPEXCEPTION_POINTERS);
++ typedef void (*PN)(void *);
++ void Set(jmp_buf jb, void *pdata=NULL, PF pfilter=NULL, PH phandlerbody=NULL, PN pfinal=NULL)
++ {
++ __builtin_memcpy(m_jmpbuf, jb, sizeof(jmp_buf));
++ m_pData=pdata;
++ switch (reinterpret_cast<int>(pfilter))
++ {
++ default:
++ m_filter=pfilter;
++ break;
++ case EXCEPTION_CONTINUE_EXECUTION:
++ m_filter=DefaultFilterContinueExecution;
++ break;
++ case EXCEPTION_EXECUTE_HANDLER:
++ m_filter=DefaultFilterExecuteHandler;
++ break;
++ case EXCEPTION_CONTINUE_SEARCH:
++ m_filter=DefaultFilterContinueSearch;
++ break;
++ }
++ if (phandlerbody)
++ m_handlerbody=phandlerbody;
++ else
++ m_handlerbody=DefaultHandler;
++ if (pfinal)
++ m_final=pfinal;
++ else
++ m_final=DefaultFinal;
++ m_ER.pHandlerClass = this;
++ m_ER.hp = handler;
++ asm("movl %%fs:0, %%eax\n\t"
++ "movl %%eax, %0": : "m" (m_ER.prev): "%eax" );
++ asm("movl %0, %%eax\n\t"
++ "movl %%eax, %%fs:0": : "r" (&m_ER): "%eax" );
++ }
++ void Reset()
++ {
++ m_final(m_pData);
++ asm("movl %0, %%eax \n\t"
++ "movl %%eax, %%fs:0"
++ : : "m" (m_ER.prev): "%eax");
++ }
++ private:
++ __SEHandler(const __SEHandler&);
++ __SEHandler& operator=(const __SEHandler&);
++ struct _ER {
++ _ER* prev;
++ PEXCEPTION_HANDLER hp;
++ __SEHandler *pHandlerClass;
++ };
++ static EXCEPTION_DISPOSITION handler(
++ struct _EXCEPTION_RECORD *pExceptionRecord,
++ void * EstablisherFrame,
++ struct _CONTEXT *ContextRecord,
++ void * /*DispatcherContext*/)
++ {
++ __SEHandler* pThis = reinterpret_cast< _ER * >(EstablisherFrame)->pHandlerClass;
++ if ( pExceptionRecord->ExceptionFlags & EH_UNWINDING )
++ {
++ pThis->m_final(pThis->m_pData);
++ return ExceptionContinueSearch;
++ }
++ EXCEPTION_POINTERS ep={pExceptionRecord, ContextRecord};
++ switch ( pThis->m_filter(pThis->m_pData, &ep) )
++ {
++ case EXCEPTION_EXECUTE_HANDLER:
++ RtlUnwind(EstablisherFrame, &&__set_label, pExceptionRecord, 0);
++__set_label:
++ pThis->m_handlerbody(pThis->m_pData, &ep);
++ ContextRecord->Ebp = pThis->m_jmpbuf[0];
++ ContextRecord->Eip = pThis->m_jmpbuf[1];
++ ContextRecord->Esp = pThis->m_jmpbuf[2];
++ return ExceptionContinueExecution;
++ case EXCEPTION_CONTINUE_SEARCH:
++ return ExceptionContinueSearch;
++ case EXCEPTION_CONTINUE_EXECUTION:
++ return ExceptionContinueExecution;
++ }
++ return ExceptionContinueExecution;
++ }
++ static int DefaultFilterContinueSearch(void *, LPEXCEPTION_POINTERS) { return EXCEPTION_CONTINUE_SEARCH; }
++ static int DefaultFilterContinueExecution(void *, LPEXCEPTION_POINTERS) { return EXCEPTION_CONTINUE_EXECUTION; }
++ static int DefaultFilterExecuteHandler(void *, LPEXCEPTION_POINTERS) { return EXCEPTION_EXECUTE_HANDLER; }
++ static void DefaultHandler(void *, LPEXCEPTION_POINTERS) {}
++ static void DefaultFinal(void *) {}
++ typedef int (*handler_p)(
++ struct _EXCEPTION_RECORD *ExceptionRecord,
++ void * EstablisherFrame,
++ struct _CONTEXT *ContextRecord,
++ void * DispatcherContext);
++ _ER m_ER;
++ void *m_pData;
++ PN m_final;
++ PH m_handlerbody;
++ PF m_filter;
++ jmp_buf m_jmpbuf;
++};
+ #endif
+
+ #endif /* Not RC_INVOKED */
+--- include/tchar.h.orig 2009-01-11 04:32:46.000000000 +0900
++++ include/tchar.h 2009-08-21 09:21:56.000000000 +0900
+@@ -223,6 +223,9 @@
+ #define _ttelldir _wtelldir
+ #define _tseekdir _wseekdir
+
++#define _ttempnam _wtempnam
++
++
+ #else /* Not _UNICODE */
+
+ /*
+@@ -407,6 +410,8 @@
+ #define _ttelldir telldir
+ #define _tseekdir seekdir
+
++#define _ttempnam _tempnam
++
+ #endif /* Not _UNICODE */
+
+ /*
+--- include/amvideo.h.orig 2008-12-06 11:31:53.000000000 +0900
++++ include/amvideo.h 2009-08-21 09:21:56.000000000 +0900
+@@ -52,10 +52,10 @@
+ BITMAPINFOHEADER bmiHeader;
+ } VIDEOINFOHEADER;
+ typedef struct tagVIDEOINFO {
+- RECT rcSource,
+- RECT rcTarget,
+- DWORD dwBitRate,
+- DWORD dwBitErrorRate,
++ RECT rcSource;
++ RECT rcTarget;
++ DWORD dwBitRate;
++ DWORD dwBitErrorRate;
+ REFERENCE_TIME AvgTimePerFrame;
+ BITMAPINFOHEADER bmiHeader;
+ union {
+--- include/basetyps.h.orig 2008-12-06 11:31:53.000000000 +0900
++++ include/basetyps.h 2009-08-21 09:21:56.000000000 +0900
+@@ -80,6 +80,8 @@
+ CONST_VTABLE struct i##Vtbl
+ # define DECLARE_INTERFACE_(i,b) DECLARE_INTERFACE(i)
+ # endif
++# define DECLARE_INTERFACE_IID(i,s) EXTERN_C const IID IID_##i; DECLARE_INTERFACE(i)
++# define DECLARE_INTERFACE_IID_(i,b,s) EXTERN_C const IID IID_##i; DECLARE_INTERFACE_(i,b)
+ # define BEGIN_INTERFACE
+ # define END_INTERFACE
+
+--- include/objidl.h.orig 2008-12-06 11:32:04.000000000 +0900
++++ include/objidl.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#include <windows.h>
++#include <ole2.h>
++
+ #ifndef _OBJIDL_H
+ #define _OBJIDL_H
+ #if __GNUC__ >= 3
+@@ -880,8 +883,8 @@
+ STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
+ STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+ STDMETHOD_(ULONG,Release)(THIS) PURE;
+- STDMETHOD(AddConnection)(THIS_ DWORD,DWORD) PURE;
+- STDMETHOD(ReleaseConnection)(THIS_ DWORD,DWORD,BOOL) PURE;
++ STDMETHOD_(DWORD,AddConnection)(THIS_ DWORD,DWORD) PURE;
++ STDMETHOD_(DWORD,ReleaseConnection)(THIS_ DWORD,DWORD,BOOL) PURE;
+ };
+ #undef INTERFACE
+
+--- include/specstrings.h.orig 2008-12-06 11:32:09.000000000 +0900
++++ include/specstrings.h 2009-08-21 09:21:56.000000000 +0900
+@@ -11,8 +11,31 @@
+ /* __in and __out currently conflict with libstdc++, use with caution */
+
+
++#define __RPC__deref_inout_opt
++#define __RPC__deref_opt_inout_ecount_full_opt(size)
++#define __RPC__deref_opt_inout_opt
++#define __RPC__deref_out
++#define __RPC__deref_out_ecount_full_opt(size)
++#define __RPC__deref_out_opt
++#define __RPC__deref_out_opt_string
++#define __RPC__in
++#define __RPC__in_ecount_full(size)
++#define __RPC__in_ecount_full_opt(size)
++#define __RPC__in_opt
++#define __RPC__inout
++#define __RPC__inout_ecount_full(size)
++#define __RPC__inout_ecount_full_opt(size)
++#define __RPC__inout_opt
++#define __RPC__out
++#define __RPC__out_ecount_full(size)
++#define __RPC__out_ecount_full_string(size)
++#define __RPC__out_ecount_part(size,init)
++#define __RPC_unique_pointer
+ #define __bcount(size)
+ #define __bcount_opt(size)
++#define __callback
++#define __checkReturn
++#define __deref
+ #define __deref_bcount(size)
+ #define __deref_bcount_opt(size)
+ #define __deref_ecount(size)
+@@ -36,6 +59,7 @@
+ #define __deref_inout_ecount_opt(size)
+ #define __deref_inout_ecount_part(size,length)
+ #define __deref_inout_ecount_part_opt(size,length)
++#define __deref_inout_ecount_z(size)
+ #define __deref_inout_opt
+ #define __deref_opt_bcount(size)
+ #define __deref_opt_bcount_opt(size)
+@@ -89,14 +113,23 @@
+ #define __deref_out_ecount_part(size,length)
+ #define __deref_out_ecount_part_opt(size,length)
+ #define __deref_out_opt
++#define __deref_out_z
++#define __deref_out_z_opt
+ #define __ecount(size)
+ #define __ecount_opt(size)
++#define __field_bcount(size)
++#define __field_ecount(size)
++#define __field_ecount_opt(size)
++#define __format_string
++#define __gdi_entry
+ #define __in
+ #define __in_bcount(size)
+ #define __in_bcount_opt(size)
+ #define __in_ecount(size)
+ #define __in_ecount_opt(size)
+ #define __in_opt
++#define __in_xcount(size)
++#define __in_z_opt
+ #define __inout
+ #define __inout_bcount(size)
+ #define __inout_bcount_full(size)
+@@ -111,7 +144,12 @@
+ #define __inout_ecount_part(size,length)
+ #define __inout_ecount_part_opt(size,length)
+ #define __inout_opt
++#define __inout_xcount(size)
++#define __notnull
++#define __nullnullterminated
++#define __nullterminated
+ #define __out
++#define __out_awcount(expr,size)
+ #define __out_bcount(size)
+ #define __out_bcount_full(size)
+ #define __out_bcount_full_opt(size)
+@@ -119,12 +157,20 @@
+ #define __out_bcount_part(size,length)
+ #define __out_bcount_part_opt(size,length)
+ #define __out_ecount(size)
++#define __out_ecount(size)
+ #define __out_ecount_full(size)
+ #define __out_ecount_full_opt(size)
+ #define __out_ecount_opt(size)
+ #define __out_ecount_part(size,length)
+ #define __out_ecount_part_opt(size,length)
+ #define __out_opt
++#define __out_xcount(size)
++#define __out_xcount_opt(size)
++#define __reserved
++#define __struct_bcount(size)
++#define __success(expr)
++#define __typefix(ctype)
++#define __unaligned
+
+
+ #endif /*_SPECSTRINGS_H */
+--- include/uxtheme.h.orig 2008-12-06 11:32:11.000000000 +0900
++++ include/uxtheme.h 2010-01-22 14:50:56.327000000 +0900
+@@ -10,7 +10,7 @@
+ extern "C" {
+ #endif
+
+-#if (_WIN32_WINNT >= 0x0501)
++#if (_WIN32_WINNT >= 0x0500)
+ #define DTBG_CLIPRECT 0x00000001
+ #define DTBG_DRAWSOLID 0x00000002
+ #define DTBG_OMITBORDER 0x00000004
+@@ -35,6 +35,7 @@
+ #define HTTB_RESIZINGBORDER (HTTB_RESIZINGBORDER_LEFT|HTTB_RESIZINGBORDER_TOP|HTTB_RESIZINGBORDER_RIGHT|HTTB_RESIZINGBORDER_BOTTOM)
+ #define HTTB_SIZINGTEMPLATE 0x0100
+ #define HTTB_SYSTEMSIZINGMARGINS 0x0200
++#if 0
+ #define TMT_DISPLAYNAME 0x0259
+ #define TMT_TOOLTIP 0x025A
+ #define TMT_COMPANY 0x025B
+@@ -186,6 +187,7 @@
+ #define BT_IMAGEFILE 0x0000
+ #define BT_BORDERFILL 0x0001
+ #define BT_NONE 0x0002
++#endif
+
+ typedef enum PROPERTYORIGIN {
+ PO_STATE = 0,
+--- include/winbase.h.orig 2008-12-06 11:32:11.000000000 +0900
++++ include/winbase.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1354,8 +1354,8 @@
+ WINBASEAPI HANDLE WINAPI FindFirstFileExW(LPCWSTR,FINDEX_INFO_LEVELS,PVOID,FINDEX_SEARCH_OPS,PVOID,DWORD);
+ WINBASEAPI BOOL WINAPI FindFirstFreeAce(PACL,PVOID*);
+ #if (_WIN32_WINNT >= 0x0500)
+-WINBASEAPI HANDLE WINAPI FindFirstVolumeA(LPCSTR,DWORD);
+-WINBASEAPI HANDLE WINAPI FindFirstVolumeW(LPCWSTR,DWORD);
++WINBASEAPI HANDLE WINAPI FindFirstVolumeA(LPSTR,DWORD);
++WINBASEAPI HANDLE WINAPI FindFirstVolumeW(LPWSTR,DWORD);
+ WINBASEAPI HANDLE WINAPI FindFirstVolumeMountPointA(LPSTR,LPSTR,DWORD);
+ WINBASEAPI HANDLE WINAPI FindFirstVolumeMountPointW(LPWSTR,LPWSTR,DWORD);
+ #endif
+@@ -1363,7 +1363,7 @@
+ WINBASEAPI BOOL WINAPI FindNextFileA(HANDLE,LPWIN32_FIND_DATAA);
+ WINBASEAPI BOOL WINAPI FindNextFileW(HANDLE,LPWIN32_FIND_DATAW);
+ #if (_WIN32_WINNT >= 0x0500)
+-WINBASEAPI BOOL WINAPI FindNextVolumeA(HANDLE,LPCSTR,DWORD);
++WINBASEAPI BOOL WINAPI FindNextVolumeA(HANDLE,LPSTR,DWORD);
+ WINBASEAPI BOOL WINAPI FindNextVolumeW(HANDLE,LPWSTR,DWORD);
+ WINBASEAPI BOOL WINAPI FindNextVolumeMountPointA(HANDLE,LPSTR,DWORD);
+ WINBASEAPI BOOL WINAPI FindNextVolumeMountPointW(HANDLE,LPWSTR,DWORD);
+@@ -1475,10 +1475,10 @@
+ WINBASEAPI DWORD WINAPI GetLogicalDrives(void);
+ WINBASEAPI DWORD WINAPI GetLogicalDriveStringsA(DWORD,LPSTR);
+ WINBASEAPI DWORD WINAPI GetLogicalDriveStringsW(DWORD,LPWSTR);
+-#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
++//#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
+ WINBASEAPI DWORD WINAPI GetLongPathNameA(LPCSTR,LPSTR,DWORD);
+ WINBASEAPI DWORD WINAPI GetLongPathNameW(LPCWSTR,LPWSTR,DWORD);
+-#endif
++//#endif
+ WINBASEAPI BOOL WINAPI GetMailslotInfo(HANDLE,PDWORD,PDWORD,PDWORD,PDWORD);
+ WINBASEAPI DWORD WINAPI GetModuleFileNameA(HINSTANCE,LPSTR,DWORD);
+ WINBASEAPI DWORD WINAPI GetModuleFileNameW(HINSTANCE,LPWSTR,DWORD);
+@@ -1519,9 +1519,9 @@
+ #endif
+ WINBASEAPI HANDLE WINAPI GetProcessHeap(VOID);
+ WINBASEAPI DWORD WINAPI GetProcessHeaps(DWORD,PHANDLE);
+-#if (_WIN32_WINNT >= 0x0501)
++//#if (_WIN32_WINNT >= 0x0501)
+ WINBASEAPI DWORD WINAPI GetProcessId(HANDLE);
+-#endif
++//#endif
+ #if (_WIN32_WINNT >= 0x0500)
+ WINBASEAPI BOOL WINAPI GetProcessIoCounters(HANDLE,PIO_COUNTERS);
+ #endif
+@@ -1802,9 +1802,9 @@
+ WINBASEAPI BOOL WINAPI OpenProcessToken(HANDLE,DWORD,PHANDLE);
+ WINBASEAPI HANDLE WINAPI OpenSemaphoreA(DWORD,BOOL,LPCSTR);
+ WINBASEAPI HANDLE WINAPI OpenSemaphoreW(DWORD,BOOL,LPCWSTR);
+-#if (_WIN32_WINNT >= 0x0500) || (_WIN32_WINDOWS >= 0x0490)
++//#if (_WIN32_WINNT >= 0x0500) || (_WIN32_WINDOWS >= 0x0490)
+ WINBASEAPI HANDLE WINAPI OpenThread(DWORD,BOOL,DWORD);
+-#endif
++//#endif
+ WINBASEAPI BOOL WINAPI OpenThreadToken(HANDLE,DWORD,BOOL,PHANDLE);
+ WINBASEAPI HANDLE WINAPI OpenWaitableTimerA(DWORD,BOOL,LPCSTR);
+ WINBASEAPI HANDLE WINAPI OpenWaitableTimerW(DWORD,BOOL,LPCWSTR);
+@@ -2029,6 +2029,7 @@
+ WINBASEAPI DWORD WINAPI WaitForSingleObjectEx(HANDLE,DWORD,BOOL);
+ WINBASEAPI BOOL WINAPI WaitNamedPipeA(LPCSTR,DWORD);
+ WINBASEAPI BOOL WINAPI WaitNamedPipeW(LPCWSTR,DWORD);
++WINBASEAPI UINT WINAPI WinExec(LPCSTR,UINT);
+ WINBASEAPI BOOL WINAPI WinLoadTrustProvider(GUID*);
+ WINBASEAPI BOOL WINAPI WriteFile(HANDLE,PCVOID,DWORD,PDWORD,LPOVERLAPPED);
+ WINBASEAPI BOOL WINAPI WriteFileEx(HANDLE,PCVOID,DWORD,LPOVERLAPPED,LPOVERLAPPED_COMPLETION_ROUTINE);
+@@ -2151,9 +2152,9 @@
+ #define GetFileAttributesEx GetFileAttributesExW
+ #define GetFullPathName GetFullPathNameW
+ #define GetLogicalDriveStrings GetLogicalDriveStringsW
+-#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
++//#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
+ #define GetLongPathName GetLongPathNameW
+-#endif
++//#endif
+ #define GetModuleFileName GetModuleFileNameW
+ #define GetModuleHandle GetModuleHandleW
+ #if (_WIN32_WINNT >= 0x0500)
+@@ -2346,9 +2347,9 @@
+ #define GetFileAttributesEx GetFileAttributesExA
+ #define GetFullPathName GetFullPathNameA
+ #define GetLogicalDriveStrings GetLogicalDriveStringsA
+-#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
++//#if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
+ #define GetLongPathName GetLongPathNameA
+-#endif
++//#endif
+ #define GetNamedPipeHandleState GetNamedPipeHandleStateA
+ #define GetModuleHandle GetModuleHandleA
+ #if (_WIN32_WINNT >= 0x0500)
+--- include/windef.h.orig 2008-12-06 11:32:12.000000000 +0900
++++ include/windef.h 2009-08-21 09:21:56.000000000 +0900
+@@ -251,6 +251,7 @@
+ typedef unsigned int UINT,*PUINT,*LPUINT;
+
+ #include <winnt.h>
++#include <specstrings.h>
+
+ typedef UINT_PTR WPARAM;
+ typedef LONG_PTR LPARAM;
+--- include/wininet.h.orig 2008-12-06 11:32:13.000000000 +0900
++++ include/wininet.h 2009-08-21 09:21:56.000000000 +0900
+@@ -868,6 +868,7 @@
+ BOOL WINAPI InternetAutodial(DWORD,DWORD);
+ BOOL WINAPI InternetAutodialHangup(DWORD);
+ BOOL WINAPI InternetGetConnectedState(LPDWORD,DWORD);
++BOOL WINAPI InternetGetConnectedStateEx(LPDWORD,LPTSTR,DWORD,DWORD);
+ BOOL WINAPI InternetSetDialState(LPCTSTR,DWORD,DWORD);
+ BOOL WINAPI InternetReadFileExA(HINTERNET,LPINTERNET_BUFFERSA,DWORD,DWORD_PTR);
+ BOOL WINAPI InternetReadFileExW(HINTERNET,LPINTERNET_BUFFERSW,DWORD,DWORD_PTR);
+--- include/winver.h.orig 2008-12-06 11:32:14.000000000 +0900
++++ include/winver.h 2009-08-21 09:21:56.000000000 +0900
+@@ -101,10 +101,10 @@
+ DWORD WINAPI VerFindFileW(DWORD,LPWSTR,LPWSTR,LPWSTR,LPWSTR,PUINT,LPWSTR,PUINT);
+ DWORD WINAPI VerInstallFileA(DWORD,LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,LPSTR,PUINT);
+ DWORD WINAPI VerInstallFileW(DWORD,LPWSTR,LPWSTR,LPWSTR,LPWSTR,LPWSTR,LPWSTR,PUINT);
+-DWORD WINAPI GetFileVersionInfoSizeA(LPCSTR,PDWORD);
+-DWORD WINAPI GetFileVersionInfoSizeW(LPCWSTR,PDWORD);
+-BOOL WINAPI GetFileVersionInfoA(LPCSTR,DWORD,DWORD,PVOID);
+-BOOL WINAPI GetFileVersionInfoW(LPCWSTR,DWORD,DWORD,PVOID);
++DWORD WINAPI GetFileVersionInfoSizeA(LPSTR,PDWORD);
++DWORD WINAPI GetFileVersionInfoSizeW(LPWSTR,PDWORD);
++BOOL WINAPI GetFileVersionInfoA(LPSTR,DWORD,DWORD,PVOID);
++BOOL WINAPI GetFileVersionInfoW(LPWSTR,DWORD,DWORD,PVOID);
+ DWORD WINAPI VerLanguageNameA(DWORD,LPSTR,DWORD);
+ DWORD WINAPI VerLanguageNameW(DWORD,LPWSTR,DWORD);
+ BOOL WINAPI VerQueryValueA(const LPVOID,LPSTR,LPVOID*,PUINT);
+--- include/wtypes.h.orig 2008-12-06 11:32:14.000000000 +0900
++++ include/wtypes.h 2009-08-21 09:21:56.000000000 +0900
+@@ -66,6 +66,19 @@
+ unsigned short asData[1];
+ }FLAGGED_WORD_BLOB;
+
++typedef struct _COAUTHIDENTITY
++ {
++ /* [size_is] */ USHORT *User;
++ /* [range] */ ULONG UserLength;
++ /* [size_is] */ USHORT *Domain;
++ /* [range] */ ULONG DomainLength;
++ /* [size_is] */ USHORT *Password;
++ /* [range] */ ULONG PasswordLength;
++ ULONG Flags;
++ } COAUTHIDENTITY;
++
++typedef WORD CLIPFORMAT,*LPCLIPFORMAT;
++
+ #ifndef OLE2ANSI
+ typedef WCHAR OLECHAR;
+ typedef LPWSTR LPOLESTR;
+@@ -94,6 +107,7 @@
+ }_STRUCT_NAME(s);
+ LONGLONG int64;
+ } CY;
++typedef union tagCY *LPCY;
+ typedef double DATE;
+ typedef struct tagBSTRBLOB {
+ ULONG cbSize;
+@@ -165,6 +179,52 @@
+ #define DECIMAL_SETZERO(d) {(d).Lo64=(d).Hi32=(d).signscale=0;}
+ #endif
+ typedef void *HMETAFILEPICT;
++
++typedef enum tagTYSPEC {
++ TYSPEC_CLSID,
++ TYSPEC_FILEEXT,
++ TYSPEC_MIMETYPE,
++ TYSPEC_FILENAME,
++ TYSPEC_PROGID,
++ TYSPEC_PACKAGENAME,
++ TYSPEC_OBJECTID
++} TYSPEC;
++
++typedef union {
++ CLSID clsid;
++ LPOLESTR pFileExt;
++ LPOLESTR pMimeType;
++ LPOLESTR pProgId;
++ LPOLESTR pFileName;
++ struct {
++ LPOLESTR pPackageName;
++ GUID PolicyId;
++ } ByName;
++ struct {
++ GUID ObjectId;
++ GUID PolicyId;
++ } ByObjectId;
++} uCLSSPEC;
++
++typedef struct tagCSPLATFORM {
++ DWORD dwContext;
++ DWORD dwVersionHi;
++ DWORD dwVersionLo;
++ DWORD dwProcessorArch;
++} CSPLATFORM;
++
++typedef struct tagQUERYCONTEXT {
++ DWORD dwContext;
++ CSPLATFORM Platform;
++ LCID Locale;
++ DWORD dwVersionHi;
++ DWORD dwVersionLo;
++} QUERYCONTEXT;
++typedef struct
++{
++ GUID fmtid;
++ DWORD pid;
++} PROPERTYKEY;
+ #ifdef __cplusplus
+ }
+ #endif
+--- include/adoctint.h.orig 2008-01-18 22:17:10.000000000 +0900
++++ include/adoctint.h 2009-08-21 09:21:56.000000000 +0900
+@@ -11,6 +11,9 @@
+ //--------------------------------------------------------------------
+ #ifndef _ADOCTINT_H_
+ #define _ADOCTINT_H_
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #ifndef _INC_TCHAR
+ #include <tchar.h>
+@@ -2489,11 +2492,11 @@
+ #endif /* __Procedure_INTERFACE_DEFINED__ */
+ EXTERN_C const CLSID CLSID_Catalog;
+ #ifdef __cplusplus
+-Catalog;
++//Catalog;
+ #endif
+ EXTERN_C const CLSID CLSID_Table;
+ #ifdef __cplusplus
+-Table;
++//Table;
+ #endif
+ #ifndef __Property_INTERFACE_DEFINED__
+ #define __Property_INTERFACE_DEFINED__
+@@ -2635,23 +2638,23 @@
+ #endif /* __Property_INTERFACE_DEFINED__ */
+ EXTERN_C const CLSID CLSID_Group;
+ #ifdef __cplusplus
+-Group;
++//Group;
+ #endif
+ EXTERN_C const CLSID CLSID_User;
+ #ifdef __cplusplus
+-User;
++//User;
+ #endif
+ EXTERN_C const CLSID CLSID_Column;
+ #ifdef __cplusplus
+-Column;
++//Column;
+ #endif
+ EXTERN_C const CLSID CLSID_Index;
+ #ifdef __cplusplus
+-Index;
++//Index;
+ #endif
+ EXTERN_C const CLSID CLSID_Key;
+ #ifdef __cplusplus
+-Key;
++//Key;
+ #endif
+ #ifndef __Tables_INTERFACE_DEFINED__
+ #define __Tables_INTERFACE_DEFINED__
+@@ -3332,8 +3335,8 @@
+ /* [in] */ VARIANT Item,
+ /* [defaultvalue][in] */ KeyTypeEnum Type,
+ /* [optional][in] */ VARIANT Column,
+- /* [defaultvalue][in] */ __RPC__in BSTR RelatedADOTable = L"",
+- /* [defaultvalue][in] */ __RPC__in BSTR RelatedADOColumn = L"") = 0;
++ /* [defaultvalue][in] */ __RPC__in BSTR RelatedADOTable = const_cast<BSTR>(L""),
++ /* [defaultvalue][in] */ __RPC__in BSTR RelatedADOColumn = const_cast<BSTR>(L"")) = 0;
+
+ virtual /* [helpcontext] */ HRESULT STDMETHODCALLTYPE Delete(
+ /* [in] */ VARIANT Item) = 0;
+--- include/adodef.h.orig 2008-01-18 22:17:10.000000000 +0900
++++ include/adodef.h 2009-08-21 09:21:56.000000000 +0900
+@@ -12,6 +12,9 @@
+
+ #ifndef _ADODEF_H_
+ #define _ADODEF_H_
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ // TYPELIB MAJOR VERSIONS
+ #define ADO_MAJOR 6
+--- include/adoguids.h.orig 2008-01-18 22:17:10.000000000 +0900
++++ include/adoguids.h 2009-08-21 09:21:56.000000000 +0900
+@@ -11,6 +11,10 @@
+ //-----------------------------------------------------------------------------
+
+
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
++
+ #define STRING_GUID(l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) l##-##w1##-##w2##-##b1##b2##-##b3##b4##b5##b6##b7##b8
+
+ #if defined(__midl) || defined(GEN_MIDL)
+--- include/adoint.h.orig 2008-01-18 22:17:10.000000000 +0900
++++ include/adoint.h 2009-08-21 09:21:56.000000000 +0900
+@@ -11,6 +11,9 @@
+ //--------------------------------------------------------------------
+ #ifndef _ADOINT_H_
+ #define _ADOINT_H_
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #ifndef _INC_TCHAR
+ #include <tchar.h>
+@@ -3494,7 +3497,7 @@
+ #endif /* __ADOConnectionConstruction_INTERFACE_DEFINED__ */
+ EXTERN_C const CLSID CLSID_Connection;
+ #ifdef __cplusplus
+-Connection;
++//Connection;
+ #endif
+ #ifndef ___Record_INTERFACE_DEFINED__
+ #define ___Record_INTERFACE_DEFINED__
+@@ -3793,7 +3796,7 @@
+ #endif /* ___Record_INTERFACE_DEFINED__ */
+ EXTERN_C const CLSID CLSID_Record;
+ #ifdef __cplusplus
+-Record;
++//Record;
+ #endif
+ #ifndef ___Stream_INTERFACE_DEFINED__
+ #define ___Stream_INTERFACE_DEFINED__
+@@ -4123,7 +4126,7 @@
+ #endif /* ___Stream_INTERFACE_DEFINED__ */
+ EXTERN_C const CLSID CLSID_Stream;
+ #ifdef __cplusplus
+-Stream;
++//Stream;
+ #endif
+ #ifndef __ADORecordConstruction_INTERFACE_DEFINED__
+ #define __ADORecordConstruction_INTERFACE_DEFINED__
+@@ -4405,11 +4408,11 @@
+ #endif /* __ADOCommandConstruction_INTERFACE_DEFINED__ */
+ EXTERN_C const CLSID CLSID_Command;
+ #ifdef __cplusplus
+-Command;
++//Command;
+ #endif
+ EXTERN_C const CLSID CLSID_Recordset;
+ #ifdef __cplusplus
+-Recordset;
++//Recordset;
+ #endif
+ #ifndef __Recordset15_INTERFACE_DEFINED__
+ #define __Recordset15_INTERFACE_DEFINED__
+@@ -8305,7 +8308,7 @@
+ #endif /* ___Parameter_INTERFACE_DEFINED__ */
+ EXTERN_C const CLSID CLSID_Parameter;
+ #ifdef __cplusplus
+-Parameter;
++//Parameter;
+ #endif
+ #ifndef __Parameters_INTERFACE_DEFINED__
+ #define __Parameters_INTERFACE_DEFINED__
+--- include/bcrypt.h.orig 2008-01-18 22:17:12.000000000 +0900
++++ include/bcrypt.h 2008-04-10 22:57:54.410750000 +0900
+@@ -40,12 +40,6 @@
+ #define OPTIONAL
+ #endif
+
+-#if !defined(__midl)
+-#define BCRYPT_STRUCT_ALIGNMENT __declspec(align(BCRYPT_OBJECT_ALIGNMENT))
+-#else
+-#define BCRYPT_STRUCT_ALIGNMENT
+-#endif /*!defined(__midl)*/
+-
+ //
+ // Alignment macros
+ //
+@@ -57,11 +51,7 @@
+ #define BCRYPT_OBJECT_ALIGNMENT 4
+ #endif
+
+-#if !defined(__midl)
+-#define BCRYPT_STRUCT_ALIGNMENT __declspec(align(BCRYPT_OBJECT_ALIGNMENT))
+-#else
+ #define BCRYPT_STRUCT_ALIGNMENT
+-#endif /*!defined(__midl)*/
+
+ //
+ // DeriveKey KDF Types
+@@ -108,7 +98,11 @@
+
+ typedef BCRYPT_KEY_LENGTHS_STRUCT BCRYPT_AUTH_TAG_LENGTHS_STRUCT;
+
+-#pragma pack(push, BCRYPT_OBJECT_ALIGNMENT)
++#if defined(_IA64_) || defined(_AMD64_)
++#pragma pack(push, 8)
++#else
++#pragma pack(push, 4)
++#endif
+ typedef BCRYPT_STRUCT_ALIGNMENT struct _BCRYPT_OID
+ {
+ ULONG cbOID;
+--- include/commctrl.h.orig 2008-01-18 22:17:14.000000000 +0900
++++ include/commctrl.h 2009-08-21 09:21:56.000000000 +0900
+@@ -14,6 +14,14 @@
+ #ifndef _INC_COMMCTRL
+ #define _INC_COMMCTRL
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #if defined(_MSC_VER) && (_MSC_VER >= 1200)
+ #pragma warning(push)
+ #pragma warning(disable:4001) /* nonstandard extension : single line comment */
+@@ -369,8 +377,10 @@
+
+ // Shell reserved (0U-580U) - (0U-589U)
+
++#ifndef CDN_FIRST
+ #define CDN_FIRST (0U-601U) // common dialog (new)
+ #define CDN_LAST (0U-699U)
++#endif
+
+ #define TBN_FIRST (0U-700U) // toolbar
+ #define TBN_LAST (0U-720U)
+@@ -683,7 +693,7 @@
+ #define ILP_DOWNLEVEL 1 // Write or reads the stream using downlevel sematics.
+
+
+-WINCOMMCTRLAPI HRESULT WINAPI ImageList_ReadEx(DWORD dwFlags, LPSTREAM pstm, REFIID riid, PVOID* ppv);
++//WINCOMMCTRLAPI HRESULT WINAPI ImageList_ReadEx(DWORD dwFlags, LPSTREAM pstm, REFIID riid, PVOID* ppv);
+ WINCOMMCTRLAPI HRESULT WINAPI ImageList_WriteEx(HIMAGELIST himl, DWORD dwFlags, LPSTREAM pstm);
+ #endif
+
+@@ -713,7 +723,7 @@
+ #endif
+
+ #if (_WIN32_WINNT >= 0x0501)
+-WINCOMMCTRLAPI HRESULT WINAPI HIMAGELIST_QueryInterface(HIMAGELIST himl, REFIID riid, void** ppv);
++//WINCOMMCTRLAPI HRESULT WINAPI HIMAGELIST_QueryInterface(HIMAGELIST himl, REFIID riid, void** ppv);
+
+ #ifdef __cplusplus
+ FORCEINLINE HIMAGELIST IImageListToHIMAGELIST(struct IImageList *himl)
+@@ -8056,8 +8066,10 @@
+ #if (_WIN32_WINNT >= 0x0501)
+
+ // custom combobox control messages
++#ifndef CB_SETMINVISIBLE
+ #define CB_SETMINVISIBLE (CBM_FIRST + 1)
+ #define CB_GETMINVISIBLE (CBM_FIRST + 2)
++#endif
+ #define CB_SETCUEBANNER (CBM_FIRST + 3)
+ #define CB_GETCUEBANNER (CBM_FIRST + 4)
+
+@@ -8651,7 +8663,7 @@
+
+ #if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
+ #if defined(ISOLATION_AWARE_ENABLED) && (ISOLATION_AWARE_ENABLED != 0)
+-#include "commctrl.inl"
++//#include "commctrl.inl"
+ #endif /* ISOLATION_AWARE_ENABLED */
+ #endif /* RC */
+
+@@ -8666,6 +8678,10 @@
+ #pragma warning(pop)
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif /* _INC_COMMCTRL */
+
+
+--- include/control.h.orig 2008-01-18 22:17:14.000000000 +0900
++++ include/control.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+--- include/dispex.h.orig 2008-01-18 22:17:16.000000000 +0900
++++ include/dispex.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+--- include/filter.h.orig 2008-01-18 22:17:18.000000000 +0900
++++ include/filter.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+--- include/gdiplusbitmap.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusbitmap.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /**************************************************************************\
+ *
+ * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
+--- include/gdiplusbrush.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusbrush.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /**************************************************************************\
+ *
+ * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
+--- include/gdiplusenums.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusenums.h 2009-08-21 09:21:56.000000000 +0900
+@@ -542,7 +542,7 @@
+
+ #define GDIP_EMFPLUS_RECORD_BASE 0x00004000
+ #define GDIP_WMF_RECORD_BASE 0x00010000
+-#define GDIP_WMF_RECORD_TO_EMFPLUS(n) ((EmfPlusRecordType)((n) | GDIP_WMF_RECORD_BASE))
++#define GDIP_WMF_RECORD_TO_EMFPLUS(n) ((n) | GDIP_WMF_RECORD_BASE)
+ #define GDIP_EMFPLUS_RECORD_TO_WMF(n) ((n) & (~GDIP_WMF_RECORD_BASE))
+ #define GDIP_IS_WMF_RECORDTYPE(n) (((n) & GDIP_WMF_RECORD_BASE) != 0)
+
+--- include/gdiplusfont.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusfont.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /**************************************************************************\
+ *
+ * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
+--- include/gdiplusheaders.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusheaders.h 2008-03-28 21:44:34.907750000 +0900
+@@ -704,7 +704,7 @@
+
+ class CachedBitmap : public GdiplusBase
+ {
+- friend Graphics;
++ friend class Graphics;
+
+ public:
+ CachedBitmap(IN Bitmap *bitmap,
+@@ -888,7 +888,7 @@
+
+ UINT GetDownLevelRasterizationLimit() const;
+
+- static UINT Metafile::EmfToWmfBits(
++ static UINT EmfToWmfBits(
+ IN HENHMETAFILE hemf,
+ IN UINT cbData16,
+ OUT LPBYTE pData16,
+--- include/gdiplusimageattributes.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusimageattributes.h 2009-08-21 09:21:56.000000000 +0900
+@@ -32,6 +32,9 @@
+
+ #ifndef _GDIPLUSIMAGEATTRIBUTES_H
+ #define _GDIPLUSIMAGEATTRIBUTES_H
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ class GpImageAttributes;
+
+--- include/gdiplusimaging.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusimaging.h 2009-08-21 09:21:56.000000000 +0900
+@@ -160,7 +160,7 @@
+ UINT Width;
+ UINT Height;
+ INT Stride;
+- PixelFormat PixelFormat;
++ ::Gdiplus::PixelFormat PixelFormat;
+ VOID* Scan0;
+ UINT_PTR Reserved;
+ };
+--- include/gdiplusmatrix.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusmatrix.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /**************************************************************************\
+ *
+ * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
+--- include/gdipluspath.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdipluspath.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /**************************************************************************\
+ *
+ * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
+--- include/gdipluspen.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdipluspen.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /**************************************************************************\
+ *
+ * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
+--- include/gdiplusregion.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusregion.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /**************************************************************************\
+ *
+ * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
+--- include/gdiplusstringformat.h.orig 2008-01-18 22:17:46.000000000 +0900
++++ include/gdiplusstringformat.h 2009-08-21 09:21:56.000000000 +0900
+@@ -217,7 +217,7 @@
+ ));
+ }
+
+- StringTrimming StringFormat::GetTrimming() const
++ StringTrimming GetTrimming() const
+ {
+ StringTrimming trimming;
+ SetStatus(DllExports::GdipGetStringFormatTrimming(
+--- include/imm.h.orig 2008-01-18 22:17:20.000000000 +0900
++++ include/imm.h 2009-08-21 09:21:56.000000000 +0900
+@@ -7,6 +7,13 @@
+ #ifndef _IMM_
+ #define _IMM_
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
+
+ #ifdef __cplusplus
+ extern "C" {
+@@ -715,5 +722,9 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // _IMM_
+
+--- include/imagehlp.h.orig 2008-01-18 22:17:20.000000000 +0900
++++ include/imagehlp.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /*++ BUILD Version: 0000 Increment this if a change has global effects
+
+ Copyright (c) Microsoft Corporation. All rights reserved.
+@@ -59,6 +62,13 @@
+ #include <wintrust.h>
+ #endif
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
+
+ #ifdef __cplusplus
+ extern "C" {
+@@ -407,7 +417,7 @@
+ IMAGEAPI
+ TouchFileTimes (
+ __in HANDLE FileHandle,
+- __in_opt PSYSTEMTIME pSystemTime
++ __in_opt LPSYSTEMTIME pSystemTime
+ );
+
+ BOOL
+@@ -3950,7 +3960,7 @@
+ // ThreadId must be 4 bytes on all architectures.
+ //
+
+-C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4);
++//C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4);
+
+ typedef struct _MINIDUMP_THREAD {
+ ULONG32 ThreadId;
+@@ -4684,5 +4694,9 @@
+ #endif
+
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // _IMAGEHLP_
+
+--- include/mapiwin.h.orig 2008-01-18 22:17:22.000000000 +0900
++++ include/mapiwin.h 2009-08-21 09:21:56.000000000 +0900
+@@ -428,5 +428,5 @@
+ #endif
+
+ #endif /* __MAPIWIN_H__ */
+-
++
+
+--- include/msdasc.h.orig 2008-01-18 22:17:26.000000000 +0900
++++ include/msdasc.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+--- include/msi.h.orig 2008-01-18 22:17:28.000000000 +0900
++++ include/msi.h 2009-08-21 09:21:56.000000000 +0900
+@@ -59,6 +59,14 @@
+ #endif // _MSI_NO_CRYPTO
+ #endif //(_WIN32_MSI >= 150)
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ // --------------------------------------------------------------------------
+ // Installer generic handle definitions
+ // --------------------------------------------------------------------------
+@@ -2248,5 +2256,9 @@
+ // LOCALIZE END
+
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // _MSI_H_
+
+--- include/msiquery.h.orig 2008-01-18 22:17:28.000000000 +0900
++++ include/msiquery.h 2009-08-21 09:21:56.000000000 +0900
+@@ -21,6 +21,14 @@
+ #define _MSIQUERY_H_
+ #include "msi.h" // INSTALLSTATE
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #define MSI_NULL_INTEGER 0x80000000 // integer value reserved for null
+
+ // MsiOpenDatabase persist predefine values, otherwise output database path is used
+@@ -1026,5 +1034,9 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // _MSIQUERY_H_
+
+--- include/multimon.h.orig 2008-01-18 22:17:30.000000000 +0900
++++ include/multimon.h 2009-08-21 09:21:56.000000000 +0900
+@@ -175,7 +175,7 @@
+
+ BOOL IsPlatformNT()
+ {
+- OSVERSIONINFOA osvi = {0};
++ OSVERSIONINFOA osvi;
+ osvi.dwOSVersionInfoSize = sizeof(osvi);
+ GetVersionExA((OSVERSIONINFOA*)&osvi);
+ return (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId);
+--- include/ntquery.h.orig 2008-01-18 22:17:30.000000000 +0900
++++ include/ntquery.h 2009-02-16 21:34:39.065125000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ //+---------------------------------------------------------------------------
+ //
+ // Microsoft Windows
+@@ -18,6 +21,14 @@
+
+ #include "stgprop.h"
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #if defined(__cplusplus)
+ extern "C"
+ {
+@@ -404,6 +415,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // __NTQUERY_H__
+
+
+--- include/oaidl.h.orig 2008-12-06 11:32:03.000000000 +0900
++++ include/oaidl.h 2010-02-27 13:28:29.448250000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -442,7 +445,7 @@
+ FLOAT fltVal;
+ DOUBLE dblVal;
+ VARIANT_BOOL boolVal;
+- _VARIANT_BOOL bool;
++// _VARIANT_BOOL bool;
+ SCODE scode;
+ CY cyVal;
+ DATE date;
+--- include/ocidl.h.orig 2008-01-18 22:17:32.000000000 +0900
++++ include/ocidl.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -294,6 +297,14 @@
+ #include "servprov.h"
+ #include "urlmon.h"
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+@@ -4595,11 +4606,13 @@
+ HITRESULT_HIT = 3
+ } HITRESULT;
+
++#if 0
+ typedef /* [v1_enum] */
+ enum tagDVASPECT2
+ { DVASPECT_OPAQUE = 16,
+ DVASPECT_TRANSPARENT = 32
+ } DVASPECT2;
++#endif
+
+ typedef struct tagExtentInfo
+ {
+@@ -6554,6 +6567,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif
+
+
+--- include/oleauto.h.orig 2008-01-18 22:17:32.000000000 +0900
++++ include/oleauto.h 2009-08-21 09:21:56.000000000 +0900
+@@ -56,6 +56,14 @@
+ /* pull in the MIDL generated header */
+ #include <oaidl.h>
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+
+ /*---------------------------------------------------------------------*/
+ /* BSTR API */
+@@ -1160,7 +1168,7 @@
+
+ // Declare variant access functions.
+
+-#if __STDC__ || defined(NONAMELESSUNION)
++#ifdef NONAMELESSUNION
+ #define V_UNION(X, Y) ((X)->n1.n2.n3.Y)
+ #define V_VT(X) ((X)->n1.n2.vt)
+ #define V_RECORDINFO(X) ((X)->n1.n2.n3.brecVal.pRecInfo)
+@@ -1242,5 +1250,9 @@
+ #include <poppack.h>
+ #endif // RC_INVOKED
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // __OLEAUTO_H__
+
+--- include/olectl.h.orig 2008-01-18 22:17:32.000000000 +0900
++++ include/olectl.h 2009-08-21 09:21:56.000000000 +0900
+@@ -28,6 +28,14 @@
+ #include <ocidl.h>
+ #endif // _MAC
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifdef _OLEAUT32_
+ #define WINOLECTLAPI STDAPI
+ #define WINOLECTLAPI_(type) STDAPI_(type)
+@@ -616,5 +624,9 @@
+
+ #endif // defined(__MKTYPLIB__) || defined(__midl)
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // _OLECTL_H_
+
+--- include/oledb.h.orig 2008-01-18 22:17:32.000000000 +0900
++++ include/oledb.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -797,7 +800,7 @@
+
+ //@@@+ V2.0
+ #if( OLEDBVER >= 0x0200 )
+-#if !defined(_WINBASE_) && !defined(_FILETIME_)
++#if !defined(_WINBASE_H) && !defined(_FILETIME_)
+ #define _FILETIME_
+ typedef struct _FILETIME {
+ DWORD dwLowDateTime;
+--- include/oleidl.h.orig 2008-01-18 22:17:32.000000000 +0900
++++ include/oleidl.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -189,6 +192,14 @@
+ /* header files for imported files */
+ #include "objidl.h"
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+@@ -3868,6 +3879,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif
+
+
+--- include/propidl.h.orig 2008-01-18 22:17:32.000000000 +0900
++++ include/propidl.h 2010-02-27 14:11:52.213875000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -76,6 +79,14 @@
+ #include "objidl.h"
+ #include "oaidl.h"
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+@@ -143,6 +154,7 @@
+ CHAR *pElems;
+ } CAC;
+
++#if 0
+ typedef struct tagCAUB
+ {
+ ULONG cElems;
+@@ -268,7 +280,9 @@
+ ULONG cElems;
+ CLSID *pElems;
+ } CACLSID;
++#endif
+
++#if 0
+ #ifdef MIDL_PASS
+ // This is the PROPVARIANT padding layout for marshaling.
+ typedef BYTE PROPVAR_PAD1;
+@@ -385,6 +399,7 @@
+ #endif
+
+ #endif /* _MSC_EXTENSIONS */
++#endif
+
+ #ifdef MIDL_PASS
+ // This is the LPPROPVARIANT definition for marshaling.
+@@ -509,6 +524,7 @@
+
+ #define PRSPEC_PROPID ( 1 )
+
++#if 0
+ typedef struct tagPROPSPEC
+ {
+ ULONG ulKind;
+@@ -526,12 +542,14 @@
+ PROPID propid;
+ VARTYPE vt;
+ } STATPROPSTG;
++#endif
+
+ // Macros for parsing the OS Version of the Property Set Header
+ #define PROPSETHDR_OSVER_KIND(dwOSVer) HIWORD( (dwOSVer) )
+ #define PROPSETHDR_OSVER_MAJOR(dwOSVer) LOBYTE(LOWORD( (dwOSVer) ))
+ #define PROPSETHDR_OSVER_MINOR(dwOSVer) HIBYTE(LOWORD( (dwOSVer) ))
+ #define PROPSETHDR_OSVERSION_UNKNOWN 0xFFFFFFFF
++#if 0
+ typedef struct tagSTATPROPSETSTG
+ {
+ FMTID fmtid;
+@@ -542,12 +560,14 @@
+ FILETIME atime;
+ DWORD dwOSVersion;
+ } STATPROPSETSTG;
++#endif
+
+
+
+ extern RPC_IF_HANDLE __MIDL_itf_propidl_0000_0000_v0_0_c_ifspec;
+ extern RPC_IF_HANDLE __MIDL_itf_propidl_0000_0000_v0_0_s_ifspec;
+
++#if 0
+ #ifndef __IPropertyStorage_INTERFACE_DEFINED__
+ #define __IPropertyStorage_INTERFACE_DEFINED__
+
+@@ -1119,7 +1139,6 @@
+ #endif /* C style interface */
+
+
+-
+ /* [call_as] */ HRESULT STDMETHODCALLTYPE IEnumSTATPROPSETSTG_RemoteNext_Proxy(
+ IEnumSTATPROPSETSTG * This,
+ /* [in] */ ULONG celt,
+@@ -1136,6 +1155,7 @@
+
+
+ #endif /* __IEnumSTATPROPSETSTG_INTERFACE_DEFINED__ */
++#endif
+
+
+ /* interface __MIDL_itf_propidl_0000_0004 */
+@@ -1268,6 +1287,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif
+
+
+--- include/propkeydef.h.orig 2008-01-18 22:17:32.000000000 +0900
++++ include/propkeydef.h 2009-08-21 09:21:56.000000000 +0900
+@@ -2,6 +2,10 @@
+ #define PID_FIRST_USABLE 2
+ #endif
+
++#ifndef __MIDL_CONST
++#define __MIDL_CONST const
++#endif
++
+ #ifndef REFPROPERTYKEY
+ #ifdef __cplusplus
+ #define REFPROPERTYKEY const PROPERTYKEY &
+--- include/propsys.h.orig 2008-01-18 22:17:34.000000000 +0900
++++ include/propsys.h 2009-08-21 09:21:56.000000000 +0900
+@@ -228,6 +228,14 @@
+ #endif // 0
+ #include <propkeydef.h>
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+
+ extern RPC_IF_HANDLE __MIDL_itf_propsys_0000_0000_v0_0_c_ifspec;
+ extern RPC_IF_HANDLE __MIDL_itf_propsys_0000_0000_v0_0_s_ifspec;
+@@ -3600,6 +3608,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif
+
+
+--- include/propvarutil.h.orig 2008-01-18 22:17:34.000000000 +0900
++++ include/propvarutil.h 2010-02-26 19:34:40.863625000 +0900
+@@ -14,6 +14,14 @@
+ #include <shtypes.h>
+ #include <shlwapi.h>
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifndef PSSTDAPI
+ #if defined(_PROPSYS_)
+ #define PSSTDAPI STDAPI
+--- include/shlobj.h.orig 2008-01-18 22:17:36.000000000 +0900
++++ include/shlobj.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /*===========================================================================
+
+ Copyright (c) Microsoft Corporation. All rights reserved.
+@@ -103,6 +106,14 @@
+ #include <shtypes.h>
+ #include <shobjidl.h>
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #if defined(_MSC_VER) && (_MSC_VER >= 1200)
+ #pragma once
+ #endif
+@@ -3117,7 +3128,7 @@
+ SHSTDAPI_(BOOL) ILIsEqual(__in PCIDLIST_ABSOLUTE pidl1, __in PCIDLIST_ABSOLUTE pidl2);
+ SHSTDAPI_(BOOL) ILIsParent(__in PCIDLIST_ABSOLUTE pidl1, __in PCIDLIST_ABSOLUTE pidl2, BOOL fImmediate);
+ SHSTDAPI ILSaveToStream(__in IStream *pstm, __in PCUIDLIST_RELATIVE pidl);
+-DECLSPEC_DEPRECATED SHSTDAPI ILLoadFromStream(__in IStream *pstm, __inout PIDLIST_RELATIVE *pidl);
++SHSTDAPI ILLoadFromStream(__in IStream *pstm, __inout PIDLIST_RELATIVE *pidl);
+ SHSTDAPI ILLoadFromStreamEx(__in IStream *pstm, __deref_out PIDLIST_RELATIVE *pidl);
+
+ #if (_WIN32_IE >= 0x0400)
+@@ -4578,5 +4589,9 @@
+ #endif
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif /* _SHLOBJ_H_ */
+
+--- include/shobjidl.h.orig 2008-01-18 22:17:36.000000000 +0900
++++ include/shobjidl.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -1667,6 +1670,14 @@
+ #include "prsht.h"
+ #include "propsys.h"
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+@@ -6384,7 +6395,6 @@
+
+ typedef ICommDlgBrowser2 *LPCOMMDLGBROWSER2;
+
+-#endif // NTDDI_WIN2K
+ #if (_WIN32_IE >= _WIN32_IE_IE70)
+
+
+@@ -6727,6 +6737,7 @@
+ /* [local] */
+
+ #endif // (_WIN32_IE >= _WIN32_IE_IE70)
++#endif // NTDDI_WIN2K
+
+
+ extern RPC_IF_HANDLE __MIDL_itf_shobjidl_0000_0026_v0_0_c_ifspec;
+@@ -7331,6 +7342,13 @@
+ typedef LPTBBUTTON LPTBBUTTONSB;
+ #endif //_NEVER_
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
+
+ extern RPC_IF_HANDLE __MIDL_itf_shobjidl_0000_0032_v0_0_c_ifspec;
+ extern RPC_IF_HANDLE __MIDL_itf_shobjidl_0000_0032_v0_0_s_ifspec;
+@@ -29000,6 +29018,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif
+
+
+--- include/shtypes.h.orig 2008-01-18 22:17:36.000000000 +0900
++++ include/shtypes.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -137,7 +140,7 @@
+
+ #endif // defined(STRICT_TYPED_ITEMIDS) && defined(__cplusplus)
+ #include <poppack.h>
+-typedef /* [unique] */ __RPC_unique_pointer BYTE_BLOB *wirePIDL;
++//typedef /* [unique] */ __RPC_unique_pointer BYTE_BLOB *wirePIDL;
+
+ typedef /* [wire_marshal] */ ITEMIDLIST __unaligned *LPITEMIDLIST;
+
+--- include/sspi.h.orig 2008-01-18 22:17:38.000000000 +0900
++++ include/sspi.h 2009-08-21 09:21:56.000000000 +0900
+@@ -20,6 +20,14 @@
+ #define __SSPI_H__
+ // end_ntifs
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #if _MSC_VER > 1000
+ #pragma once
+ #endif
+@@ -2154,8 +2162,7 @@
+
+ // begin_ntifs
+
+-#ifndef _AUTH_IDENTITY_DEFINED
+-#define _AUTH_IDENTITY_DEFINED
++#ifndef SEC_WINNT_AUTH_IDENTITY_ANSI
+
+ //
+ // This was not defined in NTIFS.h for windows 2000 however
+@@ -2326,6 +2333,10 @@
+ } // extern "C"
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ // begin_ntifs
+ #endif // __SSPI_H__
+ // end_ntifs
+--- include/strmif.h.orig 2008-01-18 22:17:38.000000000 +0900
++++ include/strmif.h 2009-02-16 21:34:39.065125000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -888,6 +891,14 @@
+ #include "oaidl.h"
+ #include "ocidl.h"
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+@@ -16250,7 +16261,7 @@
+ #define _IAMFilterGraphCallback_
+ // Note: Because this interface was not defined as a proper interface it is
+ // supported under C++ only. Methods aren't stdcall.
+-EXTERN_GUID(IID_IAMFilterGraphCallback,0x56a868fd,0x0ad4,0x11ce,0xb0,0xa3,0x0,0x20,0xaf,0x0b,0xa7,0x70);
++DEFINE_GUID(IID_IAMFilterGraphCallback,0x56a868fd,0x0ad4,0x11ce,0xb0,0xa3,0x0,0x20,0xaf,0x0b,0xa7,0x70);
+ interface IAMFilterGraphCallback : public IUnknown
+ {
+ // S_OK means rendering complete, S_FALSE means retry now.
+@@ -21934,7 +21945,7 @@
+ typedef struct tagVMRGUID
+ {
+ GUID *pGUID;
+- GUID GUID;
++ GUID aGUID;
+ } VMRGUID;
+
+ typedef struct tagVMRMONITORINFO
+@@ -23341,6 +23352,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif
+
+
+--- include/strsafe.h.orig 2008-01-18 22:17:38.000000000 +0900
++++ include/strsafe.h 2009-02-16 21:34:39.065125000 +0900
+@@ -13,12 +13,23 @@
+ #if (_MSC_VER > 1000)
+ #pragma once
+ #endif
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #include <stdio.h> // for _vsnprintf, _vsnwprintf, getc, getwc
+ #include <string.h> // for memset
+ #include <stdarg.h> // for va_start, etc.
+ #include <specstrings.h> // for __in, etc.
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #if !defined(_W64)
+ #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && (_MSC_VER >= 1300)
+ #define _W64 __w64
+@@ -9254,7 +9265,7 @@
+ wchar_t ch = getwc(stdin);
+ // ASSERT(sizeof(wchar_t) == sizeof(wint_t));
+
+- if (ch == WEOF)
++ if (ch == 0xffff)
+ {
+ if (cchNewDestLength == 0)
+ {
+@@ -9763,5 +9774,9 @@
+
+ #pragma warning(pop)
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // _STRSAFE_H_INCLUDED_
+
+--- include/structuredquery.h.orig 2008-01-18 22:17:38.000000000 +0900
++++ include/structuredquery.h 2009-08-21 09:21:56.000000000 +0900
+@@ -233,6 +233,14 @@
+ #include "ocidl.h"
+ #include "propidl.h"
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+@@ -2472,6 +2480,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif
+
+
+--- include/urlmon.h.orig 2008-01-18 22:17:40.000000000 +0900
++++ include/urlmon.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+
+ /* this ALWAYS GENERATED file contains the definitions for the interfaces */
+@@ -330,6 +333,14 @@
+ #include "servprov.h"
+ #include "msxml.h"
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+@@ -8880,6 +8891,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif
+
+
+--- include/wincrypt.h.orig 2008-01-18 22:17:42.000000000 +0900
++++ include/wincrypt.h 2009-02-16 21:34:39.065125000 +0900
+@@ -14,6 +14,14 @@
+
+ #include <specstrings.h> /* for SAL annotations */
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ #if defined (_MSC_VER)
+
+ #if ( _MSC_VER >= 800 )
+@@ -1927,6 +1935,14 @@
+ #include <bcrypt.h>
+ #include <ncrypt.h>
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++
+ // This type is used when the API can take either the CAPI1 HCRYPTPROV or
+ // the CNG NCRYPT_KEY_HANDLE. Where appropriate, the HCRYPTPROV will be
+ // converted to a NCRYPT_KEY_HANDLE via the CNG NCryptTranslateHandle().
+@@ -17113,8 +17129,8 @@
+ __in DWORD dwFlags,
+ __in_opt PCRYPT_KEY_PROV_INFO pKeyProvInfo,
+ __in_opt PCRYPT_ALGORITHM_IDENTIFIER pSignatureAlgorithm,
+- __in_opt PSYSTEMTIME pStartTime,
+- __in_opt PSYSTEMTIME pEndTime,
++ __in_opt LPSYSTEMTIME pStartTime,
++ __in_opt LPSYSTEMTIME pEndTime,
+ __in_opt PCERT_EXTENSIONS pExtensions
+ );
+
+@@ -19174,6 +19190,10 @@
+ #endif
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif // __WINCRYPT_H__
+
+
+--- include/winerror.h.orig 2008-01-18 22:17:42.000000000 +0900
++++ include/winerror.h 2009-08-21 09:21:56.000000000 +0900
+@@ -23,6 +23,11 @@
+
+ #include <specstrings.h>
+
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
+ //
+ // Values are 32 bit values laid out as follows:
+ //
+--- include/wingdi.h.orig 2008-01-18 22:17:42.000000000 +0900
++++ include/wingdi.h 2009-08-21 09:21:56.000000000 +0900
+@@ -9,6 +9,13 @@
+ #ifndef _WINGDI_
+ #define _WINGDI_
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
+
+ #pragma once
+
+@@ -1901,7 +1908,7 @@
+ /* size of a form name string */
+ #define CCHFORMNAME 32
+
+-#if (_WIN32_WINNT >= ((OSVER(NTDDI_WINXPSP2)) >> 16))
++#if (_WIN32_WINNT >= ((NTDDI_WINXPSP2 & 0xFFFF0000) >> 16))
+ typedef struct _devicemodeA {
+ BYTE dmDeviceName[CCHDEVICENAME];
+ WORD dmSpecVersion;
+@@ -5424,6 +5431,10 @@
+ }
+ #endif
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif /* _WINGDI_ */
+
+
+--- include/wintrust.h.orig 2008-01-18 22:17:42.000000000 +0900
++++ include/wintrust.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1252,6 +1252,7 @@
+ //
+ #ifdef WT_DEFINE_ALL_APIS
+
++#if 0
+ typedef struct _WIN_CERTIFICATE
+ {
+ DWORD dwLength;
+@@ -1260,6 +1261,7 @@
+ BYTE bCertificate[ANYSIZE_ARRAY];
+
+ } WIN_CERTIFICATE, *LPWIN_CERTIFICATE;
++#endif
+
+ #define WIN_CERT_REVISION_1_0 (0x0100)
+ #define WIN_CERT_REVISION_2_0 (0x0200)
+--- include/winuser.h.orig 2008-01-18 22:17:44.000000000 +0900
++++ include/winuser.h 2009-08-21 09:21:56.000000000 +0900
+@@ -11,6 +11,15 @@
+ #ifndef _WINUSER_
+ #define _WINUSER_
+
++#define __in
++#define __out
++#ifdef __cplusplus
++#define __inline inline
++#else
++#define __inline static __inline__
++#endif
++DECLARE_HANDLE(HHOOK);
++typedef CONST GUID *LPCGUID;
+
+
+ #pragma once
+@@ -39,7 +48,7 @@
+ #define WINVER 0x0500 /* version 5.0 */
+ #endif /* !WINVER */
+
+-#include <stdarg.h>
++#include <../include/stdarg.h>
+
+ #ifndef NOUSER
+
+@@ -10717,7 +10726,7 @@
+ #define CDS_RESET 0x40000000
+ #define CDS_NORESET 0x10000000
+
+-#include <tvout.h>
++//#include <tvout.h>
+
+ /* Return values for ChangeDisplaySettings */
+ #define DISP_CHANGE_SUCCESSFUL 0
+@@ -12571,16 +12580,20 @@
+
+
+
+-#if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
+-#if defined(ISOLATION_AWARE_ENABLED) && (ISOLATION_AWARE_ENABLED != 0)
+-#include "winuser.inl"
+-#endif /* ISOLATION_AWARE_ENABLED */
+-#endif /* RC */
++//#if !defined(RC_INVOKED) /* RC complains about long symbols in #ifs */
++//#if defined(ISOLATION_AWARE_ENABLED) && (ISOLATION_AWARE_ENABLED != 0)
++//#include "winuser.inl"
++//#endif /* ISOLATION_AWARE_ENABLED */
++//#endif /* RC */
+
+ #ifdef __cplusplus
+ }
+ #endif /* __cplusplus */
+
++#undef __in
++#undef __out
++#undef __inline
++
+ #endif /* !_WINUSER_ */
+
+
+--- include/wspiapi.h.orig 2008-01-18 22:17:44.000000000 +0900
++++ include/wspiapi.h 2009-08-21 09:21:56.000000000 +0900
+@@ -15,6 +15,9 @@
+
+ #ifndef _WSPIAPI_H_
+ #define _WSPIAPI_H_
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #pragma once
+
+@@ -85,6 +88,11 @@
+
+ #ifdef __cplusplus
+ extern "C" {
++#define _inline inline
++#define __inline inline
++#else
++#define _inline static __inline__
++#define __inline static __inline__
+ #endif
+
+ ////////////////////////////////////////////////////////////
+@@ -1052,6 +1060,8 @@
+ (*pfFreeAddrInfo)(ai);
+ }
+
++#undef _inline
++#undef __inline
+ #ifdef __cplusplus
+ }
+ #endif
+--- include/d3dtypes.h.orig 2004-09-27 12:34:16.000000000 +0900
++++ include/d3dtypes.h 2007-11-30 21:42:09.558750000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ /*==========================================================================;
+ *
+ * Copyright (C) Microsoft Corporation. All Rights Reserved.
+--- include/d3dx9core.h.orig 2006-03-31 12:16:02.000000000 +0900
++++ include/d3dx9core.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ // Copyright (C) Microsoft Corporation. All Rights Reserved.
+--- include/d3dx9math.h.orig 2005-07-22 17:00:18.000000000 +0900
++++ include/d3dx9math.h 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ //////////////////////////////////////////////////////////////////////////////
+ //
+ // Copyright (C) Microsoft Corporation. All Rights Reserved.
+--- include/d3dx9math.inl.orig 2005-03-18 17:26:56.000000000 +0900
++++ include/d3dx9math.inl 2009-08-21 09:21:56.000000000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+ //////////////////////////////////////////////////////////////////////////////
+ //
+ // Copyright (C) Microsoft Corporation. All Rights Reserved.
+--- include/dxtrans.h.orig 2004-09-28 00:18:32.000000000 +0900
++++ include/dxtrans.h 2007-01-02 22:08:41.640625000 +0900
+@@ -1,3 +1,6 @@
++#if __GNUC__ >=3
++#pragma GCC system_header
++#endif
+
+ #pragma warning( disable: 4049 ) /* more than 64k source lines */
+
diff --git a/external/prj/build.lst b/external/prj/build.lst
new file mode 100644
index 000000000000..8bcc6c10c07e
--- /dev/null
+++ b/external/prj/build.lst
@@ -0,0 +1,5 @@
+el external : soltools NULL
+el external usr1 - all el_mkout NULL
+el external\glibc nmake - all el_glibc NULL
+el external\gcc3_specific nmake - all el_gcc3 NULL
+el external\mingwheaders nmake - w el_mingwheaders NULL
diff --git a/external/prj/d.lst b/external/prj/d.lst
new file mode 100644
index 000000000000..e4d61b6a1c3c
--- /dev/null
+++ b/external/prj/d.lst
@@ -0,0 +1,67 @@
+mkdir: %_DEST%\inc%_EXT%\external
+mkdir: %_DEST%\inc%_EXT%\external\glibc
+mkdir: %_DEST%\inc%_EXT%\external\mingw
+mkdir: %_DEST%\inc%_EXT%\external\mingw\include
+mkdir: %_DEST%\inc%_EXT%\external\mingw\include\atl
+mkdir: %_DEST%\inc%_EXT%\external\mingw\include\sys
+
+..\glibc\rtufiles\config.h %_DEST%\inc%_EXT%\external\glibc\config.h
+..\glibc\rtufiles\getopt.h %_DEST%\inc%_EXT%\external\glibc\getopt.h
+
+..\%__SRC%\slb\gnu_getopt.lib %_DEST%\lib%_EXT%\gnu_getopt.lib
+..\%__SRC%\lib\libgnu_getopt.a %_DEST%\lib%_EXT%\libgnu_getopt.a
+..\%__SRC%\lib\libgnu_getopt_static.a %_DEST%\lib%_EXT%\libgnu_getopt_static.a
+
+..\%__SRC%\inc\*.h %_DEST%\inc%_EXT%\external\glibc\*.h
+
+..\%__SRC%\misc\mingw\include\*.h %_DEST%\inc%_EXT%\external\mingw\include\*
+..\%__SRC%\misc\mingw\include\atl\*.h %_DEST%\inc%_EXT%\external\mingw\include\atl\*
+..\%__SRC%\misc\mingw\include\sys\*.h %_DEST%\inc%_EXT%\external\mingw\include\sys\*
+
+..\%__SRC%\lib\libautorec*.* %_DEST%\lib%_EXT%\lib*.*
+
+..\%__SRC%\lib\libgcc_s.so.* %_DEST%\lib%_EXT%\libgcc_s.so.*
+..\%__SRC%\lib\libstdc++.so.* %_DEST%\lib%_EXT%\libstdc++.so.*
+
+..\dbghelp\dbghelp.dll %_DEST%\bin%_EXT%\dbghelp.dll
+
+..\gdiplus\gdiplus.dll %_DEST%\bin%_EXT%\gdiplus.dll
+
+..\msvcp70\msvcp70.dll %_DEST%\bin%_EXT%\msvcp70.dll
+..\msvcp70\msvcr70.dll %_DEST%\bin%_EXT%\msvcr70.dll
+
+..\msvcp71\msvcp71*.dll %_DEST%\bin%_EXT%
+..\msvcp71\msvcr71*.dll %_DEST%\bin%_EXT%
+
+..\msvcp80\msvcm80*.dll %_DEST%\bin%_EXT%
+..\msvcp80\msvcp80*.dll %_DEST%\bin%_EXT%
+..\msvcp80\msvcr80*.dll %_DEST%\bin%_EXT%
+..\msvcp80\Microsoft.VC80.CRT.manifest %_DEST%\bin%_EXT%\Microsoft.VC80.CRT.manifest
+..\msvcp80\Microsoft.VC80.DebugCRT.manifest %_DEST%\bin%_EXT%\Microsoft.VC80.DebugCRT.manifest
+
+..\msvcp90\msvcm90*.dll %_DEST%\bin%_EXT%
+..\msvcp90\msvcp90*.dll %_DEST%\bin%_EXT%
+..\msvcp90\msvcr90*.dll %_DEST%\bin%_EXT%
+..\msvcp90\Microsoft.VC90.CRT.manifest %_DEST%\bin%_EXT%\Microsoft.VC90.CRT.manifest
+..\msvcp90\Microsoft.VC90.DebugCRT.manifest %_DEST%\bin%_EXT%\Microsoft.VC90.DebugCRT.manifest
+..\msm90\*.msm %_DEST%\bin%_EXT%
+
+..\unicows\unicows.dll %_DEST%\bin%_EXT%\unicows.dll
+
+..\unowinreg\unowinreg.dll %_DEST%\bin%_EXT%\unowinreg.dll
+
+..\msi\instmsiw.exe %_DEST%\bin%_EXT%\instmsiw.exe
+
+..\vcredist\vcredist_x86.exe %_DEST%\bin%_EXT%\vcredist_x86.exe
+..\vcredist\vcredist_x64.exe %_DEST%\bin%_EXT%\vcredist_x64.exe
+
+..\%__SRC%\bin\mingwm10.dll %_DEST%\bin%_EXT%\mingwm10.dll
+..\%__SRC%\bin\libgcc*.dll %_DEST%\bin%_EXT%\libgcc*.dll
+..\%__SRC%\bin\libstdc++*.dll %_DEST%\bin%_EXT%\libstdc++*.dll
+
+..\%__SRC%\lib\libmsvcrt*.* %_DEST%\lib%_EXT%\lib*.*
+
+..\%__SRC%\lib\lib*static*.dylib %_DEST%\lib%_EXT%\lib*static*.dylib
+
+linklib: libgcc_s.*.*
+
diff --git a/external/unowinreg/README b/external/unowinreg/README
new file mode 100644
index 000000000000..464f64be8fb9
--- /dev/null
+++ b/external/unowinreg/README
@@ -0,0 +1,2 @@
+Copy unowinreg.dll from http://tools.openoffice.org/unowinreg_prebuild/680/
+here... [ or rebuild it using --with-mingwin= ]