Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
time.h File Reference
#include <linux/cache.h>
#include <linux/seqlock.h>
#include <linux/math64.h>
#include <uapi/linux/time.h>

Go to the source code of this file.

Data Structures

struct  tm
 

Macros

#define MSEC_PER_SEC   1000L
 
#define USEC_PER_MSEC   1000L
 
#define NSEC_PER_USEC   1000L
 
#define NSEC_PER_MSEC   1000000L
 
#define USEC_PER_SEC   1000000L
 
#define NSEC_PER_SEC   1000000000L
 
#define FSEC_PER_SEC   1000000000000000LL
 
#define TIME_T_MAX   (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)
 
#define KTIME_MAX   ((s64)~((u64)1 << 63))
 
#define KTIME_SEC_MAX   LONG_MAX
 
#define CURRENT_TIME   (current_kernel_time())
 
#define CURRENT_TIME_SEC   ((struct timespec) { get_seconds(), 0 })
 
#define do_posix_clock_monotonic_gettime(ts)   ktime_get_ts(ts)
 

Functions

unsigned long mktime (const unsigned int year, const unsigned int mon, const unsigned int day, const unsigned int hour, const unsigned int min, const unsigned int sec)
 
void set_normalized_timespec (struct timespec *ts, time_t sec, s64 nsec)
 
struct timespec timespec_add_safe (const struct timespec lhs, const struct timespec rhs)
 
void read_persistent_clock (struct timespec *ts)
 
void read_boot_clock (struct timespec *ts)
 
int update_persistent_clock (struct timespec now)
 
void timekeeping_init (void)
 
unsigned long get_seconds (void)
 
struct timespec current_kernel_time (void)
 
struct timespec __current_kernel_time (void)
 
struct timespec get_monotonic_coarse (void)
 
void get_xtime_and_monotonic_and_sleep_offset (struct timespec *xtim, struct timespec *wtom, struct timespec *sleep)
 
void timekeeping_inject_sleeptime (struct timespec *delta)
 
void do_gettimeofday (struct timeval *tv)
 
int do_settimeofday (const struct timespec *tv)
 
int do_sys_settimeofday (const struct timespec *tv, const struct timezone *tz)
 
long do_utimes (int dfd, const char __user *filename, struct timespec *times, int flags)
 
int do_setitimer (int which, struct itimerval *value, struct itimerval *ovalue)
 
unsigned int alarm_setitimer (unsigned int seconds)
 
int do_getitimer (int which, struct itimerval *value)
 
void getnstimeofday (struct timespec *tv)
 
void getrawmonotonic (struct timespec *ts)
 
void getnstime_raw_and_real (struct timespec *ts_raw, struct timespec *ts_real)
 
void getboottime (struct timespec *ts)
 
void monotonic_to_bootbased (struct timespec *ts)
 
void get_monotonic_boottime (struct timespec *ts)
 
struct timespec timespec_trunc (struct timespec t, unsigned gran)
 
int timekeeping_valid_for_hres (void)
 
u64 timekeeping_max_deferment (void)
 
int timekeeping_inject_offset (struct timespec *ts)
 
void do_sys_times (struct tms *)
 
void time_to_tm (time_t totalsecs, int offset, struct tm *result)
 
struct timespec ns_to_timespec (const s64 nsec)
 
struct timeval ns_to_timeval (const s64 nsec)
 

Variables

struct timezone sys_tz
 
int timekeeping_suspended
 

Macro Definition Documentation

#define CURRENT_TIME   (current_kernel_time())

Definition at line 132 of file time.h.

#define CURRENT_TIME_SEC   ((struct timespec) { get_seconds(), 0 })

Definition at line 133 of file time.h.

#define do_posix_clock_monotonic_gettime (   ts)    ktime_get_ts(ts)

Definition at line 154 of file time.h.

#define FSEC_PER_SEC   1000000000000000LL

Definition at line 18 of file time.h.

#define KTIME_MAX   ((s64)~((u64)1 << 63))

Definition at line 87 of file time.h.

#define KTIME_SEC_MAX   LONG_MAX

