• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ clocktime函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中clocktime函数的典型用法代码示例。如果您正苦于以下问题:C++ clocktime函数的具体用法?C++ clocktime怎么用?C++ clocktime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了clocktime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: writecontrolaction

void writecontrolaction(int k, int i)
/*
----------------------------------------------------------------
**   Input:   k  = link index                                     
**            i  = control index                                
**   Output:  none                                                
**   Purpose: writes control action taken to status report
**--------------------------------------------------------------
*/
{
   int n;
   switch (Control[i].Type)
   {
      case LOWLEVEL:
      case HILEVEL:
         n = Control[i].Node;
         sprintf(Msg,FMT54,clocktime(Atime,Htime),LinkTxt[Link[k].Type],
            Link[k].ID,NodeTxt[getnodetype(n)],Node[n].ID);
         break;
      case TIMER:
      case TIMEOFDAY:
         sprintf(Msg,FMT55,clocktime(Atime,Htime),LinkTxt[Link[k].Type],
            Link[k].ID);
         break;
      default: return;
   }
   writeline(Msg);
}
开发者ID:sdteffen,项目名称:ooten,代码行数:28,代码来源:report.c


示例2: forcibly_timeout_mp

void
forcibly_timeout_mp(am_node *mp)
{
  mntfs *mf = mp->am_al->al_mnt;
  /*
   * Arrange to timeout this node
   */
  if (mf && ((mp->am_flags & AMF_ROOT) ||
	     (mf->mf_flags & (MFF_MOUNTING | MFF_UNMOUNTING)))) {
    /*
     * We aren't going to schedule a timeout, so we need to notify the
     * child here unless we are already unmounting, in which case that
     * process is responsible for notifying the child.
     */
    if (mf->mf_flags & MFF_UNMOUNTING)
      plog(XLOG_WARNING, "node %s is currently being unmounted, ignoring timeout request", mp->am_path);
    else {
      plog(XLOG_WARNING, "ignoring timeout request for active node %s", mp->am_path);
      notify_child(mp, AMQ_UMNT_FAILED, EBUSY, 0);
    }
  } else {
    plog(XLOG_INFO, "\"%s\" forcibly timed out", mp->am_path);
    mp->am_flags &= ~AMF_NOTIMEOUT;
    mp->am_ttl = clocktime(NULL);
    /*
     * Force mtime update of parent dir, to prevent DNLC/dcache from caching
     * the old entry, which could result in ESTALE errors, bad symlinks, and
     * more.
     */
    clocktime(&mp->am_parent->am_fattr.na_mtime);
    reschedule_timeout_mp();
  }
}
开发者ID:0mp,项目名称:freebsd,代码行数:33,代码来源:autil.c


示例3: checkup

/*
 * Check that we are not burning resources
 */
static void
checkup(void)
{

  static int max_fd = 0;
  static char *max_mem = 0;

  int next_fd = dup(0);
  caddr_t next_mem = sbrk(0);
  close(next_fd);

  if (max_fd < next_fd) {
    dlog("%d new fds allocated; total is %d",
	 next_fd - max_fd, next_fd);
    max_fd = next_fd;
  }
  if (max_mem < next_mem) {
#ifdef HAVE_GETPAGESIZE
    dlog("%#lx bytes of memory allocated; total is %#lx (%ld pages)",
	 (long) (next_mem - max_mem), (unsigned long) next_mem,
	 ((long) next_mem + getpagesize() - 1) / (long) getpagesize());
#else /* not HAVE_GETPAGESIZE */
    dlog("%#lx bytes of memory allocated; total is %#lx",
	 (long) (next_mem - max_mem), (unsigned long) next_mem);
#endif /* not HAVE_GETPAGESIZE */
    max_mem = next_mem;

  }
}
#else  /* not DEBUG */
#define checkup()
#endif /* not DEBUG */


