* dcrt0.cc (reent_data): Reluctantly resurrect.
(__cygwin_user_data::impure_ptr): Ditto. (_dll_crt0): Reluctantly initialize _impure_ptr here. (initialize_main_tls): Eliminate local_clib initialization since it now happens in init_thread. * init.cc (dll_entry): Reluctantly remove code which set _impure_ptr to the main thread's local_clib. * perthread.h (reent_data): Remove obsolete declaration. * sigproc.cc (proc_subproc): Add more debugging output. (get_proc_lock): Ditto. *dcrt0.cc (dll_crt0_1): Allocate argv[0] via malloc since main thread could exit.
This commit is contained in:
		
							parent
							
								
									1f32b7b382
								
							
						
					
					
						commit
						76832a5b32
					
				| 
						 | 
				
			
			@ -1,3 +1,20 @@
 | 
			
		|||
2003-12-25  Christopher Faylor  <cgf@redhat.com>
 | 
			
		||||
 | 
			
		||||
	* dcrt0.cc (reent_data): Reluctantly resurrect.
 | 
			
		||||
	(__cygwin_user_data::impure_ptr): Ditto.
 | 
			
		||||
	(_dll_crt0): Reluctantly initialize _impure_ptr here.
 | 
			
		||||
	(initialize_main_tls): Eliminate local_clib initialization since it now
 | 
			
		||||
	happens in init_thread.
 | 
			
		||||
	* init.cc (dll_entry): Reluctantly remove code which set _impure_ptr to
 | 
			
		||||
	the main thread's local_clib.
 | 
			
		||||
	* perthread.h (reent_data): Remove obsolete declaration.
 | 
			
		||||
 | 
			
		||||
	* sigproc.cc (proc_subproc): Add more debugging output.
 | 
			
		||||
	(get_proc_lock): Ditto.
 | 
			
		||||
 | 
			
		||||
	*dcrt0.cc (dll_crt0_1): Allocate argv[0] via malloc since main thread
 | 
			
		||||
	could exit.
 | 
			
		||||
 | 
			
		||||
2003-12-23  Christopher Faylor  <cgf@redhat.com>
 | 
			
		||||
 | 
			
		||||
	* fork.cc (fork_child): After a pthread/fork, ensure that impure
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -90,6 +90,7 @@ extern "C"
 | 
			
		|||
  char ***main_environ;
 | 
			
		||||
  /* __progname used in getopt error message */
 | 
			
		||||
  char *__progname;
 | 
			
		||||
  static struct _reent reent_data;
 | 
			
		||||
  struct per_process __cygwin_user_data =
 | 
			
		||||
  {/* initial_sp */ 0, /* magic_biscuit */ 0,
 | 
			
		||||
   /* dll_major */ CYGWIN_VERSION_DLL_MAJOR,
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +111,7 @@ extern "C"
 | 
			
		|||
   /* api_minor */ CYGWIN_VERSION_API_MINOR,
 | 
			
		||||
   /* unused2 */ {0, 0, 0, 0, 0},
 | 
			
		||||
   /* resourcelocks */ &_reslock, /* threadinterface */ &_mtinterf,
 | 
			
		||||
   /* impure_ptr */ NULL,
 | 
			
		||||
   /* impure_ptr */ &reent_data,
 | 
			
		||||
  };
 | 
			
		||||
  bool ignore_case_with_glob;
 | 
			
		||||
  int __declspec (dllexport) _check_for_executable = true;
 | 
			
		||||