Definition at line 91 of file time.h.

#define MSEC_PER_SEC   1000L

Definition at line 12 of file time.h.

#define NSEC_PER_MSEC   1000000L

Definition at line 15 of file time.h.

#define NSEC_PER_SEC   1000000000L

Definition at line 17 of file time.h.

#define NSEC_PER_USEC   1000L

Definition at line 14 of file time.h.

#define TIME_T_MAX   (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1)

Definition at line 20 of file time.h.

#define USEC_PER_MSEC   1000L

Definition at line 13 of file time.h.

#define USEC_PER_SEC   1000000L

Definition at line 16 of file time.h.

Function Documentation

struct timespec __current_kernel_time ( void  )
read

Definition at line 1260 of file timekeeping.c.

unsigned int alarm_setitimer ( unsigned int  seconds)

alarm_setitimer - set alarm in seconds

: number of seconds until alarm 0 disables the alarm

Returns the remaining time in seconds of a pending timer or 0 when the timer is not active.

On 32 bit machines the seconds value is limited to (INT_MAX/2) to avoid negative timeval settings which would cause immediate expiry.

Definition at line 253 of file itimer.c.

struct timespec current_kernel_time ( void  )
read

Definition at line 1267 of file timekeeping.c.

int do_getitimer ( int  which,
struct itimerval value 
)

Definition at line 79 of file itimer.c.

void do_gettimeofday ( struct timeval tv)

do_gettimeofday - Returns the time of day in a timeval : pointer to the timeval to be set

NOTE: Users should be converted to using getnstimeofday()

Definition at line 346 of file timekeeping.c.

int do_setitimer ( int  which,
struct itimerval value,
struct itimerval ovalue 
)

Definition at line 190 of file itimer.c.

int do_settimeofday ( const struct timespec tv)

do_settimeofday - Sets the time of day : pointer to the timespec variable containing the new time

Sets the time of day to the new time and update NTP and notify hrtimers

Definition at line 362 of file timekeeping.c.

int do_sys_settimeofday ( const struct timespec tv,
const struct timezone tz 
)

Definition at line 153 of file time.c.

void do_sys_times ( struct tms )

Definition at line 1044 of file sys.c.

long do_utimes ( int  dfd,
const char __user filename,
struct timespec times,
int  flags 
)

Definition at line 129 of file utimes.c.

void get_monotonic_boottime ( struct timespec ts)

get_monotonic_boottime - Returns monotonic time since boot : pointer to the timespec to be set

Returns the monotonic time since boot in a timespec.

This is similar to CLOCK_MONTONIC/ktime_get_ts, but also includes the time spent in suspend.

Definition at line 1199 of file timekeeping.c.

struct timespec get_monotonic_coarse ( void  )
read

Definition at line 1283 of file timekeeping.c.

unsigned long get_seconds ( void  )

Definition at line 1252 of file timekeeping.c.

void get_xtime_and_monotonic_and_sleep_offset ( struct timespec xtim,
struct timespec wtom,
struct timespec sleep 
)

get_xtime_and_monotonic_and_sleep_offset() - get xtime, wall_to_monotonic, and sleep offsets. : pointer to timespec to be set with xtime : pointer to timespec to be set with wall_to_monotonic : pointer to timespec to be set with time in suspend

Definition at line 1320 of file timekeeping.c.

void getboottime ( struct timespec ts)

getboottime - Return the real time of system boot. : pointer to the timespec to be set

Returns the wall-time of boot in a timespec.

This is based on the wall_to_monotonic offset and the total suspend time. Calls to settimeofday will affect the value returned (which basically means that however wrong your real time clock is at boot time, you get the right time here).

Definition at line 1176 of file timekeeping.c.

void getnstime_raw_and_real ( struct timespec ts_raw,
struct timespec ts_real 
)
void getnstimeofday ( struct timespec ts)

getnstimeofday - Returns the time of day in a timespec : pointer to the timespec to be set

Returns the time of day in a timespec.

Definition at line 228 of file timekeeping.c.

void getrawmonotonic ( struct timespec ts)