static int
#ifdef HAVE_SIGACTION
do_select(sigset_t smask, int fds, fd_set *fdp, struct timeval *tvp)
#else /* not HAVE_SIGACTION */
do_select(int smask, int fds, fd_set *fdp, struct timeval *tvp)
#endif /* not HAVE_SIGACTION */
{

  int sig;
  int nsel;

  if ((sig = setjmp(select_intr))) {
    select_intr_valid = 0;
    /* Got a signal */
    switch (sig) {
    case SIGINT:
    case SIGTERM:
      amd_state = Finishing;
      reschedule_timeout_mp();
      break;
    }
    nsel = -1;
    errno = EINTR;
  } else {
    select_intr_valid = 1;
    /*
     * Invalidate the current clock value
     */
    clock_valid = 0;
    /*
     * Allow interrupts.  If a signal
     * occurs, then it will cause a longjmp
     * up above.
     */
#ifdef HAVE_SIGACTION
    sigprocmask(SIG_SETMASK, &smask, NULL);
#else /* not HAVE_SIGACTION */
    (void) sigsetmask(smask);
#endif /* not HAVE_SIGACTION */

    /*
     * Wait for input
     */
    nsel = select(fds, fdp, (fd_set *) 0, (fd_set *) 0,
		  tvp->tv_sec ? tvp : (struct timeval *) 0);
  }

#ifdef HAVE_SIGACTION
  sigprocmask(SIG_BLOCK, &masked_sigs, NULL);
#else /* not HAVE_SIGACTION */
  (void) sigblock(MASKED_SIGS);
#endif /* not HAVE_SIGACTION */

  /*
   * Perhaps reload the cache?
   */
  if (do_mapc_reload < clocktime()) {
    mapc_reload();
    do_mapc_reload = clocktime() + gopt.map_reload_interval;
  }
  return nsel;
}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:99,代码来源:nfs_start.c


示例4: test_AlwaysInLimit

void
test_AlwaysInLimit(void) {
	/* Timestamp is: 2010-01-02 11:00:00Z */
	const u_int32 timestamp = 3471418800UL;
	const u_short prime_incs[] = { 127, 151, 163, 179 };
	int	cyc;
	int	yday;
	u_char	whichprime;
	u_short	ydayinc;
	int	hour;
	int	minute;
	int	second;
	u_long	yearstart;
	u_int32	actual;
	u_int32	diff;

	yearstart = 0;
	for (cyc = 0; cyc < 5; cyc++) {
		settime(1900 + cyc * 65, 1, 1, 0, 0, 0);
		for (yday = -26000; yday < 26000; yday += ydayinc) {
			whichprime = abs(yday) % COUNTOF(prime_incs);
			ydayinc = prime_incs[whichprime];
			for (hour = -204; hour < 204; hour += 2) {
				for (minute = -60; minute < 60; minute++) {
					clocktime(yday, hour, minute, 30, 0,
						  timestamp, &yearstart, &actual);
					diff = actual - timestamp;
					if (diff >= 0x80000000UL)
						diff = ~diff + 1;
					TEST_ASSERT_TRUE(isLE(diff, (183u * SECSPERDAY)));
				}
			}
		}
	}
}
开发者ID:Darge,项目名称:ntp,代码行数:35,代码来源:clocktime.c


示例5: refclock_process_f

/*
 * refclock_process - process a sample from the clock
 * refclock_process_f - refclock_process with other than time1 fudge
 *
 * This routine converts the timecode in the form days, hours, minutes,
 * seconds and milliseconds/microseconds to internal timestamp format,
 * then constructs a new entry in the median filter circular buffer.
 * Return success (1) if the data are correct and consistent with the
 * converntional calendar.
 *
 * Important for PPS users: Normally, the pp->lastrec is set to the
 * system time when the on-time character is received and the pp->year,
 * ..., pp->second decoded and the seconds fraction pp->nsec in
 * nanoseconds). When a PPS offset is available, pp->nsec is forced to
 * zero and the fraction for pp->lastrec is set to the PPS offset.
 */
