Permalink
Browse files

compile passes on win32 (but not linkable yet...)

git-svn-id: http://kazuho.31tools.com/svn/incline/trunk@264 4d3e2a30-9d6d-0410-bc8c-dac56cff10b3
  • Loading branch information...
1 parent 4fcb54d commit 35713538ebd5f0ae77424e04af2e2755c6a3afc1 kazuho committed Nov 6, 2009
View
@@ -13,6 +13,9 @@ extern "C" {
#include "incline_dbms.h"
#include "incline_driver_sharded.h"
#include "incline_mgr.h"
+#ifdef WIN32
+# include "incline_win32.h"
+#endif
using namespace std;
@@ -185,7 +188,10 @@ main(int argc, char** argv)
exit(3);
}
}
+#ifdef WIN32
+#else
signal(SIGHUP, shutdown_forwarder);
+#endif
signal(SIGTERM, shutdown_forwarder);
aq_driver()->run_forwarder(1, log_fh);
// TODO close log_fh
View
@@ -9,9 +9,8 @@
#ifdef WITH_PGSQL
# include "incline_pgsql.h"
#endif
-
-#ifdef _MSC_VER
-# pragma warning(disable : 4996) /* no warnings for vsprintf */
+#ifdef WIN32
+# include "incline_win32.h"
#endif
using namespace std;
@@ -1,6 +1,10 @@
+#ifdef WIN32
+# include <windows.h>
+#else
extern "C" {
-#include <sys/stat.h>
+# include <sys/stat.h>
}
+#endif
#include <cassert>
#include <fstream>
#include <sstream>
@@ -12,6 +16,9 @@ extern "C" {
#include "incline_fw_replicator.h"
#include "incline_mgr.h"
#include "incline_util.h"
+#ifdef WIN32
+# include "incline_win32.h"
+#endif
using namespace std;
@@ -167,7 +174,7 @@ namespace incline_driver_sharded_ns {
}
virtual incline_driver_sharded::connect_params
get_connect_params_for(const string& key) const {
- return connect_params_[str_to_key_type<long long>()(key)
+ return connect_params_[size_t(str_to_key_type<long long>()(key))
% connect_params_.size()];
}
virtual string build_expr_for(const string& column_expr, const string& host,
@@ -322,15 +329,30 @@ incline_driver_sharded::rule::should_exit_loop() const
return _get_file_mtime() != file_mtime_;
}
-time_t
+unsigned long long
incline_driver_sharded::rule::_get_file_mtime() const
{
+ if (file_.empty()) {
+ return 0;
+ }
+#ifdef WIN32
+ WIN32_FIND_DATAA fdata;
+ HANDLE fh = FindFirstFileA(file_.c_str(), &fdata);
+ if (fh == INVALID_HANDLE_VALUE) {
+ return 0;
+ }
+ FindClose(fh);
+ assert(fdata.ftLastWriteTime.dwHighDateTime != 0);
+ return (unsigned long long)fdata.ftLastWriteTime.dwHighDateTime << 32
+ | (unsigned long long)fdata.ftLastWriteTime.dwLowDateTime;
+#else
struct stat st;
- if (file_.empty() || lstat(file_.c_str(), &st) != 0) {
+ if (lstat(file_.c_str(), &st) != 0) {
return 0;
}
assert(st.st_mtime != 0); // we use mtime==0 to indicate error
return st.st_mtime;
+#endif
}
string
@@ -542,6 +564,7 @@ incline_driver_sharded::is_src_host_of(const incline_def_sharded* def) const
return rrl->source().host == cur_host_ && rrl->source().port == cur_port_;
}
assert(0);
+ return false;
}
bool
@@ -26,15 +26,15 @@ class incline_driver_sharded : public incline_driver_async_qtable {
class rule {
protected:
std::string file_;
- time_t file_mtime_;
+ unsigned long long file_mtime_;
public:
rule(const std::string& file) : file_(file), file_mtime_(_get_file_mtime()) {}
virtual ~rule() {}
std::string file() const { return file_; }
bool should_exit_loop() const;
protected:
virtual std::string parse(const picojson::value& def) = 0;
- time_t _get_file_mtime() const;
+ unsigned long long _get_file_mtime() const;
public:
static rule* parse(const std::string& file, std::string& err);
};
@@ -1,11 +1,11 @@
-#ifdef WIN32
-#include <windows.h>
-#endif
#include "incline_dbms.h"
#include "incline_def_async_qtable.h"
#include "incline_driver_async_qtable.h"
#include "incline_fw_async_qtable.h"
#include "incline_util.h"
+#ifdef WIN32
+# include "incline_win32.h"
+#endif
using namespace std;
@@ -44,11 +44,7 @@ incline_fw_async_qtable::do_run()
}
// sleep and retry if no data
if (iq_ids.empty()) {
-#ifdef WIN32
- Sleep(mgr()->poll_interval() * 1000);
-#else
sleep(mgr()->poll_interval());
-#endif
continue;
}
if (! extra_cond.empty()) {
@@ -4,6 +4,9 @@
#include "incline_fw_replicator.h"
#include "incline_mgr.h"
#include "start_thread.h"
+#ifdef WIN32
+# include "incline_win32.h"
+#endif
using namespace std;
@@ -171,6 +171,7 @@ incline_fw_sharded::manager::get_writer_for(const incline_def_sharded* def,
}
}
assert(0);
+ return NULL;
}
incline_fw_sharded::incline_fw_sharded(manager* mgr,
View
@@ -1,11 +1,8 @@
#include <cassert>
#include <cstdarg>
#include "incline_util.h"
-
-#ifdef _MSC_VER
-# define SNPRINTF _snprintf_s
-#else
-# define SNPRINTF snprintf
+#ifdef WIN32
+# include "incline_win32.h"
#endif
using namespace std;
@@ -68,7 +65,7 @@ incline_util::filter(const char* fmt, int idx, size_t n, ...)
r += repl[(size_t)(*fi - '1')];
} else if (*fi == 'I') {
char buf[16];
- SNPRINTF(buf, sizeof(buf), "%d", idx);
+ snprintf(buf, sizeof(buf), "%d", idx);
r += buf;
} else {
r.push_back(*fi);
View
@@ -43,7 +43,7 @@ extern "C" {
#include "cac/cac_mutex.h"
template <typename Handler, typename Request>
-struct interthr_call_t {
+class interthr_call_t {
public:
class call_info_t {
friend class interthr_call_t<Handler, Request>;
View
@@ -191,7 +191,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="src;C:\Program Files\MySQL\MySQL Server 5.1\include"
+ AdditionalIncludeDirectories="&quot;C:\Program Files\MySQL\MySQL Server 5.1\include&quot;;&quot;pthreads-win32\include&quot;;src"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;WITH_MYSQL"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -212,6 +212,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalDependencies="&quot;C:\Program Files\MySQL\MySQL Server 5.1\lib\debug\mysqlclient.lib&quot; pthreads-win32\lib\pthreadVC2.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
@@ -339,6 +340,10 @@
RelativePath="..\src\incline_util.cc"
>
</File>
+ <File
+ RelativePath=".\src\incline_win32.cc"
+ >
+ </File>
</Filter>
<Filter
Name="�w�b�_�[ �t�@�C��"
@@ -438,6 +443,10 @@
>
</File>
<File
+ RelativePath=".\src\incline_win32.h"
+ >
+ </File>
+ <File
RelativePath="..\src\interthr_call.h"
>
</File>
@@ -3,3 +3,11 @@
*
* Use project settings to define appropriate preprocessor macros.
*/
+
+#ifndef incline_config_h
+#define incline_config_h
+
+/* read configure.ac or find out some better way */
+#define VERSION "win32"
+
+#endif
@@ -0,0 +1,8 @@
+#include <windows.h>
+#include "incline_win32.h"
+
+void sleep(unsigned int seconds)
+{
+ // bare minimum :-p
+ Sleep(seconds * 1000);
+}
View
@@ -0,0 +1,11 @@
+#ifndef incline_win32_h
+#define incline_win32_h
+
+#ifdef _MSC_VER
+# pragma warning (disable : 4996)
+# define snprintf _snprintf_s
+#endif
+
+void sleep(unsigned int seconds);
+
+#endif

0 comments on commit 3571353

Please sign in to comment.