Changeset 3456
- Timestamp:
- Mar 16, 2011 9:22:24 AM (14 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/os.h
r3423 r3456 1170 1170 1171 1171 /** 1172 * Get monotonic time since some unspecified starting point. 1173 * 1174 * @param tv Variable to store the result. 1175 * 1176 * @return PJ_SUCCESS if successful. 1177 */ 1178 PJ_DECL(pj_status_t) pj_gettickcount(pj_time_val *tv); 1179 1180 /** 1172 1181 * Acquire high resolution timer value. The time value are stored 1173 1182 * in cycles. -
pjproject/trunk/pjlib/src/pj/ioqueue_epoll.c
r2394 r3456 466 466 467 467 pj_assert(key->closing == 1); 468 pj_getti meofday(&key->free_time);468 pj_gettickcount(&key->free_time); 469 469 key->free_time.msec += PJ_IOQUEUE_KEY_FREE_DELAY; 470 470 pj_time_val_normalize(&key->free_time); … … 584 584 pj_ioqueue_key_t *h; 585 585 586 pj_getti meofday(&now);586 pj_gettickcount(&now); 587 587 h = ioqueue->closing_list.next; 588 588 while (h != &ioqueue->closing_list) { -
pjproject/trunk/pjlib/src/pj/ioqueue_select.c
r3299 r3456 412 412 413 413 pj_assert(key->closing == 1); 414 pj_getti meofday(&key->free_time);414 pj_gettickcount(&key->free_time); 415 415 key->free_time.msec += PJ_IOQUEUE_KEY_FREE_DELAY; 416 416 pj_time_val_normalize(&key->free_time); … … 609 609 pj_ioqueue_key_t *h; 610 610 611 pj_getti meofday(&now);611 pj_gettickcount(&now); 612 612 h = ioqueue->closing_list.next; 613 613 while (h != &ioqueue->closing_list) { -
pjproject/trunk/pjlib/src/pj/ioqueue_winnt.c
r3051 r3456 620 620 621 621 pj_assert(key->closing == 1); 622 pj_getti meofday(&key->free_time);622 pj_gettickcount(&key->free_time); 623 623 key->free_time.msec += PJ_IOQUEUE_KEY_FREE_DELAY; 624 624 pj_time_val_normalize(&key->free_time); … … 875 875 pj_ioqueue_key_t *key; 876 876 877 pj_getti meofday(&now);877 pj_gettickcount(&now); 878 878 879 879 /* Move closing keys to free list when they've finished the closing -
pjproject/trunk/pjlib/src/pj/os_timestamp_common.c
r2560 r3456 189 189 } 190 190 191 PJ_DEF(pj_status_t) pj_gettickcount(pj_time_val *tv) 192 { 193 pj_timestamp ts, start; 194 pj_status_t status; 195 196 if ((status = pj_get_timestamp(&ts)) != PJ_SUCCESS) 197 return status; 198 199 pj_set_timestamp32(&start, 0, 0); 200 *tv = pj_elapsed_time(&start, &ts); 201 202 return PJ_SUCCESS; 203 } 204 191 205 #endif /* PJ_HAS_HIGH_RES_TIMER */ 192 206 -
pjproject/trunk/pjlib/src/pj/os_timestamp_posix.c
r2394 r3456 25 25 #include <ctype.h> 26 26 27 #if defined(PJ_HAS_UNISTD_H) && PJ_HAS_UNISTD_H != 0 28 # include <unistd.h> 29 30 # if defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 && \ 31 defined(_POSIX_MONOTONIC_CLOCK) 32 # define USE_POSIX_TIMERS 1 33 # endif 34 35 #endif 36 27 37 #if defined(PJ_HAS_PENTIUM) && PJ_HAS_PENTIUM!=0 && \ 28 38 defined(PJ_TIMESTAMP_USE_RDTSC) && PJ_TIMESTAMP_USE_RDTSC!=0 && \ … … 111 121 } 112 122 123 #elif defined(PJ_DARWINOS) && PJ_DARWINOS != 0 124 #include <mach/mach.h> 125 #include <mach/clock.h> 126 #include <errno.h> 127 128 #define NSEC_PER_SEC 1000000000 129 130 PJ_DEF(pj_status_t) pj_get_timestamp(pj_timestamp *ts) 131 { 132 mach_timespec_t tp; 133 int ret; 134 clock_serv_t serv; 135 136 ret = host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &serv); 137 if (ret != KERN_SUCCESS) { 138 return PJ_RETURN_OS_ERROR(EINVAL); 139 } 140 141 ret = clock_get_time(serv, &tp); 142 if (ret != KERN_SUCCESS) { 143 return PJ_RETURN_OS_ERROR(EINVAL); 144 } 145 146 ts->u64 = tp.tv_sec; 147 ts->u64 *= NSEC_PER_SEC; 148 ts->u64 += tp.tv_nsec; 149 150 return PJ_SUCCESS; 151 } 152 153 PJ_DEF(pj_status_t) pj_get_timestamp_freq(pj_timestamp *freq) 154 { 155 freq->u32.hi = 0; 156 freq->u32.lo = NSEC_PER_SEC; 157 158 return PJ_SUCCESS; 159 } 160 161 #elif defined(USE_POSIX_TIMERS) && USE_POSIX_TIMERS != 0 162 #include <sys/time.h> 163 #include <errno.h> 164 165 #define NSEC_PER_SEC 1000000000 166 167 PJ_DEF(pj_status_t) pj_get_timestamp(pj_timestamp *ts) 168 { 169 struct timespec tp; 170 171 if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0) { 172 return PJ_RETURN_OS_ERROR(pj_get_native_os_error()); 173 } 174 175 ts->u64 = tp.tv_sec; 176 ts->u64 *= NSEC_PER_SEC; 177 ts->u64 += tp.tv_nsec; 178 179 return PJ_SUCCESS; 180 } 181 182 PJ_DEF(pj_status_t) pj_get_timestamp_freq(pj_timestamp *freq) 183 { 184 freq->u32.hi = 0; 185 freq->u32.lo = NSEC_PER_SEC; 186 187 return PJ_SUCCESS; 188 } 189 113 190 #else 114 191 #include <sys/time.h> … … 141 218 142 219 #endif 143 -
pjproject/trunk/pjlib/src/pj/symbols.c
r2394 r3456 198 198 PJ_EXPORT_SYMBOL(pj_time_decode) 199 199 #if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0 200 PJ_EXPORT_SYMBOL(pj_gettickcount) 200 201 PJ_EXPORT_SYMBOL(pj_get_timestamp) 201 202 PJ_EXPORT_SYMBOL(pj_get_timestamp_freq) -
pjproject/trunk/pjlib/src/pj/timer.c
r1672 r3456 466 466 PJ_ASSERT_RETURN(entry->_timer_id < 1, PJ_EINVALIDOP); 467 467 468 pj_getti meofday(&expires);468 pj_gettickcount(&expires); 469 469 PJ_TIME_VAL_ADD(expires, *delay); 470 470 … … 504 504 505 505 count = 0; 506 pj_getti meofday(&now);506 pj_gettickcount(&now); 507 507 508 508 lock_timer_heap(ht);
Note: See TracChangeset
for help on using the changeset viewer.