summaryrefslogtreecommitdiff
path: root/bridges/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-12-18 10:30:41 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-12-18 13:02:20 +0100
commit60274d430881ffe8681a2920b4df589d16942ace (patch)
treeb5cb0d314bc3a9cd46dafe8f4313a7426ccff638 /bridges/source
parentfb1eac64df88baae9f211d052793773686c0e180 (diff)
Elide use of rtl_Instance (which is obsoleted by C++11 thread-safe statics),
...redux, after 8473ac2e27efff3ec902a358896a669ce05f047a "Elide use of rtl_Instance (which is obsoleted by C++11 thread-safe statics)" had done the same in parallel but forgot to remove some now-unnecessary parts: There appears to be no good reason to control the lifecycle of the VtableFactory instance via dso_init/exit, instead of via a plain static local variable. This removes the need for the Windows DllMain functions. They also called DisableThreadLibraryCalls, which disables the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications for the respective DllMain. Lets assume that this was only done (as an optimization) because there had to be a user-provided DllMain, and that it was not in itself a reason to have a user-provided DllMain. (Most other DllMain across the code base that call DisableThreadLibraryCalls also do something else. The only DllMain that only calls DisableThreadLibraryCalls is the one in shell/source/win32/shlxthandler/ooofilt/ooofilt.cxx, introduced with 3fbfb21e298ba506c50733d4aaefc7550bca2fe4 "INTEGRATION: CWS desktintgr02".) Change-Id: I696e1c8d49060853c1a2c24f67469f6adfea6801 Reviewed-on: https://gerrit.libreoffice.org/85367 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'bridges/source')
-rw-r--r--bridges/source/cpp_uno/msvc_win32_intel/dllinit.cxx49
-rw-r--r--bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx44
-rw-r--r--bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx24
3 files changed, 2 insertions, 115 deletions
diff --git a/bridges/source/cpp_uno/msvc_win32_intel/dllinit.cxx b/bridges/source/cpp_uno/msvc_win32_intel/dllinit.cxx
deleted file mode 100644
index f65ef74ba4e5..000000000000
--- a/bridges/source/cpp_uno/msvc_win32_intel/dllinit.cxx
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#if !defined WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-
-
-void dso_init();
-void dso_exit();
-
-
-extern "C" BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
-{
- switch(dwReason) {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hModule);
-
- dso_init();
- break;
-
- case DLL_PROCESS_DETACH:
- if (!lpvReserved)
- dso_exit();
- break;
- }
-
- return TRUE;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx b/bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx
deleted file mode 100644
index 8517f0c72674..000000000000
--- a/bridges/source/cpp_uno/msvc_win32_x86-64/dllinit.cxx
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-#include <cppinterfaceproxy.hxx>
-
-extern "C" BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpvReserved)
-{
- switch(dwReason) {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hModule);
-
- dso_init();
- break;
-
- case DLL_PROCESS_DETACH:
- if (!lpvReserved)
- dso_exit();
- break;
- }
-
- return TRUE;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx b/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx
index 466d83ef46a4..29b035fec3ab 100644
--- a/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx
+++ b/bridges/source/cpp_uno/shared/cppinterfaceproxy.cxx
@@ -29,27 +29,6 @@
#include <memory>
#include <new>
-
-static bridges::cpp_uno::shared::VtableFactory * pInstance;
-
-#if defined(__GNUG__)
-extern "C" void dso_init() __attribute__((constructor));
-extern "C" void dso_exit() __attribute__((destructor));
-#endif
-
-void dso_init() {
- if (!pInstance)
- pInstance = new bridges::cpp_uno::shared::VtableFactory();
-}
-
-void dso_exit() {
- if (pInstance)
- {
- delete pInstance;
- pInstance = nullptr;
- }
-}
-
namespace bridges { namespace cpp_uno { namespace shared {
void freeCppInterfaceProxy(uno_ExtEnvironment * pEnv, void * pInterface)
@@ -80,8 +59,9 @@ com::sun::star::uno::XInterface * CppInterfaceProxy::create(
{
typelib_typedescription_complete(
reinterpret_cast< typelib_TypeDescription ** >(&pTypeDescr));
+ static bridges::cpp_uno::shared::VtableFactory factory;
const bridges::cpp_uno::shared::VtableFactory::Vtables& rVtables(
- pInstance->getVtables(pTypeDescr));
+ factory.getVtables(pTypeDescr));
std::unique_ptr< char[] > pMemory(
new char[
sizeof (CppInterfaceProxy)