From 350ed31655b00f3043e5d723606cdd50099fa91b Mon Sep 17 00:00:00 2001 From: John Emmas Date: Wed, 17 Jul 2013 08:08:46 +0100 Subject: [PATCH] Remaining changes needed for building libpdb on Windows (except for adding the extra JE source modules) --- libs/pbd/base_ui.cc | 10 +++++----- libs/pbd/file_utils.cc | 6 +++--- libs/pbd/mountpoint.cc | 2 +- libs/pbd/pbd/base_ui.h | 4 ++-- libs/pbd/pbd/ringbuffer.h | 4 ++-- libs/pbd/pbd/semaphore.h | 6 +++--- libs/pbd/pbd/semutils.h | 6 +++--- libs/pbd/resource.cc | 4 ++-- libs/pbd/search_path.cc | 2 +- libs/pbd/semutils.cc | 6 +++--- libs/pbd/test/filesystem_test.cc | 2 +- libs/pbd/test/test_common.cc | 2 +- libs/pbd/transmitter.cc | 10 ++++++++-- libs/pbd/uuid.cc | 8 +++----- libs/pbd/xml++.cc | 2 ++ 15 files changed, 40 insertions(+), 34 deletions(-) diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index 4bd3d23514..3a4257ebdd 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -51,13 +51,13 @@ BaseUI::BaseUI (const string& str) : m_context(MainContext::get_default()) , run_loop_thread (0) , _name (str) -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS , request_channel (true) #endif { base_ui_instance = this; -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS request_channel.ios()->connect (sigc::mem_fun (*this, &BaseUI::request_handler)); #endif @@ -124,7 +124,7 @@ BaseUI::quit () } } -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS gboolean BaseUI::_request_handler (gpointer data) { @@ -172,7 +172,7 @@ void BaseUI::signal_new_request () { DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::signal_new_request\n"); -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS // handled in timeout, how to signal...? #else request_channel.wakeup (); @@ -186,7 +186,7 @@ void BaseUI::attach_request_source () { DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::attach_request_source\n"); -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS GSource* request_source = g_timeout_source_new(200); g_source_set_callback (request_source, &BaseUI::_request_handler, this, NULL); g_source_attach (request_source, m_context->gobj()); diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index 311a3948ef..03c3ea853c 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -192,9 +192,9 @@ get_absolute_path (const std::string & p) bool equivalent_paths (const std::string& a, const std::string& b) { - struct stat bA; + GStatBuf bA; int const rA = g_stat (a.c_str(), &bA); - struct stat bB; + GStatBuf bB; int const rB = g_stat (b.c_str(), &bB); return (rA == 0 && rB == 0 && bA.st_dev == bB.st_dev && bA.st_ino == bB.st_ino); @@ -225,7 +225,7 @@ exists_and_writable (const std::string & p) make us unwritable. */ - struct stat statbuf; + GStatBuf statbuf; if (g_stat (p.c_str(), &statbuf) != 0) { /* doesn't exist - not writable */ diff --git a/libs/pbd/mountpoint.cc b/libs/pbd/mountpoint.cc index 9c05f05ad6..65f011c745 100644 --- a/libs/pbd/mountpoint.cc +++ b/libs/pbd/mountpoint.cc @@ -94,7 +94,7 @@ mountpoint (string path) return best; } -#elif defined(WIN32) +#elif defined(PLATFORM_WINDOWS) string mountpoint (string path) diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h index 686af485e6..d947a06b34 100644 --- a/libs/pbd/pbd/base_ui.h +++ b/libs/pbd/pbd/base_ui.h @@ -92,7 +92,7 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop virtual void thread_init () {}; -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS static gboolean _request_handler (gpointer); bool request_handler (); #else @@ -114,7 +114,7 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop std::string _name; BaseUI* base_ui_instance; -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS CrossThreadChannel request_channel; #endif diff --git a/libs/pbd/pbd/ringbuffer.h b/libs/pbd/pbd/ringbuffer.h index f14fa71851..a1a6151542 100644 --- a/libs/pbd/pbd/ringbuffer.h +++ b/libs/pbd/pbd/ringbuffer.h @@ -198,7 +198,7 @@ RingBuffer::write (T const *src, guint cnt) } template void -RingBuffer::get_read_vector (RingBuffer::rw_vector *vec) +RingBuffer::get_read_vector (typename RingBuffer::rw_vector *vec) { guint free_cnt; @@ -238,7 +238,7 @@ RingBuffer::get_read_vector (RingBuffer::rw_vector *vec) } template void -RingBuffer::get_write_vector (RingBuffer::rw_vector *vec) +RingBuffer::get_write_vector (typename RingBuffer::rw_vector *vec) { guint free_cnt; diff --git a/libs/pbd/pbd/semaphore.h b/libs/pbd/pbd/semaphore.h index 81c4057e6a..5f0a2df2c0 100644 --- a/libs/pbd/pbd/semaphore.h +++ b/libs/pbd/pbd/semaphore.h @@ -69,7 +69,7 @@ public: private: #if defined(__APPLE__) semaphore_t _sem; // sem_t is a worthless broken mess on OSX -#elif defined(_WIN32) +#elif defined(PLATFORM_WINDOWS) HANDLE _sem; // types are overrated anyway #else sem_t _sem; @@ -114,7 +114,7 @@ Semaphore::try_wait() return semaphore_timedwait(_sem, zero) == KERN_SUCCESS; } -#elif defined(_WIN32) +#elif defined(PLATFORM_WINDOWS) inline Semaphore::Semaphore(unsigned initial) @@ -151,7 +151,7 @@ Semaphore::try_wait() return WaitForSingleObject(_sem, 0) == WAIT_OBJECT_0; } -#else /* !defined(__APPLE__) && !defined(_WIN32) */ +#else /* !defined(__APPLE__) && !defined(PLATFORM_WINDOWS) */ Semaphore::Semaphore(unsigned initial) { diff --git a/libs/pbd/pbd/semutils.h b/libs/pbd/pbd/semutils.h index 0e8bed0512..af5c201b85 100644 --- a/libs/pbd/pbd/semutils.h +++ b/libs/pbd/pbd/semutils.h @@ -19,7 +19,7 @@ #ifndef __pbd_semutils_h__ #define __pbd_semutils_h__ -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS #include #else #include @@ -29,7 +29,7 @@ namespace PBD { class ProcessSemaphore { private: -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS HANDLE _sem; #elif __APPLE__ @@ -44,7 +44,7 @@ class ProcessSemaphore { ProcessSemaphore (const char* name, int val); ~ProcessSemaphore (); -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS int signal (); int wait (); diff --git a/libs/pbd/resource.cc b/libs/pbd/resource.cc index 5ee6f6dc88..9d6f8b1746 100644 --- a/libs/pbd/resource.cc +++ b/libs/pbd/resource.cc @@ -33,7 +33,7 @@ get_resource_limit (ResourceType resource, ResourceLimit& limit) { if (resource == OpenFiles) { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS limit.current_limit = _getmaxstdio(); limit.max_limit = 2048; return true; @@ -55,7 +55,7 @@ set_resource_limit (ResourceType resource, const ResourceLimit& limit) { if (resource == OpenFiles) { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS // no soft and hard limits on windows rlimit_t new_max = _setmaxstdio(limit.current_limit); diff --git a/libs/pbd/search_path.cc b/libs/pbd/search_path.cc index 3f7be5aa56..e56e22fee3 100644 --- a/libs/pbd/search_path.cc +++ b/libs/pbd/search_path.cc @@ -27,7 +27,7 @@ using namespace std; namespace { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS const char * const path_delimiter = ";"; #else const char * const path_delimiter = ":"; diff --git a/libs/pbd/semutils.cc b/libs/pbd/semutils.cc index e5df2e5c44..e5e5898218 100644 --- a/libs/pbd/semutils.cc +++ b/libs/pbd/semutils.cc @@ -23,7 +23,7 @@ using namespace PBD; ProcessSemaphore::ProcessSemaphore (const char* name, int val) { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS if ((_sem = CreateSemaphore(NULL, val, 32767, name)) == NULL) { throw failed_constructor (); } @@ -48,14 +48,14 @@ ProcessSemaphore::ProcessSemaphore (const char* name, int val) ProcessSemaphore::~ProcessSemaphore () { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS CloseHandle(_sem); #elif __APPLE__ sem_close (ptr_to_sem()); #endif } -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS int ProcessSemaphore::signal () diff --git a/libs/pbd/test/filesystem_test.cc b/libs/pbd/test/filesystem_test.cc index 0cbe5baf32..458105d177 100644 --- a/libs/pbd/test/filesystem_test.cc +++ b/libs/pbd/test/filesystem_test.cc @@ -10,7 +10,7 @@ CPPUNIT_TEST_SUITE_REGISTRATION (FilesystemTest); void FilesystemTest::testPathIsWithin () { -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS system ("rm -r foo"); CPPUNIT_ASSERT (g_mkdir_with_parents ("foo/bar/baz", 0755) == 0); diff --git a/libs/pbd/test/test_common.cc b/libs/pbd/test/test_common.cc index 16da3ed2a8..397a69ad8c 100644 --- a/libs/pbd/test/test_common.cc +++ b/libs/pbd/test/test_common.cc @@ -28,7 +28,7 @@ PBD::SearchPath test_search_path () { -#ifdef WIN32 +#ifdef PLATFORM_WINDOWS std::string wsp(g_win32_get_package_installation_directory_of_module(NULL)); return Glib::build_filename (wsp, "pbd_testdata"); #else diff --git a/libs/pbd/transmitter.cc b/libs/pbd/transmitter.cc index a172ac457d..e4266d34d7 100644 --- a/libs/pbd/transmitter.cc +++ b/libs/pbd/transmitter.cc @@ -84,14 +84,20 @@ Transmitter::deliver () /* do the right thing if this should not return */ if (does_not_return()) { -#ifndef WIN32 +#ifndef PLATFORM_WINDOWS +// TODO !!!! Commented out temporarily (for Windows) sigset_t mask; sigemptyset (&mask); sigsuspend (&mask); -#endif /*NOTREACHED*/ exit (1); +/* JE - From what I can tell, the above code suspends + * program execution until (any) signal occurs. Not + * sure at the moment what this achieves, unless it + * provides some time for the user to see the message. + */ +#endif } } diff --git a/libs/pbd/uuid.cc b/libs/pbd/uuid.cc index 1a988b9820..8b55ab3381 100644 --- a/libs/pbd/uuid.cc +++ b/libs/pbd/uuid.cc @@ -20,10 +20,8 @@ #include "pbd/uuid.h" -using namespace PBD; - -UUID& -UUID::operator= (std::string const & str) +PBD::UUID& +PBD::UUID::operator= (std::string const & str) { boost::uuids::string_generator gen; *((boost::uuids::uuid*) this) = gen (str); @@ -31,7 +29,7 @@ UUID::operator= (std::string const & str) } std::string -UUID::to_s () const +PBD::UUID::to_s () const { return std::string ((const char*) data, size()); } diff --git a/libs/pbd/xml++.cc b/libs/pbd/xml++.cc index a1fa77db66..69187995a1 100644 --- a/libs/pbd/xml++.cc +++ b/libs/pbd/xml++.cc @@ -167,6 +167,7 @@ XMLTree::write() const void XMLTree::debug(FILE* out) const { +#ifdef LIBXML_DEBUG_ENABLED xmlDocPtr doc; XMLNodeList children; @@ -176,6 +177,7 @@ XMLTree::debug(FILE* out) const writenode(doc, _root, doc->children, 1); xmlDebugDumpDocument (out, doc); xmlFreeDoc(doc); +#endif } const string&