Exemplo n.º 1
0
int main(void)
{
	double source[ROWS][COLS];
	double target[ROWS][COLS];

	fill_arr(source);
	copy_arr(source, target);
	print_ptr(source);
	print_ptr(target);

	return 0;
}
Exemplo n.º 2
0
void task_print(char *str, struct task_t *current_task, struct task_t *next_task) {
  print_buf(str);
  print_buf(" c=");
  print_ptr(current_task);
  print_buf(" c->sp=");
  print_ptr(current_task->sp);
  print_buf(" n=");
  print_ptr(next_task);
  print_buf(" n->sp=");
  print_ptr(next_task->sp);
  print_buf(" n->pc=");
  print_hex(next_task->sp[15]); // sp: cspr, 13 regs, lr, pc
  print_buf(" n->lr=");
  print_hex(next_task->sp[14]); // sp: cspr, 13 regs, lr, pc
  print_buf("\n");
};
Exemplo n.º 3
0
struct task_t *task_start(task_func_t *task_func) {
  struct task_t *task = (struct task_t *)malloc_alloc(sizeof(struct task_t));
  char *p = malloc_alloc(0x800);
  p += 0x800;
  task->sp = (uint32 *)(p); // 2k stack
  task->msg = 0;
  task->state = TASK_STATE_ACTIVE;
  list_init(&task->input_channels);
  list_init(&task->output_channels);
  task_create(&task->sp, task_func);
  list_add_last(active_tasks, task);
  print_buf("task start:");
  print_buf(" t=");
  print_ptr(task);
  print_buf(" t->sp=");
  print_ptr(task->sp);
  print_buf("\n");
  return task;
}
Exemplo n.º 4
0
int main(int argc, char** argv) {
  int stack_size = 16 * 4096; // 16K byte
  int heap_size = (4 * 16 * 4096);
  char* stack_base = allocate_protected_space(stack_size);
  char* stack_top = stack_base + stack_size;
  char* heap_base = allocate_protected_space(heap_size);
  char* heap_top = heap_base + heap_size;

  /*printf("heap base:%u\n", (unsigned int)heap_base);*/
  context ctx;
  print_ptr(scheme_entry(&ctx, stack_top, heap_base));
  deallocate_protected_space(stack_base, stack_size);
  deallocate_protected_space(heap_base, heap_size);
  return 0;
}
Exemplo n.º 5
0
unsigned int	print_it(t_tmp_arg *tmp, t_params *params, char c,
			 unsigned int chars_to_save)
{
  unsigned int	wt;

  wt = 0;
  (c == 'd') ? (wt = print_int(tmp, params, 0, 0)) : (0);
  (c == 'i') ? (wt = print_int(tmp, params, 0, 0)) : (0);
  (c == 'u') ? (wt = print_uint(tmp, params, 0, 0)) : (0);
  (c == 'x') ? (wt = print_little_hexa(tmp, params, 0, 0)) : (0);
  (c == 'X') ? (wt = print_large_hexa(tmp, params, 0, 0)) : (0);
  (c == 'n') ? (wt = save_chars(tmp, chars_to_save)) : (0);
  (c == 'o') ? (wt = print_octal(tmp, params, 0, 0)) : (0);
  (c == 'c') ? (wt = print_char(tmp, params, 0, 0)) : (0);
  (c == 's') ? (wt = print_str(tmp, params, 0, 0)) : (0);
  (c == '%') ? (wt = print_percent()) : (0);
  (c == 'S') ? (wt = print_all_str(tmp, params, 0, 0)) : (0);
  (c == 'p') ? (wt = print_ptr(tmp, params, 0, 0)) : (0);
  (c == 'b') ? (wt = print_binary(tmp, params, 0, 0)) : (0);
  return (wt);
}
Exemplo n.º 6
0
int main(int argc, const char *argv[])
{
	char buff[1024];
	sla_t sla;

	sla_init_seed(&sla, 5, 0.5, 2);
	for (unsigned i=0; i<sizeof(buff); i++) {
		buff[i] = 'a' + (i % ('z' - 'a' + 1));
	}

	sla_copyto_rand(&sla, buff, sizeof(buff), 10, 100);
	//sla_print_chars(&sla);
	sla_print(&sla); printf("\n");

	sla_fwrd_t ptr[sla.cur_level];
	for (size_t ptr_i=0; ptr_i<sizeof(buff); ptr_i++) {
		sla_setptr(&sla, ptr_i, ptr);
		printf("ptr for %lu\n", ptr_i); print_ptr(ptr, sla.cur_level);
		test_ptr_nextchunk(&sla, buff, ptr, ptr_i, sizeof(buff));
	}

	printf("DONE!\n");
	return 0;
}
Exemplo n.º 7
0
boolean
save_executable(char *filename, lispobj init_function)
{
    char *dir_name;

#if defined WANT_CGC
    volatile lispobj *func_ptr = &init_function;
    char sbuf[128];

    strcpy(sbuf, filename);
    filename = sbuf;
    /* Get rid of remnant stuff. This is a MUST so that
     * the memory manager can get started correctly when
     * we restart after this save. Purify is going to
     * maybe move the args so we need to consider them volatile,
     * especially if the gcc optimizer is working!!
     */
    purify(NIL, NIL);

    init_function = *func_ptr;
    /* Set dynamic space pointer to base value so we don't write out
     * MBs of just cleared heap.
     */
    if(SymbolValue(X86_CGC_ACTIVE_P) != NIL)
        SetSymbolValue(ALLOCATION_POINTER, DYNAMIC_0_SPACE_START);
#endif
    dir_name = dirname(strdup(filename));

    printf("[Undoing binding stack... ");
    fflush(stdout);
    unbind_to_here((lispobj *)BINDING_STACK_START);
    SetSymbolValue(CURRENT_CATCH_BLOCK, 0);
    SetSymbolValue(CURRENT_UNWIND_PROTECT_BLOCK, 0);
    SetSymbolValue(EVAL_STACK_TOP, 0);
    printf("done]\n");
#if defined WANT_CGC && defined X86_CGC_ACTIVE_P
    SetSymbolValue(X86_CGC_ACTIVE_P, T);
#endif
    printf("[Saving current lisp image as executable into \"%s\":\n", filename);

    printf("\t[Writing core objects\n");
    fflush(stdout);
    write_space_object(dir_name, READ_ONLY_SPACE_ID, (os_vm_address_t)read_only_space,
                       (os_vm_address_t)SymbolValue(READ_ONLY_SPACE_FREE_POINTER));
    write_space_object(dir_name, STATIC_SPACE_ID, (os_vm_address_t)static_space,
                       (os_vm_address_t)SymbolValue(STATIC_SPACE_FREE_POINTER));
#ifdef GENCGC
    /* Flush the current_region updating the tables. */
#ifdef DEBUG_BAD_HEAP
    fprintf(stderr, "before ALLOC_POINTER = %p\n", (lispobj *) SymbolValue(ALLOCATION_POINTER));
    dump_region(&boxed_region);
#endif
    gc_alloc_update_page_tables(0,&boxed_region);
    gc_alloc_update_page_tables(1,&unboxed_region);
#ifdef DEBUG_BAD_HEAP
    fprintf(stderr, "boxed_region after update\n");
    dump_region(&boxed_region);

    print_ptr((lispobj*) 0x2805a184);
#endif
#ifdef DEBUG_BAD_HEAP
    /*
     * For some reason x86 has a heap corruption problem.  I (rtoy)
     * have not been able to figure out how that occurs, but what is
     * happening is that when a core is loaded, there is some static
     * object pointing to an object that is on a free page.  In normal
     * usage, at startup there should be 4 objects in static space
     * pointing to a free page, because these are newly allocated
     * objects created by the C runtime.  However, there is an
     * additional object.
     *
     * I do not know what this object should be or how it got there,
     * but it will often cause CMUCL to fail to save a new core file.
     *
     * Disabling this call to update_dynamic_space_free_pointer is a
     * work around.  What is happening is that u_d_s_f_p is resetting
     * ALLOCATION_POINTER, but that weird object is in the current
     * region, but after resetting the pointer, that object isn't
     * saved to the core file.  By not resetting the pointer, the
     * object (or at least enough of it) gets saved in the core file
     * that we don't have problems when reloading.
     *
     * Note that on sparc and ppc, u_d_s_f_p doesn't actually do
     * anything because the call to reset ALLOCATION_POINTER is a nop
     * on sparc and ppc.  And sparc and ppc dont' have the heap
     * corruption issue.  That's not conclusive evidence, though.
     *
     * This needs more work and investigation.
     */
    update_dynamic_space_free_pointer();
#endif

#ifdef DEBUG_BAD_HEAP    
    fprintf(stderr, "after ALLOC_POINTER = %p\n", (lispobj *) SymbolValue(ALLOCATION_POINTER));
#endif    
#endif

#ifdef reg_ALLOC
    write_space_object(dir_name, DYNAMIC_SPACE_ID, (os_vm_address_t)current_dynamic_space,
                       (os_vm_address_t)current_dynamic_space_free_pointer);
#else
    write_space_object(dir_name, DYNAMIC_SPACE_ID, (os_vm_address_t)current_dynamic_space,
                       (os_vm_address_t)SymbolValue(ALLOCATION_POINTER));
#endif

    printf("\tdone]\n");
    fflush(stdout);
    
    printf("Linking executable...\n");
    fflush(stdout);
    obj_run_linker(init_function, filename);
    printf("done.\n");
    exit(0);
}
Exemplo n.º 8
0
int main(int argc, char const *argv[])
{
	print_arr(ga);
	print_ptr(ga);
	return 0;
}