Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234611
b: refs/heads/master
c: c528f7c
h: refs/heads/master
i:
  234609: 4eea3ed
  234607: 918c432
v: v3
  • Loading branch information
John Stultz authored and Thomas Gleixner committed Feb 2, 2011
1 parent 2e60008 commit 529ba8c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0061748dd2400d0bcd4d49d258db5d7b5d106ca0
refs/heads/master: c528f7c6c208f1fae6b4025957173dec045e5f21
1 change: 1 addition & 0 deletions trunk/include/linux/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
extern int timekeeping_valid_for_hres(void);
extern u64 timekeeping_max_deferment(void);
extern void timekeeping_leap_insert(int leapsecond);
extern int timekeeping_inject_offset(struct timespec *ts);

struct tms;
extern void do_sys_times(struct tms *);
Expand Down
36 changes: 36 additions & 0 deletions trunk/kernel/time/timekeeping.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,42 @@ int do_settimeofday(const struct timespec *tv)

EXPORT_SYMBOL(do_settimeofday);


/**
* timekeeping_inject_offset - Adds or subtracts from the current time.
* @tv: pointer to the timespec variable containing the offset
*
* Adds or subtracts an offset value from the current time.
*/
int timekeeping_inject_offset(struct timespec *ts)
{
unsigned long flags;

if ((unsigned long)ts->tv_nsec >= NSEC_PER_SEC)
return -EINVAL;

write_seqlock_irqsave(&xtime_lock, flags);

timekeeping_forward_now();

xtime = timespec_add(xtime, *ts);
wall_to_monotonic = timespec_sub(wall_to_monotonic, *ts);

timekeeper.ntp_error = 0;
ntp_clear();

update_vsyscall(&xtime, &wall_to_monotonic, timekeeper.clock,
timekeeper.mult);

write_sequnlock_irqrestore(&xtime_lock, flags);

/* signal hrtimers about time change */
clock_was_set();

return 0;
}
EXPORT_SYMBOL(timekeeping_inject_offset);

/**
* change_clocksource - Swaps clocksources if a new one is available
*
Expand Down

0 comments on commit 529ba8c

Please sign in to comment.