This file is indexed.

/usr/include/x86_64-linux-gnu/qcc/time.h is in liballjoyn-common-dev-1504 15.04b-8.

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
/**
 * @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 <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);

typedef enum {
    TIME_ABSOLUTE,
    TIME_RELATIVE
} TimeBase;

/*
 * Forward declaration.
 */
struct Timespec;

/**
 * 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

/**
 * Get the current time.
 * @param ts  [OUT] Timespec filled with current time.
 */
void GetTimeNow(Timespec* ts);

/** Timespec */
struct Timespec {

    static const Timespec Zero;

    uint64_t seconds;       /**< Number of seconds since EPOCH */
    uint16_t mseconds;      /**< Milliseconds in EPOCH */

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

    /**
     * Construct a Timespec that refers to an absolute (EPOCH based) time expressed in milliseconds
     * or a future time relative to the current time now.
     *
     * @param millis   Time in milliseconds.
     * @param base     Indicates if time is relative to now or absolute.
     */
    Timespec(uint64_t millis, TimeBase base = TIME_ABSOLUTE) {
        if (base == TIME_ABSOLUTE) {
            seconds = millis / 1000;
            mseconds = (uint16_t)(millis % 1000);
        } else {
            GetTimeNow(this);
            seconds += (millis + mseconds) / 1000;
            mseconds = (uint16_t)((mseconds + millis) % 1000);
        }
    }

    Timespec& operator+=(const Timespec& other) {
        seconds += other.seconds + (mseconds + other.mseconds) / 1000;
        mseconds = ((mseconds + other.mseconds) % 1000);
        return *this;
    }

    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);
    }

    uint64_t GetAbsoluteMillis() const { return (seconds * 1000) + (uint64_t)mseconds; }

};

/**
 * Return (non-absolute) timestamp in milliseconds.
 * Deprecated due to rollover every 8 days.
 * @return  timestamp in milliseconds.
 */
uint32_t GetTimestamp(void);

/**
 * Return (non-absolute) timestamp in milliseconds.
 * @return  timestamp in milliseconds.
 */
uint64_t GetTimestamp64(void);

/**
 * Return (non-absolute) timestamp in milliseconds since Epoch.
 * @return  timestamp in milliseconds.
 */
uint64_t GetEpochTimestamp(void);

/**
 * Return 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  timestamp in seconds
 */
int64_t ConvertStructureToTime(struct tm* timeptr);

/**
 * Wrapper for gmtime
 * @return  Time in a tm structure
 */
struct tm* ConvertTimeToStructure(const int64_t* timer);

/**
 * Wrapper for localtime
 * @return  Time in a tm structure
 */
struct tm* ConvertToLocalTime(const int64_t* timer);

/**
 * 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);

}

inline qcc::Timespec operator+(const qcc::Timespec& tsa, const qcc::Timespec& tsb)
{
    qcc::Timespec ret;
    ret.seconds = tsa.seconds + tsb.seconds + (tsa.mseconds + tsb.mseconds) / 1000;
    ret.mseconds = (tsa.mseconds + tsb.mseconds) % 1000;
    return ret;
}

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

inline int64_t operator-(const qcc::Timespec& ts1, const qcc::Timespec& 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