gettimeofday/settimeofday系统调用的说明(ZZ)
来源:互联网 发布:数控车床g50编程对刀 编辑:程序博客网 时间:2024/05/16 06:57
<!-- /* Font Definitions */ @font-face{font-family:宋体;panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-alt:SimSun;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 680460288 22 0 262145 0;}@font-face{font-family:"Cambria Math";panose-1:2 4 5 3 5 4 6 3 2 4;mso-font-charset:1;mso-generic-font-family:roman;mso-font-format:other;mso-font-pitch:variable;mso-font-signature:0 0 0 0 0 0;}@font-face{font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;mso-font-charset:0;mso-generic-font-family:swiss;mso-font-pitch:variable;mso-font-signature:-520092929 1073786111 9 0 415 0;}@font-face{font-family:"/@宋体";panose-1:2 1 6 0 3 1 1 1 1 1;mso-font-charset:134;mso-generic-font-family:auto;mso-font-pitch:variable;mso-font-signature:3 680460288 22 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal{mso-style-unhide:no;mso-style-qformat:yes;mso-style-parent:"";margin:0cm;margin-bottom:.0001pt;text-align:justify;text-justify:inter-ideograph;mso-pagination:none;font-size:10.5pt;mso-bidi-font-size:11.0pt;font-family:"Calibri","sans-serif";mso-ascii-font-family:Calibri;mso-ascii-theme-font:minor-latin;mso-fareast-font-family:宋体;mso-fareast-theme-font:minor-fareast;mso-hansi-font-family:Calibri;mso-hansi-theme-font:minor-latin;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;mso-font-kerning:1.0pt;}p{mso-style-noshow:yes;mso-style-priority:99;mso-margin-top-alt:auto;margin-right:0cm;mso-margin-bottom-alt:auto;margin-left:0cm;mso-pagination:widow-orphan;font-size:12.0pt;font-family:宋体;mso-bidi-font-family:宋体;}.MsoChpDefault{mso-style-type:export-only;mso-default-props:yes;mso-bidi-font-family:"Times New Roman";mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page{mso-page-border-surround-header:no;mso-page-border-surround-footer:no;}@page WordSection1{size:612.0pt 792.0pt;margin:72.0pt 90.0pt 72.0pt 90.0pt;mso-header-margin:36.0pt;mso-footer-margin:36.0pt;mso-paper-source:0;}div.WordSection1{page:WordSection1;}-->
功能描述:
gettimeofday获取当前时间和时区信息。settimeofday设置当前时间和时区信息。只有超级用户可以调用settimeofday,如果存在为NULL的参数,表示不改变某一项信息。
用法:
#include <sys/time.h>
#include <time.h>
int gettimeofday(struct timeval *tv, struct timezone *tz);
int settimeofday(const struct timeval *tv , const struct timezone *tz);
参数:
tv:对于gettimeofday,指向存放返回的时间信息的缓冲区;对于settimeofday,指向需要设置的时间信息缓冲区。原型如下
struct timeval {
time_t tv_sec; /* 秒 */
suseconds_t tv_usec; /* 微妙 */
};
tz:时区信息,一般不会被使用。原型如下
struct timezone {
int tz_minuteswest; /* minutes westof Greenwich */
inttz_dsttime; /* type of DSTcorrection */
};
如果tv或tz某一项为NULL,表示对相关的信息不感兴趣。
操作timeval结构体的宏有:
#define timerisset(tvp)/
((tvp)->tv_sec ||(tvp)->tv_usec)
#define timercmp(tvp, uvp, cmp)/
((tvp)->tv_sec cmp(uvp)->tv_sec ||/
(tvp)->tv_sec == (uvp)->tv_sec&&/
(tvp)->tv_usec cmp(uvp)->tv_usec)
#define timerclear(tvp)/
((tvp)->tv_sec =(tvp)->tv_usec = 0)
返回说明:
成功执行时,返回0。失败返回-1,errno被设为以下的某个值
EFAULT:tv或tz其中某一项指向的空间不可访问
EINVAL:时区格式无效
EPERM:权限不足,调用进程不允许使用settimeofday设置当前时间和时区值。
- gettimeofday/settimeofday系统调用的说明(ZZ)
- gettimeofday/settimeofday系统调用
- Linux系统调用--gettimeofday/settimeofday函数详解
- settimeofday(系统调用)
- gettimeofday/settimeofday
- gettimeofday(系统调用)
- 时间编程:time(),localtime(),gmtime(),asctime(),ctime(),gettimeofday(),settimeofday()
- settimeofday
- (zz)系统调用和库函数
- 关于linux系统调用的说明
- KVM系统调用说明
- KVM系统调用说明
- 应用层gettimeofday和系统层do_gettimeofday的关系
- zz关于共享内存DEST状态的说明(转载)
- zz修改Linux内核增加系统调用
- ZZ:7.5.3 测试新系统调用
- Linux 系统函数记录 gettimeofday
- 一次stl sort调用导致的进程崩溃(zz)
- Windows Embedded CE 6.0开发环境的搭建
- .net中解析json 之 json.net
- Java线程安全精解(转)
- echostudio3 破解
- 增加与查询备注
- gettimeofday/settimeofday系统调用的说明(ZZ)
- js 有趣的时钟 --仅供参考
- Asp.Net日期格式
- jsp form之间传递数据存在乱码的解决方法
- VMware和Linux版本搭配问题
- C#会重蹈覆辙吗?系列之1:论C#性能不能承受之慢
- Myeclipse8.5 xml文件不提示
- test
- 增加路由信息,机房环境同时上内网和公网。