os/ossrv/genericopenlibs/openenvcore/include/sys/time.dosc
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/** @file  ../include/sys/time.h
sl@0
     2
@internalComponent
sl@0
     3
*/
sl@0
     4
sl@0
     5
/** @fn  adjtime(const struct timeval *delta, struct timeval *olddelta)
sl@0
     6
@param delta
sl@0
     7
@param olddelta
sl@0
     8
@return   A successful call will return 0 while a failure will return -1
sl@0
     9
sl@0
    10
 
sl@0
    11
sl@0
    12
 The adjtime system call makes small adjustments to the system time (as 
sl@0
    13
  returned by gettimeofday ) by advancing it the amount 
sl@0
    14
  specified by the timeval delta .
sl@0
    15
sl@0
    16
 If delta is negative, the clock is still incremented by the positive of 
sl@0
    17
  delta until the correction is complete. Thus, the time is always a monotonically 
sl@0
    18
  increasing function and time correction from an earlier call to adjtime might not have finished when adjtime is called again. In such cases the structure pointed to by olddelta will contain, upon return, the number of microseconds still 
sl@0
    19
  to be corrected from the earlier call. Otherwise the values will be set to 0
sl@0
    20
sl@0
    21
 This call may be used by time servers that synchronize the clock.
sl@0
    22
sl@0
    23
Examples:
sl@0
    24
@code
sl@0
    25
#include <sys/time.h>
sl@0
    26
#include <stdio.h>
sl@0
    27
int main()
sl@0
    28
{
sl@0
    29
        //Fill the input struct with 100 microseconds
sl@0
    30
        const struct timeval delta = {0, 100};
sl@0
    31
        struct timeval  olddelta;
sl@0
    32
        int retval;
sl@0
    33
        retval = adjtime (&delta;, &olddelta;); //Call adjtime
sl@0
    34
        printf("adjtime returned %d",retval);
sl@0
    35
        return 0;
sl@0
    36
}
sl@0
    37
sl@0
    38
@endcode
sl@0
    39
 Output
sl@0
    40
@code
sl@0
    41
adjtime returned 0
sl@0
    42
sl@0
    43
@endcode
sl@0
    44
@see gettimeofday()
sl@0
    45
sl@0
    46
sl@0
    47
 
sl@0
    48
sl@0
    49
@publishedAll
sl@0
    50
@externallyDefinedApi
sl@0
    51
*/
sl@0
    52
sl@0
    53
/** @fn  gettimeofday(struct timeval *tp, struct timezone *tzp)
sl@0
    54
@param tp
sl@0
    55
@param tzp
sl@0
    56
@return   The gettimeofday function returns 0 for success, or -1  for  failure.
sl@0
    57
sl@0
    58
  The system's notion of the current Greenwich time and the current time
sl@0
    59
zone is obtained with the gettimeofday system call, and set with the settimeofday system call.
sl@0
    60
The time is expressed in seconds and microseconds
sl@0
    61
since midnight (0 hour), January 1, 1970.
sl@0
    62
The resolution of the system
sl@0
    63
clock is hardware dependent, and the time may be updated continuously or
sl@0
    64
in "ticks."
sl@0
    65
If tp or tzp is NULL, the associated time
sl@0
    66
information will not be returned or set.
sl@0
    67
sl@0
    68
 The structures pointed to by tp and tzp are defined in \#include \<sys/time.h\> as:
sl@0
    69
sl@0
    70
@code
sl@0
    71
struct timeval {
sl@0
    72
longtv_sec;/* seconds since Jan. 1, 1970 */
sl@0
    73
longtv_usec;/* and microseconds */
sl@0
    74
};
sl@0
    75
@endcode
sl@0
    76
sl@0
    77
@code
sl@0
    78
struct timezone {
sl@0
    79
inttz_minuteswest; /* minutes west of Greenwich */
sl@0
    80
inttz_dsttime;/* type of dst correction */
sl@0
    81
};
sl@0
    82
@endcode
sl@0
    83
