Ticket #68716: patch-have_shared_mutex.diff
File patch-have_shared_mutex.diff, 2.0 KB (added by nilason (Nicklas Larsson), 12 months ago) |
---|
-
cmake/template/cpl_config.h.in
old new 175 175 /* Define to 1 if you have the `sched_getaffinity' function. */ 176 176 #cmakedefine HAVE_SCHED_GETAFFINITY 1 177 177 178 /* Define to 1 if you have the `std::shared_mutex' function. */ 179 #cmakedefine HAVE_SHARED_MUTEX 1 180 178 181 /* Define to 1 if you have the `uselocale' function. */ 179 182 #cmakedefine HAVE_USELOCALE 1 180 183 -
cmake/helpers/configure.cmake
old new 358 358 set(DONT_DEPRECATE_SPRINTF 1) 359 359 add_definitions(-DDONT_DEPRECATE_SPRINTF) 360 360 endif () 361 362 check_cxx_source_compiles( 363 " 364 #include <mutex> 365 #include <shared_mutex> 366 int main(int argc, const char * argv[]) { 367 std::shared_mutex smtx; 368 int product = 0; 369 auto writer = [&smtx, &product](int start, int end) 370 { 371 for (int i = start; i < end; ++i) 372 { 373 auto data = i; 374 { 375 std::unique_lock<std::shared_mutex> lock(smtx); 376 product = data; 377 } 378 } 379 smtx.lock(); 380 smtx.unlock(); 381 }; 382 auto reader = [&smtx, &product]() 383 { 384 int data = 0; 385 std::vector<int> seen; 386 do 387 { 388 { 389 smtx.lock_shared(); 390 data = product; 391 smtx.unlock_shared(); 392 } 393 } 394 while (1); 395 }; 396 return 0; 397 } 398 " 399 HAVE_SHARED_MUTEX 400 ) 361 401 362 402 check_include_file("linux/userfaultfd.h" HAVE_USERFAULTFD_H) 363 403 endif () -
port/cpl_vsi_mem.cpp
old new 50 50 51 51 #include <mutex> 52 52 // c++17 or VS2017 53 #if __cplusplus >= 201703L|| _MSC_VER >= 191053 #if defined(HAVE_SHARED_MUTEX) || _MSC_VER >= 1910 54 54 #include <shared_mutex> 55 55 #define CPL_SHARED_MUTEX_TYPE std::shared_mutex 56 56 #define CPL_SHARED_LOCK std::shared_lock<std::shared_mutex>