diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index c1c7002f263..a35d1f60031 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -323,6 +323,10 @@ typedef struct void *tail; } critical_section; +#define MTX_PLAIN 0x1 +#define MTX_TRY 0x2 +#define MTX_TIMED 0x4 +#define MTX_RECURSIVE 0x100 typedef struct { DWORD flags; @@ -335,6 +339,7 @@ static int (__cdecl *p__Mtx_init)(_Mtx_t*, int); static void (__cdecl *p__Mtx_destroy)(_Mtx_t*); static int (__cdecl *p__Mtx_lock)(_Mtx_t*); static int (__cdecl *p__Mtx_unlock)(_Mtx_t*); +static int (__cdecl *p__Mtx_trylock)(_Mtx_t*); /* cnd */ typedef void *_Cnd_t; @@ -801,6 +806,8 @@ static BOOL init(void) "_Mtx_lock"); SET(p__Mtx_unlock, "_Mtx_unlock"); + SET(p__Mtx_trylock, + "_Mtx_trylock"); SET(p__Cnd_init, "_Cnd_init"); @@ -2438,6 +2445,42 @@ static void test__Pad(void) CloseHandle(_Pad__Launch_returned); } +static void test__Mtx(void) +{ +# + static int flags[] = + { + 0, MTX_PLAIN, MTX_TRY, MTX_TIMED, MTX_RECURSIVE, + MTX_PLAIN|MTX_TRY, MTX_PLAIN|MTX_RECURSIVE, MTX_PLAIN|0xbeef + }; + _Mtx_t mtx; + int i, r, expect; + + for (i=0; iflags = flags; @@ -740,7 +743,8 @@ int __cdecl _Mtx_lock(_Mtx_arg_t mtx) if(MTX_T_FROM_ARG(mtx)->thread_id != GetCurrentThreadId()) { call_func1(critical_section_lock, &MTX_T_FROM_ARG(mtx)->cs); MTX_T_FROM_ARG(mtx)->thread_id = GetCurrentThreadId(); - }else if(!(MTX_T_FROM_ARG(mtx)->flags & MTX_MULTI_LOCK)) { + }else if(!(MTX_T_FROM_ARG(mtx)->flags & MTX_RECURSIVE) + && MTX_T_FROM_ARG(mtx)->flags != MTX_PLAIN) { return MTX_LOCKED; } @@ -764,7 +768,8 @@ int __cdecl _Mtx_trylock(_Mtx_arg_t mtx) if(!call_func1(critical_section_trylock, &MTX_T_FROM_ARG(mtx)->cs)) return MTX_LOCKED; MTX_T_FROM_ARG(mtx)->thread_id = GetCurrentThreadId(); - }else if(!(MTX_T_FROM_ARG(mtx)->flags & MTX_MULTI_LOCK)) { + }else if(!(MTX_T_FROM_ARG(mtx)->flags & MTX_RECURSIVE) + && MTX_T_FROM_ARG(mtx)->flags != MTX_PLAIN) { return MTX_LOCKED; }