~ubuntu-branches/ubuntu/trusty/patch/trusty-security

« back to all changes in this revision

Viewing changes to lib/timespec.h

  • Committer: Package Import Robot
  • Author(s): Christoph Berg
  • Date: 2013-01-03 17:34:45 UTC
  • mto: (6.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20130103173445-5vf8qmnfgd7ug67h
Tags: upstream-2.7.1
ImportĀ upstreamĀ versionĀ 2.7.1

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
57
62
          : (int) (a.tv_nsec - b.tv_nsec));
58
63
}
59
64
 
 
65
/* Return -1, 0, 1, depending on the sign of A.  A.tv_nsec must be
 
66
   nonnegative.  */
 
67
_GL_TIMESPEC_INLINE int
 
68
timespec_sign (struct timespec a)
 
69
{
 
70
  return a.tv_sec < 0 ? -1 : a.tv_sec || a.tv_nsec;
 
71
}
 
72
 
 
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;
 
79
 
 
80
/* Return an approximation to A, of type 'double'.  */
 
81
_GL_TIMESPEC_INLINE double
 
82
timespectod (struct timespec a)
 
83
{
 
84
  return a.tv_sec + a.tv_nsec / 1e9;
 
85
}
 
86
 
60
87
void gettime (struct timespec *);
61
88
int settime (struct timespec const *);
62
89
 
 
90
_GL_INLINE_HEADER_END
 
91
 
63
92
#endif