# Optimisations for Linux

GCC: Don't export symbols from DSOs by default - see
http://gcc.gnu.org/wiki/Visibility

This was SVN commit r4812.
This commit is contained in:
Ykkrosh 2007-01-26 18:26:45 +00:00
parent 5e7baf3a43
commit 3573c4a4e3
12 changed files with 46 additions and 11 deletions

View File

@ -109,6 +109,14 @@ function package_set_build_flags()
"-ffast-math",
})
end
tinsert(package.buildoptions, {
-- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with
-- Windows - they should be exported explicitly with __attribute__ ((visibility ("default")))
"-fvisibility=hidden",
"-fvisibility-inlines-hidden",
})
package.includepaths = {
"/usr/X11R6/include/X11",
"/usr/include/X11",

View File

@ -14,7 +14,7 @@ void default_logger(int severity, const char* message)
static LogFn g_Logger = &default_logger;
void set_logger(LogFn logger)
EXPORT void set_logger(LogFn logger)
{
if (logger)
g_Logger = logger;
@ -108,12 +108,12 @@ int convert_dae_to_whatever(const char* dae, OutputFn writer, void* cb_data, voi
return 0;
}
int convert_dae_to_pmd(const char* dae, OutputFn pmd_writer, void* cb_data)
EXPORT int convert_dae_to_pmd(const char* dae, OutputFn pmd_writer, void* cb_data)
{
return convert_dae_to_whatever(dae, pmd_writer, cb_data, ColladaToPMD);
}
int convert_dae_to_psa(const char* dae, OutputFn psa_writer, void* cb_data)
EXPORT int convert_dae_to_psa(const char* dae, OutputFn psa_writer, void* cb_data)
{
return convert_dae_to_whatever(dae, psa_writer, cb_data, ColladaToPSA);
}

View File

@ -8,12 +8,16 @@ extern "C"
#ifdef _WIN32
# ifdef COLLADA_DLL
# define EXPORT extern __declspec(dllexport)
# define EXPORT extern "C" __declspec(dllexport)
# else
# define EXPORT extern __declspec(dllimport)
# define EXPORT extern "C" __declspec(dllimport)
# endif
#else
# define EXPORT extern
# if __GNUC__ >= 4
# define EXPORT extern "C" __attribute__ ((visibility ("default")))
# else
# define EXPORT extern "C"
# endif
#endif
#define LOG_INFO 0

View File

@ -78,7 +78,7 @@ struct InserterWithoutDuplicates
size_t add(const T& val)
{
std::map<T, size_t>::iterator it = btree.find(val);
typename std::map<T, size_t>::iterator it = btree.find(val);
if (it != btree.end())
return it->second;

View File

@ -21,7 +21,7 @@
#include <cassert>
#include <vector>
const int maxInfluences = 4;
const size_t maxInfluences = 4;
struct VertexBlend
{
uint8 bones[maxInfluences];

View File

@ -73,7 +73,8 @@ public:
FCDSkinController* skin = controller->GetSkinController();
// Find the first and last times which have animations
float timeStart = FLT_MAX, timeEnd = -FLT_MAX;
float timeStart = std::numeric_limits<float>::max();
float timeEnd = -std::numeric_limits<float>::max();
for (size_t i = 0; i < skin->GetJointCount(); ++i)
{
FCDJointMatrixPair* joint = skin->GetJoint(i);

View File

@ -12,7 +12,9 @@ extern void Log(int severity, const char* fmt, ...);
#include "FCollada.h"
#include "FCDocument/FCDocument.h"
#include "FCDocument/FCDAnimated.h"
#include "FCDocument/FCDAnimatedCurve.h"
#include "FCDocument/FCDController.h"
#include "FCDocument/FCDControllerInstance.h"
#include "FCDocument/FCDGeometry.h"
#include "FCDocument/FCDGeometryMesh.h"
#include "FCDocument/FCDGeometryPolygons.h"

View File

@ -89,6 +89,7 @@ public:
catch (PSERROR_DllLoader&)
{
LOG(ERROR, LOG_CATEGORY, "Failed to load symbols from COLLADA conversion DLL");
dll.Unload();
return CModelDefPtr();
}

View File

@ -151,7 +151,7 @@ public:
CModelDefPtr modeldef1 = meshManager->GetMesh(testPMD);
CModelDefPtr modeldef2 = meshManager->GetMesh(testPMD);
TS_ASSERT(modeldef1 && modeldef2);
TS_ASSERT_EQUALS(modeldef1.get(), modeldef2.get());
if (modeldef1 && modeldef2) TS_ASSERT_EQUALS(modeldef1.get(), modeldef2.get());
}
void test_load_dae()

View File

@ -72,6 +72,15 @@ bool DllLoader::LoadDLL()
return (m_Handle != HANDLE_UNAVAILABLE);
}
void DllLoader::Unload()
{
if (! IsLoaded())
return;
dlclose(m_Handle);
m_Handle = 0;
}
void DllLoader::LoadSymbolInternal(const char* name, void** fptr) const
{
if (! IsLoaded())

View File

@ -33,6 +33,12 @@ public:
* LoadDLL did.
*/
bool IsLoaded() const;
/**
* Unload the library, if it has been loaded already. (Usually not needed,
* since the destructor will unload it.)
*/
void Unload();
/**
* Attempt to load a named symbol from the library. If {@link #IsLoaded} is

View File

@ -70,7 +70,11 @@
#ifdef _WIN32
# define ATLASDLLIMPEXP extern "C" __declspec(dllexport)
#else
# define ATLASDLLIMPEXP extern "C"
# if __GNUC__ >= 4
# define ATLASDLLIMPEXP extern "C" __attribute__ ((visibility ("default")))
# else
# define ATLASDLLIMPEXP extern "C"
# endif
#endif
// Abort with an obvious message if wx isn't Unicode, instead of complaining