Changeset e6a78b9 in mainline for uspace/lib/c/generic
- Timestamp:
- 2012-06-29T15:31:44Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9432f08
- Parents:
- 34ab31c0 (diff), 0bbd13e (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:
-
- 18 edited
-
as.c (modified) (1 diff)
-
async.c (modified) (1 diff)
-
devman.c (modified) (2 diffs)
-
elf/elf_load.c (modified) (1 diff)
-
fibril.c (modified) (1 diff)
-
inet.c (modified) (4 diffs)
-
inetcfg.c (modified) (1 diff)
-
inetping.c (modified) (2 diffs)
-
iplink.c (modified) (1 diff)
-
loc.c (modified) (1 diff)
-
malloc.c (modified) (1 diff)
-
mman.c (modified) (1 diff)
-
net/socket_client.c (modified) (2 diffs)
-
stacktrace.c (modified) (1 diff)
-
stats.c (modified) (1 diff)
-
sysinfo.c (modified) (1 diff)
-
thread.c (modified) (3 diffs)
-
time.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/as.c
r34ab31c0 re6a78b9 46 46 * 47 47 * @param base Starting virtual address of the area. 48 * If set to (void *) -1, the kernel finds49 * a mappable area.48 * If set to AS_AREA_ANY ((void *) -1), 49 * the kernel finds a mappable area. 50 50 * @param size Size of the area. 51 51 * @param flags Flags describing type of the area. 52 52 * 53 53 * @return Starting virtual address of the created area on success. 54 * @return (void *) -1otherwise.54 * @return AS_MAP_FAILED ((void *) -1) otherwise. 55 55 * 56 56 */ -
uspace/lib/c/generic/async.c
r34ab31c0 re6a78b9 1388 1388 1389 1389 futex_down(&async_futex); 1390 if (msg->done) 1390 if (msg->done) { 1391 1391 amsg_destroy(msg); 1392 else 1392 } else { 1393 msg->dataptr = NULL; 1393 1394 msg->forget = true; 1395 } 1394 1396 futex_up(&async_futex); 1395 1397 } -
uspace/lib/c/generic/devman.c
r34ab31c0 re6a78b9 430 430 async_wait_for(req, &retval); 431 431 432 if (retval != EOK) 433 return retval; 432 if (retval != EOK) { 433 return retval; 434 } 434 435 435 436 act_size = IPC_GET_ARG2(dreply); … … 449 450 { 450 451 return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf, 452 buf_size); 453 } 454 455 int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size) 456 { 457 return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf, 451 458 buf_size); 452 459 } -
uspace/lib/c/generic/elf/elf_load.c
r34ab31c0 re6a78b9 366 366 a = as_area_create((uint8_t *) base + bias, mem_sz, 367 367 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); 368 if (a == (void *) -1) {368 if (a == AS_MAP_FAILED) { 369 369 DPRINTF("memory mapping failed (0x%x, %d)\n", 370 370 base + bias, mem_sz); -
uspace/lib/c/generic/fibril.c
r34ab31c0 re6a78b9 286 286 } 287 287 288 /** Delete a fibril that has never run. 289 * 290 * Free resources of a fibril that has been created with fibril_create() 291 * but never readied using fibril_add_ready(). 292 * 293 * @param fid Pointer to the fibril structure of the fibril to be 294 * added. 295 */ 296 void fibril_destroy(fid_t fid) 297 { 298 fibril_t *fibril = (fibril_t *) fid; 299 300 free(fibril->stack); 301 fibril_teardown(fibril); 302 } 303 288 304 /** Add a fibril to the ready list. 289 305 * -
uspace/lib/c/generic/inet.c
r34ab31c0 re6a78b9 44 44 { 45 45 async_exch_t *exch = async_exchange_begin(inet_sess); 46 46 47 47 ipc_call_t answer; 48 48 aid_t req = async_send_0(exch, INET_CALLBACK_CREATE, &answer); 49 49 int rc = async_connect_to_me(exch, 0, 0, 0, inet_cb_conn, NULL); 50 50 async_exchange_end(exch); 51 51 52 52 if (rc != EOK) 53 53 return rc; 54 54 55 55 sysarg_t retval; 56 56 async_wait_for(req, &retval); 57 if (retval != EOK) 58 return retval; 59 60 return EOK; 57 58 return retval; 61 59 } 62 60 63 61 static int inet_set_proto(uint8_t protocol) 64 62 { 65 int rc;66 67 63 async_exch_t *exch = async_exchange_begin(inet_sess); 68 rc = async_req_1_0(exch, INET_SET_PROTO, protocol);64 int rc = async_req_1_0(exch, INET_SET_PROTO, protocol); 69 65 async_exchange_end(exch); 70 66 71 67 return rc; 72 68 } … … 80 76 assert(inet_ev_ops == NULL); 81 77 assert(inet_protocol == 0); 82 78 83 79 rc = loc_service_get_id(SERVICE_NAME_INET, &inet_svc, 84 80 IPC_FLAG_BLOCKING); 85 81 if (rc != EOK) 86 82 return ENOENT; 87 83 88 84 inet_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc, 89 85 IPC_FLAG_BLOCKING); 90 86 if (inet_sess == NULL) 91 87 return ENOENT; 92 88 93 89 if (inet_set_proto(protocol) != EOK) { 94 90 async_hangup(inet_sess); … … 96 92 return EIO; 97 93 } 98 94 99 95 if (inet_callback_create() != EOK) { 100 96 async_hangup(inet_sess); … … 102 98 return EIO; 103 99 } 104 100 105 101 inet_protocol = protocol; 106 102 inet_ev_ops = ev_ops; -
uspace/lib/c/generic/inetcfg.c
r34ab31c0 re6a78b9 119 119 120 120 assert(inetcfg_sess == NULL); 121 121 122 122 rc = loc_service_get_id(SERVICE_NAME_INETCFG, &inet_svc, 123 123 IPC_FLAG_BLOCKING); 124 124 if (rc != EOK) 125 125 return ENOENT; 126 126 127 127 inetcfg_sess = loc_service_connect(EXCHANGE_SERIALIZE, inet_svc, 128 128 IPC_FLAG_BLOCKING); 129 129 if (inetcfg_sess == NULL) 130 130 return ENOENT; 131 131 132 132 return EOK; 133 133 } -
uspace/lib/c/generic/inetping.c
r34ab31c0 re6a78b9 49 49 50 50 assert(inetping_sess == NULL); 51 51 52 52 inetping_ev_ops = ev_ops; 53 53 54 54 rc = loc_service_get_id(SERVICE_NAME_INETPING, &inetping_svc, 55 55 IPC_FLAG_BLOCKING); 56 56 if (rc != EOK) 57 57 return ENOENT; 58 58 59 59 inetping_sess = loc_service_connect(EXCHANGE_SERIALIZE, inetping_svc, 60 60 IPC_FLAG_BLOCKING); 61 61 if (inetping_sess == NULL) 62 62 return ENOENT; 63 63 64 64 async_exch_t *exch = async_exchange_begin(inetping_sess); 65 65 66 66 rc = async_connect_to_me(exch, 0, 0, 0, inetping_cb_conn, NULL); 67 67 async_exchange_end(exch); 68 68 69 69 if (rc != EOK) { 70 70 async_hangup(inetping_sess); … … 72 72 return rc; 73 73 } 74 74 75 75 return EOK; 76 76 } -
uspace/lib/c/generic/iplink.c
r34ab31c0 re6a78b9 49 49 iplink_t **riplink) 50 50 { 51 iplink_t *iplink = NULL; 52 int rc; 53 54 iplink = calloc(1, sizeof(iplink_t)); 51 iplink_t *iplink = calloc(1, sizeof(iplink_t)); 55 52 if (iplink == NULL) 56 53 return ENOMEM; 57 54 58 55 iplink->sess = sess; 59 56 iplink->ev_ops = ev_ops; 60 57 61 58 async_exch_t *exch = async_exchange_begin(sess); 62 63 rc = async_connect_to_me(exch, 0, 0, 0, iplink_cb_conn, iplink);59 60 int rc = async_connect_to_me(exch, 0, 0, 0, iplink_cb_conn, iplink); 64 61 async_exchange_end(exch); 65 62 66 63 if (rc != EOK) 67 64 goto error; 68 65 69 66 *riplink = iplink; 70 67 return EOK; 71 68 72 69 error: 73 70 if (iplink != NULL) 74 71 free(iplink); 75 72 76 73 return rc; 77 74 } -
uspace/lib/c/generic/loc.c
r34ab31c0 re6a78b9 450 450 } 451 451 452 /** Get service server name. 453 * 454 * Provided ID of a service, return the name of its server. 455 * 456 * @param svc_id Service ID 457 * @param name Place to store pointer to new string. Caller should 458 * free it using free(). 459 * @return EOK on success or negative error code 460 */ 461 int loc_service_get_server_name(service_id_t svc_id, char **name) 462 { 463 return loc_get_name_internal(LOC_SERVICE_GET_SERVER_NAME, svc_id, name); 464 } 465 452 466 int loc_namespace_get_id(const char *name, service_id_t *handle, 453 467 unsigned int flags) -
uspace/lib/c/generic/malloc.c
r34ab31c0 re6a78b9 285 285 /* Align the heap area size on page boundary */ 286 286 size_t asize = ALIGN_UP(size, PAGE_SIZE); 287 void *astart = as_area_create( (void *) -1, asize,287 void *astart = as_area_create(AS_AREA_ANY, asize, 288 288 AS_AREA_WRITE | AS_AREA_READ); 289 if (astart == (void *) -1)289 if (astart == AS_MAP_FAILED) 290 290 return false; 291 291 -
uspace/lib/c/generic/mman.c
r34ab31c0 re6a78b9 42 42 { 43 43 if (!start) 44 start = (void *) -1;44 start = AS_AREA_ANY; 45 45 46 46 // if (!((flags & MAP_SHARED) ^ (flags & MAP_PRIVATE))) -
uspace/lib/c/generic/net/socket_client.c
r34ab31c0 re6a78b9 283 283 static async_sess_t *socket_get_tcp_sess(void) 284 284 { 285 if (socket_globals.tcp_sess == NULL) {285 if (socket_globals.tcp_sess == NULL) 286 286 socket_globals.tcp_sess = service_bind(SERVICE_TCP, 287 287 0, 0, SERVICE_TCP, socket_connection); 288 } 289 288 290 289 return socket_globals.tcp_sess; 291 290 } … … 300 299 static async_sess_t *socket_get_udp_sess(void) 301 300 { 302 if (socket_globals.udp_sess == NULL) {301 if (socket_globals.udp_sess == NULL) 303 302 socket_globals.udp_sess = service_bind(SERVICE_UDP, 304 303 0, 0, SERVICE_UDP, socket_connection); 305 } 306 304 307 305 return socket_globals.udp_sess; 308 306 } -
uspace/lib/c/generic/stacktrace.c
r34ab31c0 re6a78b9 38 38 #include <sys/types.h> 39 39 #include <errno.h> 40 #include <unistd.h> 40 41 41 42 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data); -
uspace/lib/c/generic/stats.c
r34ab31c0 re6a78b9 40 40 #include <inttypes.h> 41 41 #include <malloc.h> 42 #include <unistd.h> 42 43 43 44 #define SYSINFO_STATS_MAX_PATH 64 -
uspace/lib/c/generic/sysinfo.c
r34ab31c0 re6a78b9 39 39 #include <malloc.h> 40 40 #include <bool.h> 41 #include <unistd.h> 41 42 42 43 /** Get sysinfo keys size -
uspace/lib/c/generic/thread.c
r34ab31c0 re6a78b9 41 41 #include <str.h> 42 42 #include <async.h> 43 #include <errno.h> 44 #include <as.h> 43 45 #include "private/thread.h" 44 46 45 #ifndef THREAD_INITIAL_STACK_PAGES _NO46 #define THREAD_INITIAL_STACK_PAGES_NO 2 47 #ifndef THREAD_INITIAL_STACK_PAGES 48 #define THREAD_INITIAL_STACK_PAGES 2 47 49 #endif 48 50 … … 65 67 66 68 uarg->uspace_thread_function(uarg->uspace_thread_arg); 67 /* XXX: we cannot free the userspace stack while running on it 68 free(uarg->uspace_stack); 69 free(uarg); 70 */ 69 /* 70 * XXX: we cannot free the userspace stack while running on it 71 * 72 * free(uarg->uspace_stack); 73 * free(uarg); 74 */ 71 75 72 76 /* If there is a manager, destroy it */ … … 92 96 thread_id_t *tid) 93 97 { 94 char *stack; 95 uspace_arg_t *uarg; 96 int rc; 97 98 stack = (char *) malloc(getpagesize() * THREAD_INITIAL_STACK_PAGES_NO); 99 if (!stack) 100 return -1; 101 102 uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t)); 103 if (!uarg) { 104 free(stack); 105 return -1; 98 uspace_arg_t *uarg = 99 (uspace_arg_t *) malloc(sizeof(uspace_arg_t)); 100 if (!uarg) 101 return ENOMEM; 102 103 size_t stack_size = getpagesize() * THREAD_INITIAL_STACK_PAGES; 104 void *stack = as_area_create(AS_AREA_ANY, stack_size, 105 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); 106 if (stack == AS_MAP_FAILED) { 107 free(uarg); 108 return ENOMEM; 106 109 } 107 110 108 111 uarg->uspace_entry = (void *) FADDR(__thread_entry); 109 uarg->uspace_stack = (void *) stack; 112 uarg->uspace_stack = stack; 113 uarg->uspace_stack_size = stack_size; 110 114 uarg->uspace_thread_function = function; 111 115 uarg->uspace_thread_arg = arg; 112 116 uarg->uspace_uarg = uarg; 113 117 114 rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg, (sysarg_t) name,115 (sysarg_t) str_size(name), (sysarg_t) tid);118 int rc = __SYSCALL4(SYS_THREAD_CREATE, (sysarg_t) uarg, 119 (sysarg_t) name, (sysarg_t) str_size(name), (sysarg_t) tid); 116 120 117 if (rc ) {121 if (rc != EOK) { 118 122 /* 119 123 * Failed to create a new thread. 120 * Free up the allocated structures.124 * Free up the allocated data. 121 125 */ 126 as_area_destroy(stack); 122 127 free(uarg); 123 free(stack);124 128 } 125 129 126 130 return rc; 127 131 } -
uspace/lib/c/generic/time.c
r34ab31c0 re6a78b9 43 43 #include <ddi.h> 44 44 #include <libc.h> 45 #include <unistd.h> 45 46 46 47 /** Pointer to kernel shared variables with time */
Note:
See TracChangeset
for help on using the changeset viewer.
