Skip to content

Commit

Permalink
make some windows compat fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
novas0x2a committed Feb 11, 2009
1 parent dd35e08 commit 8879c42
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 14 deletions.
4 changes: 3 additions & 1 deletion INSTALLGUIDE
Expand Up @@ -127,7 +127,9 @@ configure your project's include file and library search paths
appropriately. Also be sure to configure your project to define the
preprocessor symbol "NOMINMAX" to disable the non-portable Windows
definitions of min() and max() macros, which interfere with the
standard C++ library functions of the same names.
standard C++ library functions of the same names. In addition, you
will need to define the preprocessor symbol "_USE_MATH_DEFINES" to
ensure that math.h defines constants such as M_PI.


Configuring the Build System
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Expand Up @@ -86,6 +86,10 @@ AX_COMMON_OPTIONS
# Does the compiler support introspection?
AX_CHECK_INTROSPECTION

# Looking for posix headers
AC_CHECK_HEADERS([unistd.h pwd.h])
AC_CHECK_FUNCS([getpwuid getpid])

# Look for the python stuff
AM_PATH_PYTHON([2.4], [HAVE_PYTHON=yes], [HAVE_PYTHON=no])
AC_PYTHON_DEVEL([HAVE_PYTHON=yes], [HAVE_PYTHON=no])
Expand Down
32 changes: 25 additions & 7 deletions src/vw/Core/Log.cc
Expand Up @@ -37,8 +37,21 @@
// C Standard Library headers ( for stat(2) and getpwuid() )
#include <sys/types.h>
#include <sys/stat.h>

#ifdef VW_HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifdef VW_HAVE_PWD_H
#include <pwd.h>
#endif

#ifdef WIN32
#define stat _stat
typedef struct _stat struct_stat;
#else
typedef struct stat struct_stat;
#endif


// Posix time is not fully supported in the version of Boost for RHEL
Expand Down Expand Up @@ -205,16 +218,16 @@ void vw::Log::stat_logconf() {

// Check to see if the file has changed. If so, re-read the
// settings.
struct stat stat_struct;
if (stat(m_logconf_filename.c_str(), &stat_struct) == 0) {
struct_stat statbuf;
if (stat(m_logconf_filename.c_str(), &statbuf) == 0) {
#ifdef __APPLE__
if (stat_struct.st_mtimespec.tv_sec > m_logconf_last_modification) {
m_logconf_last_modification = stat_struct.st_mtimespec.tv_sec;
if (statbuf.st_mtimespec.tv_sec > m_logconf_last_modification) {
m_logconf_last_modification = statbuf.st_mtimespec.tv_sec;
reload_logconf_rules();
}
#else // Linux
if (stat_struct.st_mtime > m_logconf_last_modification) {
m_logconf_last_modification = stat_struct.st_mtime;
if (statbuf.st_mtime > m_logconf_last_modification) {
m_logconf_last_modification = statbuf.st_mtime;
reload_logconf_rules();
}
#endif
Expand All @@ -224,9 +237,14 @@ void vw::Log::stat_logconf() {
}

void vw::Log::set_default_logconf_filename() {
std::string homedir;
#ifdef VW_HAVE_GETPWUID
struct passwd *pw;
pw = getpwuid( getuid() );
std::string homedir = pw->pw_dir;
homedir = pw->pw_dir;
#endif
if (homedir.empty())
homedir = getenv("HOME");
m_logconf_filename = homedir + "/.vw_logconf";
}

Expand Down
13 changes: 10 additions & 3 deletions src/vw/Core/TerminationHandler.cc
@@ -1,6 +1,5 @@
#include <cstdio>
#include <stdexcept>
#include <unistd.h>
#include <cstdlib>

#include <typeinfo>
Expand All @@ -20,6 +19,10 @@
#include <dlfcn.h>
#endif

#ifdef VW_HAVE_UNISTD_H
#include <unistd.h>
#endif

#include "TerminationHandler.h"


Expand Down Expand Up @@ -52,9 +55,13 @@ void vw_terminate()

if (current)
current();
fprintf(stderr, "terminate() called! If you'd like to connect gdb to this process, use:\n");

fprintf(stderr, "terminate() called! You can attach a debugger.");
#ifdef VW_HAVE_GETPID
fprintf(stderr, "If you'd like to connect gdb to this process, use:\n");
fprintf(stderr, "gdb ignored %d\n", getpid());
fprintf(stderr, "Press 'enter' to abort...\n");
#endif
fprintf(stderr, "or press 'enter' to abort...\n");
// It's probably not safe to getchar here, but, given where we are,
// we can't really make it worse...
getchar();
Expand Down
2 changes: 1 addition & 1 deletion src/vw/Core/Thread.h
Expand Up @@ -289,7 +289,7 @@ namespace vw {
xt.sec++;
milliseconds -= 1000;
}
xt.nsec+=int_fast32_t(1e6*milliseconds);
xt.nsec+=boost::int_fast32_t(1e6*milliseconds);
boost::thread::sleep(xt);
}
};
Expand Down
7 changes: 6 additions & 1 deletion src/vw/FileIO/JP2.h
Expand Up @@ -31,7 +31,12 @@
#include <list>
#include <iostream>

#include <arpa/inet.h> // ntohl, htonl
// ntohl, htonl
#ifdef WIN32
#include <winsock2.h>
#else
#include <arpa/inet.h>
#endif

#include <boost/algorithm/string.hpp>

Expand Down
2 changes: 1 addition & 1 deletion src/vw/Image/PixelTypeInfo.h
Expand Up @@ -446,7 +446,7 @@ namespace vw {
template <class ChannelT> class PixelLab;

// Forward pixel type declarations for the pixel mask wrapper
template <class ChildT> class PixelMask;
template <class ChildT> struct PixelMask;

// *******************************************************************
// Run-time pixel type manipulation routines.
Expand Down

0 comments on commit 8879c42

Please sign in to comment.