Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | a771a51 | 2007-02-19 01:13:53 +0000 | [diff] [blame] | 3 | * Copyright (C)2003-2007 Benny Prijono <benny@prijono.org> |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #include <pj/os.h> |
| 20 | #include <linux/time.h> |
| 21 | |
| 22 | #if 0 |
| 23 | PJ_DEF(pj_status_t) pj_get_timestamp(pj_timestamp *ts) |
| 24 | { |
| 25 | ts->u32.hi = 0; |
| 26 | ts->u32.lo = jiffies; |
| 27 | return 0; |
| 28 | } |
| 29 | |
| 30 | PJ_DEF(pj_status_t) pj_get_timestamp_freq(pj_timestamp *freq) |
| 31 | { |
| 32 | freq->u32.hi = 0; |
| 33 | freq->u32.lo = HZ; |
| 34 | return 0; |
| 35 | } |
| 36 | #elif 0 |
| 37 | PJ_DEF(pj_status_t) pj_get_timestamp(pj_timestamp *ts) |
| 38 | { |
| 39 | struct timespec tv; |
| 40 | |
| 41 | tv = CURRENT_TIME; |
| 42 | |
| 43 | ts->u64 = tv.tv_sec; |
| 44 | ts->u64 *= NSEC_PER_SEC; |
| 45 | ts->u64 += tv.tv_nsec; |
| 46 | |
| 47 | return PJ_SUCCESS; |
| 48 | } |
| 49 | |
| 50 | PJ_DEF(pj_status_t) pj_get_timestamp_freq(pj_timestamp *freq) |
| 51 | { |
| 52 | freq->u32.hi = 0; |
| 53 | freq->u32.lo = NSEC_PER_SEC; |
| 54 | return 0; |
| 55 | } |
| 56 | #else |
| 57 | PJ_DEF(pj_status_t) pj_get_timestamp(pj_timestamp *ts) |
| 58 | { |
| 59 | struct timeval tv; |
| 60 | |
| 61 | do_gettimeofday(&tv); |
| 62 | |
| 63 | ts->u64 = tv.tv_sec; |
| 64 | ts->u64 *= USEC_PER_SEC; |
| 65 | ts->u64 += tv.tv_usec; |
| 66 | |
| 67 | return PJ_SUCCESS; |
| 68 | } |
| 69 | |
| 70 | PJ_DEF(pj_status_t) pj_get_timestamp_freq(pj_timestamp *freq) |
| 71 | { |
| 72 | freq->u32.hi = 0; |
| 73 | freq->u32.lo = USEC_PER_SEC; |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | #endif |
| 78 | |