Changes in / [9e7e1dc:0b44848] in mainline
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
common/adt/bitmap.c
r9e7e1dc r0b44848 27 27 */ 28 28 29 /** @addtogroup kernel_generic_adt29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 43 43 #include <assert.h> 44 44 #include <macros.h> 45 #include <typedefs.h>46 45 47 46 #define ALL_ONES 0xff -
common/include/adt/bitmap.h
r9e7e1dc r0b44848 27 27 */ 28 28 29 /** @addtogroup kernel_generic_adt29 /** @addtogroup libc 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #ifndef KERN_BITMAP_H_36 #define KERN_BITMAP_H_35 #ifndef _LIBC_BITMAP_H_ 36 #define _LIBC_BITMAP_H_ 37 37 38 38 #include <stddef.h> -
uspace/app/tester/meson.build
r9e7e1dc r0b44848 1 1 # 2 # Copyright (c) 202 3Jiri Svoboda2 # Copyright (c) 2025 Jiri Svoboda 3 3 # Copyright (c) 2005 Martin Decky 4 4 # Copyright (c) 2007 Jakub Jermar … … 33 33 'tester.c', 34 34 'util.c', 35 'thread/deadlock.c', 35 36 'thread/thread1.c', 36 37 'thread/setjmp1.c', -
uspace/app/tester/tester.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2006 Ondrej Palkovsky 3 4 * Copyright (c) 2007 Martin Decky … … 49 50 50 51 test_t tests[] = { 52 #include "thread/deadlock.def" 51 53 #include "thread/thread1.def" 52 54 #include "thread/setjmp1.def" -
uspace/app/tester/tester.h
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2007 Martin Decky 3 4 * All rights reserved. … … 79 80 } test_t; 80 81 82 extern const char *test_deadlock(void); 81 83 extern const char *test_thread1(void); 82 84 extern const char *test_setjmp1(void); -
uspace/app/uidemo/uidemo.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 108 108 static void uidemo_file_load(ui_menu_entry_t *, void *); 109 109 static void uidemo_file_message(ui_menu_entry_t *, void *); 110 static void uidemo_file_confirmation(ui_menu_entry_t *, void *); 110 111 static void uidemo_file_exit(ui_menu_entry_t *, void *); 111 112 static void uidemo_edit_modify(ui_menu_entry_t *, void *); … … 340 341 } 341 342 342 /** Display a message window .343 /** Display a message window with OK button. 343 344 * 344 345 * @param demo UI demo … … 405 406 mdparams.caption = "Message For You"; 406 407 mdparams.text = "Hello, world!"; 408 409 rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog); 410 if (rc != EOK) { 411 printf("Error creating message dialog.\n"); 412 return; 413 } 414 415 ui_msg_dialog_set_cb(dialog, &msg_dialog_cb, &demo); 416 } 417 418 /** File / Confirmation menu entry selected. 419 * 420 * @param mentry Menu entry 421 * @param arg Argument (demo) 422 */ 423 static void uidemo_file_confirmation(ui_menu_entry_t *mentry, void *arg) 424 { 425 ui_demo_t *demo = (ui_demo_t *) arg; 426 ui_msg_dialog_params_t mdparams; 427 ui_msg_dialog_t *dialog; 428 errno_t rc; 429 430 ui_msg_dialog_params_init(&mdparams); 431 mdparams.caption = "Confirmation"; 432 mdparams.text = "This will not actually do anything. Proceed?"; 433 mdparams.choice = umdc_ok_cancel; 407 434 408 435 rc = ui_msg_dialog_create(demo->ui, &mdparams, &dialog); … … 782 809 ui_menu_entry_set_cb(mmsg, uidemo_file_message, (void *) &demo); 783 810 811 rc = ui_menu_entry_create(demo.mfile, "~C~onfirmation", "", &mmsg); 812 if (rc != EOK) { 813 printf("Error creating menu.\n"); 814 return rc; 815 } 816 817 ui_menu_entry_set_cb(mmsg, uidemo_file_confirmation, (void *) &demo); 818 784 819 rc = ui_menu_entry_create(demo.mfile, "~L~oad", "", &mload); 785 820 if (rc != EOK) { -
uspace/lib/c/generic/thread/fibril_synch.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 2025 Jiri Svoboda 2 3 * Copyright (c) 2009 Jakub Jermar 3 4 * All rights reserved. … … 112 113 #define AWAITER_INIT { .fid = fibril_get_id() } 113 114 114 static void print_deadlock(fibril_owner_info_t *oi) 115 /** Print deadlock message nad blocking chain. 116 * 117 * @param oi Owner info for the resource being acquired 118 * @param f Fibril that is trying to acquire the resource 119 */ 120 static void print_deadlock(fibril_owner_info_t *oi, fibril_t *f) 115 121 { 116 122 // FIXME: Print to stderr. 117 118 fibril_t *f = (fibril_t *) fibril_get_id();119 123 120 124 if (deadlocked) { … … 143 147 } 144 148 145 static void check_fibril_for_deadlock(fibril_owner_info_t *oi, fibril_t *fib) 146 { 149 /** Check whether fibril trying to acquire a resource will cause deadlock. 150 * 151 * @param wanted_oi Owner info for the primitive that the fibril wants 152 * @param fib Fibril that wants to aquire the primitive 153 */ 154 static void check_fibril_for_deadlock(fibril_owner_info_t *wanted_oi, 155 fibril_t *fib) 156 { 157 fibril_owner_info_t *oi; 158 147 159 futex_assert_is_locked(&fibril_synch_futex); 148 160 161 oi = wanted_oi; 149 162 while (oi && oi->owned_by) { 150 163 if (oi->owned_by == fib) { 151 164 futex_unlock(&fibril_synch_futex); 152 print_deadlock( oi);165 print_deadlock(wanted_oi, fib); 153 166 abort(); 154 167 } … … 157 170 } 158 171 172 /** Check whether trying to acquire a resource will cause deadlock. 173 * 174 * @param oi Owner info for the primitive that the current fibril wants 175 */ 159 176 static void check_for_deadlock(fibril_owner_info_t *oi) 160 177 { -
uspace/lib/c/meson.build
r9e7e1dc r0b44848 59 59 60 60 src += files( 61 'common/adt/bitmap.c', 61 62 'common/adt/checksum.c', 62 63 'common/adt/circ_buf.c', -
uspace/lib/display/include/display.h
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 48 48 extern errno_t display_open(const char *, display_t **); 49 49 extern void display_close(display_t *); 50 extern void display_lock(display_t *); 51 extern void display_unlock(display_t *); 50 52 extern errno_t display_get_info(display_t *, display_info_t *); 51 53 -
uspace/lib/display/src/display.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 138 138 } 139 139 140 /* 141 * Lock display. 142 * 143 * While display is locked, display event handlers will not be called. 144 * 145 * @param display Display 146 */ 147 void display_lock(display_t *display) 148 { 149 fibril_mutex_lock(&display->lock); 150 } 151 152 /* 153 * Unlock display. 154 * 155 * @param display Display 156 */ 157 void display_unlock(display_t *display) 158 { 159 fibril_mutex_unlock(&display->lock); 160 } 161 140 162 /** Initialize window parameters structure. 141 163 * … … 700 722 display_wnd_ev_t event; 701 723 724 display_lock(display); 725 702 726 while (true) { 703 fibril_mutex_lock(&display->lock);704 705 727 if (display->sess != NULL) 706 728 rc = display_get_event(display, &window, &event); 707 729 else 708 730 rc = ENOENT; 709 710 fibril_mutex_unlock(&display->lock);711 731 712 732 if (rc != EOK) … … 752 772 } 753 773 774 display_unlock(display); 754 775 async_answer_0(icall, EOK); 755 776 } -
uspace/lib/ui/include/types/ui/msgdialog.h
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 45 45 typedef struct ui_msg_dialog ui_msg_dialog_t; 46 46 47 enum { 48 /** Maximum number of buttons in message dialog. */ 49 ui_msg_dialog_maxbtn = 2 50 }; 51 52 /** Which choices the user can select from. */ 53 typedef enum { 54 /** OK (the default) */ 55 umdc_ok, 56 /** OK, Cancel */ 57 umdc_ok_cancel 58 } ui_msg_dialog_choice_t; 59 47 60 /** Message dialog parameters */ 48 61 typedef struct { … … 51 64 /** Message text */ 52 65 const char *text; 66 /** The choice that the user is given */ 67 ui_msg_dialog_choice_t choice; 53 68 } ui_msg_dialog_params_t; 54 69 -
uspace/lib/ui/private/msgdialog.h
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #define _UI_PRIVATE_MSGDIALOG_H 39 39 40 #include <types/ui/msgdialog.h> 41 #include <ui/pbutton.h> 42 #include <ui/window.h> 43 40 44 /** Actual structure of message dialog. 41 45 * … … 45 49 /** Dialog window */ 46 50 struct ui_window *window; 47 /** OK button*/48 struct ui_pbutton *b ok;51 /** Buttons */ 52 struct ui_pbutton *btn[ui_msg_dialog_maxbtn]; 49 53 /** Message dialog callbacks */ 50 54 struct ui_msg_dialog_cb *cb; -
uspace/lib/ui/src/filedialog.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 396 396 * 397 397 * @param window Window 398 * @param arg Argument (ui_ prompt_dialog_t *)398 * @param arg Argument (ui_file_dialog_t *) 399 399 * @param event Keyboard event 400 400 */ … … 427 427 } 428 428 } 429 430 429 } 431 430 -
uspace/lib/ui/src/msgdialog.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 47 47 48 48 static void ui_msg_dialog_wnd_close(ui_window_t *, void *); 49 static void ui_msg_dialog_wnd_kbd(ui_window_t *, void *, kbd_event_t *); 49 50 50 51 ui_window_cb_t ui_msg_dialog_wnd_cb = { 51 .close = ui_msg_dialog_wnd_close 52 .close = ui_msg_dialog_wnd_close, 53 .kbd = ui_msg_dialog_wnd_kbd 52 54 }; 53 55 … … 56 58 ui_pbutton_cb_t ui_msg_dialog_btn_cb = { 57 59 .clicked = ui_msg_dialog_btn_clicked 60 }; 61 62 static const char *ui_msg_dialog_captions[][ui_msg_dialog_maxbtn + 1] = { 63 [umdc_ok] = { "OK", NULL }, 64 [umdc_ok_cancel] = { "OK", "Cancel", NULL } 58 65 }; 59 66 … … 86 93 ui_fixed_t *fixed = NULL; 87 94 ui_label_t *label = NULL; 88 ui_pbutton_t *bok = NULL; 95 ui_pbutton_t *btn[ui_msg_dialog_maxbtn]; 96 const char **cp; 97 unsigned i, nb; 89 98 gfx_rect_t rect; 99 gfx_coord_t bw, bpad, btnsw, bp0x; 90 100 ui_resource_t *ui_res; 101 102 for (i = 0; i < ui_msg_dialog_maxbtn; i++) 103 btn[i] = NULL; 91 104 92 105 dialog = calloc(1, sizeof(ui_msg_dialog_t)); … … 103 116 wparams.rect.p0.x = 0; 104 117 wparams.rect.p0.y = 0; 105 wparams.rect.p1.x = 40;118 wparams.rect.p1.x = 60; 106 119 wparams.rect.p1.y = 7; 107 120 } else { 108 121 wparams.rect.p0.x = 0; 109 122 wparams.rect.p0.y = 0; 110 wparams.rect.p1.x = 200;123 wparams.rect.p1.x = 400; 111 124 wparams.rect.p1.y = 110; 112 125 } … … 132 145 rect.p0.x = 3; 133 146 rect.p0.y = 2; 134 rect.p1.x = 17;147 rect.p1.x = 57; 135 148 rect.p1.y = 3; 136 149 } else { 137 150 rect.p0.x = 10; 138 151 rect.p0.y = 35; 139 rect.p1.x = 190;152 rect.p1.x = 390; 140 153 rect.p1.y = 50; 141 154 } … … 150 163 label = NULL; 151 164 152 rc = ui_pbutton_create(ui_res, "OK", &bok); 153 if (rc != EOK) 154 goto error; 155 156 ui_pbutton_set_cb(bok, &ui_msg_dialog_btn_cb, dialog); 157 158 /* FIXME: Auto layout */ 165 i = 0; 166 assert(params->choice == umdc_ok || params->choice == umdc_ok_cancel); 167 cp = ui_msg_dialog_captions[params->choice]; 168 169 while (*cp != NULL) { 170 rc = ui_pbutton_create(ui_res, *cp, &btn[i]); 171 if (rc != EOK) 172 goto error; 173 174 ui_pbutton_set_cb(btn[i], &ui_msg_dialog_btn_cb, dialog); 175 ++cp; 176 ++i; 177 } 178 179 nb = i; 180 159 181 if (ui_is_textmode(ui)) { 160 rect.p0.x = 8; 161 rect.p0.y = 4; 162 rect.p1.x = 12; 163 rect.p1.y = 5; 182 bw = 12; 183 bpad = 2; 164 184 } else { 165 rect.p0.x = 55; 166 rect.p0.y = 60; 167 rect.p1.x = 145; 168 rect.p1.y = 88; 169 } 170 171 ui_pbutton_set_rect(bok, &rect); 172 173 ui_pbutton_set_default(bok, true); 174 175 rc = ui_fixed_add(fixed, ui_pbutton_ctl(bok)); 176 if (rc != EOK) 177 goto error; 178 179 dialog->bok = bok; 180 bok = NULL; 185 bw = 90; 186 bpad = 10; 187 } 188 189 btnsw = (nb - 1) * (bw + bpad) + bw; 190 bp0x = (wparams.rect.p0.x + wparams.rect.p1.x - btnsw) / 2; 191 192 for (i = 0; i < nb; i++) { 193 /* FIXME: Auto layout */ 194 if (ui_is_textmode(ui)) { 195 rect.p0.x = bp0x + i * (bw + bpad); 196 rect.p0.y = 4; 197 rect.p1.x = bp0x + bw + i * (bw + bpad); 198 rect.p1.y = 5; 199 } else { 200 rect.p0.x = bp0x + i * (bw + bpad); 201 rect.p0.y = 60; 202 rect.p1.x = bp0x + bw + i * (bw + bpad); 203 rect.p1.y = 88; 204 } 205 206 ui_pbutton_set_rect(btn[i], &rect); 207 208 rc = ui_fixed_add(fixed, ui_pbutton_ctl(btn[i])); 209 if (rc != EOK) 210 goto error; 211 } 212 213 ui_pbutton_set_default(btn[0], true); 214 215 for (i = 0; i < ui_msg_dialog_maxbtn; i++) { 216 dialog->btn[i] = btn[i]; 217 btn[i] = NULL; 218 } 181 219 182 220 ui_window_add(window, ui_fixed_ctl(fixed)); … … 191 229 return EOK; 192 230 error: 193 if (bok != NULL) 194 ui_pbutton_destroy(bok); 231 for (i = 0; i < ui_msg_dialog_maxbtn; i++) { 232 if (btn[i] != NULL) 233 ui_pbutton_destroy(btn[i]); 234 } 195 235 if (label != NULL) 196 236 ui_label_destroy(label); … … 243 283 } 244 284 285 /** Message dialog window keyboard event handler. 286 * 287 * @param window Window 288 * @param arg Argument (ui_msg_dialog_t *) 289 * @param event Keyboard event 290 */ 291 static void ui_msg_dialog_wnd_kbd(ui_window_t *window, void *arg, 292 kbd_event_t *event) 293 { 294 ui_msg_dialog_t *dialog = (ui_msg_dialog_t *) arg; 295 ui_evclaim_t claim; 296 297 claim = ui_window_def_kbd(window, event); 298 if (claim == ui_claimed) 299 return; 300 301 if (event->type == KEY_PRESS && 302 (event->mods & (KM_CTRL | KM_SHIFT | KM_ALT)) == 0) { 303 if (event->key == KC_ENTER) { 304 /* OK / default button */ 305 if (dialog->cb != NULL && dialog->cb->button != NULL) { 306 dialog->cb->button(dialog, dialog->arg, 0); 307 return; 308 } 309 } else if (event->key == KC_ESCAPE) { 310 /* Cancel */ 311 if (dialog->cb != NULL && dialog->cb->close != NULL) { 312 dialog->cb->close(dialog, dialog->arg); 313 return; 314 } 315 } 316 } 317 318 } 319 245 320 /** Message dialog button click handler. 246 321 * … … 251 326 { 252 327 ui_msg_dialog_t *dialog = (ui_msg_dialog_t *) arg; 253 254 if (dialog->cb != NULL && dialog->cb->button != NULL) 255 dialog->cb->button(dialog, dialog->arg, 0); 328 unsigned i; 329 330 if (dialog->cb != NULL && dialog->cb->button != NULL) { 331 for (i = 0; i < ui_msg_dialog_maxbtn; i++) { 332 if (dialog->btn[i] == pbutton) 333 dialog->cb->button(dialog, dialog->arg, i); 334 } 335 } 256 336 } 257 337 -
uspace/lib/ui/src/ui.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 3Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 568 568 void ui_lock(ui_t *ui) 569 569 { 570 if (ui->display != NULL) 571 display_lock(ui->display); 570 572 fibril_mutex_lock(&ui->lock); 571 573 } … … 582 584 { 583 585 fibril_mutex_unlock(&ui->lock); 586 if (ui->display != NULL) 587 display_unlock(ui->display); 584 588 } 585 589 -
uspace/lib/ui/src/window.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 978 978 ui_t *ui = window->ui; 979 979 980 ui_lock(ui);980 fibril_mutex_lock(&ui->lock); 981 981 ui_window_send_close(window); 982 ui_unlock(ui);982 fibril_mutex_unlock(&ui->lock); 983 983 } 984 984 … … 989 989 ui_t *ui = window->ui; 990 990 991 ui_lock(ui);991 fibril_mutex_lock(&ui->lock); 992 992 (void)nfocus; 993 993 … … 998 998 999 999 ui_window_send_focus(window, nfocus); 1000 ui_unlock(ui);1000 fibril_mutex_unlock(&ui->lock); 1001 1001 } 1002 1002 … … 1007 1007 ui_t *ui = window->ui; 1008 1008 1009 ui_lock(ui);1009 fibril_mutex_lock(&ui->lock); 1010 1010 ui_window_send_kbd(window, kbd_event); 1011 ui_unlock(ui);1011 fibril_mutex_unlock(&ui->lock); 1012 1012 } 1013 1013 … … 1023 1023 return; 1024 1024 1025 ui_lock(ui);1025 fibril_mutex_lock(&ui->lock); 1026 1026 1027 1027 claim = ui_wdecor_pos_event(window->wdecor, event); 1028 1028 if (claim == ui_claimed) { 1029 ui_unlock(ui);1029 fibril_mutex_unlock(&ui->lock); 1030 1030 return; 1031 1031 } 1032 1032 1033 1033 ui_window_send_pos(window, event); 1034 ui_unlock(ui);1034 fibril_mutex_unlock(&ui->lock); 1035 1035 } 1036 1036 … … 1048 1048 return; 1049 1049 1050 ui_lock(ui);1050 fibril_mutex_lock(&ui->lock); 1051 1051 (void) ui_window_resize(window, rect); 1052 1052 ui_window_send_resize(window); 1053 ui_unlock(ui);1053 fibril_mutex_unlock(&ui->lock); 1054 1054 } 1055 1055 … … 1060 1060 ui_t *ui = window->ui; 1061 1061 1062 ui_lock(ui);1062 fibril_mutex_lock(&ui->lock); 1063 1063 1064 1064 if (window->wdecor != NULL && nfocus == 0) { … … 1068 1068 1069 1069 ui_window_send_unfocus(window, nfocus); 1070 ui_unlock(ui);1070 fibril_mutex_unlock(&ui->lock); 1071 1071 } 1072 1072 -
uspace/lib/ui/test/msgdialog.c
r9e7e1dc r0b44848 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 92 92 ui_msg_dialog_params_t params; 93 93 ui_msg_dialog_t *dialog = NULL; 94 unsigned i; 94 95 test_cb_resp_t resp; 95 96 … … 100 101 params.caption = "Message"; 101 102 params.text = "Hello"; 103 params.choice = umdc_ok_cancel; 102 104 103 105 rc = ui_msg_dialog_create(ui, ¶ms, &dialog); … … 106 108 107 109 /* Button callback with no callbacks set */ 108 ui_pbutton_clicked(dialog->b ok);110 ui_pbutton_clicked(dialog->btn[0]); 109 111 110 112 /* Button callback with callback not implemented */ 111 113 ui_msg_dialog_set_cb(dialog, &dummy_msg_dialog_cb, NULL); 112 ui_pbutton_clicked(dialog->b ok);114 ui_pbutton_clicked(dialog->btn[0]); 113 115 114 /* Button callback with real callback set */ 115 resp.button = false; 116 resp.bnum = 123; 117 ui_msg_dialog_set_cb(dialog, &test_msg_dialog_cb, &resp); 118 ui_pbutton_clicked(dialog->bok); 119 PCUT_ASSERT_TRUE(resp.button); 120 PCUT_ASSERT_INT_EQUALS(0, resp.bnum); 116 for (i = 0; i < 2; i++) { 117 /* Button callback with real callback set */ 118 resp.button = false; 119 resp.bnum = 123; 120 ui_msg_dialog_set_cb(dialog, &test_msg_dialog_cb, &resp); 121 ui_pbutton_clicked(dialog->btn[i]); 122 PCUT_ASSERT_TRUE(resp.button); 123 PCUT_ASSERT_INT_EQUALS(i, resp.bnum); 124 } 121 125 122 126 ui_msg_dialog_destroy(dialog);
Note:
See TracChangeset
for help on using the changeset viewer.