sl@0
    84
 The timezone structure indicates the local time zone (measured in minutes of time 
sl@0
    85
  westward from Greenwich) and a flag that, if nonzero, indicates that Daylight 
sl@0
    86
  Saving time applies locally during the appropriate part of the year.
sl@0
    87
sl@0
    88
Examples:
sl@0
    89
@code
sl@0
    90
#include <stdio.h>
sl@0
    91
#include <sys/time.h>
sl@0
    92
 
sl@0
    93
int main()
sl@0
    94
{
sl@0
    95
  struct timeval *tv;
sl@0
    96
  struct timezone *tz;
sl@0
    97
  int i = gettimeofday(tv, tz);
sl@0
    98
      
sl@0
    99
  printf("tv: %d, %d", tv->tv_sec, tv->tv_usec);
sl@0
   100
  printf("tz: %d, %d", tz->tz_minuteswest, tz->tz_dsttime);
sl@0
   101
  return 0;
sl@0
   102
}
sl@0
   103
sl@0
   104
@endcode
sl@0
   105
 Output
sl@0
   106
@code
sl@0
   107
tv: 1474660693, -326937770
sl@0
   108
tz: 7804688, 3
sl@0
   109
sl@0
   110
@endcode
sl@0
   111
@see adjtime()
sl@0
   112
@see clock_gettime()
sl@0
   113
@see ctime()
sl@0
   114
sl@0
   115
sl@0
   116
 
sl@0
   117
sl@0
   118
@publishedAll
sl@0
   119
@externallyDefinedApi
sl@0
   120
*/
sl@0
   121
sl@0
   122
/** @fn  utimes(const char *filename, const struct timeval *tvp)
sl@0
   123
@param filename
sl@0
   124
@param tvp
sl@0
   125
sl@0
   126
Note: This description also covers the following functions -
sl@0
   127
 lutimes()  futimes() 
sl@0
   128
sl@0
   129
@return   Upon successful completion, the value 0 is returned; otherwise the
sl@0
   130
value -1 is returned and the global variable errno is set to indicate the
sl@0
   131
error.
sl@0
   132
sl@0
   133
  The utimes function sets the access and modification times of the file pointed 
sl@0
   134
to by the path argument to the value of the times argument.
sl@0
   135
 The utimes function allows time specifications accurate to the microsecond.
sl@0
   136
sl@0
   137
 For utimes , the times argument is an array of timeval structures. The first array 
sl@0
   138
  member represents the date and time of last access and the second member represents the date and time of last modification. 
sl@0
   139
  The times in the timeval structure are measured in seconds and microseconds since the Epoch, although rounding toward 
sl@0
   140
  the nearest second may occur.
sl@0
   141
sl@0
   142
 If the times argument is a null pointer, the access and modification times 
sl@0
   143
  of the file are set to the current time.
sl@0
   144
sl@0
   145
Examples:
sl@0
   146
@code
sl@0
   147
/*  Detailed description: Sample usage of utimes system call.
sl@0
   148
 *  Preconditions: Example.txt file should exist in the working directory
sl@0
   149
 */
sl@0
   150
#include <sys/types.h>
sl@0
   151
#include <utime.h>
sl@0
   152
#include <sys/time.h>
sl@0
   153
int main()
sl@0
   154
{
sl@0
   155
  struct timeval Tim[1] ;
sl@0
   156
 Tim[0].tv_sec = 0 ;
sl@0
   157
 Tim[0].tv_usec = 0 ;
sl@0
   158
  if(utimes("Example.txt"  , Tim) < 0 )
sl@0
   159
  {
sl@0
   160
     printf("Utimes system call failed") ;
sl@0
   161
     return -1 ;
sl@0
   162
  }
sl@0
   163
  printf("Utimes call succeded") ;
sl@0
   164
 return 0 ;
sl@0
   165
}
sl@0
   166
sl@0
   167
@endcode
sl@0
   168
@see stat()
sl@0
   169
@see utime()
sl@0
   170
sl@0
   171
sl@0
   172
sl@0
   173
