Changeset 3a0a4d8 in mainline for uspace/lib/c/generic
- Timestamp:
- 2013-09-12T07:54:05Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 95027b5
- Parents:
- 47f5a77 (diff), 64f3d3b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/c/generic
- Files:
-
- 2 added
- 14 edited
-
adt/hash_table.c (modified) (2 diffs)
-
adt/list.c (modified) (1 diff)
-
async.c (modified) (2 diffs)
-
cfg.c (modified) (3 diffs)
-
corecfg.c (added)
-
ddi.c (modified) (4 diffs)
-
device/hw_res.c (modified) (3 diffs)
-
device/hw_res_parsed.c (modified) (6 diffs)
-
device/pio_window.c (added)
-
devman.c (modified) (8 diffs)
-
dnsr.c (modified) (2 diffs)
-
futex.c (modified) (4 diffs)
-
inet/addr.c (modified) (2 diffs)
-
pio_trace.c (modified) (2 diffs)
-
time.c (modified) (1 diff)
-
vfs/vfs.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/hash_table.c
r47f5a77 r3a0a4d8 227 227 228 228 /* Check for duplicates. */ 229 list_foreach(h->bucket[idx], cur) {229 list_foreach(h->bucket[idx], link, ht_link_t, cur_link) { 230 230 /* 231 231 * We could filter out items using their hashes first, but 232 232 * calling equal() might very well be just as fast. 233 233 */ 234 ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);235 234 if (h->op->equal(cur_link, item)) 236 235 return false; … … 258 257 size_t idx = h->op->key_hash(key) % h->bucket_cnt; 259 258 260 list_foreach(h->bucket[idx], cur) { 261 ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link); 259 list_foreach(h->bucket[idx], link, ht_link_t, cur_link) { 262 260 /* 263 261 * Is this is the item we are looking for? We could have first -
uspace/lib/c/generic/adt/list.c
r47f5a77 r3a0a4d8 102 102 unsigned int count = 0; 103 103 104 list_foreach(*list, link) { 104 link_t *link = list_first(list); 105 while (link != NULL) { 105 106 count++; 107 link = list_next(link, list); 106 108 } 107 109 -
uspace/lib/c/generic/async.c
r47f5a77 r3a0a4d8 2281 2281 bool async_data_read_receive(ipc_callid_t *callid, size_t *size) 2282 2282 { 2283 ipc_call_t data; 2284 return async_data_read_receive_call(callid, &data, size); 2285 } 2286 2287 /** Wrapper for receiving the IPC_M_DATA_READ calls using the async framework. 2288 * 2289 * This wrapper only makes it more comfortable to receive IPC_M_DATA_READ 2290 * calls so that the user doesn't have to remember the meaning of each IPC 2291 * argument. 2292 * 2293 * So far, this wrapper is to be used from within a connection fibril. 2294 * 2295 * @param callid Storage for the hash of the IPC_M_DATA_READ. 2296 * @param size Storage for the maximum size. Can be NULL. 2297 * 2298 * @return True on success, false on failure. 2299 * 2300 */ 2301 bool async_data_read_receive_call(ipc_callid_t *callid, ipc_call_t *data, 2302 size_t *size) 2303 { 2283 2304 assert(callid); 2284 2285 ipc_call_t data;2286 *callid = async_get_call( &data);2287 2288 if (IPC_GET_IMETHOD( data) != IPC_M_DATA_READ)2305 assert(data); 2306 2307 *callid = async_get_call(data); 2308 2309 if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_READ) 2289 2310 return false; 2290 2311 2291 2312 if (size) 2292 *size = (size_t) IPC_GET_ARG2( data);2313 *size = (size_t) IPC_GET_ARG2(*data); 2293 2314 2294 2315 return true; … … 2385 2406 bool async_data_write_receive(ipc_callid_t *callid, size_t *size) 2386 2407 { 2408 ipc_call_t data; 2409 return async_data_write_receive_call(callid, &data, size); 2410 } 2411 2412 /** Wrapper for receiving the IPC_M_DATA_WRITE calls using the async framework. 2413 * 2414 * This wrapper only makes it more comfortable to receive IPC_M_DATA_WRITE 2415 * calls so that the user doesn't have to remember the meaning of each IPC 2416 * argument. 2417 * 2418 * So far, this wrapper is to be used from within a connection fibril. 2419 * 2420 * @param callid Storage for the hash of the IPC_M_DATA_WRITE. 2421 * @param data Storage for the ipc call data. 2422 * @param size Storage for the suggested size. May be NULL. 2423 * 2424 * @return True on success, false on failure. 2425 * 2426 */ 2427 bool async_data_write_receive_call(ipc_callid_t *callid, ipc_call_t *data, 2428 size_t *size) 2429 { 2387 2430 assert(callid); 2388 2389 ipc_call_t data;2390 *callid = async_get_call( &data);2391 2392 if (IPC_GET_IMETHOD( data) != IPC_M_DATA_WRITE)2431 assert(data); 2432 2433 *callid = async_get_call(data); 2434 2435 if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_WRITE) 2393 2436 return false; 2394 2437 2395 2438 if (size) 2396 *size = (size_t) IPC_GET_ARG2( data);2439 *size = (size_t) IPC_GET_ARG2(*data); 2397 2440 2398 2441 return true; -
uspace/lib/c/generic/cfg.c
r47f5a77 r3a0a4d8 83 83 return true; 84 84 85 list_foreach(data->sections, link) { 86 const cfg_section_t *section = cfg_section_instance(link); 87 85 cfg_file_foreach(data, section) { 88 86 if (!list_empty(§ion->entries)) 89 87 return false; … … 413 411 const cfg_section_t *cfg_find_section(const cfg_file_t *data, const char *title) 414 412 { 415 list_foreach(data->sections, link) { 416 const cfg_section_t *section = cfg_section_instance(link); 417 413 cfg_file_foreach(data, section) { 418 414 if (str_cmp(section->title, title) == 0) 419 415 return section; … … 434 430 const char *cfg_find_value(const cfg_section_t *section, const char *key) 435 431 { 436 list_foreach(section->entries, link) { 437 const cfg_entry_t *entry = cfg_entry_instance(link); 438 432 cfg_section_foreach(section, entry) { 439 433 if (str_cmp(entry->key, key) == 0) 440 434 return entry->value; -
uspace/lib/c/generic/ddi.c
r47f5a77 r3a0a4d8 76 76 * 77 77 */ 78 int physmem_map( void *phys, size_t pages, unsigned int flags, void **virt)78 int physmem_map(uintptr_t phys, size_t pages, unsigned int flags, void **virt) 79 79 { 80 80 return __SYSCALL5(SYS_PHYSMEM_MAP, (sysarg_t) phys, … … 83 83 84 84 int dmamem_map(void *virt, size_t size, unsigned int map_flags, 85 unsigned int flags, void **phys)85 unsigned int flags, uintptr_t *phys) 86 86 { 87 87 return (int) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size, … … 90 90 } 91 91 92 int dmamem_map_anonymous(size_t size, unsigned int map_flags, 93 unsigned int flags, void **phys, void **virt) 94 { 92 int dmamem_map_anonymous(size_t size, uintptr_t constraint, 93 unsigned int map_flags, unsigned int flags, uintptr_t *phys, void **virt) 94 { 95 *phys = constraint; 96 95 97 return (int) __SYSCALL6(SYS_DMAMEM_MAP, (sysarg_t) size, 96 98 (sysarg_t) map_flags, (sysarg_t) flags | DMAMEM_FLAGS_ANONYMOUS, … … 158 160 if (!virt) 159 161 return EINVAL; 160 161 void *phys_frame =162 (void *)ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE);163 size_t offset = pio_addr - phys_frame;162 163 uintptr_t phys_frame = 164 ALIGN_DOWN((uintptr_t) pio_addr, PAGE_SIZE); 165 size_t offset = (uintptr_t) pio_addr - phys_frame; 164 166 size_t pages = SIZE2PAGES(offset + size); 165 167 -
uspace/lib/c/generic/device/hw_res.c
r47f5a77 r3a0a4d8 44 44 45 45 async_exch_t *exch = async_exchange_begin(sess); 46 46 47 int rc = async_req_1_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 47 48 HW_RES_GET_RESOURCE_LIST, &count); … … 77 78 { 78 79 async_exch_t *exch = async_exchange_begin(sess); 80 79 81 int rc = async_req_1_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 80 82 HW_RES_ENABLE_INTERRUPT); … … 84 86 } 85 87 88 /** Setup DMA channel to specified place and mode. 89 * 90 * @param channel DMA channel. 91 * @param pa Physical address of the buffer. 92 * @param size DMA buffer size. 93 * @param mode Mode of the DMA channel: 94 * - Read or Write 95 * - Allow automatic reset 96 * - Use address decrement instead of increment 97 * - Use SINGLE/BLOCK/ON DEMAND transfer mode 98 * 99 * @return Error code. 100 * 101 */ 102 int hw_res_dma_channel_setup(async_sess_t *sess, 103 unsigned channel, uint32_t pa, uint32_t size, uint8_t mode) 104 { 105 async_exch_t *exch = async_exchange_begin(sess); 106 107 const uint32_t packed = (channel & 0xffff) | (mode << 16); 108 const int ret = async_req_4_0(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 109 HW_RES_DMA_CHANNEL_SETUP, packed, pa, size); 110 111 async_exchange_end(exch); 112 113 return ret; 114 } 115 116 /** Query remaining bytes in the buffer. 117 * 118 * @param channel DMA channel. 119 * 120 * @return Number of bytes remaining in the buffer if positive. 121 * @return Error code if negative. 122 * 123 */ 124 int hw_res_dma_channel_remain(async_sess_t *sess, unsigned channel) 125 { 126 async_exch_t *exch = async_exchange_begin(sess); 127 128 sysarg_t remain; 129 const int ret = async_req_2_1(exch, DEV_IFACE_ID(HW_RES_DEV_IFACE), 130 HW_RES_DMA_CHANNEL_REMAIN, channel, &remain); 131 132 async_exchange_end(exch); 133 134 if (ret == EOK) 135 return remain; 136 137 return ret; 138 } 139 86 140 /** @} 87 141 */ -
uspace/lib/c/generic/device/hw_res_parsed.c
r47f5a77 r3a0a4d8 38 38 #include <errno.h> 39 39 40 static void hw_res_parse_add_irq(hw_res_list_parsed_t *out, hw_resource_t *res, 41 int flags) 40 static void hw_res_parse_add_dma_channel(hw_res_list_parsed_t *out, 41 const hw_resource_t *res, int flags) 42 { 43 assert(res); 44 assert((res->type == DMA_CHANNEL_8) || (res->type == DMA_CHANNEL_16)); 45 46 const unsigned channel = (res->type == DMA_CHANNEL_8) ? 47 res->res.dma_channel.dma8 : res->res.dma_channel.dma16; 48 const size_t count = out->dma_channels.count; 49 const int keep_duplicit = flags & HW_RES_KEEP_DUPLICIT; 50 51 if (!keep_duplicit) { 52 for (size_t i = 0; i < count; ++i) { 53 if (out->dma_channels.channels[i] == channel) 54 return; 55 } 56 } 57 58 out->dma_channels.channels[count] = channel; 59 ++out->dma_channels.count; 60 } 61 62 static void hw_res_parse_add_irq(hw_res_list_parsed_t *out, 63 const hw_resource_t *res, int flags) 42 64 { 43 65 assert(res && (res->type == INTERRUPT)); … … 59 81 60 82 static void hw_res_parse_add_io_range(hw_res_list_parsed_t *out, 61 hw_resource_t *res, int flags)83 const hw_resource_t *res, int flags) 62 84 { 63 85 assert(res && (res->type == IO_RANGE)); … … 90 112 91 113 static void hw_res_parse_add_mem_range(hw_res_list_parsed_t *out, 92 hw_resource_t *res, int flags)114 const hw_resource_t *res, int flags) 93 115 { 94 116 assert(res && (res->type == MEM_RANGE)); … … 132 154 * 133 155 */ 134 int hw_res_list_parse( hw_resource_list_t *hw_resources,156 int hw_res_list_parse(const hw_resource_list_t *hw_resources, 135 157 hw_res_list_parsed_t *out, int flags) 136 158 { … … 141 163 hw_res_list_parsed_clean(out); 142 164 143 out->irqs.irqs = malloc(res_count * sizeof(int)); 144 out->io_ranges.ranges = malloc(res_count * sizeof(io_range_t)); 145 out->mem_ranges.ranges = malloc(res_count * sizeof(mem_range_t)); 165 out->irqs.irqs = calloc(res_count, sizeof(int)); 166 out->dma_channels.channels = calloc(res_count, sizeof(int)); 167 out->io_ranges.ranges = calloc(res_count, sizeof(io_range_t)); 168 out->mem_ranges.ranges = calloc(res_count, sizeof(mem_range_t)); 169 if (!out->irqs.irqs || !out->dma_channels.channels || 170 !out->io_ranges.ranges || !out->mem_ranges.ranges) { 171 hw_res_list_parsed_clean(out); 172 return ENOMEM; 173 } 146 174 147 175 for (size_t i = 0; i < res_count; ++i) { 148 hw_resource_t *resource = &(hw_resources->resources[i]);176 const hw_resource_t *resource = &(hw_resources->resources[i]); 149 177 150 178 switch (resource->type) { … … 158 186 hw_res_parse_add_mem_range(out, resource, flags); 159 187 break; 188 case DMA_CHANNEL_8: 189 case DMA_CHANNEL_16: 190 hw_res_parse_add_dma_channel(out, resource, flags); 191 break; 160 192 default: 193 hw_res_list_parsed_clean(out); 161 194 return EINVAL; 162 195 } -
uspace/lib/c/generic/devman.c
r47f5a77 r3a0a4d8 1 1 /* 2 2 * Copyright (c) 2007 Josef Cejka 3 * Copyright (c) 201 1Jiri Svoboda3 * Copyright (c) 2013 Jiri Svoboda 4 4 * Copyright (c) 2010 Lenka Trochtova 5 5 * All rights reserved. … … 230 230 } 231 231 232 match_id_t *match_id = NULL; 233 234 list_foreach(match_ids->ids, link) { 235 match_id = list_get_instance(link, match_id_t, link); 236 232 list_foreach(match_ids->ids, link, match_id_t, match_id) { 237 233 ipc_call_t answer2; 238 234 aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID, … … 405 401 } 406 402 407 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf,408 s ize_t buf_size)403 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, 404 sysarg_t arg2, sysarg_t *r1, char *buf, size_t buf_size) 409 405 { 410 406 async_exch_t *exch; … … 416 412 417 413 ipc_call_t answer; 418 aid_t req = async_send_ 1(exch, method, arg1, &answer);414 aid_t req = async_send_2(exch, method, arg1, arg2, &answer); 419 415 aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply); 420 416 async_wait_for(dreq, &dretval); … … 434 430 } 435 431 432 if (r1 != NULL) 433 *r1 = IPC_GET_ARG1(answer); 436 434 act_size = IPC_GET_ARG2(dreply); 437 435 assert(act_size <= buf_size - 1); … … 443 441 int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size) 444 442 { 445 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf, 446 buf_size); 443 return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, 0, NULL, 444 buf, buf_size); 445 } 446 447 int devman_fun_get_match_id(devman_handle_t handle, size_t index, char *buf, 448 size_t buf_size, unsigned int *rscore) 449 { 450 int rc; 451 sysarg_t score = 0; 452 453 rc = devman_get_str_internal(DEVMAN_FUN_GET_MATCH_ID, handle, index, 454 &score, buf, buf_size); 455 if (rc != EOK) 456 return rc; 457 458 *rscore = score; 459 return rc; 447 460 } 448 461 449 462 int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size) 450 463 { 451 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf,452 buf _size);464 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, 0, NULL, 465 buf, buf_size); 453 466 } 454 467 455 468 int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size) 456 469 { 457 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf,458 buf_size);470 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, 0, 471 NULL, buf, buf_size); 459 472 } 460 473 … … 583 596 } 584 597 598 int devman_dev_get_parent(devman_handle_t devh, devman_handle_t *funh) 599 { 600 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 601 if (exch == NULL) 602 return ENOMEM; 603 604 sysarg_t retval = async_req_1_1(exch, DEVMAN_DEV_GET_PARENT, 605 devh, funh); 606 607 devman_exchange_end(exch); 608 return (int) retval; 609 } 610 585 611 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle) 586 612 { … … 596 622 } 597 623 624 int devman_get_drivers(devman_handle_t **drvs, 625 size_t *count) 626 { 627 return devman_get_handles_internal(DEVMAN_GET_DRIVERS, 0, drvs, count); 628 } 629 630 int devman_driver_get_devices(devman_handle_t drvh, devman_handle_t **devs, 631 size_t *count) 632 { 633 return devman_get_handles_internal(DEVMAN_DRIVER_GET_DEVICES, 634 drvh, devs, count); 635 } 636 637 int devman_driver_get_handle(const char *drvname, devman_handle_t *handle) 638 { 639 async_exch_t *exch; 640 641 exch = devman_exchange_begin(DEVMAN_CLIENT); 642 if (exch == NULL) 643 return ENOMEM; 644 645 ipc_call_t answer; 646 aid_t req = async_send_0(exch, DEVMAN_DRIVER_GET_HANDLE, &answer); 647 sysarg_t retval = async_data_write_start(exch, drvname, 648 str_size(drvname)); 649 650 devman_exchange_end(exch); 651 652 if (retval != EOK) { 653 async_forget(req); 654 return retval; 655 } 656 657 async_wait_for(req, &retval); 658 659 if (retval != EOK) { 660 if (handle != NULL) 661 *handle = (devman_handle_t) -1; 662 663 return retval; 664 } 665 666 if (handle != NULL) 667 *handle = (devman_handle_t) IPC_GET_ARG1(answer); 668 669 return retval; 670 } 671 672 int devman_driver_get_match_id(devman_handle_t handle, size_t index, char *buf, 673 size_t buf_size, unsigned int *rscore) 674 { 675 int rc; 676 sysarg_t score = 0; 677 678 rc = devman_get_str_internal(DEVMAN_DRIVER_GET_MATCH_ID, handle, index, 679 &score, buf, buf_size); 680 if (rc != EOK) 681 return rc; 682 683 *rscore = score; 684 return rc; 685 } 686 687 int devman_driver_get_name(devman_handle_t handle, char *buf, size_t buf_size) 688 { 689 return devman_get_str_internal(DEVMAN_DRIVER_GET_NAME, handle, 0, NULL, 690 buf, buf_size); 691 } 692 693 int devman_driver_get_state(devman_handle_t drvh, driver_state_t *rstate) 694 { 695 sysarg_t state; 696 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 697 if (exch == NULL) 698 return ENOMEM; 699 700 int rc = async_req_1_1(exch, DEVMAN_DRIVER_GET_STATE, drvh, 701 &state); 702 703 devman_exchange_end(exch); 704 if (rc != EOK) 705 return rc; 706 707 *rstate = state; 708 return rc; 709 } 710 711 int devman_driver_load(devman_handle_t drvh) 712 { 713 async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT); 714 if (exch == NULL) 715 return ENOMEM; 716 717 int rc = async_req_1_0(exch, DEVMAN_DRIVER_LOAD, drvh); 718 719 devman_exchange_end(exch); 720 return rc; 721 } 722 598 723 /** @} 599 724 */ -
uspace/lib/c/generic/dnsr.c
r47f5a77 r3a0a4d8 67 67 } 68 68 69 int dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo )69 int dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo, uint16_t af) 70 70 { 71 71 dnsr_hostinfo_t *info = calloc(1, sizeof(dnsr_hostinfo_t)); … … 76 76 77 77 ipc_call_t answer; 78 aid_t req = async_send_0(exch, DNSR_NAME2HOST, &answer); 78 aid_t req = async_send_1(exch, DNSR_NAME2HOST, (sysarg_t) af, 79 &answer); 79 80 80 81 int rc = async_data_write_start(exch, name, str_size(name)); -
uspace/lib/c/generic/futex.c
r47f5a77 r3a0a4d8 35 35 #include <futex.h> 36 36 #include <atomic.h> 37 #include <libarch/barrier.h> 37 38 #include <libc.h> 38 39 #include <sys/types.h> … … 59 60 int futex_trydown(futex_t *futex) 60 61 { 61 return cas(futex, 1, 0); 62 int rc; 63 64 rc = cas(futex, 1, 0); 65 CS_ENTER_BARRIER(); 66 67 return rc; 62 68 } 63 69 … … 73 79 int futex_down(futex_t *futex) 74 80 { 75 if ((atomic_signed_t) atomic_predec(futex) < 0) 81 atomic_signed_t nv; 82 83 nv = (atomic_signed_t) atomic_predec(futex); 84 CS_ENTER_BARRIER(); 85 if (nv < 0) 76 86 return __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &futex->count); 77 87 … … 89 99 int futex_up(futex_t *futex) 90 100 { 101 CS_LEAVE_BARRIER(); 102 91 103 if ((atomic_signed_t) atomic_postinc(futex) < 0) 92 104 return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &futex->count); -
uspace/lib/c/generic/inet/addr.c
r47f5a77 r3a0a4d8 52 52 }; 53 53 54 static const addr48_t inet_addr48_solicited_node = { 55 0x33, 0x33, 0xff, 0, 0, 0 56 }; 57 54 58 static const inet_addr_t inet_addr_any_addr = { 55 59 .family = AF_INET, … … 72 76 } 73 77 78 int addr48_compare(const addr48_t a, const addr48_t b) 79 { 80 return memcmp(a, b, 6); 81 } 82 74 83 int addr128_compare(const addr128_t a, const addr128_t b) 75 84 { 76 85 return memcmp(a, b, 16); 86 } 87 88 /** Compute solicited node MAC multicast address from target IPv6 address 89 * 90 * @param ip Target IPv6 address 91 * @param mac Solicited MAC address to be assigned 92 * 93 */ 94 void addr48_solicited_node(const addr128_t ip, addr48_t mac) 95 { 96 memcpy(mac, inet_addr48_solicited_node, 3); 97 memcpy(mac + 3, ip + 13, 3); 77 98 } 78 99 -
uspace/lib/c/generic/pio_trace.c
r47f5a77 r3a0a4d8 95 95 pio_regions_t *regions = get_regions(); 96 96 fibril_rwlock_read_lock(®ions->guard); 97 list_foreach(regions->list, it) { 98 assert(it); 99 region_t *reg = region_instance(it); 100 assert(reg); 97 list_foreach(regions->list, link, region_t, reg) { 101 98 if ((r >= reg->base) && (r < reg->base + reg->size)) { 102 99 if (reg->log) … … 131 128 fibril_rwlock_write_lock(®ions->guard); 132 129 list_foreach_safe(regions->list, it, next) { 133 assert(it);134 130 region_t *reg = region_instance(it); 135 assert(reg);136 131 if (r >= reg->base && (r < reg->base + reg->size)) { 137 list_remove(®->link);138 region_destroy(reg);132 list_remove(®->link); 133 region_destroy(reg); 139 134 } 140 135 } -
uspace/lib/c/generic/time.c
r47f5a77 r3a0a4d8 556 556 557 557 void *addr; 558 rc = physmem_map( (void *) faddr, 1,559 AS_AREA_READ | AS_AREA_CACHEABLE,&addr);558 rc = physmem_map(faddr, 1, AS_AREA_READ | AS_AREA_CACHEABLE, 559 &addr); 560 560 if (rc != EOK) { 561 561 as_area_destroy(addr); -
uspace/lib/c/generic/vfs/vfs.c
r47f5a77 r3a0a4d8 43 43 #include <stdio.h> 44 44 #include <sys/stat.h> 45 #include <sys/statfs.h> 45 46 #include <sys/types.h> 46 47 #include <ipc/services.h> … … 892 893 } 893 894 895 int statfs(const char *path, struct statfs *statfs) 896 { 897 sysarg_t rc; 898 sysarg_t rc_orig; 899 aid_t req; 900 size_t pa_size; 901 902 char *pa = absolutize(path, &pa_size); 903 if (!pa) 904 return ENOMEM; 905 async_exch_t *exch = vfs_exchange_begin(); 906 907 req = async_send_0(exch, VFS_IN_STATFS, NULL); 908 rc = async_data_write_start(exch, pa, pa_size); 909 if (rc != EOK) { 910 vfs_exchange_end(exch); 911 free(pa); 912 async_wait_for(req, &rc_orig); 913 if (rc_orig == EOK) 914 return (int) rc; 915 else 916 return (int) rc_orig; 917 } 918 rc = async_data_read_start(exch, (void *) statfs, sizeof(struct statfs)); 919 if (rc != EOK) { 920 vfs_exchange_end(exch); 921 free(pa); 922 async_wait_for(req, &rc_orig); 923 if (rc_orig == EOK) 924 return (int) rc; 925 else 926 return (int) rc_orig; 927 } 928 vfs_exchange_end(exch); 929 free(pa); 930 async_wait_for(req, &rc); 931 return rc; 932 } 933 894 934 /** @} 895 935 */
Note:
See TracChangeset
for help on using the changeset viewer.