int
refclock_process_f(
	struct refclockproc *pp,	/* refclock structure pointer */
	double fudge
	)
{
	l_fp offset, ltemp;

	/*
	 * Compute the timecode timestamp from the days, hours, minutes,
	 * seconds and milliseconds/microseconds of the timecode. Use
	 * clocktime() for the aggregate seconds and the msec/usec for
	 * the fraction, when present. Note that this code relies on the
	 * filesystem time for the years and does not use the years of
	 * the timecode.
	 */
	if (!clocktime(pp->day, pp->hour, pp->minute, pp->second, GMT,
		pp->lastrec.l_ui, &pp->yearstart, &offset.l_ui))
		return (0);

	offset.l_uf = 0;
	DTOLFP(pp->nsec / 1e9, &ltemp);
	L_ADD(&offset, &ltemp);
	refclock_process_offset(pp, offset, pp->lastrec, fudge);
	return (1);
}
开发者ID:pexip,项目名称:os-ntp,代码行数:42,代码来源:ntp_refclock.c


示例6: ndbm_init

int
ndbm_init(mnt_map *m, char *map, time_t *tp)
{
  DBM *db;

  db = dbm_open(map, O_RDONLY, 0);
  if (db) {
    struct stat stb;
    int error;
#ifdef DBM_SUFFIX
    char dbfilename[256];

    xstrlcpy(dbfilename, map, sizeof(dbfilename));
    xstrlcat(dbfilename, DBM_SUFFIX, sizeof(dbfilename));
    error = stat(dbfilename, &stb);
#else /* not DBM_SUFFIX */
    error = fstat(dbm_pagfno(db), &stb);
#endif /* not DBM_SUFFIX */
    if (error < 0)
      *tp = clocktime(NULL);
    else
      *tp = stb.st_mtime;
    dbm_close(db);
    return 0;
  }
  return errno;
}
开发者ID:0mp,项目名称:freebsd,代码行数:27,代码来源:info_ndbm.c


示例7: refclock_process

