posix.c

来自「extremeDB s sample code,useful for you」· C语言 代码 · 共 38 行

C
38
字号
#include    "platform.h"#include    "mco.h"static time_t init_time		= 0;timer_unit mco_system_get_current_time(){  unsigned long r;  struct timeb t;  ftime(&t);  if ( init_time == 0 )  init_time = t.time;  r  = (t.time-init_time)*1000;  r += t.millitm;  return (timer_unit)r;}/* Suspend the current thread for the specified # of milliseconds */void Sleep( unsigned long millisecs) {	struct timespec tm1;	struct timespec tm2;	tm1.tv_sec = millisecs / 1000;	tm1.tv_nsec = (millisecs % 1000) * 1000000;	while (nanosleep(&tm1, &tm2) != 0)		memcpy(&tm1, &tm2, sizeof(struct timespec));}/* print string to STDOUT & flush buffer */void Printf(char *str,...){    va_list argptr;    va_start(argptr, str);    vfprintf(stdout, str, argptr);    va_end(argptr);    fflush(stdout);}

⌨️ 快捷键说明

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