Assigning values to errno would not work; the next invocation would
overwrite them with the host platform errno again. We do now track changes and use a hopefully reasonable strategy for updating the host errno. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20608 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -159,8 +159,24 @@ _haiku_build_strerror(int errnum)
|
|||||||
int *
|
int *
|
||||||
_haiku_build_errno()
|
_haiku_build_errno()
|
||||||
{
|
{
|
||||||
|
static int previousErrno = 0;
|
||||||
static int localErrno = 0;
|
static int localErrno = 0;
|
||||||
localErrno = to_haiku_error(errno);
|
static int previousLocalErrno = 0;
|
||||||
|
|
||||||
|
// If the localErrno has been changed and the real errno has not changed
|
||||||
|
// in the meantime, we update errno itself, so that the local update will
|
||||||
|
// be reflected. If errno has changed we always update localErrno.
|
||||||
|
int currentErrno = errno;
|
||||||
|
if (currentErrno == previousErrno) {
|
||||||
|
if (localErrno != previousLocalErrno) {
|
||||||
|
errno = previousErrno = to_host_error(localErrno);
|
||||||
|
previousLocalErrno = localErrno;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
previousErrno = currentErrno;
|
||||||
|
previousLocalErrno = localErrno = to_haiku_error(errno);
|
||||||
|
}
|
||||||
|
|
||||||
return &localErrno;
|
return &localErrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user