/*
 * refclock_process - process a sample from the clock
 *
 * This routine converts the timecode in the form days, hours, minutes,
 * seconds and milliseconds/microseconds to internal timestamp format,
 * then constructs a new entry in the median filter circular buffer.
 * Return success (1) if the data are correct and consistent with the
 * converntional calendar.
*/
int
refclock_process(
	struct refclockproc *pp
	)
{
	l_fp offset;

	/*
	 * Compute the timecode timestamp from the days, hours, minutes,
	 * seconds and milliseconds/microseconds of the timecode. Use
	 * clocktime() for the aggregate seconds and the msec/usec for
	 * the fraction, when present. Note that this code relies on the
	 * filesystem time for the years and does not use the years of
	 * the timecode.
	 */
	if (!clocktime(pp->day, pp->hour, pp->minute, pp->second, GMT,
		pp->lastrec.l_ui, &pp->yearstart, &offset.l_ui))
		return (0);
	if (pp->usec) {
		TVUTOTSF(pp->usec, offset.l_uf);
	} else {
		MSUTOTSF(pp->msec, offset.l_uf);
	}
	refclock_process_offset(pp, offset, pp->lastrec,
	    pp->fudgetime1);
	return (1);
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:36,代码来源:ntp_refclock.c


示例8: autofs_mounted

void
autofs_mounted(am_node *mp)
{
  autofs_fh_t *fh = mp->am_autofs_fh;
  unsigned long timeout = gopt.am_timeo;

  close(fh->kernelfd);
  fh->kernelfd = -1;

  autofs_get_mp(mp);

  /* Get autofs protocol version */
  if (ioctl(fh->ioctlfd, AUTOFS_IOC_PROTOVER, &fh->version) < 0) {
    plog(XLOG_ERROR, "AUTOFS_IOC_PROTOVER: %s", strerror(errno));
    fh->version = AUTOFS_MIN_VERSION;
    plog(XLOG_ERROR, "autofs: assuming protocol version %d", fh->version);
  } else
    plog(XLOG_INFO, "autofs: using protocol version %d", fh->version);

  /* set expiration timeout */
  if (ioctl(fh->ioctlfd, AUTOFS_IOC_SETTIMEOUT, &timeout) < 0)
    plog(XLOG_ERROR, "AUTOFS_IOC_SETTIMEOUT: %s", strerror(errno));

  /* tell the daemon to call us for expirations */
  mp->am_autofs_ttl = clocktime(NULL) + gopt.am_timeo_w;
}
开发者ID:enukane,项目名称:netbsd-src,代码行数:26,代码来源:autofs_linux.c


示例9: clocktime

myapplication::myapplication(){
  this->sec=0;
  this->min=0;
  this->hour=0;
  this->day=0;
  this->resolution = clocktime();
}
开发者ID:DannyArends,项目名称:Other,代码行数:7,代码来源:myapplication.cpp


示例10: init_map

/*
 * Initialize an allocated mount node.
 * It is assumed that the mount node was b-zero'd
 * before getting here so anything that would
 * be set to zero isn't done here.
 */
void
init_map(am_node *mp, char *dir)
{
  /*
   * mp->am_mapno is initialized by exported_ap_alloc
   * other fields don't need to be set to zero.
   */
  mp->am_mnt = new_mntfs();
  mp->am_mfarray = 0;
  mp->am_name = strdup(dir);
  mp->am_path = strdup(dir);
  mp->am_gen = new_gen();
#ifdef HAVE_FS_AUTOFS
  mp->am_autofs_fh = 0;
#endif /* HAVE_FS_AUTOFS */

  mp->am_timeo = gopt.am_timeo;
  mp->am_attr.ns_status = NFS_OK;
  mp->am_fattr = gen_fattr;
  mp->am_fattr.na_fsid = 42;
  mp->am_fattr.na_fileid = mp->am_gen;
  clocktime(&mp->am_fattr.na_atime);
  /* next line copies a "struct nfstime" among several fields */
  mp->am_fattr.na_mtime = mp->am_fattr.na_ctime = mp->am_fattr.na_atime;

  new_ttl(mp);
  mp->am_stats.s_mtime = mp->am_fattr.na_atime.nt_seconds;
  mp->am_dev = -1;
  mp->am_rdev = -1;
}
开发者ID:marulkan,项目名称:am-utils-tcp-workaround,代码行数:36,代码来源:map.c


示例11: new_ttl

/*
 * Compute a new time to live value for a node.
 */
void
new_ttl(am_node *mp)
{
  mp->am_timeo_w = 0;
  mp->am_ttl = clocktime(&mp->am_fattr.na_atime);
  mp->am_ttl += mp->am_timeo;	/* sun's -tl option */
}
开发者ID:marulkan,项目名称:am-utils-tcp-workaround,代码行数:10,代码来源:map.c


示例12: amfs_retry

/*
 * Retry a mount
 */
static void
amfs_retry(int rc, int term, opaque_t arg)
{
  struct continuation *cp = (struct continuation *) arg;
  am_node *mp = cp->mp;
  int error = 0;

  dlog("Commencing retry for mount of %s", mp->am_path);

  new_ttl(mp);

  if ((cp->start + ALLOWED_MOUNT_TIME) < clocktime(NULL)) {
    /*
     * The entire mount has timed out.  Set the error code and skip past all
     * the mntfs's so that amfs_bgmount will not have any more
     * ways to try the mount, thus causing an error.
     */
    plog(XLOG_INFO, "mount of \"%s\" has timed out", mp->am_path);
    error = ETIMEDOUT;
    while (*cp->mf)
      cp->mf++;
    /* explicitly forbid further retries after timeout */
    cp->retry = FALSE;
  }
  if (error || !IN_PROGRESS(cp))
    error = amfs_bgmount(cp);

  reschedule_timeout_mp();
}
开发者ID:0xbda2d2f8,项目名称:freebsd,代码行数:32,代码来源:amfs_generic.c


示例13: autofs_mounted

void
autofs_mounted(am_node *mp)
{
  mntfs *mf = mp->am_mnt;
  autofs_fh_t *fh = mf->mf_autofs_fh;
  unsigned long timeout = gopt.am_timeo;

  close(fh->kernelfd);
  fh->kernelfd = -1;

  fh->ioctlfd = open(mf->mf_mount, O_RDONLY);
  /* Get autofs protocol version */
  if (ioctl(fh->ioctlfd, AUTOFS_IOC_PROTOVER, &fh->version) < 0) {
    plog(XLOG_ERROR, "AUTOFS_IOC_PROTOVER: %s", strerror(errno));
    fh->version = AUTOFS_MIN_VERSION;
    plog(XLOG_ERROR, "autofs: assuming protocol version %d", fh->version);
  } else
    plog(XLOG_INFO, "autofs: using protocol version %d", fh->version);

  if (fh->version < 4) {
    /* no support for subdirs */
    plog(XLOG_INFO, "Turning off autofs support for host filesystems");
    amfs_host_ops.nfs_fs_flags &= ~FS_AUTOFS;
    amfs_host_ops.autofs_fs_flags &= ~FS_AUTOFS;
  }

  /* set expiration timeout */
  if (ioctl(fh->ioctlfd, AUTOFS_IOC_SETTIMEOUT, &timeout) < 0)
    plog(XLOG_ERROR, "AUTOFS_IOC_SETTIMEOUT: %s", strerror(errno));

  /* tell the daemon to call us for expirations */
  mp->am_ttl = clocktime() + gopt.am_timeo_w;
}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:33,代码来源:autofs_linux.c


示例14: amfs_generic_mount_child

am_node *
amfs_generic_mount_child(am_node *new_mp, int *error_return)
{
  int error;
  struct continuation *cp;	/* Continuation structure if need to mount */

  dlog("in amfs_generic_mount_child");

  *error_return = error = 0;	/* Error so far */

  /* we have an errorfs attached to the am_node, free it */
  if (new_mp->am_al)
    free_loc(new_mp->am_al);
  new_mp->am_al = NULL;

  /*
   * Construct a continuation
   */
  cp = ALLOC(struct continuation);
  cp->callout = 0;
  cp->mp = new_mp;
  cp->retry = TRUE;
  cp->start = clocktime(NULL);
  cp->al = new_mp->am_alarray;

  /*
   * Try and mount the file system.  If this succeeds immediately (possible
   * for a ufs file system) then return the attributes, otherwise just
   * return an error.
   */
  error = amfs_bgmount(cp);
  reschedule_timeout_mp();
  if (!error)
    return new_mp;

  /*
   * Code for quick reply.  If current_transp is set, then it's the
   * transp that's been passed down from nfs_dispatcher() or from
   * autofs_program_[123]().
   * If new_mp->am_transp is not already set, set it by copying in
   * current_transp.  Once am_transp is set, nfs_quick_reply() and
   * autofs_mount_succeeded() can use it to send a reply to the
   * client that requested this mount.
   */
  if (current_transp && !new_mp->am_transp) {
    dlog("Saving RPC transport for %s", new_mp->am_path);
    new_mp->am_transp = (SVCXPRT *) xmalloc(sizeof(SVCXPRT));
    *(new_mp->am_transp) = *current_transp;
  }
  if (error && new_mp->am_al && new_mp->am_al->al_mnt &&
      (new_mp->am_al->al_mnt->mf_ops == &amfs_error_ops))
    new_mp->am_error = error;

  if (new_mp->am_error > 0)
    assign_error_mntfs(new_mp);

  ereturn(error);
}
开发者ID:IIJ-NetBSD,项目名称:netbsd-src,代码行数:58,代码来源:amfs_generic.c


示例15: test_NoReasonableConversion

void
test_NoReasonableConversion(void) {
	/* Timestamp is: 2010-01-02 11:00:00Z */
	const u_int32 timestamp = 3471418800UL;
	
	const int yday=100, hour=12, minute=0, second=0, tzoff=0;
	u_long yearstart = 0;
	u_int32 actual;

	TEST_ASSERT_FALSE(clocktime(yday, hour, minute, second, tzoff, timestamp,
						   &yearstart, &actual));
}
开发者ID:Darge,项目名称:ntp,代码行数:12,代码来源:clocktime.c


示例16: file_open

static FILE *
file_open(char *map, time_t *tp)
{
  FILE *mapf = fopen(map, "r");

  if (mapf && tp) {
    struct stat stb;
    if (fstat(fileno(mapf), &stb) < 0)
      *tp = clocktime(NULL);
    else
      *tp = stb.st_mtime;
  }
  return mapf;
}
开发者ID:IIJ-NetBSD,项目名称:netbsd-src,代码行数:14,代码来源:info_file.c


示例17: writeruleaction

void writeruleaction(int k, char *ruleID)
/*
**--------------------------------------------------------------
**   Input:   k  = link index                                     
**            *ruleID  = rule ID
**   Output:  none                                                
**   Purpose: writes rule action taken to status report
**--------------------------------------------------------------
*/
{
   sprintf(Msg,FMT63,clocktime(Atime,Htime),LinkTxt[Link[k].Type],
      Link[k].ID,ruleID);
   writeline(Msg);
}
开发者ID:sdteffen,项目名称:ooten,代码行数:14,代码来源:report.c


示例18: test_CurrentYear

void
test_CurrentYear(void) {
	// Timestamp: 2010-06-24 12:50:00Z
	const u_int32 timestamp = 3486372600UL;
	const u_int32 expected	= timestamp; // exactly the same.

	const int yday=175, hour=12, minute=50, second=0, tzoff=0;

	u_long yearstart=0;
	u_int32 actual;

	TEST_ASSERT_TRUE(clocktime(yday, hour, minute, second, tzoff, timestamp,
						  &yearstart, &actual));
	TEST_ASSERT_EQUAL(expected, actual);
}
开发者ID:Darge,项目名称:ntp,代码行数:15,代码来源:clocktime.c


示例19: writehyderr

void  writehyderr(int errnode)
/*
**-----------------------------------------------------------
**   Input:   none                                          
**   Output:  none                                          
**   Purpose: outputs status & checks connectivity when     
**            network hydraulic equations cannot be solved. 
**-----------------------------------------------------------
*/
{
   sprintf(Msg,FMT62,clocktime(Atime,Htime),Node[errnode].ID);
   if (Messageflag) writeline(Msg);
   writehydstat(0,0);
   disconnected();
}                        /* End of writehyderr */
开发者ID:sdteffen,项目名称:ooten,代码行数:15,代码来源:report.c


示例20: show_time_host_and_name

/*
 * Output the time of day and hostname to the logfile
 */
static void
show_time_host_and_name(int lvl)
{
  static time_t last_t = 0;
  static char *last_ctime = 0;
  time_t t = clocktime();
  char *sev;

  if (t != last_t) {
    last_ctime = ctime(&t);
    last_t = t;
  }
  switch (lvl) {
  case XLOG_FATAL:
    sev = "fatal:";
    break;
  case XLOG_ERROR:
    sev = "error:";
    break;
  case XLOG_USER:
    sev = "user: ";
    break;
  case XLOG_WARNING:
    sev = "warn: ";
    break;
  case XLOG_INFO:
    sev = "info: ";
    break;
  case XLOG_DEBUG:
    sev = "debug:";
    break;
  case XLOG_MAP:
    sev = "map:  ";
    break;
  case XLOG_STATS:
    sev = "stats:";
    break;
  default:
    sev = "hmm:  ";
    break;
  }
  fprintf(logfp, "%15.15s %s %s[%ld]/%s ",
	  last_ctime + 4, am_get_hostname(),
	  am_get_progname(),
	  (long) am_mypid,
	  sev);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:50,代码来源:xutil.c



注:本文中的clocktime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ clog函数代码示例发布时间:2022-05-30
下一篇:
C++ clocksource_register_hz函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap