mirror of https://github.com/FreeRDP/FreeRDP
Merge branch 'master' of github.com:FreeRDP/FreeRDP
This commit is contained in:
commit
a6af3f5c0a
|
@ -12,6 +12,7 @@
|
||||||
#import "TSXAdditions.h"
|
#import "TSXAdditions.h"
|
||||||
|
|
||||||
#import <freerdp/input.h>
|
#import <freerdp/input.h>
|
||||||
|
#import <freerdp/version.h>
|
||||||
#import "config.h"
|
#import "config.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
|
@ -279,10 +279,10 @@ static UIFont *buttonFont = nil;
|
||||||
button.frame = CGRectMake(xOffset, _height, width, kAlertButtonHeight);
|
button.frame = CGRectMake(xOffset, _height, width, kAlertButtonHeight);
|
||||||
button.titleLabel.font = buttonFont;
|
button.titleLabel.font = buttonFont;
|
||||||
if (IOS_LESS_THAN_6) {
|
if (IOS_LESS_THAN_6) {
|
||||||
#pragma clan diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
button.titleLabel.minimumFontSize = 10;
|
button.titleLabel.minimumFontSize = 10;
|
||||||
#pragma clan diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
button.titleLabel.adjustsFontSizeToFitWidth = YES;
|
button.titleLabel.adjustsFontSizeToFitWidth = YES;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#cmakedefine HAVE_TIMERFD_H
|
#cmakedefine HAVE_TIMERFD_H
|
||||||
#cmakedefine HAVE_TM_GMTOFF
|
#cmakedefine HAVE_TM_GMTOFF
|
||||||
#cmakedefine HAVE_AIO_H
|
#cmakedefine HAVE_AIO_H
|
||||||
|
#cmakedefine HAVE_PTHREAD_GNU_EXT
|
||||||
|
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
|
|
|
@ -9,6 +9,7 @@ set(${MODULE_PREFIX}_TESTS
|
||||||
TestSynchMutex.c
|
TestSynchMutex.c
|
||||||
TestSynchCritical.c
|
TestSynchCritical.c
|
||||||
TestSynchSemaphore.c
|
TestSynchSemaphore.c
|
||||||
|
TestSynchThread.c
|
||||||
TestSynchWaitableTimer.c)
|
TestSynchWaitableTimer.c)
|
||||||
|
|
||||||
create_test_sourcelist(${MODULE_PREFIX}_SRCS
|
create_test_sourcelist(${MODULE_PREFIX}_SRCS
|
||||||
|
|
|
@ -4,16 +4,48 @@
|
||||||
|
|
||||||
int TestSynchMutex(int argc, char* argv[])
|
int TestSynchMutex(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
DWORD rc;
|
||||||
HANDLE mutex;
|
HANDLE mutex;
|
||||||
|
|
||||||
mutex = CreateMutex(NULL, FALSE, NULL);
|
mutex = CreateMutex(NULL, FALSE, NULL);
|
||||||
|
|
||||||
if (!mutex)
|
if (!mutex)
|
||||||
{
|
{
|
||||||
printf("CreateMutex failure\n");
|
printf("CreateMutex failure\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lock the mutex */
|
||||||
|
rc = WaitForSingleObject(mutex, INFINITE);
|
||||||
|
if (WAIT_OBJECT_0 != rc)
|
||||||
|
{
|
||||||
|
printf("WaitForSingleObject on mutex failed with %d\n", rc);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TryLock should now fail. */
|
||||||
|
rc = WaitForSingleObject(mutex, 0);
|
||||||
|
if (WAIT_TIMEOUT != rc)
|
||||||
|
{
|
||||||
|
printf("Timed WaitForSingleObject on locked mutex failed with %d\n", rc);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the mutex */
|
||||||
|
rc = ReleaseMutex(mutex);
|
||||||
|
if (!rc)
|
||||||
|
{
|
||||||
|
printf("ReleaseMutex failed.\n");
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TryLock should now succeed. */
|
||||||
|
rc = WaitForSingleObject(mutex, 0);
|
||||||
|
if (WAIT_OBJECT_0 != rc)
|
||||||
|
{
|
||||||
|
printf("Timed WaitForSingleObject on free mutex failed with %d\n", rc);
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
|
||||||
CloseHandle(mutex);
|
CloseHandle(mutex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
|
||||||
|
#include <winpr/crt.h>
|
||||||
|
#include <winpr/synch.h>
|
||||||
|
#include <winpr/thread.h>
|
||||||
|
|
||||||
|
static void *test_thread(void *arg)
|
||||||
|
{
|
||||||
|
Sleep(1000);
|
||||||
|
|
||||||
|
ExitThread(0);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int TestSynchThread(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
DWORD rc;
|
||||||
|
HANDLE thread;
|
||||||
|
|
||||||
|
thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_thread,
|
||||||
|
NULL, 0, NULL);
|
||||||
|
if (!thread)
|
||||||
|
{
|
||||||
|
printf("CreateThread failure\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TryJoin should now fail. */
|
||||||
|
rc = WaitForSingleObject(thread, 0);
|
||||||
|
if (WAIT_TIMEOUT != rc)
|
||||||
|
{
|
||||||
|
printf("Timed WaitForSingleObject on running thread failed with %d\n", rc);
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Join the thread */
|
||||||
|
rc = WaitForSingleObject(thread, INFINITE);
|
||||||
|
if (WAIT_OBJECT_0 != rc)
|
||||||
|
{
|
||||||
|
printf("WaitForSingleObject on thread failed with %d\n", rc);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* TimedJoin should now succeed. */
|
||||||
|
rc = WaitForSingleObject(thread, 0);
|
||||||
|
if (WAIT_OBJECT_0 != rc)
|
||||||
|
{
|
||||||
|
printf("Timed WaitForSingleObject on dead thread failed with %d\n", rc);
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(thread);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -86,10 +86,20 @@ int clock_gettime(int clk_id, struct timespec *t)
|
||||||
*/
|
*/
|
||||||
#if !defined(HAVE_PTHREAD_GNU_EXT)
|
#if !defined(HAVE_PTHREAD_GNU_EXT)
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
|
static long long ts_difftime(struct timespec *o,
|
||||||
|
struct timespec *n)
|
||||||
|
{
|
||||||
|
long long old = o->tv_sec * 1000000000LL + o->tv_nsec;
|
||||||
|
long long new = n->tv_sec * 1000000000LL + n->tv_nsec;
|
||||||
|
|
||||||
|
return new - old;
|
||||||
|
}
|
||||||
|
|
||||||
static int pthread_timedjoin_np(pthread_t td, void **res,
|
static int pthread_timedjoin_np(pthread_t td, void **res,
|
||||||
struct timespec *timeout)
|
struct timespec *timeout)
|
||||||
{
|
{
|
||||||
struct timeval timenow;
|
struct timespec timenow;
|
||||||
struct timespec sleepytime;
|
struct timespec sleepytime;
|
||||||
/* This is just to avoid a completely busy wait */
|
/* This is just to avoid a completely busy wait */
|
||||||
sleepytime.tv_sec = 0;
|
sleepytime.tv_sec = 0;
|
||||||
|
@ -101,11 +111,10 @@ static int pthread_timedjoin_np(pthread_t td, void **res,
|
||||||
return pthread_join(td, res);
|
return pthread_join(td, res);
|
||||||
|
|
||||||
nanosleep(&sleepytime, NULL);
|
nanosleep(&sleepytime, NULL);
|
||||||
|
|
||||||
gettimeofday(&timenow, NULL);
|
clock_gettime(CLOCK_MONOTONIC, &timenow);
|
||||||
|
|
||||||
if (timenow.tv_sec >= timeout->tv_sec &&
|
if (ts_difftime(timeout, &timenow) >= 0)
|
||||||
(timenow.tv_usec * 1000) >= timeout->tv_nsec)
|
|
||||||
{
|
{
|
||||||
return ETIMEDOUT;
|
return ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +126,7 @@ static int pthread_timedjoin_np(pthread_t td, void **res,
|
||||||
|
|
||||||
static int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *timeout)
|
static int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *timeout)
|
||||||
{
|
{
|
||||||
struct timeval timenow;
|
struct timespec timenow;
|
||||||
struct timespec sleepytime;
|
struct timespec sleepytime;
|
||||||
int retcode;
|
int retcode;
|
||||||
|
|
||||||
|
@ -127,10 +136,9 @@ static int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec
|
||||||
|
|
||||||
while ((retcode = pthread_mutex_trylock (mutex)) == EBUSY)
|
while ((retcode = pthread_mutex_trylock (mutex)) == EBUSY)
|
||||||
{
|
{
|
||||||
gettimeofday (&timenow, NULL);
|
clock_gettime(CLOCK_MONOTONIC, &timenow);
|
||||||
|
|
||||||
if (timenow.tv_sec >= timeout->tv_sec &&
|
if (ts_difftime(timeout, &timenow) >= 0)
|
||||||
(timenow.tv_usec * 1000) >= timeout->tv_nsec)
|
|
||||||
{
|
{
|
||||||
return ETIMEDOUT;
|
return ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +180,6 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
|
||||||
|
|
||||||
if (thread->started)
|
if (thread->started)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
|
||||||
if (dwMilliseconds != INFINITE)
|
if (dwMilliseconds != INFINITE)
|
||||||
{
|
{
|
||||||
struct timespec timeout;
|
struct timespec timeout;
|
||||||
|
@ -182,7 +189,7 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
|
||||||
if (dwMilliseconds == 0)
|
if (dwMilliseconds == 0)
|
||||||
dwMilliseconds ++;
|
dwMilliseconds ++;
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &timeout);
|
clock_gettime(CLOCK_MONOTONIC, &timeout);
|
||||||
ts_add_ms(&timeout, dwMilliseconds);
|
ts_add_ms(&timeout, dwMilliseconds);
|
||||||
|
|
||||||
status = pthread_timedjoin_np(thread->thread, &thread_status, &timeout);
|
status = pthread_timedjoin_np(thread->thread, &thread_status, &timeout);
|
||||||
|
@ -191,7 +198,6 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
|
||||||
return WAIT_TIMEOUT;
|
return WAIT_TIMEOUT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
status = pthread_join(thread->thread, &thread_status);
|
status = pthread_join(thread->thread, &thread_status);
|
||||||
|
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
|
@ -223,13 +229,12 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
|
||||||
|
|
||||||
mutex = (WINPR_MUTEX*) Object;
|
mutex = (WINPR_MUTEX*) Object;
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
if (dwMilliseconds != INFINITE)
|
if (dwMilliseconds != INFINITE)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
struct timespec timeout;
|
struct timespec timeout;
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &timeout);
|
clock_gettime(CLOCK_MONOTONIC, &timeout);
|
||||||
ts_add_ms(&timeout, dwMilliseconds);
|
ts_add_ms(&timeout, dwMilliseconds);
|
||||||
|
|
||||||
status = pthread_mutex_timedlock(&mutex->mutex, &timeout);
|
status = pthread_mutex_timedlock(&mutex->mutex, &timeout);
|
||||||
|
@ -238,7 +243,6 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
|
||||||
return WAIT_TIMEOUT;
|
return WAIT_TIMEOUT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
pthread_mutex_lock(&mutex->mutex);
|
pthread_mutex_lock(&mutex->mutex);
|
||||||
}
|
}
|
||||||
else if (Type == HANDLE_TYPE_EVENT)
|
else if (Type == HANDLE_TYPE_EVENT)
|
||||||
|
|
Loading…
Reference in New Issue