Fixes to compile with libc++
This commit is contained in:
parent
717832b791
commit
86d06057ca
|
@ -237,12 +237,14 @@ else()
|
||||||
message(STATUS "Crash handler: OFF")
|
message(STATUS "Crash handler: OFF")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads")
|
||||||
set(framework_DEFINITIONS ${framework_DEFINITIONS} -D_WIN32_WINNT=0x0501)
|
set(framework_DEFINITIONS ${framework_DEFINITIONS} -D_WIN32_WINNT=0x0501)
|
||||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--large-address-aware") # strip all debug information
|
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -Wl,--large-address-aware") # strip all debug information
|
||||||
set(SYSTEM_LIBRARIES "")
|
set(SYSTEM_LIBRARIES "")
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
set(framework_DEFINITIONS ${framework_DEFINITIONS} -D_REENTRANT) # enable thread safe code
|
set(framework_DEFINITIONS ${framework_DEFINITIONS} -D_REENTRANT) # enable thread safe code
|
||||||
set(SYSTEM_LIBRARIES "")
|
set(SYSTEM_LIBRARIES "")
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
# OPENAL_INCLUDE_DIR - the OPENAL include directory
|
# OPENAL_INCLUDE_DIR - the OPENAL include directory
|
||||||
# OPENAL_LIBRARY - the OPENAL library
|
# OPENAL_LIBRARY - the OPENAL library
|
||||||
|
|
||||||
FIND_PATH(OPENAL_INCLUDE_DIR NAMES AL/al.h)
|
SET(OPENAL_APPLE_PATHS ~/Library/Frameworks /Library/Frameworks)
|
||||||
|
FIND_PATH(OPENAL_INCLUDE_DIR NAMES AL/al.h PATHS ${OPENAL_APPLE_PATHS})
|
||||||
SET(_OPENAL_STATIC_LIBS libOpenAL.a libal.a libopenal.a libOpenAL32.a)
|
SET(_OPENAL_STATIC_LIBS libOpenAL.a libal.a libopenal.a libOpenAL32.a)
|
||||||
SET(_OPENAL_SHARED_LIBS libOpenAL.dll.a libal.dll.a libopenal.dll.a libOpenAL32.dll.a OpenAL al openal OpenAL32)
|
SET(_OPENAL_SHARED_LIBS libOpenAL.dll.a libal.dll.a libopenal.dll.a libOpenAL32.dll.a OpenAL al openal OpenAL32)
|
||||||
IF(USE_STATIC_LIBS)
|
IF(USE_STATIC_LIBS)
|
||||||
FIND_LIBRARY(OPENAL_LIBRARY NAMES ${_OPENAL_STATIC_LIBS} ${_OPENAL_SHARED_LIBS})
|
FIND_LIBRARY(OPENAL_LIBRARY NAMES ${_OPENAL_STATIC_LIBS} ${_OPENAL_SHARED_LIBS} PATHS ${OPENAL_APPLE_PATHS})
|
||||||
ELSE()
|
ELSE()
|
||||||
FIND_LIBRARY(OPENAL_LIBRARY NAMES ${_OPENAL_SHARED_LIBS} ${_OPENAL_STATIC_LIBS})
|
FIND_LIBRARY(OPENAL_LIBRARY NAMES ${_OPENAL_SHARED_LIBS} ${_OPENAL_STATIC_LIBS} PATHS ${OPENAL_APPLE_PATHS})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
INCLUDE(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
|
||||||
|
|
|
@ -75,16 +75,6 @@ void EventDispatcher::poll()
|
||||||
}
|
}
|
||||||
m_pollEventsSize = m_eventList.size();
|
m_pollEventsSize = m_eventList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto it = m_coroutines.begin(); it != m_coroutines.end();) {
|
|
||||||
stdext::coroutine& coroutine = (*it);
|
|
||||||
if(coroutine.is_finished())
|
|
||||||
it = m_coroutines.erase(it);
|
|
||||||
else {
|
|
||||||
coroutine.resume();
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduledEventPtr EventDispatcher::scheduleEvent(const std::function<void()>& callback, int delay)
|
ScheduledEventPtr EventDispatcher::scheduleEvent(const std::function<void()>& callback, int delay)
|
||||||
|
@ -125,7 +115,3 @@ EventPtr EventDispatcher::addEvent(const std::function<void()>& callback, bool p
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::addCoroutine(const stdext::coroutine& coroutine)
|
|
||||||
{
|
|
||||||
m_coroutines.push_back(coroutine);
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "scheduledevent.h"
|
#include "scheduledevent.h"
|
||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <framework/stdext/coroutine.h>
|
|
||||||
|
|
||||||
// @bindsingleton g_dispatcher
|
// @bindsingleton g_dispatcher
|
||||||
class EventDispatcher
|
class EventDispatcher
|
||||||
|
@ -36,7 +35,6 @@ public:
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void poll();
|
void poll();
|
||||||
|
|
||||||
void addCoroutine(const stdext::coroutine& coroutine);
|
|
||||||
EventPtr addEvent(const std::function<void()>& callback, bool pushFront = false);
|
EventPtr addEvent(const std::function<void()>& callback, bool pushFront = false);
|
||||||
ScheduledEventPtr scheduleEvent(const std::function<void()>& callback, int delay);
|
ScheduledEventPtr scheduleEvent(const std::function<void()>& callback, int delay);
|
||||||
ScheduledEventPtr cycleEvent(const std::function<void()>& callback, int delay);
|
ScheduledEventPtr cycleEvent(const std::function<void()>& callback, int delay);
|
||||||
|
@ -46,7 +44,6 @@ private:
|
||||||
int m_pollEventsSize;
|
int m_pollEventsSize;
|
||||||
stdext::boolean<false> m_disabled;
|
stdext::boolean<false> m_disabled;
|
||||||
std::priority_queue<ScheduledEventPtr, std::vector<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList;
|
std::priority_queue<ScheduledEventPtr, std::vector<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList;
|
||||||
std::list<stdext::coroutine> m_coroutines;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EventDispatcher g_dispatcher;
|
extern EventDispatcher g_dispatcher;
|
||||||
|
|
|
@ -205,7 +205,7 @@ namespace luabinder
|
||||||
template<typename C>
|
template<typename C>
|
||||||
LuaCppFunction bind_mem_fun(int (C::*f)(LuaInterface*)) {
|
LuaCppFunction bind_mem_fun(int (C::*f)(LuaInterface*)) {
|
||||||
auto mf = std::mem_fn(f);
|
auto mf = std::mem_fn(f);
|
||||||
return [=](LuaInterface* lua) -> int {
|
return [=](LuaInterface* lua) mutable -> int {
|
||||||
auto obj = lua->castValue<stdext::shared_object_ptr<C>>(1);
|
auto obj = lua->castValue<stdext::shared_object_ptr<C>>(1);
|
||||||
lua->remove(1);
|
lua->remove(1);
|
||||||
return mf(obj, lua);
|
return mf(obj, lua);
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
#include <framework/core/application.h>
|
#include <framework/core/application.h>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
Protocol::Protocol()
|
Protocol::Protocol()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2010-2013 OTClient <https://github.com/edubart/otclient>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COROUTINE_H
|
|
||||||
#define COROUTINE_H
|
|
||||||
|
|
||||||
#include "thread.h"
|
|
||||||
#include <functional>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace stdext {
|
|
||||||
|
|
||||||
class coroutine
|
|
||||||
{
|
|
||||||
struct codata : public stdext::shared_object {
|
|
||||||
std::unique_ptr<std::thread> thread;
|
|
||||||
std::condition_variable conditionVar;
|
|
||||||
std::mutex mutex;
|
|
||||||
std::function<void()> func;
|
|
||||||
};
|
|
||||||
|
|
||||||
stdext::shared_object_ptr<codata> m;
|
|
||||||
|
|
||||||
void run() {
|
|
||||||
assert(m->func);
|
|
||||||
m->func();
|
|
||||||
std::lock_guard<std::mutex> lock(m->mutex);
|
|
||||||
m->func = nullptr;
|
|
||||||
m->conditionVar.notify_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
coroutine() : m(stdext::make_shared_object<codata>()) { }
|
|
||||||
coroutine(const coroutine& other) : m(other.m) { }
|
|
||||||
|
|
||||||
coroutine& operator=(const coroutine& other) { m = other.m; return *this; }
|
|
||||||
|
|
||||||
~coroutine() {
|
|
||||||
if(m.is_unique()) {
|
|
||||||
m->conditionVar.notify_all();
|
|
||||||
m->thread->join();
|
|
||||||
assert(!m->func);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void create(const std::function<void()>& func) {
|
|
||||||
assert(!!func && !m->func);
|
|
||||||
m->func = func;
|
|
||||||
}
|
|
||||||
|
|
||||||
void yield() const {
|
|
||||||
std::unique_lock<std::mutex> lock(m->mutex);
|
|
||||||
m->conditionVar.notify_all();
|
|
||||||
m->conditionVar.wait(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void resume() {
|
|
||||||
if(!m->thread) {
|
|
||||||
std::unique_lock<std::mutex> lock(m->mutex);
|
|
||||||
m->thread.reset(new std::thread(std::bind(&coroutine::run, this)));
|
|
||||||
m->conditionVar.wait(lock); // wait for the thread to start
|
|
||||||
} else {
|
|
||||||
std::unique_lock<std::mutex> lock(m->mutex);
|
|
||||||
assert(m->func);
|
|
||||||
m->conditionVar.notify_all();
|
|
||||||
m->conditionVar.wait(lock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void join() {
|
|
||||||
while(!is_finished())
|
|
||||||
resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_suspended() { return !!m->func; }
|
|
||||||
bool is_finished() { return !m->func; }
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define STDEXT_TYPES_H
|
#define STDEXT_TYPES_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
typedef unsigned char uchar;
|
typedef unsigned char uchar;
|
||||||
typedef unsigned short ushort;
|
typedef unsigned short ushort;
|
||||||
|
|
Loading…
Reference in New Issue