OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [src/] [librlink/] [ReventFd.cpp] - Blame information for rev 22

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 22 wfjm
// $Id: ReventFd.cpp 529 2013-08-02 17:15:43Z mueller $
2 19 wfjm
//
3
// Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16
// 2013-01-14   475   1.0    Initial version
17
// 2013-01-11   473   0.5    First draft
18
// ---------------------------------------------------------------------------
19
 
20
/*!
21
  \file
22 22 wfjm
  \version $Id: ReventFd.cpp 529 2013-08-02 17:15:43Z mueller $
23 19 wfjm
  \brief   Implemenation of class ReventFd.
24
*/
25
 
26
#include <errno.h>
27
#include <unistd.h>
28
#include <sys/eventfd.h>
29
 
30
#include "ReventFd.hpp"
31
 
32
#include "librtools/Rexception.hpp"
33
 
34
using namespace std;
35
 
36
/*!
37
  \class Retro::ReventFd
38
  \brief FIXME_docs
39
*/
40
 
41
// all method definitions in namespace Retro
42
namespace Retro {
43
 
44
//------------------------------------------+-----------------------------------
45
//! FIXME_docs
46
 
47
ReventFd::ReventFd()
48
{
49 22 wfjm
  fFd = ::eventfd(0,0);                    // ini value = 0; no flags
50 19 wfjm
  if (fFd < 0)
51
    throw Rexception("ReventFd::ctor", "eventfd() failed: ", errno);
52
}
53
 
54
//------------------------------------------+-----------------------------------
55
//! FIXME_docs
56
 
57
ReventFd::~ReventFd()
58
{
59 22 wfjm
  ::close(fFd);
60 19 wfjm
}
61
 
62
//------------------------------------------+-----------------------------------
63
//! FIXME_docs
64
 
65
int ReventFd::SignalFd(int fd)
66
{
67
  uint64_t one(1);
68 22 wfjm
  int irc = ::write(fd, &one, sizeof(one));
69 19 wfjm
  return irc;
70
}
71
 
72
//------------------------------------------+-----------------------------------
73
//! FIXME_docs
74
 
75
int ReventFd::WaitFd(int fd)
76
{
77
  uint64_t buf;
78 22 wfjm
  int irc = ::read(fd, &buf, sizeof(buf));
79 19 wfjm
  return (irc <= 0) ? irc : (int)buf;
80
}
81
 
82
} // end namespace Retro

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.