* 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

@ -1,3 +1,18 @@
Mon Apr 2 22:48:58 2001 Christopher Faylor <cgf@cygnus.com>
* 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.
2001-04-02 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
* fhandler.cc (fhandler_disk_file::open): Avoid checking a magic

View File

@ -15,6 +15,7 @@ details. */
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
int
main(int argc, char **argv)
@ -29,7 +30,7 @@ main(int argc, char **argv)
exit (0);
}
setenv("CYGWIN_TESTING", "1");
putenv("CYGWIN_TESTING=1");
SetEnvironmentVariable("CYGWIN_TESTING", "1");
memset(&sa, 0, sizeof(sa));

View File

@ -200,7 +200,10 @@ _mcleanup()
proffile = "gmon.out";
}
#else
proffile = "gmon.out";
{
char gmon_out[] = "gmon.out";
proffile = gmon_out;
}
#endif
fd = open(proffile , O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0666);

View File

@ -44,9 +44,9 @@ public:
int lmicrosec;
int execing;
strace() : version(1) {}
void prntf (unsigned, const char *func, const char *, ...);
void vprntf (unsigned, const char *func, const char *, va_list ap);
void wm (int message, int word, int lon);
void prntf (unsigned, const char *func, const char *, ...) /*__attribute__ ((regparm(3)))*/;
void vprntf (unsigned, const char *func, const char *, va_list ap) /*__attribute__ ((regparm(3)))*/;
void wm (int message, int word, int lon) __attribute__ ((regparm(3)));
};
extern strace strace;

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 ();
}

View File

@ -98,7 +98,7 @@ profile_off (struct profinfo *p)
static int
profile_on (struct profinfo *p)
{
int thrid;
DWORD thrid;
/* get handle for this thread */
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),

View File

@ -1666,9 +1666,9 @@ setmode (int fd, int mode)
setmode_file = fd;
_fwalk (_REENT, setmode_helper);
syscall_printf ("setmode (%d, %s) returns %s\n", fd,
mode&O_TEXT ? "text" : "binary",
res&O_TEXT ? "text" : "binary");
syscall_printf ("setmode (%d<%s>, %s) returns %s\n", fd, p->get_name (),
mode & O_TEXT ? "text" : "binary",
res & O_TEXT ? "text" : "binary");
return res;
}

View File

@ -212,12 +212,12 @@ void __stdcall set_console_title (char *);
void set_console_handler ();
#define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__)
void __set_winsock_errno (const char *fn, int ln);
void __set_winsock_errno (const char *fn, int ln) __attribute__ ((regparm(2)));
/* Printf type functions */
extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn));
extern "C" int __small_sprintf (char *dst, const char *fmt, ...);
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap);
extern "C" int __small_sprintf (char *dst, const char *fmt, ...) /*__attribute__ ((regparm (2)))*/;
extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/;
/**************************** Exports ******************************/