diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 7d5f06d6b..a0ed90947 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -397,6 +397,7 @@ int transport_read(rdpTransport* transport, STREAM* s) int stream_bytes; int transport_status; + pdu_bytes = 0; transport_status = 0; /* first check if we have header */ diff --git a/libfreerdp/primitives/prim_add.c b/libfreerdp/primitives/prim_add.c index 64b4e6d86..17e504201 100644 --- a/libfreerdp/primitives/prim_add.c +++ b/libfreerdp/primitives/prim_add.c @@ -19,15 +19,19 @@ #endif #include + #include #include + #ifdef WITH_SSE2 -# include -# include +#include +#include #endif /* WITH_SSE2 */ + #ifdef WITH_IPP -# include +#include #endif /* WITH_IPP */ + #include "prim_internal.h" #include "prim_templates.h" diff --git a/libfreerdp/primitives/prim_alphaComp.c b/libfreerdp/primitives/prim_alphaComp.c index dbae5f4ff..b6d4e2e80 100644 --- a/libfreerdp/primitives/prim_alphaComp.c +++ b/libfreerdp/primitives/prim_alphaComp.c @@ -25,15 +25,19 @@ #endif #include + #include #include + #include "prim_internal.h" + #ifdef WITH_SSE2 -# include -# include +#include +#include #endif /* WITH_SSE2 */ + #ifdef WITH_IPP -# include +#include #endif /* WITH_IPP */ #define ALPHA(_k_) (((_k_) & 0xFF000000U) >> 24) diff --git a/libfreerdp/primitives/prim_andor.c b/libfreerdp/primitives/prim_andor.c index c7dc481e4..358d6c823 100644 --- a/libfreerdp/primitives/prim_andor.c +++ b/libfreerdp/primitives/prim_andor.c @@ -18,15 +18,19 @@ #endif #include + #include #include + #ifdef WITH_SSE2 -# include -# include +#include +#include #endif /* WITH_SSE2 */ + #ifdef WITH_IPP -# include +#include #endif /* WITH_IPP */ + #include "prim_internal.h" #include "prim_templates.h" @@ -39,8 +43,12 @@ PRIM_STATIC pstatus_t general_andC_32u( UINT32 *pDst, INT32 len) { - if (val == 0) return PRIMITIVES_SUCCESS; - while (len--) *pDst++ = *pSrc++ & val; + if (val == 0) + return PRIMITIVES_SUCCESS; + + while (len--) + *pDst++ = *pSrc++ & val; + return PRIMITIVES_SUCCESS; } @@ -53,8 +61,12 @@ PRIM_STATIC pstatus_t general_orC_32u( UINT32 *pDst, INT32 len) { - if (val == 0) return PRIMITIVES_SUCCESS; - while (len--) *pDst++ = *pSrc++ | val; + if (val == 0) + return PRIMITIVES_SUCCESS; + + while (len--) + *pDst++ = *pSrc++ | val; + return PRIMITIVES_SUCCESS; } @@ -76,6 +88,7 @@ void primitives_init_andor( /* Start with the default. */ prims->andC_32u = general_andC_32u; prims->orC_32u = general_orC_32u; + #if defined(WITH_IPP) prims->andC_32u = (__andC_32u_t) ippsAndC_32u; prims->orC_32u = (__orC_32u_t) ippsOrC_32u; diff --git a/libfreerdp/primitives/prim_shift.c b/libfreerdp/primitives/prim_shift.c index eb1961af1..331c7216e 100644 --- a/libfreerdp/primitives/prim_shift.c +++ b/libfreerdp/primitives/prim_shift.c @@ -18,15 +18,19 @@ #endif #include + #include #include + #ifdef WITH_SSE2 -# include -# include +#include +#include #endif /* WITH_SSE2 */ + #ifdef WITH_IPP -# include +#include #endif /* WITH_IPP */ + #include "prim_internal.h" #include "prim_templates.h" diff --git a/libfreerdp/primitives/prim_sign.c b/libfreerdp/primitives/prim_sign.c index 6a8a05d2e..a3b11ee14 100644 --- a/libfreerdp/primitives/prim_sign.c +++ b/libfreerdp/primitives/prim_sign.c @@ -18,12 +18,15 @@ #endif #include + #include #include + #ifdef WITH_SSE2 -# include -# include +#include +#include #endif /* WITH_SSE2 */ + #include "prim_internal.h" /* ---------------------------------------------------------------------------- diff --git a/libfreerdp/primitives/primitives.c b/libfreerdp/primitives/primitives.c index 03ab7fbb5..3288787e6 100644 --- a/libfreerdp/primitives/primitives.c +++ b/libfreerdp/primitives/primitives.c @@ -23,13 +23,15 @@ #include #include + #include "prim_internal.h" + #ifdef ANDROID -# include "cpu-features.h" +#include "cpu-features.h" #endif /* Singleton pointer used throughout the program when requested. */ -static primitives_t *pPrimitives = NULL; +static primitives_t* pPrimitives = NULL; #define D_BIT_MMX (1<<23) #define D_BIT_SSE (1<<25) @@ -40,14 +42,14 @@ static primitives_t *pPrimitives = NULL; #define C_BIT_SSSE3 (1<<9) #define C_BIT_SSE41 (1<<19) #define C_BIT_SSE42 (1<<20) -#define C_BIT_XGETBV (1<<27) +#define C_BIT_XGETBV (1<<27) #define C_BIT_AVX (1<<28) #define C_BITS_AVX (C_BIT_XGETBV|C_BIT_AVX) #define E_BIT_XMM (1<<1) #define E_BIT_YMM (1<<2) #define E_BITS_AVX (E_BIT_XMM|E_BIT_YMM) #define C_BIT_FMA (1<<11) -#define C_BIT_AVX_AES (1<<24) +#define C_BIT_AVX_AES (1<<24) /* If x86 */ #if defined(__x86_64) || defined(__x86_64__) || defined(__amd64) \ @@ -60,6 +62,7 @@ static primitives_t *pPrimitives = NULL; /* If GCC */ # ifdef __GNUC__ + # define xgetbv(_func_, _lo_, _hi_) \ __asm__ __volatile__ ("xgetbv" : "=a" (_lo_), "=d" (_hi_) : "c" (_func_)) @@ -90,36 +93,50 @@ static void cpuid( ); } -static void set_hints( - primitives_hints_t *hints) +static void set_hints(primitives_hints_t* hints) { unsigned a, b, c, d; + cpuid(1, &a, &b, &c, &d); - if (d & D_BIT_MMX) hints->x86_flags |= PRIM_X86_MMX_AVAILABLE; - if (d & D_BIT_SSE) hints->x86_flags |= PRIM_X86_SSE_AVAILABLE; - if (d & D_BIT_SSE2) hints->x86_flags |= PRIM_X86_SSE2_AVAILABLE; - if (d & D_BIT_3DN) hints->x86_flags |= PRIM_X86_3DNOW_AVAILABLE; - if (c & C_BIT_3DNP) hints->x86_flags |= PRIM_X86_3DNOW_PREFETCH_AVAILABLE; - if (c & C_BIT_SSE3) hints->x86_flags |= PRIM_X86_SSE3_AVAILABLE; - if (c & C_BIT_SSSE3) hints->x86_flags |= PRIM_X86_SSSE3_AVAILABLE; - if (c & C_BIT_SSE41) hints->x86_flags |= PRIM_X86_SSE41_AVAILABLE; - if (c & C_BIT_SSE42) hints->x86_flags |= PRIM_X86_SSE42_AVAILABLE; + + if (d & D_BIT_MMX) + hints->x86_flags |= PRIM_X86_MMX_AVAILABLE; + if (d & D_BIT_SSE) + hints->x86_flags |= PRIM_X86_SSE_AVAILABLE; + if (d & D_BIT_SSE2) + hints->x86_flags |= PRIM_X86_SSE2_AVAILABLE; + if (d & D_BIT_3DN) + hints->x86_flags |= PRIM_X86_3DNOW_AVAILABLE; + if (c & C_BIT_3DNP) + hints->x86_flags |= PRIM_X86_3DNOW_PREFETCH_AVAILABLE; + if (c & C_BIT_SSE3) + hints->x86_flags |= PRIM_X86_SSE3_AVAILABLE; + if (c & C_BIT_SSSE3) + hints->x86_flags |= PRIM_X86_SSSE3_AVAILABLE; + if (c & C_BIT_SSE41) + hints->x86_flags |= PRIM_X86_SSE41_AVAILABLE; + if (c & C_BIT_SSE42) + hints->x86_flags |= PRIM_X86_SSE42_AVAILABLE; + if ((c & C_BITS_AVX) == C_BITS_AVX) { int e, f; xgetbv(0, e, f); + if ((e & E_BITS_AVX) == E_BITS_AVX) { hints->x86_flags |= PRIM_X86_AVX_AVAILABLE; - if (c & C_BIT_FMA) hints->x86_flags |= PRIM_X86_FMA_AVAILABLE; - if (c & C_BIT_AVX_AES) hints->x86_flags |= PRIM_X86_AVX_AES_AVAILABLE; + + if (c & C_BIT_FMA) + hints->x86_flags |= PRIM_X86_FMA_AVAILABLE; + if (c & C_BIT_AVX_AES) + hints->x86_flags |= PRIM_X86_AVX_AES_AVAILABLE; } } /* TODO: AVX2: set eax=7, ecx=0, cpuid, check ebx-bit5 */ } # else -static void set_hints( - primitives_hints_t *hints) +static void set_hints(primitives_hints_t* hints) { /* x86 non-GCC: TODO */ } @@ -167,12 +184,14 @@ static void set_hints( /* ------------------------------------------------------------------------- */ void primitives_init(void) { - primitives_hints_t *hints; + primitives_hints_t* hints; if (pPrimitives == NULL) { pPrimitives = calloc(1, sizeof(primitives_t)); - if (pPrimitives == NULL) return; + + if (pPrimitives == NULL) + return; } hints = calloc(1, sizeof(primitives_hints_t)); @@ -191,17 +210,19 @@ void primitives_init(void) } /* ------------------------------------------------------------------------- */ -primitives_t *primitives_get(void) +primitives_t* primitives_get(void) { - if (pPrimitives == NULL) primitives_init(); + if (pPrimitives == NULL) + primitives_init(); + return pPrimitives; } /* ------------------------------------------------------------------------- */ -UINT32 primitives_get_flags( - const primitives_t *prims) +UINT32 primitives_get_flags(const primitives_t* prims) { - primitives_hints_t *hints = (primitives_hints_t *) (prims->hints); + primitives_hints_t* hints = (primitives_hints_t*) (prims->hints); + #ifdef i386 return hints->x86_flags; #elif defined(__arm__) @@ -212,69 +233,81 @@ UINT32 primitives_get_flags( } /* ------------------------------------------------------------------------- */ -void primitives_flags_str( - const primitives_t *prims, - char *str, - size_t len) + +typedef struct +{ + UINT32 flag; + const char *str; +} flagpair_t; + +static const flagpair_t x86_flags[] = +{ + { PRIM_X86_MMX_AVAILABLE, "MMX" }, + { PRIM_X86_3DNOW_AVAILABLE, "3DNow" }, + { PRIM_X86_3DNOW_PREFETCH_AVAILABLE, "3DNow-PF" }, + { PRIM_X86_SSE_AVAILABLE, "SSE" }, + { PRIM_X86_SSE2_AVAILABLE, "SSE2" }, + { PRIM_X86_SSE3_AVAILABLE, "SSE3" }, + { PRIM_X86_SSSE3_AVAILABLE, "SSSE3" }, + { PRIM_X86_SSE41_AVAILABLE, "SSE4.1" }, + { PRIM_X86_SSE42_AVAILABLE, "SSE4.2" }, + { PRIM_X86_AVX_AVAILABLE, "AVX" }, + { PRIM_X86_FMA_AVAILABLE, "FMA" }, + { PRIM_X86_AVX_AES_AVAILABLE, "AVX-AES" }, + { PRIM_X86_AVX2_AVAILABLE, "AVX2" }, +}; + +static const flagpair_t arm_flags[] = +{ + { PRIM_ARM_VFP1_AVAILABLE, "VFP1" }, + { PRIM_ARM_VFP2_AVAILABLE, "VFP2" }, + { PRIM_ARM_VFP3_AVAILABLE, "VFP3" }, + { PRIM_ARM_VFP4_AVAILABLE, "VFP4" }, + { PRIM_ARM_FPA_AVAILABLE, "FPA" }, + { PRIM_ARM_FPE_AVAILABLE, "FPE" }, + { PRIM_ARM_IWMMXT_AVAILABLE, "IWMMXT" }, + { PRIM_ARM_NEON_AVAILABLE, "NEON" }, +}; + +void primitives_flags_str(const primitives_t* prims, char* str, size_t len) { - typedef struct - { - UINT32 flag; - const char *str; - } flagpair_t; - static const flagpair_t x86_flags[] = - { - { PRIM_X86_MMX_AVAILABLE, "MMX" }, - { PRIM_X86_3DNOW_AVAILABLE, "3DNow" }, - { PRIM_X86_3DNOW_PREFETCH_AVAILABLE, "3DNow-PF" }, - { PRIM_X86_SSE_AVAILABLE, "SSE" }, - { PRIM_X86_SSE2_AVAILABLE, "SSE2" }, - { PRIM_X86_SSE3_AVAILABLE, "SSE3" }, - { PRIM_X86_SSSE3_AVAILABLE, "SSSE3" }, - { PRIM_X86_SSE41_AVAILABLE, "SSE4.1" }, - { PRIM_X86_SSE42_AVAILABLE, "SSE4.2" }, - { PRIM_X86_AVX_AVAILABLE, "AVX" }, - { PRIM_X86_FMA_AVAILABLE, "FMA" }, - { PRIM_X86_AVX_AES_AVAILABLE, "AVX-AES" }, - { PRIM_X86_AVX2_AVAILABLE, "AVX2" }, - }; - static const flagpair_t arm_flags[] = - { - { PRIM_ARM_VFP1_AVAILABLE, "VFP1" }, - { PRIM_ARM_VFP2_AVAILABLE, "VFP2" }, - { PRIM_ARM_VFP3_AVAILABLE, "VFP3" }, - { PRIM_ARM_VFP4_AVAILABLE, "VFP4" }, - { PRIM_ARM_FPA_AVAILABLE, "FPA" }, - { PRIM_ARM_FPE_AVAILABLE, "FPE" }, - { PRIM_ARM_IWMMXT_AVAILABLE, "IWMMXT" }, - { PRIM_ARM_NEON_AVAILABLE, "NEON" }, - }; int i; - primitives_hints_t *hints; + primitives_hints_t* hints; *str = '\0'; --len; /* for the '/0' */ - hints = (primitives_hints_t *) (prims->hints); - for (i=0; ihints); + + for (i = 0; i < sizeof(x86_flags) / sizeof(flagpair_t); ++i) { if (hints->x86_flags & x86_flags[i].flag) { int slen = strlen(x86_flags[i].str) + 1; - if (len < slen) break; - if (*str != '\0') strcat(str, " "); + + if (len < slen) + break; + + if (*str != '\0') + strcat(str, " "); + strcat(str, x86_flags[i].str); len -= slen; } } - for (i=0; iarm_flags & arm_flags[i].flag) { int slen = strlen(arm_flags[i].str) + 1; - if (len < slen) break; - if (*str != '\0') strcat(str, " "); + + if (len < slen) + break; + + if (*str != '\0') + strcat(str, " "); + strcat(str, arm_flags[i].str); len -= slen; } @@ -284,7 +317,8 @@ void primitives_flags_str( /* ------------------------------------------------------------------------- */ void primitives_deinit(void) { - if (pPrimitives == NULL) return; + if (pPrimitives == NULL) + return; /* Call each section's de-initialization routine. */ primitives_deinit_add(pPrimitives); @@ -296,7 +330,9 @@ void primitives_deinit(void) primitives_deinit_sign(pPrimitives); primitives_deinit_colors(pPrimitives); - if (pPrimitives->hints != NULL) free((void *) (pPrimitives->hints)); - free((void *) pPrimitives); + if (pPrimitives->hints != NULL) + free((void*) (pPrimitives->hints)); + + free((void*) pPrimitives); pPrimitives = NULL; } diff --git a/libfreerdp/primitives/test/prim_test.c b/libfreerdp/primitives/test/prim_test.c index b074a7d06..172d6ffd4 100644 --- a/libfreerdp/primitives/test/prim_test.c +++ b/libfreerdp/primitives/test/prim_test.c @@ -133,77 +133,83 @@ void _floatprint( #define TEST_SET8 (1<<1) #define TEST_SET32S (1<<2) #define TEST_SET32U (1<<3) -#define TEST_SIGN16S (1<<4) +#define TEST_SIGN16S (1<<4) #define TEST_ADD16S (1<<5) -#define TEST_LSHIFT16S (1<<6) -#define TEST_LSHIFT16U (1<<7) -#define TEST_RSHIFT16S (1<<8) -#define TEST_RSHIFT16U (1<<9) +#define TEST_LSHIFT16S (1<<6) +#define TEST_LSHIFT16U (1<<7) +#define TEST_RSHIFT16S (1<<8) +#define TEST_RSHIFT16U (1<<9) #define TEST_RGB (1<<10) #define TEST_ALPHA (1<<11) #define TEST_AND (1<<12) #define TEST_OR (1<<13) /* Specific types of testing: */ -#define TEST_FUNCTIONALITY (1<<0) -#define TEST_PERFORMANCE (1<<1) +#define TEST_FUNCTIONALITY (1<<0) +#define TEST_PERFORMANCE (1<<1) /* ------------------------------------------------------------------------- */ -int main( - int argc, - char **argv) + +typedef struct { - typedef struct - { - const char *testStr; - UINT32 bits; - } test_t; - static const test_t testList[] = - { - { "all", 0xFFFFFFFFU }, - { "copy", TEST_COPY8 }, - { "copy8", TEST_COPY8 }, - { "set", TEST_SET8|TEST_SET32S|TEST_SET32U }, - { "set8", TEST_SET8 }, - { "set32", TEST_SET32S|TEST_SET32U }, - { "set32s", TEST_SET32S }, - { "set32u", TEST_SET32U }, - { "sign", TEST_SIGN16S }, - { "sign16s", TEST_SIGN16S }, - { "add", TEST_ADD16S }, - { "add16s", TEST_ADD16S }, - { "lshift", TEST_LSHIFT16S|TEST_LSHIFT16U }, - { "rshift", TEST_RSHIFT16S|TEST_RSHIFT16U }, - { "shift", TEST_LSHIFT16S|TEST_LSHIFT16U|TEST_RSHIFT16S|TEST_RSHIFT16U }, - { "lshift16s", TEST_LSHIFT16S }, - { "lshift16u", TEST_LSHIFT16U }, - { "rshift16s", TEST_RSHIFT16S }, - { "rshift16u", TEST_RSHIFT16U }, - { "rgb", TEST_RGB }, - { "color", TEST_RGB }, - { "colors", TEST_RGB }, - { "alpha", TEST_ALPHA }, - { "and", TEST_AND }, - { "or", TEST_OR }, - }; + const char *testStr; + UINT32 bits; +} test_t; + +static const test_t testList[] = +{ + { "all", 0xFFFFFFFFU }, + { "copy", TEST_COPY8 }, + { "copy8", TEST_COPY8 }, + { "set", TEST_SET8|TEST_SET32S|TEST_SET32U }, + { "set8", TEST_SET8 }, + { "set32", TEST_SET32S|TEST_SET32U }, + { "set32s", TEST_SET32S }, + { "set32u", TEST_SET32U }, + { "sign", TEST_SIGN16S }, + { "sign16s", TEST_SIGN16S }, + { "add", TEST_ADD16S }, + { "add16s", TEST_ADD16S }, + { "lshift", TEST_LSHIFT16S|TEST_LSHIFT16U }, + { "rshift", TEST_RSHIFT16S|TEST_RSHIFT16U }, + { "shift", TEST_LSHIFT16S|TEST_LSHIFT16U|TEST_RSHIFT16S|TEST_RSHIFT16U }, + { "lshift16s", TEST_LSHIFT16S }, + { "lshift16u", TEST_LSHIFT16U }, + { "rshift16s", TEST_RSHIFT16S }, + { "rshift16u", TEST_RSHIFT16U }, + { "rgb", TEST_RGB }, + { "color", TEST_RGB }, + { "colors", TEST_RGB }, + { "alpha", TEST_ALPHA }, + { "and", TEST_AND }, + { "or", TEST_OR } +}; + #define NUMTESTS (sizeof(testList)/sizeof(test_t)) - static const test_t testTypeList[] = - { - { "functionality", TEST_FUNCTIONALITY }, - { "performance", TEST_PERFORMANCE }, - }; + +static const test_t testTypeList[] = +{ + { "functionality", TEST_FUNCTIONALITY }, + { "performance", TEST_PERFORMANCE }, +}; + #define NUMTESTTYPES (sizeof(testTypeList)/sizeof(test_t)) + +int main(int argc, char** argv) +{ + int i; char hints[256]; UINT32 testSet = 0; UINT32 testTypes = 0; - int i; int results = SUCCESS; /* Parse command line for the test set. */ - for (i=1; ifb_shm_info.shmid, IPC_RMID, 0); printf("display: %p root_window: %p width: %d height: %d depth: %d\n", - xfi->display, xfi->root_window, xfi->fb_image->width, xfi->fb_image->height, xfi->fb_image->depth); + xfi->display, (void*) xfi->root_window, xfi->fb_image->width, xfi->fb_image->height, xfi->fb_image->depth); xfi->fb_pixmap = XShmCreatePixmap(xfi->display, xfi->root_window, xfi->fb_image->data, &(xfi->fb_shm_info), diff --git a/winpr/libwinpr/sspi/test/TestSchannel.c b/winpr/libwinpr/sspi/test/TestSchannel.c index e7ddae7c0..e0b69eda1 100644 --- a/winpr/libwinpr/sspi/test/TestSchannel.c +++ b/winpr/libwinpr/sspi/test/TestSchannel.c @@ -98,7 +98,7 @@ int schannel_recv(PSecurityFunctionTable table, HANDLE hPipe, PCtxtHandle phCont { BYTE* ioBuffer; UINT32 ioBufferLength; - BYTE* pMessageBuffer; + //BYTE* pMessageBuffer; SecBuffer Buffers[4]; SecBufferDesc Message; SECURITY_STATUS status;