LCOV - code coverage report
Current view: top level - vcl/inc/unx - salunxtime.h (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 15 25 60.0 %
Date: 2015-06-13 12:38:46 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_INC_UNX_SALUNXTIME_H
      21             : #define INCLUDED_VCL_INC_UNX_SALUNXTIME_H
      22             : 
      23             : #if defined LINUX || defined FREEBSD || \
      24             :     defined NETBSD || defined OPENBSD || defined DRAGONFLY
      25             : #include <sys/time.h>
      26             : #elif defined AIX
      27             : #include <time.h>
      28             : #include <sys/time.h>
      29             : #include <strings.h>
      30             : #endif
      31             : #include <sal/types.h>
      32             : 
      33    24941055 : inline bool operator >= ( const timeval &t1, const timeval &t2 )
      34             : {
      35    24941055 :     if( t1.tv_sec == t2.tv_sec )
      36    24915304 :         return t1.tv_usec >= t2.tv_usec;
      37       25751 :     return t1.tv_sec > t2.tv_sec;
      38             : }
      39             : 
      40       44625 : inline bool operator > ( const timeval &t1, const timeval &t2 )
      41             : {
      42       44625 :     if( t1.tv_sec == t2.tv_sec )
      43       29428 :         return t1.tv_usec > t2.tv_usec;
      44       15197 :     return t1.tv_sec > t2.tv_sec;
      45             : }
      46             : 
      47             : inline bool operator == ( const timeval &t1, const timeval &t2 )
      48             : {
      49             :     return t1.tv_sec == t2.tv_sec && t1.tv_usec == t2.tv_usec;
      50             : }
      51             : 
      52           0 : inline timeval &operator -= ( timeval &t1, const timeval &t2 )
      53             : {
      54           0 :     if( t1.tv_usec < t2.tv_usec )
      55             :     {
      56           0 :         t1.tv_sec--;
      57           0 :         t1.tv_usec += 1000000;
      58             :     }
      59           0 :     t1.tv_sec  -= t2.tv_sec;
      60           0 :     t1.tv_usec -= t2.tv_usec;
      61           0 :     return t1;
      62             : }
      63             : 
      64             : inline timeval &operator += ( timeval &t1, const timeval &t2 )
      65             : {
      66             :     t1.tv_sec  += t2.tv_sec;
      67             :     t1.tv_usec += t2.tv_usec;
      68             :     if( t1.tv_usec > 1000000 )
      69             :     {
      70             :         t1.tv_sec++;
      71             :         t1.tv_usec -= 1000000;
      72             :     }
      73             :     return t1;
      74             : }
      75             : 
      76    13427707 : inline timeval &operator += ( timeval &t1, sal_uIntPtr t2 )
      77             : {
      78    13427707 :     t1.tv_sec  += t2 / 1000;
      79    13427707 :     t1.tv_usec += t2 ? (t2 % 1000) * 1000 : 500;
      80    13427707 :     if( t1.tv_usec > 1000000 )
      81             :     {
      82       18485 :         t1.tv_sec++;
      83       18485 :         t1.tv_usec -= 1000000;
      84             :     }
      85    13427707 :     return t1;
      86             : }
      87             : 
      88             : inline timeval operator + ( const timeval &t1, const timeval &t2 )
      89             : {
      90             :     timeval t0 = t1;
      91             :     return t0 += t2;
      92             : }
      93             : 
      94             : inline timeval operator + ( const timeval &t1, sal_uIntPtr t2 )
      95             : {
      96             :     timeval t0 = t1;
      97             :     return t0 += t2;
      98             : }
      99             : 
     100           0 : inline timeval operator - ( const timeval &t1, const timeval &t2 )
     101             : {
     102           0 :     timeval t0 = t1;
     103           0 :     return t0 -= t2;
     104             : }
     105             : 
     106             : #endif // INCLUDED_VCL_INC_UNX_SALUNXTIME_H
     107             : 
     108             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11