struct timeval

struct timeval
{
__time_t tv_sec;        /* Seconds. */
__suseconds_t tv_usec;  /* Microseconds. */
};
/* Get the current time of day and timezone information,
   putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
   Returns 0 on success, -1 on errors.
   NOTE: This form of timezone information is obsolete.
   Use the functions and variables declared in <time.h> instead. */

extern int gettimeofday (struct timeval *__restrict __tv,
                         __timezone_ptr_t __tz) __THROW __nonnull ((1));
时间: 2024-07-28 20:11:45

struct timeval的相关文章

struct timeval 计时问题

linux编程中,如果用到计时,可以用struct timeval获取系统时间.struct timeval的函数原型如下: struct timeval { __kernel_time_t tv_sec; /* seconds */ __kernel_suseconds_t tv_usec; /* microseconds */ }; 比如,如果要计算某代码运行的时间,可以使用如下代码: int main() { struct timeval tv; long long start_time,

struct timeval 和 struct timespec

struct timeval { time_t tv_sec; suseconds_t tv_usec; }; 测试代码如下: #include <stdio.h> #include <sys/time.h> #include <time.h> int gettimeofday(struct timeval *tv, struct timezone *tz); int main(int argc,char * argv[]){ struct timeval tv; wh

struct timeval和gettimeofday()

http://www.cppblog.com/lynch/archive/2011/08/05/152520.html struct timeval结构体在time.h中的定义为: struct timeval { time_t tv_sec; /* Seconds. */ suseconds_t tv_usec; /* Microseconds. */ }; 其中,tv_sec为Epoch到创建struct timeval时的秒数,tv_usec为微秒 struct timeval结构体在ti

struct timespec 和 struct timeval

time()提供了秒级的精确度 . 1.头文件 <time.h> 2.函数原型 time_t time(time_t * timer) 函数返回从TC1970-1-1 0:0:0开始到现在的秒数 用time()函数结合其他函数(如:localtime.gmtime.asctime.ctime)可以获得当前系统时间或是标准时间. 如果需要更高的时间精确度,就需要struct timespec 和 struct timeval来处理: 一.struct timespec 定义: typedef l

使用未定义的 struct “timeval” 解决方案

场景 在应用VS编译RabbitMQ examples目录下的amqp_comsumer.c文件,出现如上的问题,调用amqp_consume_message函数指定超时时间 struct timeval tvTimeout; tvTimeout.tv_sec = 1; tvTimeout.tv_usec = 0; ret = amqp_consume_message(conn, &envelope, &tvTimeout, 0); 解决 添加头文件#include <windows

struct sk_buff 结构

struct sk_buff可能是linux网络代码中最重要的数据结构,它表示接收或发送数据包的包头信息,并包含很多成员变量供网络代码中的各子系统使用.    这个结构被网络的不同层(MAC或者其他二层链路协议,三层的IP,四层的TCP或UDP等)使用,并且其中的成员变量在结构从一层向另一层传递时改变. L4向L3传递前会添加一个L4的头部,同样,L3向L2传递前,会添加一个L3的头部.添加头部比在不同层之间拷贝数据的效率更高.由于在缓冲区的头部 添加数据意味着要修改指向缓冲区的指针,这是个复杂

C语言通过timeval结构设置周期

在C语言中,我们经常需要设置一个时间周期.在这里,我们通过Timeval结构实现时间周期的设置.首先,我们介绍timeval,其定义如下(转载http://www.cnblogs.com/wainiwann/archive/2012/11/28/2792133.html): "timeval是一个结构体,在time.h中定义为:struct timeval{     __time_t tv_sec;                /* Seconds. */     __suseconds_t

struct sk_buff结构体详解

struct sk_buff是linux网络系统中的核心结构体,linux网络中的所有数据包的封装以及解封装都是在这个结构体的基础上进行. struct sk_buff_head  {     struct sk_buff *next;     struct sk_buff *prev;          __u32 qlen;     spinlock_t lock; } struct sk_buff {     struct sk_buff *next;     struct sk_buff

Linux struct itimerval用法

先看一段代码 #include <stdio.h> #include <time.h> #include <sys/time.h> #include <stdlib.h> #include <signal.h> static int count = 0; void set_timer() { struct itimerval itv; itv.it_value.tv_sec = 3; //timer start after 3 seconds l