fixed a potential issue concerning makecontext()

This commit is contained in:
hyung-hwan 2013-01-04 16:04:18 +00:00
parent 02831b01a0
commit db32de0ceb
3 changed files with 37 additions and 6 deletions

View File

@ -60,7 +60,7 @@
# undef QSE_HAVE_INLINE_NEVER
#endif
#if defined(_WIN32)
#if defined(_WIN32) || defined(__WATCOMC__)
# define QSE_IMPORT __declspec(dllimport)
# define QSE_EXPORT __declspec(dllexport)
# define QSE_PRIVATE
@ -69,10 +69,6 @@
# define QSE_EXPORT __attribute__((visibility("default")))
# define QSE_PRIVATE __attribute__((visibility("hidden")))
/*# define QSE_PRIVATE __attribute__((visibility("internal")))*/
#elif defined(__WATCOMC__)
# define QSE_IMPORT __declspec(dllimport)
# define QSE_EXPORT __declspec(dllexport)
# define QSE_PRIVATE
#else
# define QSE_IMPORT
# define QSE_EXPORT

View File

@ -190,6 +190,29 @@ static void link_task (qse_task_t* task, qse_task_slice_t* slice)
# define __CALL_BACK__
#endif
#if defined(USE_UCONTEXT) && \
(QSE_SIZEOF_INT == QSE_SIZEOF_INT32_T) && \
(QSE_SIZEOF_VOID_P == (QSE_SIZEOF_INT32_T * 2))
static void __CALL_BACK__ execute_current_slice (qse_uint32_t ptr1, qse_uint32_t ptr2)
{
qse_task_slice_t* slice;
qse_task_slice_t* to;
slice = (qse_task_slice_t*)(((qse_uintptr_t)ptr1 << 32) | ptr2);
QSE_ASSERT (slice->task->current == slice);
to = slice->fnc (slice->task, slice, slice->ctx);
/* the task function is now terminated. we need to
* purge it from the slice list and switch to the next
* slice. */
purge_current_slice (slice, to);
QSE_ASSERT (!"must never reach here...");
}
#else
static void __CALL_BACK__ execute_current_slice (qse_task_slice_t* slice)
{
qse_task_slice_t* to;
@ -204,6 +227,8 @@ static void __CALL_BACK__ execute_current_slice (qse_task_slice_t* slice)
QSE_ASSERT (!"must never reach here...");
}
#endif
#if defined(__WATCOMC__)
/* for watcom, i support i386/32bit only */
@ -261,7 +286,17 @@ qse_task_slice_t* qse_task_create (
slice->uctx.uc_stack.ss_sp = slice + 1;
slice->uctx.uc_stack.ss_size = stksize;
slice->uctx.uc_link = QSE_NULL;
#if (QSE_SIZEOF_INT == QSE_SIZEOF_INT32_T) && \
(QSE_SIZEOF_VOID_P == (QSE_SIZEOF_INT32_T * 2))
/* limited work around for unclear makecontext parameters */
makecontext (&slice->uctx, execute_current_slice, 2,
(qse_uint32_t)(((qse_uintptr_t)slice) >> 32),
(qse_uint32_t)((qse_uintptr_t)slice & 0xFFFFFFFFu));
#else
makecontext (&slice->uctx, execute_current_slice, 1, slice);
#endif
#else