* 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:
		
							parent
							
								
									be61cf4d0c
								
							
						
					
					
						commit
						c90e420d91
					
				|  | @ -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> | 2001-04-02  Kazuhiro Fujieda  <fujieda@jaist.ac.jp> | ||||||
| 
 | 
 | ||||||
| 	* fhandler.cc (fhandler_disk_file::open): Avoid checking a magic | 	* fhandler.cc (fhandler_disk_file::open): Avoid checking a magic | ||||||
|  |  | ||||||
|  | @ -15,6 +15,7 @@ details. */ | ||||||
| 
 | 
 | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <windows.h> | #include <windows.h> | ||||||
|  | #include <stdlib.h> | ||||||
| 
 | 
 | ||||||
| int | int | ||||||
| main(int argc, char **argv) | main(int argc, char **argv) | ||||||
|  | @ -29,7 +30,7 @@ main(int argc, char **argv) | ||||||
|       exit (0); |       exit (0); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   setenv("CYGWIN_TESTING", "1"); |   putenv("CYGWIN_TESTING=1"); | ||||||
|   SetEnvironmentVariable("CYGWIN_TESTING", "1"); |   SetEnvironmentVariable("CYGWIN_TESTING", "1"); | ||||||
| 
 | 
 | ||||||
|   memset(&sa, 0, sizeof(sa)); |   memset(&sa, 0, sizeof(sa)); | ||||||
|  |  | ||||||
|  | @ -200,7 +200,10 @@ _mcleanup() | ||||||
| 		proffile = "gmon.out"; | 		proffile = "gmon.out"; | ||||||
| 	} | 	} | ||||||
| #else | #else | ||||||
| 	proffile = "gmon.out"; | 	{ | ||||||
|  | 	  char gmon_out[] = "gmon.out"; | ||||||
|  | 	  proffile = gmon_out; | ||||||
|  | 	} | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 	fd = open(proffile , O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0666); | 	fd = open(proffile , O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0666); | ||||||
|  |  | ||||||
|  | @ -44,9 +44,9 @@ public: | ||||||
|   int lmicrosec; |   int lmicrosec; | ||||||
|   int execing; |   int execing; | ||||||
|   strace() : version(1) {} |   strace() : version(1) {} | ||||||
|   void prntf (unsigned, const char *func, const char *, ...); |   void prntf (unsigned, const char *func, const char *, ...) /*__attribute__ ((regparm(3)))*/; | ||||||
|   void vprntf (unsigned, const char *func, const char *, va_list ap); |   void vprntf (unsigned, const char *func, const char *, va_list ap) /*__attribute__ ((regparm(3)))*/; | ||||||
|   void wm (int message, int word, int lon); |   void wm (int message, int word, int lon) __attribute__ ((regparm(3))); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| extern strace strace; | extern strace strace; | ||||||
|  |  | ||||||
|  | @ -247,26 +247,24 @@ static struct tl errmap[] = | ||||||
|  {0, NULL, 0} |  {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 */ | /* Cygwin internal */ | ||||||
| void | void | ||||||
| __set_winsock_errno (const char *fn, int ln) | __set_winsock_errno (const char *fn, int ln) | ||||||
| { | { | ||||||
|   int i; |   DWORD werr = WSAGetLastError (); | ||||||
|   int why = WSAGetLastError (); |   int err = find_winsock_errno (werr); | ||||||
|   for (i = 0; errmap[i].w != 0; ++i) |   set_errno (err); | ||||||
|     if (why == errmap[i].w) |   syscall_printf ("%s:%d - winsock error %d -> errno %d", fn, ln, werr, err); | ||||||
|       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); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  | @ -524,6 +522,9 @@ cygwin_setsockopt (int fd, | ||||||
| 	case SO_OOBINLINE: | 	case SO_OOBINLINE: | ||||||
| 	  name="SO_OOBINLINE"; | 	  name="SO_OOBINLINE"; | ||||||
| 	  break; | 	  break; | ||||||
|  | 	case SO_ERROR: | ||||||
|  | 	  name="SO_ERROR"; | ||||||
|  | 	  break; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|       res = setsockopt (h->get_socket (), level, optname, |       res = setsockopt (h->get_socket (), level, optname, | ||||||
|  | @ -584,11 +585,20 @@ cygwin_getsockopt (int fd, | ||||||
| 	case SO_OOBINLINE: | 	case SO_OOBINLINE: | ||||||
| 	  name="SO_OOBINLINE"; | 	  name="SO_OOBINLINE"; | ||||||
| 	  break; | 	  break; | ||||||
|  | 	case SO_ERROR: | ||||||
|  | 	  name="SO_ERROR"; | ||||||
|  | 	  break; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|       res = getsockopt (h->get_socket (), level, optname, |       res = getsockopt (h->get_socket (), level, optname, | ||||||
| 				       (char *) optval, (int *) optlen); | 				       (char *) optval, (int *) optlen); | ||||||
| 
 | 
 | ||||||
|  |       if (optname == SO_ERROR) | ||||||
|  | 	{ | ||||||
|  | 	  int *e = (int *) optval; | ||||||
|  | 	  *e = find_winsock_errno (*e); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|       if (res) |       if (res) | ||||||
| 	set_winsock_errno (); | 	set_winsock_errno (); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -98,7 +98,7 @@ profile_off (struct profinfo *p) | ||||||
| static int | static int | ||||||
| profile_on (struct profinfo *p) | profile_on (struct profinfo *p) | ||||||
| { | { | ||||||
|   int thrid; |   DWORD thrid; | ||||||
| 
 | 
 | ||||||
|   /* get handle for this thread */ |   /* get handle for this thread */ | ||||||
|   if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), |   if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), | ||||||
|  |  | ||||||
|  | @ -1666,9 +1666,9 @@ setmode (int fd, int mode) | ||||||
|   setmode_file = fd; |   setmode_file = fd; | ||||||
|   _fwalk (_REENT, setmode_helper); |   _fwalk (_REENT, setmode_helper); | ||||||
| 
 | 
 | ||||||
|   syscall_printf ("setmode (%d, %s) returns %s\n", fd, |   syscall_printf ("setmode (%d<%s>, %s) returns %s\n", fd, p->get_name (), | ||||||
| 		  mode&O_TEXT ? "text" : "binary", | 		  mode & O_TEXT ? "text" : "binary", | ||||||
| 		  res&O_TEXT ? "text" : "binary"); | 		  res & O_TEXT ? "text" : "binary"); | ||||||
| 
 | 
 | ||||||
|   return res; |   return res; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -212,12 +212,12 @@ void __stdcall set_console_title (char *); | ||||||
| void set_console_handler (); | void set_console_handler (); | ||||||
| 
 | 
 | ||||||
| #define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__) | #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 */ | /* Printf type functions */ | ||||||
| extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn)); | extern "C" void __api_fatal (const char *, ...) __attribute__ ((noreturn)); | ||||||
| extern "C" int __small_sprintf (char *dst, const char *fmt, ...); | 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); | extern "C" int __small_vsprintf (char *dst, const char *fmt, va_list ap) /*__attribute__ ((regparm (3)))*/; | ||||||
| 
 | 
 | ||||||
| /**************************** Exports ******************************/ | /**************************** Exports ******************************/ | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue