Changes in uspace/lib/c/generic/task.c [0eff68e:1e9f8ab] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/task.c
r0eff68e r1e9f8ab 35 35 36 36 #include <task.h> 37 #include <libc.h> 38 #include <stdlib.h> 39 #include <errno.h> 37 40 #include <loader/loader.h> 38 41 #include <stdarg.h> … … 40 43 #include <ipc/ns.h> 41 44 #include <macros.h> 42 #include <assert.h>43 45 #include <async.h> 44 #include <errno.h>45 #include <malloc.h>46 #include <libc.h>47 #include "private/ns.h"48 46 49 47 task_id_t task_get_id(void) … … 70 68 int task_set_name(const char *name) 71 69 { 72 assert(name);73 74 70 return __SYSCALL2(SYS_TASK_SET_NAME, (sysarg_t) name, str_size(name)); 75 71 } … … 92 88 * loader API. Arguments are passed as a null-terminated array of strings. 93 89 * 94 * @param id If not NULL, the ID of the task is stored here on success. 95 * @param path Pathname of the binary to execute. 96 * @param argv Command-line arguments. 97 * 98 * @return Zero on success or negative error code. 99 * 90 * @param id If not NULL, the ID of the task is stored here on success. 91 * @param path Pathname of the binary to execute. 92 * @param argv Command-line arguments. 93 * 94 * @return Zero on success or negative error code. 100 95 */ 101 96 int task_spawnv(task_id_t *id, const char *path, const char *const args[]) 102 97 { 98 loader_t *ldr; 99 task_id_t task_id; 100 int rc; 101 103 102 /* Connect to a program loader. */ 104 l oader_t *ldr = loader_connect();103 ldr = loader_connect(); 105 104 if (ldr == NULL) 106 105 return EREFUSED; 107 106 108 107 /* Get task ID. */ 109 task_id_t task_id; 110 int rc = loader_get_task_id(ldr, &task_id); 108 rc = loader_get_task_id(ldr, &task_id); 111 109 if (rc != EOK) 112 110 goto error; … … 165 163 166 164 /* Success */ 165 free(ldr); 166 167 167 if (id != NULL) 168 168 *id = task_id; … … 173 173 /* Error exit */ 174 174 loader_abort(ldr); 175 free(ldr); 175 176 return rc; 176 177 } … … 181 182 * loader API. Arguments are passed as a null-terminated list of arguments. 182 183 * 183 * @param id If not NULL, the ID of the task is stored here on success. 184 * @param path Pathname of the binary to execute. 185 * @param ... Command-line arguments. 186 * 187 * @return Zero on success or negative error code. 188 * 184 * @param id If not NULL, the ID of the task is stored here on success. 185 * @param path Pathname of the binary to execute. 186 * @param ... Command-line arguments. 187 * 188 * @return Zero on success or negative error code. 189 189 */ 190 190 int task_spawnl(task_id_t *task_id, const char *path, ...) 191 191 { 192 /* Count the number of arguments. */193 194 192 va_list ap; 193 int rc, cnt; 195 194 const char *arg; 196 195 const char **arglist; 197 int cnt = 0; 198 196 197 /* Count the number of arguments. */ 198 cnt = 0; 199 199 va_start(ap, path); 200 200 do { … … 203 203 } while (arg != NULL); 204 204 va_end(ap); 205 205 206 206 /* Allocate argument list. */ 207 207 arglist = malloc(cnt * sizeof(const char *)); 208 208 if (arglist == NULL) 209 209 return ENOMEM; 210 210 211 211 /* Fill in arguments. */ 212 212 cnt = 0; … … 217 217 } while (arg != NULL); 218 218 va_end(ap); 219 219 220 220 /* Spawn task. */ 221 intrc = task_spawnv(task_id, path, arglist);222 221 rc = task_spawnv(task_id, path, arglist); 222 223 223 /* Free argument list. */ 224 224 free(arglist); … … 228 228 int task_wait(task_id_t id, task_exit_t *texit, int *retval) 229 229 { 230 assert(texit);231 assert(retval);232 233 async_exch_t *exch = async_exchange_begin(session_ns);234 230 sysarg_t te, rv; 235 int rc = (int) async_req_2_2(exch, NS_TASK_WAIT, LOWER32(id), 231 int rc; 232 233 rc = (int) async_req_2_2(PHONE_NS, NS_TASK_WAIT, LOWER32(id), 236 234 UPPER32(id), &te, &rv); 237 async_exchange_end(exch);238 239 235 *texit = te; 240 236 *retval = rv; 241 237 242 238 return rc; 243 239 } … … 245 241 int task_retval(int val) 246 242 { 247 async_exch_t *exch = async_exchange_begin(session_ns); 248 int rc = (int) async_req_1_0(exch, NS_RETVAL, val); 249 async_exchange_end(exch); 250 251 return rc; 243 return (int) async_req_1_0(PHONE_NS, NS_RETVAL, val); 252 244 } 253 245
Note:
See TracChangeset
for help on using the changeset viewer.