Changeset 46b881c in mainline for uspace/lib/c/generic
- Timestamp:
- 2011-01-29T11:36:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0b6931a, 8add9ca5
- Parents:
- e26a4633 (diff), ffa2c8ef (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
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
re26a4633 r46b881c 77 77 * { 78 78 * if (want_refuse) { 79 * ipc_answer_0(icallid, ELIMIT);79 * async_answer_0(icallid, ELIMIT); 80 80 * return; 81 81 * } 82 * ipc_answer_0(icallid, EOK);82 * async_answer_0(icallid, EOK); 83 83 * 84 84 * callid = async_get_call(&call); 85 85 * somehow_handle_the_call(callid, call); 86 * ipc_answer_2(callid, 1, 2, 3);86 * async_answer_2(callid, 1, 2, 3); 87 87 * 88 88 * callid = async_get_call(&call); … … 92 92 */ 93 93 94 #define LIBC_ASYNC_C_ 95 #include <ipc/ipc.h> 96 #include <async.h> 97 #undef LIBC_ASYNC_C_ 98 94 99 #include <futex.h> 95 #include <async.h>96 100 #include <fibril.h> 97 101 #include <stdio.h> 98 102 #include <adt/hash_table.h> 99 103 #include <adt/list.h> 100 #include <ipc/ipc.h>101 104 #include <assert.h> 102 105 #include <errno.h> … … 1235 1238 } 1236 1239 1240 void async_msg_0(int phone, sysarg_t imethod) 1241 { 1242 ipc_call_async_0(phone, imethod, NULL, NULL, true); 1243 } 1244 1245 void async_msg_1(int phone, sysarg_t imethod, sysarg_t arg1) 1246 { 1247 ipc_call_async_1(phone, imethod, arg1, NULL, NULL, true); 1248 } 1249 1250 void async_msg_2(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2) 1251 { 1252 ipc_call_async_2(phone, imethod, arg1, arg2, NULL, NULL, true); 1253 } 1254 1255 void async_msg_3(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, 1256 sysarg_t arg3) 1257 { 1258 ipc_call_async_3(phone, imethod, arg1, arg2, arg3, NULL, NULL, true); 1259 } 1260 1261 void async_msg_4(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, 1262 sysarg_t arg3, sysarg_t arg4) 1263 { 1264 ipc_call_async_4(phone, imethod, arg1, arg2, arg3, arg4, NULL, NULL, 1265 true); 1266 } 1267 1268 void async_msg_5(int phone, sysarg_t imethod, sysarg_t arg1, sysarg_t arg2, 1269 sysarg_t arg3, sysarg_t arg4, sysarg_t arg5) 1270 { 1271 ipc_call_async_5(phone, imethod, arg1, arg2, arg3, arg4, arg5, NULL, 1272 NULL, true); 1273 } 1274 1275 sysarg_t async_answer_0(ipc_callid_t callid, sysarg_t retval) 1276 { 1277 return ipc_answer_0(callid, retval); 1278 } 1279 1280 sysarg_t async_answer_1(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1) 1281 { 1282 return ipc_answer_1(callid, retval, arg1); 1283 } 1284 1285 sysarg_t async_answer_2(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1, 1286 sysarg_t arg2) 1287 { 1288 return ipc_answer_2(callid, retval, arg1, arg2); 1289 } 1290 1291 sysarg_t async_answer_3(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1, 1292 sysarg_t arg2, sysarg_t arg3) 1293 { 1294 return ipc_answer_3(callid, retval, arg1, arg2, arg3); 1295 } 1296 1297 sysarg_t async_answer_4(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1, 1298 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4) 1299 { 1300 return ipc_answer_4(callid, retval, arg1, arg2, arg3, arg4); 1301 } 1302 1303 sysarg_t async_answer_5(ipc_callid_t callid, sysarg_t retval, sysarg_t arg1, 1304 sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5) 1305 { 1306 return ipc_answer_5(callid, retval, arg1, arg2, arg3, arg4, arg5); 1307 } 1308 1309 int async_forward_fast(ipc_callid_t callid, int phoneid, int imethod, 1310 sysarg_t arg1, sysarg_t arg2, int mode) 1311 { 1312 return ipc_forward_fast(callid, phoneid, imethod, arg1, arg2, mode); 1313 } 1314 1315 int async_forward_slow(ipc_callid_t callid, int phoneid, int imethod, 1316 sysarg_t arg1, sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5, 1317 int mode) 1318 { 1319 return ipc_forward_slow(callid, phoneid, imethod, arg1, arg2, arg3, arg4, 1320 arg5, mode); 1321 } 1322 1237 1323 /** Wrapper for making IPC_M_CONNECT_TO_ME calls using the async framework. 1238 1324 * … … 1314 1400 1315 1401 return newphid; 1402 } 1403 1404 /** Connect to a task specified by id. 1405 * 1406 */ 1407 int async_connect_kbox(task_id_t id) 1408 { 1409 return ipc_connect_kbox(id); 1410 } 1411 1412 /** Wrapper for ipc_hangup. 1413 * 1414 * @param phone Phone handle to hung up. 1415 * 1416 * @return Zero on success or a negative error code. 1417 * 1418 */ 1419 int async_hangup(int phone) 1420 { 1421 return ipc_hangup(phone); 1422 } 1423 1424 /** Interrupt one thread of this task from waiting for IPC. */ 1425 void async_poke(void) 1426 { 1427 ipc_poke(); 1316 1428 } 1317 1429 … … 1503 1615 1504 1616 /** Wrapper for forwarding any read request 1505 *1506 1617 * 1507 1618 */ … … 1690 1801 /** Wrapper for forwarding any data that is about to be received 1691 1802 * 1692 *1693 1803 */ 1694 1804 int async_data_write_forward_fast(int phoneid, sysarg_t method, sysarg_t arg1, -
uspace/lib/c/generic/async_sess.c
re26a4633 r46b881c 99 99 100 100 #include <async_sess.h> 101 #include <ipc/ipc.h>102 101 #include <fibril_synch.h> 103 102 #include <adt/list.h> … … 200 199 list_remove(&conn->global_link); 201 200 202 ipc_hangup(conn->data_phone);201 async_hangup(conn->data_phone); 203 202 free(conn); 204 203 } … … 260 259 data_phone = conn->data_phone; 261 260 free(conn); 262 ipc_hangup(data_phone);261 async_hangup(data_phone); 263 262 goto retry; 264 263 } else { … … 292 291 * means that we simply hang up. 293 292 */ 294 ipc_hangup(data_phone);293 async_hangup(data_phone); 295 294 fibril_mutex_unlock(&async_sess_mutex); 296 295 return; -
uspace/lib/c/generic/ddi.c
re26a4633 r46b881c 127 127 } 128 128 129 /** Register IRQ notification. 130 * 131 * @param inr IRQ number. 132 * @param devno Device number of the device generating inr. 133 * @param method Use this method for notifying me. 134 * @param ucode Top-half pseudocode handler. 135 * 136 * @return Value returned by the kernel. 137 * 138 */ 139 int register_irq(int inr, int devno, int method, irq_code_t *ucode) 140 { 141 return __SYSCALL4(SYS_IPC_REGISTER_IRQ, inr, devno, method, 142 (sysarg_t) ucode); 143 } 144 145 /** Unregister IRQ notification. 146 * 147 * @param inr IRQ number. 148 * @param devno Device number of the device generating inr. 149 * 150 * @return Value returned by the kernel. 151 * 152 */ 153 int unregister_irq(int inr, int devno) 154 { 155 return __SYSCALL2(SYS_IPC_UNREGISTER_IRQ, inr, devno); 156 } 157 129 158 /** @} 130 159 */ -
uspace/lib/c/generic/devman.c
re26a4633 r46b881c 28 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 29 */ 30 31 30 31 /** @addtogroup libc 32 32 * @{ 33 33 */ … … 37 37 #include <str.h> 38 38 #include <stdio.h> 39 #include <ipc/ipc.h>40 39 #include <ipc/services.h> 41 40 #include <ipc/devman.h> … … 116 115 async_set_client_connection(conn); 117 116 118 ipc_connect_to_me(phone, 0, 0, 0, NULL, NULL);117 async_connect_to_me(phone, 0, 0, 0, NULL); 119 118 async_wait_for(req, &retval); 120 119 … … 221 220 case DEVMAN_DRIVER: 222 221 if (devman_phone_driver >= 0) { 223 ipc_hangup(devman_phone_driver);222 async_hangup(devman_phone_driver); 224 223 devman_phone_driver = -1; 225 224 } … … 227 226 case DEVMAN_CLIENT: 228 227 if (devman_phone_client >= 0) { 229 ipc_hangup(devman_phone_client);228 async_hangup(devman_phone_client); 230 229 devman_phone_client = -1; 231 230 } -
uspace/lib/c/generic/devmap.c
re26a4633 r46b881c 29 29 30 30 #include <str.h> 31 #include <ipc/ipc.h>32 31 #include <ipc/services.h> 33 32 #include <ipc/ns.h> … … 80 79 case DEVMAP_DRIVER: 81 80 if (devmap_phone_driver >= 0) { 82 ipc_hangup(devmap_phone_driver);81 async_hangup(devmap_phone_driver); 83 82 devmap_phone_driver = -1; 84 83 } … … 86 85 case DEVMAP_CLIENT: 87 86 if (devmap_phone_client >= 0) { 88 ipc_hangup(devmap_phone_client);87 async_hangup(devmap_phone_client); 89 88 devmap_phone_client = -1; 90 89 } … … 117 116 async_set_client_connection(conn); 118 117 119 ipc_connect_to_me(phone, 0, 0, 0, NULL, NULL);118 async_connect_to_me(phone, 0, 0, 0, NULL); 120 119 async_wait_for(req, &retval); 121 120 -
uspace/lib/c/generic/event.c
re26a4633 r46b881c 35 35 */ 36 36 /** @file 37 */ 37 */ 38 38 39 39 #include <libc.h> 40 40 #include <event.h> 41 41 #include <kernel/ipc/event_types.h> 42 #include <ipc/ipc.h>43 42 44 43 /** Subscribe for event notifications. -
uspace/lib/c/generic/fibril_synch.c
re26a4633 r46b881c 55 55 */ 56 56 if (atomic_get(&threads_in_ipc_wait) > 0) 57 ipc_poke();57 async_poke(); 58 58 } 59 59 -
uspace/lib/c/generic/io/io.c
re26a4633 r46b881c 41 41 #include <bool.h> 42 42 #include <malloc.h> 43 #include <async.h> 43 44 #include <io/klog.h> 44 45 #include <vfs/vfs.h> … … 322 323 323 324 if (stream->phone >= 0) 324 ipc_hangup(stream->phone);325 async_hangup(stream->phone); 325 326 326 327 if (stream->fd >= 0) -
uspace/lib/c/generic/ipc.c
re26a4633 r46b881c 45 45 #include <errno.h> 46 46 #include <adt/list.h> 47 #include <stdio.h>48 #include <unistd.h>49 47 #include <futex.h> 50 #include <kernel/synch/synch.h>51 #include <async.h>52 48 #include <fibril.h> 53 #include <assert.h>54 49 55 50 /** … … 650 645 } 651 646 652 /** Register IRQ notification.653 *654 * @param inr IRQ number.655 * @param devno Device number of the device generating inr.656 * @param method Use this method for notifying me.657 * @param ucode Top-half pseudocode handler.658 *659 * @return Value returned by the kernel.660 */661 int ipc_register_irq(int inr, int devno, int method, irq_code_t *ucode)662 {663 return __SYSCALL4(SYS_IPC_REGISTER_IRQ, inr, devno, method,664 (sysarg_t) ucode);665 }666 667 /** Unregister IRQ notification.668 *669 * @param inr IRQ number.670 * @param devno Device number of the device generating inr.671 *672 * @return Value returned by the kernel.673 */674 int ipc_unregister_irq(int inr, int devno)675 {676 return __SYSCALL2(SYS_IPC_UNREGISTER_IRQ, inr, devno);677 }678 679 647 /** Forward a received call to another destination. 680 648 * -
uspace/lib/c/generic/ipc/ns.c
re26a4633 r46b881c 79 79 } 80 80 81 void *service_realtime_share_in(void) 82 { 83 void *rtime = as_get_mappable_page(PAGE_SIZE); 84 if (rtime == NULL) 85 return NULL; 86 87 int res = async_share_in_start_1_0(PHONE_NS, rtime, PAGE_SIZE, 88 SERVICE_MEM_REALTIME); 89 if (res != EOK) { 90 as_area_destroy((void *) rtime); 91 return NULL; 92 } 93 94 return rtime; 95 } 96 81 97 /** @} 82 98 */ -
uspace/lib/c/generic/libc.c
re26a4633 r46b881c 47 47 #include <thread.h> 48 48 #include <fibril.h> 49 #include <ipc/ipc.h>50 49 #include <async.h> 51 50 #include <as.h> -
uspace/lib/c/generic/loader.c
re26a4633 r46b881c 33 33 */ 34 34 35 #include <ipc/ipc.h>36 35 #include <ipc/loader.h> 37 36 #include <ipc/services.h> … … 320 319 return rc; 321 320 322 ipc_hangup(ldr->phone_id);321 async_hangup(ldr->phone_id); 323 322 ldr->phone_id = 0; 324 323 return EOK; … … 338 337 void loader_abort(loader_t *ldr) 339 338 { 340 ipc_hangup(ldr->phone_id);339 async_hangup(ldr->phone_id); 341 340 ldr->phone_id = 0; 342 341 } -
uspace/lib/c/generic/net/icmp_api.c
re26a4633 r46b881c 41 41 #include <net/modules.h> 42 42 #include <net/ip_codes.h> 43 44 43 #include <async.h> 45 44 #include <sys/types.h> 46 45 #include <sys/time.h> 47 46 #include <errno.h> 48 49 #include <ipc/ipc.h>50 47 #include <ipc/services.h> 51 48 #include <ipc/icmp.h> -
uspace/lib/c/generic/net/modules.c
re26a4633 r46b881c 43 43 #include <errno.h> 44 44 #include <sys/time.h> 45 46 #include <ipc/ipc.h>47 45 #include <ipc/services.h> 48 49 46 #include <net/modules.h> 50 47 … … 67 64 switch (count) { 68 65 case 0: 69 ipc_answer_0(callid, (sysarg_t) result);66 async_answer_0(callid, (sysarg_t) result); 70 67 break; 71 68 case 1: 72 ipc_answer_1(callid, (sysarg_t) result,69 async_answer_1(callid, (sysarg_t) result, 73 70 IPC_GET_ARG1(*answer)); 74 71 break; 75 72 case 2: 76 ipc_answer_2(callid, (sysarg_t) result,73 async_answer_2(callid, (sysarg_t) result, 77 74 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer)); 78 75 break; 79 76 case 3: 80 ipc_answer_3(callid, (sysarg_t) result,77 async_answer_3(callid, (sysarg_t) result, 81 78 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 82 79 IPC_GET_ARG3(*answer)); 83 80 break; 84 81 case 4: 85 ipc_answer_4(callid, (sysarg_t) result,82 async_answer_4(callid, (sysarg_t) result, 86 83 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 87 84 IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer)); … … 89 86 case 5: 90 87 default: 91 ipc_answer_5(callid, (sysarg_t) result,88 async_answer_5(callid, (sysarg_t) result, 92 89 IPC_GET_ARG1(*answer), IPC_GET_ARG2(*answer), 93 90 IPC_GET_ARG3(*answer), IPC_GET_ARG4(*answer), … … 137 134 sysarg_t arg3, async_client_conn_t client_receiver, suseconds_t timeout) 138 135 { 139 int rc;140 141 136 /* Connect to the needed service */ 142 137 int phone = connect_to_service_timeout(need, timeout); 143 138 if (phone >= 0) { 144 139 /* Request the bidirectional connection */ 145 sysarg_t taskhash; 146 sysarg_t phonehash; 147 148 rc = ipc_connect_to_me(phone, arg1, arg2, arg3, &taskhash, 149 &phonehash); 140 int rc = async_connect_to_me(phone, arg1, arg2, arg3, client_receiver); 150 141 if (rc != EOK) { 151 ipc_hangup(phone);142 async_hangup(phone); 152 143 return rc; 153 144 } 154 async_new_connection(taskhash, phonehash, 0, NULL,155 client_receiver);156 145 } 157 146 -
uspace/lib/c/generic/net/socket_client.c
re26a4633 r46b881c 43 43 #include <stdlib.h> 44 44 #include <errno.h> 45 45 #include <task.h> 46 46 #include <ipc/services.h> 47 47 #include <ipc/socket.h> 48 49 48 #include <net/modules.h> 50 49 #include <net/in.h> … … 278 277 } 279 278 280 ipc_answer_0(callid, (sysarg_t) rc);279 async_answer_0(callid, (sysarg_t) rc); 281 280 goto loop; 282 281 } … … 687 686 688 687 /* Read address */ 689 ipc_data_read_start(socket->phone, cliaddr, *addrlen);688 async_data_read_start(socket->phone, cliaddr, *addrlen); 690 689 fibril_rwlock_write_unlock(&socket_globals.lock); 691 690 async_wait_for(message_id, &ipc_result); -
uspace/lib/c/generic/time.c
re26a4633 r46b881c 35 35 #include <sys/time.h> 36 36 #include <unistd.h> 37 #include < ipc/ipc.h>38 #include < stdio.h>37 #include <bool.h> 38 #include <ipc/ns.h> 39 39 #include <arch/barrier.h> 40 #include <unistd.h> 41 #include <atomic.h> 42 #include <sysinfo.h> 43 #include <ipc/services.h> 40 #include <macros.h> 44 41 #include <libc.h> 45 46 #include <sysinfo.h>47 #include <as.h>48 #include <ddi.h>49 50 42 #include <time.h> 51 43 52 /* Pointers to publicvariables with time */44 /** Pointer to kernel shared variables with time */ 53 45 struct { 54 46 volatile sysarg_t seconds1; … … 59 51 /** Add microseconds to given timeval. 60 52 * 61 * @param tv Destination timeval. 62 * @param usecs Number of microseconds to add. 53 * @param tv Destination timeval. 54 * @param usecs Number of microseconds to add. 55 * 63 56 */ 64 57 void tv_add(struct timeval *tv, suseconds_t usecs) … … 66 59 tv->tv_sec += usecs / 1000000; 67 60 tv->tv_usec += usecs % 1000000; 61 68 62 if (tv->tv_usec > 1000000) { 69 63 tv->tv_sec++; … … 74 68 /** Subtract two timevals. 75 69 * 76 * @param tv1 First timeval. 77 * @param tv2 Second timeval. 78 * 79 * @return Return difference between tv1 and tv2 (tv1 - tv2) in 80 * microseconds. 70 * @param tv1 First timeval. 71 * @param tv2 Second timeval. 72 * 73 * @return Difference between tv1 and tv2 (tv1 - tv2) in 74 * microseconds. 75 * 81 76 */ 82 77 suseconds_t tv_sub(struct timeval *tv1, struct timeval *tv2) 83 78 { 84 suseconds_t result; 85 86 result = tv1->tv_usec - tv2->tv_usec; 87 result += (tv1->tv_sec - tv2->tv_sec) * 1000000; 88 89 return result; 79 return (tv1->tv_usec - tv2->tv_usec) + 80 ((tv1->tv_sec - tv2->tv_sec) * 1000000); 90 81 } 91 82 92 83 /** Decide if one timeval is greater than the other. 93 84 * 94 * @param t1 First timeval. 95 * @param t2 Second timeval. 96 * 97 * @return Return true tv1 is greater than tv2. Otherwise return 98 * false. 85 * @param t1 First timeval. 86 * @param t2 Second timeval. 87 * 88 * @return True if tv1 is greater than tv2. 89 * @return False otherwise. 90 * 99 91 */ 100 92 int tv_gt(struct timeval *tv1, struct timeval *tv2) 101 93 { 102 94 if (tv1->tv_sec > tv2->tv_sec) 103 return 1; 104 if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec > tv2->tv_usec) 105 return 1; 106 return 0; 95 return true; 96 97 if ((tv1->tv_sec == tv2->tv_sec) && (tv1->tv_usec > tv2->tv_usec)) 98 return true; 99 100 return false; 107 101 } 108 102 109 103 /** Decide if one timeval is greater than or equal to the other. 110 104 * 111 * @param tv1 First timeval. 112 * @param tv2 Second timeval. 113 * 114 * @return Return true if tv1 is greater than or equal to tv2. 115 * Otherwise return false. 105 * @param tv1 First timeval. 106 * @param tv2 Second timeval. 107 * 108 * @return True if tv1 is greater than or equal to tv2. 109 * @return False otherwise. 110 * 116 111 */ 117 112 int tv_gteq(struct timeval *tv1, struct timeval *tv2) 118 113 { 119 114 if (tv1->tv_sec > tv2->tv_sec) 120 return 1; 121 if (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec >= tv2->tv_usec) 122 return 1; 123 return 0; 124 } 125 126 127 /** POSIX gettimeofday 128 * 129 * The time variables are memory mapped(RO) from kernel, which updates 130 * them periodically. As it is impossible to read 2 values atomically, we 131 * use a trick: First read a seconds, then read microseconds, then 132 * read seconds again. If a second elapsed in the meantime, set it to zero. 133 * This provides assurance, that at least the 134 * sequence of subsequent gettimeofday calls is ordered. 115 return true; 116 117 if ((tv1->tv_sec == tv2->tv_sec) && (tv1->tv_usec >= tv2->tv_usec)) 118 return true; 119 120 return false; 121 } 122 123 /** Get time of day 124 * 125 * The time variables are memory mapped (read-only) from kernel which 126 * updates them periodically. 127 * 128 * As it is impossible to read 2 values atomically, we use a trick: 129 * First we read the seconds, then we read the microseconds, then we 130 * read the seconds again. If a second elapsed in the meantime, set 131 * the microseconds to zero. 132 * 133 * This assures that the values returned by two subsequent calls 134 * to gettimeofday() are monotonous. 135 * 135 136 */ 136 137 int gettimeofday(struct timeval *tv, struct timezone *tz) 137 138 { 138 void *mapping;139 sysarg_t s1, s2;140 int rights;141 int res;142 143 139 if (!ktime) { 144 mapping = as_get_mappable_page(PAGE_SIZE); 145 /* Get the mapping of kernel clock */ 146 res = ipc_share_in_start_1_1(PHONE_NS, mapping, PAGE_SIZE, 147 SERVICE_MEM_REALTIME, &rights); 148 if (res) { 149 printf("Failed to initialize timeofday memarea\n"); 150 _exit(1); 151 } 152 if (!(rights & AS_AREA_READ)) { 153 printf("Received bad rights on time area: %X\n", 154 rights); 155 as_area_destroy(mapping); 156 _exit(1); 157 } 158 ktime = mapping; 159 } 140 ktime = service_realtime_share_in(); 141 if (!ktime) 142 return -1; 143 } 144 160 145 if (tz) { 161 146 tz->tz_minuteswest = 0; 162 147 tz->tz_dsttime = DST_NONE; 163 148 } 164 165 s2 = ktime->seconds2; 149 150 sysarg_t s2 = ktime->seconds2; 151 166 152 read_barrier(); 167 153 tv->tv_usec = ktime->useconds; 154 168 155 read_barrier(); 169 s1 = ktime->seconds1; 156 sysarg_t s1 = ktime->seconds1; 157 170 158 if (s1 != s2) { 159 tv->tv_sec = max(s1, s2); 171 160 tv->tv_usec = 0; 172 tv->tv_sec = s1 > s2 ? s1 : s2;173 161 } else 174 162 tv->tv_sec = s1; 175 163 176 164 return 0; 177 165 } … … 180 168 { 181 169 struct timeval tv; 182 183 170 if (gettimeofday(&tv, NULL)) 184 171 return (time_t) -1; 172 185 173 if (tloc) 186 174 *tloc = tv.tv_sec; 175 187 176 return tv.tv_sec; 188 177 } 189 178 190 /** Wait unconditionally for specified number of microseconds */ 179 /** Wait unconditionally for specified number of microseconds 180 * 181 */ 191 182 int usleep(useconds_t usec) 192 183 { … … 195 186 } 196 187 197 /** Wait unconditionally for specified number of seconds */ 188 /** Wait unconditionally for specified number of seconds 189 * 190 */ 198 191 unsigned int sleep(unsigned int sec) 199 192 { 200 /* Sleep in 1000 second steps to support 201 full argument range */ 193 /* 194 * Sleep in 1000 second steps to support 195 * full argument range 196 */ 197 202 198 while (sec > 0) { 203 199 unsigned int period = (sec > 1000) ? 1000 : sec; 204 200 205 201 usleep(period * 1000000); 206 202 sec -= period; 207 203 } 204 208 205 return 0; 209 206 } -
uspace/lib/c/generic/udebug.c
re26a4633 r46b881c 31 31 */ 32 32 /** @file 33 */ 33 */ 34 34 35 35 #include <udebug.h> 36 36 #include <sys/types.h> 37 #include <ipc/ipc.h>38 37 #include <async.h> 39 38 -
uspace/lib/c/generic/vfs/vfs.c
re26a4633 r46b881c 1 1 /* 2 * Copyright (c) 2008 Jakub Jermar 2 * Copyright (c) 2008 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 43 43 #include <sys/stat.h> 44 44 #include <sys/types.h> 45 #include <ipc/ipc.h>46 45 #include <ipc/services.h> 47 46 #include <ipc/ns.h>
Note:
See TracChangeset
for help on using the changeset viewer.