gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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) : value(v) {}
67 
70 
72  static SyscallReturn
74  {
75  SyscallReturn s(0);
76  s.retryFlag = true;
77  return s;
78  }
79 
81 
83  bool
84  successful() const
85  {
86  return (value >= 0 || value <= -4096);
87  }
88 
90  bool needsRetry() const { return retryFlag; }
91 
93  bool suppressed() const { return suppressedFlag; }
94 
96  int64_t
97  returnValue() const
98  {
99  assert(successful());
100  return value;
101  }
102 
104  int
105  errnoValue() const
106  {
107  assert(!successful());
108  return -value;
109  }
110 
112  int64_t encodedValue() const { return value; }
113 
114  private:
115  int64_t value;
116 
117  bool retryFlag = false;
118  bool suppressedFlag = false;
119 };
120 
121 #endif
Bitfield< 28 > v
bool successful() const
Was the system call successful?
int errnoValue() const
The errno value.
int64_t encodedValue() const
The encoded value (as described above)
Bitfield< 4 > s
static SyscallReturn retry()
Pseudo-constructor to create an instance with the retry flag set.
SyscallReturn(int64_t v)
For simplicity, allow the object to be initialized with a single signed integer using the same positi...
int64_t returnValue() const
The return value.
bool suppressed() const
Should returning this value be suppressed?
SyscallReturn()
A SyscallReturn constructed with no value means don&#39;t return anything.
bool needsRetry() const
Does the syscall need to be retried?
This class represents the return value from an emulated system call, including any errno setting...

Generated on Fri Feb 28 2020 16:27:03 for gem5 by doxygen 1.8.13