* Makefile.in (dtable_CFLAGS): Use -fomit-frame-pointer and -fcheck-new.
* cygheap.cc (cmalloc): Only emit system_printf warnings on failure if DEBUGGING. (crealloc): Ditto. (ccalloc): Ditto. * dtable.cc (build_fh_name): Treat NULL return from cnew as indicative of EMFILE condition. (build_fh_dev): Ditto. (dtable::dup_worker): Handle NULL return from build_fh_pc. (dtable::vfork_child_dup): Trust dup_worker to set errno. * fhandler.h (fhandler_base::new): Mark as nothrow.
This commit is contained in:
		| @@ -1,3 +1,18 @@ | |||||||
|  | 2005-08-07  Christopher Faylor  <cgf@timesys.com> | ||||||
|  |  | ||||||
|  | 	* Makefile.in (dtable_CFLAGS): Use -fomit-frame-pointer and | ||||||
|  | 	-fcheck-new. | ||||||
|  | 	* cygheap.cc (cmalloc): Only emit system_printf warnings on failure if | ||||||
|  | 	DEBUGGING. | ||||||
|  | 	(crealloc): Ditto. | ||||||
|  | 	(ccalloc): Ditto. | ||||||
|  | 	* dtable.cc (build_fh_name): Treat NULL return from cnew as indicative | ||||||
|  | 	of EMFILE condition. | ||||||
|  | 	(build_fh_dev): Ditto. | ||||||
|  | 	(dtable::dup_worker): Handle NULL return from build_fh_pc. | ||||||
|  | 	(dtable::vfork_child_dup): Trust dup_worker to set errno. | ||||||
|  | 	* fhandler.h (fhandler_base::new): Mark as nothrow. | ||||||
|  |  | ||||||
| 2005-08-07  Christopher Faylor  <cgf@timesys.com> | 2005-08-07  Christopher Faylor  <cgf@timesys.com> | ||||||
|  |  | ||||||
| 	* dllfixdbg: New perl script. | 	* dllfixdbg: New perl script. | ||||||
|   | |||||||
| @@ -230,6 +230,7 @@ devices_CFLAGS:=-fomit-frame-pointer -Os | |||||||
| dir_CFLAGS:=-fomit-frame-pointer | dir_CFLAGS:=-fomit-frame-pointer | ||||||
| dlfcn_CFLAGS:=-fomit-frame-pointer | dlfcn_CFLAGS:=-fomit-frame-pointer | ||||||
| dll_init_CFLAGS:=-fomit-frame-pointer | dll_init_CFLAGS:=-fomit-frame-pointer | ||||||
|  | dtable_CFLAGS:=-fomit-frame-pointer -fcheck-new | ||||||
| fcntl_CFLAGS:=-fomit-frame-pointer | fcntl_CFLAGS:=-fomit-frame-pointer | ||||||
| fhandler_CFLAGS:=-fomit-frame-pointer | fhandler_CFLAGS:=-fomit-frame-pointer | ||||||
| fhandler_clipboard_CFLAGS:=-fomit-frame-pointer | fhandler_clipboard_CFLAGS:=-fomit-frame-pointer | ||||||
|   | |||||||
| @@ -279,8 +279,8 @@ cmalloc (cygheap_types x, DWORD n) | |||||||
|   c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n)); |   c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n)); | ||||||
|   if (!c) |   if (!c) | ||||||
|     { |     { | ||||||
|       system_printf ("cmalloc returned NULL"); |  | ||||||
| #ifdef DEBUGGING | #ifdef DEBUGGING | ||||||
|  |       system_printf ("cmalloc returned NULL"); | ||||||
|       try_to_debug (); |       try_to_debug (); | ||||||
| #endif | #endif | ||||||
|     } |     } | ||||||
| @@ -298,8 +298,10 @@ crealloc (void *s, DWORD n) | |||||||
|   cygheap_entry *c = tocygheap (s); |   cygheap_entry *c = tocygheap (s); | ||||||
|   cygheap_types t = (cygheap_types) c->type; |   cygheap_types t = (cygheap_types) c->type; | ||||||
|   c = (cygheap_entry *) _crealloc (c, sizeof_cygheap (n)); |   c = (cygheap_entry *) _crealloc (c, sizeof_cygheap (n)); | ||||||
|  | #ifdef DEBUGGING | ||||||
|   if (!c) |   if (!c) | ||||||
|     system_printf ("crealloc returned NULL"); |     system_printf ("crealloc returned NULL"); | ||||||
|  | #endif | ||||||
|   return creturn (t, c, n); |   return creturn (t, c, n); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -328,8 +330,10 @@ ccalloc (cygheap_types x, DWORD n, DWORD size) | |||||||
|   c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n)); |   c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n)); | ||||||
|   if (c) |   if (c) | ||||||
|     memset (c->data, 0, n); |     memset (c->data, 0, n); | ||||||
|  | #ifdef DEBUGGING | ||||||
|   if (!c) |   if (!c) | ||||||
|     system_printf ("ccalloc returned NULL"); |     system_printf ("ccalloc returned NULL"); | ||||||
|  | #endif | ||||||
|   return creturn (x, c, n); |   return creturn (x, c, n); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -725,6 +725,11 @@ dll_crt0_1 (char *) | |||||||
|  |  | ||||||
|   check_sanity_and_sync (user_data); |   check_sanity_and_sync (user_data); | ||||||
|   malloc_init (); |   malloc_init (); | ||||||
|  | #ifdef CGF | ||||||
|  |   int i = 0; | ||||||
|  |   while (i) | ||||||
|  |     cmalloc (HEAP_STR, 2000000); | ||||||
|  | #endif | ||||||
|  |  | ||||||
|   /* Initialize SIGSEGV handling, etc. */ |   /* Initialize SIGSEGV handling, etc. */ | ||||||
|   init_exceptions (&cygwin_except_entry); |   init_exceptions (&cygwin_except_entry); | ||||||
|   | |||||||
| @@ -342,8 +342,9 @@ build_fh_name (const char *name, HANDLE h, unsigned opt, suffix_info *si) | |||||||
|   if (pc.error) |   if (pc.error) | ||||||
|     { |     { | ||||||
|       fhandler_base *fh = cnew (fhandler_nodevice) (); |       fhandler_base *fh = cnew (fhandler_nodevice) (); | ||||||
|       fh->set_error (pc.error); |       if (fh) | ||||||
|       set_errno (pc.error); | 	fh->set_error (pc.error); | ||||||
|  |       set_errno (fh ? pc.error : EMFILE); | ||||||
|       return fh; |       return fh; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -364,10 +365,11 @@ build_fh_dev (const device& dev, const char *unix_name) | |||||||
|   return build_fh_pc (pc); |   return build_fh_pc (pc); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #define fh_unset ((fhandler_base *) 1) | ||||||
| fhandler_base * | fhandler_base * | ||||||
| build_fh_pc (path_conv& pc) | build_fh_pc (path_conv& pc) | ||||||
| { | { | ||||||
|   fhandler_base *fh = NULL; |   fhandler_base *fh = fh_unset; | ||||||
|  |  | ||||||
|   switch (pc.dev.major) |   switch (pc.dev.major) | ||||||
|     { |     { | ||||||
| @@ -472,9 +474,13 @@ build_fh_pc (path_conv& pc) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|   if (!fh) |   if (!fh) | ||||||
|     fh = cnew (fhandler_nodevice) (); |     set_errno (EMFILE); | ||||||
|  |   else | ||||||
|   fh->set_name (pc); |     { | ||||||
|  |       if (fh == fh_unset) | ||||||
|  | 	fh = cnew (fhandler_nodevice) (); | ||||||
|  |       fh->set_name (pc); | ||||||
|  |     } | ||||||
|  |  | ||||||
|   debug_printf ("fh %p", fh); |   debug_printf ("fh %p", fh); | ||||||
|   return fh; |   return fh; | ||||||
| @@ -484,18 +490,23 @@ fhandler_base * | |||||||
| dtable::dup_worker (fhandler_base *oldfh) | dtable::dup_worker (fhandler_base *oldfh) | ||||||
| { | { | ||||||
|   fhandler_base *newfh = build_fh_pc (oldfh->pc); |   fhandler_base *newfh = build_fh_pc (oldfh->pc); | ||||||
|   *newfh = *oldfh; |   if (!newfh) | ||||||
|   newfh->set_io_handle (NULL); |     debug_printf ("build_fh_pc failed"); | ||||||
|   if (oldfh->dup (newfh)) |   else | ||||||
|     { |     { | ||||||
|       cfree (newfh); |       *newfh = *oldfh; | ||||||
|       newfh = NULL; |       newfh->set_io_handle (NULL); | ||||||
|       return NULL; |       if (oldfh->dup (newfh)) | ||||||
|  | 	{ | ||||||
|  | 	  cfree (newfh); | ||||||
|  | 	  debug_printf ("oldfh->dup failed"); | ||||||
|  | 	} | ||||||
|  |       else | ||||||
|  | 	{ | ||||||
|  | 	  newfh->close_on_exec (false); | ||||||
|  | 	  debug_printf ("duped '%s' old %p, new %p", oldfh->get_name (), oldfh->get_io_handle (), newfh->get_io_handle ()); | ||||||
|  | 	} | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   newfh->close_on_exec (false); |  | ||||||
|   MALLOC_CHECK; |  | ||||||
|   debug_printf ("duped '%s' old %p, new %p", oldfh->get_name (), oldfh->get_io_handle (), newfh->get_io_handle ()); |  | ||||||
|   return newfh; |   return newfh; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -745,7 +756,6 @@ dtable::vfork_child_dup () | |||||||
|     else |     else | ||||||
|       { |       { | ||||||
| 	res = 0; | 	res = 0; | ||||||
| 	set_errno (EBADF); |  | ||||||
| 	goto out; | 	goto out; | ||||||
|       } |       } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -301,7 +301,7 @@ class fhandler_base | |||||||
| 				      _off64_t offset, DWORD size, | 				      _off64_t offset, DWORD size, | ||||||
| 				      void *address); | 				      void *address); | ||||||
|  |  | ||||||
|   void *operator new (size_t, void *p) {return p;} |   void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;} | ||||||
|  |  | ||||||
|   virtual void init (HANDLE, DWORD, mode_t); |   virtual void init (HANDLE, DWORD, mode_t); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user