This file is indexed.

/usr/include/x86_64-linux-gnu/qcc/time.h is in liballjoyn-common-dev-1604 16.04a-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/**
 * @file
 *
 * Platform specific header files that defines time related functions
 */

/******************************************************************************
 * Copyright AllSeen Alliance. All rights reserved.
 *
 *    Permission to use, copy, modify, and/or distribute this software for any
 *    purpose with or without fee is hereby granted, provided that the above
 *    copyright notice and this permission notice appear in all copies.
 *
 *    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 *    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 *    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 *    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 *    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 *    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 *    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 ******************************************************************************/
#ifndef _QCC_TIME_H
#define _QCC_TIME_H

#include <alljoyn/Status.h>
#include <qcc/platform.h>
#include <qcc/String.h>

namespace qcc {


/**
 * Actually more than 500 million years from now but who's counting.
 */
static const uint64_t END_OF_TIME = static_cast<uint64_t>(-1);

/*
 * Forward declaration.
 */
template <typename TimeBase>
struct Timespec;

struct EpochTime; /**< Time relative to Epoch. */
struct MonotonicTime; /**< Time relative to some unspecified starting time. */

/**
 * Granularity of GetTimestamp64(), GetTimestamp() and GetTimeNow().
 *
 * GetTimestamp64() is based on ::GetTickCount64() on Windows. ::GetTickCount64()
 * typically has a 10-16 milliseconds granularity, so the result of GetTimestamp64()
 * on Windows can be up to ~15 milliseconds smaller than expected at any given time.
 */
#if defined(QCC_OS_GROUP_WINDOWS)
    #define QCC_TIMESTAMP_GRANULARITY 15
#else
    #define QCC_TIMESTAMP_GRANULARITY 0
#endif

/**
 * Gets the current time, relative to some unspecified starting time.
 *
 * @param[out] ts Timespec filled with current time, relative to some
 *                unspecified starting time.
 */
void GetTimeNow(Timespec<MonotonicTime>* ts);

/** Timespec */
template <typename TimeBase>
struct Timespec {

    uint64_t seconds;       /**< The number of seconds. */
    uint16_t mseconds;      /**< The number of milliseconds. */

    Timespec() : seconds(0), mseconds(0) { }

    /**
     * Constructs a Timespec that refers to an Epoch based time or a
     * future time relative to the current time.
     *
     * @param millis The time in milliseconds.
     */
    explicit Timespec(uint64_t millis);

    Timespec& operator+=(uint32_t ms) {
        seconds += (ms + mseconds) / 1000;
        mseconds = (uint16_t)((ms + mseconds) % 1000);
        return *this;
    }

    bool operator<(const Timespec& other) const {
        return (seconds < other.seconds) || ((seconds == other.seconds) && (mseconds < other.mseconds));
    }

    bool operator<=(const Timespec& other) const {
        return (seconds < other.seconds) || ((seconds == other.seconds) && (mseconds <= other.mseconds));
    }

    bool operator==(const Timespec& other) const {
        return (seconds == other.seconds) && (mseconds == other.mseconds);
    }

    bool operator!=(const Timespec& other) const {
        return !(*this == other);
    }

    /**
     * Gets the value of this Timespec in milliseconds.
     *
     * @return The value of this Timespec in milliseconds.
     */
    uint64_t GetMillis() const {
        return (seconds * 1000) + (uint64_t)mseconds;
    }
};

template <> inline
Timespec<EpochTime>::Timespec(uint64_t millis)
{
    seconds = millis / 1000;
    mseconds = (uint16_t)(millis % 1000);
}

template <> inline
Timespec<MonotonicTime>::Timespec(uint64_t millis)
{
    GetTimeNow(this);
    seconds += (millis + mseconds) / 1000;
    mseconds = (uint16_t)((mseconds + millis) % 1000);
}

/**
 * Gets the current time in milliseconds, relative to the first call of
 * GetTimestamp() or GetTimestamp64().
 *
 * @deprecated due to rollover every 8 days.
 *
 * @return The time in milliseconds.
 */
uint32_t GetTimestamp();

/**
 * Gets the current time in milliseconds, relative to the first call of
 * GetTimestamp() or GetTimestamp64().
 *
 * @return The time in milliseconds.
 */
uint64_t GetTimestamp64();

/**
 * Gets the current time in milliseconds since the Epoch.
 *
 * @return The time in milliseconds.
 */
uint64_t GetEpochTimestamp();

/**
 * Returns a formatted string for current UTC date and time. Format conforms to
 * RFC 1123 e.g. "Tue, 30 Aug 2011 17:01:45 GMT".
 *
 * @return The formatted date/time string.
 */
qcc::String UTCTime();

/**
 * Wrapper for mktime.
 *
 * @return The time in seconds.
 */
int64_t ConvertStructureToTime(struct tm* timeptr);

/**
 * Wrapper for gmtime.
 *
 * @param[in] timer The calendar time value to be formated into a tm structure.
 * @param tm set to the time in a tm structure.
 *
 * @return ER_OK if success else ER_FAIL.
 */
QStatus ConvertTimeToStructure(const int64_t* timer, struct tm* tm);

/**
 * Wrapper for localtime
 *
 * @param timer calendar time value to be formated into a tm structure
 * @param tm set to the Time in a tm structure
 *
 * @return ER_OK if success else ER_FAIL.
 */
QStatus ConvertToLocalTime(const int64_t* timer, struct tm* tm);

/**
 * Wrapper for strftime
 *
 * @return Number of characters placed in dest.
 */
size_t FormatTime(char* dest, size_t destSize, const char* format, const struct tm* timeptr);

}

template <typename T>
inline qcc::Timespec<T> operator+(const qcc::Timespec<T>& ts, uint32_t ms)
{
    qcc::Timespec<T> ret;
    ret.seconds = ts.seconds + (ts.mseconds + ms) / 1000;
    ret.mseconds = (uint16_t)((ts.mseconds + ms) % 1000);
    return ret;
}

template <typename T>
inline int64_t operator-(const qcc::Timespec<T>& ts1, const qcc::Timespec<T>& ts2)
{
    int64_t t1 = (int64_t) ts1.seconds;
    t1 *= 1000;
    t1 += ts1.mseconds;

    int64_t t2 = (int64_t) ts2.seconds;
    t2 *= 1000;
    t2 += ts2.mseconds;

    return t1 - t2;
}

#endif