📄 clock.c
字号:
/*
********************************************************************************
* linux213x
* linux213x timer module for decoder
*
* (c) Copyright 2002-2003, Actions Co,Ld.
* All Right Reserved
*
* File : dec_timer.c
* By : styao
* Version: 1> v1.00 first version 02.27.2006
********************************************************************************
*/
#include <sys/time.h>#include <stdio.h>#include <stdlib.h>
struct timeval time_start;
int start_clock(){ gettimeofday(&time_start,NULL);
return 0;}unsigned int get_clock_time(){
struct timeval cur_tv,last_tv;
unsigned int current_time;
/*calculate the current time*/
gettimeofday(&cur_tv,NULL);
last_tv=time_start;
if(cur_tv.tv_usec<last_tv.tv_usec){
cur_tv.tv_sec--;
current_time=1000000+cur_tv.tv_usec-last_tv.tv_usec;
}else
current_time=cur_tv.tv_usec-last_tv.tv_usec;
current_time=current_time/1000;
current_time+=(cur_tv.tv_sec-last_tv.tv_sec)*1000;
/*adjust time if possible*/
return current_time;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -