* cygrun.c (main): Fix compiler warning.

* gmon.c (_mcleanup): Ditto.
* profil.c (profile_off): Ditto.
* net.cc (find_winsock_errno): New function.
(__set_winsock_errno): Use find_winsock_errno.
(cygwin_setsockopt): Detect SO_ERROR for debugging.
(cygwin_getsockopt): Ditto.  Translate error when getsockopt returns SO_ERROR.
* winsup.h: regparmize __set_winsock_errno.
* include/sys/strace.h: Document that strace functions can't use regparm.
This commit is contained in:
Christopher Faylor
2001-04-03 02:53:25 +00:00
parent be61cf4d0c
commit c90e420d91
8 changed files with 57 additions and 28 deletions

View File

@@ -247,26 +247,24 @@ static struct tl errmap[] =
{0, NULL, 0}
};
static int
find_winsock_errno (int why)
{
for (int i = 0; errmap[i].w != 0; ++i)
if (why == errmap[i].w)
return errmap[i].e;
return EPERM;
}
/* Cygwin internal */
void
__set_winsock_errno (const char *fn, int ln)
{
int i;
int why = WSAGetLastError ();
for (i = 0; errmap[i].w != 0; ++i)
if (why == errmap[i].w)
break;
if (errmap[i].w != 0)
{
syscall_printf ("%s:%d - %d (%s) -> %d", fn, ln, why, errmap[i].s, errmap[i].e);
set_errno (errmap[i].e);
}
else
{
syscall_printf ("%s:%d - unknown error %d", fn, ln, why);
set_errno (EPERM);
}
DWORD werr = WSAGetLastError ();
int err = find_winsock_errno (werr);
set_errno (err);
syscall_printf ("%s:%d - winsock error %d -> errno %d", fn, ln, werr, err);
}
/*
@@ -524,6 +522,9 @@ cygwin_setsockopt (int fd,
case SO_OOBINLINE:
name="SO_OOBINLINE";
break;
case SO_ERROR:
name="SO_ERROR";
break;
}
res = setsockopt (h->get_socket (), level, optname,
@@ -584,11 +585,20 @@ cygwin_getsockopt (int fd,
case SO_OOBINLINE:
name="SO_OOBINLINE";
break;
case SO_ERROR:
name="SO_ERROR";
break;
}
res = getsockopt (h->get_socket (), level, optname,
(char *) optval, (int *) optlen);
if (optname == SO_ERROR)
{
int *e = (int *) optval;
*e = find_winsock_errno (*e);
}
if (res)
set_winsock_errno ();
}