Exemplo n.º 1
0
void test_instructions_for_call() {
	asm_p as = &(asm_t){ 0 };
	char* disassembly = NULL;
	as_new(as);
	
	as_clear(as);
		as_call(as, reld(0x7abbccdd));
		as_call(as, RAX);
		as_ret(as, 0);
		as_ret(as, 16);
	disassembly = disassemble(as);
	st_check_str(disassembly,
		"call   0x7afbcce2\n"
		"call   rax\n"
		"ret    \n"
		"ret    0x10\n"
	);
	
	as_clear(as);
		as_enter(as, 65, 0);
		as_leave(as);
		as_enter(as, 0, 0);
		as_leave(as);
	disassembly = disassemble(as);
	st_check_str(disassembly,
		"enter  0x41,0x0\n"
		"leave  \n"
		"enter  0x0,0x0\n"
		"leave  \n"
	);
	
	free(disassembly);
}
Exemplo n.º 2
0
/// The pthread entry function for dedicated worker threads.
///
/// This is used by _create().
static void *_run(void *worker) {
    dbg_assert(here);
    dbg_assert(here->gas);
    dbg_assert(worker);

    _bind_self(worker);

    // Ensure that all of the threads have joined the address spaces.
    as_join(AS_REGISTERED);
    as_join(AS_GLOBAL);
    as_join(AS_CYCLIC);

#ifdef HAVE_APEX
    // let APEX know there is a new thread
    apex_register_thread("HPX WORKER THREAD");
#endif

    // wait for the other threads to join
    system_barrier_wait(&here->sched->barrier);

    if (worker_start()) {
        dbg_error("failed to start processing lightweight threads.\n");
        return NULL;
    }

#ifdef HAVE_APEX
    // let APEX know the thread is exiting
    apex_exit_thread();
#endif

    // leave the global address space
    as_leave();

    // unbind self and return NULL
    return (self = NULL);
}