From 6d8e1e87830eb24a1ecd6b0a115c39ed43914b5c Mon Sep 17 00:00:00 2001
From: Adam Ierymenko <adam.ierymenko@gmail.com>
Date: Fri, 26 Jan 2018 21:34:56 -0500
Subject: [PATCH] More cleanup of old stuff.

---
 controller/EmbeddedNetworkController.hpp |  1 -
 node/Mutex.hpp                           | 22 ++++++++----
 node/Network.hpp                         |  3 +-
 node/NonCopyable.hpp                     | 46 ------------------------
 node/Path.hpp                            |  3 +-
 node/Peer.hpp                            |  3 +-
 node/Switch.hpp                          |  3 +-
 osdep/Binder.hpp                         |  3 +-
 osdep/ManagedRoute.hpp                   |  6 ++--
 9 files changed, 24 insertions(+), 66 deletions(-)
 delete mode 100644 node/NonCopyable.hpp

diff --git a/controller/EmbeddedNetworkController.hpp b/controller/EmbeddedNetworkController.hpp
index e9b4764a8..1dda9f45f 100644
--- a/controller/EmbeddedNetworkController.hpp
+++ b/controller/EmbeddedNetworkController.hpp
@@ -35,7 +35,6 @@
 #include "../node/Utils.hpp"
 #include "../node/Address.hpp"
 #include "../node/InetAddress.hpp"
-#include "../node/NonCopyable.hpp"
 
 #include "../osdep/OSUtils.hpp"
 #include "../osdep/Thread.hpp"
diff --git a/node/Mutex.hpp b/node/Mutex.hpp
index cbd805245..a60a00b25 100644
--- a/node/Mutex.hpp
+++ b/node/Mutex.hpp
@@ -28,7 +28,6 @@
 #define ZT_MUTEX_HPP
 
 #include "Constants.hpp"
-#include "NonCopyable.hpp"
 
 #ifdef __UNIX_LIKE__
 
@@ -41,7 +40,7 @@ namespace ZeroTier {
 #if defined(__GNUC__) && (defined(__amd64) || defined(__amd64__) || defined(__x86_64) || defined(__x86_64__) || defined(__AMD64) || defined(__AMD64__) || defined(_M_X64))
 
 // Inline ticket lock on x64 systems with GCC and CLANG (Mac, Linux) -- this is really fast as long as locking durations are very short
-class Mutex : NonCopyable
+class Mutex
 {
 public:
 	Mutex() :
@@ -67,7 +66,7 @@ public:
 	/**
 	 * Uses C++ contexts and constructor/destructor to lock/unlock automatically
 	 */
-	class Lock : NonCopyable
+	class Lock
 	{
 	public:
 		Lock(Mutex &m) :
@@ -92,6 +91,9 @@ public:
 	};
 
 private:
+	Mutex(const Mutex &) {}
+	const Mutex &operator=(const Mutex &) { return *this; }
+
 	uint16_t nextTicket;
 	uint16_t nowServing;
 };
@@ -99,7 +101,7 @@ private:
 #else
 
 // libpthread based mutex lock
-class Mutex : NonCopyable
+class Mutex
 {
 public:
 	Mutex()
@@ -122,7 +124,7 @@ public:
 		pthread_mutex_unlock(&((const_cast <Mutex *> (this))->_mh));
 	}
 
-	class Lock : NonCopyable
+	class Lock
 	{
 	public:
 		Lock(Mutex &m) :
@@ -147,6 +149,9 @@ public:
 	};
 
 private:
+	Mutex(const Mutex &) {}
+	const Mutex &operator=(const Mutex &) { return *this; }
+
 	pthread_mutex_t _mh;
 };
 
@@ -164,7 +169,7 @@ private:
 namespace ZeroTier {
 
 // Windows critical section based lock
-class Mutex : NonCopyable
+class Mutex
 {
 public:
 	Mutex()
@@ -197,7 +202,7 @@ public:
 		(const_cast <Mutex *> (this))->unlock();
 	}
 
-	class Lock : NonCopyable
+	class Lock
 	{
 	public:
 		Lock(Mutex &m) :
@@ -222,6 +227,9 @@ public:
 	};
 
 private:
+	Mutex(const Mutex &) {}
+	const Mutex &operator=(const Mutex &) { return *this; }
+
 	CRITICAL_SECTION _cs;
 };
 
diff --git a/node/Network.hpp b/node/Network.hpp
index db2851080..95b5483aa 100644
--- a/node/Network.hpp
+++ b/node/Network.hpp
@@ -38,7 +38,6 @@
 #include <stdexcept>
 
 #include "Constants.hpp"
-#include "NonCopyable.hpp"
 #include "Hashtable.hpp"
 #include "Address.hpp"
 #include "Mutex.hpp"
@@ -63,7 +62,7 @@ class Peer;
 /**
  * A virtual LAN
  */
