/// conversion, so a bare integer is used where a SyscallReturn
/// value is expected, e.g., as the return value from a system
/// call emulation function ('return 0;' or 'return -EFAULT;').
- SyscallReturn(int64_t v) : value(v) {}
+ SyscallReturn(int64_t v) : _value(v), _count(1) {}
/// A SyscallReturn constructed with no value means don't return anything.
- SyscallReturn() : suppressedFlag(true) {}
+ SyscallReturn() : _count(0) {}
+
+ /// A SyscallReturn constructed with two values means put the second value
+ /// in additional return registers as defined by the ABI, if they exist.
+ SyscallReturn(int64_t v1, int64_t v2) :
+ _value(v1), _value2(v2), _count(2)
+ {}
/// Pseudo-constructor to create an instance with the retry flag set.
static SyscallReturn
bool
successful() const
{
- return (value >= 0 || value <= -4096);
+ return (_value >= 0 || _value <= -4096);
}
/// Does the syscall need to be retried?
bool needsRetry() const { return retryFlag; }
/// Should returning this value be suppressed?
- bool suppressed() const { return suppressedFlag; }
+ bool suppressed() const { return _count == 0; }
+
+ /// How many values did the syscall attempt to return?
+ int count() const { return _count; }
/// The return value
int64_t
returnValue() const
{
assert(successful());
- return value;
+ return _value;
}
/// The errno value
errnoValue() const
{
assert(!successful());
- return -value;
+ return -_value;
}
/// The encoded value (as described above)
- int64_t encodedValue() const { return value; }
+ int64_t encodedValue() const { return _value; }
+ int64_t value2() const { return _value2; }
private:
- int64_t value;
+ int64_t _value, _value2;
+ int _count;
bool retryFlag = false;
- bool suppressedFlag = false;
};
#endif