Пример #1
0
void LmuxRelease(lmutex_t *mux)
{
    unsigned my_id;

    my_id = ThrGetThreadInfo()->id;
    if (mux->locks > 1)
    {
	if (mux->owner != my_id)
	{
	    _wdprintf(L"LmuxRelease(%p/%u): incorrect owner %u, should be %u\n",
		mux, mux->mutex, mux->owner, my_id);
	    __asm__("int3");
	}

	mux->eip = 0;
	mux->owner = 0;
	if (!SemUp(mux->mutex))
	    __asm__("int3");
    }
    else
    {
	mux->eip = 0;
	mux->locks = 0;
	mux->owner = 0;
    }
}
Пример #2
0
/*
 * Allocate an event handle for a sync I/O operation
 */
static handle_t FsAllocSyncIoEvent()
{
    thread_info_t *info;
    unsigned index;

    info = ThrGetThreadInfo();
    index = info->next_sync_io_event++;
    return info->sync_io_events[index];
}
Пример #3
0
void __libc_exception_handler(void)
{
    static bool nested;
    bool handled;
    context_t *ctx;

    if (nested)
	ProcExitProcess(0);

    nested = true;
    ctx = &ThrGetThreadInfo()->exception_info;
    handled = DbgHandleException(ctx);
    nested = false;

    if (handled)
    ThrContinue(ctx);
    else
	exit(0);
}
Пример #4
0
void __libc_init(void)
{
    extern void (*__CTOR_LIST__[])();
    void (**pfunc)() = __CTOR_LIST__;

    if (ProcGetProcessInfo()->std_out != 0)
	ThrGetThreadInfo()->exception_handler = __libc_exception_handler;

    __malloc_lock_init();
    __malloc_debug_init();
    atexit(__malloc_lock_cleanup);
    __get_stdin();
    __get_stdout();
    __get_stderr();
    __setup_file_rec_list();

    while (*++pfunc)
	;
    while (--pfunc > __CTOR_LIST__)
	(*pfunc) ();
}
Пример #5
0
void LmuxAcquire(lmutex_t *mux)
{
    unsigned my_id;
    volatile lmutex_t *vmux = (volatile lmutex_t*) mux;

    my_id = ThrGetThreadInfo()->id;

    if (vmux->owner == my_id)
    {
	_wdprintf(L"LmuxAcquire(%p/%u): recursive acquisition by %u\n",
	    vmux, vmux->mutex, my_id);
	__asm__("int3");
    }

    if (SysIncrement(&vmux->locks) > 0)
    {
	if (!SemDown(vmux->mutex))
	    __asm__("int3");

	if (vmux->owner != 0)
	{
	    _wdprintf(L"LmuxAcquire(%p/%u): still locked by %u, %u contend\n",
		vmux, vmux->mutex, vmux->owner, my_id);
	    __asm__("int3");
	}

	vmux->eip = *(&mux - 1);
	vmux->locks--;
	vmux->owner = my_id;
    }
    else
    {
	vmux->eip = *(&mux - 1);
	vmux->owner = my_id;
    }
}
Пример #6
0
int *_geterrno()
{
	return &ThrGetThreadInfo()->status;
}
Пример #7
0
/*
 * Deallocate an event handle used for a sync I/O operation
 */
static void FsFreeSyncIoEvent(handle_t event)
{
    thread_info_t *info;
    info = ThrGetThreadInfo();
    info->next_sync_io_event--;
}