Changeset 102f641 in mainline for uspace/lib/c
- Timestamp:
- 2019-09-02T19:01:50Z (6 years ago)
- Children:
- 25697163
- Parents:
- 241f1985
- Location:
- uspace/lib/c
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/dyn_array.c
r241f1985 r102f641 44 44 #include <stdlib.h> 45 45 46 47 48 49 46 static int dyn_array_realloc(dyn_array_t *da, size_t capacity) 50 47 { … … 74 71 _dyn_array_unshift(da, index, 1); 75 72 int rc = dyn_array_reserve(da, da->size); 76 73 assert(rc == EOK); 77 74 } 78 75 … … 96 93 _dyn_array_unshift(da, begin, end - begin); 97 94 int rc = dyn_array_reserve(da, da->size); 98 95 assert(rc == EOK); 99 96 } 100 97 … … 192 189 } 193 190 194 195 191 /** @} 196 192 */ -
uspace/lib/c/generic/async/client.c
r241f1985 r102f641 164 164 static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv); 165 165 166 167 166 /** Create session for existing phone 168 167 * 169 168 * @return session on success, NULL on error 170 169 */ 171 170 172 171 async_sess_t *create_session(cap_phone_handle_t phone, exch_mgmt_t mgmt, 173 172 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3) … … 181 180 session->arg2 = arg2; 182 181 session->arg3 = arg3; 183 182 184 183 fibril_mutex_initialize(&session->remote_state_mtx); 185 184 session->remote_state_data = NULL; 186 185 187 186 list_initialize(&session->exch_list); 188 187 fibril_mutex_initialize(&session->mutex); -
uspace/lib/c/generic/async/server.c
r241f1985 r102f641 226 226 void async_set_implicit_connection(async_port_handler_t conn) 227 227 { 228 assert(implicit_connection == NULL); 229 implicit_connection = conn; 230 } 231 228 assert(implicit_connection == NULL); 229 implicit_connection = conn; 230 } 232 231 233 232 static fibril_rmutex_t client_mutex; -
uspace/lib/c/generic/libc.c
r241f1985 r102f641 54 54 #include "private/taskman.h" 55 55 56 57 56 #ifdef CONFIG_RTLD 58 57 #include <rtld/rtld.h> … … 119 118 } 120 119 #endif 121 120 122 121 /* Setup async framework and taskman connection */ 123 122 __async_server_init(); -
uspace/lib/c/generic/loader.c
r241f1985 r102f641 68 68 if (ldr == NULL) 69 69 return NULL; 70 70 71 71 async_sess_t *sess = taskman_session_loader(); 72 72 if (sess == NULL) { -
uspace/lib/c/generic/private/async.h
r241f1985 r102f641 108 108 extern void async_reply_received(ipc_call_t *); 109 109 extern async_sess_t *create_session(cap_phone_handle_t, exch_mgmt_t, 110 110 sysarg_t, sysarg_t, sysarg_t); 111 111 extern cap_phone_handle_t async_session_phone(async_sess_t *); 112 112 -
uspace/lib/c/generic/task.c
r241f1985 r102f641 115 115 async_exch_t *exch = taskman_exchange_begin(); 116 116 if (exch == NULL) 117 117 return EIO; 118 118 119 119 wait->aid = async_send_3(exch, TASKMAN_WAIT, LOWER32(id), UPPER32(id), … … 388 388 if (wait->flags & TASK_WAIT_RETVAL && retval) 389 389 *retval = ipc_get_arg2(&wait->result); 390 391 390 } 392 391 … … 440 439 errno_t rc = async_req_2_0(exch, TASKMAN_RETVAL, val, wait_for_exit); 441 440 taskman_exchange_end(exch); 442 441 443 442 return rc; 444 443 } -
uspace/lib/c/generic/task_event.c
r241f1985 r102f641 63 63 while (true) { 64 64 ipc_call_t call; 65 65 66 66 if (!async_get_call(&call) || !ipc_get_imethod(&call)) { 67 67 /* Hangup, end of game */ … … 99 99 port_id_t port; 100 100 errno_t rc = async_create_callback_port(exch, INTERFACE_TASKMAN_CB, 0, 0, 101 101 taskman_event_conn, NULL, &port); 102 102 taskman_exchange_end(exch); 103 103 -
uspace/lib/c/generic/taskman.c
r241f1985 r102f641 32 32 /** @file 33 33 */ 34 35 34 36 35 #include <async.h> … … 86 85 aid_t req = async_send_0(exch, TASKMAN_NEW_TASK, NULL); 87 86 async_exchange_end(exch); 88 87 89 88 if (req) { 90 89 async_forget(req); … … 104 103 105 104 async_sess_t *sess = async_connect_me_to(exch, INTERFACE_NS, 106 105 TASKMAN_CONNECT_TO_NS, 0); 107 106 async_exchange_end(exch); 108 107 … … 170 169 } 171 170 172 173 174 171 /** @} 175 172 */ -
uspace/lib/c/generic/taskman_noasync.c
r241f1985 r102f641 44 44 #include <taskman_noasync.h> 45 45 46 47 48 49 46 /** Tell taskman we are his NS 50 47 * … … 67 64 } 68 65 69 70 66 void task_retval_noasync(errno_t retval) 71 67 { -
uspace/lib/c/include/adt/dyn_array.h
r241f1985 r102f641 60 60 _dyn_array_initialize((dyn_array), sizeof(type)) 61 61 62 63 62 /** Dynamic array accessor 64 63 * … … 68 67 (*((type *) (dyn_array)->_data + index)) 69 68 70 71 69 /** Access last element 72 70 * … … 75 73 #define dyn_array_last(dyn_array, type) \ 76 74 (*((type *) (dyn_array)->_data + ((dyn_array)->size - 1))) 77 78 75 79 76 /** Insert item at given position, shift rest of array … … 101 98 #define dyn_array_append(dyn_array, type, value) \ 102 99 dyn_array_insert(dyn_array, type, (dyn_array)->size, (value)) 103 104 100 105 101 /** Dynamic array iteration -
uspace/lib/c/include/ipc/common.h
r241f1985 r102f641 46 46 /** 47 47 * IPC_FLAG_AUTOSTART_ is for use in brokers only. In clinet code use 48 * IPC_AUTOSTART that includes implies blocking behavior. */ 48 * IPC_AUTOSTART that includes implies blocking behavior. 49 */ 49 50 #define IPC_FLAG_AUTOSTART_ 0x02 50 51 -
uspace/lib/c/include/ipc/services.h
r241f1985 r102f641 67 67 #define SERVICE_NAME_VOLSRV "volsrv" 68 68 69 70 69 #define LOC_DEVICE_NAMESPACE "devices" 71 70 #define LOC_UNIT_NAMESPACE_SEPARATOR "__" -
uspace/lib/c/include/ipc/taskman.h
r241f1985 r102f641 38 38 #include <ipc/common.h> 39 39 40 41 40 typedef enum { 42 41 TASKMAN_WAIT = IPC_FIRST_USER_METHOD, -
uspace/lib/c/include/loader/pcb.h
r241f1985 r102f641 63 63 /** Session to taskman (typically spawn parent) */ 64 64 async_sess_t *session_taskman; 65 65 66 66 /** Current working directory. */ 67 67 char *cwd; -
uspace/lib/c/include/taskman_noasync.h
r241f1985 r102f641 36 36 #define LIBC_TASKMAN_NOASYNC_H_ 37 37 38 39 38 /* Internal functions to be used by NS only */ 40 39 extern int taskman_intro_ns_noasync(void); -
uspace/lib/c/include/types/task.h
r241f1985 r102f641 51 51 } task_wait_t; 52 52 53 typedef void (* 53 typedef void (*task_event_handler_t)(task_id_t, int, task_exit_t, int); 54 54 55 55 #endif -
uspace/lib/c/test/dyn_array.c
r241f1985 r102f641 38 38 static dyn_array_t da; 39 39 40 PCUT_TEST_BEFORE { 40 PCUT_TEST_BEFORE 41 { 41 42 dyn_array_initialize(&da, data_t); 42 43 int rc = dyn_array_reserve(&da, 3); … … 44 45 } 45 46 46 PCUT_TEST_AFTER { 47 PCUT_TEST_AFTER 48 { 47 49 dyn_array_destroy(&da); 48 50 } 49 51 50 PCUT_TEST(initialization) { 52 PCUT_TEST(initialization) 53 { 51 54 PCUT_ASSERT_INT_EQUALS(da.capacity, 3); 52 55 PCUT_ASSERT_INT_EQUALS(da.size, 0); 53 56 } 54 57 55 PCUT_TEST(append) { 58 PCUT_TEST(append) 59 { 56 60 dyn_array_append(&da, data_t, 42); 57 61 dyn_array_append(&da, data_t, 666); … … 62 66 } 63 67 64 PCUT_TEST(assign) { 68 PCUT_TEST(assign) 69 { 65 70 dyn_array_append(&da, data_t, 42); 66 71 dyn_array_at(&da, data_t, 0) = 112; … … 69 74 } 70 75 71 PCUT_TEST(remove) { 76 PCUT_TEST(remove) 77 { 72 78 dyn_array_append(&da, data_t, 10); 73 79 dyn_array_append(&da, data_t, 11); … … 79 85 } 80 86 81 PCUT_TEST(insert) { 87 PCUT_TEST(insert) 88 { 82 89 dyn_array_append(&da, data_t, 10); 83 90 dyn_array_append(&da, data_t, 11); … … 92 99 } 93 100 94 PCUT_TEST(capacity_grow) { 101 PCUT_TEST(capacity_grow) 102 { 95 103 dyn_array_append(&da, data_t, 42); 96 104 dyn_array_append(&da, data_t, 666); … … 101 109 } 102 110 103 PCUT_TEST(capacity_shrink) { 111 PCUT_TEST(capacity_shrink) 112 { 104 113 dyn_array_append(&da, data_t, 42); 105 114 dyn_array_append(&da, data_t, 666); … … 113 122 } 114 123 115 PCUT_TEST(iterator) { 124 PCUT_TEST(iterator) 125 { 116 126 for (int i = 0; i < 10; ++i) { 117 dyn_array_append(&da, data_t, i *i);127 dyn_array_append(&da, data_t, i * i); 118 128 } 119 129 120 130 int i = 0; 121 131 dyn_array_foreach(da, data_t, it) { 122 PCUT_ASSERT_INT_EQUALS(i *i, *it);132 PCUT_ASSERT_INT_EQUALS(i * i, *it); 123 133 ++i; 124 134 } 125 135 } 126 136 127 PCUT_TEST(find) { 137 PCUT_TEST(find) 138 { 128 139 dyn_array_append(&da, data_t, 10); 129 140 dyn_array_append(&da, data_t, 11); … … 136 147 } 137 148 138 PCUT_TEST(clear_range_middle) { 149 PCUT_TEST(clear_range_middle) 150 { 139 151 dyn_array_append(&da, data_t, 10); 140 152 dyn_array_append(&da, data_t, 11); … … 148 160 } 149 161 150 PCUT_TEST(clear_range_begin) { 162 PCUT_TEST(clear_range_begin) 163 { 151 164 dyn_array_append(&da, data_t, 10); 152 165 dyn_array_append(&da, data_t, 11); … … 160 173 } 161 174 162 PCUT_TEST(clear_range_end) { 175 PCUT_TEST(clear_range_end) 176 { 163 177 dyn_array_append(&da, data_t, 10); 164 178 dyn_array_append(&da, data_t, 11); … … 172 186 } 173 187 174 PCUT_TEST(clear_range_empty) { 188 PCUT_TEST(clear_range_empty) 189 { 175 190 dyn_array_append(&da, data_t, 10); 176 191 dyn_array_append(&da, data_t, 99); … … 182 197 } 183 198 184 PCUT_TEST(concat_simple) { 199 PCUT_TEST(concat_simple) 200 { 185 201 dyn_array_append(&da, data_t, 10); 186 202 dyn_array_append(&da, data_t, 99); … … 202 218 dyn_array_destroy(&da2); 203 219 } 204 PCUT_TEST(concat_self) { 220 221 PCUT_TEST(concat_self) 222 { 205 223 dyn_array_append(&da, data_t, 10); 206 224 dyn_array_append(&da, data_t, 99);
Note:
See TracChangeset
for help on using the changeset viewer.