summaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common')
-rw-r--r--lib/common/BeginStructPackForWire.h2
-rwxr-xr-xlib/common/Box.h63
-rwxr-xr-xlib/common/BoxPlatform.h286
-rw-r--r--lib/common/EndStructPackForWire.h2
-rw-r--r--lib/common/EventWatchFilesystemObject.cpp6
-rw-r--r--lib/common/EventWatchFilesystemObject.h4
-rwxr-xr-xlib/common/ExcludeList.cpp8
-rwxr-xr-xlib/common/ExcludeList.h4
-rwxr-xr-xlib/common/FileModificationTime.h6
-rwxr-xr-xlib/common/LinuxWorkaround.cpp73
-rwxr-xr-xlib/common/LinuxWorkaround.h20
-rwxr-xr-xlib/common/NamedLock.cpp42
-rwxr-xr-xlib/common/TemporaryDirectory.h4
-rw-r--r--lib/common/WaitForEvent.cpp8
-rw-r--r--lib/common/WaitForEvent.h10
15 files changed, 109 insertions, 429 deletions
diff --git a/lib/common/BeginStructPackForWire.h b/lib/common/BeginStructPackForWire.h
index f9f8f616..e73bb886 100644
--- a/lib/common/BeginStructPackForWire.h
+++ b/lib/common/BeginStructPackForWire.h
@@ -9,7 +9,7 @@
// No header guard -- this is intentional
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#pragma pack(1)
diff --git a/lib/common/Box.h b/lib/common/Box.h
index 19e78ada..4a76e74e 100755
--- a/lib/common/Box.h
+++ b/lib/common/Box.h
@@ -21,12 +21,13 @@
//#define MEMLEAKFINDER_FULL_MALLOC_MONITORING
#ifndef NDEBUG
- // not available on OpenBSD... oh well.
- //#define SHOW_BACKTRACE_ON_EXCEPTION
+ #ifdef HAVE_EXECINFO_H
+ #define SHOW_BACKTRACE_ON_EXCEPTION
+ #endif
#endif
#ifdef SHOW_BACKTRACE_ON_EXCEPTION
- // include "Utils.h"
+ #include "Utils.h"
#define OPTIONAL_DO_BACKTRACE DumpStackBacktrace();
#else
#define OPTIONAL_DO_BACKTRACE
@@ -126,55 +127,17 @@ inline uint64_t box_swap64(uint64_t x)
(x & 0xff00000000000000LL) >> 56);
}
-// Does the platform provide a built in SWAP64 we can use?
-#ifdef PLATFORM_NO_BUILT_IN_SWAP64
-
- #define hton64(x) box_swap64(x)
- #define ntoh64(x) box_swap64(x)
-
+#ifdef WORDS_BIGENDIAN
+ #define box_hton64(x) (x)
+ #define box_ntoh64(x) (x)
#else
+ #define box_hton64(x) box_swap64(x)
+ #define box_ntoh64(x) box_swap64(x)
+#endif
- #if BYTE_ORDER == BIG_ENDIAN
-
- // Less hassle than trying to find some working things
- // on Darwin PPC
- #define hton64(x) (x)
- #define ntoh64(x) (x)
-
- #else
-
- #ifdef PLATFORM_LINUX
- // On Linux, use some internal kernal stuff to do this
- #include <asm/byteorder.h>
- #define hton64 __cpu_to_be64
- #define ntoh64 __be64_to_cpu
- #else
- #define hton64 htobe64
- #define ntoh64 betoh64
- #endif
-
- // hack to make some of these work
- // version in /usr/include/sys/endian.h doesn't include the 'LL' at the end of the constants
- // provoking complaints from the compiler
- #ifdef __GNUC__
- #undef __swap64gen
- #define __swap64gen(x) __extension__({ \
- u_int64_t __swap64gen_x = (x); \
- \
- (u_int64_t)((__swap64gen_x & 0xff) << 56 | \
- (__swap64gen_x & 0xff00LL) << 40 | \
- (__swap64gen_x & 0xff0000LL) << 24 | \
- (__swap64gen_x & 0xff000000LL) << 8 | \
- (__swap64gen_x & 0xff00000000LL) >> 8 | \
- (__swap64gen_x & 0xff0000000000LL) >> 24 | \
- (__swap64gen_x & 0xff000000000000LL) >> 40 | \
- (__swap64gen_x & 0xff00000000000000LL) >> 56); \
- })
- #endif // __GNUC__
-
- #endif // n BYTE_ORDER == BIG_ENDIAN
-
-#endif // PLATFORM_NO_BUILT_IN_SWAP64
+#ifdef HAVE_NETINET_IN_H
+ #include <netinet/in.h>
+#endif
#endif // BOX__H
diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h
index 3b75f992..6ddd1643 100755
--- a/lib/common/BoxPlatform.h
+++ b/lib/common/BoxPlatform.h
@@ -16,266 +16,76 @@
#define PLATFORM_DEV_NULL "/dev/null"
+#include "config.h"
-// Other flags which might be useful...
-//
-// #define PLATFORM_BERKELEY_DB_NOT_SUPPORTED
-// -- dbopen etc not on this platform
-//
-// #define PLATFORM_REGEX_NOT_SUPPORTED
-// -- regex support not available on this platform
-
-
-#ifdef PLATFORM_OPENBSD
-
- #include <sys/types.h>
-
- #define PLATFORM_HAVE_setproctitle
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_HAVE_getpeereid
-
- #define PLATFORM_RANDOM_DEVICE "/dev/arandom"
-
-#endif // PLATFORM_OPENBSD
-
-#ifdef PLATFORM_NETBSD
-
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
-
- #define PLATFORM_HAVE_setproctitle
-
- #define PLATFORM_NO_BUILT_IN_SWAP64
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_KQUEUE_NOT_SUPPORTED
-
- #define PLATFORM_RANDOM_DEVICE "/dev/urandom"
-
#endif
-
-#ifdef PLATFORM_FREEBSD
-
- #include <sys/types.h>
- #include <netinet/in.h>
-
- #define PLATFORM_HAVE_setproctitle
-
- #define PLATFORM_NO_BUILT_IN_SWAP64
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_HAVE_getpeereid
-
- #define PLATFORM_RANDOM_DEVICE "/dev/urandom"
-
-#endif // PLATFORM_FREEBSD
-
-#ifdef PLATFORM_DARWIN
-
- #include <sys/types.h>
- #include <netdb.h>
-
- // types 'missing'
- #ifndef _SOCKLEN_T
- typedef int socklen_t;
+#ifdef HAVE_INTTYPES_H
+ #include <inttypes.h>
+#else
+ #ifdef HAVE_STDINT_H
+ #include <stdint.h>
#endif
- typedef u_int8_t uint8_t;
- typedef signed char int8_t;
- typedef u_int64_t uint64_t;
- typedef u_int32_t uint32_t;
- typedef u_int16_t uint16_t;
-
- // poll() emulator on Darwin misses this declaration
- #define INFTIM -1
+#endif
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_LCHOWN_NOT_SUPPORTED
-
- #define PLATFORM_READLINE_NOT_SUPPORTED
+// Find out if credentials on UNIX sockets can be obtained
+#ifndef HAVE_GETPEEREID
+ #if !HAVE_DECL_SO_PEERCRED
+ #define PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET
+ #endif
+#endif
- #define PLATFORM_RANDOM_DEVICE "/dev/random"
-
-#endif // PLATFORM_DARWIN
+// Cannot do the intercepts in test/raidfile if large file support is enabled
+#ifdef HAVE_LARGE_FILE_SUPPORT
+ #define PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE
+#endif
-#ifdef PLATFORM_LINUX
-
- #include <sys/types.h>
+#ifdef HAVE_DEFINE_PRAGMA
+ // set packing to one bytes (can't use push/pop on gcc)
+ #define BEGIN_STRUCTURE_PACKING_FOR_WIRE #pragma pack(1)
- // for ntohl etc...
- #include <netinet/in.h>
+ // Use default packing
+ #define END_STRUCTURE_PACKING_FOR_WIRE #pragma pack()
+#else
+ #define STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
+#endif
- // types 'missing'
+// Define missing types
+#ifndef HAVE_UINT8_T
typedef u_int8_t uint8_t;
- typedef signed char int8_t;
- typedef u_int32_t uint32_t;
- typedef u_int16_t uint16_t;
- typedef u_int64_t uint64_t;
-
- // not defined in Linux, a BSD thing
- #define INFTIM -1
-
- #define LLONG_MAX 9223372036854775807LL
- #define LLONG_MIN (-LLONG_MAX - 1LL)
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_HAVE_getsockopt_SO_PEERCRED
-
- // load in installation specific linux configuration
- #include "../../local/_linux_platform.h"
-
- #define PLATFORM_KQUEUE_NOT_SUPPORTED
- #define PLATFORM_dirent_BROKEN_d_type
- #define PLATFORM_stat_SHORT_mtime
- #define PLATFORM_stat_NO_st_flags
- #define PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
- #define PLATFORM_open_USE_flock
- #define PLATFORM_sockaddr_NO_len
-
- #define PLATFORM_RANDOM_DEVICE "/dev/urandom"
-
- // If large file support is on, can't do the intercepts in the test/raidfile
- #if _FILE_OFFSET_BITS == 64
- #define PLATFORM_CLIB_FNS_INTERCEPTION_IMPOSSIBLE
- #endif
-
-#endif // PLATFORM_LINUX
+#endif
-#ifdef PLATFORM_SUNOS
+#ifndef HAVE_UINT16_T
+ typedef u_int16_t uint16_t;
+#endif
- #include <sys/types.h>
+#ifndef HAVE_UINT32_T
+ typedef u_int32_t uint32_t;
+#endif
- // for ntohl etc...
- #include <netinet/in.h>
+#ifndef HAVE_UINT64_T
+ typedef u_int64_t uint64_t;
+#endif
- // types 'missing'
+#ifndef HAVE_U_INT8_T
typedef uint8_t u_int8_t;
-// typedef signed char int8_t;
- typedef uint32_t u_int32_t;
- typedef uint16_t u_int16_t;
- typedef uint64_t u_int64_t;
-
- // not defined in Solaris, a BSD thing
- #define INFTIM -1
-
- //#define LLONG_MAX 9223372036854775807LL
- //#define LLONG_MIN (-LLONG_MAX - 1LL)
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_BERKELEY_DB_NOT_SUPPORTED
- #define PLATFORM_KQUEUE_NOT_SUPPORTED // This may be in Solaris 10
- #define PLATFORM_dirent_BROKEN_d_type // Well, no d_type at all actually
- #define PLATFORM_stat_SHORT_mtime
- #define PLATFORM_stat_NO_st_flags
- #define PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
- #define PLATFORM_open_USE_fcntl
- #define PLATFORM_sockaddr_NO_len
-
- #define PLATFORM_RANDOM_DEVICE "/dev/urandom"
-
-#endif // PLATFORM_SUNOS
-
-#ifdef PLATFORM_CYGWIN
-
- #define PLATFORM_BERKELEY_DB_NOT_SUPPORTED
-
- #define PLATFORM_KQUEUE_NOT_SUPPORTED
- #define PLATFORM_dirent_BROKEN_d_type
- #define PLATFORM_stat_SHORT_mtime
- #define PLATFORM_stat_NO_st_flags
- #define PLATFORM_USES_MTAB_FILE_FOR_MOUNTS
- #define PLATFORM_open_USE_flock
- #define PLATFORM_sockaddr_NO_len
- #define PLATFORM_NO_BUILT_IN_SWAP64
-
- #define PLATFORM_STATIC_TEMP_DIRECTORY_NAME "/tmp"
-
- #define PLATFORM_READLINE_NOT_SUPPORTED
-
- #define LLONG_MAX 9223372036854775807LL
- #define LLONG_MIN (-LLONG_MAX - 1LL)
-
- #define INFTIM -1
-
- // File listing canonical interesting mount points.
- #define MNTTAB _PATH_MNTTAB
-
- // File listing currently active mount points.
- #define MOUNTED _PATH_MOUNTED
-
- #define __need_FILE
-
- // Extra includes
- #include <stdint.h>
- #include <stdlib.h>
- #include <netinet/in.h>
- #include <sys/socket.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <dirent.h>
- #include <stdio.h>
- #include <paths.h>
-
- // No easy random entropy source
- #define PLATFORM_RANDOM_DEVICE_NONE
-
-#endif // PLATFORM_CYGWIN
-
-
-// Check the processor type
-#ifdef PLATFORM_SPARC
- #define PLATFORM_ALIGN_INT
#endif
-#ifdef PLATFORM_ARM
- #define PLATFORM_ALIGN_INT
+#ifndef HAVE_U_INT16_T
+ typedef uint16_t u_int16_t;
#endif
-
-// Find out if credentials on UNIX sockets can be obtained
-#ifndef PLATFORM_HAVE_getpeereid
- #ifndef PLATFORM_HAVE_getsockopt_SO_PEERCRED
- #define PLATFORM_CANNOT_FIND_PEER_UID_OF_UNIX_SOCKET
- #endif
+#ifndef HAVE_U_INT32_T
+ typedef uint32_t u_int32_t;
#endif
-
-// Compiler issues
-#ifdef __GNUC__
-
- #ifdef PLATFORM_GCC3
-
- // GCC v3 doesn't like pragmas in #defines
- #define STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
-
- // But fortunately, the STL allocations are much better behaved.
-
- #else
-
- // Force STL to use malloc() for memory allocation
- // -- slower, but doesn't gradually use more and more memory
- // HOWEVER -- this 'fix' is broken on some platforms. Lots of fun!
- #ifndef PLATFORM_STL_USE_MALLOC_BROKEN
- #define __USE_MALLOC
- #endif
-
- // set packing to one bytes (can't use push/pop on gcc)
- #define BEGIN_STRUCTURE_PACKING_FOR_WIRE #pragma pack(1)
-
- // Use default packing
- #define END_STRUCTURE_PACKING_FOR_WIRE #pragma pack()
-
- #endif
-
-#else
- compiler not supported!
+#ifndef HAVE_U_INT64_T
+ typedef uint64_t u_int64_t;
#endif
+#if !HAVE_DECL_INFTIM
+ #define INFTIM -1
+#endif
#endif // BOXPLATFORM__H
-
diff --git a/lib/common/EndStructPackForWire.h b/lib/common/EndStructPackForWire.h
index c9655cd7..82637f33 100644
--- a/lib/common/EndStructPackForWire.h
+++ b/lib/common/EndStructPackForWire.h
@@ -9,7 +9,7 @@
// No header guard -- this is intentional
-#ifdef STRUCTURE_PATCKING_FOR_WIRE_USE_HEADERS
+#ifdef STRUCTURE_PACKING_FOR_WIRE_USE_HEADERS
#pragma pack()
diff --git a/lib/common/EventWatchFilesystemObject.cpp b/lib/common/EventWatchFilesystemObject.cpp
index 1611d5bd..c3fe11f8 100644
--- a/lib/common/EventWatchFilesystemObject.cpp
+++ b/lib/common/EventWatchFilesystemObject.cpp
@@ -27,11 +27,11 @@
//
// --------------------------------------------------------------------------
EventWatchFilesystemObject::EventWatchFilesystemObject(const char *Filename)
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
: mDescriptor(::open(Filename, O_RDONLY /*O_EVTONLY*/, 0))
#endif
{
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
if(mDescriptor == -1)
{
THROW_EXCEPTION(CommonException, OSFileOpenError)
@@ -77,7 +77,7 @@ EventWatchFilesystemObject::EventWatchFilesystemObject(const EventWatchFilesyste
}
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
// --------------------------------------------------------------------------
//
// Function
diff --git a/lib/common/EventWatchFilesystemObject.h b/lib/common/EventWatchFilesystemObject.h
index d8a7245b..f9175a49 100644
--- a/lib/common/EventWatchFilesystemObject.h
+++ b/lib/common/EventWatchFilesystemObject.h
@@ -10,7 +10,7 @@
#ifndef EVENTWATCHFILESYSTEMOBJECT__H
#define EVENTWATCHFILESYSTEMOBJECT__H
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
#include <sys/event.h>
#endif
@@ -34,7 +34,7 @@ private:
EventWatchFilesystemObject &operator=(const EventWatchFilesystemObject &);
public:
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
void FillInKEvent(struct kevent &rEvent, int Flags = 0) const;
#else
void FillInPoll(int &fd, short &events, int Flags = 0) const;
diff --git a/lib/common/ExcludeList.cpp b/lib/common/ExcludeList.cpp
index 6350869d..556a2079 100755
--- a/lib/common/ExcludeList.cpp
+++ b/lib/common/ExcludeList.cpp
@@ -9,7 +9,7 @@
#include "Box.h"
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
#include <regex.h>
#define EXCLUDELIST_IMPLEMENTATION_REGEX_T_DEFINED
#endif
@@ -44,7 +44,7 @@ ExcludeList::ExcludeList()
// --------------------------------------------------------------------------
ExcludeList::~ExcludeList()
{
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
// free regex memory
while(mRegex.size() > 0)
{
@@ -106,7 +106,7 @@ void ExcludeList::AddDefiniteEntries(const std::string &rEntries)
// --------------------------------------------------------------------------
void ExcludeList::AddRegexEntries(const std::string &rEntries)
{
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
// Split strings up
std::vector<std::string> ens;
@@ -173,7 +173,7 @@ bool ExcludeList::IsExcluded(const std::string &rTest) const
}
// Check against regular expressions
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
for(std::vector<regex_t *>::const_iterator i(mRegex.begin()); i != mRegex.end(); ++i)
{
// Test against this expression
diff --git a/lib/common/ExcludeList.h b/lib/common/ExcludeList.h
index a1954044..5324d226 100755
--- a/lib/common/ExcludeList.h
+++ b/lib/common/ExcludeList.h
@@ -45,7 +45,7 @@ public:
// Mainly for tests
unsigned int SizeOfDefiniteList() const {return mDefinite.size();}
unsigned int SizeOfRegexList() const
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
{return mRegex.size();}
#else
{return 0;}
@@ -53,7 +53,7 @@ public:
private:
std::set<std::string> mDefinite;
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
std::vector<regex_t *> mRegex;
#endif
diff --git a/lib/common/FileModificationTime.h b/lib/common/FileModificationTime.h
index 78f5c115..a84df579 100755
--- a/lib/common/FileModificationTime.h
+++ b/lib/common/FileModificationTime.h
@@ -16,7 +16,7 @@
inline box_time_t FileModificationTime(struct stat &st)
{
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
box_time_t datamodified = ((int64_t)st.st_mtime) * (MICRO_SEC_IN_SEC_LL);
#else
box_time_t datamodified = (((int64_t)st.st_mtimespec.tv_nsec) / NANO_SEC_IN_USEC_LL)
@@ -28,7 +28,7 @@ inline box_time_t FileModificationTime(struct stat &st)
inline box_time_t FileAttrModificationTime(struct stat &st)
{
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
box_time_t statusmodified = ((int64_t)st.st_ctime) * (MICRO_SEC_IN_SEC_LL);
#else
box_time_t statusmodified = (((int64_t)st.st_ctimespec.tv_nsec) / NANO_SEC_IN_USEC_LL)
@@ -40,7 +40,7 @@ inline box_time_t FileAttrModificationTime(struct stat &st)
inline box_time_t FileModificationTimeMaxModAndAttr(struct stat &st)
{
-#ifdef PLATFORM_stat_SHORT_mtime
+#ifndef HAVE_STRUCT_STAT_ST_MTIMESPEC
box_time_t datamodified = ((int64_t)st.st_mtime) * (MICRO_SEC_IN_SEC_LL);
box_time_t statusmodified = ((int64_t)st.st_ctime) * (MICRO_SEC_IN_SEC_LL);
#else
diff --git a/lib/common/LinuxWorkaround.cpp b/lib/common/LinuxWorkaround.cpp
deleted file mode 100755
index 7900fa6e..00000000
--- a/lib/common/LinuxWorkaround.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-// --------------------------------------------------------------------------
-//
-// File
-// Name: LinuxWorkaround.cpp
-// Purpose: Workarounds for Linux
-// Created: 2003/10/31
-//
-// --------------------------------------------------------------------------
-
-#include "Box.h"
-
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <string>
-
-#include "LinuxWorkaround.h"
-#include "CommonException.h"
-
-#include "MemLeakFindOn.h"
-
-#ifdef PLATFORM_LINUX
-
-// --------------------------------------------------------------------------
-//
-// Function
-// Name: LinuxWorkaround_FinishDirentStruct(struct dirent *, const char *)
-// Purpose: Finishes off filling in a dirent structure, which Linux leaves incomplete.
-// Created: 2003/10/31
-//
-// --------------------------------------------------------------------------
-void LinuxWorkaround_FinishDirentStruct(struct dirent *entry, const char *DirectoryName)
-{
- // From man readdir under Linux:
- //
- // BUGS
- // Field d_type is not implemented as of libc6 2.1 and will always return
- // DT_UNKNOWN (0).
- //
- // What kind of an OS is this?
-
-
- // Build filename of this entry
- std::string fn(DirectoryName);
- fn += '/';
- fn += entry->d_name;
-
- // Do a stat on it
- struct stat st;
- if(::lstat(fn.c_str(), &st) != 0)
- {
- THROW_EXCEPTION(CommonException, OSFileError)
- }
-
- // Fill in the d_type field.
- if(S_ISREG(st.st_mode))
- {
- entry->d_type = DT_REG;
- }
- else if(S_ISDIR(st.st_mode))
- {
- entry->d_type = DT_DIR;
- }
- else if(S_ISLNK(st.st_mode))
- {
- entry->d_type = DT_LNK;
- }
- // otherwise leave it as we found it
-}
-
-#endif // PLATFORM_LINUX
-
diff --git a/lib/common/LinuxWorkaround.h b/lib/common/LinuxWorkaround.h
deleted file mode 100755
index bcd27495..00000000
--- a/lib/common/LinuxWorkaround.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// --------------------------------------------------------------------------
-//
-// File
-// Name: LinuxWorkaround.h
-// Purpose: Workarounds for Linux
-// Created: 2003/10/31
-//
-// --------------------------------------------------------------------------
-
-#ifndef LINUXWORKAROUND__H
-#define LINUXWORKAROUND__H
-
-#ifdef PLATFORM_LINUX
-
-void LinuxWorkaround_FinishDirentStruct(struct dirent *entry, const char *DirectoryName);
-
-#endif // PLATFORM_LINUX
-
-#endif // LINUXWORKAROUND__H
-
diff --git a/lib/common/NamedLock.cpp b/lib/common/NamedLock.cpp
index 8953db89..b9aeb768 100755
--- a/lib/common/NamedLock.cpp
+++ b/lib/common/NamedLock.cpp
@@ -12,9 +12,9 @@
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
-#ifdef PLATFORM_open_USE_flock
+#ifdef HAVE_FLOCK
#include <sys/file.h>
-#endif // PLATFORM_open_USE_flock
+#endif
#include "NamedLock.h"
#include "CommonException.h"
@@ -68,14 +68,31 @@ bool NamedLock::TryAndGetLock(const char *Filename, int mode)
}
// See if the lock can be got
-#if defined(PLATFORM_open_USE_flock) || defined(PLATFORM_open_USE_fcntl)
+#if HAVE_DECL_O_EXLOCK
+ int fd = ::open(Filename, O_WRONLY | O_NONBLOCK | O_CREAT | O_TRUNC | O_EXLOCK, mode);
+ if(fd != -1)
+ {
+ // Got a lock, lovely
+ mFileDescriptor = fd;
+ return true;
+ }
+
+ // Failed. Why?
+ if(errno != EWOULDBLOCK)
+ {
+ // Not the expected error
+ THROW_EXCEPTION(CommonException, OSFileError)
+ }
+
+ return false;
+#else
int fd = ::open(Filename, O_WRONLY | O_CREAT | O_TRUNC, mode);
if(fd == -1)
{
THROW_EXCEPTION(CommonException, OSFileError)
}
-#ifdef PLATFORM_open_USE_flock
+#ifdef HAVE_FLOCK
if(::flock(fd, LOCK_EX | LOCK_NB) != 0)
{
::close(fd);
@@ -112,23 +129,6 @@ bool NamedLock::TryAndGetLock(const char *Filename, int mode)
mFileDescriptor = fd;
return true;
-#else
- int fd = ::open(Filename, O_WRONLY | O_NONBLOCK | O_CREAT | O_TRUNC | O_EXLOCK, mode);
- if(fd != -1)
- {
- // Got a lock, lovely
- mFileDescriptor = fd;
- return true;
- }
-
- // Failed. Why?
- if(errno != EWOULDBLOCK)
- {
- // Not the expected error
- THROW_EXCEPTION(CommonException, OSFileError)
- }
-
- return false;
#endif
}
diff --git a/lib/common/TemporaryDirectory.h b/lib/common/TemporaryDirectory.h
index 62010f79..e683863b 100755
--- a/lib/common/TemporaryDirectory.h
+++ b/lib/common/TemporaryDirectory.h
@@ -12,11 +12,11 @@
#include <string>
-#ifdef PLATFORM_STATIC_TEMP_DIRECTORY_NAME
+#ifdef TEMP_DIRECTORY_NAME
// Prefix name with Box to avoid clashing with OS API names
inline std::string BoxGetTemporaryDirectoryName()
{
- return std::string(PLATFORM_STATIC_TEMP_DIRECTORY_NAME);
+ return std::string(TEMP_DIRECTORY_NAME);
}
#else
non-static temporary directory names not supported yet
diff --git a/lib/common/WaitForEvent.cpp b/lib/common/WaitForEvent.cpp
index e9ee58d2..c552bb12 100644
--- a/lib/common/WaitForEvent.cpp
+++ b/lib/common/WaitForEvent.cpp
@@ -25,7 +25,7 @@
// Created: 9/3/04
//
// --------------------------------------------------------------------------
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
WaitForEvent::WaitForEvent(int Timeout)
: mKQueue(::kqueue()),
mpTimeout(0)
@@ -56,7 +56,7 @@ WaitForEvent::WaitForEvent(int Timeout)
// --------------------------------------------------------------------------
WaitForEvent::~WaitForEvent()
{
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
::close(mKQueue);
mKQueue = -1;
#else
@@ -79,7 +79,7 @@ WaitForEvent::~WaitForEvent()
// --------------------------------------------------------------------------
void WaitForEvent::SetTimeout(int Timeout)
{
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
// Generate timeout
if(Timeout != TimeoutInfinite)
{
@@ -106,7 +106,7 @@ void WaitForEvent::SetTimeout(int Timeout)
// --------------------------------------------------------------------------
void *WaitForEvent::Wait()
{
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
// Event return structure
struct kevent e;
::memset(&e, 0, sizeof(e));
diff --git a/lib/common/WaitForEvent.h b/lib/common/WaitForEvent.h
index b8f79da6..46f152c5 100644
--- a/lib/common/WaitForEvent.h
+++ b/lib/common/WaitForEvent.h
@@ -10,7 +10,7 @@
#ifndef WAITFOREVENT__H
#define WAITFOREVENT__H
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
#include <sys/event.h>
#include <sys/time.h>
#else
@@ -42,7 +42,7 @@ public:
void *Wait();
-#ifdef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifndef HAVE_KQUEUE
typedef struct
{
int fd;
@@ -63,7 +63,7 @@ public:
void Add(const T *pItem, int Flags = 0)
{
ASSERT(pItem != 0);
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
struct kevent e;
pItem->FillInKEvent(e, Flags);
// Fill in extra flags to say what to do
@@ -100,7 +100,7 @@ public:
void Remove(const T *pItem, int Flags = 0)
{
ASSERT(pItem != 0);
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
struct kevent e;
pItem->FillInKEvent(e, Flags);
// Fill in extra flags to say what to do
@@ -128,7 +128,7 @@ public:
}
private:
-#ifndef PLATFORM_KQUEUE_NOT_SUPPORTED
+#ifdef HAVE_KQUEUE
int mKQueue;
struct timespec mTimeout;
struct timespec *mpTimeout;