~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/timespec.h

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* timespec -- System time interface
2
2
 
3
 
   Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2011 Free Software
 
3
   Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2012 Free Software
4
4
   Foundation, Inc.
5
5
 
6
6
   This program is free software: you can redistribute it and/or modify
21
21
 
22
22
# include <time.h>
23
23
 
 
24
_GL_INLINE_HEADER_BEGIN
 
25
#ifndef _GL_TIMESPEC_INLINE
 
26
# define _GL_TIMESPEC_INLINE _GL_INLINE
 
27
#endif
 
28
 
24
29
/* Return negative, zero, positive if A < B, A == B, A > B, respectively.
25
30
 
26
31
   For each time stamp T, this code assumes that either:
49
54
 
50
55
   The (int) cast avoids a gcc -Wconversion warning.  */
51
56
 
52
 
static inline int
 
57
_GL_TIMESPEC_INLINE int
53
58
timespec_cmp (struct timespec a, struct timespec b)
54
59
{
55
60
  return (a.tv_sec < b.tv_sec ? -1
59
64
 
60
65
/* Return -1, 0, 1, depending on the sign of A.  A.tv_nsec must be
61
66
   nonnegative.  */
62
 
static inline int
 
67
_GL_TIMESPEC_INLINE int
63
68
timespec_sign (struct timespec a)
64
69
{
65
70
  return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec;
66
71
}
67
72
 
68
 
struct timespec timespec_add (struct timespec, struct timespec);
69
 
struct timespec timespec_sub (struct timespec, struct timespec);
70
 
struct timespec dtotimespec (double);
 
73
struct timespec timespec_add (struct timespec, struct timespec)
 
74
  _GL_ATTRIBUTE_CONST;
 
75
struct timespec timespec_sub (struct timespec, struct timespec)
 
76
  _GL_ATTRIBUTE_CONST;
 
77
struct timespec dtotimespec (double)
 
78
  _GL_ATTRIBUTE_CONST;
71
79
 
72
80
/* Return an approximation to A, of type 'double'.  */
73
 
static inline double
 
81
_GL_TIMESPEC_INLINE double
74
82
timespectod (struct timespec a)
75
83
{
76
84
  return a.tv_sec + a.tv_nsec / 1e9;
79
87
void gettime (struct timespec *);
80
88
int settime (struct timespec const *);
81
89
 
 
90
_GL_INLINE_HEADER_END
 
91
 
82
92
#endif