From 2bc1930c6c40b964fce9c698a1ca75da3138ad63 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 30 Sep 2009 03:22:57 +0200 Subject: Windows improvements : manual backport of htttp://lists.mysql.com/commits/50957?f=plain Always use TLS functions instead of __declspec(thread) to access thread local storage variables. The change removes the necessity to recomplile the same source files twice - with USE_TLS for DLLs and without USE_TLS for EXEs. Real benefit of this change is better readability and maintainability of TLS functions within MySQL. There is a performance loss using TlsXXX functions compared to __declspec but the difference is negligible in practice. In a sysbench-like benchmark I ran with with TlsGetValue, pthread_[get|set]_specific was called 600000000 times and took 0.17sec of total 35min CPU time, or 0.008%. --- libmysql/CMakeLists.txt | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'libmysql') diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index b252d94b50e..06c17c80bfe 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -100,29 +100,13 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/mf_qsort.c ../mysys/my_getsystime.c ../mysys/my_sync.c ../mysys/my_winerr.c ../mysys/my_winfile.c ${LIB_SOURCES}) -# Need to set USE_TLS for building the DLL, since __declspec(thread) -# approach to thread local storage does not work properly in DLLs. -# -# The static library might be used to form another DLL, as is the case -# with the ODBC driver, so it has to be compiled with USE_TLS as well. -# -# We create a third library without USE_TLS for internal use. We can't -# be sure that some client application part of this build doesn't go -# beond the documented API, and try access the Thread Local Storage. -# The "_notls" means no Tls*() functions used, i.e. "static" TLS. + ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES}) ADD_DEPENDENCIES(mysqlclient GenError) TARGET_LINK_LIBRARIES(mysqlclient) -ADD_LIBRARY(mysqlclient_notls STATIC ${CLIENT_SOURCES}) -ADD_DEPENDENCIES(mysqlclient_notls GenError) -TARGET_LINK_LIBRARIES(mysqlclient_notls) - ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def) -IF(WIN32) - SET_TARGET_PROPERTIES(libmysql mysqlclient PROPERTIES COMPILE_FLAGS "-DUSE_TLS") -ENDIF(WIN32) ADD_DEPENDENCIES(libmysql GenError) TARGET_LINK_LIBRARIES(libmysql wsock32) -- cgit v1.2.1