| 
						 | 
				
			
			@ -700,9 +701,9 @@ dll_crt0_1 (char *)
 | 
			
		|||
	 win32 style. */
 | 
			
		||||
      if ((strchr (__argv[0], ':')) || (strchr (__argv[0], '\\')))
 | 
			
		||||
	{
 | 
			
		||||
	  char *new_argv0 = (char *) alloca (CYG_MAX_PATH);
 | 
			
		||||
	  char *new_argv0 = (char *) malloc (CYG_MAX_PATH);
 | 
			
		||||
	  cygwin_conv_to_posix_path (__argv[0], new_argv0);
 | 
			
		||||
	  __argv[0] = new_argv0;
 | 
			
		||||
	  __argv[0] = (char *) realloc (new_argv0, strlen (new_argv0) + 1);
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -826,9 +827,6 @@ initialize_main_tls (char *padding)
 | 
			
		|||
      _threadinfo::init ();
 | 
			
		||||
      _main_tls = &_my_tls;
 | 
			
		||||
      _main_tls->init_thread (padding);
 | 
			
		||||
      _main_tls->local_clib._stdin = &_main_tls->local_clib.__sf[0];
 | 
			
		||||
      _main_tls->local_clib._stdout = &_main_tls->local_clib.__sf[1];
 | 
			
		||||
      _main_tls->local_clib._stderr = &_main_tls->local_clib.__sf[2];
 | 
			
		||||
    }
 | 
			
		||||
  return &_main_tls->local_clib;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -906,7 +904,12 @@ _dll_crt0 ()
 | 
			
		|||
	}
 | 
			
		||||
    }
 | 
			
		||||
  
 | 
			
		||||
  user_data->impure_ptr = _impure_ptr = initialize_main_tls (zeros);
 | 
			
		||||
  _impure_ptr = &reent_data;
 | 
			
		||||
  _impure_ptr->_stdin = &_impure_ptr->__sf[0];
 | 
			
		||||
  _impure_ptr->_stdout = &_impure_ptr->__sf[1];
 | 
			
		||||
  _impure_ptr->_stderr = &_impure_ptr->__sf[2];
 | 
			
		||||
  _impure_ptr->_current_locale = "C";
 | 
			
		||||
  initialize_main_tls (zeros);
 | 
			
		||||
  dll_crt0_1 (zeros);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -300,7 +300,10 @@ fhandler_process::fill_filebuf ()
 | 
			
		|||
	filebuf = p->cmdline (fs);
 | 
			
		||||
	filesize = fs;
 | 
			
		||||
	if (!filebuf || !*filebuf)
 | 
			
		||||
	  filebuf = strdup ("<defunct>");
 | 
			
		||||
	  {
 | 
			
		||||
	    filebuf = strdup ("<defunct>");
 | 
			
		||||
	    filesize = strlen (filebuf) + 1;
 | 
			
		||||
	  }
 | 
			
		||||
	break;
 | 
			
		||||
      }
 | 
			
		||||
    case PROCESS_EXENAME:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
 | 
			
		|||
    {
 | 
			
		||||
    case DLL_PROCESS_ATTACH:
 | 
			
		||||
      dynamically_loaded = (static_load == NULL);
 | 
			
		||||
      __cygwin_user_data.impure_ptr = &_my_tls.local_clib;
 | 
			
		||||
      // __cygwin_user_data.impure_ptr = &_my_tls.local_clib;
 | 
			
		||||
      _my_tls.stackptr = _my_tls.stack;
 | 
			
		||||
      break;
 | 
			
		||||
    case DLL_PROCESS_DETACH:
 | 
			
		||||
| 
						 | 
				
			
			@ -60,6 +60,8 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
 | 
			
		|||
    case DLL_THREAD_ATTACH:
 | 
			
		||||
      munge_threadfunc (h);
 | 
			
		||||
      break;
 | 
			
		||||
    case DLL_THREAD_DETACH:
 | 
			
		||||
      break;
 | 
			
		||||
    }
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,9 +12,6 @@ details. */
 | 
			
		|||
 | 
			
		||||
#define PTMAGIC 0x77366377
 | 
			
		||||
 | 
			
		||||
struct _reent;
 | 
			
		||||
extern struct _reent reent_data;
 | 
			
		||||
 | 
			
		||||
#define PER_THREAD_FORK_CLEAR ((void *)UINT32_MAX)
 | 
			
		||||
class per_thread
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -226,14 +226,20 @@ get_proc_lock (DWORD what, DWORD val)
 | 
			
		|||
{
 | 
			
		||||
  Static int lastwhat = -1;
 | 
			
		||||
  if (!sync_proc_subproc)
 | 
			
		||||
    return false;
 | 
			
		||||
    {
 | 
			
		||||
      sigproc_printf ("sync_proc_subproc is NULL (1)");
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
  if (sync_proc_subproc->acquire (WPSP))
 | 
			
		||||
    {
 | 
			
		||||
      lastwhat = what;
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
  if (!sync_proc_subproc)
 | 
			
		||||
    return false;
 | 
			
		||||
    {
 | 
			
		||||
      sigproc_printf ("sync_proc_subproc is NULL (2)");
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
  system_printf ("Couldn't aquire sync_proc_subproc for(%d,%d), %E, last %d",
 | 
			
		||||
		  what, val, lastwhat);
 | 
			
		||||
  return true;
 | 
			
		||||
| 
						 | 
				
			
			@ -312,7 +318,7 @@ proc_subproc (DWORD what, DWORD val)
 | 
			
		|||
 | 
			
		||||
  if (!get_proc_lock (what, val))	// Serialize access to this function
 | 
			
		||||
    {
 | 
			
		||||
      system_printf ("couldn't get proc lock.  Something is wrong.");
 | 
			
		||||
      system_printf ("couldn't get proc lock. what %d, val %d", what, val);
 | 
			
		||||
      goto out1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -546,9 +552,7 @@ proc_terminate (void)
 | 
			
		|||
	  pchildren[i].release ();
 | 
			
		||||
	}
 | 
			
		||||
      nchildren = nzombies = 0;
 | 
			
		||||
      /* Just zero sync_proc_subproc as the delete below seems to cause
 | 
			
		||||
	 problems for older gccs. */
 | 
			
		||||
	sync_proc_subproc = NULL;
 | 
			
		||||
      sync_proc_subproc = NULL;
 | 
			
		||||
    }
 | 
			
		||||
  sigproc_printf ("leaving");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1167,9 +1171,9 @@ wait_sig (VOID *self)
 | 
			
		|||
	      int sigres = sig_handle (pack.sig, *pack.mask, pack.pid, pack.tls);
 | 
			
		||||
	      if (sigres <= 0)
 | 
			
		||||
		{
 | 
			
		||||
#ifdef DEBUGGING
 | 
			
		||||
#ifdef DEBUGGING2
 | 
			
		||||
		  if (!sigres)
 | 
			
		||||
		    system_printf ("Failed to arm signal %d from pid %d");
 | 
			
		||||
		    system_printf ("Failed to arm signal %d from pid %d", pack.sig, pack.pid);
 | 
			
		||||
#endif
 | 
			
		||||
		  sigqueue.add (pack.sig, pack.pid, pack.tls);// FIXME: Shouldn't add this in !sh condition
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue