diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f98a93667..7e826ec9a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,18 @@ +Mon Apr 2 22:48:58 2001 Christopher Faylor + + * 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 * fhandler.cc (fhandler_disk_file::open): Avoid checking a magic diff --git a/winsup/cygwin/cygrun.c b/winsup/cygwin/cygrun.c index 8aa3e30a1..3086d7594 100644 --- a/winsup/cygwin/cygrun.c +++ b/winsup/cygwin/cygrun.c @@ -15,6 +15,7 @@ details. */ #include #include +#include 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)); diff --git a/winsup/cygwin/gmon.c b/winsup/cygwin/gmon.c index 6187a7c8f..e07d62221 100644 --- a/winsup/cygwin/gmon.c +++ b/winsup/cygwin/gmon.c @@ -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); diff --git a/winsup/cygwin/include/sys/strace.h b/winsup/cygwin/include/sys/strace.h index 6c85feba4..87cc1d785 100644 --- a/winsup/cygwin/include/sys/strace.h +++ b/winsup/cygwin/include/sys/strace.h @@ -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; diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index eaeef5e5d..5f10a68b0 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -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 (); } diff --git a/winsup/cygwin/profil.c b/winsup/cygwin/profil.c index 0cac701b0..8a615524b 100644 --- a/winsup/cygwin/profil.c +++ b/winsup/cygwin/profil.c @@ -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 (), diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 6ec1e0595..79eb62f75 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -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; } diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index 1578cdfca..c49010740 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -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 ******************************/