LCOV - code coverage report
Current view: top level - vcl/inc/unx - salunxtime.h (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 25 60.0 %
Date: 2012-08-25 Functions: 3 5 60.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 8 87.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SALUNX_TIME_H
      30                 :            : #define _SALUNX_TIME_H
      31                 :            : 
      32                 :            : #if defined LINUX || defined FREEBSD || \
      33                 :            :     defined NETBSD || defined OPENBSD || defined DRAGONFLY
      34                 :            : #include <sys/time.h>
      35                 :            : #elif defined AIX
      36                 :            : #include <time.h>
      37                 :            : #include <sys/time.h>
      38                 :            : #include <strings.h>
      39                 :            : #endif
      40                 :            : #include <sal/types.h>
      41                 :            : 
      42                 :            : // -=-= timeval =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
      43                 :     227414 : inline int operator >= ( const timeval &t1, const timeval &t2 )
      44                 :            : {
      45         [ +  + ]:     227414 :     if( t1.tv_sec == t2.tv_sec )
      46                 :     216329 :         return t1.tv_usec >= t2.tv_usec;
      47                 :     227414 :     return t1.tv_sec > t2.tv_sec;
      48                 :            : }
      49                 :            : 
      50                 :      43475 : inline int operator > ( const timeval &t1, const timeval &t2 )
      51                 :            : {
      52         [ +  + ]:      43475 :     if( t1.tv_sec == t2.tv_sec )
      53                 :      35334 :         return t1.tv_usec > t2.tv_usec;
      54                 :      43475 :     return t1.tv_sec > t2.tv_sec;
      55                 :            : }
      56                 :            : 
      57                 :            : inline int operator == ( const timeval &t1, const timeval &t2 )
      58                 :            : {
      59                 :            :     if( t1.tv_sec == t2.tv_sec )
      60                 :            :         return t1.tv_usec == t2.tv_usec;
      61                 :            :     return sal_False;
      62                 :            : }
      63                 :            : 
      64                 :          0 : inline timeval &operator -= ( timeval &t1, const timeval &t2 )
      65                 :            : {
      66                 :          0 :     if( t1.tv_usec < t2.tv_usec )
      67                 :            :     {
      68                 :          0 :         t1.tv_sec--;
      69                 :          0 :         t1.tv_usec += 1000000;
      70                 :            :     }
      71                 :          0 :     t1.tv_sec  -= t2.tv_sec;
      72                 :          0 :     t1.tv_usec -= t2.tv_usec;
      73                 :          0 :     return t1;
      74                 :            : }
      75                 :            : 
      76                 :            : inline timeval &operator += ( timeval &t1, const timeval &t2 )
      77                 :            : {
      78                 :            :     t1.tv_sec  += t2.tv_sec;
      79                 :            :     t1.tv_usec += t2.tv_usec;
      80                 :            :     if( t1.tv_usec > 1000000 )
      81                 :            :     {
      82                 :            :         t1.tv_sec++;
      83                 :            :         t1.tv_usec -= 1000000;
      84                 :            :     }
      85                 :            :     return t1;
      86                 :            : }
      87                 :            : 
      88                 :      76487 : inline timeval &operator += ( timeval &t1, sal_uIntPtr t2 )
      89                 :            : {
      90                 :      76487 :     t1.tv_sec  += t2 / 1000;
      91         [ +  - ]:      76487 :     t1.tv_usec += t2 ? (t2 % 1000) * 1000 : 500;
      92         [ +  + ]:      76487 :     if( t1.tv_usec > 1000000 )
      93                 :            :     {
      94                 :       5707 :         t1.tv_sec++;
      95                 :       5707 :         t1.tv_usec -= 1000000;
      96                 :            :     }
      97                 :      76487 :     return t1;
      98                 :            : }
      99                 :            : 
     100                 :            : inline timeval operator + ( const timeval &t1, const timeval &t2 )
     101                 :            : {
     102                 :            :     timeval t0 = t1;
     103                 :            :     return t0 += t2;
     104                 :            : }
     105                 :            : 
     106                 :            : inline timeval operator + ( const timeval &t1, sal_uIntPtr t2 )
     107                 :            : {
     108                 :            :     timeval t0 = t1;
     109                 :            :     return t0 += t2;
     110                 :            : }
     111                 :            : 
     112                 :          0 : inline timeval operator - ( const timeval &t1, const timeval &t2 )
     113                 :            : {
     114                 :          0 :     timeval t0 = t1;
     115                 :          0 :     return t0 -= t2;
     116                 :            : }
     117                 :            : 
     118                 :            : #endif // _SALUNX_TIME_H
     119                 :            : 
     120                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10