[Groonga-commit] groonga/groonga at 3ff250d [master] cmake windows: enable USE_EXACT_ALLOC_COUNT (#924)

Back to archive index
Kentaro Hayashi null+****@clear*****
Fri Apr 5 14:38:21 JST 2019


Kentaro Hayashi	2019-04-05 14:38:21 +0900 (Fri, 05 Apr 2019)

  Revision: 3ff250da176b358fe70958273933b60d9a89123b
  https://github.com/groonga/groonga/commit/3ff250da176b358fe70958273933b60d9a89123b

  Message:
    cmake windows: enable USE_EXACT_ALLOC_COUNT (#924)
    
    * cmake windows: enable USE_EXACT_ALLOC_COUNT
    
    Without it, atomic operation is not enabled.
    So, grn_fin(N) reports unexpected leaks.
    
    * cmake windows: use builtin _InterlockedExchangeAdd for atomic operation
    
    Without this commit, grn_fin(N) still reports leaks.
    
    To enable InterlockedExchangeAdd as intrinsics #pragma intrinsic
    (FUNCTION) must be specified explicitly.
    
    See: https://docs.microsoft.com/en-us/cpp/intrinsics/interlockedexchangeadd-intrinsic-functions?view=vs-2017
    
    * cmake windows: follow set(... TRUE) style
    
    * cmake windows: remove needless space

  Modified files:
    CMakeLists.txt
    lib/grn.h

  Modified: CMakeLists.txt (+1 -0)
===================================================================
--- CMakeLists.txt    2019-04-05 13:01:17 +0900 (a2fef62ef)
+++ CMakeLists.txt    2019-04-05 14:38:21 +0900 (639f531b7)
@@ -334,6 +334,7 @@ if(WIN32)
 
   SET(PSAPI_LIBS "psapi.lib")
 
+  set(USE_EXACT_ALLOC_COUNT TRUE)
   set(USE_SELECT TRUE)
 else()
   ac_check_headers(sys/epoll.h)

  Modified: lib/grn.h (+2 -1)
===================================================================
--- lib/grn.h    2019-04-05 13:01:17 +0900 (81282cef1)
+++ lib/grn.h    2019-04-05 14:38:21 +0900 (abf8167b3)
@@ -135,6 +135,7 @@ typedef SOCKET grn_sock;
 
 # ifndef __GNUC__
 #  include <intrin.h>
+#  pragma intrinsic(_InterlockedExchangeAdd)
 #  include <sys/timeb.h>
 #  include <errno.h>
 # endif
@@ -466,7 +467,7 @@ typedef int grn_cond;
 #elif (defined(WIN32) || defined (_WIN64)) /* __GNUC__ */
 
 # define GRN_ATOMIC_ADD_EX(p,i,r) \
-  ((r) = InterlockedExchangeAdd((p), (i)))
+  ((r) = _InterlockedExchangeAdd((p), (i)))
 # if defined(_WIN64) /* ATOMIC 64BIT SET */
 #  define GRN_SET_64BIT(p,v) \
   (*(p) = (v))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190405/210c4b46/attachment.html>


More information about the Groonga-commit mailing list
Back to archive index