summaryrefslogtreecommitdiffstats
path: root/net/i2pd/gcc46.patch
blob: fbe907db94a75dc01a6dcd2d3530c7c70e3bbd10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
--- Makefile.linux.orig	2016-10-17 00:37:40.000000000 -0400
+++ Makefile.linux	2016-10-19 19:43:21.061181283 -0400
@@ -18,7 +18,7 @@
 else ifeq ($(shell expr match ${CXXVER} "4\.[7-9]"),3) # >= 4.7
 	NEEDED_CXXFLAGS += -std=c++11 -D_GLIBCXX_USE_NANOSLEEP=1
 else ifeq ($(shell expr match ${CXXVER} "4\.6"),3) # = 4.6
-	NEEDED_CXXFLAGS += -std=c++0x
+	NEEDED_CXXFLAGS += -std=c++0x -D_GLIBCXX_USE_NANOSLEEP=1
 else ifeq ($(shell expr match ${CXXVER} "[5-6]\.[0-9]"),3) # gcc >= 5.0
 	NEEDED_CXXFLAGS += -std=c++11
 else # not supported
--- Tunnel.cpp.orig	2016-10-17 00:37:40.000000000 -0400
+++ Tunnel.cpp	2016-10-19 19:56:06.096526898 -0400
@@ -406,7 +406,7 @@
 	
 	void Tunnels::AddTransitTunnel (std::shared_ptr<TransitTunnel> tunnel)
 	{
-		if (m_Tunnels.emplace (tunnel->GetTunnelID (), tunnel).second)
+		if (m_Tunnels.insert (make_pair(tunnel->GetTunnelID (), tunnel)).second)
 			m_TransitTunnels.push_back (tunnel);
 		else
 			LogPrint (eLogError, "Tunnel: tunnel with id ", tunnel->GetTunnelID (), " already exists");
@@ -808,7 +808,7 @@
 
 	void Tunnels::AddInboundTunnel (std::shared_ptr<InboundTunnel> newTunnel)
 	{
-		if (m_Tunnels.emplace (newTunnel->GetTunnelID (), newTunnel).second)
+		if (m_Tunnels.insert (make_pair(newTunnel->GetTunnelID (), newTunnel)).second)
 		{
 			m_InboundTunnels.push_back (newTunnel);
 			auto pool = newTunnel->GetTunnelPool ();
--- TunnelPool.h.orig
+++ TunnelPool.h
@@ -106,8 +106,8 @@ namespace tunnel
 			std::mutex m_CustomPeerSelectorMutex;
 			TunnelPeerSelector m_CustomPeerSelector;
 
-		uint64_t m_MinLatency=0; // if > 0 this tunnel pool will try building tunnels with minimum latency by ms
-		uint64_t m_MaxLatency=0; // if > 0 this tunnel pool will try building tunnels with maximum latency by ms
+		uint64_t m_MinLatency; // if > 0 this tunnel pool will try building tunnels with minimum latency by ms
+		uint64_t m_MaxLatency; // if > 0 this tunnel pool will try building tunnels with maximum latency by ms
 		
 		public:
 
--- TunnelPool.cpp.orig
+++ TunnelPool.cpp
@@ -14,6 +14,12 @@
 #include "Event.h"
 #endif
 
+template<typename T> struct decltype_t {
+	typedef T type;
+};
+
+#define DECLTYPE(expr) decltype_t<decltype(expr)>::type
+
 namespace i2p
 {
 namespace tunnel
@@ -22,7 +28,7 @@ namespace tunnel
 	TunnelPool::TunnelPool (int numInboundHops, int numOutboundHops, int numInboundTunnels, int numOutboundTunnels):
 		m_NumInboundHops (numInboundHops), m_NumOutboundHops (numOutboundHops),
 		m_NumInboundTunnels (numInboundTunnels), m_NumOutboundTunnels (numOutboundTunnels), m_IsActive (true),
-		m_CustomPeerSelector(nullptr)
+		m_CustomPeerSelector(nullptr), m_MinLatency(0), m_MaxLatency(0)
 	{
 	}
 
@@ -322,7 +328,7 @@ namespace tunnel
 		buf += 4;	
 		uint64_t timestamp = bufbe64toh (buf);
 
-		decltype(m_Tests)::mapped_type test;
+		DECLTYPE(m_Tests)::mapped_type test;
 		bool found = false;	
 		{
 			std::unique_lock<std::mutex> l(m_TestsMutex);
--- Event.h.orig	2017-02-16 13:28:19.692773653 -0500
+++ Event.h	2017-02-16 13:30:19.903805378 -0500
@@ -25,6 +25,7 @@
 		class EventCore
 		{
 		public:
+			EventCore(): m_listener(nullptr) {}
 			void QueueEvent(const EventType & ev);
       void CollectEvent(const std::string & type, const std::string & ident, uint64_t val);
 			void SetListener(EventListener * l);
@@ -39,7 +40,7 @@
         uint64_t Val;
       };
       std::map<std::string, CollectedEvent> m_collected;
-			EventListener * m_listener = nullptr;
+			EventListener * m_listener;
 		};
 #ifdef WITH_EVENTS		
 		extern EventCore core;
 		extern EventCore core;
--- Log.cpp.orig
+++ Log.cpp
@@ -30,11 +30,11 @@
 	static const char *LogMsgColors[] = { "", "", "", "", "" };
 #else /* UNIX */
 	static const char *LogMsgColors[] = {
-		[eLogError]     = "\033[1;31m", /* red */
-		[eLogWarning]   = "\033[1;33m", /* yellow */
-		[eLogInfo]      = "\033[1;36m", /* cyan */
-		[eLogDebug]     = "\033[1;34m", /* blue */
-		[eNumLogLevels] = "\033[0m",    /* reset */
+		"\033[1;31m", /* red */
+		"\033[1;33m", /* yellow */
+		"\033[1;36m", /* cyan */
+		"\033[1;34m", /* blue */
+		"\033[0m",    /* reset */
 	};
 #endif
 
--- NTCPSession.cpp.orig
+++ NTCPSession.cpp
@@ -167,7 +167,13 @@ namespace transport
 					return;
 				}	
 			}	
-
+#if (__GNUC__ == 4) && (__GNUC_MINOR__ <= 7)
+// due the bug in gcc 4.7. std::shared_future.get() is not const
+			if (!m_DHKeysPair)
+				m_DHKeysPair = transports.GetNextDHKeysPair ();
+			CreateAESKey (m_Establisher->phase1.pubKey);
+			SendPhase2 ();
+#else
 			// TODO: check for number of pending keys
 			auto s = shared_from_this ();
 			auto keyCreated = std::async (std::launch::async, [s] ()
@@ -180,7 +186,8 @@ namespace transport
 				{  
 					keyCreated.get (); 
 					s->SendPhase2 ();
-				});	
+				});
+#endif	
 		}	
 	}	
 
@@ -239,6 +246,11 @@ namespace transport
 		}
 		else
 		{	
+#if (__GNUC__ == 4) && (__GNUC_MINOR__ <= 7)
+// due the bug in gcc 4.7. std::shared_future.get() is not const
+			CreateAESKey (m_Establisher->phase2.pubKey);
+			HandlePhase2 ();
+#else
 			auto s = shared_from_this ();
 			// create AES key in separate thread
 			auto keyCreated = std::async (std::launch::async, [s] ()
@@ -251,6 +263,7 @@ namespace transport
 					keyCreated.get (); // we might wait if no more pending operations
 					s->HandlePhase2 ();
 				});	
+#endif
 		}	
 	}