summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2016-09-03 00:07:23 +0100
committerChris Wilson <chris+github@qwirx.com>2016-09-03 00:07:23 +0100
commitc0125ee22e09a31ae291e42faa817835bd903dbc (patch)
treeaca37c831ef9897f1b4898cbf8d2bef36112c5af /lib
parent0560d351665313fcdd503af213118eec46930cbe (diff)
Update platform feature detection to work with CMake.
Rewrite some macros in forms that can be parsed by our parser written in CMake language (fake m4 with regexps). Fix incorrect conditional includes and incorrect #if/#ifdef assumptions.
Diffstat (limited to 'lib')
-rw-r--r--lib/backupstore/BackupClientFileAttributes.cpp6
-rw-r--r--lib/backupstore/BackupStoreFileDiff.cpp2
-rw-r--r--lib/backupstore/HousekeepStoreAccount.cpp2
-rw-r--r--lib/common/BoxConfig-MSVC.h9
-rw-r--r--lib/common/BoxPlatform.h23
-rw-r--r--lib/common/DebugMemLeakFinder.cpp12
-rw-r--r--lib/common/ExcludeList.cpp4
-rw-r--r--lib/common/Logging.cpp14
-rw-r--r--lib/server/Daemon.cpp13
-rw-r--r--lib/server/TcpNice.cpp4
-rw-r--r--lib/win32/emu.h6
11 files changed, 51 insertions, 44 deletions
diff --git a/lib/backupstore/BackupClientFileAttributes.cpp b/lib/backupstore/BackupClientFileAttributes.cpp
index 7ec6f478..37140301 100644
--- a/lib/backupstore/BackupClientFileAttributes.cpp
+++ b/lib/backupstore/BackupClientFileAttributes.cpp
@@ -545,7 +545,7 @@ void BackupClientFileAttributes::FillAttributesLink(
void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBlock,
const std::string& Filename)
{
-#ifdef HAVE_SYS_XATTR_H
+#if defined HAVE_LLISTXATTR && defined HAVE_LGETXATTR
int listBufferSize = 10000;
char* list = new char[listBufferSize];
@@ -693,7 +693,7 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc
throw;
}
delete[] list;
-#endif
+#endif // defined HAVE_LLISTXATTR && defined HAVE_LGETXATTR
}
// --------------------------------------------------------------------------
@@ -992,7 +992,7 @@ void BackupClientFileAttributes::EnsureClearAvailable() const
// --------------------------------------------------------------------------
void BackupClientFileAttributes::WriteExtendedAttr(const std::string& Filename, int xattrOffset) const
{
-#ifdef HAVE_SYS_XATTR_H
+#if defined HAVE_LSETXATTR
const char* buffer = static_cast<char*>(mpClearAttributes->GetBuffer());
uint32_t xattrBlockLength = 0;
diff --git a/lib/backupstore/BackupStoreFileDiff.cpp b/lib/backupstore/BackupStoreFileDiff.cpp
index 1d83d854..e6df11a6 100644
--- a/lib/backupstore/BackupStoreFileDiff.cpp
+++ b/lib/backupstore/BackupStoreFileDiff.cpp
@@ -16,7 +16,7 @@
#ifdef HAVE_TIME_H
#include <time.h>
-#elif HAVE_SYS_TIME_H
+#elif defined HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
diff --git a/lib/backupstore/HousekeepStoreAccount.cpp b/lib/backupstore/HousekeepStoreAccount.cpp
index f24d7227..d5acf62c 100644
--- a/lib/backupstore/HousekeepStoreAccount.cpp
+++ b/lib/backupstore/HousekeepStoreAccount.cpp
@@ -932,7 +932,7 @@ void HousekeepStoreAccount::UpdateDirectorySize(
BackupStoreDirectory& rDirectory,
IOStream::pos_type new_size_in_blocks)
{
-#ifndef NDEBUG
+#ifndef BOX_RELEASE_BUILD
{
std::string dirFilename;
MakeObjectFilename(rDirectory.GetObjectID(), dirFilename);
diff --git a/lib/common/BoxConfig-MSVC.h b/lib/common/BoxConfig-MSVC.h
index 82ab4997..2ec2edd7 100644
--- a/lib/common/BoxConfig-MSVC.h
+++ b/lib/common/BoxConfig-MSVC.h
@@ -2,9 +2,6 @@
/* lib/common/BoxConfig.h.in. Generated from configure.ac by autoheader. */
/* Hacked by hand to work for MSVC by Chris Wilson */
-// using std::min/max
-#define NOMINMAX
-
/* Define to major version for BDB_VERSION */
/* #undef BDB_VERSION_MAJOR */
@@ -389,9 +386,6 @@
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
-/* Define to `int' if <sys/types.h> doesn't define. */
-#define gid_t int
-
/* Define to `int' if <sys/types.h> does not define. */
/* #undef mode_t */
@@ -403,6 +397,3 @@
/* Define to `unsigned' if <sys/types.h> does not define. */
/* #undef size_t */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-#define uid_t int
diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h
index 35ad7a2c..f8720587 100644
--- a/lib/common/BoxPlatform.h
+++ b/lib/common/BoxPlatform.h
@@ -96,16 +96,19 @@
#endif
// Handle differing xattr APIs
-#ifdef HAVE_SYS_XATTR_H
- #if !defined(HAVE_LLISTXATTR) && defined(HAVE_LISTXATTR) && HAVE_DECL_XATTR_NOFOLLOW
- #define llistxattr(a,b,c) listxattr(a,b,c,XATTR_NOFOLLOW)
- #endif
- #if !defined(HAVE_LGETXATTR) && defined(HAVE_GETXATTR) && HAVE_DECL_XATTR_NOFOLLOW
- #define lgetxattr(a,b,c,d) getxattr(a,b,c,d,0,XATTR_NOFOLLOW)
- #endif
- #if !defined(HAVE_LSETXATTR) && defined(HAVE_SETXATTR) && HAVE_DECL_XATTR_NOFOLLOW
- #define lsetxattr(a,b,c,d,e) setxattr(a,b,c,d,0,(e)|XATTR_NOFOLLOW)
- #endif
+#if !defined(HAVE_LLISTXATTR) && defined(HAVE_LISTXATTR) && HAVE_DECL_XATTR_NOFOLLOW
+ #define llistxattr(a,b,c) listxattr(a,b,c,XATTR_NOFOLLOW)
+ #define HAVE_LLISTXATTR
+#endif
+
+#if !defined(HAVE_LGETXATTR) && defined(HAVE_GETXATTR) && HAVE_DECL_XATTR_NOFOLLOW
+ #define lgetxattr(a,b,c,d) getxattr(a,b,c,d,0,XATTR_NOFOLLOW)
+ #define HAVE_LGETXATTR
+#endif
+
+#if !defined(HAVE_LSETXATTR) && defined(HAVE_SETXATTR) && HAVE_DECL_XATTR_NOFOLLOW
+ #define lsetxattr(a,b,c,d,e) setxattr(a,b,c,d,0,(e)|XATTR_NOFOLLOW)
+ #define HAVE_LSETXATTR
#endif
#if !HAVE_DECL_INFTIM
diff --git a/lib/common/DebugMemLeakFinder.cpp b/lib/common/DebugMemLeakFinder.cpp
index 81e999c4..58a82c0e 100644
--- a/lib/common/DebugMemLeakFinder.cpp
+++ b/lib/common/DebugMemLeakFinder.cpp
@@ -15,15 +15,19 @@
#undef realloc
#undef free
-#ifdef HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_PROCESS_H
+# include <process.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
#include <cstdlib> // for std::atexit
#include <map>
#include <set>
diff --git a/lib/common/ExcludeList.cpp b/lib/common/ExcludeList.cpp
index f101782a..4d964021 100644
--- a/lib/common/ExcludeList.cpp
+++ b/lib/common/ExcludeList.cpp
@@ -10,9 +10,9 @@
#include "Box.h"
#ifdef HAVE_REGEX_SUPPORT
- #ifdef HAVE_PCREPOSIX_H
+ #if defined HAVE_PCREPOSIX_H
#include <pcreposix.h>
- #else
+ #elif defined HAVE_REGEX_H
#include <regex.h>
#endif
#define EXCLUDELIST_IMPLEMENTATION_REGEX_T_DEFINED
diff --git a/lib/common/Logging.cpp b/lib/common/Logging.cpp
index a0d1ec8c..0928a4d4 100644
--- a/lib/common/Logging.cpp
+++ b/lib/common/Logging.cpp
@@ -13,19 +13,19 @@
#include <time.h>
#include <string.h> // for stderror
-// c.f. http://bugs.debian.org/512510
-#include <cstdio>
+#ifdef HAVE_PROCESS_H
+# include <process.h>
+#endif
#ifdef HAVE_SYSLOG_H
- #include <syslog.h>
+# include <syslog.h>
#endif
+
#ifdef HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-#ifdef WIN32
- #include <process.h>
+# include <unistd.h>
#endif
+#include <cstdio>
#include <cstring>
#include <iomanip>
diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp
index 836948bf..d3c8441f 100644
--- a/lib/server/Daemon.cpp
+++ b/lib/server/Daemon.cpp
@@ -9,16 +9,20 @@
#include "Box.h"
-#ifdef HAVE_UNISTD_H
- #include <unistd.h>
-#endif
-
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <stdarg.h>
+#ifdef HAVE_PROCESS_H
+# include <process.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
#ifdef HAVE_BSD_UNISTD_H
#include <bsd/unistd.h>
#endif
@@ -26,7 +30,6 @@
#ifdef WIN32
#include <Strsafe.h>
#include <ws2tcpip.h>
- #include <process.h>
#endif
#include "depot.h"
diff --git a/lib/server/TcpNice.cpp b/lib/server/TcpNice.cpp
index 40e7a6b5..79e91eeb 100644
--- a/lib/server/TcpNice.cpp
+++ b/lib/server/TcpNice.cpp
@@ -146,7 +146,7 @@ void NiceSocketStream::Write(const void *pBuffer, int NBytes)
int socket = mapSocket->GetSocketHandle();
int rtt = 50; // WAG
-# if HAVE_DECL_SOL_TCP && HAVE_DECL_TCP_INFO && HAVE_STRUCT_TCP_INFO_TCPI_RTT
+# if HAVE_DECL_SOL_TCP && defined HAVE_STRUCT_TCP_INFO_TCPI_RTT
struct tcp_info info;
socklen_t optlen = sizeof(info);
if(getsockopt(socket, SOL_TCP, TCP_INFO, &info, &optlen) == -1)
@@ -164,7 +164,7 @@ void NiceSocketStream::Write(const void *pBuffer, int NBytes)
{
rtt = info.tcpi_rtt;
}
-# endif
+# endif // HAVE_DECL_SOL_TCP && defined HAVE_STRUCT_TCP_INFO_TCPI_RTT
int newWindow = mTcpNice.GetNextWindowSize(mBytesWrittenThisPeriod,
elapsed, rtt);
diff --git a/lib/win32/emu.h b/lib/win32/emu.h
index b8539bb6..d0b7081b 100644
--- a/lib/win32/emu.h
+++ b/lib/win32/emu.h
@@ -39,8 +39,14 @@
#ifndef __MINGW32__
typedef unsigned int mode_t;
typedef unsigned int pid_t;
+ typedef unsigned int uid_t;
+ typedef unsigned int gid_t;
#endif
+// Disable Windows' non-standard implementation of min() and max():
+// http://stackoverflow.com/a/5004874/648162
+#define NOMINMAX
+
// Windows headers
#include <winsock2.h>