From: Patrick von Reth Date: Mon, 1 Feb 2010 00:01:17 +0000 (+0100) Subject: More mingw fixes X-Git-Tag: 0.6-beta1~16 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=5736e6f3ac874aa05cdc87706471e37f7ab6fffc;ds=sidebyside More mingw fixes mingw and unicode definition fix cleaned up logbacktrace_win.cpp gcc asm currenly missing --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 64409ef9..7fdc6fdb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,12 @@ else(WITH_KDE) message(STATUS "Not enabling KDE4 integration") endif(WITH_KDE) +# needed to compile with mingw without kde +if(MINGW AND NOT HAVE_KDE) + add_definitions(-D_WIN32_WINNT=0x0500) + message(STATUS "Added _WIN32_WINNT=0x0500 definition for MinGW") +endif(MINGW AND NOT HAVE_KDE) + # Setup Phonon support - we only need this if we don't have or want KDE4 if(NOT HAVE_KDE) if(WITH_PHONON) diff --git a/src/common/identity.cpp b/src/common/identity.cpp index 275afcc6..6cb37808 100644 --- a/src/common/identity.cpp +++ b/src/common/identity.cpp @@ -76,6 +76,18 @@ Identity::Identity(const Identity &other, QObject *parent) init(); } +#ifdef Q_WS_WIN +#ifdef UNICODE +QString tcharToQString(TCHAR *tchar){ + return QString::fromUtf16( reinterpret_cast(tchar)); +} +#else +QString tcharToQString(TCHAR *tchar){ + return QString::fromLocal8Bit(tchar); +} +#endif + +#endif void Identity::init() { setObjectName(QString::number(id().toInt())); setAllowClientUpdates(true); @@ -102,7 +114,7 @@ QString Identity::defaultNick() { DWORD bufCharCount = 128; //if(GetUserNameEx(/* NameSamCompatible */ 1, infoBuf, &bufCharCount)) if(GetUserNameEx(NameSamCompatible, infoBuf, &bufCharCount)) { - QString nickName(infoBuf); + QString nickName(tcharToQString(infoBuf)); int lastBs = nickName.lastIndexOf('\\'); if(lastBs != -1) { nickName = nickName.mid(lastBs + 1); @@ -138,7 +150,7 @@ QString Identity::defaultRealName() { TCHAR infoBuf[128]; DWORD bufCharCount = 128; if(GetUserName(infoBuf, &bufCharCount)) - return QString(infoBuf); + return tcharToQString(infoBuf); else return generalDefault; #else diff --git a/src/common/logbacktrace_win.cpp b/src/common/logbacktrace_win.cpp index 31d1f957..ed11ea44 100644 --- a/src/common/logbacktrace_win.cpp +++ b/src/common/logbacktrace_win.cpp @@ -49,7 +49,7 @@ struct EnumModulesContext { EnumModulesContext(HANDLE hProcess, QTextStream &stream) : hProcess(hProcess), stream(stream) {} }; -BOOL CALLBACK EnumModulesCB(PCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) { +BOOL CALLBACK EnumModulesCB(LPCSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) { IMAGEHLP_MODULE64 mod; EnumModulesContext *context = (EnumModulesContext *)UserContext; mod.SizeOfStruct = sizeof(IMAGEHLP_MODULE64); @@ -70,14 +70,12 @@ BOOL CALLBACK EnumModulesCB(PCTSTR ModuleName, DWORD64 BaseOfDll, PVOID UserCont return TRUE; } -// we don't use the ModuleName anyways so we can easily "convert" this -inline BOOL CALLBACK EnumModulesCB(PSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext) { - return EnumModulesCB(PCTSTR(0), BaseOfDll, UserContext); -} -#ifdef _M_IX86 + +#if defined( _M_IX86 ) && defined(Q_CC_MSVC) // Disable global optimization and ignore /GS waning caused by // inline assembly. + // not needed with mingw cause we can tell mingw which registers we use #pragma optimize("g", off) #pragma warning(push) #pragma warning(disable : 4748) @@ -90,13 +88,26 @@ void Quassel::logBacktrace(const QString &filename) { #ifdef _M_IX86 ZeroMemory(&Context, sizeof(CONTEXT)); Context.ContextFlags = CONTEXT_CONTROL; - __asm { + +// TODO: port asssembler to mingw32 +#ifdef __MINGW32__ +// asm("Label:\n\t" +// "movl %%ebp,%0;\n\t" +// "movl %%esp,%1;\n\t" +// "movl $Label,%%eax;\n\t" +// "movl %%eax,;\n\t" +// :"=r"(Content.Epb),"=r"(Context.Esp),"=r"(Context.Eip) +// ://no input +// :"ebp","esp","eax"); +#else + _asm { Label: mov [Context.Ebp], ebp; mov [Context.Esp], esp; mov eax, [Label]; mov [Context.Eip], eax; } +#endif #else RtlCaptureContext(&Context); #endif @@ -202,7 +213,7 @@ void Quassel::logBacktrace(const QString &filename) { logFile.close(); } -#ifdef _M_IX86 +#if defined(_M_IX86) && defined(Q_CC_MSVC) #pragma warning(pop) #pragma optimize("g", on) #endif diff --git a/src/common/syncableobject.h b/src/common/syncableobject.h index 28e14720..bec189a6 100644 --- a/src/common/syncableobject.h +++ b/src/common/syncableobject.h @@ -33,13 +33,13 @@ #define SYNCABLE_OBJECT static const int _classNameOffset__; #define INIT_SYNCABLE_OBJECT(x) const int x ::_classNameOffset__ = QByteArray(staticMetaObject.className()).length() + 2; -#ifdef Q_WS_WIN +#ifdef Q_CC_MSVC # define SYNC(...) sync_call__(SignalProxy::Server, (__FUNCTION__ + _classNameOffset__), __VA_ARGS__); # define REQUEST(...) sync_call__(SignalProxy::Client, (__FUNCTION__ + _classNameOffset__) , __VA_ARGS__); #else # define SYNC(...) sync_call__(SignalProxy::Server, __func__, __VA_ARGS__); # define REQUEST(...) sync_call__(SignalProxy::Client, __func__, __VA_ARGS__); -#endif //Q_WS_WIN +#endif //Q_CC_MSVC #define SYNC_OTHER(x, ...) sync_call__(SignalProxy::Server, #x, __VA_ARGS__); #define REQUEST_OTHER(x, ...) sync_call__(SignalProxy::Client, #x, __VA_ARGS__);