gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
syscall_return.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Authors: Gabe Black
29  */
30 
31 #ifndef __SIM_SYSCALLRETURN_HH__
32 #define __SIM_SYSCALLRETURN_HH__
33 
34 #include <inttypes.h>
35 
55 {
56  public:
57 
66  SyscallReturn(int64_t v)
67  : value(v), retryFlag(false)
68  {}
69 
72  {
73  SyscallReturn s(0);
74  s.retryFlag = true;
75  return s;
76  }
77 
79 
81  bool successful() const
82  {
83  return (value >= 0 || value <= -4096);
84  }
85 
87  bool needsRetry() const { return retryFlag; }
88 
90  int64_t returnValue() const
91  {
92  assert(successful());
93  return value;
94  }
95 
97  int errnoValue() const
98  {
99  assert(!successful());
100  return -value;
101  }
102 
104  int64_t encodedValue() const
105  {
106  return value;
107  }
108 
109  private:
110 
111  int64_t value;
112 
113  bool retryFlag;
114 };
115 
116 #endif
Bitfield< 28 > v
Definition: miscregs.hh:1366
int64_t returnValue() const
The return value.
Bitfield< 4 > s
Definition: miscregs.hh:1738
static SyscallReturn retry()
Pseudo-constructor to create an instance with the retry flag set.
int errnoValue() const
The errno value.
SyscallReturn(int64_t v)
For simplicity, allow the object to be initialized with a single signed integer using the same positi...
bool needsRetry() const
Does the syscall need to be retried?
int64_t encodedValue() const
The encoded value (as described above)
This class represents the return value from an emulated system call, including any errno setting...
bool successful() const
Was the system call successful?

Generated on Fri Jun 9 2017 13:03:51 for gem5 by doxygen 1.8.6