当前位置: 首页>>代码示例>>C++>>正文


C++ do_settimeofday函数代码示例

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


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


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