Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/libs/ardour/ardour/msvc_libardour.h b/libs/ardour/ardour/msvc_libardour.h
- index 06bbddf833..db0e5f5ba7 100644
- --- a/libs/ardour/ardour/msvc_libardour.h
- +++ b/libs/ardour/ardour/msvc_libardour.h
- @@ -50,7 +50,7 @@ extern "C" {
- #ifndef __THROW
- #define __THROW throw()
- #endif
- -#include <ardourext/sys/time.h>
- +#include <sys/time.h>
- namespace ARDOUR {
- diff --git a/libs/ardour/port_manager.cc b/libs/ardour/port_manager.cc
- index e5a160327e..d6b1f3f3ae 100644
- --- a/libs/ardour/port_manager.cc
- +++ b/libs/ardour/port_manager.cc
- @@ -22,7 +22,7 @@
- #include <vector>
- #ifdef COMPILER_MSVC
- -#include <ardourext/misc.h>
- +#include <pbd/compat.h>
- #include <io.h> // Microsoft's nearest equivalent to <unistd.h>
- #else
- #include <regex.h>
- diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc
- index b15a548cfa..30500c7ce8 100644
- --- a/libs/pbd/base_ui.cc
- +++ b/libs/pbd/base_ui.cc
- @@ -20,6 +20,25 @@
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- +#ifdef _WIN32
- +#define NOMINMAX
- +#define WIN32_LEAN_AND_MEAN
- +#define NOMSG
- +#define NOGDI
- +#define NOUSER
- +#define NOSERVICE
- +#define NOSOUND
- +#define NOMCX
- +#include <windows.h>
- +#ifdef ERROR
- +#undef ERROR
- +#endif
- +#ifdef NO_ERROR
- +#undef NO_ERROR
- +#endif
- +#endif
- +
- +
- #include <cstring>
- #include <stdint.h>
- #ifdef COMPILER_MSVC
- @@ -62,7 +81,6 @@ BaseUI::BaseUI (const string& loop_name)
- , request_channel (true)
- {
- base_ui_instance = this;
- - request_channel.set_receive_handler (sigc::mem_fun (*this, &BaseUI::request_handler));
- /* derived class must set _ok */
- }
- @@ -104,8 +122,8 @@ BaseUI::main_thread ()
- bool
- BaseUI::signal_running ()
- {
- - Glib::Threads::Mutex::Lock lm (_run_lock);
- - _running.signal ();
- + std::unique_lock<std::mutex> lm(_run_lock);
- + _running.notify_one();
- return false; // don't call it again
- }
- @@ -120,9 +138,9 @@ BaseUI::run ()
- _main_loop = MainLoop::create (m_context);
- attach_request_source ();
- - Glib::Threads::Mutex::Lock lm (_run_lock);
- + std::unique_lock<std::mutex> lm(_run_lock);
- _run_loop_thread = PBD::Thread::create (std::bind (&BaseUI::main_thread, this), string_compose ("UI:%1", event_loop_name ()));
- - _running.wait (_run_lock);
- + _running.wait(lm);
- }
- void
- @@ -139,7 +157,7 @@ BaseUI::request_handler (Glib::IOCondition ioc)
- {
- /* check the request pipe */
- - if (ioc & IO_IN) {
- + if (static_cast<int>(ioc) & static_cast<int>(Glib::IOCondition::IO_IN)) {
- request_channel.drain ();
- /* there may been an error. we'd rather handle requests first,
- @@ -152,7 +170,7 @@ BaseUI::request_handler (Glib::IOCondition ioc)
- handle_ui_requests ();
- }
- - if (ioc & ~(IO_IN|IO_PRI)) {
- + if (static_cast<int>(ioc) & ~(static_cast<int>(Glib::IOCondition::IO_IN)|static_cast<int>(Glib::IOCondition::IO_PRI))) {
- _main_loop->quit ();
- }
- @@ -175,6 +193,7 @@ void
- BaseUI::attach_request_source ()
- {
- DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: attach request source\n", event_loop_name()));
- + request_channel.set_receive_handler (sigc::mem_fun (*this, &BaseUI::request_handler));
- request_channel.attach (m_context);
- maybe_install_precall_handler (m_context);
- }
- diff --git a/libs/pbd/basename.cc b/libs/pbd/basename.cc
- index 97a3a3cecb..ee59adde07 100644
- --- a/libs/pbd/basename.cc
- +++ b/libs/pbd/basename.cc
- @@ -24,7 +24,7 @@ using Glib::ustring;
- ustring
- PBD::basename_nosuffix (ustring str)
- {
- - ustring base = Glib::path_get_basename (str);
- + std::string base = Glib::path_get_basename (str.raw());
- return base.substr (0, base.find_last_of ('.'));
- diff --git a/libs/pbd/boost_debug.cc b/libs/pbd/boost_debug.cc
- index c9a9f58a30..d6d508c2b7 100644
- --- a/libs/pbd/boost_debug.cc
- +++ b/libs/pbd/boost_debug.cc
- @@ -28,7 +28,7 @@
- #include <map>
- #include <set>
- #include <vector>
- -#include <glibmm/threads.h>
- +#include <mutex>
- #include "pbd/stacktrace.h"
- #include "pbd/boost_debug.h"
- @@ -134,11 +134,11 @@ IPointerMap& interesting_pointers()
- return *_interesting_pointers;
- }
- -static Glib::Threads::Mutex* _the_lock;
- -static Glib::Threads::Mutex& the_lock()
- +static std::mutex* _the_lock;
- +static std::mutex& the_lock()
- {
- if (_the_lock == 0) {
- - _the_lock = new Glib::Threads::Mutex;
- + _the_lock = new std::mutex;
- }
- return *_the_lock;
- }
- @@ -167,7 +167,7 @@ boost_debug_shared_ptr_show_live_debugging (bool yn)
- void
- boost_debug_shared_ptr_mark_interesting (void* ptr, const char* type)
- {
- - Glib::Threads::Mutex::Lock guard (the_lock());
- + std::lock_guard<std::mutex> guard(the_lock());
- pair<void*,const char*> newpair (ptr, type);
- interesting_pointers().insert (newpair);
- if (debug_out) {
- @@ -182,7 +182,7 @@ boost_debug_shared_ptr_operator_equals (void const *sp, void const *old_obj, int
- return;
- }
- - Glib::Threads::Mutex::Lock guard (the_lock());
- + std::lock_guard<std::mutex> guard(the_lock());
- if (is_interesting_object (old_obj) || is_interesting_object (obj)) {
- if (debug_out) {
- @@ -230,7 +230,7 @@ boost_debug_shared_ptr_reset (void const *sp, void const *old_obj, int old_use_c
- return;
- }
- - Glib::Threads::Mutex::Lock guard (the_lock());
- + std::lock_guard<std::mutex> guard(the_lock());
- if (is_interesting_object (old_obj) || is_interesting_object (obj)) {
- if (debug_out) {
- @@ -274,7 +274,7 @@ boost_debug_shared_ptr_reset (void const *sp, void const *old_obj, int old_use_c
- void
- boost_debug_shared_ptr_destructor (void const *sp, volatile void const *obj, int use_count)
- {
- - Glib::Threads::Mutex::Lock guard (the_lock());
- + std::lock_guard<std::mutex> guard(the_lock());
- PointerMap::iterator x = sptrs().find (sp);
- if (x != sptrs().end()) {
- @@ -289,7 +289,7 @@ void
- boost_debug_shared_ptr_constructor (void const *sp, volatile void const *obj, int use_count)
- {
- if (is_interesting_object (obj)) {
- - Glib::Threads::Mutex::Lock guard (the_lock());
- + std::lock_guard<std::mutex> guard(the_lock());
- pair<void const*, SPDebug*> newpair;
- newpair.first = sp;
- @@ -306,14 +306,14 @@ boost_debug_shared_ptr_constructor (void const *sp, volatile void const *obj, in
- void
- boost_debug_count_ptrs ()
- {
- - Glib::Threads::Mutex::Lock guard (the_lock());
- + std::lock_guard<std::mutex> guard(the_lock());
- // cerr << "Tracking " << interesting_pointers().size() << " interesting objects with " << sptrs().size () << " shared ptrs\n";
- }
- void
- boost_debug_list_ptrs ()
- {
- - Glib::Threads::Mutex::Lock guard (the_lock());
- + std::lock_guard<std::mutex> guard(the_lock());
- if (sptrs().empty()) {
- cerr << "There are no dangling shared ptrs\n";
- diff --git a/libs/pbd/cartesian.cc b/libs/pbd/cartesian.cc
- index 9f2a868309..a61ff2bc55 100644
- --- a/libs/pbd/cartesian.cc
- +++ b/libs/pbd/cartesian.cc
- @@ -20,6 +20,10 @@
- #include "pbd/cartesian.h"
- +#ifndef M_PI
- +#define M_PI 3.14159265358979323846
- +#endif
- +
- using namespace std;
- void
- diff --git a/libs/pbd/ccurl.cc b/libs/pbd/ccurl.cc
- index 7c551357f0..5689ac2988 100644
- --- a/libs/pbd/ccurl.cc
- +++ b/libs/pbd/ccurl.cc
- @@ -128,13 +128,13 @@ CCurl::setup_certificate_paths ()
- */
- assert (!ca_path && !ca_info); // call once
- - if (Glib::file_test ("/etc/pki/tls/certs/ca-bundle.crt", Glib::FILE_TEST_IS_REGULAR)) {
- + if (Glib::file_test ("/etc/pki/tls/certs/ca-bundle.crt", Glib::FileTest::IS_REGULAR)) {
- // Fedora / RHEL, Arch
- ca_info = "/etc/pki/tls/certs/ca-bundle.crt";
- - } else if (Glib::file_test ("/etc/ssl/certs/ca-certificates.crt", Glib::FILE_TEST_IS_REGULAR)) {
- + } else if (Glib::file_test ("/etc/ssl/certs/ca-certificates.crt", Glib::FileTest::IS_REGULAR)) {
- // Debian and derivatives
- ca_info = "/etc/ssl/certs/ca-certificates.crt";
- - } else if (Glib::file_test ("/etc/pki/tls/cert.pem", Glib::FILE_TEST_IS_REGULAR)) {
- + } else if (Glib::file_test ("/etc/pki/tls/cert.pem", Glib::FileTest::IS_REGULAR)) {
- // GNU/TLS can keep extra stuff here
- ca_info = "/etc/pki/tls/cert.pem";
- }
- diff --git a/libs/pbd/command.cc b/libs/pbd/command.cc
- index f120aeee4b..04fe3463d0 100644
- --- a/libs/pbd/command.cc
- +++ b/libs/pbd/command.cc
- @@ -21,6 +21,13 @@
- #include "pbd/command.h"
- #include "pbd/xml++.h"
- +#undef read
- +#undef write
- +#undef close
- +#undef seek
- +#undef flush
- +
- +
- XMLNode &PBD::Command::get_state() const
- {
- XMLNode *node = new XMLNode ("Command");
- diff --git a/libs/pbd/controllable.cc b/libs/pbd/controllable.cc
- index c27a09bd6a..a0ab7e1e35 100644
- --- a/libs/pbd/controllable.cc
- +++ b/libs/pbd/controllable.cc
- @@ -29,6 +29,8 @@
- #include "pbd/i18n.h"
- +#include <shared_mutex>
- +
- using namespace PBD;
- using namespace std;
- @@ -37,7 +39,7 @@ PBD::Signal<void(std::weak_ptr<PBD::Controllable> )> Controllable::StopLearning;
- PBD::Signal<void(std::weak_ptr<PBD::Controllable> )> Controllable::GUIFocusChanged;
- PBD::Signal<void(std::weak_ptr<PBD::Controllable> )> Controllable::ControlTouched;
- -Glib::Threads::RWLock Controllable::registry_lock;
- +std::shared_mutex Controllable::registry_lock;
- Controllable::Controllables Controllable::registry;
- PBD::ScopedConnectionList Controllable::registry_connections;
- @@ -116,7 +118,7 @@ Controllable::clear_flag (Flag f)
- void
- Controllable::add (Controllable& ctl)
- {
- - Glib::Threads::RWLock::WriterLock lm (registry_lock);
- + auto lm = std::unique_lock(registry_lock);
- registry.insert (&ctl);
- ctl.DropReferences.connect_same_thread (registry_connections, std::bind (&Controllable::remove, &ctl));
- ctl.Destroyed.connect_same_thread (registry_connections, std::bind (&Controllable::remove, &ctl));
- @@ -125,7 +127,7 @@ Controllable::add (Controllable& ctl)
- void
- Controllable::remove (Controllable* ctl)
- {
- - Glib::Threads::RWLock::WriterLock lm (registry_lock);
- + auto lm = std::unique_lock(registry_lock);
- Controllables::iterator i = std::find (registry.begin(), registry.end(), ctl);
- if (i != registry.end()) {
- registry.erase (i);
- @@ -135,7 +137,7 @@ Controllable::remove (Controllable* ctl)
- std::shared_ptr<Controllable>
- Controllable::by_id (const ID& id)
- {
- - Glib::Threads::RWLock::ReaderLock lm (registry_lock);
- + auto lm = std::shared_lock(registry_lock);
- for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
- if ((*i)->id() == id) {
- @@ -149,7 +151,7 @@ ControllableSet
- Controllable::registered_controllables ()
- {
- ControllableSet rv;
- - Glib::Threads::RWLock::ReaderLock lm (registry_lock);
- + auto lm = std::shared_lock(registry_lock);
- for (auto const& i : registry) {
- try {
- rv.insert (i->shared_from_this ());
- @@ -164,7 +166,7 @@ Controllable::registered_controllables ()
- void
- Controllable::dump_registry ()
- {
- - Glib::Threads::RWLock::ReaderLock lm (registry_lock);
- + auto lm = std::shared_lock(registry_lock);
- if (registry.size() == 0) {
- return;
- }
- diff --git a/libs/pbd/cpus.cc b/libs/pbd/cpus.cc
- index f39c8a57de..70ce61a44a 100644
- --- a/libs/pbd/cpus.cc
- +++ b/libs/pbd/cpus.cc
- @@ -36,7 +36,7 @@
- #include "pbd/cpus.h"
- #if defined(COMPILER_MSVC) && !defined(PTW32_VERSION)
- -#include <ardourext/pthread.h> // Gets us 'PTW32_VERSION'
- +#include <pthread.h> // Gets us 'PTW32_VERSION'
- #endif
- int32_t
- diff --git a/libs/pbd/crossthread.cc b/libs/pbd/crossthread.cc
- index bf21d2befc..84e42e5320 100644
- --- a/libs/pbd/crossthread.cc
- +++ b/libs/pbd/crossthread.cc
- @@ -16,20 +16,20 @@
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- +#ifndef PLATFORM_WINDOWS
- +#include <unistd.h>
- +#endif
- #include <cstdlib>
- #include <cerrno>
- #include <cstring>
- #include <fcntl.h>
- -#include <unistd.h>
- -#ifdef PLATFORM_WINDOWS
- -#include <winsock2.h>
- -#include <ws2tcpip.h>
- -#endif
- +#include <glibmm.h>
- +#include <giomm.h>
- -#include "pbd/error.h"
- #include "pbd/crossthread.h"
- +#include "pbd/error.h"
- using namespace std;
- using namespace PBD;
- @@ -41,28 +41,14 @@ using namespace Glib;
- #include "crossthread.win.cc"
- #endif
- -#ifndef G_SOURCE_FUNC
- -#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f))
- -#endif
- -
- -gboolean
- -cross_thread_channel_call_receive_slot (GIOChannel*, GIOCondition condition, void *data)
- -{
- - CrossThreadChannel* ctc = static_cast<CrossThreadChannel*>(data);
- - return ctc->receive_slot (Glib::IOCondition (condition));
- -}
- -
- -void
- -CrossThreadChannel::set_receive_handler (sigc::slot<bool,Glib::IOCondition> s)
- -{
- - receive_slot = s;
- -}
- -
- void
- CrossThreadChannel::attach (Glib::RefPtr<Glib::MainContext> context)
- {
- - receive_source = g_io_create_watch (receive_channel, GIOCondition(G_IO_IN | G_IO_ERR | G_IO_HUP));
- -
- - g_source_set_callback (receive_source, G_SOURCE_FUNC(cross_thread_channel_call_receive_slot), this, NULL);
- - g_source_attach (receive_source, context->gobj());
- + source = Gio::SocketSource::create (recv_socket,
- + static_cast<Glib::IOCondition>(G_IO_IN | G_IO_ERR | G_IO_HUP));
- + CrossThreadChannel* self = this;
- + source->connect ([self](Glib::IOCondition cond) -> bool {
- + return self->receive_slot (cond);
- + });
- + source->attach (context);
- }
- diff --git a/libs/pbd/crossthread.win.cc b/libs/pbd/crossthread.win.cc
- index 1d0758c911..f117e1ec80 100644
- --- a/libs/pbd/crossthread.win.cc
- +++ b/libs/pbd/crossthread.win.cc
- @@ -18,187 +18,53 @@
- */
- CrossThreadChannel::CrossThreadChannel (bool non_blocking)
- - : receive_channel (0)
- - , receive_source (0)
- - , receive_slot ()
- - , send_socket()
- - , receive_socket()
- - , recv_address()
- + : receive_slot ()
- {
- - struct sockaddr_in send_address;
- + auto inet = Gio::InetAddress::create("127.0.0.1");
- + Gio::SocketFamily family = static_cast<Gio::SocketFamily>(G_SOCKET_FAMILY_IPV4);
- + Gio::Socket::Type type = static_cast<Gio::Socket::Type>(G_SOCKET_TYPE_DATAGRAM);
- + Gio::Socket::Protocol proto = static_cast<Gio::Socket::Protocol>(G_SOCKET_PROTOCOL_UDP);
- - // Create Send Socket
- - send_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- - send_address.sin_family = AF_INET;
- - send_address.sin_addr.s_addr = inet_addr("127.0.0.1");
- - send_address.sin_port = htons(0);
- - int status = ::bind(send_socket, (SOCKADDR*)&send_address,
- - sizeof(send_address));
- + send_socket = Gio::Socket::create(family, type, proto);
- + recv_socket = Gio::Socket::create(family, type, proto);
- - if (status != 0) {
- - std::cerr << "CrossThreadChannel::CrossThreadChannel() Send socket binding failed with error: " << WSAGetLastError() << std::endl;
- - return;
- - }
- + recv_socket->bind(Gio::InetSocketAddress::create(inet, 0), true);
- - // make the socket non-blockable if required
- - u_long mode = (u_long)non_blocking;
- - int otp_result = 0;
- -
- - otp_result = ioctlsocket(send_socket, FIONBIO, &mode);
- - if (otp_result != NO_ERROR) {
- - std::cerr << "CrossThreadChannel::CrossThreadChannel() Send socket cannot be set to non blocking mode with error: " << WSAGetLastError() << std::endl;
- - }
- -
- - // Create Receive Socket, this socket will be set to unblockable mode by IO channel
- - receive_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- - recv_address.sin_family = AF_INET;
- - recv_address.sin_addr.s_addr = inet_addr("127.0.0.1");
- - recv_address.sin_port = htons(0);
- - status = ::bind(receive_socket, (SOCKADDR*)&recv_address,
- - sizeof(recv_address));
- -
- - if (status != 0) {
- - std::cerr << "CrossThreadChannel::CrossThreadChannel() Receive socket binding failed with error: " << WSAGetLastError() << std::endl;
- - return;
- - }
- -
- - // recieve socket will be made non-blocking by GSource which will use it
- -
- - // get assigned port number for Receive Socket
- - int recv_addr_len = sizeof(recv_address);
- - status = getsockname(receive_socket, (SOCKADDR*)&recv_address, &recv_addr_len);
- -
- - if (status != 0) {
- - std::cerr << "CrossThreadChannel::CrossThreadChannel() Setting receive socket address to local failed with error: " << WSAGetLastError() << std::endl;
- - return;
- - }
- -
- - // construct IOChannel
- - receive_channel = g_io_channel_win32_new_socket((gint)receive_socket);
- -
- - // set binary data type
- - GIOStatus g_status = g_io_channel_set_encoding (receive_channel, NULL, NULL);
- - if (G_IO_STATUS_NORMAL != g_status ) {
- - std::cerr << "CrossThreadChannel::CrossThreadChannel() Cannot set flag for IOChannel. " << g_status << std::endl;
- - return;
- - }
- -
- - // disable channel buffering
- - g_io_channel_set_buffered (receive_channel, false);
- -}
- -
- -CrossThreadChannel::~CrossThreadChannel ()
- -{
- - if (receive_source) {
- - /* this disconnects it from any main context it was attached in
- - in ::attach(), this prevent its callback from being invoked
- - after the destructor has finished.
- - */
- - g_source_destroy (receive_source);
- - }
- -
- - /* glibmm hack */
- -
- - if (receive_channel) {
- - g_io_channel_unref (receive_channel);
- - }
- -
- - closesocket(send_socket);
- - closesocket(receive_socket);
- + send_socket->set_blocking(!non_blocking);
- + recv_socket->set_blocking(!non_blocking);
- }
- -void
- -CrossThreadChannel::wakeup ()
- +CrossThreadChannel::~CrossThreadChannel()
- {
- - char c = 0;
- -
- - // write one byte to wake up a thread which is listening our IOS
- - sendto(send_socket, &c, sizeof(c), 0, (SOCKADDR*)&recv_address, sizeof(recv_address) );
- + if (source)
- + source->destroy();
- }
- void
- -CrossThreadChannel::drain ()
- +CrossThreadChannel::wakeup()
- {
- - /* flush the buffer - empty the channel from all requests */
- - GError *g_error = 0;
- - gchar buffer[512];
- - gsize read = 0;
- -
- - while (1) {
- - GIOStatus g_status = g_io_channel_read_chars (receive_channel, buffer, sizeof(buffer), &read, &g_error);
- -
- - if (G_IO_STATUS_AGAIN == g_status) {
- - break;
- - }
- -
- - if (G_IO_STATUS_NORMAL != g_status) {
- - std::cerr << "CrossThreadChannel::CrossThreadChannel() Cannot drain from read buffer! " << g_status << std::endl;
- -
- - if (g_error) {
- - std::cerr << "Error is Domain: " << g_error->domain << " Code: " << g_error->code << std::endl;
- - g_clear_error(&g_error);
- - } else {
- - std::cerr << "No error provided\n";
- - }
- - break;
- - }
- - }
- + char c = 0;
- + deliver(c);
- }
- -
- int
- -CrossThreadChannel::deliver (char msg)
- +CrossThreadChannel::deliver(char msg)
- {
- -
- - // write one particular byte to wake up the thread which is listening our IOS
- - int status = sendto(send_socket, &msg, sizeof(msg), 0, (SOCKADDR*)&recv_address, sizeof(recv_address) );
- -
- - if (SOCKET_ERROR == status) {
- - return -1;
- - }
- -
- - return status;
- + auto addr = recv_socket->get_local_address();
- + gssize sent = send_socket->send_to(addr, &msg, sizeof(msg));
- + return (sent < 0) ? -1 : static_cast<int>(sent);
- }
- -bool
- -CrossThreadChannel::poll_for_request()
- +int
- +CrossThreadChannel::receive(char& msg, bool /*wait*/)
- {
- - // windows before Vista has no poll
- - while(true) {
- - fd_set rfds;
- - FD_ZERO(&rfds);
- - FD_SET(receive_socket, &rfds);
- - if ((select(receive_socket+1, &rfds, NULL, NULL, NULL)) < 0) {
- - if (errno == EINTR) {
- - continue;
- - }
- - break;
- - }
- - if(FD_ISSET(receive_socket, &rfds)) {
- - return true;
- - }
- - }
- - return false;
- + gssize r = recv_socket->receive(&msg, sizeof(msg));
- + return (r < 0) ? -1 : static_cast<int>(r);
- }
- -int
- -CrossThreadChannel::receive (char& msg, bool wait)
- +void
- +CrossThreadChannel::drain()
- {
- - gsize read = 0;
- - GError *g_error = 0;
- -
- - if (wait) {
- - if (!poll_for_request ()) {
- - return -1;
- - }
- - }
- -
- - // fetch the message from the channel.
- - GIOStatus g_status = g_io_channel_read_chars (receive_channel, &msg, sizeof(msg), &read, &g_error);
- -
- - if (G_IO_STATUS_NORMAL != g_status) {
- - read = -1;
- - }
- -
- - return read;
- + char buf[512];
- + while (recv_socket->receive(buf, sizeof(buf)) > 0) {}
- }
- diff --git a/libs/pbd/debug.cc b/libs/pbd/debug.cc
- index 2fcbc1f510..42434ef4be 100644
- --- a/libs/pbd/debug.cc
- +++ b/libs/pbd/debug.cc
- @@ -26,8 +26,11 @@
- #include <map>
- #include <vector>
- #include <algorithm>
- +#include <sstream>
- -#include <boost/tokenizer.hpp>
- +#ifdef PLATFORM_WINDOWS
- +#define strncasecmp _strnicmp
- +#endif
- #include "pbd/debug.h"
- #include "pbd/error.h"
- @@ -130,23 +133,26 @@ int
- PBD::parse_debug_options (const char* str)
- {
- string in_str = str;
- - typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
- - boost::char_separator<char> sep (",");
- - tokenizer tokens (in_str, sep);
- + std::vector<std::string> tokens;
- + std::stringstream ss(in_str);
- + std::string token;
- + while (std::getline(ss, token, ',')) {
- + tokens.push_back(token);
- + }
- - for (tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter) {
- - if (*tok_iter == "list") {
- + for (auto const& tok : tokens) {
- + if (tok == "list") {
- list_debug_options ();
- return 1;
- }
- - if (*tok_iter == "all") {
- + if (tok == "all") {
- debug_bits.set (); /* sets all bits */
- return 0;
- }
- for (map<const char*,DebugBits>::iterator i = _debug_bit_map().begin(); i != _debug_bit_map().end(); ++i) {
- - const char* cstr = (*tok_iter).c_str();
- + const char* cstr = tok.c_str();
- if (strncasecmp (cstr, i->first, strlen (cstr)) == 0) {
- debug_bits |= i->second;
- diff --git a/libs/pbd/downloader.cc b/libs/pbd/downloader.cc
- index 3986a796bc..f7e278403f 100644
- --- a/libs/pbd/downloader.cc
- +++ b/libs/pbd/downloader.cc
- @@ -69,13 +69,13 @@ Downloader::Downloader (string const & u, string const & dir)
- , _download_size (0)
- , _downloaded (0)
- {
- - if (!Glib::file_test (destdir, Glib::FILE_TEST_EXISTS)) {
- + if (!Glib::file_test (destdir, Glib::FileTest::EXISTS)) {
- if (g_mkdir_with_parents (destdir.c_str(), 0700) != 0) {
- error << string_compose (_("Could not create clip library dir %1 (%2)"), destdir, strerror(errno)) << endmsg;
- throw failed_constructor();
- }
- } else {
- - if (!Glib::file_test (destdir, Glib::FILE_TEST_IS_DIR)) {
- + if (!Glib::file_test (destdir, Glib::FileTest::IS_DIR)) {
- error << string_compose (_("Clip library dir (%1) is not a directory"), destdir) << endmsg;
- throw failed_constructor();
- }
- diff --git a/libs/pbd/event_loop.cc b/libs/pbd/event_loop.cc
- index a0dae62fef..01bc33ef44 100644
- --- a/libs/pbd/event_loop.cc
- +++ b/libs/pbd/event_loop.cc
- @@ -19,6 +19,7 @@
- */
- #include <cstring>
- +#include <mutex>
- #include <pthread.h>
- @@ -33,11 +34,9 @@
- using namespace PBD;
- using namespace std;
- -static void do_not_delete_the_loop_pointer (void*) { }
- +thread_local EventLoop* detail::EventLoopTLS::value = nullptr;
- -Glib::Threads::Private<EventLoop> EventLoop::thread_event_loop (do_not_delete_the_loop_pointer);
- -
- -Glib::Threads::Mutex EventLoop::thread_buffer_requests_lock;
- +std::mutex EventLoop::thread_buffer_requests_lock;
- EventLoop::ThreadRequestBufferList EventLoop::thread_buffer_requests;
- EventLoop::RequestBufferSuppliers EventLoop::request_buffer_suppliers;
- @@ -61,19 +60,22 @@ EventLoop::~EventLoop ()
- EventLoop*
- EventLoop::get_event_loop_for_thread()
- {
- - return thread_event_loop.get ();
- + return current_thread_event_loop();
- }
- void
- EventLoop::set_event_loop_for_thread (EventLoop* loop)
- {
- - thread_event_loop.set (loop);
- + EventLoopTLS::value = loop;
- }
- -void*
- -EventLoop::invalidate_request (void* data)
- +void
- +EventLoop::invalidate_request (sigc::notifiable* data)
- {
- - InvalidationRecord* ir = (InvalidationRecord*) data;
- + /* data points to the notifiable_base member, so we need to get back to the containing InvalidationRecord */
- + InvalidationRecord* ir = reinterpret_cast<InvalidationRecord*>(
- + reinterpret_cast<char*>(data) - offsetof(InvalidationRecord, notifiable_base)
- + );
- /* Some of the requests queued with an EventLoop may involve functors
- * that make method calls to objects whose lifetime is shorter
- @@ -101,12 +103,10 @@ EventLoop::invalidate_request (void* data)
- if (ir->event_loop) {
- DEBUG_TRACE (PBD::DEBUG::EventLoop, string_compose ("%1: invalidating request from %2 (%3) @ %4\n", pthread_name(), ir->event_loop, ir->event_loop->event_loop_name(), ir));
- - Glib::Threads::RWLock::WriterLock lm (ir->event_loop->slot_invalidation_rwlock());
- + WriteLock<RWMutex> lm (ir->event_loop->slot_invalidation_rwlock());
- ir->invalidate ();
- ir->event_loop->trash.push_back(ir);
- }
- -
- - return 0;
- }
- /** Create a PBD::EventLoop::InvalidationRecord and attach a callback
- @@ -121,7 +121,7 @@ EventLoop::__invalidator (sigc::trackable& trackable, const char* file, int line
- ir->file = file;
- ir->line = line;
- - trackable.add_destroy_notify_callback (ir, PBD::EventLoop::invalidate_request);
- + trackable.add_destroy_notify_callback (&ir->notifiable_base, PBD::EventLoop::invalidate_request);
- return ir;
- }
- @@ -131,7 +131,7 @@ vector<EventLoop::ThreadBufferMapping>
- EventLoop::get_request_buffers_for_target_thread (const std::string& target_thread)
- {
- vector<ThreadBufferMapping> ret;
- - Glib::Threads::Mutex::Lock lm (thread_buffer_requests_lock);
- + std::lock_guard<std::mutex> lm (thread_buffer_requests_lock);
- DEBUG_TRACE (PBD::DEBUG::EventLoop, string_compose ("%1 look for request buffers via %2\n", pthread_name(), target_thread));
- @@ -160,7 +160,7 @@ EventLoop::pre_register (const string& emitting_thread_name, uint32_t num_reques
- */
- ThreadBufferMapping mapping;
- - Glib::Threads::Mutex::Lock lm (thread_buffer_requests_lock);
- + std::lock_guard<std::mutex> lm (thread_buffer_requests_lock);
- mapping.emitting_thread = pthread_self();
- mapping.num_requests = num_requests;
- @@ -206,7 +206,7 @@ EventLoop::pre_register (const string& emitting_thread_name, uint32_t num_reques
- void
- EventLoop::remove_request_buffer_from_map (pthread_t pth)
- {
- - Glib::Threads::Mutex::Lock lm (thread_buffer_requests_lock);
- + std::lock_guard<std::mutex> lm (thread_buffer_requests_lock);
- for (ThreadRequestBufferList::iterator x = thread_buffer_requests.begin(); x != thread_buffer_requests.end(); ++x) {
- if (pthread_equal (x->emitting_thread, pth)) {
- diff --git a/libs/pbd/file_archive.cc b/libs/pbd/file_archive.cc
- index f26c7a26f1..99c3f64534 100644
- --- a/libs/pbd/file_archive.cc
- +++ b/libs/pbd/file_archive.cc
- @@ -27,6 +27,10 @@
- #include <fcntl.h>
- #include <sys/stat.h>
- +#ifdef PLATFORM_WINDOWS
- +#include <io.h>
- +#endif
- +
- #include <glib.h>
- #include "pbd/gstdio_compat.h"
- #include <glibmm.h>
- @@ -89,7 +93,7 @@ get_url (void* arg)
- return NULL;
- }
- -static ssize_t
- +static la_ssize_t
- ar_read (struct archive* a, void* d, const void** buff)
- {
- FileArchive::MemPipe* p = (FileArchive::MemPipe*)d;
- @@ -558,8 +562,13 @@ FileArchive::create (const std::map<std::string, std::string>& filemap, Compress
- int fd = g_open (filepath, O_RDONLY, 0444);
- assert (fd >= 0);
- + int len;
- - ssize_t len = read (fd, buf, sizeof (buf));
- +#ifdef PLATFORM_WINDOWS
- + len = _read (fd, buf, sizeof (buf));
- +#else
- + len = ::read (fd, buf, sizeof (buf));
- +#endif
- while (len > 0) {
- read_bytes += len;
- archive_write_data (a, buf, len);
- @@ -569,9 +578,17 @@ FileArchive::create (const std::map<std::string, std::string>& filemap, Compress
- break;
- }
- }
- - len = read (fd, buf, sizeof (buf));
- +#ifdef PLATFORM_WINDOWS
- + len = _read (fd, buf, sizeof (buf));
- +#else
- + len = ::read (fd, buf, sizeof (buf));
- +#endif
- }
- - close (fd);
- +#ifdef PLATFORM_WINDOWS
- + _close (fd);
- +#else
- + ::close (fd);
- +#endif
- if (_progress && _progress->cancelled ()) {
- break;
- }
- diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc
- index aed050e694..5e9951def4 100644
- --- a/libs/pbd/file_utils.cc
- +++ b/libs/pbd/file_utils.cc
- @@ -53,8 +53,13 @@
- /* close(), read(), write() */
- #ifdef COMPILER_MSVC
- -#include <io.h> // Microsoft's nearest equivalent to <unistd.h>
- -#include <ardourext/misc.h>
- +#include <io.h>
- +#include <stdlib.h>
- +#define PATH_MAX _MAX_PATH
- +#include <basetsd.h>
- +#include <windows.h>
- +#include <regex>
- +typedef SSIZE_T ssize_t;
- #else
- #include <unistd.h>
- #include <regex.h>
- @@ -92,7 +97,7 @@ run_functor_for_paths (vector<string>& result,
- DEBUG_TRACE (DEBUG::FileUtils,
- string_compose("Find files in expanded path: %1\n", expanded_path));
- - if (!Glib::file_test (expanded_path, Glib::FILE_TEST_IS_DIR)) continue;
- + if (!Glib::file_test (expanded_path, Glib::FileTest::EXISTS)) continue;
- Glib::Dir dir(expanded_path);
- @@ -101,7 +106,7 @@ run_functor_for_paths (vector<string>& result,
- string fullpath = Glib::build_filename (expanded_path, *di);
- string basename = *di;
- - bool is_dir = Glib::file_test (fullpath, Glib::FILE_TEST_IS_DIR);
- + bool is_dir = Glib::file_test (fullpath, Glib::FileTest::EXISTS);
- if (is_dir && recurse) {
- if (scanned_paths.find (fullpath) == scanned_paths.end ()) {
- @@ -143,12 +148,12 @@ run_functor_for_paths (vector<string>& result,
- }
- catch (Glib::FileError const& err) {
- char errstr[PATH_MAX*2];
- - snprintf (errstr, sizeof (errstr), "Cannot access file: %s", err.what().c_str());
- + snprintf (errstr, sizeof (errstr), "Cannot access file: %s", err.what());
- warning << errstr << endmsg;
- }
- catch (Glib::ConvertError const& err) {
- char errstr[PATH_MAX*2];
- - snprintf (errstr, sizeof (errstr), "Cannot convert filename: %s", err.what().c_str());
- + snprintf (errstr, sizeof (errstr), "Cannot convert filename: %s", err.what());
- warning << errstr << endmsg;
- }
- }
- @@ -235,10 +240,10 @@ find_file (const Searchpath& search_path,
- return true;
- }
- -
- +#ifndef COMPILER_MSVC
- static
- bool
- -regexp_filter (const string& str, void *arg)
- + regexp_filter (const string& str, void *arg)
- {
- regex_t* pattern = (regex_t*)arg;
- return regexec (pattern, str.c_str(), 0, 0, 0) == 0;
- @@ -252,7 +257,7 @@ find_files_matching_regex (vector<string>& result,
- {
- int err;
- char msg[256];
- - regex_t compiled_pattern;
- + std::regex compiled_pattern;
- if ((err = regcomp (&compiled_pattern, regexp.c_str(),
- REG_EXTENDED|REG_NOSUB))) {
- @@ -274,10 +279,25 @@ find_files_matching_regex (vector<string>& result,
- find_files_matching_filter (result, paths,
- regexp_filter, &compiled_pattern,
- true, true, recurse);
- +}
- +#endif
- - regfree (&compiled_pattern);
- +#ifdef COMPILER_MSVC
- +static
- +bool
- +regexp_filter (const string& str, void *arg)
- +{
- + const std::regex* pattern = static_cast<std::regex*>(arg);
- + return std::regex_search (str, *pattern);
- }
- +void
- +find_files_matching_regex (vector<string>& result,
- + const Searchpath& paths,
- + const std::string& regexp,
- + bool recurse);
- +#endif
- +
- void
- find_paths_matching_filter (vector<string>& result,
- const Searchpath& paths,
- @@ -305,7 +325,7 @@ find_files_matching_filter (vector<string>& result,
- bool
- copy_file(const std::string & from_path, const std::string & to_path)
- {
- - if (!Glib::file_test (from_path, Glib::FILE_TEST_EXISTS)) return false;
- + if (!Glib::file_test (from_path, Glib::FileTest::EXISTS)) return false;
- PBD::ScopedFileDescriptor fd_from (g_open (from_path.c_str(), O_RDONLY, 0444));
- PBD::ScopedFileDescriptor fd_to (g_open (to_path.c_str(), O_CREAT|O_TRUNC|O_RDWR, 0666));
- @@ -400,7 +420,7 @@ hard_link (const std::string& existing_file, const std::string& new_path)
- return false;
- # else
- /* see also ntfs_link -- msvc only pbd extension */
- - return CreateHardLinkA (new_path.c_str(), existing_file.c_str(), NULL);
- + return CreateHardLinkA (new_path.c_str(), existing_file.c_str(), nullptr) != 0;
- # endif
- #else
- return 0 == link (existing_file.c_str(), new_path.c_str());
- @@ -538,7 +558,7 @@ exists_and_writable (const std::string & p)
- * permissions permit access, the mount status does not.
- * access(2) seems like the best test for this.
- */
- - if (g_access (p.c_str(), W_OK) != 0) {
- + if (g_access (p.c_str(), 2) != 0) {
- DEBUG_TRACE (DEBUG::FileUtils, string_compose("exists_and_writable g_access '%1': !W_OK\n", p));
- return false;
- }
- @@ -611,7 +631,7 @@ tmp_writable_directory (const char* domain, const string& prefix)
- oss << g_random_int ();
- dir_name = oss.str();
- new_test_dir = Glib::build_filename (tmp_dir, dir_name);
- - if (Glib::file_test (new_test_dir, Glib::FILE_TEST_EXISTS)) continue;
- + if (Glib::file_test (new_test_dir, Glib::FileTest::EXISTS)) continue;
- } while (g_mkdir_with_parents (new_test_dir.c_str(), 0755) != 0);
- return new_test_dir;
- }
- @@ -619,7 +639,7 @@ tmp_writable_directory (const char* domain, const string& prefix)
- int
- toggle_file_existence (string const & path)
- {
- - if (Glib::file_test (path, Glib::FILE_TEST_IS_REGULAR)) {
- + if (Glib::file_test (path, Glib::FileTest::EXISTS)) {
- return g_unlink (path.c_str());
- }
- diff --git a/libs/pbd/history_owner.cc b/libs/pbd/history_owner.cc
- index 362b717ae2..887730879e 100644
- --- a/libs/pbd/history_owner.cc
- +++ b/libs/pbd/history_owner.cc
- @@ -1,6 +1,8 @@
- #include <string>
- #include <vector>
- +#include <chrono>
- +#include <ctime>
- #include "pbd/command.h"
- #include "pbd/compose.h"
- #include "pbd/debug.h"
- @@ -165,7 +167,18 @@ HistoryOwner::commit_reversible_command (Command *cmd)
- return;
- }
- - gettimeofday (&now, 0);
- + // portable replacement for gettimeofday
- + auto tp = std::chrono::system_clock::now();
- + auto secs = std::chrono::system_clock::to_time_t(tp);
- + auto us = std::chrono::duration_cast<std::chrono::microseconds>(
- + tp.time_since_epoch()) % 1000000;
- + now = {static_cast<long>(secs), static_cast<long>(us.count())};
- +
- +
- +
- +
- +
- +
- _current_trans->set_timestamp (now);
- DEBUG_TRACE (DEBUG::UndoHistory,
- diff --git a/libs/pbd/id.cc b/libs/pbd/id.cc
- index 79bc9cd4de..0aaf8877eb 100644
- --- a/libs/pbd/id.cc
- +++ b/libs/pbd/id.cc
- @@ -24,20 +24,22 @@
- #include "pbd/id.h"
- #include "pbd/string_convert.h"
- -
- +#include <mutex>
- #include <string>
- using namespace std;
- using namespace PBD;
- -Glib::Threads::Mutex* ID::counter_lock = 0;
- +static std::mutex* cxx_mutex = nullptr;
- +GMutex* ID::counter_lock = nullptr;
- uint64_t ID::_counter = 0;
- void
- ID::init ()
- {
- if (!counter_lock) {
- - counter_lock = new Glib::Threads::Mutex;
- + cxx_mutex = new std::mutex;
- + counter_lock = reinterpret_cast<GMutex*>(cxx_mutex);
- }
- }
- @@ -66,7 +68,7 @@ ID::ID (uint64_t n)
- void
- ID::reset ()
- {
- - Glib::Threads::Mutex::Lock lm (*counter_lock);
- + std::lock_guard<std::mutex> g (*cxx_mutex);
- _id = ++_counter;
- }
- diff --git a/libs/pbd/msvc/msvc_pbd.cc b/libs/pbd/msvc/msvc_pbd.cc
- index 730672a31d..2c322d7319 100644
- --- a/libs/pbd/msvc/msvc_pbd.cc
- +++ b/libs/pbd/msvc/msvc_pbd.cc
- @@ -34,8 +34,8 @@ CreateHardLinkA( LPCSTR lpFileName,
- #include <stdlib.h>
- #include <sys/stat.h>
- #include <pbd/error.h>
- -#include <ardourext/misc.h>
- -#include <ardourext/pthread.h> // Should ensure that we include the right
- +#include <pbd/compat.h>
- +#include <pthread.h> // Should ensure that we include the right
- // version - but we'll check anyway, later
- #include <glibmm.h>
- diff --git a/libs/pbd/pathexpand.cc b/libs/pbd/pathexpand.cc
- index 4aba783b5d..6876a85fa3 100644
- --- a/libs/pbd/pathexpand.cc
- +++ b/libs/pbd/pathexpand.cc
- @@ -25,7 +25,7 @@
- #include <cerrno>
- #include <cstdlib>
- -#include <regex.h>
- +#include <glibmm/regex.h>
- #include <glibmm/fileutils.h>
- #include <glibmm/miscutils.h>
- @@ -62,46 +62,34 @@ PBD::path_expand (string path)
- /* now do $VAR substitution, since wordexp isn't reliable */
- - regex_t compiled_pattern;
- - const int nmatches = 100;
- - regmatch_t matches[nmatches];
- + Glib::RefPtr<Glib::Regex> re = Glib::Regex::create (
- + "\\$([a-zA-Z_][a-zA-Z0-9_]*|\\{[a-zA-Z_][a-zA-Z0-9_]*\\})");
- - if (regcomp (&compiled_pattern, "\\$([a-zA-Z_][a-zA-Z0-9_]*|\\{[a-zA-Z_][a-zA-Z0-9_]*\\})", REG_EXTENDED)) {
- - std::cerr << "bad regcomp\n";
- - return path;
- - }
- -
- - while (true) {
- -
- - if (regexec (&compiled_pattern, path.c_str(), nmatches, matches, 0)) {
- + Glib::ustring u_path = path;
- + Glib::MatchInfo mi;
- + while (re->match (u_path, mi, Glib::Regex::MatchFlags::DEFAULT)) {
- + Glib::ustring match = mi.fetch (0);
- + if (match.empty())
- break;
- - }
- -
- - /* matches[0] gives the entire match */
- -
- - string match = path.substr (matches[0].rm_so, matches[0].rm_eo - matches[0].rm_so);
- -
- +
- /* try to get match from the environment */
- -
- - if (match[1] == '{') {
- - /* ${FOO} form */
- - match = match.substr (2, match.length() - 3);
- - }
- -
- - char* matched_value = getenv (match.c_str());
- -
- - if (matched_value) {
- - path.replace (matches[0].rm_so, matches[0].rm_eo - matches[0].rm_so, matched_value);
- - } else {
- - path.replace (matches[0].rm_so, matches[0].rm_eo - matches[0].rm_so, string());
- - }
- -
- - /* go back and do it again with whatever remains after the
- - * substitution
- - */
- - }
- -
- - regfree (&compiled_pattern);
- + if (match[1] == '{') {
- + /* ${FOO} form */
- + match = match.substr (2, match.bytes() - 3);
- + }
- +
- + char* matched_value = getenv (match.raw().c_str());
- +
- + gint start = 0, end = 0;
- + mi.fetch_pos (0, start, end);
- +
- + if (matched_value)
- + path.replace (start, end - start, matched_value);
- + else
- + path.replace (start, end - start, string());
- +
- + u_path = path; // keep ustring in sync
- + }
- /* canonicalize */
- @@ -158,7 +146,7 @@ PBD::parse_path(std::string path, bool check_if_exists)
- {
- dir = *i;
- }
- - if (!check_if_exists || Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) {
- + if (!check_if_exists || Glib::file_test (dir, Glib::FileTest::IS_DIR)) {
- pathlist.push_back(dir);
- }
- }
- diff --git a/libs/pbd/pbd.cc b/libs/pbd/pbd.cc
- index c19af3e462..820b23d76e 100644
- --- a/libs/pbd/pbd.cc
- +++ b/libs/pbd/pbd.cc
- @@ -28,8 +28,6 @@
- #include <giomm.h>
- -#include <glibmm/thread.h>
- -
- #include "pbd/pbd.h"
- #include "pbd/ccurl.h"
- #include "pbd/debug.h"
- @@ -87,10 +85,6 @@ PBD::init ()
- }
- #endif
- - if (!Glib::thread_supported()) {
- - Glib::thread_init();
- - }
- -
- Gio::init ();
- PBD::ID::init ();
- diff --git a/libs/pbd/pbd/abstract_ui.inc.cc b/libs/pbd/pbd/abstract_ui.inc.cc
- index f3f735c973..4ab8f59e5c 100644
- --- a/libs/pbd/pbd/abstract_ui.inc.cc
- +++ b/libs/pbd/pbd/abstract_ui.inc.cc
- @@ -33,7 +33,7 @@
- #include "pbd/i18n.h"
- #ifdef COMPILER_MSVC
- -#include <ardourext/misc.h> // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
- +#include <pbd/compat.h> // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
- // searched and sorted. Thus, when instantiating the container, MSVC complains
- // if the type of object being contained has no appropriate comparison operators
- // defined (specifically, if operators '<' and '==' are undefined). This seems
- diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h
- index 23b35926f0..800846ed0d 100644
- --- a/libs/pbd/pbd/base_ui.h
- +++ b/libs/pbd/pbd/base_ui.h
- @@ -20,14 +20,20 @@
- #pragma once
- +#ifdef _WIN32
- +#define NOMINMAX
- +#define WIN32_LEAN_AND_MEAN
- +#endif
- +
- #include <string>
- #include <stdint.h>
- #include <sigc++/slot.h>
- #include <sigc++/trackable.h>
- -#include <glibmm/threads.h>
- #include <glibmm/main.h>
- +#include <mutex>
- +#include <condition_variable>
- #include "pbd/libpbd_visibility.h"
- #include "pbd/crossthread.h"
- @@ -79,8 +85,8 @@ class LIBPBD_API BaseUI : public sigc::trackable, public PBD::EventLoop
- Glib::RefPtr<Glib::MainLoop> _main_loop;
- Glib::RefPtr<Glib::MainContext> m_context;
- PBD::Thread* _run_loop_thread;
- - Glib::Threads::Mutex _run_lock;
- - Glib::Threads::Cond _running;
- + std::mutex _run_lock;
- + std::condition_variable _running;
- /* this signals _running from within the event loop,
- from an idle callback
- diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h
- index 4cd0433d09..c700f00a93 100644
- --- a/libs/pbd/pbd/controllable.h
- +++ b/libs/pbd/pbd/controllable.h
- @@ -25,10 +25,11 @@
- #include <memory>
- #include <string>
- #include <set>
- +#include <glib.h>
- +#include <glibmm.h>
- #include "pbd/libpbd_visibility.h"
- #include "pbd/signals.h"
- -#include <glibmm/threads.h>
- #include "pbd/statefuldestructible.h"
- @@ -191,7 +192,7 @@ private:
- typedef std::set<PBD::Controllable*> Controllables;
- static ScopedConnectionList registry_connections;
- - static Glib::Threads::RWLock registry_lock;
- + static std::shared_mutex registry_lock;
- static Controllables registry;
- static void add (Controllable&);
- diff --git a/libs/pbd/pbd/crossthread.h b/libs/pbd/pbd/crossthread.h
- index 08f61a5b58..f5eb328696 100644
- --- a/libs/pbd/pbd/crossthread.h
- +++ b/libs/pbd/pbd/crossthread.h
- @@ -19,18 +19,29 @@
- #pragma once
- -#ifdef check
- -#undef check
- -#endif
- -
- -#include <glibmm/main.h>
- -
- #include "pbd/libpbd_visibility.h"
- +#include <gio/gio.h>
- +
- #ifdef PLATFORM_WINDOWS
- +#include <winsock2.h>
- #include <windows.h>
- +#undef check
- +#undef read
- +#undef write
- +#undef close
- +#undef seek
- +#undef flush
- +#undef interface
- +#undef min
- +#ifdef Flags
- +#undef Flags
- +#endif
- +#undef max
- #endif // PLATFORM_WINDOWS
- +#include <glibmm/main.h>
- +#include <giomm.h>
- /** A simple abstraction of a mechanism of signalling one thread from another.
- * The signaller calls \ref wakeup() to tell the signalled thread to check for
- @@ -81,25 +92,26 @@ public:
- */
- void drain ();
- - void set_receive_handler (sigc::slot<bool,Glib::IOCondition> s);
- void attach (Glib::RefPtr<Glib::MainContext>);
- + void set_receive_handler (sigc::slot<bool(Glib::IOCondition)> s) { receive_slot = s; }
- private:
- - friend gboolean cross_thread_channel_call_receive_slot (GIOChannel*, GIOCondition condition, void *data);
- + sigc::slot<bool(Glib::IOCondition)> receive_slot;
- +#ifndef PLATFORM_WINDOWS
- + friend gboolean cross_thread_channel_call_receive_slot (GIOChannel*, GIOCondition condition, void *data);
- GIOChannel* receive_channel;
- GSource* receive_source;
- - sigc::slot<bool,Glib::IOCondition> receive_slot;
- +#endif
- bool poll_for_request();
- #ifndef PLATFORM_WINDOWS
- int fds[2]; // current implementation uses a pipe/fifo
- #else
- -
- - SOCKET send_socket;
- - SOCKET receive_socket;
- - struct sockaddr_in recv_address;
- + Glib::RefPtr<Gio::Socket> send_socket;
- + Glib::RefPtr<Gio::Socket> recv_socket;
- + Glib::RefPtr<Gio::SocketSource> source;
- #endif
- };
- diff --git a/libs/pbd/pbd/debug.h b/libs/pbd/pbd/debug.h
- index 7efea83d11..7e51c474a5 100644
- --- a/libs/pbd/pbd/debug.h
- +++ b/libs/pbd/pbd/debug.h
- @@ -31,7 +31,7 @@
- /* check for PTW32_VERSION */
- #ifdef COMPILER_MSVC
- -#include <ardourext/pthread.h>
- +#include <pthread.h>
- #else
- #include <pthread.h>
- #endif
- diff --git a/libs/pbd/pbd/event_loop.h b/libs/pbd/pbd/event_loop.h
- index 31df5d5925..b7415cc6d2 100644
- --- a/libs/pbd/pbd/event_loop.h
- +++ b/libs/pbd/pbd/event_loop.h
- @@ -25,13 +25,61 @@
- #include <map>
- #include <stdint.h>
- #include <pthread.h>
- -#include <glibmm/threads.h>
- -
- +#include <mutex>
- +#include <sigc++/trackable.h>
- +#include <functional>
- #include "pbd/libpbd_visibility.h"
- +#ifdef PLATFORM_WINDOWS
- +#include <shared_mutex>
- +#endif
- namespace PBD
- {
- +#ifdef PLATFORM_WINDOWS
- +using RWMutex = std::shared_mutex;
- +template<typename Mutex>
- +using ReadLock = std::shared_lock<Mutex>;
- +template<typename Mutex>
- +using WriteLock = std::unique_lock<Mutex>;
- +#else
- +// Wrapper for pthread_rwlock to maintain consistent behavior with glibmm-2.4
- +class PThreadRWLock {
- + pthread_rwlock_t _lock;
- +public:
- + PThreadRWLock() { pthread_rwlock_init(&_lock, nullptr); }
- + ~PThreadRWLock() { pthread_rwlock_destroy(&_lock); }
- + void lock() { pthread_rwlock_wrlock(&_lock); }
- + void unlock() { pthread_rwlock_unlock(&_lock); }
- + void lock_shared() { pthread_rwlock_rdlock(&_lock); }
- + void unlock_shared() { pthread_rwlock_unlock(&_lock); }
- + // Non-copyable
- + PThreadRWLock(const PThreadRWLock&) = delete;
- + PThreadRWLock& operator=(const PThreadRWLock&) = delete;
- +};
- +using RWMutex = PThreadRWLock;
- +
- +template<typename Mutex>
- +class ReadLock {
- + Mutex& _mutex;
- +public:
- + explicit ReadLock(Mutex& m) : _mutex(m) { _mutex.lock_shared(); }
- + ~ReadLock() { _mutex.unlock_shared(); }
- + ReadLock(const ReadLock&) = delete;
- + ReadLock& operator=(const ReadLock&) = delete;
- +};
- +
- +template<typename Mutex>
- +class WriteLock {
- + Mutex& _mutex;
- +public:
- + explicit WriteLock(Mutex& m) : _mutex(m) { _mutex.lock(); }
- + ~WriteLock() { _mutex.unlock(); }
- + WriteLock(const WriteLock&) = delete;
- + WriteLock& operator=(const WriteLock&) = delete;
- +};
- +#endif
- +
- /** An EventLoop is as basic abstraction designed to be used with any "user
- * interface" (not necessarily graphical) that needs to wait on
- * events/requests and dispatch/process them as they arrive.
- @@ -41,7 +89,15 @@ namespace PBD
- * when something like this is needed (it inherits from EventLoop).
- */
- -class LIBPBD_API EventLoop
- +class EventLoop;
- +
- +namespace detail {
- +struct EventLoopTLS {
- + static thread_local EventLoop* value;
- +};
- +}
- +
- +class LIBPBD_API EventLoop : private detail::EventLoopTLS
- {
- public:
- EventLoop (std::string const&);
- @@ -54,6 +110,7 @@ public:
- struct BaseRequestObject;
- struct InvalidationRecord {
- + sigc::notifiable notifiable_base;
- std::list<BaseRequestObject*> requests;
- PBD::EventLoop* event_loop;
- std::atomic<int> _valid;
- @@ -71,7 +128,7 @@ public:
- int use_count () { return _ref.load (); }
- };
- - static void* invalidate_request (void* data);
- + static void invalidate_request (sigc::notifiable* data);
- struct BaseRequestObject {
- RequestType type;
- @@ -87,7 +144,7 @@ public:
- };
- virtual bool call_slot (InvalidationRecord*, const std::function<void()>&) = 0;
- - virtual Glib::Threads::RWLock& slot_invalidation_rwlock() = 0;
- + virtual RWMutex& slot_invalidation_rwlock() = 0;
- std::string event_loop_name() const { return _name; }
- @@ -109,12 +166,14 @@ public:
- static InvalidationRecord* __invalidator (sigc::trackable& trackable, const char*, int);
- private:
- - static Glib::Threads::Private<EventLoop> thread_event_loop;
- + static EventLoop* current_thread_event_loop() {
- + return EventLoopTLS::value;
- + }
- std::string _name;
- typedef std::vector<ThreadBufferMapping> ThreadRequestBufferList;
- static ThreadRequestBufferList thread_buffer_requests;
- - static Glib::Threads::Mutex thread_buffer_requests_lock;
- + static std::mutex thread_buffer_requests_lock;
- struct RequestBufferSupplier {
- diff --git a/libs/pbd/pbd/id.h b/libs/pbd/pbd/id.h
- index cf8d571e51..bfe28ff9db 100644
- --- a/libs/pbd/pbd/id.h
- +++ b/libs/pbd/pbd/id.h
- @@ -24,7 +24,7 @@
- #include <stdint.h>
- #include <string>
- -#include <glibmm/threads.h>
- +#include <glib.h>
- #include "pbd/libpbd_visibility.h"
- @@ -70,7 +70,7 @@ class LIBPBD_API ID {
- uint64_t _id;
- bool string_assign (std::string);
- - static Glib::Threads::Mutex* counter_lock;
- + static GMutex* counter_lock;
- static uint64_t _counter;
- };
- diff --git a/libs/pbd/pbd/msvc_pbd.h b/libs/pbd/pbd/msvc_pbd.h
- index ed52b55b0a..e448484fb5 100644
- --- a/libs/pbd/pbd/msvc_pbd.h
- +++ b/libs/pbd/pbd/msvc_pbd.h
- @@ -28,8 +28,8 @@
- #ifndef COMPILER_MSVC
- #include <sys/time.h>
- #else
- -#include <ardourext/misc.h>
- -#include <ardourext/sys/time.h>
- +#include <pbd/compat.h>
- +#include <sys/time.h>
- #endif
- #if !defined(PBD_IS_IN_WINDLL)
- diff --git a/libs/pbd/pbd/pool.h b/libs/pbd/pbd/pool.h
- index 0346736b50..224b406682 100644
- --- a/libs/pbd/pbd/pool.h
- +++ b/libs/pbd/pbd/pool.h
- @@ -23,8 +23,8 @@
- #include <string>
- #include <vector>
- -
- -#include <glibmm/threads.h>
- +#include <mutex>
- +#include <thread>
- #include "pbd/libpbd_visibility.h"
- #include "pbd/ringbuffer.h"
- @@ -85,7 +85,7 @@ public:
- virtual void release (void*);
- private:
- - Glib::Threads::Mutex m_lock;
- + std::mutex m_lock;
- };
- class LIBPBD_API MultiAllocSingleReleasePool : public Pool
- @@ -98,7 +98,7 @@ public:
- virtual void release (void*);
- private:
- - Glib::Threads::Mutex m_lock;
- + std::mutex m_lock;
- };
- class LIBPBD_API PerThreadPool;
- @@ -150,10 +150,6 @@ class LIBPBD_API PerThreadPool
- public:
- PerThreadPool ();
- - const Glib::Threads::Private<CrossThreadPool>& key () const
- - {
- - return _key;
- - }
- void create_per_thread_pool (std::string name, unsigned long item_size, unsigned long nitems, PoolDumpCallback cb = NULL);
- @@ -164,13 +160,14 @@ public:
- void add_to_trash (CrossThreadPool*);
- private:
- - Glib::Threads::Private<CrossThreadPool> _key;
- std::string _name;
- /** mutex to protect either changes to the _trash variable, or writes to the RingBuffer */
- - Glib::Threads::Mutex _trash_mutex;
- + std::mutex _trash_mutex;
- PBD::RingBuffer<CrossThreadPool*>* _trash;
- };
- +extern thread_local CrossThreadPool* pbd_tls_pool_ptr;
- +
- } // namespace PBD
- diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h
- index b864205791..e59bdb403e 100644
- --- a/libs/pbd/pbd/pthread_utils.h
- +++ b/libs/pbd/pbd/pthread_utils.h
- @@ -37,7 +37,7 @@
- #endif /* PTHREAD_MACROS_DEFINED */
- #ifdef COMPILER_MSVC
- -#include <ardourext/pthread.h>
- +#include <pthread.h>
- #else
- #include <pthread.h>
- #endif
- diff --git a/libs/pbd/pbd/scoped_file_descriptor.h b/libs/pbd/pbd/scoped_file_descriptor.h
- index 0d525275aa..0864ee2f6a 100644
- --- a/libs/pbd/pbd/scoped_file_descriptor.h
- +++ b/libs/pbd/pbd/scoped_file_descriptor.h
- @@ -18,7 +18,15 @@
- #pragma once
- +#ifdef COMPILER_MSVC
- +#include <io.h> // _close, intptr_t
- +#include <stdlib.h> // intptr_t
- +inline int close(int fd) { return _close(fd); }
- +#else
- #include <unistd.h>
- +#endif
- +
- +#include <cstddef>
- namespace PBD {
- diff --git a/libs/pbd/pbd/signals.h b/libs/pbd/pbd/signals.h
- index db59407fc0..d2a19f12e4 100644
- --- a/libs/pbd/pbd/signals.h
- +++ b/libs/pbd/pbd/signals.h
- @@ -32,7 +32,8 @@
- #include <atomic>
- -#include <glibmm/threads.h>
- +#include <mutex>
- +#include <thread>
- #include <boost/bind/protect.hpp>
- #include <boost/enable_shared_from_this.hpp>
- @@ -89,7 +90,7 @@ public:
- #endif
- protected:
- - mutable Glib::Threads::Mutex _mutex;
- + mutable std::mutex _mutex;
- std::atomic<bool> _in_dtor;
- #ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
- bool _debug_connection;
- @@ -160,12 +161,12 @@ public:
- operator() (A... a);
- bool empty () const {
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- return _slots.empty ();
- }
- size_t size () const {
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- return _slots.size ();
- }
- @@ -201,7 +202,7 @@ public:
- void disconnect ()
- {
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- SignalBase* signal = _signal.exchange (0, std::memory_order_acq_rel);
- if (signal) {
- /* It is safe to assume that signal has not been destructed.
- @@ -233,7 +234,7 @@ public:
- * be an effective NO-OP since SignalBase::_in_dtor is true,
- * then we can proceed.
- */
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- }
- if (_invalidation_record) {
- _invalidation_record->unref ();
- @@ -241,7 +242,7 @@ public:
- }
- private:
- - Glib::Threads::Mutex _mutex;
- + std::mutex _mutex;
- std::atomic<SignalBase*> _signal;
- PBD::EventLoop::InvalidationRecord* _invalidation_record;
- };
- @@ -292,7 +293,7 @@ class LIBPBD_API ScopedConnectionList
- void add_connection (const UnscopedConnection& c);
- void drop_connections ();
- - std::list<ScopedConnectionList*>::size_type size() const { Glib::Threads::Mutex::Lock lm (_scoped_connection_lock); return _scoped_connection_list.size(); }
- + std::list<ScopedConnectionList*>::size_type size() const { std::unique_lock<std::mutex> lm (_scoped_connection_lock); return _scoped_connection_list.size(); }
- private:
- /* Even though our signals code is thread-safe, this additional list of
- @@ -306,7 +307,7 @@ class LIBPBD_API ScopedConnectionList
- one from another.
- */
- - mutable Glib::Threads::Mutex _scoped_connection_lock;
- + mutable std::mutex _scoped_connection_lock;
- typedef std::list<ScopedConnection*> ConnectionList;
- ConnectionList _scoped_connection_list;
- @@ -325,7 +326,7 @@ template <typename Combiner, typename R, typename... A>
- SignalWithCombiner<Combiner, R(A...)>::~SignalWithCombiner ()
- {
- _in_dtor.store (true, std::memory_order_release);
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- /* Tell our connection objects that we are going away, so they don't try to call us */
- for (typename Slots::const_iterator i = _slots.begin(); i != _slots.end(); ++i) {
- i->first->signal_going_away ();
- @@ -461,7 +462,7 @@ SignalWithCombiner<Combiner, R(A...)>::operator() (A... a)
- */
- {
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- /* copy only the raw pointer, no need for a shared_ptr in this
- * context, we only use the address as a lookup into the _slots
- * container. Note: because of the use of a stack allocator,
- @@ -491,7 +492,7 @@ SignalWithCombiner<Combiner, R(A...)>::operator() (A... a)
- bool still_there = false;
- {
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- typename Slots::const_iterator f = std::find_if (_slots.begin(), _slots.end(), [&](typename Slots::value_type const & elem) { return elem.first.get() == c; });
- if (f != _slots.end()) {
- functor = f->second;
- @@ -562,7 +563,7 @@ SignalWithCombiner<Combiner, R(A...)>::operator() (A... a)
- bool still_there = false;
- {
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- typename Slots::const_iterator f = std::find_if (_slots.begin(), _slots.end(), [&](typename Slots::value_type const & elem) { return elem.first.get() == c; });
- if (f != _slots.end()) {
- @@ -597,7 +598,7 @@ SignalWithCombiner<Combiner, R(A...)>::_connect (PBD::EventLoop::InvalidationRec
- slot_function_type f)
- {
- std::shared_ptr<Connection> c (new Connection (this, ir));
- - Glib::Threads::Mutex::Lock lm (_mutex);
- + std::unique_lock<std::mutex> lm (_mutex);
- _slots[c] = f;
- #ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
- @@ -617,14 +618,14 @@ void
- SignalWithCombiner<Combiner, R(A...)>::disconnect (std::shared_ptr<Connection> c)
- {
- /* ~ScopedConnection can call this concurrently with our d'tor */
- - Glib::Threads::Mutex::Lock lm (_mutex, Glib::Threads::TRY_LOCK);
- - while (!lm.locked()) {
- + std::unique_lock<std::mutex> lm (_mutex, std::try_to_lock);
- + while (!lm.owns_lock()) {
- if (_in_dtor.load (std::memory_order_acquire)) {
- /* d'tor signal_going_away() took care of everything already */
- return;
- }
- /* Spin */
- - lm.try_acquire ();
- + (void)lm.try_lock ();
- }
- _slots.erase (c);
- lm.release ();
- diff --git a/libs/pbd/pbd/stack_allocator.h b/libs/pbd/pbd/stack_allocator.h
- index b5a907711b..da862d00d8 100644
- --- a/libs/pbd/pbd/stack_allocator.h
- +++ b/libs/pbd/pbd/stack_allocator.h
- @@ -105,7 +105,7 @@ public:
- size_type max_size () const throw ()
- {
- - return std::numeric_limits<size_type>::max () / sizeof (T);
- + return (std::numeric_limits<size_type>::max) () / sizeof (T);
- }
- bool operator== (StackAllocator const& a) const
- diff --git a/libs/pbd/pbd/stacktrace.h b/libs/pbd/pbd/stacktrace.h
- index 9ea89f5b30..8563407b2e 100644
- --- a/libs/pbd/pbd/stacktrace.h
- +++ b/libs/pbd/pbd/stacktrace.h
- @@ -27,7 +27,7 @@
- #include <iostream>
- #include <ostream>
- -#include <glibmm/threads.h>
- +#include <glib.h>
- #include <list>
- #ifdef HAVE_EXECINFO
- @@ -57,8 +57,9 @@ public:
- #else
- allocation_backtrace_size = 0;
- #endif
- - Glib::Threads::Mutex::Lock lm (all_mutex);
- + g_mutex_lock (&all_mutex);
- all.push_back (this);
- + g_mutex_unlock (&all_mutex);
- }
- thing_with_backtrace (const thing_with_backtrace<T>& other) {
- @@ -69,16 +70,18 @@ public:
- #else
- allocation_backtrace_size = 0;
- #endif
- - Glib::Threads::Mutex::Lock lm (all_mutex);
- + g_mutex_lock (&all_mutex);
- all.push_back (this);
- + g_mutex_unlock (&all_mutex);
- }
- ~thing_with_backtrace() {
- if (allocation_backtrace_size) {
- delete [] allocation_backtrace;
- }
- - Glib::Threads::Mutex::Lock lm (all_mutex);
- + g_mutex_lock (&all_mutex);
- all.remove (this);
- + g_mutex_unlock (&all_mutex);
- }
- thing_with_backtrace<T>& operator= (const thing_with_backtrace<T>& other) {
- @@ -112,11 +115,11 @@ private:
- void** allocation_backtrace;
- int allocation_backtrace_size;
- static std::list<thing_with_backtrace<T>* > all;
- - static Glib::Threads::Mutex all_mutex;
- + static GMutex all_mutex;
- };
- template<typename T> /*LIBPBD_API*/ std::list<PBD::thing_with_backtrace<T> *> PBD::thing_with_backtrace<T>::all;
- -template<typename T> /*LIBPBD_API*/ Glib::Threads::Mutex PBD::thing_with_backtrace<T>::all_mutex;
- +template<typename T> /*LIBPBD_API*/ GMutex PBD::thing_with_backtrace<T>::all_mutex;
- } // namespace PBD
- diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h
- index 8bb10b2cbc..74a02c9490 100644
- --- a/libs/pbd/pbd/stateful.h
- +++ b/libs/pbd/pbd/stateful.h
- @@ -27,6 +27,7 @@
- #include <list>
- #include <cassert>
- +#include <glib.h>
- #include "pbd/libpbd_visibility.h"
- #include "pbd/id.h"
- #include "pbd/xml++.h"
- @@ -123,7 +124,7 @@ class LIBPBD_API Stateful {
- XMLNode *_extra_xml;
- XMLNode *_instant_xml;
- PBD::PropertyChange _pending_changed;
- - Glib::Threads::Mutex _lock;
- + GMutex _lock;
- std::string _xml_node_name; ///< name of node to use for this object in XML
- OwnedPropertyList* _properties;
- @@ -138,7 +139,7 @@ class LIBPBD_API Stateful {
- private:
- friend struct ForceIDRegeneration;
- - static Glib::Threads::Private<bool> _regenerate_xml_or_string_ids;
- + static GPrivate* _regenerate_xml_or_string_ids;
- PBD::ID _id;
- std::atomic<int> _stateful_frozen;
- diff --git a/libs/pbd/pbd/timer.h b/libs/pbd/pbd/timer.h
- index 6c95da2537..dccf5676b2 100644
- --- a/libs/pbd/pbd/timer.h
- +++ b/libs/pbd/pbd/timer.h
- @@ -88,7 +88,7 @@ public:
- StandardTimer (unsigned int interval,
- const Glib::RefPtr<Glib::MainContext>& main_context = Glib::MainContext::get_default());
- - sigc::connection connect (const sigc::slot<void>& slot);
- + sigc::connection connect (const sigc::slot<void()>& slot);
- virtual unsigned int connection_count () const
- { return m_signal.size (); }
- @@ -97,7 +97,7 @@ protected:
- virtual bool on_elapsed ();
- - sigc::signal<void> m_signal;
- + sigc::signal<void()> m_signal;
- };
- @@ -109,7 +109,7 @@ public:
- const Glib::RefPtr<Glib::MainContext>& main_context = Glib::MainContext::get_default());
- - sigc::connection connect (const sigc::slot<void, bool>& slot);
- + sigc::connection connect (const sigc::slot<void(bool)>& slot);
- virtual unsigned int connection_count () const
- { return m_blink_signal.size (); }
- @@ -118,7 +118,7 @@ protected:
- virtual bool on_elapsed ();
- - sigc::signal<void, bool> m_blink_signal;
- + sigc::signal<void(bool)> m_blink_signal;
- };
- diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h
- index 5d93d451ac..158c9087ca 100644
- --- a/libs/pbd/pbd/undo.h
- +++ b/libs/pbd/pbd/undo.h
- @@ -25,14 +25,14 @@
- #include <list>
- #include <map>
- #include <string>
- -
- +#include <ctime>
- #include <sigc++/bind.h>
- #include <sigc++/slot.h>
- -#ifndef COMPILER_MSVC
- -#include <sys/time.h>
- +#ifdef COMPILER_MSVC
- +#include <winsock2.h>
- #else
- -#include <ardourext/misc.h>
- +#include <sys/time.h>
- #endif
- #include "pbd/command.h"
- @@ -67,19 +67,19 @@ public:
- XMLNode& get_state () const;
- - void set_timestamp (struct timeval& t)
- + void set_timestamp (::timeval& t)
- {
- _timestamp = t;
- }
- - const struct timeval& timestamp () const
- + const ::timeval& timestamp () const
- {
- return _timestamp;
- }
- private:
- std::list<PBD::Command*> actions;
- - struct timeval _timestamp;
- + ::timeval _timestamp;
- bool _clearing;
- void about_to_explicitly_delete ();
- diff --git a/libs/pbd/pbd/windows_special_dirs.h b/libs/pbd/pbd/windows_special_dirs.h
- index 179fef1014..c9b267efe9 100644
- --- a/libs/pbd/pbd/windows_special_dirs.h
- +++ b/libs/pbd/pbd/windows_special_dirs.h
- @@ -21,7 +21,11 @@
- #pragma once
- +#define WIN32_LEAN_AND_MEAN
- +#define NOMINMAX
- +
- #include <windows.h>
- +
- #include <string>
- #include "pbd/libpbd_visibility.h"
- diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc
- index 83c8d29ac7..3a5afa8e5c 100644
- --- a/libs/pbd/pool.cc
- +++ b/libs/pbd/pool.cc
- @@ -35,6 +35,8 @@
- using namespace std;
- using namespace PBD;
- +thread_local CrossThreadPool* PBD::pbd_tls_pool_ptr = nullptr;
- +
- Pool::Pool (string n, unsigned long item_size, unsigned long nitems, PoolDumpCallback cb)
- : free_list (nitems)
- , _name (n)
- @@ -132,7 +134,7 @@ SingleAllocMultiReleasePool::~SingleAllocMultiReleasePool ()
- void*
- MultiAllocSingleReleasePool::alloc ()
- {
- - Glib::Threads::Mutex::Lock guard (m_lock);
- + std::lock_guard<std::mutex> guard (m_lock);
- return Pool::alloc ();
- }
- @@ -151,7 +153,7 @@ SingleAllocMultiReleasePool::alloc ()
- void
- SingleAllocMultiReleasePool::release (void* ptr)
- {
- - Glib::Threads::Mutex::Lock guard (m_lock);
- + std::lock_guard<std::mutex> guard (m_lock);
- Pool::release (ptr);
- }
- @@ -182,8 +184,7 @@ free_per_thread_pool (void* ptr)
- }
- PerThreadPool::PerThreadPool ()
- - : _key (free_per_thread_pool)
- - , _trash (0)
- + : _trash (nullptr)
- {
- }
- @@ -195,7 +196,7 @@ PerThreadPool::PerThreadPool ()
- void
- PerThreadPool::create_per_thread_pool (string n, unsigned long isize, unsigned long nitems, PoolDumpCallback cb)
- {
- - _key.set (new CrossThreadPool (n, isize, nitems, this, cb));
- + pbd_tls_pool_ptr = new CrossThreadPool (n, isize, nitems, this, cb);
- }
- /** @return True if CrossThreadPool for the current thread exists,
- @@ -204,7 +205,7 @@ PerThreadPool::create_per_thread_pool (string n, unsigned long isize, unsigned l
- bool
- PerThreadPool::has_per_thread_pool ()
- {
- - CrossThreadPool* p = _key.get ();
- + CrossThreadPool* p = pbd_tls_pool_ptr;
- if (p) {
- return true;
- }
- @@ -217,7 +218,7 @@ PerThreadPool::has_per_thread_pool ()
- CrossThreadPool*
- PerThreadPool::per_thread_pool (bool must_exist)
- {
- - CrossThreadPool* p = _key.get ();
- + CrossThreadPool* p = pbd_tls_pool_ptr;
- if (!p && must_exist) {
- fatal << "programming error: no per-thread pool \"" << _name << "\" for thread " << pthread_name () << endmsg;
- abort (); /*NOTREACHED*/
- @@ -228,7 +229,7 @@ PerThreadPool::per_thread_pool (bool must_exist)
- void
- PerThreadPool::set_trash (RingBuffer<CrossThreadPool*>* t)
- {
- - Glib::Threads::Mutex::Lock lm (_trash_mutex);
- + std::lock_guard<std::mutex> lm (_trash_mutex);
- _trash = t;
- }
- @@ -236,7 +237,7 @@ PerThreadPool::set_trash (RingBuffer<CrossThreadPool*>* t)
- void
- PerThreadPool::add_to_trash (CrossThreadPool* p)
- {
- - Glib::Threads::Mutex::Lock lm (_trash_mutex);
- + std::lock_guard<std::mutex> lm (_trash_mutex);
- if (!_trash) {
- warning << "Pool " << p->name () << " has no trash collector; a memory leak has therefore occurred" << endmsg;
- diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc
- index c3d54afc80..40cec75b47 100644
- --- a/libs/pbd/pthread_utils.cc
- +++ b/libs/pbd/pthread_utils.cc
- @@ -37,28 +37,41 @@
- #include "pbd/failed_constructor.h"
- #include "pbd/pthread_utils.h"
- -#ifdef COMPILER_MSVC
- -DECLARE_DEFAULT_COMPARISONS (pthread_t) // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
- - // searched and sorted. Thus, when instantiating the container, MSVC complains
- - // if the type of object being contained has no appropriate comparison operators
- - // defined (specifically, if operators '<' and '==' are undefined). This seems
- - // to be the case with ptw32 'pthread_t' which is a simple struct.
- -
- -#define pthread_gethandle pthread_getw32threadhandle_np
- -#endif
- -
- #ifdef __APPLE__
- #include <mach/mach_time.h>
- #include <mach/thread_act.h>
- #include <mach/thread_policy.h>
- #endif
- +#ifdef COMPILER_MSVC
- +/* MSVC needs < and == for pthread_t because it is an opaque struct. */
- +namespace std {
- + template<>
- + struct less<pthread_t> {
- + bool operator() (const pthread_t& a, const pthread_t& b) const {
- + return a.p < b.p; // ptw32 layout: first member is the Win32 HANDLE
- + }
- + };
- +
- + inline bool operator== (const pthread_t& a, const pthread_t& b) {
- + return a.p == b.p;
- + }
- + inline bool operator!= (const pthread_t& a, const pthread_t& b) {
- + return !(a == b);
- + }
- +}
- +#define pthread_gethandle pthread_getw32threadhandle_np
- +#endif
- +
- +
- +
- +
- using namespace std;
- typedef std::map<pthread_t, std::string> ThreadMap;
- static ThreadMap all_threads;
- static pthread_mutex_t thread_map_lock = PTHREAD_MUTEX_INITIALIZER;
- -static Glib::Threads::Private<char> thread_name (free);
- +static thread_local std::string thread_name;
- static int base_priority_relative_to_max = -20;
- #ifdef PLATFORM_WINDOWS
- @@ -234,8 +247,7 @@ pthread_create_and_store (string name, pthread_t* thread, void* (*start_routine)
- void
- pthread_set_name (const char* str)
- {
- - /* copy string and delete it when exiting */
- - thread_name.set (strdup (str)); // leaks
- + thread_name = str;
- #if !defined PTW32_VERSION && defined _GNU_SOURCE
- /* set public thread name, up to 16 chars */
- @@ -249,10 +261,8 @@ pthread_set_name (const char* str)
- const char*
- pthread_name ()
- {
- - const char* str = thread_name.get ();
- -
- - if (str) {
- - return str;
- + if (!thread_name.empty()) {
- + return thread_name.c_str();
- }
- return "unknown";
- }
- @@ -443,7 +453,7 @@ pbd_set_thread_priority (pthread_t thread, int policy, int priority)
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Change '%1' to policy = %2 priority = %3\n", pthread_name(), policy, param.sched_priority));
- #ifdef PLATFORM_WINDOWS
- - if (is_pthread_active (thread) && param.sched_priority >= 12) {
- + if (param.sched_priority >= 12) {
- if (set_win_set_realtime_policy (thread, param.sched_priority)) {
- return 0;
- }
- @@ -611,5 +621,29 @@ PBD::Thread::join ()
- bool
- PBD::Thread::caller_is_self () const
- {
- - return pthread_equal (_t, pthread_self ()) != 0;
- + return pthread_equal (_t, pthread_self ());
- +}
- +
- +#ifdef COMPILER_MSVC
- +extern "C" int
- +pthread_setname_np (pthread_t thread, const char* name)
- +{
- + char buf[16];
- + strncpy (buf, name, 15);
- + buf[15] = 0;
- +
- + #pragma pack(push,8)
- + struct { DWORD type; LPCSTR szName; DWORD threadId; DWORD flags; } info = {
- + 0x1000, buf, static_cast<DWORD>(pthread_getw32threadid_np(thread)), 0
- + };
- + #pragma pack(pop)
- +
- + __try {
- + RaiseException (0x406D1384, 0, sizeof(info)/sizeof(ULONG_PTR),
- + reinterpret_cast<ULONG_PTR*>(&info));
- + } __except(EXCEPTION_EXECUTE_HANDLER) {
- + /* name not supported on this OS version – benign */
- + }
- + return 0;
- }
- +#endif
- \ No newline at end of file
- diff --git a/libs/pbd/signals.cc b/libs/pbd/signals.cc
- index 3c9d14dac5..e75ab9274c 100644
- --- a/libs/pbd/signals.cc
- +++ b/libs/pbd/signals.cc
- @@ -18,6 +18,7 @@
- */
- #include "pbd/signals.h"
- +#include <glib.h>
- #include "pbd/demangle.h"
- using namespace PBD;
- @@ -34,17 +35,17 @@ ScopedConnectionList::~ScopedConnectionList()
- void
- ScopedConnectionList::add_connection (const UnscopedConnection& c)
- {
- - Glib::Threads::Mutex::Lock lm (_scoped_connection_lock);
- + std::lock_guard<std::mutex> lock(_scoped_connection_lock);
- _scoped_connection_list.push_back (new ScopedConnection (c));
- }
- void
- ScopedConnectionList::drop_connections ()
- {
- - Glib::Threads::Mutex::Lock lm (_scoped_connection_lock);
- + std::lock_guard<std::mutex> lock(_scoped_connection_lock);
- - for (ConnectionList::iterator i = _scoped_connection_list.begin(); i != _scoped_connection_list.end(); ++i) {
- - delete *i;
- + for (auto* conn : _scoped_connection_list) {
- + delete conn;
- }
- _scoped_connection_list.clear ();
- diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc
- index 9879c7ee2e..3406aee143 100644
- --- a/libs/pbd/stateful.cc
- +++ b/libs/pbd/stateful.cc
- @@ -42,7 +42,7 @@ namespace PBD {
- int Stateful::current_state_version = 0;
- int Stateful::loading_state_version = 0;
- -Glib::Threads::Private<bool> Stateful::_regenerate_xml_or_string_ids;
- +GPrivate* Stateful::_regenerate_xml_or_string_ids = nullptr;
- Stateful::Stateful ()
- : _extra_xml (nullptr)
- @@ -110,7 +110,7 @@ Stateful::save_extra_xml (const XMLNode& node)
- void
- Stateful::add_instant_xml (XMLNode& node, const std::string& directory_path)
- {
- - if (!Glib::file_test (directory_path, Glib::FILE_TEST_IS_DIR)) {
- + if (!g_file_test (directory_path.c_str(), G_FILE_TEST_IS_DIR)) {
- if (g_mkdir_with_parents (directory_path.c_str(), 0755) != 0) {
- error << string_compose(_("Error: could not create directory %1"), directory_path) << endmsg;
- return;
- @@ -153,7 +153,7 @@ Stateful::instant_xml (const string& str, const std::string& directory_path)
- if (_instant_xml == nullptr) {
- std::string instant_xml_path = Glib::build_filename (directory_path, "instant.xml");
- - if (Glib::file_test (instant_xml_path, Glib::FILE_TEST_EXISTS)) {
- + if (g_file_test (instant_xml_path.c_str(), G_FILE_TEST_EXISTS)) {
- XMLTree tree;
- if (tree.read(instant_xml_path)) {
- _instant_xml = new XMLNode(*(tree.root()));
- @@ -287,13 +287,14 @@ Stateful::send_change (const PropertyChange& what_changed)
- }
- {
- - Glib::Threads::Mutex::Lock lm (_lock);
- + g_mutex_lock (&_lock);
- if (property_changes_suspended ()) {
- _pending_changed.add (what_changed);
- + g_mutex_unlock (&_lock);
- return;
- }
- }
- -
- + g_mutex_unlock (&_lock);
- PropertyChanged (what_changed);
- }
- @@ -309,9 +310,10 @@ Stateful::resume_property_changes ()
- PropertyChange what_changed;
- {
- - Glib::Threads::Mutex::Lock lm (_lock);
- + g_mutex_lock (&_lock);
- if (property_changes_suspended() && PBD::atomic_dec_and_test (_stateful_frozen) == FALSE) {
- + g_mutex_unlock (&_lock);
- return;
- }
- @@ -319,6 +321,7 @@ Stateful::resume_property_changes ()
- what_changed = _pending_changed;
- _pending_changed.clear ();
- }
- + g_mutex_unlock (&_lock);
- }
- mid_thaw (what_changed);
- @@ -385,7 +388,7 @@ Stateful::clear_owned_changes ()
- bool
- Stateful::set_id (const XMLNode& node)
- {
- - bool* regen = _regenerate_xml_or_string_ids.get();
- + bool* regen = (bool*) g_private_get (_regenerate_xml_or_string_ids);
- if (regen && *regen) {
- reset_id ();
- @@ -405,22 +408,22 @@ Stateful::reset_id ()
- _id = ID ();
- }
- -void
- -Stateful::set_id (const string& str)
- -{
- - bool* regen = _regenerate_xml_or_string_ids.get();
- + void
- + Stateful::set_id (const string& str)
- + {
- + bool* regen = (bool*) g_private_get (_regenerate_xml_or_string_ids);
- - if (regen && *regen) {
- - reset_id ();
- - } else {
- - _id = str;
- + if (regen && *regen) {
- + reset_id ();
- + } else {
- + _id = str;
- + }
- }
- -}
- bool
- Stateful::regenerate_xml_or_string_ids () const
- {
- - bool* regen = _regenerate_xml_or_string_ids.get();
- + bool* regen = (bool*) g_private_get (_regenerate_xml_or_string_ids);
- if (regen && *regen) {
- return true;
- } else {
- @@ -431,8 +434,9 @@ Stateful::regenerate_xml_or_string_ids () const
- void
- Stateful::set_regenerate_xml_and_string_ids_in_this_thread (bool yn)
- {
- - bool* val = new bool (yn);
- - _regenerate_xml_or_string_ids.set (val);
- + if (!_regenerate_xml_or_string_ids)
- + _regenerate_xml_or_string_ids = g_private_new (g_free);
- + g_private_set (_regenerate_xml_or_string_ids, g_memdup (&yn, sizeof (bool)));
- }
- } // namespace PBD
- diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc
- index 8570dfa598..b520993224 100644
- --- a/libs/pbd/system_exec.cc
- +++ b/libs/pbd/system_exec.cc
- @@ -22,7 +22,9 @@
- #include <stdlib.h>
- #include <string.h>
- #include <errno.h>
- +#ifndef COMPILER_MSVC
- #include <unistd.h>
- +#endif
- #include <algorithm>
- #include <assert.h>
- diff --git a/libs/pbd/timer.cc b/libs/pbd/timer.cc
- index 0bbfeb96ea..5f8affdb8a 100644
- --- a/libs/pbd/timer.cc
- +++ b/libs/pbd/timer.cc
- @@ -106,7 +106,7 @@ StandardTimer::StandardTimer(unsigned int interval,
- { }
- sigc::connection
- -StandardTimer::connect(const sigc::slot<void>& slot)
- +StandardTimer::connect(const sigc::slot<void()>& slot)
- {
- if(m_signal.size() == 0) { start(); }
- @@ -134,7 +134,7 @@ BlinkTimer::BlinkTimer(unsigned int interval,
- { }
- sigc::connection
- -BlinkTimer::connect(const sigc::slot<void, bool>& slot)
- +BlinkTimer::connect(const sigc::slot<void(bool)>& slot)
- {
- if(m_blink_signal.size() == 0) { start(); }
- diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc
- index 7c12abf1a4..67ac163306 100644
- --- a/libs/pbd/undo.cc
- +++ b/libs/pbd/undo.cc
- @@ -35,7 +35,13 @@ using namespace PBD;
- UndoTransaction::UndoTransaction ()
- : _clearing (false)
- {
- +#ifdef COMPILER_MSVC
- + gint64 now = g_get_real_time ();
- + _timestamp.tv_sec = now / G_USEC_PER_SEC;
- + _timestamp.tv_usec = now % G_USEC_PER_SEC;
- +#else
- gettimeofday (&_timestamp, 0);
- +#endif
- }
- UndoTransaction::UndoTransaction (const UndoTransaction& rhs)
- diff --git a/libs/pbd/windows_special_dirs.cc b/libs/pbd/windows_special_dirs.cc
- index 713677675f..cb59217dfd 100644
- --- a/libs/pbd/windows_special_dirs.cc
- +++ b/libs/pbd/windows_special_dirs.cc
- @@ -17,21 +17,34 @@
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- +#include "pbd/windows_special_dirs.h"
- +
- #include <shlobj.h>
- #include <winreg.h>
- -#include <glibmm.h>
- +#include <limits.h>
- +#include <glib.h>
- +#include <glibmm/convert.h>
- -#include "pbd/windows_special_dirs.h"
- +#ifdef _WIN32
- +#undef read
- +#undef write
- +#undef close
- +#undef flush
- +#undef seek
- +#endif
- +
- +#if !defined(PATH_MAX) && defined(MAX_PATH)
- +#define PATH_MAX MAX_PATH
- +#endif
- std::string
- PBD::get_win_special_folder_path (int csidl)
- {
- - wchar_t path[PATH_MAX+1];
- - HRESULT hr;
- - LPITEMIDLIST pidl = 0;
- - char *utf8_folder_path = 0;
- + wchar_t path[PATH_MAX+1]{};
- + LPITEMIDLIST pidl = nullptr ;
- + char *utf8_folder_path = nullptr;
- - if (S_OK == (hr = SHGetSpecialFolderLocation (0, csidl, &pidl))) {
- + if (S_OK == SHGetSpecialFolderLocation (nullptr, csidl, &pidl)) {
- if (SHGetPathFromIDListW (pidl, path)) {
- utf8_folder_path = g_utf16_to_utf8 ((const gunichar2*)path, -1, 0, 0, 0);
- @@ -44,7 +57,7 @@ PBD::get_win_special_folder_path (int csidl)
- g_free (utf8_folder_path);
- return folder_path;
- }
- - return std::string();
- + return {};
- }
- bool
- @@ -52,7 +65,7 @@ PBD::windows_query_registry (const char *regkey, const char *regval, std::string
- {
- HKEY key;
- DWORD size = PATH_MAX;
- - char tmp[PATH_MAX+1];
- + char tmp[PATH_MAX+1]{};
- if (ERROR_SUCCESS == RegOpenKeyExA (root, regkey, 0, KEY_READ, &key)) {
- if (ERROR_SUCCESS == RegQueryValueExA (key, regval, 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size)) {
- diff --git a/libs/pbd/wscript b/libs/pbd/wscript
- index a2c429b63c..e6fdb89b64 100644
- --- a/libs/pbd/wscript
- +++ b/libs/pbd/wscript
- @@ -99,6 +99,7 @@ def options(opt):
- def configure(conf):
- autowaf.check_pkg(conf, 'libxml-2.0', uselib_store='XML')
- autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0')
- + autowaf.check_pkg(conf, 'pthreadVC3', uselib_store='PTHREADVC3', mandatory=True)
- autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0', mandatory=True)
- autowaf.check_pkg(conf, 'libarchive', uselib_store='ARCHIVE', atleast_version='3.0.0', mandatory=True)
- autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True)
- @@ -179,10 +180,14 @@ def build(bld):
- obj.defines += [ 'USE_X86_64_ASM' ]
- if bld.env['build_target'] == 'mingw' or bld.env['build_target'] == 'msvc':
- obj.defines += [ 'NO_POSIX_MEMALIGN' ]
- + if bld.env['build_target'] == 'msvc':
- + obj.lib = ['advapi32', 'shell32', 'ws2_32', 'dbghelp', 'user32', 'ole32', 'winmm']
- + obj.uselib += ' PTHREADVC3'
- + else:
- + obj.uselib += ' OLE32 ADVAPI32 SHELL32 WINMM USER32 WSOCK32 WS2_32 DBGHELP GDI32 OLEAUT32 UUID COMCTL32 IMM32 WININET PTHREADVC3'
- obj.source += [ 'windows_special_dirs.cc' ]
- obj.source += [ 'windows_timer_utils.cc' ]
- obj.source += [ 'windows_mmcss.cc' ]
- - obj.uselib += ' OLE'
- if bld.env['BUILD_TESTS'] and bld.is_defined('HAVE_CPPUNIT'):
- # Unit tests
- diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
- index 08e88716d1..88fa6094b1 100644
- --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
- +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
- @@ -28,7 +28,7 @@
- #ifdef COMPILER_MSVC
- #include <io.h> // Microsoft's nearest equivalent to <unistd.h>
- -#include <ardourext/misc.h>
- +#include <pbd/compat.h>
- #else
- #include <regex.h>
- #endif
- diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h
- index 738dda4392..fb85126781 100644
- --- a/libs/temporal/temporal/tempo.h
- +++ b/libs/temporal/temporal/tempo.h
- @@ -27,8 +27,6 @@
- #include <boost/intrusive/list.hpp>
- -#include <glibmm/threads.h>
- -
- #include "pbd/command.h"
- #include "pbd/enum_convert.h"
- #include "pbd/integer_division.h"
- diff --git a/libs/tk/ydk-pixbuf/gdk-pixbuf-io.c b/libs/tk/ydk-pixbuf/gdk-pixbuf-io.c
- index 7c50b87460..c1369191ec 100644
- --- a/libs/tk/ydk-pixbuf/gdk-pixbuf-io.c
- +++ b/libs/tk/ydk-pixbuf/gdk-pixbuf-io.c
- @@ -26,9 +26,6 @@
- #include <stdio.h>
- #include <string.h>
- #include <errno.h>
- -#ifdef HAVE_UNISTD_H
- -#include <unistd.h>
- -#endif
- #include <glib.h>
- #include <gio/gio.h>
- diff --git a/libs/tk/ydk-pixbuf/io-xbm.c b/libs/tk/ydk-pixbuf/io-xbm.c
- index 1856adab51..b101fdf2cc 100644
- --- a/libs/tk/ydk-pixbuf/io-xbm.c
- +++ b/libs/tk/ydk-pixbuf/io-xbm.c
- @@ -30,9 +30,6 @@
- #include "config.h"
- #include <stdlib.h>
- #include <string.h>
- -#ifdef HAVE_UNISTD_H
- -#include <unistd.h>
- -#endif
- #include <stdio.h>
- #include <errno.h>
- #include "gdk-pixbuf-private.h"
- diff --git a/libs/tk/ydk-pixbuf/io-xpm.c b/libs/tk/ydk-pixbuf/io-xpm.c
- index 27add284ca..90bd351fd9 100644
- --- a/libs/tk/ydk-pixbuf/io-xpm.c
- +++ b/libs/tk/ydk-pixbuf/io-xpm.c
- @@ -26,9 +26,6 @@
- #include <stdlib.h>
- #include <string.h>
- #include <glib.h>
- -#ifdef HAVE_UNISTD_H
- -#include <unistd.h> /* for unlink */
- -#endif
- #include <errno.h>
- #include "gdk-pixbuf-private.h"
- #include <glib/gstdio.h>
- diff --git a/libs/tk/ydk/win32/bdfcursor.c b/libs/tk/ydk/win32/bdfcursor.c
- index 599f365747..ae56893c29 100644
- --- a/libs/tk/ydk/win32/bdfcursor.c
- +++ b/libs/tk/ydk/win32/bdfcursor.c
- @@ -24,6 +24,10 @@
- #include <ctype.h>
- #include <stdlib.h>
- +#ifdef _MSC_VER
- +#define strncasecmp _strnicmp
- +#endif
- +
- #include <glib.h>
- typedef struct {
- diff --git a/libs/tk/ydk/wscript b/libs/tk/ydk/wscript
- index ecff3c21cf..429090dfe0 100644
- --- a/libs/tk/ydk/wscript
- +++ b/libs/tk/ydk/wscript
- @@ -188,13 +188,18 @@ def build(bld):
- obj.export_includes += ['quartz']
- elif bld.env['build_target'] == 'mingw' or bld.env['build_target'] == 'msvc':
- obj.source = libydk_sources + libydk_win32_sources
- - obj.cflags += ['-mms-bitfields', '-Wl,--export-all-symbols']
- obj.uselib += ' GIO-WINDOWS'
- obj.defines += [ 'INSIDE_GDK_WIN32', 'DLL_EXPORT', 'PIC' ]
- obj.includes += ['win32', 'win32/ydk']
- obj.export_includes += ['win32']
- - obj.linkflags = ['-Wl,--export-all-symbols']
- - obj.ldflags = '-limm32 -lole32 -lgdi32 -lcomdlg32 -lwinspool -lcomctl32 -luuid'
- + if bld.env['build_target'] == 'mingw':
- + obj.cflags += ['-mms-bitfields']
- + obj.linkflags = ['-Wl,--export-all-symbols']
- + obj.ldflags = '-limm32 -lole32 -lgdi32 -lcomdlg32 -lwinspool -lcomctl32 -luuid'
- + else:
- + obj.lib = ['imm32', 'ole32', 'gdi32', 'comdlg32', 'winspool', 'comctl32', 'uuid', 'user32', 'shell32', 'advapi32']
- +
- +
- else:
- obj.source = libydk_sources + libydk_x11_sources
- obj.uselib += ' GIO-UNIX X11 XEXT XINERAMA RANDR DL'
- diff --git a/libs/tk/ydkmm/wscript b/libs/tk/ydkmm/wscript
- index b1dc925890..f60f7c348a 100644
- --- a/libs/tk/ydkmm/wscript
- +++ b/libs/tk/ydkmm/wscript
- @@ -45,8 +45,8 @@ def options(opt):
- def configure(conf):
- autowaf.check_pkg(conf, 'giomm-2.4', uselib_store='GIOMM', atleast_version='2.2', mandatory=True)
- - autowaf.check_pkg(conf, 'cairomm-1.0', uselib_store='CAIROMM', atleast_version='1.8.4', mandatory=True)
- - autowaf.check_pkg(conf, 'pangomm-1.4', uselib_store='PANGOMM', atleast_version='1.4', mandatory=True)
- + autowaf.check_pkg(conf, 'cairomm-1.16', uselib_store='CAIROMM', atleast_version='1.8.4', mandatory=True)
- + autowaf.check_pkg(conf, 'pangomm-2.48', uselib_store='PANGOMM', atleast_version='1.4', mandatory=True)
- autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True)
- autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0', mandatory=True)
- diff --git a/libs/tk/ztkmm/wscript b/libs/tk/ztkmm/wscript
- index dcee2d2029..aebb486847 100644
- --- a/libs/tk/ztkmm/wscript
- +++ b/libs/tk/ztkmm/wscript
- @@ -38,7 +38,7 @@ def options(opt):
- def configure(conf):
- autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True)
- - autowaf.check_pkg(conf, 'sigc++-2.0', uselib_store='SIGCPP', atleast_version='2.0', mandatory=True)
- + autowaf.check_pkg(conf, 'sigc++-3.0', uselib_store='SIGCPP', atleast_version='2.0', mandatory=True)
- def build(bld):
- obj = bld.shlib(features = 'cxx cxxshlib', source=libztkmm_sources)
- diff --git a/libs/vamp-plugins/Onset.cpp b/libs/vamp-plugins/Onset.cpp
- index 03e35ba3fe..5e472b335e 100644
- --- a/libs/vamp-plugins/Onset.cpp
- +++ b/libs/vamp-plugins/Onset.cpp
- @@ -15,7 +15,7 @@
- */
- #ifdef COMPILER_MSVC
- -#include <ardourext/float_cast.h>
- +#include <cmath>
- #endif
- #include <math.h>
- #include "Onset.h"
- diff --git a/libs/vamp-plugins/OnsetDetect.cpp b/libs/vamp-plugins/OnsetDetect.cpp
- index c2b6d68dbc..1298597f30 100644
- --- a/libs/vamp-plugins/OnsetDetect.cpp
- +++ b/libs/vamp-plugins/OnsetDetect.cpp
- @@ -13,7 +13,7 @@
- */
- #ifdef COMPILER_MSVC
- -#include <ardourext/float_cast.h>
- +#include <cmath>
- #endif
- #include "OnsetDetect.h"
- diff --git a/libs/vamp-plugins/PercussionOnsetDetector.cpp b/libs/vamp-plugins/PercussionOnsetDetector.cpp
- index 35dd8ca668..67315b9d36 100644
- --- a/libs/vamp-plugins/PercussionOnsetDetector.cpp
- +++ b/libs/vamp-plugins/PercussionOnsetDetector.cpp
- @@ -35,7 +35,7 @@
- */
- #ifdef COMPILER_MSVC
- -#include <ardourext/float_cast.h>
- +#include <cmath>
- #endif
- #include "PercussionOnsetDetector.h"
Add Comment
Please, Sign In to add comment