Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
time.c File Reference
#include <linux/export.h>
#include <linux/timex.h>
#include <linux/capability.h>
#include <linux/timekeeper_internal.h>
#include <linux/errno.h>
#include <linux/syscalls.h>
#include <linux/security.h>
#include <linux/fs.h>
#include <linux/math64.h>
#include <linux/ptrace.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include "timeconst.h"

Go to the source code of this file.

Functions

 EXPORT_SYMBOL (sys_tz)
 
 SYSCALL_DEFINE2 (gettimeofday, struct timeval __user *, tv, struct timezone __user *, tz)
 
int do_sys_settimeofday (const struct timespec *tv, const struct timezone *tz)
 
 SYSCALL_DEFINE2 (settimeofday, struct timeval __user *, tv, struct timezone __user *, tz)
 
 SYSCALL_DEFINE1 (adjtimex, struct timex __user *, txc_p)
 
struct timespec current_fs_time (struct super_block *sb)
 
 EXPORT_SYMBOL (current_fs_time)
 
unsigned int jiffies_to_msecs (const unsigned long j)
 
 EXPORT_SYMBOL (jiffies_to_msecs)
 
unsigned int jiffies_to_usecs (const unsigned long j)
 
 EXPORT_SYMBOL (jiffies_to_usecs)
 
struct timespec timespec_trunc (struct timespec t, unsigned gran)
 
 EXPORT_SYMBOL (timespec_trunc)
 
unsigned long mktime (const unsigned int year0, const unsigned int mon0, const unsigned int day, const unsigned int hour, const unsigned int min, const unsigned int sec)
 
 EXPORT_SYMBOL (mktime)
 
void set_normalized_timespec (struct timespec *ts, time_t sec, s64 nsec)
 
 EXPORT_SYMBOL (set_normalized_timespec)
 
struct timespec ns_to_timespec (const s64 nsec)
 
 EXPORT_SYMBOL (ns_to_timespec)
 
struct timeval ns_to_timeval (const s64 nsec)
 
 EXPORT_SYMBOL (ns_to_timeval)
 
unsigned long msecs_to_jiffies (const unsigned int m)
 
 EXPORT_SYMBOL (msecs_to_jiffies)
 
unsigned long usecs_to_jiffies (const unsigned int u)
 
 EXPORT_SYMBOL (usecs_to_jiffies)
 
unsigned long timespec_to_jiffies (const struct timespec *value)
 
 EXPORT_SYMBOL (timespec_to_jiffies)
 
void jiffies_to_timespec (const unsigned long jiffies, struct timespec *value)
 
 EXPORT_SYMBOL (jiffies_to_timespec)
 
unsigned long timeval_to_jiffies (const struct timeval *value)
 
 EXPORT_SYMBOL (timeval_to_jiffies)
 
void jiffies_to_timeval (const unsigned long jiffies, struct timeval *value)
 
 EXPORT_SYMBOL (jiffies_to_timeval)
 
clock_t jiffies_to_clock_t (unsigned long x)
 
 EXPORT_SYMBOL (jiffies_to_clock_t)
 
unsigned long clock_t_to_jiffies (unsigned long x)
 
 EXPORT_SYMBOL (clock_t_to_jiffies)
 
u64 jiffies_64_to_clock_t (u64 x)
 
 EXPORT_SYMBOL (jiffies_64_to_clock_t)
 
u64 nsec_to_clock_t (u64 x)
 
u64 nsecs_to_jiffies64 (u64 n)
 
unsigned long nsecs_to_jiffies (u64 n)
 
struct timespec timespec_add_safe (const struct timespec lhs, const struct timespec rhs)
 

Variables

struct timezone sys_tz
 

Function Documentation

unsigned long clock_t_to_jiffies ( unsigned long  x)

Definition at line 586 of file time.c.

struct timespec current_fs_time ( struct super_block sb)
read

current_fs_time - Return FS time : Superblock.

Return the current time truncated to the time granularity supported by the fs.

Definition at line 222 of file time.c.

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

Definition at line 153 of file time.c.

EXPORT_SYMBOL ( sys_tz  )
EXPORT_SYMBOL ( current_fs_time  )
EXPORT_SYMBOL ( jiffies_to_msecs  )
EXPORT_SYMBOL ( jiffies_to_usecs  )
EXPORT_SYMBOL ( timespec_trunc  )
EXPORT_SYMBOL ( mktime  )
EXPORT_SYMBOL ( set_normalized_timespec  )
EXPORT_SYMBOL ( ns_to_timespec  )
EXPORT_SYMBOL ( ns_to_timeval  )
EXPORT_SYMBOL ( msecs_to_jiffies  )
EXPORT_SYMBOL ( usecs_to_jiffies  )
EXPORT_SYMBOL ( timespec_to_jiffies  )
EXPORT_SYMBOL ( jiffies_to_timespec  )
EXPORT_SYMBOL ( timeval_to_jiffies  )
EXPORT_SYMBOL ( jiffies_to_timeval  )
EXPORT_SYMBOL ( jiffies_to_clock_t  )
EXPORT_SYMBOL ( clock_t_to_jiffies  )
EXPORT_SYMBOL ( jiffies_64_to_clock_t  )
u64 jiffies_64_to_clock_t ( u64  x)

Definition at line 603 of file time.c.

clock_t jiffies_to_clock_t ( unsigned long  x)

Definition at line 572 of file time.c.

unsigned int jiffies_to_msecs ( const unsigned long  j)
inline

Definition at line 235 of file time.c.

void jiffies_to_timespec ( const unsigned long  jiffies,
struct timespec value 
)

Definition at line 514 of file time.c.

void jiffies_to_timeval ( const unsigned long  jiffies,
struct timeval value 
)

Definition at line 555 of file time.c.

unsigned int jiffies_to_usecs ( const unsigned long  j)
inline

Definition at line 251 of file time.c.

unsigned long mktime ( const unsigned int  year0,
const unsigned int  mon0,
const unsigned int  day,
const unsigned int  hour,
const unsigned int  min,
const unsigned int  sec 
)

Definition at line 313 of file time.c.

unsigned long msecs_to_jiffies ( const unsigned int  m)

Definition at line 428 of file time.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.

u64 nsec_to_clock_t ( u64  x)

Definition at line 625 of file time.c.

unsigned long nsecs_to_jiffies ( u64  n)

nsecs_to_jiffies - Convert nsecs in u64 to jiffies


: nsecs in u64

Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64. And this doesn't return MAX_JIFFY_OFFSET since this function is designed for scheduler, not for use in device drivers to calculate timeout value.

note: NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512) ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years

Definition at line 684 of file time.c.

u64 nsecs_to_jiffies64 ( u64  n)

nsecs_to_jiffies64 - Convert nsecs in u64 to jiffies64


: nsecs in u64

Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64. And this doesn't return MAX_JIFFY_OFFSET since this function is designed for scheduler, not for use in device drivers to calculate timeout value.

note: NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512) ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years

Definition at line 654 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.

SYSCALL_DEFINE1 ( adjtimex  ,
struct timex __user ,
txc_p   
)

Definition at line 200 of file time.c.

SYSCALL_DEFINE2 ( gettimeofday  ,
struct timeval __user ,
tv  ,
struct timezone __user ,
tz   
)

Definition at line 101 of file time.c.

SYSCALL_DEFINE2 ( settimeofday  ,
struct timeval __user ,
tv  ,
struct timezone __user ,
tz   
)

Definition at line 179 of file time.c.

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

Definition at line 693 of file time.c.

unsigned long timespec_to_jiffies ( const struct timespec value)

Definition at line 497 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.

unsigned long timeval_to_jiffies ( const struct timeval value)

Definition at line 540 of file time.c.

unsigned long usecs_to_jiffies ( const unsigned int  u)

Definition at line 470 of file time.c.

Variable Documentation

struct timezone sys_tz

Definition at line 50 of file time.c.