⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time.c

📁 著名操作系统Plan 9的第三版的部分核心源代码。现在很难找到了。Plan 9是bell实验室开发的Unix后继者。
💻 C
字号:
#include <u.h>#include <libc.h>/* *  after a fork with fd's copied, both fd's are pointing to *  the same Chan structure.  Since the offset is kept in the Chan *  structure, the seek's and read's in the two processes can be *  are competing moving the offset around.  Hence the unusual loop *  in the middle of this routine. */static longoldtime(long *tp){	char b[20];	static int f = -1;	int i, retries;	long t;	memset(b, 0, sizeof(b));	for(retries = 0; retries < 100; retries++){		if(f < 0)			f = open("/dev/time", OREAD|OCEXEC);		if(f < 0)			break;		if(seek(f, 0, 0) < 0 || (i = read(f, b, sizeof(b))) < 0){			close(f);			f = -1;		} else {			if(i != 0)				break;		}	}	t = atol(b);	if(tp)		*tp = t;	return t;}longtime(long *tp){	vlong t;	t = nsec()/1000000000LL;	if(t == 0)		t = oldtime(0);	if(tp != nil)		*tp = t;	return t;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -