From 3f86b77068cf0a7e6382d266ef6f22dfdffe7744 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Fri, 6 Nov 2015 20:47:52 +0000 Subject: [PATCH] Add the rest of current Windows-related third-party patches --- CMakeLists.txt | 7 +++++-- third-party/event2-01-win32.patch | 14 ++++++++++++++ third-party/utp-02-win32.patch | 31 +++++++++++++++++++++++++++++++ third-party/utp-03-msvc14.patch | 30 ++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 third-party/event2-01-win32.patch create mode 100644 third-party/utp-02-win32.patch create mode 100644 third-party/utp-03-msvc14.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index e402524b1..a827a5dd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,7 +247,8 @@ set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third-party) if(WIN32) tr_add_external_auto_library(EVENT2 event - PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${THIRD_PARTY_DIR}/event2.cmake" "/CMakeLists.txt") + PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${THIRD_PARTY_DIR}/event2.cmake" "/CMakeLists.txt" + COMMAND "${CMAKE_COMMAND}" -E chdir "" patch -p1 -i "${THIRD_PARTY_DIR}/event2-01-win32.patch") else() tr_add_external_auto_library(EVENT2 event BUILD_IN_SOURCE 1 @@ -287,7 +288,9 @@ if(ENABLE_UTP) tr_add_external_auto_library(UTP utp PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${THIRD_PARTY_DIR}/utp.cmake" "/CMakeLists.txt" COMMAND "${CMAKE_COMMAND}" -E copy "${THIRD_PARTY_DIR}/utp_config.h" "/utp_config.h" - COMMAND "${CMAKE_COMMAND}" -E chdir "" patch -p1 --binary -i "${THIRD_PARTY_DIR}/utp-01-ticket-5002.patch") + COMMAND "${CMAKE_COMMAND}" -E chdir "" patch -p1 --binary -i "${THIRD_PARTY_DIR}/utp-01-ticket-5002.patch" + COMMAND "${CMAKE_COMMAND}" -E chdir "" patch -p1 --binary -i "${THIRD_PARTY_DIR}/utp-02-win32.patch" + COMMAND "${CMAKE_COMMAND}" -E chdir "" patch -p1 --binary -i "${THIRD_PARTY_DIR}/utp-03-msvc14.patch") endif() tr_add_external_auto_library(B64 b64 diff --git a/third-party/event2-01-win32.patch b/third-party/event2-01-win32.patch new file mode 100644 index 000000000..a75ca0cb8 --- /dev/null +++ b/third-party/event2-01-win32.patch @@ -0,0 +1,14 @@ +diff --git a/WIN32-Code/event2/event-config.h b/WIN32-Code/event2/event-config.h +--- a/WIN32-Code/event2/event-config.h ++++ b/WIN32-Code/event2/event-config.h +@@ -167,7 +167,9 @@ + /* #undef _EVENT_HAVE_STRSEP */ + + /* Define to 1 if you have the `strtok_r' function. */ +-/* #undef _EVENT_HAVE_STRTOK_R */ ++#if defined(__MINGW32__) || defined(__MINGW64__) ++#define _EVENT_HAVE_STRTOK_R 1 ++#endif + + /* Define to 1 if you have the `strtoll' function. */ + /* #define _EVENT_HAVE_STRTOLL 1 */ diff --git a/third-party/utp-02-win32.patch b/third-party/utp-02-win32.patch new file mode 100644 index 000000000..fa3fa3f84 --- /dev/null +++ b/third-party/utp-02-win32.patch @@ -0,0 +1,31 @@ +diff --git a/utp.h b/utp.h +--- a/utp.h ++++ b/utp.h +@@ -4,12 +4,18 @@ + #include "utypes.h" + + #ifdef WIN32 ++#ifndef _CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE ++#endif ++#ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN ++#endif + #include + #include + #include ++#ifdef _MSC_VER + #pragma comment(lib,"ws2_32.lib") ++#endif + #else + #include + #include +@@ -142,7 +148,7 @@ + }; + + // Get stats for UTP socket +-void UTP_GetStats(struct UTPSocket *socket, UTPStats *stats); ++void UTP_GetStats(struct UTPSocket *socket, struct UTPStats *stats); + #endif + + // Close the UTP socket. diff --git a/third-party/utp-03-msvc14.patch b/third-party/utp-03-msvc14.patch new file mode 100644 index 000000000..0297101e4 --- /dev/null +++ b/third-party/utp-03-msvc14.patch @@ -0,0 +1,30 @@ +diff --git a/utp.cpp b/utp.cpp +--- a/utp.cpp ++++ b/utp.cpp +@@ -859,7 +859,7 @@ + int flags = version == 0 ? b->flags : b1->type(); + uint16 seq_nr = version == 0 ? b->seq_nr : b1->seq_nr; + uint16 ack_nr = version == 0 ? b->ack_nr : b1->ack_nr; +- LOG_UTPV("0x%08x: send %s len:%u id:%u timestamp:"I64u" reply_micro:%u flags:%s seq_nr:%u ack_nr:%u", ++ LOG_UTPV("0x%08x: send %s len:%u id:%u timestamp:" I64u " reply_micro:%u flags:%s seq_nr:%u ack_nr:%u", + this, addrfmt(addr, addrbuf), (uint)length, conn_id_send, time, reply_micro, flagnames[flags], + seq_nr, ack_nr); + #endif +@@ -1705,7 +1705,7 @@ + // used in parse_log.py + LOG_UTP("0x%08x: actual_delay:%u our_delay:%d their_delay:%u off_target:%d max_window:%u " + "delay_base:%u delay_sum:%d target_delay:%d acked_bytes:%u cur_window:%u " +- "scaled_gain:%f rtt:%u rate:%u quota:%d wnduser:%u rto:%u timeout:%d get_microseconds:"I64u" " ++ "scaled_gain:%f rtt:%u rate:%u quota:%d wnduser:%u rto:%u timeout:%d get_microseconds:" I64u " " + "cur_window_packets:%u packet_size:%u their_delay_base:%u their_actual_delay:%u", + this, actual_delay, our_delay / 1000, their_hist.get_value() / 1000, + (int)off_target / 1000, (uint)(max_window), our_hist.delay_base, +@@ -1790,7 +1790,7 @@ + + if (pk_flags >= ST_NUM_STATES) return 0; + +- LOG_UTPV("0x%08x: Got %s. seq_nr:%u ack_nr:%u state:%s version:%u timestamp:"I64u" reply_micro:%u", ++ LOG_UTPV("0x%08x: Got %s. seq_nr:%u ack_nr:%u state:%s version:%u timestamp:" I64u " reply_micro:%u", + conn, flagnames[pk_flags], pk_seq_nr, pk_ack_nr, statenames[conn->state], conn->version, + conn->version == 0?(uint64)(pf->tv_sec) * 1000000 + pf->tv_usec:uint64(pf1->tv_usec), + conn->version == 0?(uint32)(pf->reply_micro):(uint32)(pf1->reply_micro));