getrawmonotonic - Returns the raw monotonic time in a timespec : pointer to the timespec to be set

Returns the raw monotonic time (completely un-modified by ntp)

Definition at line 503 of file timekeeping.c.

unsigned long mktime ( const unsigned int  year,
const unsigned int  mon,
const unsigned int  day,
const unsigned int  hour,
const unsigned int  min,
const unsigned int  sec 
)

Definition at line 313 of file time.c.

void monotonic_to_bootbased ( struct timespec ts)

monotonic_to_bootbased - Convert the monotonic time to boot based. : pointer to the timespec to be converted

Definition at line 1244 of file timekeeping.c.

struct timespec ns_to_timespec ( const s64  nsec)
read

ns_to_timespec - Convert nanoseconds to timespec : the nanoseconds value to be converted

Returns the timespec representation of the nsec parameter.

Definition at line 377 of file time.c.

struct timeval ns_to_timeval ( const s64  nsec)
read

ns_to_timeval - Convert nanoseconds to timeval : the nanoseconds value to be converted

Returns the timeval representation of the nsec parameter.

Definition at line 402 of file time.c.

void read_boot_clock ( struct timespec ts)

Definition at line 110 of file time.c.

void read_persistent_clock ( struct timespec ts)

Definition at line 118 of file time.c.

void set_normalized_timespec ( struct timespec ts,
time_t  sec,
s64  nsec 
)

set_normalized_timespec - set timespec sec and nsec parts and normalize

: pointer to timespec variable to be set : seconds to set : nanoseconds to set

Set seconds and nanoseconds field of a timespec variable and normalize to the timespec storage format

Note: The tv_nsec part is always in the range of 0 <= tv_nsec < NSEC_PER_SEC For negative values only the tv_sec field is negative !

Definition at line 349 of file time.c.

void time_to_tm ( time_t  totalsecs,
int  offset,
struct tm result 
)

time_to_tm - converts the calendar time to local broken-down time

the number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC). offset seconds adding to totalsecs.

Returns
pointer to struct tm variable to receive broken-down time

Definition at line 77 of file timeconv.c.

void timekeeping_init ( void  )

Definition at line 591 of file timekeeping.c.

int timekeeping_inject_offset ( struct timespec ts)

timekeeping_inject_offset - Adds or subtracts from the current time. : pointer to the timespec variable containing the offset

Adds or subtracts an offset value from the current time.

Definition at line 400 of file timekeeping.c.

void timekeeping_inject_sleeptime ( struct timespec delta)

timekeeping_inject_sleeptime - Adds suspend interval to timeekeeping values : pointer to a timespec delta value

This hook is for architectures that cannot support read_persistent_clock because their RTC/persistent clock is only accessible when irqs are enabled.

This function should only be called by rtc_resume(), and allows a suspend offset to be injected into the timekeeping values.

Definition at line 673 of file timekeeping.c.

u64 timekeeping_max_deferment ( void  )

timekeeping_max_deferment - Returns max time the clocksource can be deferred

Definition at line 542 of file timekeeping.c.

int timekeeping_valid_for_hres ( void  )

timekeeping_valid_for_hres - Check if timekeeping is suitable for hres

Definition at line 523 of file timekeeping.c.

struct timespec timespec_add_safe ( const struct timespec  lhs,
const struct timespec  rhs 
)
read

Definition at line 693 of file time.c.

struct timespec timespec_trunc ( struct timespec  t,
unsigned  gran 
)
read

timespec_trunc - Truncate timespec to a granularity : Timespec : Granularity in ns.

Truncate a timespec to a granularity. gran must be smaller than a second. Always rounds down.

This function should be only used for timestamps returned by current_kernel_time() or CURRENT_TIME, not with do_gettimeofday() because it doesn't handle the better resolution of the latter.

Definition at line 279 of file time.c.

int update_persistent_clock ( struct timespec  now)

Definition at line 113 of file time.c.

Variable Documentation

struct timezone sys_tz

Definition at line 50 of file time.c.

int timekeeping_suspended

Definition at line 35 of file timekeeping.c.