• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  ptimestamp.h  *
3  *                                                                           *
4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5  *                                                                           *
6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7  *  you may not use this file except in compliance with the License.         *
8  *                                                                           *
9  *  You may obtain a copy of the License at                                  *
10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
11  *                                                                           *
12  *  Unless required by applicable law or agreed to in writing, software      *
13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15  *  See the License for the specific language governing permissions and      *
16  *  limitations under the License.                                           *
17  *                                                                           *
18  *---------------------------------------------------------------------------*/
19 
20 #ifndef PTIMESTAMP_H
21 #define PTIMESTAMP_H
22 
23 
24 
25 #include <time.h>
26 #include "PortPrefix.h"
27 #include "ptypes.h"
28 
29 /**
30  * @addtogroup PTimeStampModule PTimeStamp API functions
31  *
32  * @{
33  */
34 
35 /**
36  * Time stamp structure with two fields: seconds and milliseconds.  The secs
37  * field represent the number of seconds since January 1st 1970, 00:00:00 UTC.
38  * msecs represent the number of milliseconds within that second.
39  **/
40 typedef struct PTimeStamp_t
41 {
42   /**
43    * Seconds component of timestamp.
44    */
45   time_t secs;
46 
47   /**
48    * Milliseconds component of timestamp.
49    */
50   asr_uint16_t msecs;
51 }
52 PTimeStamp;
53 
54 /**
55  * Sets the time stamp to represent current time.  Sets both secs field and
56  * msecs field to 0 if platform does not support it.
57  **/
58 PORTABLE_API void PTimeStampSet(PTimeStamp *timestamp);
59 
60 /**
61  * Returns the difference between two timestamps, in terms of milliseconds.
62  *
63  * @param a First timestamp
64  * @param b Second timestamp
65  * @return a - b
66  */
67 PORTABLE_API int PTimeStampDiff(const PTimeStamp *a, const PTimeStamp *b);
68 
69 /**
70  * @}
71  */
72 
73 
74 #endif
75