From 9c64e77a8404a4a58598f119804229e7b92ed7c7 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 10 Aug 2016 11:06:34 +0200 Subject: [PATCH] Disabled thread local storage on iOS. iOS does not support Thread Local Storage. Disabling it for now until a solution is found. Print a compiler warning informing developers about this issue. --- client/X11/xf_graphics.c | 86 ++++++++++++++++++++------------ client/iOS/CMakeLists.txt | 2 +- cmake/ConfigOptionsiOS.cmake | 1 + libfreerdp/core/tcp.c | 1 + scripts/OpenSSL-DownloadAndBuild.command | 2 +- winpr/include/winpr/interlocked.h | 7 --- winpr/include/winpr/platform.h | 1 - winpr/include/winpr/winpr.h | 8 ++- winpr/libwinpr/environment/environment.c | 1 + winpr/libwinpr/path/shell.c | 1 + 10 files changed, 68 insertions(+), 42 deletions(-) diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index 10c28e1..f5956d6 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -43,7 +43,7 @@ #define TAG CLIENT_TAG("x11") BOOL xf_decode_color(rdpGdi* gdi, const UINT32 srcColor, - UINT32* color, UINT32* format) + UINT32* color, UINT32* format) { xfContext* xfc; UINT32 DstFormat; @@ -54,14 +54,14 @@ BOOL xf_decode_color(rdpGdi* gdi, const UINT32 srcColor, xfc = (xfContext*)gdi->context; SrcFormat = gdi_get_pixel_format(gdi->context->settings->ColorDepth, - FALSE); + FALSE); if (format) *format = SrcFormat; DstFormat = xf_get_local_color_format(xfc, FALSE); *color = ConvertColor(srcColor, SrcFormat, - DstFormat, &gdi->palette); + DstFormat, &gdi->palette); return TRUE; } @@ -80,7 +80,7 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap) data = bitmap->data; depth = GetBitsPerPixel(bitmap->format); pixmap = XCreatePixmap(xfc->display, xfc->drawable, bitmap->width, - bitmap->height, xfc->depth); + bitmap->height, xfc->depth); if (bitmap->data) { @@ -96,19 +96,19 @@ static BOOL xf_Bitmap_New(rdpContext* context, rdpBitmap* bitmap) SrcFormat = bitmap->format; freerdp_image_copy(data, gdi->dstFormat, 0, 0, 0, - bitmap->width, bitmap->height, - bitmap->data, SrcFormat, - 0, 0, 0, &context->gdi->palette); + bitmap->width, bitmap->height, + bitmap->data, SrcFormat, + 0, 0, 0, &context->gdi->palette); _aligned_free(bitmap->data); bitmap->data = data; bitmap->format = gdi->dstFormat; } image = XCreateImage(xfc->display, xfc->visual, xfc->depth, - ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, - xfc->scanline_pad, 0); + ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, + xfc->scanline_pad, 0); XPutImage(xfc->display, pixmap, xfc->gc, image, 0, 0, 0, 0, bitmap->width, - bitmap->height); + bitmap->height); XFree(image); } @@ -139,10 +139,10 @@ static BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap) xf_lock_x11(xfc, FALSE); XSetFunction(xfc->display, xfc->gc, GXcopy); image = XCreateImage(xfc->display, xfc->visual, xfc->depth, - ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, - xfc->scanline_pad, 0); + ZPixmap, 0, (char*) bitmap->data, bitmap->width, bitmap->height, + xfc->scanline_pad, 0); XPutImage(xfc->display, xfc->primary, xfc->gc, - image, 0, 0, bitmap->left, bitmap->top, width, height); + image, 0, 0, bitmap->left, bitmap->top, width, height); XFree(image); ret = gdi_InvalidateRegion(xfc->hdc, bitmap->left, bitmap->top, width, height); xf_unlock_x11(xfc, FALSE); @@ -150,7 +150,7 @@ static BOOL xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap) } static BOOL xf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, - BOOL primary) + BOOL primary) { xfContext* xfc = (xfContext*) context; xf_lock_x11(xfc, FALSE); @@ -186,18 +186,18 @@ static BOOL xf_Pointer_New(rdpContext* context, rdpPointer* pointer) ci.yhot = pointer->yPos; if (!(ci.pixels = (XcursorPixel*) calloc(ci.height, - ci.width * GetBytesPerPixel(gdi->dstFormat)))) + ci.width * GetBytesPerPixel(gdi->dstFormat)))) { xf_unlock_x11(xfc, FALSE); return FALSE; } if (freerdp_image_copy_from_pointer_data( - (BYTE*) ci.pixels, gdi->dstFormat, - 0, 0, 0, pointer->width, pointer->height, - pointer->xorMaskData, pointer->lengthXorMask, - pointer->andMaskData, pointer->lengthAndMask, - pointer->xorBpp, &context->gdi->palette) < 0) + (BYTE*) ci.pixels, gdi->dstFormat, + 0, 0, 0, pointer->width, pointer->height, + pointer->xorMaskData, pointer->lengthXorMask, + pointer->andMaskData, pointer->lengthAndMask, + pointer->xorBpp, &context->gdi->palette) < 0) { free(ci.pixels); xf_unlock_x11(xfc, FALSE); @@ -225,7 +225,7 @@ static void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer) } static BOOL xf_Pointer_Set(rdpContext* context, - const rdpPointer* pointer) + const rdpPointer* pointer) { #ifdef WITH_XCURSOR xfContext* xfc = (xfContext*) context; @@ -305,7 +305,7 @@ static BOOL xf_Pointer_SetPosition(rdpContext* context, UINT32 x, UINT32 y) tmp.event_mask = (current.your_event_mask & ~(PointerMotionMask)); if (XChangeWindowAttributes(xfc->display, xfc->window->handle, CWEventMask, - &tmp) == 0) + &tmp) == 0) goto out; XWarpPointer(xfc->display, None, xfc->window->handle, 0, 0, 0, 0, x, y); @@ -328,14 +328,14 @@ static BOOL xf_Glyph_New(rdpContext* context, const rdpGlyph* glyph) xf_lock_x11(xfc, FALSE); scanline = (glyph->cx + 7) / 8; xf_glyph->pixmap = XCreatePixmap(xfc->display, xfc->drawing, glyph->cx, - glyph->cy, 1); + glyph->cy, 1); image = XCreateImage(xfc->display, xfc->visual, 1, - ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline); + ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline); image->byte_order = MSBFirst; image->bitmap_bit_order = MSBFirst; XInitImage(image); XPutImage(xfc->display, xf_glyph->pixmap, xfc->gc_mono, image, 0, 0, 0, 0, - glyph->cx, glyph->cy); + glyph->cx, glyph->cy); XFree(image); xf_unlock_x11(xfc, FALSE); return TRUE; @@ -354,24 +354,48 @@ static void xf_Glyph_Free(rdpContext* context, rdpGlyph* glyph) free(glyph); } +static BOOL xf_Glyph_Put(rdpContext* context, const rdpGlyph* glyph) +{ + int scanline; + XImage* image; + xfGlyph* xf_glyph; + xf_glyph = (xfGlyph*) glyph; + xfContext* xfc = (xfContext*) context; + + scanline = (glyph->cx + 7) / 8; + + image = XCreateImage(xfc->display, xfc->visual, 1, + ZPixmap, 0, (char*) glyph->aj, glyph->cx, glyph->cy, 8, scanline); + image->byte_order = MSBFirst; + image->bitmap_bit_order = MSBFirst; + XInitImage(image); + XPutImage(xfc->display, xf_glyph->pixmap, xfc->gc_mono, image, 0, 0, 0, 0, + glyph->cx, glyph->cy); + XFree(image); + return TRUE; +} + static BOOL xf_Glyph_Draw(rdpContext* context, const rdpGlyph* glyph, UINT32 x, - UINT32 y) + UINT32 y) { xfGlyph* xf_glyph; xfContext* xfc = (xfContext*) context; xf_glyph = (xfGlyph*) glyph; xf_lock_x11(xfc, FALSE); + XSetStipple(xfc->display, xfc->gc, xf_glyph->pixmap); XSetTSOrigin(xfc->display, xfc->gc, x, y); XFillRectangle(xfc->display, xfc->drawing, xfc->gc, x, y, glyph->cx, glyph->cy); + xf_Glyph_Put(context, glyph); XSetStipple(xfc->display, xfc->gc, xfc->bitmap_mono); + xf_unlock_x11(xfc, FALSE); return TRUE; } static BOOL xf_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y, - UINT32 width, UINT32 height, UINT32 bgcolor, - UINT32 fgcolor, BOOL fOpRedundant) + UINT32 width, UINT32 height, UINT32 bgcolor, + UINT32 fgcolor, BOOL fOpRedundant) { xfContext* xfc = (xfContext*) context; @@ -394,14 +418,14 @@ static BOOL xf_Glyph_BeginDraw(rdpContext* context, UINT32 x, UINT32 y, XSetForeground(xfc->display, xfc->gc, bgcolor); XSetBackground(xfc->display, xfc->gc, fgcolor); XSetFillStyle(xfc->display, xfc->gc, - fOpRedundant ? FillOpaqueStippled : FillStippled); + fOpRedundant ? FillOpaqueStippled : FillStippled); xf_unlock_x11(xfc, FALSE); return TRUE; } static BOOL xf_Glyph_EndDraw(rdpContext* context, UINT32 x, UINT32 y, - UINT32 width, UINT32 height, - UINT32 bgcolor, UINT32 fgcolor) + UINT32 width, UINT32 height, + UINT32 bgcolor, UINT32 fgcolor) { xfContext* xfc = (xfContext*) context; BOOL ret = TRUE; diff --git a/client/iOS/CMakeLists.txt b/client/iOS/CMakeLists.txt index 4c9e2af..4970cee 100644 --- a/client/iOS/CMakeLists.txt +++ b/client/iOS/CMakeLists.txt @@ -107,7 +107,7 @@ set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOU set(EXECUTABLE_NAME "\${EXECUTABLE_NAME}") set_target_properties(${MODULE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${IOS_CLIENT_DIR}/iFreeRDP.plist) -set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "6.3") +set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IOS_TARGET_SDK}") set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "gnu++0x") set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO) diff --git a/cmake/ConfigOptionsiOS.cmake b/cmake/ConfigOptionsiOS.cmake index 84a8196..8783789 100644 --- a/cmake/ConfigOptionsiOS.cmake +++ b/cmake/ConfigOptionsiOS.cmake @@ -19,4 +19,5 @@ if (NOT FREERDP_IOS_EXTERNAL_SSL_PATH) set(FREERDP_IOS_EXTERNAL_SSL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/openssl") endif() mark_as_advanced(FREERDP_IOS_EXTERNAL_SSL_PATH) +set(IOS_TARGET_SDK 9.3 CACHE STRING "Application target iOS SDK") diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index 7be7a41..0217227 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -27,6 +27,7 @@ #include #include +#include #include #if !defined(_WIN32) diff --git a/scripts/OpenSSL-DownloadAndBuild.command b/scripts/OpenSSL-DownloadAndBuild.command index 10e15f2..7d7f428 100755 --- a/scripts/OpenSSL-DownloadAndBuild.command +++ b/scripts/OpenSSL-DownloadAndBuild.command @@ -15,7 +15,7 @@ SHA256SUM="1d4007e53aad94a5b2002fe045ee7bb0b3d98f1a47f8b2bc851dcd1c74332919" SDK_VERSION="" # Minimum SDK version the application supports -MIN_SDK_VERSION="" +MIN_SDK_VERSION="9.3" ## Defaults INSTALLDIR="external" diff --git a/winpr/include/winpr/interlocked.h b/winpr/include/winpr/interlocked.h index 2b2d9c7..f622f91 100644 --- a/winpr/include/winpr/interlocked.h +++ b/winpr/include/winpr/interlocked.h @@ -31,13 +31,6 @@ extern "C" { #ifndef _WIN32 -#ifdef __IOS__ -/* workaround for SLIST_ENTRY conflict */ - -#include -#undef SLIST_ENTRY -#endif - #ifndef CONTAINING_RECORD #define CONTAINING_RECORD(address, type, field) \ ((type *)(((ULONG_PTR) address) - (ULONG_PTR)(&(((type *) 0)->field)))) diff --git a/winpr/include/winpr/platform.h b/winpr/include/winpr/platform.h index 6722fe3..91291ed 100644 --- a/winpr/include/winpr/platform.h +++ b/winpr/include/winpr/platform.h @@ -22,7 +22,6 @@ #include -#include #include /* diff --git a/winpr/include/winpr/winpr.h b/winpr/include/winpr/winpr.h index 67a1ed7..cafd692 100644 --- a/winpr/include/winpr/winpr.h +++ b/winpr/include/winpr/winpr.h @@ -19,6 +19,8 @@ #ifndef WINPR_H #define WINPR_H +#include + #if defined _WIN32 || defined __CYGWIN__ #ifdef WINPR_EXPORTS #ifdef __GNUC__ @@ -48,8 +50,12 @@ #else #define WINPR_TLS __declspec(thread) #endif -#else +#elif !defined(__IOS__) #define WINPR_TLS __thread +#else +#warning "Target iOS does not support Thread Local Storage!" +#warning "Multi Instance support is disabled!" +#define WINPR_TLS #endif diff --git a/winpr/libwinpr/environment/environment.c b/winpr/libwinpr/environment/environment.c index ccd2f4a..6227619 100644 --- a/winpr/libwinpr/environment/environment.c +++ b/winpr/libwinpr/environment/environment.c @@ -24,6 +24,7 @@ #endif #include +#include #include #include diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index c3091a1..adf73e7 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include -- 2.7.4