Example #1
0
t_data			*init(void)
{
	t_data		*d;

	if(!(d = tt_malloc(sizeof(t_data))))
		exit(tt_pl("Failed to alloc data"));
	d->r.o = VEC3(0, 0, 0);
	tt_pl("Init mlx");
	init_mlx(d);
	tt_pl("Init obj");
	init_obj(d);
	tt_pl("Init light");
	init_light(d);
	return (d);
}
Example #2
0
obj * create_str(char * str, int len){
    obj* o = init_obj();
    o->type = 's';
    o->hash = str_hash(str, len);

    String * s = malloc(sizeof(String) + len);
    MEM_ERROR_CHECK(s)
    s->len = len;
    strncpy(s->string, str, len);

    table_set(o->dict, m_add, str_add);
    table_set(o->dict, m_iadd, str_add);

    o->data = s;
    return o;
}
Example #3
0
static obj * create_str_concat(String * str1, String * str2){
    obj* o = init_obj();
    o->type = 's';

    int new_len = str1->len + str2->len;

    String * s = malloc(sizeof(String) + new_len);
    MEM_ERROR_CHECK(s)
    s->len = new_len;
    strncpy(s->string, str1->string, str1->len);
    strncat(s->string, str2->string, str2->len);

    table_set(o->dict, m_add, str_add);
    table_set(o->dict, m_iadd, str_add);

    o->hash = str_hash(s->string, new_len);
    o->data = s;
    return o;
}
Example #4
0
int get_varnames(unsigned* pycbuf, struct code_obj* pobj, int cur)
{
    struct obj* ptrobj;
    int n_varnames = (pobj->varnames).length = compute_const(pycbuf, cur);
    cur += 5;
    while(n_varnames--) {
        if (pycbuf[cur] == TYPE_INTERN) {
            ptrobj = init_obj();
            copy(ptrobj->name, pycbuf, cur+5, length(pycbuf, cur));
            objects[obj_cnt++] = ptrobj;
        
            cur = skip_element(pycbuf,  cur);
        } else if (pycbuf[cur] == TYPE_SREF) {
            cur += 5;
        } else
            cur++;
    }
    return cur;
}
Example #5
0
File: main.c Project: cpylua/scheme
static int init(void) {
    int ret;

    ret = gc_init(-1); /* -1: default heap size */
    if (ret != 0) {
        fprintf(stderr, "gc system failed to initialize\n");
        return ret;
    }

    ret = init_obj();
    if (ret != 0) {
        return ret;
    }

    ret = setup_startup_time();
    if (ret != 0) {
        return ret;
    }

    init_random();
    return 0;
}
Example #6
0
t_board		*my_init_board()
{
  t_board	*board;

  if ((board = bunny_malloc(sizeof(*board))) == NULL ||
      (board->button =
       bunny_malloc(sizeof(*board->button) * (NB_BUTTON + 1))) == NULL ||
      (board->obj =
       bunny_malloc(sizeof(*board->obj) * (NB_OBJ + 1))) == NULL ||
      init_button(board->button) == - 1 || init_obj(board->obj) == - 1 ||
      (board->calque = bunny_malloc(sizeof(*board->calque))) == NULL ||
      (board->calque->pix = load_bitmap(BOARD_BMP)) == NULL)
    return (NULL);
  board->calque->x_speed = 0;
  board->calque->y_speed = 0;
  board->calque->x_init = 0;
  board->calque->y_init = 0;
  board->calque->x = 0;
  board->calque->y = 720;
  board->calque->scale = 100;
  board->sel = ID_GO;
  return (board);
}
Example #7
0
int			init_env(t_env *e, t_obj *obj)
{
	if ((e->mlx = mlx_init()) == NULL)
		return (m_error("mlx_init(): fail"));
	if ((e->win = mlx_new_window(e->mlx, WIN_X, WIN_Y, "rtv1")) == NULL)
		return (m_error("mlx_new_window(): fail"));
	if ((e->img = mlx_new_image(e->mlx, WIN_X, WIN_Y)) == NULL)
		return (m_error("mlx_new_image(): fail"));
	if ((e->addr = mlx_get_data_addr(e->img, &(e->bpp), &(e->size_line),
		&(e->endian))) == NULL)
		return (m_error("mlx_get_data_addr(): fail"));
	if ((e->rgb_tab = (t_rgb *)malloc(sizeof(t_rgb) * (WIN_X * WIN_Y))) == NULL)
		return (m_error("rgb_tab_init(): fail"));
	e->eye_pos = vec_new(0, 0, 0);
	e->eye_dir = vec_new(0, 0, 1);
	e->right_vec = vec_new(1, 0, 0);
	e->up_vec = vec_new(0, -1, 0);
	e->view_plane_ori = vec_add(vec_add(e->eye_pos, vec_numb(e->eye_dir,
		VIEW_PLANE_DIST)), vec_sub(vec_numb(e->up_vec, VIEW_PLANE_HEIGHT / 2.0)
		, vec_numb(e->right_vec, VIEW_PLANE_WIDTH / 2.0)));
	init_obj(obj);
	return (0);
}
Example #8
0
void object_spawn_init(master *mstr){

	//init timer1 and interrupt


	//set base values
	init_obj(mstr->o);
	init_obj(mstr->co);
	init_obj(mstr->spikes);
	init_obj(mstr->box_3);
	init_obj(mstr->box_1);
	init_obj(mstr->flag);

	IOWR_16DIRECT(TIMER_1_BASE, 8, mstr->l->wait_time[mstr->l->obj_index] & 0xFFFF); //writes the period to the hardware timer
	IOWR_16DIRECT(TIMER_1_BASE, 12, mstr->l->wait_time[mstr->l->obj_index] >> 16);
	IOWR_16DIRECT(TIMER_1_BASE, 4, 1 << 3); //stop timer

	alt_irq_register(TIMER_1_IRQ,mstr,(void*)object_spawn_interrupt);//registers function to a specific IRQ

	//IOWR_16DIRECT(TIMER_1_BASE, 4, 0x5);	//starts timer with interrupt

	return;
}
Example #9
0
obj * create_c_func(obj* (*function)(obj* self, int argc, obj** args)){
    obj *o = init_obj();
    o->type = 'c';
    o->c_func = function;
    return o;
}
Example #10
0
obj * create_user_obj(){
    obj * o = init_obj();
    return o;
}
Example #11
0
// **********************************************************************
// **********************************************************************
// create task
int createTask(char* name,						// task name
					int (*task)(int, char**),	// task address
					int priority,				// task priority
					int argc,					// task argument count
					char* argv[])				// task argument pointers
{
	int tid;

	// find an open tcb entry slot
	for (tid = 0; tid < MAX_TASKS; tid++)
	{
		if (tcb[tid].name == 0)
		{
			char buf[8];

			// create task semaphore
			if (taskSems[tid]) deleteSemaphore(&taskSems[tid]);
			sprintf(buf, "task%d", tid);
			taskSems[tid] = createSemaphore(buf, 0, 0);
			taskSems[tid]->taskNum = 0;	// assign to shell

			// copy task name
			tcb[tid].name = (char*)malloc(strlen(name)+1);
			strcpy(tcb[tid].name, name);

			// set task address and other parameters
			tcb[tid].task = task;			// task address
			tcb[tid].state = S_NEW;			// NEW task state
			tcb[tid].priority = priority;	// task priority
			tcb[tid].parent = curTask;		// parent
			tcb[tid].argc = argc;			// argument count

			// ?? malloc new argv parameters
			tcb[tid].argv = (char**)malloc(sizeof(char*) * (argc+1));	// argument pointers
			for (int i = 0; i < argc; i++)
			{
				tcb[tid].argv[i] = (char*)malloc(sizeof(char) * (strlen(argv[i])+1));
				strcpy(tcb[tid].argv[i], argv[i]);
			}
			//////////////////////////////////////////

			tcb[tid].event = 0;				// suspend semaphore
			tcb[tid].RPT = LC3_RPT + ((tid) ? ((tid - 1) << 6) : 0);
			tcb[tid].cdir = CDIR;			// inherit parent cDir (project 6)

			tcb[tid].taskTime = 0;

			// define task signals
			createTaskSigHandlers(tid);

			// Each task must have its own stack and stack pointer.
			tcb[tid].stack = malloc(STACK_SIZE * sizeof(int));

			obj task;
			init_obj(&task,tcb[tid].priority,tid);
			enQ(&readyQ, task);

			if (tid) swapTask();				// do context switch (if not cli)
			return tid;							// return tcb index (curTask)
		}
	}
	// tcb full!
	return -1;
} // end createTask
Example #12
0
//----------------------------------------------------
//constructor de Mesa
obj_Mesa *Mesa_new()
{
  return (obj_Mesa *)init_obj(sizeof(obj_Mesa), init_Mesa);
}
HeapWord* CollectedHeap::common_mem_allocate_init(size_t size, bool is_noref, TRAPS) {
  HeapWord* obj = common_mem_allocate_noinit(size, is_noref, CHECK_0);
  init_obj(obj, size);
  return obj;
}
Example #14
0
//----------------------------------------------------
//constructor de Escuela
obj_Escuela *Escuela_new()
{
  return (obj_Escuela *)init_obj(sizeof(obj_Escuela), init_Escuela);
}
Example #15
0
File: main.c Project: j16r/poseidon
void entry(struct Multiboot_Info_dec * old_mbinfo)
{
    // This function is entered into by the kernel header
    // which sets up some basic tables for use and passes on 
    // the multiboot info structure
    
    struct Multiboot_Info_dec mbinfo;
    
#ifdef DEBUG

    U8 * screen = (U8 *)0xB8000;
    U16 i;

    // Clear the screen so debug messages are more visible

    for (i = 0; i < 160; i+=2)
    {
        screen[i] = ' ';
        screen[i+1] = 0x17;
    }

    for (i = 160; i < 7840; i+=2)
    {
        screen[i] = ' ';
        screen[i+1] = 0x07;
    }

    dprint("\t\t\tThe Poseidon Project Kernel.\n\n");

    dprint("The Poseidon Project (c) Copyright 1998, 1999 John Barker\n");
    dprint("All rights reserved. 32 bit message based real time operating system.\n\n");
    
#endif

    // Copy the old table to a local one for safe keeping
    // because once memory is initialized the old one may be wiped

    memcpy(&mbinfo,old_mbinfo,sizeof(struct Multiboot_Info_dec));

    // Set up the exception traps
    init_traps();

    // Allocate the irq routines
    init_irqs();
    
    // Initialize memory management so we can use kmalloc and other
    // memory based functions
    init_mm(&mbinfo);

    // Initialize the object manager so we can start using it
    init_obj();
    
    // Initialize the module/driver interface so modules can be loaded
    init_mdi();

    // Set up the clocks and timers
    init_time();

    // Set up tables and data for the executive
    init_executive();

    // Initialize IPC and message buffers for all objects
    init_ipc();

    // Initialize the system calls (system call interface)
    init_sci();
    
    // Load all the modules passed to us at boot time, one of these
    // should be init or main
    load_modules(&mbinfo);

    // Start the executive scheduler, will boot the init module
    start_executive();

    // The idle function - just loop, should be run in user mode
    idle();
}
Example #16
0
obj * create_real(double real){
    obj * o = init_obj();
    o->type = 'r';
    o->real = real;
    return o;
}
HeapWord* CollectedHeap::common_permanent_mem_allocate_init(size_t size, TRAPS) {
  HeapWord* obj = common_permanent_mem_allocate_noinit(size, CHECK_0);
  init_obj(obj, size);
  return obj;
}
Example #18
0
//----------------------------------------------------
//constructor de ActaTelegrama
obj_ActaTelegrama *ActaTelegrama_new()
{
  return (obj_ActaTelegrama *)init_obj(sizeof(obj_ActaTelegrama), init_ActaTelegrama);
}