Commit 4e863fa7 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcp100: Support exceptions while copying object in _Concurrent_queue_base_v4::_Internal_push.

parent 2149f472
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "winbase.h" #include "winbase.h"
#include "winternl.h" #include "winternl.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/exception.h"
WINE_DEFAULT_DEBUG_CHANNEL(msvcp); WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
struct __Container_proxy; struct __Container_proxy;
...@@ -1397,6 +1398,12 @@ static MSVCP_size_t InterlockedIncrementSizeT(MSVCP_size_t volatile *dest) ...@@ -1397,6 +1398,12 @@ static MSVCP_size_t InterlockedIncrementSizeT(MSVCP_size_t volatile *dest)
#define InterlockedIncrementSizeT(dest) InterlockedIncrement((LONG*)dest) #define InterlockedIncrementSizeT(dest) InterlockedIncrement((LONG*)dest)
#endif #endif
static void CALLBACK queue_push_finally(BOOL normal, void *ctx)
{
threadsafe_queue *queue = ctx;
InterlockedIncrementSizeT(&queue->tail_pos);
}
static void threadsafe_queue_push(threadsafe_queue *queue, MSVCP_size_t id, static void threadsafe_queue_push(threadsafe_queue *queue, MSVCP_size_t id,
void *e, _Concurrent_queue_base_v4 *parent, BOOL copy) void *e, _Concurrent_queue_base_v4 *parent, BOOL copy)
{ {
...@@ -1430,21 +1437,24 @@ static void threadsafe_queue_push(threadsafe_queue *queue, MSVCP_size_t id, ...@@ -1430,21 +1437,24 @@ static void threadsafe_queue_push(threadsafe_queue *queue, MSVCP_size_t id,
p = queue->tail; p = queue->tail;
} }
/* TODO: Add exception handling */ __TRY
{
if(copy) if(copy)
call__Concurrent_queue_base_v4__Copy_item(parent, p, id-page_id, e); call__Concurrent_queue_base_v4__Copy_item(parent, p, id-page_id, e);
else else
call__Concurrent_queue_base_v4__Move_item(parent, p, id-page_id, e); call__Concurrent_queue_base_v4__Move_item(parent, p, id-page_id, e);
p->_Mask |= 1 << (id - page_id); p->_Mask |= 1 << (id - page_id);
InterlockedIncrementSizeT(&queue->tail_pos); }
__FINALLY_CTX(queue_push_finally, queue);
} }
static void threadsafe_queue_pop(threadsafe_queue *queue, MSVCP_size_t id, static BOOL threadsafe_queue_pop(threadsafe_queue *queue, MSVCP_size_t id,
void *e, _Concurrent_queue_base_v4 *parent) void *e, _Concurrent_queue_base_v4 *parent)
{ {
MSVCP_size_t page_id = id & ~(parent->alloc_count-1); MSVCP_size_t page_id = id & ~(parent->alloc_count-1);
int spin; int spin;
_Page *p; _Page *p;
BOOL ret = FALSE;
spin = 0; spin = 0;
while(queue->tail_pos <= id) while(queue->tail_pos <= id)
...@@ -1455,8 +1465,12 @@ static void threadsafe_queue_pop(threadsafe_queue *queue, MSVCP_size_t id, ...@@ -1455,8 +1465,12 @@ static void threadsafe_queue_pop(threadsafe_queue *queue, MSVCP_size_t id,
spin_wait(&spin); spin_wait(&spin);
p = queue->head; p = queue->head;
if(p->_Mask & (1 << (id-page_id)))
{
/* TODO: Add exception handling */ /* TODO: Add exception handling */
call__Concurrent_queue_base_v4__Assign_and_destroy_item(parent, e, p, id-page_id); call__Concurrent_queue_base_v4__Assign_and_destroy_item(parent, e, p, id-page_id);
ret = TRUE;
}
if(id == page_id+parent->alloc_count-1) if(id == page_id+parent->alloc_count-1)
{ {
...@@ -1471,7 +1485,9 @@ static void threadsafe_queue_pop(threadsafe_queue *queue, MSVCP_size_t id, ...@@ -1471,7 +1485,9 @@ static void threadsafe_queue_pop(threadsafe_queue *queue, MSVCP_size_t id,
/* TODO: Add exception handling */ /* TODO: Add exception handling */
call__Concurrent_queue_base_v4__Deallocate_page(parent, p); call__Concurrent_queue_base_v4__Deallocate_page(parent, p);
} }
InterlockedIncrementSizeT(&queue->head_pos); InterlockedIncrementSizeT(&queue->head_pos);
return ret;
} }
/* ?_Internal_push@_Concurrent_queue_base_v4@details@Concurrency@@IAEXPBX@Z */ /* ?_Internal_push@_Concurrent_queue_base_v4@details@Concurrency@@IAEXPBX@Z */
...@@ -1516,11 +1532,14 @@ MSVCP_bool __thiscall _Concurrent_queue_base_v4__Internal_pop_if_present( ...@@ -1516,11 +1532,14 @@ MSVCP_bool __thiscall _Concurrent_queue_base_v4__Internal_pop_if_present(
do do
{ {
do
{
id = this->data->head_pos; id = this->data->head_pos;
if(id == this->data->tail_pos) return FALSE; if(id == this->data->tail_pos) return FALSE;
} while(InterlockedCompareExchangePointer((void**)&this->data->head_pos, } while(InterlockedCompareExchangePointer((void**)&this->data->head_pos,
(void*)(id+1), (void*)id) != (void*)id); (void*)(id+1), (void*)id) != (void*)id);
threadsafe_queue_pop(this->data->queues + id % QUEUES_NO, id / QUEUES_NO, e, this); } while(!threadsafe_queue_pop(this->data->queues + id % QUEUES_NO,
id / QUEUES_NO, e, this));
return TRUE; return TRUE;
} }
......
...@@ -92,7 +92,7 @@ extern "C" { ...@@ -92,7 +92,7 @@ extern "C" {
#else /* USE_COMPILER_EXCEPTIONS */ #else /* USE_COMPILER_EXCEPTIONS */
#if defined(__MINGW32__) || defined(__CYGWIN__) #if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__WINE_SETJMP_H)
#define sigjmp_buf jmp_buf #define sigjmp_buf jmp_buf
#define sigsetjmp(buf,sigs) setjmp(buf) #define sigsetjmp(buf,sigs) setjmp(buf)
#define siglongjmp(buf,val) longjmp(buf,val) #define siglongjmp(buf,val) longjmp(buf,val)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment