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

« back to all changes in this revision

Viewing changes to lib/stat-time.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
/* stat-related time functions.
2
2
 
3
 
   Copyright (C) 2005, 2007, 2009-2011 Free Software Foundation, Inc.
 
3
   Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc.
4
4
 
5
5
   This program is free software: you can redistribute it and/or modify
6
6
   it under the terms of the GNU General Public License as published by
23
23
#include <sys/stat.h>
24
24
#include <time.h>
25
25
 
 
26
_GL_INLINE_HEADER_BEGIN
 
27
#ifndef _GL_STAT_TIME_INLINE
 
28
# define _GL_STAT_TIME_INLINE _GL_INLINE
 
29
#endif
 
30
 
26
31
/* STAT_TIMESPEC (ST, ST_XTIM) is the ST_XTIM member for *ST of type
27
32
   struct timespec, if available.  If not, then STAT_TIMESPEC_NS (ST,
28
33
   ST_XTIM) is the nanosecond component of the ST_XTIM member for *ST,
46
51
#endif
47
52
 
48
53
/* Return the nanosecond component of *ST's access time.  */
49
 
static inline long int
 
54
_GL_STAT_TIME_INLINE long int
50
55
get_stat_atime_ns (struct stat const *st)
51
56
{
52
57
# if defined STAT_TIMESPEC
59
64
}
60
65
 
61
66
/* Return the nanosecond component of *ST's status change time.  */
62
 
static inline long int
 
67
_GL_STAT_TIME_INLINE long int
63
68
get_stat_ctime_ns (struct stat const *st)
64
69
{
65
70
# if defined STAT_TIMESPEC
72
77
}
73
78
 
74
79
/* Return the nanosecond component of *ST's data modification time.  */
75
 
static inline long int
 
80
_GL_STAT_TIME_INLINE long int
76
81
get_stat_mtime_ns (struct stat const *st)
77
82
{
78
83
# if defined STAT_TIMESPEC
85
90
}
86
91
 
87
92
/* Return the nanosecond component of *ST's birth time.  */
88
 
static inline long int
 
93
_GL_STAT_TIME_INLINE long int
89
94
get_stat_birthtime_ns (struct stat const *st)
90
95
{
91
96
# if defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
100
105
}
101
106
 
102
107
/* Return *ST's access time.  */
103
 
static inline struct timespec
 
108
_GL_STAT_TIME_INLINE struct timespec
104
109
get_stat_atime (struct stat const *st)
105
110
{
106
111
#ifdef STAT_TIMESPEC
114
119
}
115
120
 
116
121
/* Return *ST's status change time.  */
117
 
static inline struct timespec
 
122
_GL_STAT_TIME_INLINE struct timespec
118
123
get_stat_ctime (struct stat const *st)
119
124
{
120
125
#ifdef STAT_TIMESPEC
128
133
}
129
134
 
130
135
/* Return *ST's data modification time.  */
131
 
static inline struct timespec
 
136
_GL_STAT_TIME_INLINE struct timespec
132
137
get_stat_mtime (struct stat const *st)
133
138
{
134
139
#ifdef STAT_TIMESPEC
143
148
 
144
149
/* Return *ST's birth time, if available; otherwise return a value
145
150
   with tv_sec and tv_nsec both equal to -1.  */
146
 
static inline struct timespec
 
151
_GL_STAT_TIME_INLINE struct timespec
147
152
get_stat_birthtime (struct stat const *st)
148
153
{
149
154
  struct timespec t;
155
160
  t.tv_sec = st->st_birthtime;
156
161
  t.tv_nsec = st->st_birthtimensec;
157
162
#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
158
 
  /* Woe32 native platforms (but not Cygwin) put the "file creation
 
163
  /* Native Windows platforms (but not Cygwin) put the "file creation
159
164
     time" in st_ctime (!).  See
160
165
     <http://msdn2.microsoft.com/de-de/library/14h5k7ff(VS.80).aspx>.  */
161
166
  t.tv_sec = st->st_ctime;
186
191
  return t;
187
192
}
188
193
 
 
194
_GL_INLINE_HEADER_END
 
195
 
189
196
#endif