-class Network : NonCopyable
+class Network
 {
 	friend class SharedPtr<Network>;
 
diff --git a/node/NonCopyable.hpp b/node/NonCopyable.hpp
deleted file mode 100644
index 31107a503..000000000
--- a/node/NonCopyable.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ZeroTier One - Network Virtualization Everywhere
- * Copyright (C) 2011-2018  ZeroTier, Inc.  https://www.zerotier.com/
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- * --
- *
- * You can be released from the requirements of the license by purchasing
- * a commercial license. Buying such a license is mandatory as soon as you
- * develop commercial closed-source software that incorporates or links
- * directly against ZeroTier software without disclosing the source code
- * of your own application.
- */
-
-#ifndef ZT_NONCOPYABLE_HPP__
-#define ZT_NONCOPYABLE_HPP__
-
-namespace ZeroTier {
-
-/**
- * A simple concept that belongs in the C++ language spec
- */
-class NonCopyable
-{
-protected:
-	NonCopyable() {}
-private:
-	NonCopyable(const NonCopyable&);
-	const NonCopyable& operator=(const NonCopyable&);
-};
-
-} // namespace ZeroTier
-
-#endif
diff --git a/node/Path.hpp b/node/Path.hpp
index 62d750b7a..3d468ad9f 100644
--- a/node/Path.hpp
+++ b/node/Path.hpp
@@ -38,7 +38,6 @@
 #include "InetAddress.hpp"
 #include "SharedPtr.hpp"
 #include "AtomicCounter.hpp"
-#include "NonCopyable.hpp"
 #include "Utils.hpp"
 
 /**
@@ -53,7 +52,7 @@ class RuntimeEnvironment;
 /**
  * A path across the physical network
  */
-class Path : NonCopyable
+class Path
 {
 	friend class SharedPtr<Path>;
 
diff --git a/node/Peer.hpp b/node/Peer.hpp
index 99216bab2..b6f3c695a 100644
--- a/node/Peer.hpp
+++ b/node/Peer.hpp
@@ -49,7 +49,6 @@
 #include "AtomicCounter.hpp"
 #include "Hashtable.hpp"
 #include "Mutex.hpp"
-#include "NonCopyable.hpp"
 
 #define ZT_PEER_MAX_SERIALIZED_STATE_SIZE (sizeof(Peer) + 32 + (sizeof(Path) * 2))
 
@@ -58,7 +57,7 @@ namespace ZeroTier {
 /**
  * Peer on P2P Network (virtual layer 1)
  */
-class Peer : NonCopyable
+class Peer
 {
 	friend class SharedPtr<Peer>;
 
diff --git a/node/Switch.hpp b/node/Switch.hpp
index 082087357..906f418e6 100644
--- a/node/Switch.hpp
+++ b/node/Switch.hpp
@@ -35,7 +35,6 @@
 #include "Constants.hpp"
 #include "Mutex.hpp"
 #include "MAC.hpp"
-#include "NonCopyable.hpp"
 #include "Packet.hpp"
 #include "Utils.hpp"
 #include "InetAddress.hpp"
@@ -58,7 +57,7 @@ class Peer;
  * packets from tap devices, and this sends them where they need to go and
  * wraps/unwraps accordingly. It also handles queues and timeouts and such.
  */
-class Switch : NonCopyable
+class Switch
 {
 public:
 	Switch(const RuntimeEnvironment *renv);
diff --git a/osdep/Binder.hpp b/osdep/Binder.hpp
index d7c3f03c7..93fad9f13 100644
--- a/osdep/Binder.hpp
+++ b/osdep/Binder.hpp
@@ -60,7 +60,6 @@
 #include <set>
 #include <atomic>
 
-#include "../node/NonCopyable.hpp"
 #include "../node/InetAddress.hpp"
 #include "../node/Mutex.hpp"
 #include "../node/Utils.hpp"
@@ -87,7 +86,7 @@ namespace ZeroTier {
  * On OSes that do not support local port enumeration or where this is not
  * meaningful, this degrades to binding to wildcard.
  */
-class Binder : NonCopyable
+class Binder
 {
 private:
 	struct _Binding
diff --git a/osdep/ManagedRoute.hpp b/osdep/ManagedRoute.hpp
index 873d0cfbd..779ad6a1b 100644
--- a/osdep/ManagedRoute.hpp
+++ b/osdep/ManagedRoute.hpp
@@ -34,7 +34,6 @@
 #include "../node/Utils.hpp"
 #include "../node/SharedPtr.hpp"
 #include "../node/AtomicCounter.hpp"
-#include "../node/NonCopyable.hpp"
 
 #include <stdexcept>
 #include <vector>
@@ -45,7 +44,7 @@ namespace ZeroTier {
 /**
  * A ZT-managed route that used C++ RAII semantics to automatically clean itself up on deallocate
  */
-class ManagedRoute : NonCopyable
+class ManagedRoute
 {
 	friend class SharedPtr<ManagedRoute>;
 
@@ -91,6 +90,9 @@ public:
 	inline const char *device() const { return _device; }
 
 private:
+	ManagedRoute(const ManagedRoute &) {}
+	inline ManagedRoute &operator=(const ManagedRoute &) { return *this; }
+
 	InetAddress _target;
 	InetAddress _via;
 	InetAddress _systemVia; // for route overrides