Bug 969918 - Use decltype to declare pointers for dynamic-loaded functions. r=jimm sr=roc
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Tue, 18 Feb 2014 07:32:52 +0900
changeset 186374 9945bc3b7d36c659395bf69f2306f7ba74427ddb
parent 186373 047ac8e24409b423ee3042000e62451f52fb5928
child 186375 b732738b75f89122d9ad0cab4396194d7ca27de0
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, roc
bugs969918
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 969918 - Use decltype to declare pointers for dynamic-loaded functions. r=jimm sr=roc
browser/app/nsBrowserApp.cpp
browser/components/shell/src/nsWindowsShellService.cpp
browser/metro/shell/commandexecutehandler/CEHHelper.cpp
content/media/wmf/DXVA2Manager.cpp
content/media/wmf/WMFUtils.cpp
dom/plugins/test/testplugin/nptest_windows.cpp
gfx/2d/DrawTargetD2D.cpp
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/d3d9/DeviceManagerD3D9.cpp
gfx/thebes/gfxWindowsPlatform.cpp
hal/windows/WindowsBattery.cpp
image/decoders/icon/win/nsIconChannel.cpp
netwerk/system/win32/nsNotifyAddrListener.cpp
netwerk/wifi/nsWifiScannerWin.cpp
netwerk/wifi/wlanapi.h
toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
toolkit/content/license.html
toolkit/mozapps/update/common/uachelper.cpp
toolkit/xre/nsAppRunner.cpp
tools/trace-malloc/lib/nsDebugHelpWin32.cpp
tools/trace-malloc/lib/nsDebugHelpWin32.h
tools/trace-malloc/lib/nsWinTraceMalloc.cpp
widget/windows/WinIMEHandler.cpp
widget/windows/WinIMEHandler.h
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -78,18 +78,18 @@ static void Output(const char *fmt, ... 
                       _countof(wide_msg));
 #if MOZ_WINCONSOLE
   fwprintf_s(stderr, wide_msg);
 #else
   // Linking user32 at load-time interferes with the DLL blocklist (bug 932100).
   // This is a rare codepath, so we can load user32 at run-time instead.
   HMODULE user32 = LoadLibraryW(L"user32.dll");
   if (user32) {
-    typedef int (WINAPI * MessageBoxWFn)(HWND, LPCWSTR, LPCWSTR, UINT);
-    MessageBoxWFn messageBoxW = (MessageBoxWFn)GetProcAddress(user32, "MessageBoxW");
+    decltype(MessageBoxW)* messageBoxW =
+      (decltype(MessageBoxW)*) GetProcAddress(user32, "MessageBoxW");
     if (messageBoxW) {
       messageBoxW(nullptr, wide_msg, L"Firefox", MB_OK
                                                | MB_ICONERROR
                                                | MB_SETFOREGROUND);
     }
     FreeLibrary(user32);
   }
 #endif
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -601,29 +601,26 @@ nsWindowsShellService::GetCanSetDesktopB
 {
   *aResult = true;
   return NS_OK;
 }
 
 static nsresult
 DynSHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
 {
-  typedef HRESULT (WINAPI * SHOpenWithDialogPtr)(HWND hwndParent,
-                                                 const OPENASINFO *poainfo);
-  
   // shell32.dll is in the knownDLLs list so will always be loaded from the
   // system32 directory.
   static const wchar_t kSehllLibraryName[] =  L"shell32.dll";
   HMODULE shellDLL = ::LoadLibraryW(kSehllLibraryName);
   if (!shellDLL) {
     return NS_ERROR_FAILURE;
   }
 
-  SHOpenWithDialogPtr SHOpenWithDialogFn =
-    (SHOpenWithDialogPtr)GetProcAddress(shellDLL, "SHOpenWithDialog");
+  decltype(SHOpenWithDialog)* SHOpenWithDialogFn =
+    (decltype(SHOpenWithDialog)*) GetProcAddress(shellDLL, "SHOpenWithDialog");
 
   if (!SHOpenWithDialogFn) {
     return NS_ERROR_FAILURE;
   }
 
   nsresult rv = 
     SUCCEEDED(SHOpenWithDialogFn(hwndParent, poainfo)) ? NS_OK :
                                                          NS_ERROR_FAILURE;
--- a/browser/metro/shell/commandexecutehandler/CEHHelper.cpp
+++ b/browser/metro/shell/commandexecutehandler/CEHHelper.cpp
@@ -11,21 +11,16 @@
 #endif
 
 HANDLE sCon;
 LPCWSTR metroDX10Available = L"MetroD3DAvailable";
 LPCWSTR metroLastAHE = L"MetroLastAHE";
 LPCWSTR cehDumpDebugStrings = L"CEHDump";
 extern const WCHAR* kFirefoxExe;
 
-typedef HRESULT (WINAPI*D3D10CreateDevice1Func)
-  (IDXGIAdapter *, D3D10_DRIVER_TYPE, HMODULE, UINT,
-   D3D10_FEATURE_LEVEL1, UINT, ID3D10Device1 **);
-typedef HRESULT(WINAPI*CreateDXGIFactory1Func)(REFIID , void **);
-
 void
 Log(const wchar_t *fmt, ...)
 {
 #if !defined(SHOW_CONSOLE)
   DWORD dwRes = 0;
   if (!GetDWORDRegKey(cehDumpDebugStrings, dwRes) || !dwRes) {
     return;
   }
@@ -65,20 +60,19 @@ SetupConsole()
 bool
 IsImmersiveProcessDynamic(HANDLE process)
 {
   HMODULE user32DLL = LoadLibraryW(L"user32.dll");
   if (!user32DLL) {
     return false;
   }
 
-  typedef BOOL (WINAPI* IsImmersiveProcessFunc)(HANDLE process);
-  IsImmersiveProcessFunc IsImmersiveProcessPtr =
-    (IsImmersiveProcessFunc)GetProcAddress(user32DLL,
-                                           "IsImmersiveProcess");
+  decltype(IsImmersiveProcess)* IsImmersiveProcessPtr =
+    (decltype(IsImmersiveProcess)*) GetProcAddress(user32DLL,
+                                                   "IsImmersiveProcess");
   if (!IsImmersiveProcessPtr) {
     FreeLibrary(user32DLL);
     return false;
   }
 
   BOOL bImmersiveProcess = IsImmersiveProcessPtr(process);
   FreeLibrary(user32DLL);
   return bImmersiveProcess;
@@ -146,31 +140,31 @@ IsDX10Available()
     return isDX10Available;
   }
 
   HMODULE dxgiModule = LoadLibraryA("dxgi.dll");
   if (!dxgiModule) {
     SetDWORDRegKey(metroDX10Available, 0);
     return false;
   }
-  CreateDXGIFactory1Func createDXGIFactory1 =
-    (CreateDXGIFactory1Func) GetProcAddress(dxgiModule, "CreateDXGIFactory1");
+  decltype(CreateDXGIFactory1)* createDXGIFactory1 =
+    (decltype(CreateDXGIFactory1)*) GetProcAddress(dxgiModule, "CreateDXGIFactory1");
   if (!createDXGIFactory1) {
     SetDWORDRegKey(metroDX10Available, 0);
     return false;
   }
 
   HMODULE d3d10module = LoadLibraryA("d3d10_1.dll");
   if (!d3d10module) {
     SetDWORDRegKey(metroDX10Available, 0);
     return false;
   }
-  D3D10CreateDevice1Func createD3DDevice =
-    (D3D10CreateDevice1Func) GetProcAddress(d3d10module,
-                                            "D3D10CreateDevice1");
+  decltype(D3D10CreateDevice1)* createD3DDevice =
+    (decltype(D3D10CreateDevice1)*) GetProcAddress(d3d10module,
+                                                   "D3D10CreateDevice1");
   if (!createD3DDevice) {
     SetDWORDRegKey(metroDX10Available, 0);
     return false;
   }
 
   CComPtr<IDXGIFactory1> factory1;
   if (FAILED(createDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&factory1))) {
     SetDWORDRegKey(metroDX10Available, 0);
--- a/content/media/wmf/DXVA2Manager.cpp
+++ b/content/media/wmf/DXVA2Manager.cpp
@@ -55,28 +55,26 @@ D3D9DXVA2Manager::~D3D9DXVA2Manager()
 
 IUnknown*
 D3D9DXVA2Manager::GetDXVADeviceManager()
 {
   MutexAutoLock lock(mLock);
   return mDeviceManager;
 }
 
-typedef HRESULT (WINAPI*Direct3DCreate9Func)(UINT SDKVersion, IDirect3D9Ex**);
-
 HRESULT
 D3D9DXVA2Manager::Init()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   // Create D3D9Ex.
   HMODULE d3d9lib = LoadLibraryW(L"d3d9.dll");
   NS_ENSURE_TRUE(d3d9lib, E_FAIL);
-  Direct3DCreate9Func d3d9Create =
-    (Direct3DCreate9Func)GetProcAddress(d3d9lib, "Direct3DCreate9Ex");
+  decltype(Direct3DCreate9Ex)* d3d9Create =
+    (decltype(Direct3DCreate9Ex)*) GetProcAddress(d3d9lib, "Direct3DCreate9Ex");
   nsRefPtr<IDirect3D9Ex> d3d9Ex;
   HRESULT hr = d3d9Create(D3D_SDK_VERSION, getter_AddRefs(d3d9Ex));
   if (!d3d9Ex) {
     NS_WARNING("Direct3DCreate9 failed");
     return E_FAIL;
   }
 
   // Ensure we can do the YCbCr->RGB conversion in StretchRect.
--- a/content/media/wmf/WMFUtils.cpp
+++ b/content/media/wmf/WMFUtils.cpp
@@ -484,205 +484,197 @@ UnloadDLLs()
       FreeLibrary(sDLLs[i].handle);
       sDLLs[i].handle = nullptr;
     }
     sDLLsLoaded = false;
   }
   return S_OK;
 }
 
