From 2e7dee07874b6637510855b554c0ab2f001bce1a Mon Sep 17 00:00:00 2001
From: David Capello <davidcapello@gmail.com>
Date: Mon, 13 Mar 2017 18:35:29 -0300
Subject: [PATCH] Add support for multithread harfbuzz with gcc

---
 third_party/harfbuzz-cmake/CMakeLists.txt | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/third_party/harfbuzz-cmake/CMakeLists.txt b/third_party/harfbuzz-cmake/CMakeLists.txt
index a16a5522b..13d6cd5bb 100644
--- a/third_party/harfbuzz-cmake/CMakeLists.txt
+++ b/third_party/harfbuzz-cmake/CMakeLists.txt
@@ -19,6 +19,20 @@ if(USE_ICU)
     ../harfbuzz/src/hb-icu.cc)
 endif()
 
+if(UNIX AND NOT APPLE)
+  include(CheckCSourceCompiles)
+  check_cxx_source_compiles("
+     void memory_barrier (void) { __sync_synchronize (); }
+     int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
+     int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
+     void mutex_unlock (int *m) { __sync_lock_release (m); }
+     int main() { ; return 0; }"
+    HAVE_INTEL_ATOMIC_PRIMITIVES)
+  if(HAVE_INTEL_ATOMIC_PRIMITIVES)
+    add_definitions(-DHAVE_INTEL_ATOMIC_PRIMITIVES)
+  endif()
+endif()
+
 add_library(harfbuzz
   ../harfbuzz/src/hb-blob.cc
   ../harfbuzz/src/hb-buffer-serialize.cc