From: Julian Seward Date: Tue, 17 Oct 2006 01:38:48 +0000 (+0000) Subject: Merge r6131: X-Git-Tag: svn/VALGRIND_3_3_0~608 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e10473fe675af227b7eedfb0985fd2e9c28dae82;p=thirdparty%2Fvalgrind.git Merge r6131: Change the SysRes type so as to represent both the error value and the non-error result at the same time. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6268 --- diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h index 32e20f18f6..1bebc9a92a 100644 --- a/include/pub_tool_basics.h +++ b/include/pub_tool_basics.h @@ -80,6 +80,7 @@ typedef ULong Off64T; // 64 64 # define NULL ((void*)0) #endif + /* --------------------------------------------------------------------- non-builtin types ------------------------------------------------------------------ */ @@ -91,14 +92,34 @@ typedef ULong Off64T; // 64 64 typedef UInt ThreadId; /* An abstraction of syscall return values. - When .isError == False, val holds the return value. - When .isError == True, val holds the error code. + Linux: + When .isError == False, + res holds the return value, and err is zero. + When .isError == True, + err holds the error code, and res is zero. + + AIX: + res is the POSIX result of the syscall. + err is the corresponding errno value. + isError === err==0 + + Unlike on Linux, it is possible for 'err' to be nonzero (thus an + error has occurred), nevertheless 'res' is also nonzero. AIX + userspace does not appear to consistently inspect 'err' to + determine whether or not an error has occurred. For example, + sys_open() will return -1 for 'val' if a file cannot be opened, + as well as the relevant errno value in 'err', but AIX userspace + then consults 'val' to figure out if the syscall failed, rather + than looking at 'err'. Hence we need to represent them both. */ -typedef struct { - UWord val; - Bool isError; -} -SysRes; +typedef + struct { + UWord res; + UWord err; + Bool isError; + } + SysRes; + /* --------------------------------------------------------------------- Miscellaneous (word size, endianness, regparmness, stringification)