-#define ENSURE_FUNCTION_PTR(FunctionName, DLL) \
-  static FunctionName##Ptr_t FunctionName##Ptr = nullptr; \
+#define ENSURE_FUNCTION_PTR_HELPER(FunctionType, FunctionName, DLL) \
+  static FunctionType FunctionName##Ptr = nullptr; \
   if (!FunctionName##Ptr) { \
-    FunctionName##Ptr = (FunctionName##Ptr_t)GetProcAddress(GetModuleHandle( #DLL ), #FunctionName ); \
+    FunctionName##Ptr = (FunctionType) GetProcAddress(GetModuleHandle(#DLL), #FunctionName); \
     if (!FunctionName##Ptr) { \
-      NS_WARNING("Failed to get GetProcAddress of " #FunctionName " from " #DLL ); \
+      NS_WARNING("Failed to get GetProcAddress of " #FunctionName " from " #DLL); \
       return E_FAIL; \
     } \
   }
 
+#define ENSURE_FUNCTION_PTR(FunctionName, DLL) \
+  ENSURE_FUNCTION_PTR_HELPER(decltype(::FunctionName)*, FunctionName, DLL) \
+
+#define ENSURE_FUNCTION_PTR_(FunctionName, DLL) \
+  ENSURE_FUNCTION_PTR_HELPER(FunctionName##Ptr_t, FunctionName, DLL) \
+
 #define DECL_FUNCTION_PTR(FunctionName, ...) \
   typedef HRESULT (STDMETHODCALLTYPE * FunctionName##Ptr_t)(__VA_ARGS__)
 
 HRESULT
 MFStartup()
 {
   const int MF_VISTA_VERSION = (0x0001 << 16 | MF_API_VERSION);
   const int MF_WIN7_VERSION = (0x0002 << 16 | MF_API_VERSION);
 
+  // decltype is unusable for functions having default parameters
   DECL_FUNCTION_PTR(MFStartup, ULONG, DWORD);
-  ENSURE_FUNCTION_PTR(MFStartup, Mfplat.dll)
+  ENSURE_FUNCTION_PTR_(MFStartup, Mfplat.dll)
   if (!IsWin7OrLater())
     return MFStartupPtr(MF_VISTA_VERSION, MFSTARTUP_FULL);
   else
     return MFStartupPtr(MF_WIN7_VERSION, MFSTARTUP_FULL);
 }
 
 HRESULT
 MFShutdown()
 {
-  DECL_FUNCTION_PTR(MFShutdown);
   ENSURE_FUNCTION_PTR(MFShutdown, Mfplat.dll)
   return (MFShutdownPtr)();
 }
 
 HRESULT
 MFCreateAsyncResult(IUnknown *aUnkObject,
                     IMFAsyncCallback *aCallback,
                     IUnknown *aUnkState,
                     IMFAsyncResult **aOutAsyncResult)
 {
-  DECL_FUNCTION_PTR(MFCreateAsyncResult, IUnknown*, IMFAsyncCallback*, IUnknown*, IMFAsyncResult**);
   ENSURE_FUNCTION_PTR(MFCreateAsyncResult, Mfplat.dll)
   return (MFCreateAsyncResultPtr)(aUnkObject, aCallback, aUnkState, aOutAsyncResult);
 }
 
 HRESULT
 MFInvokeCallback(IMFAsyncResult *aAsyncResult)
 {
-  DECL_FUNCTION_PTR(MFInvokeCallback, IMFAsyncResult*);
   ENSURE_FUNCTION_PTR(MFInvokeCallback, Mfplat.dll);
   return (MFInvokeCallbackPtr)(aAsyncResult);
 }
 
 HRESULT
 MFCreateMediaType(IMFMediaType **aOutMFType)
 {
-  DECL_FUNCTION_PTR(MFCreateMediaType, IMFMediaType**);
   ENSURE_FUNCTION_PTR(MFCreateMediaType, Mfplat.dll)
   return (MFCreateMediaTypePtr)(aOutMFType);
 }
 
 HRESULT
 MFCreateSourceReaderFromByteStream(IMFByteStream *aByteStream,
                                    IMFAttributes *aAttributes,
                                    IMFSourceReader **aOutSourceReader)
 {
-  DECL_FUNCTION_PTR(MFCreateSourceReaderFromByteStream, IMFByteStream*, IMFAttributes*, IMFSourceReader**);
   ENSURE_FUNCTION_PTR(MFCreateSourceReaderFromByteStream, Mfreadwrite.dll)
   return (MFCreateSourceReaderFromByteStreamPtr)(aByteStream,
                                                  aAttributes,
                                                  aOutSourceReader);
 }
 
 HRESULT
 PropVariantToUInt32(REFPROPVARIANT aPropvar, ULONG *aOutUL)
 {
+  // decltype is unusable for overloaded functions
   DECL_FUNCTION_PTR(PropVariantToUInt32, REFPROPVARIANT, ULONG *);
-  ENSURE_FUNCTION_PTR(PropVariantToUInt32, Propsys.dll)
+  ENSURE_FUNCTION_PTR_(PropVariantToUInt32, Propsys.dll)
   return (PropVariantToUInt32Ptr)(aPropvar, aOutUL);
 }
 
 HRESULT PropVariantToInt64(REFPROPVARIANT aPropVar, LONGLONG *aOutLL)
 {
-  DECL_FUNCTION_PTR(PropVariantToInt64, REFPROPVARIANT, LONGLONG *);
   ENSURE_FUNCTION_PTR(PropVariantToInt64, Propsys.dll)
   return (PropVariantToInt64Ptr)(aPropVar, aOutLL);
 }
 
 HRESULT
 MFTGetInfo(CLSID aClsidMFT,
            LPWSTR *aOutName,
            MFT_REGISTER_TYPE_INFO **aOutInputTypes,
            UINT32 *aOutNumInputTypes,
            MFT_REGISTER_TYPE_INFO **aOutOutputTypes,
            UINT32 *aOutNumOutputTypes,
            IMFAttributes **aOutAttributes)
 {
-  DECL_FUNCTION_PTR(MFTGetInfo, CLSID, LPWSTR*, MFT_REGISTER_TYPE_INFO**, UINT32*, MFT_REGISTER_TYPE_INFO**, UINT32*, IMFAttributes**);
   ENSURE_FUNCTION_PTR(MFTGetInfo, Mfplat.dll)
   return (MFTGetInfoPtr)(aClsidMFT,
                          aOutName,
                          aOutInputTypes,
                          aOutNumInputTypes,
                          aOutOutputTypes,
                          aOutNumOutputTypes,
                          aOutAttributes);
 }
 
 HRESULT
 MFGetStrideForBitmapInfoHeader(DWORD aFormat,
                                DWORD aWidth,
                                LONG *aOutStride)
 {
-  DECL_FUNCTION_PTR(MFGetStrideForBitmapInfoHeader, DWORD, DWORD, LONG*);
   ENSURE_FUNCTION_PTR(MFGetStrideForBitmapInfoHeader, Mfplat.dll)
   return (MFGetStrideForBitmapInfoHeaderPtr)(aFormat, aWidth, aOutStride);
 }
 
 HRESULT
 MFCreateSourceReaderFromURL(LPCWSTR aURL,
                             IMFAttributes *aAttributes,
                             IMFSourceReader **aSourceReader)
 {
-  DECL_FUNCTION_PTR(MFCreateSourceReaderFromURL, LPCWSTR, IMFAttributes*, IMFSourceReader**);
   ENSURE_FUNCTION_PTR(MFCreateSourceReaderFromURL, Mfreadwrite.dll)
   return (MFCreateSourceReaderFromURLPtr)(aURL, aAttributes, aSourceReader);
 }
 
 HRESULT
 MFCreateAttributes(IMFAttributes **ppMFAttributes, UINT32 cInitialSize)
 {
-  DECL_FUNCTION_PTR(MFCreateAttributes, IMFAttributes**, UINT32);
   ENSURE_FUNCTION_PTR(MFCreateAttributes, mfplat.dll)
   return (MFCreateAttributesPtr)(ppMFAttributes, cInitialSize);
 }
 
 HRESULT
 MFGetPluginControl(IMFPluginControl **aOutPluginControl)
 {
-  DECL_FUNCTION_PTR(MFGetPluginControl, IMFPluginControl **);
   ENSURE_FUNCTION_PTR(MFGetPluginControl, mfplat.dll)
   return (MFGetPluginControlPtr)(aOutPluginControl);
 }
 
 HRESULT
 MFTEnumEx(GUID guidCategory,
           UINT32 Flags,
           const MFT_REGISTER_TYPE_INFO *pInputType,
           const MFT_REGISTER_TYPE_INFO *pOutputType,
           IMFActivate ***pppMFTActivate,
           UINT32 *pcMFTActivate)
 {
-  DECL_FUNCTION_PTR(MFTEnumEx, GUID, UINT32, const MFT_REGISTER_TYPE_INFO *, const MFT_REGISTER_TYPE_INFO *, IMFActivate ***, UINT32 *);
   ENSURE_FUNCTION_PTR(MFTEnumEx, mfplat.dll)
   return (MFTEnumExPtr)(guidCategory, Flags, pInputType, pOutputType, pppMFTActivate, pcMFTActivate);
 }
 
 HRESULT MFGetService(IUnknown *punkObject,
                      REFGUID guidService,
                      REFIID riid,
                      LPVOID *ppvObject)
 {
-  DECL_FUNCTION_PTR(MFGetService, IUnknown*, REFGUID, REFIID, LPVOID *);
   ENSURE_FUNCTION_PTR(MFGetService, mf.dll)
   return (MFGetServicePtr)(punkObject, guidService, riid, ppvObject);
 }
 
 HRESULT
 DXVA2CreateDirect3DDeviceManager9(UINT *pResetToken,
                                   IDirect3DDeviceManager9 **ppDXVAManager)
 {
-  DECL_FUNCTION_PTR(DXVA2CreateDirect3DDeviceManager9, UINT*, IDirect3DDeviceManager9 **);
   ENSURE_FUNCTION_PTR(DXVA2CreateDirect3DDeviceManager9, dxva2.dll)
   return (DXVA2CreateDirect3DDeviceManager9Ptr)(pResetToken, ppDXVAManager);
 }
 
 HRESULT
 MFCreateSample(IMFSample **ppIMFSample)
 {
-  DECL_FUNCTION_PTR(MFCreateSample, IMFSample **);
   ENSURE_FUNCTION_PTR(MFCreateSample, mfplat.dll)
   return (MFCreateSamplePtr)(ppIMFSample);
 }
 
 HRESULT
 MFCreateAlignedMemoryBuffer(DWORD cbMaxLength,
                             DWORD fAlignmentFlags,
                             IMFMediaBuffer **ppBuffer)
 {
-  DECL_FUNCTION_PTR(MFCreateAlignedMemoryBuffer, DWORD, DWORD, IMFMediaBuffer**);
   ENSURE_FUNCTION_PTR(MFCreateAlignedMemoryBuffer, mfplat.dll)
   return (MFCreateAlignedMemoryBufferPtr)(cbMaxLength, fAlignmentFlags, ppBuffer);
 }
 
 } // end namespace wmf
 } // end namespace mozilla
--- a/dom/plugins/test/testplugin/nptest_windows.cpp
+++ b/dom/plugins/test/testplugin/nptest_windows.cpp
@@ -35,32 +35,17 @@
 #include "nptest_platform.h"
 
 #include <windows.h>
 #include <windowsx.h>
 #include <stdio.h>
 
 #include <d3d10_1.h>
 
-typedef HRESULT (WINAPI*D3D10CreateDevice1Func)(
-  IDXGIAdapter *pAdapter,
-  D3D10_DRIVER_TYPE DriverType,
-  HMODULE Software,
-  UINT Flags,
-  D3D10_FEATURE_LEVEL1 HardwareLevel,
-  UINT SDKVersion,
-  ID3D10Device1 **ppDevice
-);
-
-typedef HRESULT(WINAPI*CreateDXGIFactory1Func)(
-  REFIID riid,
-  void **ppFactory
-);
-
- using namespace std;
+using namespace std;
 
 void SetSubclass(HWND hWnd, InstanceData* instanceData);
 void ClearSubclass(HWND hWnd);
 LRESULT CALLBACK PluginWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 struct _PlatformData {
   HWND childWindow;
   ID3D10Device1 *device;
@@ -121,23 +106,25 @@ pluginInstanceShutdown(InstanceData* ins
 }
 
 static ID3D10Device1*
 getD3D10Device()
 {
   ID3D10Device1 *device;
     
   HMODULE d3d10module = LoadLibraryA("d3d10_1.dll");
-  D3D10CreateDevice1Func createD3DDevice = (D3D10CreateDevice1Func)
-      GetProcAddress(d3d10module, "D3D10CreateDevice1");
+  decltype(D3D10CreateDevice1)* createD3DDevice =
+      (decltype(D3D10CreateDevice1)*) GetProcAddress(d3d10module,
+                                                     "D3D10CreateDevice1");
 
   if (createD3DDevice) {
     HMODULE dxgiModule = LoadLibraryA("dxgi.dll");
-    CreateDXGIFactory1Func createDXGIFactory1 = (CreateDXGIFactory1Func)
-        GetProcAddress(dxgiModule, "CreateDXGIFactory1");
+    decltype(CreateDXGIFactory1)* createDXGIFactory1 =
+        (decltype(CreateDXGIFactory1)*) GetProcAddress(dxgiModule,
+                                                       "CreateDXGIFactory1");
 
     HRESULT hr;
 
     // Try to use a DXGI 1.1 adapter in order to share resources
     // across processes.
     IDXGIAdapter1 *adapter1;
     if (createDXGIFactory1) {
       IDXGIFactory1 *factory1;
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -18,38 +18,24 @@
 #include "FilterNodeSoftware.h"
 
 #ifdef USE_D2D1_1
 #include "FilterNodeD2D1.h"
 #endif
 
 #include <dwrite.h>
 
+// decltype is not usable for overloaded functions.
 typedef HRESULT (WINAPI*D2D1CreateFactoryFunc)(
     D2D1_FACTORY_TYPE factoryType,
     REFIID iid,
     CONST D2D1_FACTORY_OPTIONS *pFactoryOptions,
     void **factory
 );
 
-typedef HRESULT (WINAPI*D3D10CreateEffectFromMemoryFunc)(
-    void *pData,
-    SIZE_T DataLength,
-    UINT FXFlags,
-    ID3D10Device *pDevice,
-    ID3D10EffectPool *pEffectPool,
-    ID3D10Effect **ppEffect
-);
-
-typedef HRESULT (WINAPI*DWriteCreateFactoryFunc)(
-  DWRITE_FACTORY_TYPE factoryType,
-  REFIID iid,
-  IUnknown **factory
-);
-
 using namespace std;
 
 namespace mozilla {
 namespace gfx {
 
 struct Vertex {
   float x;
   float y;
@@ -1383,19 +1369,19 @@ DrawTargetD2D::InitD3D10Data()
   hr = mDevice->GetPrivateData(sPrivateDataD2D, &privateDataSize, &mPrivateData);
 
   if (SUCCEEDED(hr)) {
       return true;
   }
 
   mPrivateData = new PrivateD3D10DataD2D;
 
-  D3D10CreateEffectFromMemoryFunc createD3DEffect;
+  decltype(D3D10CreateEffectFromMemory)* createD3DEffect;
   HMODULE d3dModule = LoadLibraryW(L"d3d10_1.dll");
-  createD3DEffect = (D3D10CreateEffectFromMemoryFunc)
+  createD3DEffect = (decltype(D3D10CreateEffectFromMemory)*)
       GetProcAddress(d3dModule, "D3D10CreateEffectFromMemory");
 
   hr = createD3DEffect((void*)d2deffect, sizeof(d2deffect), 0, mDevice, nullptr, byRef(mPrivateData->mEffect));
 
   if (FAILED(hr)) {
     gfxWarning() << "Failed to initialize Direct2D required effects. Code: " << hr;
     return false;
   }
@@ -2653,19 +2639,19 @@ DrawTargetD2D::CleanupD2D()
 
 IDWriteFactory*
 DrawTargetD2D::GetDWriteFactory()
 {
   if (mDWriteFactory) {
     return mDWriteFactory;
   }
 
-  DWriteCreateFactoryFunc createDWriteFactory;
+  decltype(DWriteCreateFactory)* createDWriteFactory;
   HMODULE dwriteModule = LoadLibraryW(L"dwrite.dll");
-  createDWriteFactory = (DWriteCreateFactoryFunc)
+  createDWriteFactory = (decltype(DWriteCreateFactory)*)
     GetProcAddress(dwriteModule, "DWriteCreateFactory");
 
   if (!createDWriteFactory) {
     gfxWarning() << "Failed to locate DWriteCreateFactory function.";
     return nullptr;
   }
 
   HRESULT hr = createDWriteFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -33,25 +33,16 @@
 
 using namespace std;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
-typedef HRESULT (WINAPI*D3D10CreateEffectFromMemoryFunc)(
-    void *pData,
-    SIZE_T DataLength,
-    UINT FXFlags,
-    ID3D10Device *pDevice, 
-    ID3D10EffectPool *pEffectPool,
-    ID3D10Effect **ppEffect
-);
-
 struct Vertex
 {
     float position[2];
 };
 
 // {592BF306-0EED-4F76-9D03-A0846450F472}
 static const GUID sDeviceAttachments = 
 { 0x592bf306, 0xeed, 0x4f76, { 0x9d, 0x3, 0xa0, 0x84, 0x64, 0x50, 0xf4, 0x72 } };
@@ -154,18 +145,19 @@ LayerManagerD3D10::Initialize(bool force
 
   DeviceAttachments *attachments;
   size = sizeof(DeviceAttachments*);
   if (FAILED(mDevice->GetPrivateData(sDeviceAttachments, &size, &attachments))) {
     attachments = new DeviceAttachments;
     mDevice->SetPrivateData(sDeviceAttachments, sizeof(attachments), &attachments);
 
     SetLastError(0);
-    D3D10CreateEffectFromMemoryFunc createEffect = (D3D10CreateEffectFromMemoryFunc)
-      GetProcAddress(LoadLibraryA("d3d10_1.dll"), "D3D10CreateEffectFromMemory");
+    decltype(D3D10CreateEffectFromMemory)* createEffect =
+      (decltype(D3D10CreateEffectFromMemory)*)
+        GetProcAddress(LoadLibraryA("d3d10_1.dll"), "D3D10CreateEffectFromMemory");
     if (!createEffect) {
       SetHRESULT(aHresultPtr, HRESULT_FROM_WIN32(GetLastError()));
       return false;
     }
 
     hr = createEffect((void*)g_main,
                       sizeof(g_main),
                       D3D10_EFFECT_SINGLE_THREADED,
--- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp
+++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp
@@ -22,25 +22,16 @@ using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace layers {
 
 const LPCWSTR kClassName       = L"D3D9WindowClass";
 
 #define USE_D3D9EX
 
-typedef IDirect3D9* (WINAPI*Direct3DCreate9Func)(
-  UINT SDKVersion
-);
-
-typedef HRESULT (WINAPI*Direct3DCreate9ExFunc)(
-  UINT SDKVersion,
-  IDirect3D9Ex **ppD3D
-);
-
 struct vertex {
   float x, y;
 };
 
 SwapChainD3D9::SwapChainD3D9(DeviceManagerD3D9 *aDeviceManager)
   : mDeviceManager(aDeviceManager)
   , mWnd(0)
 {
@@ -219,21 +210,21 @@ DeviceManagerD3D9::Init()
   } 
 
   /* Initialize the Nv3DVUtils object */ 
   if (mNv3DVUtils) { 
     mNv3DVUtils->Initialize(); 
   } 
 
   HMODULE d3d9 = LoadLibraryW(L"d3d9.dll");
-  Direct3DCreate9Func d3d9Create = (Direct3DCreate9Func)
+  decltype(Direct3DCreate9)* d3d9Create = (decltype(Direct3DCreate9)*)
     GetProcAddress(d3d9, "Direct3DCreate9");
-  Direct3DCreate9ExFunc d3d9CreateEx = (Direct3DCreate9ExFunc)
+  decltype(Direct3DCreate9Ex)* d3d9CreateEx = (decltype(Direct3DCreate9Ex)*)
     GetProcAddress(d3d9, "Direct3DCreate9Ex");
-  
+
 #ifdef USE_D3D9EX
   if (d3d9CreateEx) {
     hr = d3d9CreateEx(D3D_SDK_VERSION, getter_AddRefs(mD3D9Ex));
     if (SUCCEEDED(hr)) {
       mD3D9 = mD3D9Ex;
     }
   }
 #endif
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -168,56 +168,16 @@ NS_IMPL_ISUPPORTS1(GfxD2DVramReporter, n
 
 #define GFX_CLEARTYPE_PARAMS           "gfx.font_rendering.cleartype_params."
 #define GFX_CLEARTYPE_PARAMS_GAMMA     "gfx.font_rendering.cleartype_params.gamma"
 #define GFX_CLEARTYPE_PARAMS_CONTRAST  "gfx.font_rendering.cleartype_params.enhanced_contrast"
 #define GFX_CLEARTYPE_PARAMS_LEVEL     "gfx.font_rendering.cleartype_params.cleartype_level"
 #define GFX_CLEARTYPE_PARAMS_STRUCTURE "gfx.font_rendering.cleartype_params.pixel_structure"
 #define GFX_CLEARTYPE_PARAMS_MODE      "gfx.font_rendering.cleartype_params.rendering_mode"
 
-#ifdef CAIRO_HAS_DWRITE_FONT
-// DirectWrite is not available on all platforms, we need to use the function
-// pointer.
-typedef HRESULT (WINAPI*DWriteCreateFactoryFunc)(
-  DWRITE_FACTORY_TYPE factoryType,
-  REFIID iid,
-  IUnknown **factory
-);
-#endif
-
-#ifdef CAIRO_HAS_D2D_SURFACE
-typedef HRESULT (WINAPI*D3D10CreateDevice1Func)(
-  IDXGIAdapter *pAdapter,
-  D3D10_DRIVER_TYPE DriverType,
-  HMODULE Software,
-  UINT Flags,
-  D3D10_FEATURE_LEVEL1 HardwareLevel,
-  UINT SDKVersion,
-  ID3D10Device1 **ppDevice
-);
-#endif
-
-typedef HRESULT(WINAPI*CreateDXGIFactory1Func)(
-  REFIID riid,
-  void **ppFactory
-);
-
-typedef HRESULT (WINAPI*D3D11CreateDeviceFunc)(
-  IDXGIAdapter *pAdapter,
-  D3D_DRIVER_TYPE DriverType,
-  HMODULE Software,
-  UINT Flags,
-  D3D_FEATURE_LEVEL *pFeatureLevels,
-  UINT FeatureLevels,
-  UINT SDKVersion,
-  ID3D11Device **ppDevice,
-  D3D_FEATURE_LEVEL *pFeatureLevel,
-  ID3D11DeviceContext *ppImmediateContext
-);
-
 class GPUAdapterReporter : public nsIMemoryReporter
 {
     // Callers must Release the DXGIAdapter after use or risk mem-leak
     static bool GetDXGIAdapter(IDXGIAdapter **DXGIAdapter)
     {
         ID3D10Device1 *D2D10Device;
         IDXGIDevice *DXGIDevice;
         bool result = false;
@@ -461,17 +421,17 @@ gfxWindowsPlatform::UpdateRenderMode()
     }
 #endif
 
 #ifdef CAIRO_HAS_DWRITE_FONT
     // Enable when it's preffed on -and- we're using Vista or higher. Or when
     // we're going to use D2D.
     if (!mDWriteFactory && (mUseDirectWrite && isVistaOrHigher)) {
         mozilla::ScopedGfxFeatureReporter reporter("DWrite");
-        DWriteCreateFactoryFunc createDWriteFactory = (DWriteCreateFactoryFunc)
+        decltype(DWriteCreateFactory)* createDWriteFactory = (decltype(DWriteCreateFactory)*)
             GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory");
 
         if (createDWriteFactory) {
             /**
              * I need a direct pointer to be able to cast to IUnknown**, I also
              * need to remember to release this because the nsRefPtr will
              * AddRef it.
              */
@@ -513,18 +473,18 @@ gfxWindowsPlatform::UpdateRenderMode()
 #ifdef CAIRO_HAS_D2D_SURFACE
 HRESULT
 gfxWindowsPlatform::CreateDevice(nsRefPtr<IDXGIAdapter1> &adapter1,
                                  int featureLevelIndex)
 {
   nsModuleHandle d3d10module(LoadLibrarySystem32(L"d3d10_1.dll"));
   if (!d3d10module)
     return E_FAIL;
-  D3D10CreateDevice1Func createD3DDevice =
-    (D3D10CreateDevice1Func)GetProcAddress(d3d10module, "D3D10CreateDevice1");
+  decltype(D3D10CreateDevice1)* createD3DDevice =
+    (decltype(D3D10CreateDevice1)*) GetProcAddress(d3d10module, "D3D10CreateDevice1");
   if (!createD3DDevice)
     return E_FAIL;
 
   nsRefPtr<ID3D10Device1> device;
   HRESULT hr =
     createD3DDevice(adapter1, D3D10_DRIVER_TYPE_HARDWARE, nullptr,
                     D3D10_CREATE_DEVICE_BGRA_SUPPORT |
                     D3D10_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS,
@@ -1455,17 +1415,17 @@ gfxWindowsPlatform::GetD3D11Device()
 {
   if (mD3D11DeviceInitialized) {
     return mD3D11Device;
   }
 
   mD3D11DeviceInitialized = true;
 
   nsModuleHandle d3d11Module(LoadLibrarySystem32(L"d3d11.dll"));
-  D3D11CreateDeviceFunc d3d11CreateDevice = (D3D11CreateDeviceFunc)
+  decltype(D3D11CreateDevice)* d3d11CreateDevice = (decltype(D3D11CreateDevice)*)
     GetProcAddress(d3d11Module, "D3D11CreateDevice");
 
   if (!d3d11CreateDevice) {
     return nullptr;
   }
 
   nsTArray<D3D_FEATURE_LEVEL> featureLevels;
   if (IsWin8OrLater()) {
@@ -1523,17 +1483,17 @@ gfxWindowsPlatform::GetScreenDepth() con
 IDXGIAdapter1*
 gfxWindowsPlatform::GetDXGIAdapter()
 {
   if (mAdapter) {
     return mAdapter;
   }
 
   nsModuleHandle dxgiModule(LoadLibrarySystem32(L"dxgi.dll"));
-  CreateDXGIFactory1Func createDXGIFactory1 = (CreateDXGIFactory1Func)
+  decltype(CreateDXGIFactory1)* createDXGIFactory1 = (decltype(CreateDXGIFactory1)*)
     GetProcAddress(dxgiModule, "CreateDXGIFactory1");
 
   // Try to use a DXGI 1.1 adapter in order to share resources
   // across processes.
   if (createDXGIFactory1) {
     nsRefPtr<IDXGIFactory1> factory1;
     HRESULT hr = createDXGIFactory1(__uuidof(IDXGIFactory1),
                                     getter_AddRefs(factory1));
--- a/hal/windows/WindowsBattery.cpp
+++ b/hal/windows/WindowsBattery.cpp
@@ -16,20 +16,18 @@
 using namespace mozilla::dom::battery;
 
 namespace mozilla {
 namespace hal_impl {
 
 static nsCOMPtr<nsITimer> sUpdateTimer;
 
 /* Power Event API is Vista or later */
-typedef HPOWERNOTIFY (WINAPI *REGISTERPOWERSETTINGNOTIFICATION) (HANDLE, LPCGUID, DWORD);
-typedef BOOL (WINAPI *UNREGISTERPOWERSETTINGNOTIFICATION) (HPOWERNOTIFY);
-static REGISTERPOWERSETTINGNOTIFICATION sRegisterPowerSettingNotification = nullptr;
-static UNREGISTERPOWERSETTINGNOTIFICATION sUnregisterPowerSettingNotification = nullptr;
+static decltype(RegisterPowerSettingNotification)* sRegisterPowerSettingNotification = nullptr;
+static decltype(UnregisterPowerSettingNotification)* sUnregisterPowerSettingNotification = nullptr;
 static HPOWERNOTIFY sPowerHandle = nullptr;
 static HPOWERNOTIFY sCapacityHandle = nullptr;
 static HWND sHWnd = nullptr;
 
 static void
 UpdateHandler(nsITimer* aTimer, void* aClosure) {
   NS_ASSERTION(!IsVistaOrLater(),
                "We shouldn't call this function for Vista or later version!");
@@ -65,20 +63,20 @@ BatteryWindowProc(HWND hwnd, UINT msg, W
 void
 EnableBatteryNotifications()
 {
   if (IsVistaOrLater()) {
     // RegisterPowerSettingNotification is from Vista or later.
     // Use this API if available.
     HMODULE hUser32 = GetModuleHandleW(L"USER32.DLL");
     if (!sRegisterPowerSettingNotification)
-      sRegisterPowerSettingNotification = (REGISTERPOWERSETTINGNOTIFICATION)
+      sRegisterPowerSettingNotification = (decltype(RegisterPowerSettingNotification)*)
         GetProcAddress(hUser32, "RegisterPowerSettingNotification");
     if (!sUnregisterPowerSettingNotification)
-      sUnregisterPowerSettingNotification = (UNREGISTERPOWERSETTINGNOTIFICATION)
+      sUnregisterPowerSettingNotification = (decltype(UnregisterPowerSettingNotification)*)
         GetProcAddress(hUser32, "UnregisterPowerSettingNotification");
 
     if (!sRegisterPowerSettingNotification ||
         !sUnregisterPowerSettingNotification) {
       NS_ASSERTION(false, "Canot find PowerSettingNotification functions.");
       return;
     }
 
--- a/image/decoders/icon/win/nsIconChannel.cpp
+++ b/image/decoders/icon/win/nsIconChannel.cpp
@@ -50,18 +50,16 @@ struct ICONENTRY {
   uint8_t ieColors;
   uint8_t ieReserved;
   uint16_t iePlanes;
   uint16_t ieBitCount;
   uint32_t ieSizeImage;
   uint32_t ieFileOffset;
 };
 
-typedef HRESULT (WINAPI*SHGetStockIconInfoPtr) (SHSTOCKICONID siid, UINT uFlags, SHSTOCKICONINFO *psii);
-
 // Match stock icons with names
 static SHSTOCKICONID GetStockIconIDForName(const nsACString &aStockName)
 {
   // UAC shield icon
   if (aStockName == NS_LITERAL_CSTRING("uac-shield"))
     return SIID_SHIELD;
 
   return SIID_INVALID;
@@ -344,18 +342,18 @@ nsresult nsIconChannel::GetHIconFromFile
 }
 
 nsresult nsIconChannel::GetStockHIcon(nsIMozIconURI *aIconURI, HICON *hIcon)
 {
   nsresult rv = NS_OK;
 
   // We can only do this on Vista or above
   HMODULE hShellDLL = ::LoadLibraryW(L"shell32.dll");
-  SHGetStockIconInfoPtr pSHGetStockIconInfo =
-    (SHGetStockIconInfoPtr) ::GetProcAddress(hShellDLL, "SHGetStockIconInfo");
+  decltype(SHGetStockIconInfo)* pSHGetStockIconInfo =
+    (decltype(SHGetStockIconInfo)*) ::GetProcAddress(hShellDLL, "SHGetStockIconInfo");
 
   if (pSHGetStockIconInfo)
   {
     uint32_t desiredImageSize;
     aIconURI->GetImageSize(&desiredImageSize);
     nsAutoCString stockIcon;
     aIconURI->GetStockIcon(stockIcon);
 
--- a/netwerk/system/win32/nsNotifyAddrListener.cpp
+++ b/netwerk/system/win32/nsNotifyAddrListener.cpp
@@ -21,27 +21,25 @@
 #include "nsString.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Services.h"
 #include "nsCRT.h"
 
 #include <iptypes.h>
 #include <iphlpapi.h>
 
-typedef void (WINAPI *NcFreeNetconPropertiesFunc)(NETCON_PROPERTIES*);
-
 static HMODULE sNetshell;
-static NcFreeNetconPropertiesFunc sNcFreeNetconProperties;
+static decltype(NcFreeNetconProperties)* sNcFreeNetconProperties;
 
 static void InitNetshellLibrary(void)
 {
     if (!sNetshell) {
         sNetshell = LoadLibraryW(L"Netshell.dll");
         if (sNetshell) {
-            sNcFreeNetconProperties = (NcFreeNetconPropertiesFunc)
+            sNcFreeNetconProperties = (decltype(NcFreeNetconProperties)*)
                 GetProcAddress(sNetshell, "NcFreeNetconProperties");
         }
     }
 }
 
 static void FreeDynamicLibraries(void)
 {
     if (sNetshell) {
--- a/netwerk/wifi/nsWifiScannerWin.cpp
+++ b/netwerk/wifi/nsWifiScannerWin.cpp
@@ -10,30 +10,32 @@
 
 #include "nsWifiMonitor.h"
 #include "nsWifiAccessPoint.h"
 
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIMutableArray.h"
 
+#define DOT11_BSS_TYPE_UNUSED static_cast<DOT11_BSS_TYPE>(0)
+
 using namespace mozilla;
 
 nsresult
 nsWifiMonitor::DoScan()
 {
     HINSTANCE wlan_library = LoadLibrary("Wlanapi.dll");
     if (!wlan_library)
       return NS_ERROR_NOT_AVAILABLE;
 
-    WlanOpenHandleFunction WlanOpenHandle = (WlanOpenHandleFunction) GetProcAddress(wlan_library, "WlanOpenHandle");
-    WlanEnumInterfacesFunction WlanEnumInterfaces = (WlanEnumInterfacesFunction) GetProcAddress(wlan_library, "WlanEnumInterfaces");
-    WlanGetNetworkBssListFunction WlanGetNetworkBssList = (WlanGetNetworkBssListFunction) GetProcAddress(wlan_library, "WlanGetNetworkBssList");
-    WlanFreeMemoryFunction WlanFreeMemory = (WlanFreeMemoryFunction) GetProcAddress(wlan_library, "WlanFreeMemory");
-    WlanCloseHandleFunction WlanCloseHandle = (WlanCloseHandleFunction) GetProcAddress(wlan_library, "WlanCloseHandle");
+    decltype(::WlanOpenHandle)* WlanOpenHandle = (decltype(::WlanOpenHandle)*) GetProcAddress(wlan_library, "WlanOpenHandle");
+    decltype(::WlanEnumInterfaces)* WlanEnumInterfaces = (decltype(::WlanEnumInterfaces)*) GetProcAddress(wlan_library, "WlanEnumInterfaces");
+    decltype(::WlanGetNetworkBssList)* WlanGetNetworkBssList = (decltype(::WlanGetNetworkBssList)*) GetProcAddress(wlan_library, "WlanGetNetworkBssList");
+    decltype(::WlanFreeMemory)* WlanFreeMemory = (decltype(::WlanFreeMemory)*) GetProcAddress(wlan_library, "WlanFreeMemory");
+    decltype(::WlanCloseHandle)* WlanCloseHandle = (decltype(::WlanCloseHandle)*) GetProcAddress(wlan_library, "WlanCloseHandle");
 
     if (!WlanOpenHandle ||
         !WlanEnumInterfaces ||
         !WlanGetNetworkBssList ||
         !WlanFreeMemory ||
         !WlanCloseHandle)
       return NS_ERROR_FAILURE;
 
deleted file mode 100644
--- a/netwerk/wifi/wlanapi.h
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright 2008, Google Inc.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-//  1. Redistributions of source code must retain the above copyright notice,
-//     this list of conditions and the following disclaimer.
-//  2. Redistributions in binary form must reproduce the above copyright notice,
-//     this list of conditions and the following disclaimer in the documentation
-//     and/or other materials provided with the distribution.
-//  3. Neither the name of Google Inc. nor the names of its contributors may be
-//     used to endorse or promote products derived from this software without
-//     specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Replicates missing wlanapi.h. Taken from
-// http://msdn.microsoft.com/en-us/library/bb204766.aspx.
-
-// TODO(steveblock): Change naming convention to follow correct style.
-
-
-// WlanOpenHandle
-
-typedef DWORD (WINAPI *WlanOpenHandleFunction)(DWORD dwClientVersion,
-                                               PVOID pReserved,
-                                               PDWORD pdwNegotiatedVersion,
-                                               PHANDLE phClientHandle);
-
-// WlanEnumInterfaces
-
-typedef enum _WLAN_INTERFACE_STATE {
-  WLAN_INTERFACE_STATE_UNUSED
-} WLAN_INTERFACE_STATE;
-
-typedef struct _WLAN_INTERFACE_INFO {
-  GUID InterfaceGuid;
-  WCHAR strInterfaceDescription[256];
-  WLAN_INTERFACE_STATE isState;
-} WLAN_INTERFACE_INFO, *PWLAN_INTERFACE_INFO;
-
-typedef struct _WLAN_INTERFACE_INFO_LIST {
-  DWORD dwNumberOfItems;
-  DWORD dwIndex;
-  WLAN_INTERFACE_INFO InterfaceInfo[1];
-} WLAN_INTERFACE_INFO_LIST, *PWLAN_INTERFACE_INFO_LIST;
-
-typedef DWORD (WINAPI *WlanEnumInterfacesFunction)(
-    HANDLE hClientHandle,
-    PVOID pReserved,
-    PWLAN_INTERFACE_INFO_LIST *ppInterfaceList);
-
-// WlanGetNetworkBssList
-
-#define DOT11_SSID_MAX_LENGTH 32
-
-typedef struct _DOT11_SSID {
-  ULONG uSSIDLength;
-  UCHAR ucSSID[DOT11_SSID_MAX_LENGTH];
-} DOT11_SSID, *PDOT11_SSID;
-
-typedef UCHAR DOT11_MAC_ADDRESS[6];
-
-typedef enum _DOT11_BSS_TYPE {
-  DOT11_BSS_TYPE_UNUSED
-} DOT11_BSS_TYPE;
-
-typedef enum _DOT11_PHY_TYPE {
-  DOT11_PHY_TYPE_UNUSED
-} DOT11_PHY_TYPE;
-
-#define DOT11_RATE_SET_MAX_LENGTH (126)
-
-typedef struct _WLAN_RATE_SET {
-  ULONG uRateSetLength;
-  USHORT usRateSet[DOT11_RATE_SET_MAX_LENGTH];
-} WLAN_RATE_SET, *PWLAN_RATE_SET;
-
-typedef struct _WLAN_BSS_ENTRY {
-  DOT11_SSID dot11Ssid;
-  ULONG uPhyId;
-  DOT11_MAC_ADDRESS dot11Bssid;
-  DOT11_BSS_TYPE dot11BssType;
-  DOT11_PHY_TYPE dot11BssPhyType;
-  LONG lRssi;
-  ULONG uLinkQuality;
-  BOOLEAN bInRegDomain;
-  USHORT usBeaconPeriod;
-  ULONGLONG ullTimestamp;
-  ULONGLONG ullHostTimestamp;
-  USHORT usCapabilityInformation;
-  ULONG ulChCenterFrequency;
-  WLAN_RATE_SET wlanRateSet;
-  ULONG ulIeOffset;
-  ULONG ulIeSize;
-} WLAN_BSS_ENTRY, *PWLAN_BSS_ENTRY;
-
-typedef struct _WLAN_BSS_LIST {
-  DWORD dwTotalSize;
-  DWORD dwNumberOfItems;
-  // Following data is an array of WLAN_BSS_ENTRY objects of length
-  // dwNumberOfItems.
-  WLAN_BSS_ENTRY wlanBssEntries[1];
-} WLAN_BSS_LIST, *PWLAN_BSS_LIST;
-
-typedef DWORD (WINAPI *WlanGetNetworkBssListFunction)(
-    HANDLE hClientHandle,
-    const GUID *pInterfaceGuid,
-    const  PDOT11_SSID pDot11Ssid,
-    DOT11_BSS_TYPE dot11BssType,
-    BOOL bSecurityEnabled,
-    PVOID pReserved,
-    PWLAN_BSS_LIST *ppWlanBssList
-);
-
-// WlanFreeMemory
-
-typedef VOID (WINAPI *WlanFreeMemoryFunction)(PVOID pMemory);
-
-// WlanCloseHandle
-
-typedef DWORD (WINAPI *WlanCloseHandleFunction)(HANDLE hClientHandle,
-                                                PVOID pReserved);
-
-
--- a/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
+++ b/toolkit/components/parentalcontrols/nsParentalControlsServiceWin.cpp
@@ -16,34 +16,19 @@
 
 static const CLSID CLSID_WinParentalControls = {0xE77CC89B,0x7401,0x4C04,{0x8C,0xED,0x14,0x9D,0xB3,0x5A,0xDD,0x04}};
 static const IID IID_IWinParentalControls  = {0x28B4D88B,0xE072,0x49E6,{0x80,0x4D,0x26,0xED,0xBE,0x21,0xA7,0xB9}};
 
 NS_IMPL_ISUPPORTS1(nsParentalControlsServiceWin, nsIParentalControlsService)
 
 static HINSTANCE gAdvAPIDLLInst = nullptr;
 
-typedef ULONG (STDMETHODCALLTYPE *MyEventWrite)(
-  REGHANDLE RegHandle,
-  PCEVENT_DESCRIPTOR EventDescriptor,
-  ULONG UserDataCount,
-  PEVENT_DATA_DESCRIPTOR UserData);
-
-typedef ULONG (STDMETHODCALLTYPE *MyEventRegister)(
-  LPCGUID ProviderId,
-  PENABLECALLBACK EnableCallback,
-  PVOID CallbackContext,
-  PREGHANDLE RegHandle);
-
-typedef ULONG (STDMETHODCALLTYPE *MyEventUnregister)(
-  REGHANDLE RegHandle);
-
-MyEventWrite gEventWrite = nullptr;
-MyEventRegister gEventRegister = nullptr;
-MyEventUnregister gEventUnregister = nullptr;
+decltype(EventWrite)* gEventWrite = nullptr;
+decltype(EventRegister)* gEventRegister = nullptr;
+decltype(EventUnregister)* gEventUnregister = nullptr;
 
 nsParentalControlsServiceWin::nsParentalControlsServiceWin() :
   mEnabled(false)
 , mProvider(0)
 , mPC(nullptr)
 {
   HRESULT hr;
   CoInitialize(nullptr);
@@ -62,19 +47,19 @@ nsParentalControlsServiceWin::nsParental
 
   DWORD settings = 0;
   wpcs->GetRestrictions(&settings);
   
   if (settings) { // WPCFLAG_NO_RESTRICTION = 0
     gAdvAPIDLLInst = ::LoadLibrary("Advapi32.dll");
     if(gAdvAPIDLLInst)
     {
-      gEventWrite = (MyEventWrite) GetProcAddress(gAdvAPIDLLInst, "EventWrite");
-      gEventRegister = (MyEventRegister) GetProcAddress(gAdvAPIDLLInst, "EventRegister");
-      gEventUnregister = (MyEventUnregister) GetProcAddress(gAdvAPIDLLInst, "EventUnregister");
+      gEventWrite = (decltype(EventWrite)*) GetProcAddress(gAdvAPIDLLInst, "EventWrite");
+      gEventRegister = (decltype(EventRegister)*) GetProcAddress(gAdvAPIDLLInst, "EventRegister");
+      gEventUnregister = (decltype(EventUnregister)*) GetProcAddress(gAdvAPIDLLInst, "EventUnregister");
     }
     mEnabled = true;
   }
 }
 
 nsParentalControlsServiceWin::~nsParentalControlsServiceWin()
 {
   if (mPC)
--- a/toolkit/content/license.html
+++ b/toolkit/content/license.html
@@ -2285,53 +2285,16 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTI
 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 </pre>
 
 
     <hr>
 
-    <h1><a id="gears"></a>Google Gears License</h1>
-
-    <p>This license applies to the file
-    <span class="path">netwerk/wifi/wlanapi.h</span>.</p>
-
-<pre>
-Copyright 2008, Google Inc.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
-    this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright notice,
-    this list of conditions and the following disclaimer in the documentation
-    and/or other materials provided with the distribution.
- 3. Neither the name of Google Inc. nor the names of its contributors may be
-    used to endorse or promote products derived from this software without
-    specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-</pre>
-
-
-
-
-    <hr>
-
     <h1><a id="vp8"></a>Google VP8 License</h1>
 
     <p>This license applies to certain files in the directory
     <span class="path">media/libvpx</span>.</p>
 <pre>
 Copyright (c) 2010, Google, Inc.
 
 All rights reserved.
--- a/toolkit/mozapps/update/common/uachelper.cpp
+++ b/toolkit/mozapps/update/common/uachelper.cpp
@@ -1,18 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <windows.h>
+#include <wtsapi32.h>
 #include "uachelper.h"
 #include "updatelogging.h"
 
-typedef BOOL (WINAPI *LPWTSQueryUserToken)(ULONG, PHANDLE);
-
 // See the MSDN documentation with title: Privilege Constants
 // At the time of this writing, this documentation is located at: 
 // http://msdn.microsoft.com/en-us/library/windows/desktop/bb530716%28v=vs.85%29.aspx
 LPCTSTR UACHelper::PrivsToDisable[] = { 
   SE_ASSIGNPRIMARYTOKEN_NAME,
   SE_AUDIT_NAME,
   SE_BACKUP_NAME,
   // CreateProcess will succeed but the app will fail to launch on some WinXP 
@@ -62,18 +61,18 @@ LPCTSTR UACHelper::PrivsToDisable[] = {
  * @return A handle to the token to obtain which will be primary if enough
  *         permissions exist.  Caller should close the handle.
  */
 HANDLE
 UACHelper::OpenUserToken(DWORD sessionID)
 {
   HMODULE module = LoadLibraryW(L"wtsapi32.dll");
   HANDLE token = nullptr;
-  LPWTSQueryUserToken wtsQueryUserToken = 
-    (LPWTSQueryUserToken)GetProcAddress(module, "WTSQueryUserToken");
+  decltype(WTSQueryUserToken)* wtsQueryUserToken = 
+    (decltype(WTSQueryUserToken)*) GetProcAddress(module, "WTSQueryUserToken");
   if (wtsQueryUserToken) {
     wtsQueryUserToken(sessionID, &token);
   }
   FreeLibrary(module);
   return token;
 }
 
 /**
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -2620,22 +2620,16 @@ static void MOZ_gdk_display_close(GdkDis
  * improve startup performance.
  */
 NS_VISIBILITY_DEFAULT PRBool nspr_use_zone_allocator = PR_FALSE;
 
 #ifdef CAIRO_HAS_DWRITE_FONT
 
 #include <dwrite.h>
 
-typedef HRESULT (WINAPI*DWriteCreateFactoryFunc)(
-  DWRITE_FACTORY_TYPE factoryType,
-  REFIID iid,
-  IUnknown **factory
-);
-
 #ifdef DEBUG_DWRITE_STARTUP
 
 #define LOGREGISTRY(msg) LogRegistryEvent(msg)
 
 // for use when monitoring process
 static void LogRegistryEvent(const wchar_t *msg)
 {
   HKEY dummyKey;
@@ -2655,17 +2649,17 @@ static void LogRegistryEvent(const wchar
 #endif
 
 static DWORD InitDwriteBG(LPVOID lpdwThreadParam)
 {
   SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN);
   LOGREGISTRY(L"loading dwrite.dll");
   HMODULE dwdll = LoadLibraryW(L"dwrite.dll");
   if (dwdll) {
-    DWriteCreateFactoryFunc createDWriteFactory = (DWriteCreateFactoryFunc)
+    decltype(DWriteCreateFactory)* createDWriteFactory = (decltype(DWriteCreateFactory)*)
       GetProcAddress(dwdll, "DWriteCreateFactory");
     if (createDWriteFactory) {
       LOGREGISTRY(L"creating dwrite factory");
       IDWriteFactory *factory;
       HRESULT hr = createDWriteFactory(
         DWRITE_FACTORY_TYPE_SHARED,
         __uuidof(IDWriteFactory),
         reinterpret_cast<IUnknown**>(&factory));
--- a/tools/trace-malloc/lib/nsDebugHelpWin32.cpp
+++ b/tools/trace-malloc/lib/nsDebugHelpWin32.cpp
@@ -20,17 +20,17 @@
 
 
 
 /***************************************************************************/
 
 
 PRLock*           DHWImportHooker::gLock  = nullptr;
 DHWImportHooker*  DHWImportHooker::gHooks = nullptr;
-GETPROCADDRESS    DHWImportHooker::gRealGetProcAddress = nullptr;
+decltype(GetProcAddress)* DHWImportHooker::gRealGetProcAddress = nullptr;
 
 
 static bool
 dhwEnsureImageHlpInitialized()
 {
   static bool gInitialized = false;
   static bool gTried       = false;
 
@@ -42,17 +42,17 @@ dhwEnsureImageHlpInitialized()
       printf("DumpStack Error: DBGHELP.DLL wasn't found. GetLastError() returned 0x%8.8X\n"
              "                 This DLL is needed for succeessfully implementing trace-malloc.\n"
              "                 This dll ships by default on Win2k. Disabling trace-malloc functionality.\n"
              , dw);
       return false;
     }
 
 #define INIT_PROC(typename_, name_) \
-    dhw##name_ = (typename_) ::GetProcAddress(module, #name_); \
+    dhw##name_ = (decltype(name_)*) ::GetProcAddress(module, #name_); \
     if(!dhw##name_) return false;
 
 #ifdef _WIN64
     INIT_PROC(ENUMERATELOADEDMODULES64, EnumerateLoadedModules64);
 #else
     INIT_PROC(ENUMERATELOADEDMODULES, EnumerateLoadedModules);
 #endif
     INIT_PROC(IMAGEDIRECTORYENTRYTODATA, ImageDirectoryEntryToData);
@@ -307,53 +307,48 @@ DHWImportHooker::ModuleLoaded(HMODULE aM
     return true;
 }
 
 // static 
 HMODULE WINAPI 
 DHWImportHooker::LoadLibraryW(PCWSTR path)
 {
     //wprintf(L"LoadLibraryW %s\n",path);
-    DHW_DECLARE_FUN_TYPE(HMODULE, __stdcall, LOADLIBRARYW_, (PCWSTR));
-    HMODULE hmod = DHW_ORIGINAL(LOADLIBRARYW_, getLoadLibraryWHooker())(path);
+    HMODULE hmod = DHW_ORIGINAL(::LoadLibraryW, getLoadLibraryWHooker())(path);
     ModuleLoaded(hmod, 0);
     return hmod;
 }
 
 
 // static 
 HMODULE WINAPI 
 DHWImportHooker::LoadLibraryExW(PCWSTR path, HANDLE file, DWORD flags)
 {
     //wprintf(L"LoadLibraryExW %s\n",path);
-    DHW_DECLARE_FUN_TYPE(HMODULE, __stdcall, LOADLIBRARYEXW_, (PCWSTR, HANDLE, DWORD));
-    HMODULE hmod = DHW_ORIGINAL(LOADLIBRARYEXW_, getLoadLibraryExWHooker())(path, file, flags);
+    HMODULE hmod = DHW_ORIGINAL(::LoadLibraryExW, getLoadLibraryExWHooker())(path, file, flags);
     ModuleLoaded(hmod, flags);
     return hmod;
 }    
 
 // static 
 HMODULE WINAPI 
 DHWImportHooker::LoadLibraryA(PCSTR path)
 {
     //printf("LoadLibraryA %s\n",path);
-
-    DHW_DECLARE_FUN_TYPE(HMODULE, __stdcall, LOADLIBRARYA_, (PCSTR));
-    HMODULE hmod = DHW_ORIGINAL(LOADLIBRARYA_, getLoadLibraryAHooker())(path);
+    HMODULE hmod = DHW_ORIGINAL(::LoadLibraryA, getLoadLibraryAHooker())(path);
     ModuleLoaded(hmod, 0);
     return hmod;
 }
 
 // static 
 HMODULE WINAPI 
 DHWImportHooker::LoadLibraryExA(PCSTR path, HANDLE file, DWORD flags)
 {
     //printf("LoadLibraryExA %s\n",path);
-    DHW_DECLARE_FUN_TYPE(HMODULE, __stdcall, LOADLIBRARYEXA_, (PCSTR, HANDLE, DWORD));
-    HMODULE hmod = DHW_ORIGINAL(LOADLIBRARYEXA_, getLoadLibraryExAHooker())(path, file, flags);
+    HMODULE hmod = DHW_ORIGINAL(::LoadLibraryExA, getLoadLibraryExAHooker())(path, file, flags);
     ModuleLoaded(hmod, flags);
     return hmod;
 }     
 // static 
 FARPROC WINAPI 
 DHWImportHooker::GetProcAddress(HMODULE aModule, PCSTR aFunctionName)
 {
     FARPROC pfn = gRealGetProcAddress(aModule, aFunctionName);
--- a/tools/trace-malloc/lib/nsDebugHelpWin32.h
+++ b/tools/trace-malloc/lib/nsDebugHelpWin32.h
@@ -21,134 +21,47 @@
 
 // XXX temporary hack...
 //#include "hacky_defines.h"
 
 
 /***************************************************************************/
 // useful macros...
 
-#define DHW_DECLARE_FUN_TYPE(retval_, conv_, typename_, args_) \
-    typedef retval_ ( conv_ * typename_ ) args_ ;
-
 #ifdef DHW_IMPLEMENT_GLOBALS
-#define DHW_DECLARE_FUN_GLOBAL(typename_, name_) typename_ dhw##name_
+#define DHW_DECLARE_FUN_GLOBAL(name_) decltype(name_)* dhw##name_
 #else
-#define DHW_DECLARE_FUN_GLOBAL(typename_, name_) extern typename_ dhw##name_
+#define DHW_DECLARE_FUN_GLOBAL(name_) extern decltype(name_)* dhw##name_
 #endif
 
-#define DHW_DECLARE_FUN_PROTO(retval_, conv_, name_, args_) \
-    retval_ conv_ name_ args_
-
-#define DHW_DECLARE_FUN_STATIC_PROTO(retval_, name_, args_) \
-    static retval_ conv_ name_ args_
-
-#define DHW_DECLARE_FUN_TYPE_AND_PROTO(name_, retval_, conv_, typename_, args_) \
-    DHW_DECLARE_FUN_TYPE(retval_, conv_, typename_, args_); \
-    DHW_DECLARE_FUN_PROTO(retval_, conv_, name_, args_)
-
-#define DHW_DECLARE_FUN_TYPE_AND_STATIC_PROTO(name_, retval_, conv_, typename_, args_) \
-    DHW_DECLARE_FUN_TYPE(retval_, conv_, typename_, args_); \
-    DHW_DECLARE_FUN_STATIC_PROTO(retval_, conv_, name_, args_)
-
-#define DHW_DECLARE_FUN_TYPE_AND_GLOBAL(typename_, name_, retval_, conv_, args_) \
-    DHW_DECLARE_FUN_TYPE(retval_, conv_, typename_, args_); \
-    DHW_DECLARE_FUN_GLOBAL(typename_, name_)
-
 
 /**********************************************************/
-// These are used to get 'original' function addresses from DHWImportHooker.
-
-#define DHW_DECLARE_ORIGINAL(type_, name_, hooker_) \
-    type_ name_ = (type_) hooker_ . GetOriginalFunction()
+// This is used to get 'original' function addresses from DHWImportHooker.
 
-#define DHW_DECLARE_ORIGINAL_PTR(type_, name_, hooker_) \
-    type_ name_ = (type_) hooker_ -> GetOriginalFunction()
-
-#define DHW_ORIGINAL(type_, hooker_) \
-    ((type_) hooker_ . GetOriginalFunction())
-
-#define DHW_ORIGINAL_PTR(type_, hooker_) \
-    ((type_) hooker_ -> GetOriginalFunction())
+#define DHW_ORIGINAL(name_, hooker_) \
+    ((decltype(name_)*) hooker_ . GetOriginalFunction())
 
 /***************************************************************************/
 // Global declarations of entry points into ImgHelp functions
-#if 0
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMINITIALIZEPROC, SymInitialize, \
-                                BOOL, __stdcall, (HANDLE, LPSTR, BOOL));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMSETOPTIONS, SymSetOptions, \
-                                DWORD, __stdcall, (DWORD));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETOPTIONS, SymGetOptions, \
-                                DWORD, __stdcall, ());
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETMODULEINFO, SymGetModuleInfo, \
-                                BOOL, __stdcall, (HANDLE, DWORD, PIMAGEHLP_MODULE));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETSYMFROMADDRPROC, SymGetSymFromAddr, \
-                                BOOL, __stdcall, (HANDLE, DWORD, PDWORD, PIMAGEHLP_SYMBOL));
-
-#endif
 
 #ifndef _WIN64
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(ENUMERATELOADEDMODULES, EnumerateLoadedModules, \
-                                BOOL, __stdcall, (HANDLE, PENUMLOADED_MODULES_CALLBACK, PVOID));
+DHW_DECLARE_FUN_GLOBAL(EnumerateLoadedModules);
 #else
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(ENUMERATELOADEDMODULES64, EnumerateLoadedModules64, \
-                                BOOL, __stdcall, (HANDLE, PENUMLOADED_MODULES_CALLBACK64, PVOID));
+DHW_DECLARE_FUN_GLOBAL(EnumerateLoadedModules64);
 #endif
 
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(IMAGEDIRECTORYENTRYTODATA, ImageDirectoryEntryToData, \
-                                PVOID, __stdcall, (PVOID, BOOL, USHORT, PULONG));
-
-// We aren't using any of the below yet...
-
-/*
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMCLEANUPPROC, SymCleanup, \
-                                BOOL, __stdcall, (HANDLE));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(STACKWALKPROC, StackWalk, \
-                                BOOL, 
-                                __stdcall, 
-                                (DWORD, HANDLE, HANDLE, LPSTACKFRAME, LPVOID, \
-                                       PREAD_PROCESS_MEMORY_ROUTINE, \
-                                       PFUNCTION_TABLE_ACCESS_ROUTINE, \
-                                       PGET_MODULE_BASE_ROUTINE, \
-                                       PTRANSLATE_ADDRESS_ROUTINE));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMFUNCTIONTABLEACCESSPROC, SymFunctionTableAccess, \
-                                LPVOID, __stdcall, (HANDLE, DWORD));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETMODULEBASEPROC, SymGetModuleBase, \
-                                DWORD, __stdcall, (HANDLE, DWORD));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMLOADMODULE, SymLoadModule, \
-                                DWORD, __stdcall, (HANDLE, HANDLE, PSTR, PSTR, DWORD, DWORD));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(UNDECORATESYMBOLNAME, _UnDecorateSymbolName, \
-                                DWORD, __stdcall, (LPCSTR, LPSTR, DWORD, DWORD));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMUNDNAME, SymUnDName, \
-                                BOOL, __stdcall, (PIMAGEHLP_SYMBOL, LPSTR, DWORD));
-
-DHW_DECLARE_FUN_TYPE_AND_GLOBAL(SYMGETLINEFROMADDR, SymGetLineFromAddr, \
-                                BOOL, __stdcall, (HANDLE, DWORD, PDWORD, PIMAGEHLP_LINE));
-
-*/
+DHW_DECLARE_FUN_GLOBAL(ImageDirectoryEntryToData);
 
 /***************************************************************************/
 
 extern bool
 dhwEnsureImageHlpInitialized();
 
 /***************************************************************************/
 
-DHW_DECLARE_FUN_TYPE(FARPROC, __stdcall, GETPROCADDRESS, (HMODULE, PCSTR));
-
 class DHWImportHooker
 {
 public: 
 
     DHWImportHooker(const char* aModuleName,
                     const char* aFunctionName,
                     PROC aHook,
                     bool aExcludeOurModule = false);
@@ -182,17 +95,17 @@ private:
     PROC             mOriginal;
     PROC             mHook;
     HMODULE          mIgnoreModule;
     bool             mHooking;
 
 private:
     static PRLock* gLock;
     static DHWImportHooker* gHooks;
-    static GETPROCADDRESS gRealGetProcAddress;
+    static decltype(GetProcAddress)* gRealGetProcAddress;
     
     static HMODULE WINAPI LoadLibraryW(PCWSTR path);
     static HMODULE WINAPI LoadLibraryExW(PCWSTR path, HANDLE file, DWORD flags);
     static HMODULE WINAPI LoadLibraryExA(PCSTR path, HANDLE file, DWORD flags);
 
     static FARPROC WINAPI GetProcAddress(HMODULE aModule, PCSTR aFunctionName);
 };
 
--- a/tools/trace-malloc/lib/nsWinTraceMalloc.cpp
+++ b/tools/trace-malloc/lib/nsWinTraceMalloc.cpp
@@ -32,169 +32,169 @@
 #elif _MSC_VER == 1700
 #define NS_DEBUG_CRT "msvcr110d.dll"
 #elif _MSC_VER == 1800
 #define NS_DEBUG_CRT "msvcr120d.dll"
 #else
 #error "Don't know filename of MSVC debug library."
 #endif
 
-DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_malloc, void*, __cdecl, MALLOC_, (size_t));
+decltype(malloc) dhw_malloc;
 
 DHWImportHooker &getMallocHooker()
 {
   static DHWImportHooker gMallocHooker(NS_DEBUG_CRT, "malloc", (PROC) dhw_malloc);
   return gMallocHooker;
 }
 
 void * __cdecl dhw_malloc( size_t size )
 {
     tm_thread *t = tm_get_thread();
     ++t->suppress_tracing;
     uint32_t start = PR_IntervalNow();
-    void* result = DHW_ORIGINAL(MALLOC_, getMallocHooker())(size);
+    void* result = DHW_ORIGINAL(malloc, getMallocHooker())(size);
     uint32_t end = PR_IntervalNow();
     --t->suppress_tracing;
     MallocCallback(result, size, start, end, t);
     return result;    
 }
 
-DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_calloc, void*, __cdecl, CALLOC_, (size_t,size_t));
+decltype(calloc) dhw_calloc;
 
 DHWImportHooker &getCallocHooker()
 {
   static DHWImportHooker gCallocHooker(NS_DEBUG_CRT, "calloc", (PROC) dhw_calloc);
   return gCallocHooker;
 }
 
 void * __cdecl dhw_calloc( size_t count, size_t size )
 {
     tm_thread *t = tm_get_thread();
     ++t->suppress_tracing;
     uint32_t start = PR_IntervalNow();
-    void* result = DHW_ORIGINAL(CALLOC_, getCallocHooker())(count,size);
+    void* result = DHW_ORIGINAL(calloc, getCallocHooker())(count,size);
     uint32_t end = PR_IntervalNow();
     --t->suppress_tracing;
     CallocCallback(result, count, size, start, end, t);
     return result;    
 }
 
-DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_free, void, __cdecl, FREE_, (void*));
+decltype(free) dhw_free;
 DHWImportHooker &getFreeHooker()
 {
   static DHWImportHooker gFreeHooker(NS_DEBUG_CRT, "free", (PROC) dhw_free);
   return gFreeHooker;
 }
 
 void __cdecl dhw_free( void* p )
 {
     tm_thread *t = tm_get_thread();
     ++t->suppress_tracing;
     uint32_t start = PR_IntervalNow();
-    DHW_ORIGINAL(FREE_, getFreeHooker())(p);
+    DHW_ORIGINAL(free, getFreeHooker())(p);
     uint32_t end = PR_IntervalNow();
     --t->suppress_tracing;
     /* FIXME bug 392008: We could race with reallocation of p. */
     FreeCallback(p, start, end, t);
 }
 
 
-DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_realloc, void*, __cdecl, REALLOC_, (void*, size_t));
+decltype(realloc) dhw_realloc;
 DHWImportHooker &getReallocHooker()
 {
   static DHWImportHooker gReallocHooker(NS_DEBUG_CRT, "realloc", (PROC) dhw_realloc);
   return gReallocHooker;
 }
 
 void * __cdecl dhw_realloc(void * pin, size_t size)
 {
     tm_thread *t = tm_get_thread();
     ++t->suppress_tracing;
     uint32_t start = PR_IntervalNow();
-    void* pout = DHW_ORIGINAL(REALLOC_, getReallocHooker())(pin, size);
+    void* pout = DHW_ORIGINAL(realloc, getReallocHooker())(pin, size);
     uint32_t end = PR_IntervalNow();
     --t->suppress_tracing;
     /* FIXME bug 392008: We could race with reallocation of pin. */
     ReallocCallback(pin, pout, size, start, end, t);
     return pout;
 }
 
 // Note the mangled name!
-DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_new, void*, __cdecl, NEW_, (size_t));
+void * __cdecl dhw_new(size_t size);
 DHWImportHooker &getNewHooker()
 {
   static DHWImportHooker gNewHooker(NS_DEBUG_CRT, "??2@YAPAXI@Z", (PROC) dhw_new);
   return gNewHooker;
 }
 
 void * __cdecl dhw_new(size_t size)
 {
     tm_thread *t = tm_get_thread();
     ++t->suppress_tracing;
     uint32_t start = PR_IntervalNow();
-    void* result = DHW_ORIGINAL(NEW_, getNewHooker())(size);
+    void* result = DHW_ORIGINAL(dhw_new, getNewHooker())(size);
     uint32_t end = PR_IntervalNow();
     --t->suppress_tracing;
     MallocCallback(result, size, start, end, t);//do we need a different one for new?
     return result;
 }
 
 // Note the mangled name!
-DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_delete, void, __cdecl, DELETE_, (void*));
+void __cdecl dhw_delete(void* p);
 DHWImportHooker &getDeleteHooker()
 {
   static DHWImportHooker gDeleteHooker(NS_DEBUG_CRT, "??3@YAXPAX@Z", (PROC) dhw_delete);
   return gDeleteHooker;
 }
 
 void __cdecl dhw_delete(void* p)
 {
     tm_thread *t = tm_get_thread();
     ++t->suppress_tracing;
     uint32_t start = PR_IntervalNow();
-    DHW_ORIGINAL(DELETE_, getDeleteHooker())(p);
+    DHW_ORIGINAL(dhw_delete, getDeleteHooker())(p);
     uint32_t end = PR_IntervalNow();
     --t->suppress_tracing;
     FreeCallback(p, start, end, t);
 }
 
 // Note the mangled name!
-DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_vec_new, void*, __cdecl, VEC_NEW_, (size_t));
+void * __cdecl dhw_vec_new(size_t size);
 DHWImportHooker &getVecNewHooker()
 {
   static DHWImportHooker gVecNewHooker(NS_DEBUG_CRT, "??_U@YAPAXI@Z", (PROC) dhw_vec_new);
   return gVecNewHooker;
 }
 
 void * __cdecl dhw_vec_new(size_t size)
 {
     tm_thread *t = tm_get_thread();
     ++t->suppress_tracing; // need to suppress since new[] calls new
     uint32_t start = PR_IntervalNow();
-    void* result = DHW_ORIGINAL(VEC_NEW_, getVecNewHooker())(size);
+    void* result = DHW_ORIGINAL(dhw_vec_new, getVecNewHooker())(size);
     uint32_t end = PR_IntervalNow();
     --t->suppress_tracing;
     MallocCallback(result, size, start, end, t);//do we need a different one for new[]?
     return result;
 }
 
 // Note the mangled name!
-DHW_DECLARE_FUN_TYPE_AND_PROTO(dhw_vec_delete, void, __cdecl, VEC_DELETE_, (void*));
+void __cdecl dhw_vec_delete(void* p);
 DHWImportHooker &getVecDeleteHooker()
 {
   static DHWImportHooker gVecDeleteHooker(NS_DEBUG_CRT, "??_V@YAXPAX@Z", (PROC) dhw_vec_delete);
   return gVecDeleteHooker;
 }
 
 void __cdecl dhw_vec_delete(void* p)
 {
     tm_thread *t = tm_get_thread();
     ++t->suppress_tracing;
     uint32_t start = PR_IntervalNow();
-    DHW_ORIGINAL(VEC_DELETE_, getVecDeleteHooker())(p);
+    DHW_ORIGINAL(dhw_vec_delete, getVecDeleteHooker())(p);
     uint32_t end = PR_IntervalNow();
     --t->suppress_tracing;
     FreeCallback(p, start, end, t);
 }
 
 /*C Callbacks*/
 PR_IMPLEMENT(void)
 StartupHooker()
@@ -225,28 +225,28 @@ extern "C" {
   void* dhw_orig_calloc(size_t, size_t);
   void* dhw_orig_realloc(void*, size_t);
   void dhw_orig_free(void*);
 }
 
 void*
 dhw_orig_malloc(size_t size)
 {
-    return DHW_ORIGINAL(MALLOC_, getMallocHooker())(size);
+    return DHW_ORIGINAL(malloc, getMallocHooker())(size);
 }
 
 void*
 dhw_orig_calloc(size_t count, size_t size)
 {
-    return DHW_ORIGINAL(CALLOC_, getCallocHooker())(count,size);
+    return DHW_ORIGINAL(calloc, getCallocHooker())(count,size);
 }
 
 void*
 dhw_orig_realloc(void* pin, size_t size)
 {
-    return DHW_ORIGINAL(REALLOC_, getReallocHooker())(pin, size);
+    return DHW_ORIGINAL(realloc, getReallocHooker())(pin, size);
 }
 
 void
 dhw_orig_free(void* p)
 {
-    DHW_ORIGINAL(FREE_, getFreeHooker())(p);
+    DHW_ORIGINAL(free, getFreeHooker())(p);
 }
--- a/widget/windows/WinIMEHandler.cpp
+++ b/widget/windows/WinIMEHandler.cpp
@@ -22,17 +22,17 @@ namespace widget {
 /******************************************************************************
  * IMEHandler
  ******************************************************************************/
 
 #ifdef NS_ENABLE_TSF
 bool IMEHandler::sIsInTSFMode = false;
 bool IMEHandler::sIsIMMEnabled = true;
 bool IMEHandler::sPluginHasFocus = false;
-IMEHandler::SetInputScopesFunc IMEHandler::sSetInputScopes = nullptr;
+decltype(SetInputScopes)* IMEHandler::sSetInputScopes = nullptr;
 #endif // #ifdef NS_ENABLE_TSF
 
 // static
 void
 IMEHandler::Initialize()
 {
 #ifdef NS_ENABLE_TSF
   nsTextStore::Initialize();
@@ -41,17 +41,17 @@ IMEHandler::Initialize()
     !sIsInTSFMode || Preferences::GetBool("intl.tsf.support_imm", true);
   if (!sIsInTSFMode) {
     // When full nsTextStore is not available, try to use SetInputScopes API
     // to enable at least InputScope. Use GET_MODULE_HANDLE_EX_FLAG_PIN to
     // ensure that msctf.dll will not be unloaded.
     HMODULE module = nullptr;
     if (GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN, L"msctf.dll",
                            &module)) {
-      sSetInputScopes = reinterpret_cast<SetInputScopesFunc>(
+      sSetInputScopes = reinterpret_cast<decltype(SetInputScopes)*>(
         GetProcAddress(module, "SetInputScopes"));
     }
   }
 #endif // #ifdef NS_ENABLE_TSF
 
   nsIMM32Handler::Initialize();
 }
 
--- a/widget/windows/WinIMEHandler.h
+++ b/widget/windows/WinIMEHandler.h
@@ -114,24 +114,17 @@ public:
   /**
    * Returns true when current keyboard layout has IME.  Otherwise, false.
    */
   static bool CurrentKeyboardLayoutHasIME();
 #endif // #ifdef DEBUG
 
 private:
 #ifdef NS_ENABLE_TSF
-  typedef HRESULT (WINAPI *SetInputScopesFunc)(HWND windowHandle,
-                                               const InputScope *inputScopes,
-                                               UINT numInputScopes,
-                                               wchar_t **phrase_list,
-                                               UINT numPhraseList,
-                                               wchar_t *regExp,
-                                               wchar_t *srgs);
-  static SetInputScopesFunc sSetInputScopes;
+  static decltype(SetInputScopes)* sSetInputScopes;
   static void SetInputScopeForIMM32(nsWindow* aWindow,
                                     const nsAString& aHTMLInputType);
   static bool sIsInTSFMode;
   // If sIMMEnabled is false, any IME messages are not handled in TSF mode.
   // Additionally, IME context is always disassociated from focused window.
   static bool sIsIMMEnabled;
   static bool sPluginHasFocus;