1 Index: cppuhelper/source/shlib.cxx
2 ===================================================================
3 RCS file: /cvs/udk/cppuhelper/source/shlib.cxx,v
4 retrieving revision 1.30
5 diff -u -r1.30 shlib.cxx
6 --- cppuhelper/source/shlib.cxx 11 Apr 2008 11:37:03 -0000 1.30
7 +++ cppuhelper/source/shlib.cxx 27 Aug 2008 09:01:16 -0000
9 #include "uno/mapping.hxx"
10 #include "cppuhelper/factory.hxx"
11 #include "cppuhelper/shlib.hxx"
12 +#include "cppuhelper/bootstrap.hxx"
13 +#include <com/sun/star/lang/IllegalArgumentException.hpp>
15 #include "com/sun/star/beans/XPropertySet.hpp"
23 +// This is a temporary hack until we can add this per
24 +// shlib annotation to services.rdb.
27 +lcl_isWellKnownInternal(const OString &rLibName)
29 + // These are loaded at startup ...
30 + static const char *pLookup[] = {
32 + "configmgr2.uno.so",
33 + "deploymentli.uno.so",
37 + "introspection.uno.so",
42 + "libfilterconfig1.so",
44 + "liblocaledata_en.so",
45 + "liblocaledata_es.so",
46 + "liblocaledata_euro.so",
47 + "liblocaledata_others.so",
57 + "regtypeprov.uno.so",
59 + "servicemgr.uno.so",
60 + "shlibloader.uno.so",
63 + "reflection.uno.so",
65 + "stocservices.uno.so",
68 + "typeconverter.uno.so",
74 + // Perhaps do some cunning binary search ?
75 + for (int i = 0; pLookup[i] != NULL; i++) {
76 + bool match = rLibName.indexOf (pLookup[i]) > 0;
77 +// fprintf (stderr, "Match '%s' vs. '%s' : %d\n",
78 +// (const sal_Char *)rLibName, pLookup[i], match);
87 +OUString const & get_this_libpath();
89 +// Amusing hack to get 40% win on linking / startup speedup:
90 +// Rational: we load all of OO.o's exception symbols in a single, global
91 +// shlib once first of all (RTLD_GLOBAL). This allows us to load all
92 +// subsequent components RTLD_LOCAL, their vague linkage symbols will
93 +// resolve in the global scope.
95 +lcl_isInternalLibrary(OUString const & rLibName, OUString const & rPath)
97 + if (getenv ("OOO_DISABLE_INTERNAL"))
100 +// fprintf (stderr, "Lib path '%s' ",
101 +// (const sal_Char *)rtl::OUStringToOString(rPath, RTL_TEXTENCODING_ASCII_US));
102 +// fprintf (stderr, "name '%s' - test:\n",
103 +// (const sal_Char *)rtl::OUStringToOString(rLibName, RTL_TEXTENCODING_ASCII_US));
105 + bool bIsInternal = false;
107 + // Is this an internal library ?
108 + if (rPath.getLength() > 0 && rPath != get_this_libpath())
110 +// fprintf (stderr, "Lib path '%s' - not internal!\n",
111 +// (const sal_Char *)rtl::OUStringToOString(rPath, RTL_TEXTENCODING_ASCII_US));
115 + sal_Int32 nUpd = SUPD;
116 + OUString aIntSuffix = OUSTR("li.so");
117 + if (rLibName.indexOf (aIntSuffix) > 0)
118 + bIsInternal = true;
121 + bIsInternal = lcl_isWellKnownInternal(
122 + OUStringToOString(rLibName, RTL_TEXTENCODING_UTF8));
124 + // If internal - load the exception type library RTLD_GLOBAL first
125 + static bool bHaveLoadedExcepts = false;
126 + if (bIsInternal && !bHaveLoadedExcepts)
128 + rtl::OUString aExceptTmpl = rtl::OUString::createFromAscii("vnd.sun.star.expand:$OOO_BASE_DIR/program/libexlink") + aIntSuffix;
129 + rtl::OUString aExceptName;
132 + aExceptName = cppu::bootstrap_expandUri( aExceptTmpl );
134 + catch ( ::com::sun::star::lang::IllegalArgumentException & e ) {}
135 + oslModule nExceptLib = osl_loadModule(aExceptName.pData,
136 + SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
137 + if (nExceptLib != NULL) {
138 + bHaveLoadedExcepts = true;
139 +// fprintf (stderr, "Loaded'%s'\n",
140 +// (const sal_Char *)rtl::OUStringToOString(aExceptName, RTL_TEXTENCODING_ASCII_US));
142 + bIsInternal = false;
143 +// fprintf (stderr, "Failed to load'%s'\n",
144 +// (const sal_Char *)rtl::OUStringToOString(aExceptName, RTL_TEXTENCODING_ASCII_US));
148 +// fprintf (stderr, "Lib name '%s' %d %d\n",
149 +// (const sal_Char *)rtl::OUStringToOString(rLibName, RTL_TEXTENCODING_ASCII_US),
150 +// bIsInternal, bHaveLoadedExcepts);
152 + return bIsInternal;
156 //==============================================================================
157 static OUString getLibEnv(OUString const & aModulePath,
161 Reference< XInterface >() );
164 + sal_Int32 nFlags = SAL_LOADMODULE_LAZY;
166 + if (!lcl_isInternalLibrary (rLibName, rPath))
167 + nFlags |= SAL_LOADMODULE_GLOBAL;
168 +// else - faster local only binding
170 + nFlags |= SAL_LOADMODULE_GLOBAL;
173 - oslModule lib = osl_loadModule(
174 - aModulePath.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
175 + oslModule lib = osl_loadModule(aModulePath.pData, nFlags);
178 throw loader::CannotActivateFactoryException(