summaryrefslogtreecommitdiff
path: root/zen
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-05-10 11:21:56 -0400
committerB. Stack <bgstack15@gmail.com>2024-05-10 11:21:56 -0400
commit7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7 (patch)
tree3ed84995318afbd82d5d98a2ba044f9ba58b57c6 /zen
parentadd upstream 13.5 (diff)
downloadFreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.tar.gz
FreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.tar.bz2
FreeFileSync-7a5f22cfe87f938ef58f92b48ac379dc1c4c81c7.zip
add upstream 13.613.6
Diffstat (limited to 'zen')
-rw-r--r--zen/argon2.cpp4
-rw-r--r--zen/dir_watcher.cpp5
-rw-r--r--zen/dir_watcher.h2
-rw-r--r--zen/file_access.cpp4
-rw-r--r--zen/file_access.h2
-rw-r--r--zen/file_path.cpp2
-rw-r--r--zen/file_traverser.cpp1
-rw-r--r--zen/file_traverser.h2
-rw-r--r--zen/format_unit.cpp4
-rw-r--r--zen/legacy_compiler.h2
-rw-r--r--zen/perf.h2
-rw-r--r--zen/process_exec.cpp4
-rw-r--r--zen/scope_guard.h2
-rw-r--r--zen/socket.h12
-rw-r--r--zen/stl_tools.h2
-rw-r--r--zen/stream_buffer.h5
-rw-r--r--zen/string_tools.h4
-rw-r--r--zen/sys_info.cpp4
-rw-r--r--zen/thread.h1
-rw-r--r--zen/utf.h12
20 files changed, 45 insertions, 31 deletions
diff --git a/zen/argon2.cpp b/zen/argon2.cpp
index 1250e545..5918b4b3 100644
--- a/zen/argon2.cpp
+++ b/zen/argon2.cpp
@@ -37,9 +37,9 @@
#include "argon2.h"
#include <cassert>
-#include <cstring>
+//#include <cstring>
#include <cstdint>
-#include <cstdlib>
+//#include <cstdlib>
#if defined __GNUC__ //including clang
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" //"this statement may fall through"
diff --git a/zen/dir_watcher.cpp b/zen/dir_watcher.cpp
index dccc149d..471d5438 100644
--- a/zen/dir_watcher.cpp
+++ b/zen/dir_watcher.cpp
@@ -5,10 +5,11 @@
// *****************************************************************************
#include "dir_watcher.h"
-#include <algorithm>
-#include <set>
+//#include <algorithm>
+//#include <set>
#include "thread.h"
#include "scope_guard.h"
+ #include "file_access.h"
#include <map>
#include <sys/inotify.h>
diff --git a/zen/dir_watcher.h b/zen/dir_watcher.h
index 24af9810..8c82707f 100644
--- a/zen/dir_watcher.h
+++ b/zen/dir_watcher.h
@@ -38,7 +38,7 @@ namespace zen
class DirWatcher
{
public:
- DirWatcher(const Zstring& dirPath); //throw FileError
+ explicit DirWatcher(const Zstring& dirPath); //throw FileError
~DirWatcher();
enum class ChangeType
diff --git a/zen/file_access.cpp b/zen/file_access.cpp
index 22129157..23b6f70d 100644
--- a/zen/file_access.cpp
+++ b/zen/file_access.cpp
@@ -5,9 +5,9 @@
// *****************************************************************************
#include "file_access.h"
-#include <map>
+//#include <map>
#include <algorithm>
-#include <chrono>
+//#include <chrono>
#include <variant>
#include "file_traverser.h"
#include "scope_guard.h"
diff --git a/zen/file_access.h b/zen/file_access.h
index f6ac3740..42cf1a46 100644
--- a/zen/file_access.h
+++ b/zen/file_access.h
@@ -7,7 +7,7 @@
#ifndef FILE_ACCESS_H_8017341345614857
#define FILE_ACCESS_H_8017341345614857
-#include <functional>
+//#include <functional>
#include "file_path.h"
#include "file_error.h"
#include "serialize.h" //IoCallback
diff --git a/zen/file_path.cpp b/zen/file_path.cpp
index 6503ba2f..5941689e 100644
--- a/zen/file_path.cpp
+++ b/zen/file_path.cpp
@@ -5,7 +5,7 @@
// *****************************************************************************
#include "file_path.h"
-#include "thread.h"
+#include "zstring.h"
using namespace zen;
diff --git a/zen/file_traverser.cpp b/zen/file_traverser.cpp
index 4c3e2f97..8564e612 100644
--- a/zen/file_traverser.cpp
+++ b/zen/file_traverser.cpp
@@ -6,6 +6,7 @@
#include "file_traverser.h"
#include "file_error.h"
+ #include "file_access.h"
#include <sys/stat.h>
diff --git a/zen/file_traverser.h b/zen/file_traverser.h
index c57b7d36..8c2755d6 100644
--- a/zen/file_traverser.h
+++ b/zen/file_traverser.h
@@ -9,7 +9,7 @@
#include <functional>
#include "file_error.h"
-#include "file_path.h"
+//#include "file_path.h"
namespace zen
{
diff --git a/zen/format_unit.cpp b/zen/format_unit.cpp
index 0ce68d9b..fe44ac7b 100644
--- a/zen/format_unit.cpp
+++ b/zen/format_unit.cpp
@@ -5,8 +5,8 @@
// *****************************************************************************
#include "format_unit.h"
-#include <ctime>
-#include <cstdio>
+//#include <ctime>
+//#include <cstdio>
#include "basic_math.h"
#include "sys_error.h"
#include "i18n.h"
diff --git a/zen/legacy_compiler.h b/zen/legacy_compiler.h
index 54909b71..6d208b09 100644
--- a/zen/legacy_compiler.h
+++ b/zen/legacy_compiler.h
@@ -50,7 +50,7 @@ const char* toChars(char* first, char* last, double num);
}
-#if 0 //neat: supported on MSVC, but not yet on GCC, Clang
+#if 0 //neat: supported on MSVC and GCC, but not yet on Clang
auto closure = [](this auto&& self)
{
self(); //just call ourself until the stack overflows
diff --git a/zen/perf.h b/zen/perf.h
index a0cc905a..fe3c5f67 100644
--- a/zen/perf.h
+++ b/zen/perf.h
@@ -8,7 +8,7 @@
#define PERF_H_83947184145342652456
#include <chrono>
-#include "scope_guard.h"
+//#include "scope_guard.h"
#include "string_tools.h"
#include <iostream>
diff --git a/zen/process_exec.cpp b/zen/process_exec.cpp
index 46c04eb5..76a2e436 100644
--- a/zen/process_exec.cpp
+++ b/zen/process_exec.cpp
@@ -5,7 +5,7 @@
// *****************************************************************************
#include "process_exec.h"
-#include <chrono>
+//#include <chrono>
#include "guid.h"
#include "file_access.h"
#include "file_io.h"
@@ -207,7 +207,7 @@ std::pair<int /*exit code*/, std::string> processExecuteImpl(const Zstring& file
THROW_LAST_SYS_ERROR("lseek");
guardTmpFile.dismiss();
- FileInputPlain streamIn(fdTempFile, tempFilePath); //takes ownership!
+ FileInputPlain streamIn(fdTempFile, tempFilePath); //pass ownership!
std::string output = unbufferedLoad<std::string>([&](void* buffer, size_t bytesToRead)
{
diff --git a/zen/scope_guard.h b/zen/scope_guard.h
index 9b27eecb..866044a8 100644
--- a/zen/scope_guard.h
+++ b/zen/scope_guard.h
@@ -8,7 +8,7 @@
#define SCOPE_GUARD_H_8971632487321434
#include <cassert>
-#include "type_traits.h"
+//#include "type_traits.h"
#include "legacy_compiler.h" //std::uncaught_exceptions
//best of Zen, Loki and C++17
diff --git a/zen/socket.h b/zen/socket.h
index c2fdb145..0a311d01 100644
--- a/zen/socket.h
+++ b/zen/socket.h
@@ -10,6 +10,7 @@
#include "sys_error.h"
#include <unistd.h> //close
#include <sys/socket.h>
+ #include <netinet/tcp.h> //TCP_NODELAY
#include <netdb.h> //getaddrinfo
@@ -102,7 +103,6 @@ public:
THROW_LAST_SYS_ERROR_WSA("socket");
ZEN_ON_SCOPE_FAIL(closeSocket(testSocket));
-
if (::connect(testSocket, ai.ai_addr, static_cast<int>(ai.ai_addrlen)) != 0) //0 or SOCKET_ERROR(-1)
{
if (errno != EINPROGRESS)
@@ -141,6 +141,16 @@ public:
}
setNonBlocking(testSocket, false); //throw SysError
+ //-----------------------------------------------------------
+
+ int noDelay = 1; //disable Nagle algorithm: https://brooker.co.za/blog/2024/05/09/nagle.html
+ //e.g. test case "website sync": 23% shorter comparison time!
+ if (::setsockopt(testSocket, //_In_ SOCKET s
+ IPPROTO_TCP, //_In_ int level
+ TCP_NODELAY, //_In_ int optname
+ reinterpret_cast<char*>(&noDelay), //_In_ const char* optval
+ sizeof(noDelay)) != 0) //_In_ int optlen
+ THROW_LAST_SYS_ERROR_WSA("setsockopt(TCP_NODELAY)");
return testSocket;
};
diff --git a/zen/stl_tools.h b/zen/stl_tools.h
index ff574368..f167a814 100644
--- a/zen/stl_tools.h
+++ b/zen/stl_tools.h
@@ -14,7 +14,7 @@
#include <unordered_map>
#include <memory>
#include <cassert>
-#include <algorithm>
+//#include <algorithm>
#include <optional>
#include "type_traits.h"
diff --git a/zen/stream_buffer.h b/zen/stream_buffer.h
index 64cb76ca..5d2ec024 100644
--- a/zen/stream_buffer.h
+++ b/zen/stream_buffer.h
@@ -7,10 +7,11 @@
#ifndef STREAM_BUFFER_H_08492572089560298
#define STREAM_BUFFER_H_08492572089560298
-#include <condition_variable>
+#include <thread>
+//#include <condition_variable>
#include "ring_buffer.h"
#include "string_tools.h"
-#include "thread.h"
+//#include "thread.h"
namespace zen
diff --git a/zen/string_tools.h b/zen/string_tools.h
index 3aa1c1d6..b95a2055 100644
--- a/zen/string_tools.h
+++ b/zen/string_tools.h
@@ -7,8 +7,8 @@
#ifndef STRING_TOOLS_H_213458973046
#define STRING_TOOLS_H_213458973046
-#include <cctype> //isspace
-#include <cwctype> //iswspace
+//#include <cctype> //isspace
+//#include <cwctype> //iswspace
#include <cstdio> //sprintf
#include <cwchar> //swprintf
#include "stl_tools.h"
diff --git a/zen/sys_info.cpp b/zen/sys_info.cpp
index c3680ec7..530b3d85 100644
--- a/zen/sys_info.cpp
+++ b/zen/sys_info.cpp
@@ -8,9 +8,9 @@
#include "crc.h"
#include "file_access.h"
#include "sys_version.h"
-#include "symlink_target.h"
-#include "time.h"
+//#include "time.h"
+ #include "symlink_target.h"
#include "file_io.h"
#include <ifaddrs.h>
#include <net/if.h> //IFF_LOOPBACK
diff --git a/zen/thread.h b/zen/thread.h
index 27e23b4a..290baac5 100644
--- a/zen/thread.h
+++ b/zen/thread.h
@@ -72,6 +72,7 @@ void interruptibleSleep(const std::chrono::duration<Rep, Period>& relTime); //th
void setCurrentThreadName(const Zstring& threadName);
+
bool runningOnMainThread();
//------------------------------------------------------------------------------------------
diff --git a/zen/utf.h b/zen/utf.h
index aad05aba..0872fc8f 100644
--- a/zen/utf.h
+++ b/zen/utf.h
@@ -25,8 +25,8 @@ bool isValidUtf(const UtfString& str); //check for UTF-8 encoding errors
template <class UtfString>
size_t unicodeLength(const UtfString& str); //return number of code points for UTF-encoded string
-template <class UtfString>
-UtfString getUnicodeSubstring(const UtfString& str, size_t uniPosFirst, size_t uniPosLast);
+template <class UtfStringOut, class UtfStringIn>
+UtfStringOut getUnicodeSubstring(const UtfStringIn& str, size_t uniPosFirst, size_t uniPosLast);
@@ -310,14 +310,14 @@ size_t unicodeLength(const UtfString& str) //return number of code points (+ cor
}
-template <class UtfString> inline
-UtfString getUnicodeSubstring(const UtfString& str, size_t uniPosFirst, size_t uniPosLast) //return position of unicode char in UTF-encoded string
+template <class UtfStringOut, class UtfStringIn> inline
+UtfStringOut getUnicodeSubstring(const UtfStringIn& str, size_t uniPosFirst, size_t uniPosLast) //return position of unicode char in UTF-encoded string
{
assert(uniPosFirst <= uniPosLast && uniPosLast <= unicodeLength(str));
using namespace impl;
- using CharType = GetCharTypeT<UtfString>;
+ using CharType = GetCharTypeT<UtfStringIn>;
- UtfString output;
+ UtfStringOut output;
assert(uniPosFirst <= uniPosLast);
if (uniPosFirst >= uniPosLast) //optimize for empty range
return output;
bgstack15