int sys_kill(int pid){ //t=t; printf("killing %d.",pid); ProcStruct *proc=(procs+pid-1); proc_free(proc); remove_page(proc->cr3); remove_page((uint64_t*)PADDR((uint64_t)proc->mm)); ProcStruct* parent =((ProcStruct*)procs+proc->parent_id-1); if(parent) parent->num_child--; if((parent) && (parent->status == WAITING) && (parent->waitingfor == proc->proc_id || parent->waitingfor == 0 || (parent->num_child==0))) { parent->status=RUNNABLE; parent->waitingfor=-1; } printf("Killed %d ",proc->proc_id); // kmemset((void*)proc,0,sizeof(ProcStruct)); proc->status = FREE; //proccount-- return 0; }
void sys_exit(uint64_t error_code){ // printf("Exiting Process%p %d",curproc,curproc->proc_id); if(curproc) { proc_free(curproc); remove_page(curproc->cr3); remove_page((uint64_t*)PADDR((uint64_t)curproc->mm)); ProcStruct* parent =((ProcStruct*)procs+curproc->parent_id-1); if(parent) parent->num_child--; if((parent) && (parent->status == WAITING) && (parent->waitingfor == curproc->proc_id || parent->waitingfor == 0 || (parent->num_child==0))) { parent->status=RUNNABLE; parent->waitingfor=-1; } printf("Exited%d ",curproc->proc_id); // kmemset((void*)proc,0,sizeof(ProcStruct)); curproc->status = FREE; //proccount-- } }
static u32int contract(u32int new_size, heap_t *heap) { ASSERT(new_size < heap->end_address - heap->start_address); if (new_size & 0xfffff000) { new_size &= 0xfffff000; new_size += 0x1000; } if (new_size < HEAP_MIN_SIZE) new_size = HEAP_MIN_SIZE; u32int old_size = heap->end_address - heap->start_address; u32int i = old_size - 0x1000; while (new_size < i) { //free_page((u32int)get_page_addr(heap->start_address + i)); remove_page(heap->start_address + i); i -= 0x1000; } heap->end_address = heap->start_address + new_size; return new_size; }
static BOOL delete_page (HWND hwnd, PCONTROL ctrl, PPROPSHEETDATA propsheet, int index) { PPROPPAGE page; if ((page = get_page (propsheet, index)) == NULL) { return PS_ERR; } /* first_display_page == active */ if (propsheet->active == page && propsheet->first_display_page == page) { if (page->next) { propsheet->active = page->next; propsheet->first_display_page = page->next; } else { PPROPPAGE left = get_left_page (propsheet, propsheet->active); if (left != NULL) { propsheet->active = left; propsheet->first_display_page = left; } else { propsheet->active = propsheet->first_display_page = NULL; } } /* propsheet->active = page->next; */ /* propsheet->first_display_page = page->next; */ } else { if ((propsheet->active == page) && (propsheet->first_display_page != page)) { if (propsheet->active->next == NULL) { propsheet->active = get_left_page (propsheet, page); } else { propsheet->active = propsheet->active->next; } goto del; } if ((propsheet->active != page) && (propsheet->first_display_page == page)) { if (propsheet->first_display_page->next == NULL) { propsheet->first_display_page = get_left_page (propsheet, page); } else { propsheet->first_display_page = propsheet->first_display_page->next; } goto del; } } del: remove_page (propsheet, page); destroy_page (page); free (page); if (propsheet->head) { update_propsheet (propsheet); } if (propsheet->active) { show_hide_page (propsheet->active, SW_SHOW); } InvalidateRect (hwnd, &propsheet->head_rc, TRUE); /* dump_propsheetdata (propsheet); */ return PS_OKAY; }
int do_unmap(pde_t * pgdir, vaddr_t va, uint size) { uint i,ret; if (va & 0xfff || size & 0xfff) panic("do_unmap invalid va or size"); for (i = 0; i < size; i += PAGE) { if ((ret = remove_page(pgdir, va)) < 0) return ret; va += PAGE; } return 0; }
void *realloc_large(t_page_list *lst, void *ptr, size_t len) { size_t i; void *addr; if (!(addr = create_new_block(LARGE, len))) { MALLOC_UNLOCK(); return (return_enomem(NULL)); } i = 0; while (i < len && i < lst->page.len - sizeof(*lst)) { ((unsigned char*)addr)[i] = ((unsigned char*)ptr)[i]; i++; } remove_page(lst); munmap(lst, lst->page.len); MALLOC_UNLOCK(); return (return_enomem(addr)); }
void EditorArea::close_editor(SourceEditor *editor) { remove_page(*editor); }
static void update_current_page (CcWacomPanel *self) { GHashTable *ht; GList *devices, *tablets, *l; gboolean changed; CcWacomPanelPrivate *priv; priv = self->priv; changed = FALSE; ht = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); devices = g_hash_table_get_values (priv->devices); for (l = devices; l; l = l->next) { Tablet *tablet; GsdWacomDevice *device; device = l->data; tablet = g_hash_table_lookup (ht, gsd_wacom_device_get_name (device)); if (tablet == NULL) { tablet = g_new0 (Tablet, 1); tablet->name = gsd_wacom_device_get_name (device); g_hash_table_insert (ht, (gpointer) tablet->name, tablet); } switch (gsd_wacom_device_get_device_type (device)) { case WACOM_TYPE_STYLUS: tablet->stylus = device; break; case WACOM_TYPE_ERASER: tablet->eraser = device; break; case WACOM_TYPE_PAD: tablet->pad = device; break; default: /* Nothing */ ; } } g_list_free (devices); /* We now have a list of Tablet structs, * see which ones are full tablets */ tablets = g_hash_table_get_values (ht); for (l = tablets; l; l = l->next) { Tablet *tablet; GtkWidget *page; tablet = l->data; if (tablet->stylus == NULL || tablet->eraser == NULL) { page = g_hash_table_lookup (priv->pages, tablet->name); if (page != NULL) { remove_page (GTK_NOTEBOOK (priv->notebook), page); g_hash_table_remove (priv->pages, tablet->name); changed = TRUE; } continue; } /* this code is called once the stylus + eraser were set up, but the pad does not exist yet */ page = g_hash_table_lookup (priv->pages, tablet->name); if (page == NULL) { page = cc_wacom_page_new (self, tablet->stylus, tablet->eraser, tablet->pad); cc_wacom_page_set_navigation (CC_WACOM_PAGE (page), GTK_NOTEBOOK (priv->notebook), TRUE); gtk_widget_show (page); gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page, NULL); g_hash_table_insert (priv->pages, g_strdup (tablet->name), page); changed = TRUE; } else { cc_wacom_page_update_tools (CC_WACOM_PAGE (page), tablet->stylus, tablet->eraser, tablet->pad); } } g_list_free (tablets); g_hash_table_destroy (ht); if (changed == TRUE) { int num_pages; num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook)); if (num_pages > 1) gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), WACOM_PAGE); } }
/* window procedure of the property sheet. */ static int PropSheetCtrlProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam) { PCONTROL ctrl; PPROPSHEETDATA propsheet; ctrl = gui_Control (hwnd); propsheet = (PROPSHEETDATA *) ctrl->dwAddData2; switch (message) { case MSG_CREATE: { #ifdef __TARGET_MSTUDIO__ SetWindowBkColor(hwnd, GetWindowElementPixel (hwnd, WE_MAINC_THREED_BODY)); #endif if (!(propsheet = calloc (1, sizeof (PROPSHEETDATA)))) { return -1; } ctrl->dwAddData2 = (DWORD)propsheet; break; } /* make the client size same as window size */ case MSG_SIZECHANGED: { const RECT* rcWin = (RECT *)wParam; RECT* rcClient = (RECT *)lParam; /* cale the width of content page */ *rcClient = *rcWin; propsheet->head_rc.right = RECTWP (rcClient); if ((ctrl->dwStyle & 0xf0L) == PSS_BOTTOM) { propsheet->head_rc.top = RECTHP (rcClient) - get_metrics (MWM_ICONY) - 2 - _ICON_OFFSET * 2; propsheet->head_rc.bottom = RECTHP (rcClient); } else { propsheet->head_rc.bottom = get_metrics (MWM_ICONY) + 2 + _ICON_OFFSET * 2; } if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); } else { HDC hdc; propsheet->head_width = propsheet->head_rc.right; if (propsheet->head) { PPROPPAGE page; hdc = GetClientDC(hwnd); page = propsheet->head; while(page) { page->width = tab_required_width (hdc, propsheet, page); page = page->next; } ReleaseDC (hdc); update_propsheet (propsheet); } } resize_children (propsheet, rcClient, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 1; } case MSG_DESTROY: { PPROPPAGE page, temp; page = propsheet->head; while (page) { temp = page->next; destroy_page (page); free (page); page = temp; } free (propsheet); break; } case MSG_GETDLGCODE: { return DLGC_WANTTAB | DLGC_WANTARROWS; } case PSM_SHEETCMD: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (SendMessage (page->hwnd, MSG_SHEETCMD, wParam, lParam)) /* when encounter an error, return page index plus 1. */ return index + 1; index++; page = page->next; } return 0; /* success */ } case PSM_SETACTIVEINDEX: { PPROPPAGE page; if ((page = get_page (propsheet, wParam)) && page != propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); propsheet->active = page; update_propsheet (propsheet); NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return PS_OKAY; } return PS_ERR; } case PSM_GETACTIVEINDEX: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (page == propsheet->active) { return index; } index ++; page = page->next; } return PS_ERR; } case PSM_GETACTIVEPAGE: { return (propsheet->active) ? propsheet->active->hwnd : HWND_INVALID; } case PSM_GETPAGE: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (index == wParam) { return page->hwnd; } index ++; page = page->next; } return HWND_INVALID; } case PSM_GETPAGEINDEX: { int index = 0; PPROPPAGE page = propsheet->head; while (page) { if (page->hwnd == wParam) { return index; } index ++; page = page->next; } return PS_ERR; } case PSM_GETPAGECOUNT: { return propsheet->page_count; } case PSM_GETTITLELENGTH: { int len = PS_ERR; PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { len = strlen (page->title); } return len; } case PSM_GETTITLE: { char* buffer = (char*)lParam; PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { strcpy (buffer, page->title); return PS_OKAY; } return PS_ERR; } case PSM_SETTITLE: { BOOL rc = PS_ERR; char* buffer = (char*)lParam; PPROPPAGE page; HDC hdc; if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { if ((page = get_page (propsheet, wParam))) { rc = set_page_title (page, buffer); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); } } else { if ((page = get_page (propsheet, wParam))) { hdc = GetClientDC (hwnd); rc = set_page_title_normal_style (hdc, propsheet, page, buffer); ReleaseDC (hdc); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); } } return rc; } case PSM_ADDPAGE: { if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { int index; PPROPPAGE page; if ((propsheet->head_rc.right / (propsheet->page_count + 1)) < _MIN_TAB_WIDTH) { return PS_ERR; } if (!(page = calloc (1, sizeof (PROPPAGE)))) { return PS_ERR; } if (!create_page (hwnd, ctrl->dwStyle, propsheet, page, (DLGTEMPLATE *)wParam, (WNDPROC)lParam)) { free (page); return PS_ERR; } index = append_page (propsheet, page); if (propsheet->active) { show_hide_page (propsheet->active, SW_HIDE); } propsheet->active = page; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (page, SW_SHOW); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return index; } else { return add_new_page_normal_style (hwnd, ctrl, propsheet, (DLGTEMPLATE *)wParam, (WNDPROC)lParam); } } case PSM_REMOVEPAGE: { if ((ctrl->dwStyle & 0x0fL) != PSS_SCROLLABLE) { PPROPPAGE page; if ((page = get_page (propsheet, wParam))) { remove_page (propsheet, page); destroy_page (page); free (page); recalc_tab_widths (hwnd, propsheet, ctrl->dwStyle); } else { return PS_ERR; } if (propsheet->active == page) { propsheet->active = propsheet->head; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); if (propsheet->active) { show_hide_page (propsheet->active, SW_SHOW); } } InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return PS_OKAY; } else { return delete_page (hwnd, ctrl, propsheet, wParam); } } case MSG_LBUTTONDOWN: { click_tab_bar (hwnd, ctrl, propsheet, lParam); /* dump_propsheetdata (propsheet); */ break; } case MSG_KEYDOWN: { PPROPPAGE page, new_active = NULL; if (!(lParam & KS_CTRL) || (propsheet->head == NULL)) { break; } /* Key borad message for PSS_COMPACTTAB and PSS_SIMPLE */ switch (LOWORD (wParam)) { case SCANCODE_CURSORBLOCKDOWN: case SCANCODE_CURSORBLOCKRIGHT: if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { new_active = propsheet->active->next; if (new_active == NULL) new_active = propsheet->head; break; } else { scroll_tab_right (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } case SCANCODE_CURSORBLOCKUP: case SCANCODE_CURSORBLOCKLEFT: if ((ctrl->dwStyle & 0x0fL)!= PSS_SCROLLABLE) { page = propsheet->head; if (propsheet->head == propsheet->active) { while (page && page->next) { page = page->next; } } else { while (page) { if (page->next == propsheet->active) break; page = page->next; } } new_active = page; break; } else { scroll_tab_left (hwnd, ctrl, propsheet); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } } /* switch */ if (new_active == NULL) { break; } show_hide_page (propsheet->active, SW_HIDE); propsheet->active = new_active; NotifyParent (hwnd, ctrl->id, PSN_ACTIVE_CHANGED); show_hide_page (new_active, SW_SHOW); InvalidateRect (hwnd, &propsheet->head_rc, TRUE); return 0; } case MSG_NCPAINT: case MSG_PAINT: { HDC hdc = BeginPaint (hwnd); PPROPPAGE page = ((ctrl->dwStyle & 0x0fL) == PSS_SCROLLABLE) ? propsheet->first_display_page : propsheet->head; draw_propsheet (hwnd, hdc, ctrl, propsheet, page); EndPaint (hwnd, hdc); return 0; } default: break; } return DefaultControlProc (hwnd, message, wParam, lParam); }