static void group_hash_foreach_monitor (gpointer key, gpointer value, gpointer user_data) { DirGroup *group_node = value; DirProject *project = user_data; monitor_add (project, DIR_GROUP_DATA(group_node)->base.directory); }
static void files_hash_foreach_monitor (gpointer key, gpointer value, gpointer user_data) { GFile *makefile = (GFile *)key; MkpProject *project = user_data; monitor_add (project, makefile); }
static void monitors_setup (DirProject *project) { g_return_if_fail (project != NULL); monitors_remove (project); /* setup monitors hash */ project->monitors = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) g_file_monitor_cancel); monitor_add (project, project->root_file); if (project->groups) g_hash_table_foreach (project->groups, group_hash_foreach_monitor, project); }
bool xinerama(void) { bool is_active = false; if (xcb_get_extension_data(cfg.conn, &xcb_xinerama_id)->present) { xcb_xinerama_is_active_reply_t *reply = xcb_xinerama_is_active_reply(cfg.conn, xcb_xinerama_is_active(cfg.conn), (void *)0); if (!reply) return false; is_active = reply->state; free(reply); } if (!is_active) { warn("xinerama is not present\n"); return false; } const xcb_xinerama_query_screens_cookie_t cookie = xcb_xinerama_query_screens_unchecked(cfg.conn); xcb_xinerama_query_screens_reply_t *reply = xcb_xinerama_query_screens_reply(cfg.conn, cookie, (void *)0); if (!reply) return false; const xcb_xinerama_screen_info_t *info = xcb_xinerama_query_screens_screen_info(reply); int screens = xcb_xinerama_query_screens_screen_info_length(reply); PRINTF("xinerama screens: %d\n", screens); for (int screen = 0; screen < screens; screen++) { PRINTF("adding screen: %d\n", screen); monitor_add(info[screen].x_org, info[screen].y_org, info[screen].width, info[screen].height); } free(reply); return true; }
void proc_init(void) { LIST_INIT(&proc_ready_list); #if CONFIG_KERN_HEAP LIST_INIT(&zombie_list); heap_init(&proc_heap, heap_buf, sizeof(heap_buf)); #endif /* * We "promote" the current context into a real process. The only thing we have * to do is create a PCB and make it current. We don't need to setup the stack * pointer because it will be written the first time we switch to another process. */ proc_initStruct(&main_process); current_process = &main_process; #if CONFIG_KERN_MONITOR monitor_init(); monitor_add(current_process, "main"); #endif MOD_INIT(proc); }
bool randr(void) { if (!xcb_get_extension_data(cfg.conn, &xcb_randr_id)->present) { warn("randr is not present\n"); return false; } const xcb_randr_get_screen_resources_cookie_t cookie = xcb_randr_get_screen_resources_unchecked(cfg.conn, cfg.screen->root); xcb_randr_get_screen_resources_reply_t *reply = xcb_randr_get_screen_resources_reply(cfg.conn, cookie, (void *)0); if (!reply) return false; const xcb_randr_crtc_t *info = xcb_randr_get_screen_resources_crtcs(reply); PRINTF("randr num crtcs: %u\n", reply->num_crtcs); xcb_randr_get_crtc_info_cookie_t cookies[reply->num_crtcs]; for (uint16_t crtc = 0; crtc < reply->num_crtcs; crtc++) cookies[crtc] = xcb_randr_get_crtc_info_unchecked(cfg.conn, info[crtc], XCB_CURRENT_TIME); for (uint16_t crtc = 0; crtc < reply->num_crtcs; crtc++) { xcb_randr_get_crtc_info_reply_t *reply = xcb_randr_get_crtc_info_reply(cfg.conn, cookies[crtc], (void *)0); if (!reply) continue; PRINTF("adding crtc: %u\n", crtc); monitor_add(reply->x, reply->y, reply->width, reply->height); free(reply); } free(reply); return true; }
inline void zaphod(void) { monitor_add(0, 0, cfg.screen->width_in_pixels, cfg.screen->height_in_pixels); }
/** * Create a new process, starting at the provided entry point. * * * \note The function * \code * proc_new(entry, data, stacksize, stack) * \endcode * is a more convenient way to create a process, as you don't have to specify * the name. * * \return Process structure of new created process * if successful, NULL otherwise. */ struct Process *proc_new_with_name(UNUSED_ARG(const char *, name), void (*entry)(void), iptr_t data, size_t stack_size, cpu_stack_t *stack_base) { Process *proc; LOG_INFO("name=%s", name); #if CONFIG_KERN_HEAP bool free_stack = false; /* * Free up resources of a zombie process. * * We're implementing a kind of lazy garbage collector here for * efficiency reasons: we can avoid to introduce overhead into another * kernel task dedicated to free up resources (e.g., idle) and we're * not introducing any overhead into the scheduler after a context * switch (that would be *very* bad, because the scheduler runs with * IRQ disabled). * * In this way we are able to release the memory of the zombie tasks * without disabling IRQs and without introducing any significant * overhead in any other kernel task. */ proc_freeZombies(); /* Did the caller provide a stack for us? */ if (!stack_base) { /* Did the caller specify the desired stack size? */ if (!stack_size) stack_size = KERN_MINSTACKSIZE; /* Allocate stack dinamically */ PROC_ATOMIC(stack_base = (cpu_stack_t *)heap_allocmem(&proc_heap, stack_size)); if (stack_base == NULL) return NULL; free_stack = true; } #else // CONFIG_KERN_HEAP /* Stack must have been provided by the user */ ASSERT_VALID_PTR(stack_base); ASSERT(stack_size); #endif // CONFIG_KERN_HEAP #if CONFIG_KERN_MONITOR /* * Fill-in the stack with a special marker to help debugging. * On 64bit platforms, CONFIG_KERN_STACKFILLCODE is larger * than an int, so the (int) cast is required to silence the * warning for truncating its size. */ memset(stack_base, (int)CONFIG_KERN_STACKFILLCODE, stack_size); #endif /* Initialize the process control block */ if (CPU_STACK_GROWS_UPWARD) { proc = (Process *)stack_base; proc->stack = stack_base + PROC_SIZE_WORDS; // On some architecture stack should be aligned, so we do it. proc->stack = (cpu_stack_t *)((uintptr_t)proc->stack + (sizeof(cpu_aligned_stack_t) - ((uintptr_t)proc->stack % sizeof(cpu_aligned_stack_t)))); if (CPU_SP_ON_EMPTY_SLOT) proc->stack++; } else { proc = (Process *)(stack_base + stack_size / sizeof(cpu_stack_t) - PROC_SIZE_WORDS); // On some architecture stack should be aligned, so we do it. proc->stack = (cpu_stack_t *)((uintptr_t)proc - ((uintptr_t)proc % sizeof(cpu_aligned_stack_t))); if (CPU_SP_ON_EMPTY_SLOT) proc->stack--; } /* Ensure stack is aligned */ ASSERT((uintptr_t)proc->stack % sizeof(cpu_aligned_stack_t) == 0); stack_size -= PROC_SIZE_WORDS * sizeof(cpu_stack_t); proc_initStruct(proc); proc->user_data = data; #if CONFIG_KERN_HEAP | CONFIG_KERN_MONITOR proc->stack_base = stack_base; proc->stack_size = stack_size; #if CONFIG_KERN_HEAP if (free_stack) proc->flags |= PF_FREESTACK; #endif #endif proc->user_entry = entry; CPU_CREATE_NEW_STACK(proc->stack); #if CONFIG_KERN_MONITOR monitor_add(proc, name); #endif /* Add to ready list */ ATOMIC(SCHED_ENQUEUE(proc)); return proc; }