Remove mutex destructor in preparation for 2018 WPILib

Change-Id: I79472b15e0d89ada329d118fe8b4ccba270fda8e
diff --git a/aos/common/mutex.cc b/aos/common/mutex.cc
index eed5b0b..e8951c6 100644
--- a/aos/common/mutex.cc
+++ b/aos/common/mutex.cc
@@ -9,18 +9,6 @@
 
 namespace aos {
 
-Mutex::Mutex() : impl_() {
-  static_assert(shm_ok<Mutex>::value,
-                "Mutex is not safe for use in shared memory.");
-}
-
-Mutex::~Mutex() {
-  if (__builtin_expect(mutex_islocked(&impl_), false)) {
-    LOG(FATAL, "destroying locked mutex %p (aka %p)\n",
-        this, &impl_);
-  }
-}
-
 // Lock and Unlock use the return values of mutex_lock/mutex_unlock
 // to determine whether the lock/unlock succeeded.
 
diff --git a/aos/common/mutex.h b/aos/common/mutex.h
index cc180f5..3486c15 100644
--- a/aos/common/mutex.h
+++ b/aos/common/mutex.h
@@ -2,6 +2,7 @@
 #define AOS_COMMON_MUTEX_H_
 
 #include "aos/common/macros.h"
+#include "aos/common/type_traits.h"
 #include "aos/common/die.h"
 #include "aos/linux_code/ipc_lib/aos_sync.h"
 
@@ -31,12 +32,15 @@
   };
 
   // Creates an unlocked mutex.
-  Mutex();
+  Mutex() : impl_() {
+    static_assert(shm_ok<Mutex>::value,
+                  "Mutex is not safe for use in shared memory.");
+  }
   // Verifies that it isn't locked.
   //
   // This is important because freeing a locked mutex means there is freed
   // memory in the middle of the robust list, which breaks things horribly.
-  ~Mutex();
+  ~Mutex() = default;
 
   // Locks the mutex. If it fails, it calls LOG(FATAL).
   // Returns true if the previous owner died instead of unlocking nicely.
diff --git a/aos/common/mutex_test.cc b/aos/common/mutex_test.cc
index 3717109..18c616b 100644
--- a/aos/common/mutex_test.cc
+++ b/aos/common/mutex_test.cc
@@ -100,17 +100,6 @@
       ".*multiple lock.*");
 }
 
-// Tests that destroying a locked mutex fails nicely.
-TEST_F(MutexDeathTest, DestroyLocked) {
-  EXPECT_DEATH(
-      {
-        logging::AddImplementation(new util::DeathTestLogImplementation());
-        Mutex new_mutex;
-        ASSERT_FALSE(new_mutex.Lock());
-      },
-      ".*destroying locked mutex.*");
-}
-
 // Tests that Lock behaves correctly when the previous owner exits with the lock
 // held (which is the same as dying any other way).
 TEST_F(MutexTest, OwnerDiedDeathLock) {
diff --git a/aos/common/type_traits.h b/aos/common/type_traits.h
index 53fae23..229e574 100644
--- a/aos/common/type_traits.h
+++ b/aos/common/type_traits.h
@@ -6,8 +6,8 @@
 #include <type_traits>
 
 namespace aos {
+#if ((__GNUC__ < 5))
 namespace {
-
 template<typename Tp>
 struct has_trivial_copy_assign : public std::integral_constant<bool,
 // This changed between 4.4.5 and 4.6.3. Unless somebody discovers otherwise,
@@ -19,6 +19,7 @@
 #endif
 
 }  // namespace
+#endif
 
 // A class template that determines whether or not it is safe to pass a type
 // through the shared memory system (aka whether or not you can memcpy it).
@@ -28,10 +29,17 @@
 // copied. If it has a non-trivial destructor, somebody has to make sure to call
 // it when appropriate.
 // See also (3.9) [basic.types] in the C++11 standard.
-template<typename Tp>
-struct shm_ok : public std::integral_constant<bool,
-    (std::has_trivial_copy_constructor<Tp>::value &&
-     aos::has_trivial_copy_assign<Tp>::value)> {};
+template <typename Tp>
+struct shm_ok : public std::integral_constant<
+                    bool,
+#if ((__GNUC__ < 5))
+                    (::std::has_trivial_copy_constructor<Tp>::value &&
+                     ::aos::has_trivial_copy_assign<Tp>::value)
+#else
+                    (::std::is_trivially_copyable<Tp>::value)
+#endif
+                    > {
+};
 
 }  // namespace aos