cmake_minimum_required (VERSION 2.8)
+include (CheckCXXCompilerFlag)
+
project (apitrace)
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if (WIN32)
# MSVC & MinGW only define & use APIENTRY
add_definitions (-DGLAPIENTRY=__stdcall)
+else (WIN32)
+ CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" CXX_COMPILER_FLAG_VISIBILITY)
+ if (CXX_COMPILER_FLAG_VISIBILITY)
+ add_definitions ("-fvisibility=hidden")
+ endif (CXX_COMPILER_FLAG_VISIBILITY)
endif (WIN32)
if (MSVC)
##########################################################################
#
+# Copyright 2011 Jose Fonseca
# Copyright 2008-2010 VMware, Inc.
# All Rights Reserved.
#
class GlxTracer(GlTracer):
+ def is_public_function(self, function):
+ # The symbols visible in libGL.so can vary, so expose them all
+ return True
+
def get_function_address(self, function):
return '__%s' % (function.name,)
* we need to intercept the dlopen() call here, and redirect to our wrapper
* shared object.
*/
-extern "C" void *
-dlopen(const char *filename, int flag)
+extern "C" PUBLIC
+void * dlopen(const char *filename, int flag)
{
void *handle;
void DebugMessage(const char *format, ...);
+#if defined _WIN32 || defined __CYGWIN__
+ /* We always use .def files on windows for now */
+ #if 0
+ #define PUBLIC __declspec(dllexport)
+ #else
+ #define PUBLIC
+ #endif
+ #define PRIVATE
+#else
+ #if __GNUC__ >= 4
+ #define PUBLIC __attribute__ ((visibility("default")))
+ #define PRIVATE __attribute__ ((visibility("hidden")))
+ #else
+ #define PUBLIC
+ #define PRIVATE
+ #endif
+#endif
+
/**
* Get the current time in microseconds from an unknown base.
*/
def get_dispatch_function(self, function):
return '__' + function.name
+ def is_public_function(self, function):
+ return True
+
def trace_function_impl(self, function):
- print 'extern "C" ' + function.prototype() + ' {'
+ if self.is_public_function(function):
+ print 'extern "C" PUBLIC'
+ else:
+ print 'extern "C" PRIVATE'
+ print function.prototype() + ' {'
if function.type is not stdapi.Void:
print ' %s __result;' % function.type
self.trace_function_impl_body(function)