summaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
authorBen Summers <ben@fluffy.co.uk>2006-02-13 13:30:21 +0000
committerBen Summers <ben@fluffy.co.uk>2006-02-13 13:30:21 +0000
commit830aa82e44381c85d8486e46de7ae0e26830457e (patch)
treef29edb3c3013990a3ae758e1ccfdb56a2d20923f /lib/common
parent2edd0a00e3244cc4dbc369d81ed1748768a06fb8 (diff)
Merge chris/win32/vc2005-compile-fixes @ r455, add infrastructure/msvc to distribution
Diffstat (limited to 'lib/common')
-rw-r--r--lib/common/BoxPlatform.h10
-rw-r--r--lib/common/DebugMemLeakFinder.cpp17
-rw-r--r--lib/common/EventWatchFilesystemObject.cpp5
-rw-r--r--lib/common/ExcludeList.cpp10
-rw-r--r--lib/common/FdGetLine.cpp19
-rw-r--r--lib/common/FileStream.h5
-rw-r--r--lib/common/Guards.h5
-rw-r--r--lib/common/NamedLock.cpp6
-rw-r--r--lib/common/Test.h5
-rw-r--r--lib/common/UnixUser.cpp8
-rw-r--r--lib/common/WaitForEvent.cpp5
11 files changed, 69 insertions, 26 deletions
diff --git a/lib/common/BoxPlatform.h b/lib/common/BoxPlatform.h
index 58a5fdae..b7a72da9 100644
--- a/lib/common/BoxPlatform.h
+++ b/lib/common/BoxPlatform.h
@@ -87,13 +87,11 @@
typedef unsigned __int32 u_int32_t;
typedef unsigned __int64 u_int64_t;
- #define HAVE_UINT8_T
- #define HAVE_UINT16_T
- #define HAVE_UINT32_T
- #define HAVE_UINT64_T
+ #define HAVE_U_INT8_T
+ #define HAVE_U_INT16_T
+ #define HAVE_U_INT32_T
+ #define HAVE_U_INT64_T
- typedef unsigned int uid_t;
- typedef unsigned int gid_t;
typedef int pid_t;
#endif // WIN32 && !__MINGW32__
diff --git a/lib/common/DebugMemLeakFinder.cpp b/lib/common/DebugMemLeakFinder.cpp
index 6c7fd3eb..17a20a6d 100644
--- a/lib/common/DebugMemLeakFinder.cpp
+++ b/lib/common/DebugMemLeakFinder.cpp
@@ -16,8 +16,11 @@
#undef realloc
#undef free
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
+
#include <map>
-#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <set>
@@ -220,12 +223,12 @@ void memleakfinder_traceblocksinsection()
}
else
{
- TRACE4("Block 0x%08lx size %d allocated at %s:%d\n", (long)i->first, i->second.size, i->second.file, i->second.line);
+ TRACE4("Block 0x%08p size %d allocated at %s:%d\n", i->first, i->second.size, i->second.file, i->second.line);
}
}
for(std::map<void *, ObjectInfo>::const_iterator i(sSectionObjectBlocks.begin()); i != sSectionObjectBlocks.end(); ++i)
{
- TRACE5("Object%s 0x%08lx size %d allocated at %s:%d\n", i->second.array?" []":"", (long)i->first, i->second.size, i->second.file, i->second.line);
+ TRACE5("Object%s 0x%08p size %d allocated at %s:%d\n", i->second.array?" []":"", i->first, i->second.size, i->second.file, i->second.line);
}
}
@@ -250,11 +253,11 @@ void memleakfinder_reportleaks_file(FILE *file)
{
for(std::map<void *, MallocBlockInfo>::const_iterator i(sMallocBlocks.begin()); i != sMallocBlocks.end(); ++i)
{
- if(is_leak(i->first)) ::fprintf(file, "Block 0x%08lx size %d allocated at %s:%d\n", (long)i->first, i->second.size, i->second.file, i->second.line);
+ if(is_leak(i->first)) ::fprintf(file, "Block 0x%08p size %d allocated at %s:%d\n", i->first, i->second.size, i->second.file, i->second.line);
}
for(std::map<void *, ObjectInfo>::const_iterator i(sObjectBlocks.begin()); i != sObjectBlocks.end(); ++i)
{
- if(is_leak(i->first)) ::fprintf(file, "Object%s 0x%08lx size %d allocated at %s:%d\n", i->second.array?" []":"", (long)i->first, i->second.size, i->second.file, i->second.line);
+ if(is_leak(i->first)) ::fprintf(file, "Object%s 0x%08p size %d allocated at %s:%d\n", i->second.array?" []":"", i->first, i->second.size, i->second.file, i->second.line);
}
}
@@ -271,7 +274,11 @@ void memleakfinder_reportleaks_appendfile(const char *filename, const char *mark
{
if(memleakfinder_numleaks() > 0)
{
+#ifdef HAVE_GETPID
fprintf(file, "MEMORY LEAKS FROM PROCESS %d (%s)\n", getpid(), markertext);
+#else
+ fprintf(file, "MEMORY LEAKS (%s)\n", markertext);
+#endif
memleakfinder_reportleaks_file(file);
}
diff --git a/lib/common/EventWatchFilesystemObject.cpp b/lib/common/EventWatchFilesystemObject.cpp
index c3fe11f8..a9508c22 100644
--- a/lib/common/EventWatchFilesystemObject.cpp
+++ b/lib/common/EventWatchFilesystemObject.cpp
@@ -10,7 +10,10 @@
#include "Box.h"
#include <fcntl.h>
-#include <unistd.h>
+
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
#include "EventWatchFilesystemObject.h"
#include "autogen_CommonException.h"
diff --git a/lib/common/ExcludeList.cpp b/lib/common/ExcludeList.cpp
index 9b2e3acb..43991594 100644
--- a/lib/common/ExcludeList.cpp
+++ b/lib/common/ExcludeList.cpp
@@ -232,7 +232,7 @@ void ExcludeList::Deserialize(Archive & rArchive)
//
mDefinite.clear();
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
// free regex memory
while(mRegex.size() > 0)
{
@@ -273,7 +273,7 @@ void ExcludeList::Deserialize(Archive & rArchive)
//
//
//
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
rArchive.Read(iCount);
if (iCount > 0)
@@ -310,7 +310,7 @@ void ExcludeList::Deserialize(Archive & rArchive)
}
}
}
-#endif // PLATFORM_REGEX_NOT_SUPPORTED
+#endif // HAVE_REGEX_H
//
//
@@ -365,7 +365,7 @@ void ExcludeList::Serialize(Archive & rArchive) const
//
//
//
-#ifndef PLATFORM_REGEX_NOT_SUPPORTED
+#ifdef HAVE_REGEX_H
// don't even try to save compiled regular expressions,
// use string copies instead.
ASSERT(mRegex.size() == mRegexStr.size());
@@ -378,7 +378,7 @@ void ExcludeList::Serialize(Archive & rArchive) const
{
rArchive.Write(*i);
}
-#endif // PLATFORM_REGEX_NOT_SUPPORTED
+#endif // HAVE_REGEX_H
//
//
diff --git a/lib/common/FdGetLine.cpp b/lib/common/FdGetLine.cpp
index dee02604..9b53288b 100644
--- a/lib/common/FdGetLine.cpp
+++ b/lib/common/FdGetLine.cpp
@@ -10,7 +10,10 @@
#include "Box.h"
#include <sys/types.h>
-#include <unistd.h>
+
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
#include "FdGetLine.h"
#include "CommonException.h"
@@ -117,7 +120,21 @@ std::string FdGetLine::GetLine(bool Preprocess)
// Read more in?
if(!foundLineEnd && mBufferBegin >= mBytesInBuffer && !mPendingEOF)
{
+#ifdef WIN32
+ int bytes;
+
+ if (mFileHandle == _fileno(stdin))
+ {
+ bytes = console_read(mBuffer, sizeof(mBuffer));
+ }
+ else
+ {
+ bytes = ::read(mFileHandle, mBuffer,
+ sizeof(mBuffer));
+ }
+#else // !WIN32
int bytes = ::read(mFileHandle, mBuffer, sizeof(mBuffer));
+#endif // WIN32
// Error?
if(bytes == -1)
diff --git a/lib/common/FileStream.h b/lib/common/FileStream.h
index 7d677636..7a4a29f3 100644
--- a/lib/common/FileStream.h
+++ b/lib/common/FileStream.h
@@ -15,7 +15,10 @@
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
-#include <unistd.h>
+
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
#ifdef WIN32
#define INVALID_FILE NULL
diff --git a/lib/common/Guards.h b/lib/common/Guards.h
index 6efc5614..17d73b3f 100644
--- a/lib/common/Guards.h
+++ b/lib/common/Guards.h
@@ -11,10 +11,13 @@
#ifndef GUARDS__H
#define GUARDS__H
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
+
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
-#include <unistd.h>
#include <new>
#include "CommonException.h"
diff --git a/lib/common/NamedLock.cpp b/lib/common/NamedLock.cpp
index fc7b8309..2418c60c 100644
--- a/lib/common/NamedLock.cpp
+++ b/lib/common/NamedLock.cpp
@@ -11,7 +11,11 @@
#include <fcntl.h>
#include <errno.h>
-#include <unistd.h>
+
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
+
#ifdef HAVE_FLOCK
#include <sys/file.h>
#endif
diff --git a/lib/common/Test.h b/lib/common/Test.h
index 472f6342..8bac6036 100644
--- a/lib/common/Test.h
+++ b/lib/common/Test.h
@@ -14,7 +14,10 @@
#include <sys/stat.h>
#include <stdlib.h>
#include <signal.h>
-#include <unistd.h>
+
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
#include <stdio.h>
diff --git a/lib/common/UnixUser.cpp b/lib/common/UnixUser.cpp
index 8b85c3e1..df2d0ddd 100644
--- a/lib/common/UnixUser.cpp
+++ b/lib/common/UnixUser.cpp
@@ -9,11 +9,13 @@
#include "Box.h"
-#ifndef WIN32
-#include <pwd.h>
+#ifdef HAVE_PWD_H
+ #include <pwd.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
#include "UnixUser.h"
#include "CommonException.h"
diff --git a/lib/common/WaitForEvent.cpp b/lib/common/WaitForEvent.cpp
index c552bb12..5646bfbf 100644
--- a/lib/common/WaitForEvent.cpp
+++ b/lib/common/WaitForEvent.cpp
@@ -9,7 +9,10 @@
#include "Box.h"
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+#endif
+
#include <errno.h>
#include <string.h>