gem5 [DEVELOP-FOR-25.1]
Loading...
Searching...
No Matches
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
29#ifndef __SIM_SYSCALLRETURN_HH__
30#define __SIM_SYSCALLRETURN_HH__
31
32#include <cassert>
33#include <cinttypes>
34
35namespace gem5
36{
37
57{
58 public:
59
68 SyscallReturn(int64_t v) : _value(v), _count(1) {}
69
72
75 SyscallReturn(int64_t v1, int64_t v2) :
76 _value(v1), _value2(v2), _count(2)
77 {}
78
80 static SyscallReturn
82 {
84 s.retryFlag = true;
85 return s;
86 }
87
89
91 bool
92 successful() const
93 {
94 return (_value >= 0 || _value <= -4096);
95 }
96
98 bool needsRetry() const { return retryFlag; }
99
101 bool suppressed() const { return _count == 0; }
102
104 int count() const { return _count; }
105
107 int64_t
109 {
110 assert(successful());
111 return _value;
112 }
113
115 int
117 {
118 assert(!successful());
119 return -_value;
120 }
121
123 int64_t encodedValue() const { return _value; }
124 int64_t value2() const { return _value2; }
125
126 private:
127 int64_t _value, _value2;
129
130 bool retryFlag = false;
131};
132
133} // namespace gem5
134
135#endif
This class represents the return value from an emulated system call, including any errno setting.
bool suppressed() const
Should returning this value be suppressed?
SyscallReturn(int64_t v)
For simplicity, allow the object to be initialized with a single signed integer using the same positi...
static SyscallReturn retry()
Pseudo-constructor to create an instance with the retry flag set.
int64_t encodedValue() const
The encoded value (as described above)
bool needsRetry() const
Does the syscall need to be retried?
int64_t returnValue() const
The return value.
int count() const
How many values did the syscall attempt to return?
int64_t value2() const
SyscallReturn()
A SyscallReturn constructed with no value means don't return anything.
SyscallReturn(int64_t v1, int64_t v2)
A SyscallReturn constructed with two values means put the second value in additional return registers...
bool successful() const
Was the system call successful?
int errnoValue() const
The errno value.
Bitfield< 28 > v
Definition misc_types.hh:54
Bitfield< 4 > s
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36

Generated on Mon Oct 27 2025 04:13:04 for gem5 by doxygen 1.14.0