LCOV - code coverage report
Current view: top level - src - ath.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 14 18 77.8 %
Date: 2018-11-14 16:53:58 Functions: 7 9 77.8 %

          Line data    Source code
       1             : /* ath.c - Thread-safeness library.
       2             :    Copyright (C) 2002, 2003, 2004 g10 Code GmbH
       3             : 
       4             :    This file is part of GPGME.
       5             : 
       6             :    GPGME is free software; you can redistribute it and/or modify it
       7             :    under the terms of the GNU Lesser General Public License as
       8             :    published by the Free Software Foundation; either version 2.1 of
       9             :    the License, or (at your option) any later version.
      10             : 
      11             :    GPGME is distributed in the hope that it will be useful, but
      12             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :    Lesser General Public License for more details.
      15             : 
      16             :    You should have received a copy of the GNU Lesser General Public
      17             :    License along with this program; if not, write to the Free Software
      18             :    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
      19             :    02111-1307, USA.  */
      20             : 
      21             : #ifdef HAVE_CONFIG_H
      22             : #include <config.h>
      23             : #endif
      24             : 
      25             : #include <assert.h>
      26             : #ifdef HAVE_UNISTD_H
      27             : # include <unistd.h>
      28             : #endif
      29             : #ifdef HAVE_SYS_SELECT_H
      30             : # include <sys/select.h>
      31             : #else
      32             : # ifdef HAVE_SYS_TIME_H
      33             : #  include <sys/time.h>
      34             : # endif
      35             : #endif
      36             : #ifdef HAVE_SYS_TYPES_H
      37             : # include <sys/types.h>
      38             : #endif
      39             : #ifndef HAVE_W32_SYSTEM
      40             : #include <sys/wait.h>
      41             : #endif
      42             : 
      43             : #include "gpgme.h"
      44             : 
      45             : #ifdef _MSC_VER
      46             :   typedef int  pid_t;
      47             : #endif
      48             : 
      49             : #include "ath.h"
      50             : 
      51             : 
      52             : #ifdef HAVE_W32_SYSTEM
      53             : #include <windows.h>
      54             : uintptr_t
      55             : ath_self (void)
      56             : {
      57             :   return (uintptr_t) GetCurrentThreadId ();
      58             : }
      59             : #else
      60             : # ifdef __linux
      61             : #include <sys/syscall.h>
      62             : uintptr_t
      63           0 : ath_self (void)
      64             : {
      65             :   /* Just to catch users who don't use gpgme-pthread.  */
      66           0 :   return (uintptr_t) syscall (__NR_gettid);
      67             : }
      68             : # else
      69             : uintptr_t
      70             : ath_self (void)
      71             : {
      72             :   return (uintptr_t) getpid ();
      73             : }
      74             : # endif
      75             : #endif
      76             : 
      77             : 
      78             : gpgme_ssize_t
      79        9999 : ath_read (int fd, void *buf, size_t nbytes)
      80             : {
      81        9999 :   return read (fd, buf, nbytes);
      82             : }
      83             : 
      84             : 
      85             : gpgme_ssize_t
      86         733 : ath_write (int fd, const void *buf, size_t nbytes)
      87             : {
      88         733 :   return write (fd, buf, nbytes);
      89             : }
      90             : 
      91             : 
      92             : gpgme_ssize_t
      93       16387 : ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
      94             :             struct timeval *timeout)
      95             : {
      96             : #ifdef HAVE_W32_SYSTEM
      97             :   return -1; /* Not supported. */
      98             : #else
      99       16387 :   return select (nfd, rset, wset, eset, timeout);
     100             : #endif
     101             : }
     102             : 
     103             : 
     104             : gpgme_ssize_t
     105        1999 : ath_waitpid (pid_t pid, int *status, int options)
     106             : {
     107             : #ifdef HAVE_W32_SYSTEM
     108             :   return -1; /* Not supported. */
     109             : #else
     110        1999 :   return waitpid (pid, status, options);
     111             : #endif
     112             : }
     113             : 
     114             : 
     115             : int
     116           0 : ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
     117             : {
     118             : #ifdef HAVE_W32_SYSTEM
     119             :   return -1; /* Not supported. */
     120             : #else
     121           0 :   return accept (s, addr, length_ptr);
     122             : #endif
     123             : }
     124             : 
     125             : 
     126             : int
     127          14 : ath_connect (int s, const struct sockaddr *addr, socklen_t length)
     128             : {
     129             : #ifdef HAVE_W32_SYSTEM
     130             :   return -1; /* Not supported. */
     131             : #else
     132          14 :   return connect (s, addr, length);
     133             : #endif
     134             : }
     135             : 
     136             : 
     137             : int
     138         240 : ath_sendmsg (int s, const struct msghdr *msg, int flags)
     139             : {
     140             : #ifdef HAVE_W32_SYSTEM
     141             :   return -1; /* Not supported. */
     142             : #else
     143         240 :   return sendmsg (s, msg, flags);
     144             : #endif
     145             : }
     146             : 
     147             : 
     148             : int
     149         122 : ath_recvmsg (int s, struct msghdr *msg, int flags)
     150             : {
     151             : #ifdef HAVE_W32_SYSTEM
     152             :   return -1; /* Not supported. */
     153             : #else
     154         122 :   return recvmsg (s, msg, flags);
     155             : #endif
     156             : }

Generated by: LCOV version 1.13