Changeset ea28272 in mainline for uspace/lib/c/generic/net/modules.c
- Timestamp:
- 2010-12-30T13:43:27Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d770deb
- Parents:
- d70d80ed (diff), f418e51 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/net/modules.c
rd70d80ed rea28272 63 63 int answer_count) 64 64 { 65 / / choose the most efficient answer function65 /* Choose the most efficient answer function */ 66 66 if (answer || (!answer_count)) { 67 67 switch (answer_count) { 68 68 case 0: 69 ipc_answer_0(callid, ( ipcarg_t) result);69 ipc_answer_0(callid, (sysarg_t) result); 70 70 break; 71 71 case 1: 72 ipc_answer_1(callid, ( ipcarg_t) result,72 ipc_answer_1(callid, (sysarg_t) result, 73 73 IPC_GET_ARG1(*answer)); 74 74 break; 75 75 case 2: 76 ipc_answer_2(callid, ( ipcarg_t) result,76 ipc_answer_2(callid, (sysarg_t) result, 77 77 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer)); 78 78 break; 79 79 case 3: 80 ipc_answer_3(callid, ( ipcarg_t) result,80 ipc_answer_3(callid, (sysarg_t) result, 81 81 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 82 82 IPC_GET_ARG3(*answer)); 83 83 break; 84 84 case 4: 85 ipc_answer_4(callid, ( ipcarg_t) result,85 ipc_answer_4(callid, (sysarg_t) result, 86 86 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 87 87 IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer)); … … 89 89 case 5: 90 90 default: 91 ipc_answer_5(callid, ( ipcarg_t) result,91 ipc_answer_5(callid, (sysarg_t) result, 92 92 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 93 93 IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer), … … 111 111 * function. 112 112 */ 113 int bind_service(services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3,113 int bind_service(services_t need, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, 114 114 async_client_conn_t client_receiver) 115 115 { … … 134 134 * 135 135 */ 136 int bind_service_timeout(services_t need, ipcarg_t arg1, ipcarg_t arg2,137 ipcarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout)136 int bind_service_timeout(services_t need, sysarg_t arg1, sysarg_t arg2, 137 sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 138 138 { 139 139 int rc; … … 143 143 if (phone >= 0) { 144 144 /* Request the bidirectional connection */ 145 ipcarg_t phonehash;145 sysarg_t phonehash; 146 146 147 147 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &phonehash); … … 178 178 int phone; 179 179 180 / / if no timeout is set180 /* If no timeout is set */ 181 181 if (timeout <= 0) 182 182 return async_connect_me_to_blocking(PHONE_NS, need, 0, 0); … … 187 187 return phone; 188 188 189 / / end if no time is left189 /* Abort if no time is left */ 190 190 if (timeout <= 0) 191 191 return ETIMEOUT; 192 192 193 / / wait the minimum of the module wait time and the timeout193 /* Wait the minimum of the module wait time and the timeout */ 194 194 usleep((timeout <= MODULE_WAIT_TIME) ? 195 195 timeout : MODULE_WAIT_TIME); 196 196 timeout -= MODULE_WAIT_TIME; 197 197 } 198 }199 200 /** Receives data from the other party.201 *202 * The received data buffer is allocated and returned.203 *204 * @param[out] data The data buffer to be filled.205 * @param[out] length The buffer length.206 * @return EOK on success.207 * @return EBADMEM if the data or the length parameter is NULL.208 * @return EINVAL if the client does not send data.209 * @return ENOMEM if there is not enough memory left.210 * @return Other error codes as defined for the211 * async_data_write_finalize() function.212 */213 int data_receive(void **data, size_t *length)214 {215 ipc_callid_t callid;216 int rc;217 218 if (!data || !length)219 return EBADMEM;220 221 // fetch the request222 if (!async_data_write_receive(&callid, length))223 return EINVAL;224 225 // allocate the buffer226 *data = malloc(*length);227 if (!*data)228 return ENOMEM;229 230 // fetch the data231 rc = async_data_write_finalize(callid, *data, *length);232 if (rc != EOK) {233 free(data);234 return rc;235 }236 237 return EOK;238 198 } 239 199 … … 254 214 ipc_callid_t callid; 255 215 256 / / fetch the request216 /* Fetch the request */ 257 217 if (!async_data_read_receive(&callid, &length)) 258 218 return EINVAL; 259 219 260 / / check the requested data size220 /* Check the requested data size */ 261 221 if (length < data_length) { 262 222 async_data_read_finalize(callid, data, length); … … 264 224 } 265 225 266 / / send the data226 /* Send the data */ 267 227 return async_data_read_finalize(callid, data, data_length); 268 228 } … … 282 242 if (answer) { 283 243 IPC_SET_RETVAL(*answer, 0); 284 / / just to be precize285 IPC_SET_ METHOD(*answer, 0);244 /* Just to be precise */ 245 IPC_SET_IMETHOD(*answer, 0); 286 246 IPC_SET_ARG1(*answer, 0); 287 247 IPC_SET_ARG2(*answer, 0);
Note:
See TracChangeset
for help on using the changeset viewer.