Commit 0ab9f3be by Alexis Hetu Committed by Alexis Hétu

Fixed link time warnings on MacOS

MacOS' linker dislikes local static variables that are used in two separate libraries. Removing them from the header files fixes all the warnings. Bug b/chromium:907088 Change-Id: I7b8ed44bf9a3180489a7407980740fd3f3863046 Reviewed-on: https://swiftshader-review.googlesource.com/c/22889Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 072dc0db
// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
//
// Licensed 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "SharedLibrary.hpp"
#if defined(_WIN32)
std::string getModuleDirectory()
{
static int dummy_symbol = 0;
HMODULE module = NULL;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)&dummy_symbol, &module);
char filename[1024];
if(module && (GetModuleFileName(module, filename, sizeof(filename)) != 0))
{
std::string directory(filename);
return directory.substr(0, directory.find_last_of("\\/") + 1).c_str();
}
else
{
return "";
}
}
#else
std::string getModuleDirectory()
{
static int dummy_symbol = 0;
Dl_info dl_info;
if(dladdr(&dummy_symbol, &dl_info) != 0)
{
std::string directory(dl_info.dli_fname);
return directory.substr(0, directory.find_last_of("\\/") + 1).c_str();
}
else
{
return "";
}
}
#endif
......@@ -27,6 +27,7 @@ void *getLibraryHandle(const char *path);
void *loadLibrary(const char *path);
void freeLibrary(void *library);
void *getProcAddress(void *library, const char *name);
std::string getModuleDirectory();
template<int n>
void *loadLibrary(const std::string &libraryDirectory, const char *(&names)[n], const char *mustContainSymbol = nullptr)
......@@ -88,25 +89,6 @@ void *loadLibrary(const std::string &libraryDirectory, const char *(&names)[n],
{
return (void*)GetProcAddress((HMODULE)library, name);
}
inline std::string getModuleDirectory()
{
static int dummy_symbol = 0;
HMODULE module = NULL;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)&dummy_symbol, &module);
char filename[1024];
if(module && (GetModuleFileName(module, filename, sizeof(filename)) != 0))
{
std::string directory(filename);
return directory.substr(0, directory.find_last_of("\\/") + 1).c_str();
}
else
{
return "";
}
}
#else
inline void *loadLibrary(const char *path)
{
......@@ -150,22 +132,6 @@ void *loadLibrary(const std::string &libraryDirectory, const char *(&names)[n],
return symbol;
}
inline std::string getModuleDirectory()
{
static int dummy_symbol = 0;
Dl_info dl_info;
if(dladdr(&dummy_symbol, &dl_info) != 0)
{
std::string directory(dl_info.dli_fname);
return directory.substr(0, directory.find_last_of("\\/") + 1).c_str();
}
else
{
return "";
}
}
#endif
#endif // SharedLibrary_hpp
......@@ -31,7 +31,8 @@ COMMON_SRC_FILES := \
Display.cpp \
Surface.cpp \
libEGL.cpp \
main.cpp
main.cpp \
../../Common/SharedLibrary.cpp
COMMON_C_INCLUDES := \
bionic \
......
......@@ -52,6 +52,7 @@ swiftshader_shared_library("swiftshader_libEGL") {
}
sources = [
"../../Common/SharedLibrary.cpp",
"../common/debug.cpp",
"../common/Object.cpp",
"Config.cpp",
......
......@@ -326,6 +326,7 @@ copy "$(OutDir)libEGL.dll" "$(SolutionDir)out\$(Configuration)_$(Platform)\trans
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\Common\SharedLibrary.cpp" />
<ClCompile Include="..\common\Object.cpp" />
<ClCompile Include="Config.cpp" />
<ClCompile Include="..\Common\debug.cpp" />
......
......@@ -32,6 +32,9 @@
<ClCompile Include="Surface.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\Common\SharedLibrary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Config.h">
......
......@@ -44,7 +44,8 @@ COMMON_SRC_FILES := \
ResourceManager.cpp \
Texture.cpp \
utilities.cpp \
VertexDataManager.cpp
VertexDataManager.cpp \
../../Common/SharedLibrary.cpp
COMMON_C_INCLUDES := \
bionic \
......
......@@ -338,6 +338,7 @@ copy "$(OutDir)libGLES_CM.dll" "$(SolutionDir)out\$(Configuration)_$(Platform)\t
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\Common\SharedLibrary.cpp" />
<ClCompile Include="..\common\Image.cpp" />
<ClCompile Include="..\common\MatrixStack.cpp" />
<ClCompile Include="..\common\Object.cpp" />
......
......@@ -59,6 +59,9 @@
<ClCompile Include="..\common\Image.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\Common\SharedLibrary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Buffer.h">
......
......@@ -54,6 +54,7 @@ COMMON_SRC_FILES := \
utilities.cpp \
VertexArray.cpp \
VertexDataManager.cpp \
../../Common/SharedLibrary.cpp
COMMON_C_INCLUDES := \
bionic \
......
......@@ -68,6 +68,7 @@ swiftshader_static_library("swiftshader_libGLESv2_static") {
]
sources = [
"../../Common/SharedLibrary.cpp",
"Buffer.cpp",
"Context.cpp",
"Device.cpp",
......
......@@ -33,6 +33,13 @@
namespace es2
{
egl::Image*& ImageLevels::getNullImage()
{
static egl::Image* nullImage;
nullImage = nullptr;
return nullImage;
}
Texture::Texture(GLuint name) : egl::Texture(name)
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
......
......@@ -60,9 +60,7 @@ public:
return image[index];
}
static egl::Image* nullImage;
nullImage = nullptr;
return nullImage;
return getNullImage();
}
inline void release()
......@@ -91,6 +89,7 @@ public:
private:
egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS] = {};
static egl::Image*& getNullImage();
};
class Texture : public egl::Texture
......
......@@ -350,6 +350,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)out\$(Configuration)_$(Platform)\tr
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\Common\SharedLibrary.cpp" />
<ClCompile Include="..\common\Image.cpp" />
<ClCompile Include="..\common\Object.cpp" />
<ClCompile Include="Buffer.cpp" />
......
......@@ -80,6 +80,9 @@
<ClCompile Include="entry_points.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\Common\SharedLibrary.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Buffer.h">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment