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

C++ do_settimeofday函数代码示例

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

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



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

示例1: pxa_timer_init

static void __init pxa_timer_init(void)
{
	struct timespec tv;
	unsigned long flags;

	set_rtc = pxa_set_rtc;

	tv.tv_nsec = 0;
	tv.tv_sec = pxa_get_rtc_time();
	do_settimeofday(&tv);

	OIER = 0;		/* disable any timer interrupts */
	OSSR = 0xf;		/* clear status on all timers */
	setup_irq(IRQ_OST0, &pxa_timer_irq);
	local_irq_save(flags);
	OIER = OIER_E0;		/* enable match on timer 0 to cause interrupts */
	OSMR0 = OSCR + LATCH;	/* set initial match */
	local_irq_restore(flags);

	/*
	 * OSCR runs continuously on PXA and is not written to,
	 * so we can use it as clock source directly.
	 */
	clocksource_pxa.mult =
		clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_pxa.shift);
	clocksource_register(&clocksource_pxa);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:27,代码来源:time.c


示例2: sys_settimeofday

/*
 * In case for some reason the CMOS clock has not already been running
 * in UTC, but in some local time: The first time we set the timezone,
 * we will warp the clock so that it is ticking UTC time instead of
 * local time. Presumably, if someone is setting the timezone then we
 * are running in an environment where the programs understand about
 * timezones. This should be done at boot time in the /etc/rc script,
 * as soon as possible, so that the clock can be set right. Otherwise,
 * various programs will get confused when the clock gets warped.
 */
asmlinkage int sys_settimeofday(struct timeval *tv, struct timezone *tz)
{
	static int	firsttime = 1;
	struct timeval	new_tv;
	struct timezone new_tz;

	if (!suser())
		return -EPERM;
	if (tv) {
		int error = verify_area(VERIFY_READ, tv, sizeof(*tv));
		if (error)
			return error;
		memcpy_fromfs(&new_tv, tv, sizeof(*tv));
	}
	if (tz) {
		int error = verify_area(VERIFY_READ, tz, sizeof(*tz));
		if (error)
			return error;
		memcpy_fromfs(&new_tz, tz, sizeof(*tz));
	}
	if (tz) {
		sys_tz = new_tz;
		if (firsttime) {
			firsttime = 0;
			if (!tv)
				warp_clock();
		}
	}
	if (tv)
		do_settimeofday(&new_tv);
	return 0;
}
开发者ID:liexusong,项目名称:linux2.0-comment,代码行数:42,代码来源:time.c


示例3: mv_rtc_init

static int mv_rtc_init(void)
{
	MV_RTC_TIME time;
	struct timespec tv;
	struct device *dev;

	mvRtcTimeGet(&time);
	dev = device_create(rtc_class, NULL, -1, NULL, "mv_rtc");

	/* Date which is not in the 21 century will stop the RTC on
 	   00:00:00 - 01/01/2000, write operation will trigger it */
	if ((time.year == 0) && (time.month == 1)  && (time.date == 1)) {
		mvRtcTimeSet(&time);
		printk(KERN_INFO "RTC has been updated!!!\n");
	}

	tv.tv_nsec = 0;
	/* same as in the U-Boot we use the year for century 20 only */
	tv.tv_sec = mktime ( time.year + 2000, time.month,
			time.date, time.hours,
			time.minutes, time.seconds);
	do_settimeofday(&tv);	
	set_rtc = mv_set_rtc;

	rtc_device_register("kw-rtc", dev, &rtc_ops, THIS_MODULE);
	printk("RTC registered\n");

	return 0;
}
开发者ID:jameshilliard,项目名称:prism,代码行数:29,代码来源:rtc.c


示例4: alarm_set_rtc

static int alarm_set_rtc(struct timespec *ts)
{
	struct rtc_time new_rtc_tm;
	struct rtc_device *rtc_dev;
	unsigned long flags;
	int rv = 0;

	rtc_time_to_tm(ts->tv_sec, &new_rtc_tm);
#ifdef CONFIG_RTC_AUTO_PWRON
	pr_info("%s : set rtc %ld %ld - rtc %02d:%02d:%02d %02d/%02d/%04d\n", __func__,
		ts->tv_sec, ts->tv_nsec,
		new_rtc_tm.tm_hour, new_rtc_tm.tm_min,
		new_rtc_tm.tm_sec, new_rtc_tm.tm_mon + 1,
		new_rtc_tm.tm_mday,
		new_rtc_tm.tm_year + 1900);
#endif
	rtc_dev = alarmtimer_get_rtcdev();
	rv = do_settimeofday(ts);
	if (rv < 0)
		return rv;
	if (rtc_dev)
		rv = rtc_set_time(rtc_dev, &new_rtc_tm);

	spin_lock_irqsave(&alarm_slock, flags);
	alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
	wake_up(&alarm_wait_queue);
	spin_unlock_irqrestore(&alarm_slock, flags);

	return rv;
}
开发者ID:Serranove,项目名称:android_kernel_samsung_serranovelte,代码行数:30,代码来源:alarm-dev.c


示例5: afs_osi_SetTime

void
afs_osi_SetTime(osi_timeval_t * tvp)
{
#if defined(AFS_LINUX24_ENV)
    struct timeval tv;
    tv.tv_sec = tvp->tv_sec;
    tv.tv_usec = tvp->tv_usec;

    AFS_STATCNT(osi_SetTime);

    do_settimeofday(&tv);
#else
    extern int (*sys_settimeofdayp) (struct timeval * tv,
                                     struct timezone * tz);

    KERNEL_SPACE_DECL;

    AFS_STATCNT(osi_SetTime);

    TO_USER_SPACE();
    if (sys_settimeofdayp)
        (void)(*sys_settimeofdayp) (tvp, NULL);
    TO_KERNEL_SPACE();
#endif
}
开发者ID:kcbehler,项目名称:openafs-osd,代码行数:25,代码来源:osi_misc.c


示例6: alarm_set_rtc

static int alarm_set_rtc(struct timespec *ts)
{
	struct rtc_time new_rtc_tm;
	struct rtc_device *rtc_dev;
	unsigned long flags;
	int rv = 0;

	if (rtc_local_time)
		rtc_time_to_tm((ts->tv_sec - sys_tz.tz_minuteswest * 60), &new_rtc_tm);
	else
		rtc_time_to_tm(ts->tv_sec, &new_rtc_tm);
	rtc_dev = alarmtimer_get_rtcdev();
	rv = do_settimeofday(ts);
	if (rv < 0)
		return rv;
	if (rtc_dev)
		rv = rtc_set_time(rtc_dev, &new_rtc_tm);

	spin_lock_irqsave(&alarm_slock, flags);
	alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
	wake_up(&alarm_wait_queue);
	spin_unlock_irqrestore(&alarm_slock, flags);

	return rv;
}
开发者ID:tinocyngn,项目名称:sofia-kernel,代码行数:25,代码来源:alarm-dev.c


示例7: do_sys_settimeofday

int do_sys_settimeofday(struct timespec *tv, struct timezone *tz)
{
	static int firsttime = 1;
	int error = 0;

	if (tv && !timespec_valid(tv))
		return -EINVAL;

	error = security_settime(tv, tz);
	if (error)
		return error;

	if (tz) {
		/* SMP safe, global irq locking makes it work. */
		sys_tz = *tz;
		if (firsttime) {
			firsttime = 0;
			if (!tv)
				warp_clock();
		}
	}
	if (tv)
	{
		/* SMP safe, again the code in arch/foo/time.c should
		 * globally block out interrupts when it runs.
		 */
		return do_settimeofday(tv);
	}
	return 0;
}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:30,代码来源:time.c


示例8: rtc_hctosys

/*
 * this function syncs system time with RTC when startup
 * if there is valid time store in RTC static int rtc_hctosys(void)
 */
static int rtc_hctosys(void)
{
	int err;
	struct rtc_time tm;
	struct rtc_device *rtc = rtc_class_open("rtc1");
	if (rtc == NULL) {
		printk("%s: unable to open rtc device (rtc1) for rtc_hctosys\n",
			__FILE__);
		return -ENODEV;
	}

	err = rtc_read_time(rtc, &tm);
	if (err == 0) {
		err = rtc_valid_tm(&tm);
		if (err == 0) {
			struct timespec tv;

			tv.tv_nsec = NSEC_PER_SEC >> 1;

			rtc_tm_to_time(&tm, &tv.tv_sec);

			do_settimeofday(&tv);

			dev_info(rtc->dev.parent,
				"setting system clock to "
				"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
				tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
				tm.tm_hour, tm.tm_min, tm.tm_sec,
				(unsigned int) tv.tv_sec);
		} else { 
开发者ID:mangOH,项目名称:mangOH,代码行数:34,代码来源:rtc_sync.c


示例9: alarm_set_rtc

static int alarm_set_rtc(struct timespec *ts)
{
	struct rtc_time new_rtc_tm;
	struct timespec old_rtc_time;
	struct rtc_device *rtc_dev;
	unsigned long flags;
	int rv = 0;

/* get original rct time */
		getnstimeofday(&old_rtc_time);

	rtc_time_to_tm(ts->tv_sec, &new_rtc_tm);
	rtc_dev = alarmtimer_get_rtcdev();
	rv = do_settimeofday(ts);
	if (rv < 0)
		return rv;
	if (rtc_dev)
		rv = rtc_set_time(rtc_dev, &new_rtc_tm);

	spin_lock_irqsave(&alarm_slock, flags);
	alarm_pending |= ANDROID_ALARM_TIME_CHANGE_MASK;
	delta += ts->tv_sec - old_rtc_time.tv_sec;
	wake_up(&alarm_wait_queue);
	wake_up(&alarm_wait_change_queue);
	spin_unlock_irqrestore(&alarm_slock, flags);

	return rv;
}
开发者ID:ShinySide,项目名称:SM-G361H,代码行数:28,代码来源:alarm-dev.c


示例10: mv_rtc_init

static int mv_rtc_init(void)
{
	MV_RTC_TIME time;
	struct timespec tv;

	switch(mvBoardIdGet()) {
		case RD_88F5181L_VOIP_FXO_GE:
		case RD_88W8660_AP82S_DDR1: 
			return 0;
	}

	mvRtcDS1339TimeGet(&time);

	/* check if the year is invalid - bigger than 2038 */
	if (time.year >= 38) {
 	     time.year=0;
 	     mvRtcDS1339TimeSet(&time);
 	     printk(KERN_INFO "RTC has been updated!!!");
 	  }
 	    
	tv.tv_nsec = 0;
	/* same as in the U-Boot we use the year for century 20 only */
	tv.tv_sec = mktime ( time.year + 2000, time.month,
        			time.date, time.hours,
        			time.minutes, time.seconds);
	do_settimeofday(&tv);
	set_rtc = mv_set_rtc;
	register_rtc(&rtc_ops);
	printk("RTC registered\n");

	return 0;
}
开发者ID:KevinCabana,项目名称:xpenology,代码行数:32,代码来源:rtc.c


示例11: rtc_sync_adjust

static void rtc_sync_adjust(void)
{
	struct rtc_time		rtc_time;
	static time_t		rtc_time_t;
	struct timespec		ts_system, ts_rtc, ts_delta, ts_delta_delta;

	getnstimeofday(&ts_system);
	s3c_rtc_gettime(NULL, &rtc_time);

	rtc_tm_to_time(&rtc_time, &rtc_time_t);
	/* RTC precision is 1 second; adjust delta for avg 1/2 sec err */
	set_normalized_timespec(&ts_rtc, rtc_time_t, NSEC_PER_SEC>>1);
	
	ts_delta = timespec_sub(ts_system, ts_rtc);
	ts_delta_delta = timespec_sub (ts_saved_delta, ts_delta);

	if (ts_delta_delta.tv_sec < -2 || ts_delta_delta.tv_sec >= 2)
	{
		/* 
		 * A differential beteen system time and rtc is over 2 second
		 * , let's adjust system time and save time delta
		 */
		set_normalized_timespec(&ts_system, rtc_time_t + ts_saved_delta.tv_sec, ts_saved_delta.tv_nsec);
		do_settimeofday(&ts_system);
		printk ("RTC_SYNC: adjust system time from rtc\n");
	}
}
开发者ID:rubensollie,项目名称:Eclair-Kernel,代码行数:27,代码来源:rtc-s3c.c


示例12: rtc_hctosys

int rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	err = rtc_read_time(rtc, &tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: unable to read the hardware clock\n");
		goto err_read;

	}

	/*
	 * Force update rtc year time to 2014
	 * (The release year of device)
	 */
	tm.tm_year = 114;

	err = rtc_valid_tm(&tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: invalid date/time\n");
		goto err_invalid;
	}

	rtc_tm_to_time(&tm, &tv.tv_sec);

	err = do_settimeofday(&tv);

	dev_info(rtc->dev.parent,
		"setting system clock to "
		"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour, tm.tm_min, tm.tm_sec,
		(unsigned int) tv.tv_sec);

err_invalid:
err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	return err;
}

late_initcall(rtc_hctosys);
开发者ID:Serranove,项目名称:android_kernel_samsung_serranovelte,代码行数:58,代码来源:hctosys.c


示例13: rtc_hctosys

int rtc_hctosys(void)
{
	int err = -ENODEV;
	struct rtc_time tm;
	struct timespec tv = {
		.tv_nsec = NSEC_PER_SEC >> 1,
	};
	struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE);

	if (rtc == NULL) {
		pr_err("%s: unable to open rtc device (%s)\n",
			__FILE__, CONFIG_RTC_HCTOSYS_DEVICE);
		goto err_open;
	}

	err = rtc_read_time(rtc, &tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: unable to read the hardware clock\n");
		goto err_read;

	}

	err = rtc_valid_tm(&tm);
	if (err) {
		dev_err(rtc->dev.parent,
			"hctosys: invalid date/time\n");
		goto err_invalid;
	}

	rtc_tm_to_time(&tm, &tv.tv_sec);

	if (tv.tv_sec < 86400) {
		tv.tv_sec = 86400;
		pr_info("%s: Make sure the boot time starts from 86400 or more to avoid system server crash due to alarm trigger immediately\n", __FILE__);
	}
	do_settimeofday(&tv);

	dev_info(rtc->dev.parent,
		"setting system clock to "
		"%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n",
		tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
		tm.tm_hour, tm.tm_min, tm.tm_sec,
		(unsigned int) tv.tv_sec);

err_invalid:
err_read:
	rtc_class_close(rtc);

err_open:
	rtc_hctosys_ret = err;

	return err;
}

late_initcall(rtc_hctosys);
开发者ID:FreeProjectAce,项目名称:protou_kernel,代码行数:56,代码来源:hctosys.c


示例14: do_adj_guesttime

/*
 * Set guest time to host UTC time.
 */
static inline void do_adj_guesttime(u64 hosttime)
{
	s64 host_tns;
	struct timespec host_ts;

	host_tns = (hosttime - WLTIMEDELTA) * 100;
	host_ts = ns_to_timespec(host_tns);

	do_settimeofday(&host_ts);
}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:13,代码来源:hv_utils.c


示例15: rtc_sync_systime

static void rtc_sync_systime(struct rtc_time *tm)
{
	unsigned long time;
	struct timespec new_tv;

	rtc_tm_to_time(tm, &time);
	new_tv.tv_nsec = xtime.tv_nsec;
	new_tv.tv_sec = time;	
	do_settimeofday(&new_tv);
}
开发者ID:abgoyal,项目名称:OpenX2-kernel-original,代码行数:10,代码来源:rtc-ami8563.c


示例16: afs_osi_SetTime

void
afs_osi_SetTime(osi_timeval_t * tvp)
{
    struct timespec tv;
    tv.tv_sec = tvp->tv_sec;
    tv.tv_nsec = tvp->tv_usec * NSEC_PER_USEC;

    AFS_STATCNT(osi_SetTime);

    do_settimeofday(&tv);
}
开发者ID:bagdxk,项目名称:openafs,代码行数:11,代码来源:osi_misc.c


示例17: empeg_state_restore

int empeg_state_restore (unsigned char *buffer)
{
	/* EMPEG_FLASHBASE+0x4000 to +0x5fff is the space used for
	   the power-down state saving: we work through here until
	   we find the last entry which has a valid CRC - this is
	   the one we use */
	int a,calculated_crc,stored_crc, result = 0;
	struct timeval t;

	/* Find last valid block */
	for(a=(STATE_BLOCKS-1);a>=0;a--) {
		volatile unsigned short *blockptr=STATE_BASE+(a*(STATE_BLOCK_SIZE/sizeof(short)));

		/* See if this has a good CRC */
		calculated_crc=state_makecrc((unsigned char*)blockptr,STATE_BLOCK_SIZE-2);
		stored_crc=blockptr[(STATE_BLOCK_SIZE/sizeof(short))-1];

		if (calculated_crc==stored_crc) {
			/* Copy from flash */
			memcpy(buffer,(void*)blockptr,STATE_BLOCK_SIZE);
			
			break;
			}
	}

	/* Nothing valid found? Return nulls */
#if 1	/* FIXME: 1 == normal ; 0 == nuke savearea */
	if (a<0)
#else
	dirty = 1;
	printk("empeg_state_restore: NUKED\n");
#endif
	{

		result = 1;	// failed
		memset(buffer,0,STATE_BLOCK_SIZE);
		printk("empeg_state_restore: FAILED\n");
	}

	/* Later empegs have an RTC */
	if (empeg_hardwarerevision()<6) {
		/* Before we go: the first 4 bytes of the block are the elapsed
		   unixtime: set it */
		unixtime=t.tv_sec=*((unsigned int*)buffer);
		t.tv_usec=0;
		do_settimeofday(&t);
	} else {				// Added by tman
		unixtime=xtime.tv_sec;		// Added by tman
	}

	/* Get power-on time */
	powerontime=*((unsigned int*)(buffer+4));
	return result;
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:54,代码来源:empeg_state.c


示例18: sys_stime

asmlinkage long sys_stime(time_t *tptr)
{
   struct timespec tv;

   if (!capable(CAP_SYS_TIME))
      return -EPERM;
   if (get_user(tv.tv_sec, tptr))
      return -EFAULT;

   tv.tv_nsec = 0;
   do_settimeofday(&tv);
   return 0;
}
开发者ID:OS2World,项目名称:DRV-LXAPI32,代码行数:13,代码来源:lk_time.c


示例19: mpc834x_rtc_hookup

static int __init mpc834x_rtc_hookup(void)
{
	struct timespec tv;

	ppc_md.get_rtc_time = ds1374_get_rtc_time;
	ppc_md.set_rtc_time = ds1374_set_rtc_time;

	tv.tv_nsec = 0;
	tv.tv_sec = (ppc_md.get_rtc_time) ();
	do_settimeofday(&tv);

	return 0;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:13,代码来源:mpc834x_sys.c


示例20: l4x_rtc_update_time

static void l4x_rtc_update_time(struct work_struct *work)
{
	struct timespec ts;
	u64 current_time;

	l4x_rtc_update_offset();
	current_time = offset_to_realtime + l4rtc_get_timer();

	ts.tv_nsec = do_div(current_time, 1000000000);
	ts.tv_sec = current_time;

	do_settimeofday(&ts);
}
开发者ID:michas2,项目名称:l4re-snapshot,代码行数:13,代码来源:rtc.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ do_shutdown函数代码示例发布时间:2022-05-30
下一篇:
C++ do_sendfile函数代码示例发布时间: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