@capability Deferred @ref RFs::SetModified(const TDesC16&, const TTime&)
sl@0
   174
sl@0
   175
@publishedAll
sl@0
   176
@externallyDefinedApi
sl@0
   177
*/
sl@0
   178
sl@0
   179
sl@0
   180
/** @fn bintime_addx(struct bintime *bt, uint64_t x)
sl@0
   181
sl@0
   182
Static inline funtion. Function for reading the time.
sl@0
   183
sl@0
   184
@publishedAll
sl@0
   185
@released
sl@0
   186
*/
sl@0
   187
sl@0
   188
/** @fn  bintime_add(struct bintime *bt, const struct bintime *bt2)
sl@0
   189
sl@0
   190
Static inline funtion. Function for reading the time.
sl@0
   191
sl@0
   192
@publishedAll
sl@0
   193
@released
sl@0
   194
*/
sl@0
   195
sl@0
   196
/** @fn  bintime_sub(struct bintime *bt, const struct bintime *bt2)
sl@0
   197
sl@0
   198
Static inline funtion. Function for reading the time.
sl@0
   199
sl@0
   200
@publishedAll
sl@0
   201
@released
sl@0
   202
*/
sl@0
   203
sl@0
   204
sl@0
   205
/** @fn bintime2timespec(const struct bintime *bt, struct timespec *ts)
sl@0
   206
sl@0
   207
Static inline funtion
sl@0
   208
sl@0
   209
@publishedAll
sl@0
   210
@released
sl@0
   211
*/
sl@0
   212
sl@0
   213
/** @fn  timespec2bintime(const struct timespec *ts, struct bintime *bt)
sl@0
   214
sl@0
   215
Static inline funtion
sl@0
   216
sl@0
   217
@publishedAll
sl@0
   218
@released
sl@0
   219
*/
sl@0
   220
sl@0
   221
/** @fn  bintime2timeval(const struct bintime *bt, struct timeval *tv)
sl@0
   222
sl@0
   223
Static inline funtion
sl@0
   224
sl@0
   225
@publishedAll
sl@0
   226
@released
sl@0
   227
*/
sl@0
   228
sl@0
   229
sl@0
   230
/** @fn timeval2bintime(const struct timeval *tv, struct bintime *bt)
sl@0
   231
sl@0
   232
Static inline funtion
sl@0
   233
sl@0
   234
@publishedAll
sl@0
   235
@released
sl@0
   236
*/
sl@0
   237
sl@0
   238
/** @struct itimerval 
sl@0
   239
sl@0
   240
Includes the following members,
sl@0
   241
sl@0
   242
@publishedAll
sl@0
   243
@externallyDefinedApi
sl@0
   244
*/
sl@0
   245
sl@0
   246
/** @var itimerval::it_interval
sl@0
   247
timer interval
sl@0
   248
*/
sl@0
   249
sl@0
   250
/** @var itimerval::it_value
sl@0
   251
current value 
sl@0
   252
*/
sl@0
   253
sl@0
   254
/** @struct clockinfo 
sl@0
   255
sl@0
   256
Getkerninfo clock information structure
sl@0
   257
sl@0
   258
@publishedAll
sl@0
   259
@externallyDefinedApi
sl@0
   260
*/
sl@0
   261
sl@0
   262
/** @var clockinfo::hz
sl@0
   263
clock frequency 
sl@0
   264
*/
sl@0
   265
sl@0
   266
/** @var clockinfo::tick
sl@0
   267
micro-seconds per hz tick
sl@0
   268
*/
sl@0
   269
sl@0
   270
/** @var clockinfo::spare
sl@0
   271
current value 
sl@0
   272
*/
sl@0
   273
sl@0
   274
/** @var clockinfo::stathz
sl@0
   275
statistics clock frequency
sl@0
   276
*/
sl@0
   277
sl@0
   278
/** @var clockinfo::profhz
sl@0
   279
profiling clock frequency
sl@0
   280
*/
sl@0
   281
sl@0
   282
sl@0
   283
sl@0
   284