LCOV - code coverage report
Current view: directory - src/shared/platform/posix - nacl_timestamp.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 11 9 81.8 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright 2008 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can
       4                 :  * be found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : /*
       8                 :  * NaCl Service Runtime logging code.
       9                 :  */
      10                 : 
      11                 : #include <stdio.h>
      12                 : #include <sys/time.h>
      13                 : #include <time.h>
      14                 : #include <stdint.h>
      15                 : 
      16                 : #include "native_client/src/shared/platform/nacl_timestamp.h"
      17                 : 
      18           11946 : char  *NaClTimeStampString(char   *buffer,
      19           11946 :                            size_t buffer_size) {
      20           11946 :   struct timeval  tv;
      21           11946 :   struct tm       bdt;  /* broken down time */
      22                 : 
      23           11946 :   if (-1 == gettimeofday(&tv, (struct timezone *) NULL)) {
      24               0 :     snprintf(buffer, buffer_size, "-NA-");
      25               0 :     return buffer;
      26                 :   }
      27           11946 :   (void) localtime_r(&tv.tv_sec, &bdt);
      28                 :   /* suseconds_t holds at most 10**6 < 16**6 = (2**4)**6 = 2**24 < 2**32 */
      29           11946 :   snprintf(buffer, buffer_size, "%02d:%02d:%02d.%06d",
      30                 :            bdt.tm_hour, bdt.tm_min, bdt.tm_sec, (int) tv.tv_usec);
      31           11946 :   return buffer;
      32           11946 : }

Generated by: LCOV version 1.7