* Makefile.in: Use variables rather than configure constructs where
appropriate. (LIBCOS): Find additional stub library stuff in their own subdirectory. * dcrt0.cc: Convert user_data pointer to static __cygwin_user_data area. (do_global_ctors): Check magic_bisquit for initialization. (dll_crt0_1): First group of premain functions prior to fd initialization. Run second group before calling main. (dll_crt0 ()): New function, called from new initialization code. (dll_crt0 (per_process *uptr)): Call new dll_crt0 () function on initialization. * debug.cc (thread_stub): Initialize bottom of stack with per-thread info. * environ.cc (parse_thing): Use binmode global to control CYGWIN=binmode behavior. * fhandler.cc (fhandler_base::open): Allow explicit setting of __fmode to O_BINARY or O_TEXT to override disk mount settings. * libcmain.cc: Move to lib subdirectory. * libccrt0.cc: Ditto. * dll_main.cc: Ditto. * dll_entry.cc: Ditto. * getopt.c: Ditto. * thread.cc (thread_init_wrapper): Call ExitThread explicitly rather than returning, as a preliminary step towards placing per thread info at the bottom of the stack. * winsup.h: Move per_process class to include/sys/cygwin.h. Declare new dll_crt0(). * include/cygwin/version.h: Bump API minor version. * binmode.c: New file. * textmode.c: Ditto. * lib/_cygwin_crt0_common.cc: Ditto. * lib/crt0.h: Ditto. * lib/cygwin_attach_dll.c: Ditto. * lib/cygwin_crt0.c: Ditto. * lib/dll_entry.cc: Ditto. * lib/dll_main.cc: Ditto. * lib/getopt.c: Ditto. * lib/libcmain.c: Ditto. * lib/premain0.c: Ditto. * lib/premain1.c: Ditto. * lib/premain2.c: Ditto. * lib/premain3.c: Ditto.
This commit is contained in:
@@ -19,14 +19,13 @@ details. */
|
||||
|
||||
#define MAX_AT_FILE_LEVEL 10
|
||||
|
||||
#define PREMAIN_LEN (sizeof(user_data->premain) / sizeof (user_data->premain[0]))
|
||||
|
||||
HANDLE NO_COPY hMainProc = NULL;
|
||||
HANDLE NO_COPY hMainThread = NULL;
|
||||
|
||||
sigthread NO_COPY mainthread; // ID of the main thread
|
||||
|
||||
static NO_COPY char dummy_user_data[sizeof (per_process)] = {0};
|
||||
per_process NO_COPY *user_data = (per_process *) &dummy_user_data;
|
||||
|
||||
per_thread_waitq NO_COPY waitq_storage;
|
||||
per_thread_vfork NO_COPY vfork_storage;
|
||||
per_thread_signal_dispatch NO_COPY signal_dispatch_storage;
|
||||
@@ -56,12 +55,11 @@ extern "C"
|
||||
which use cygwin.dll. */
|
||||
char **__cygwin_environ;
|
||||
/* __progname used in getopt error message */
|
||||
char *__progname;
|
||||
char *__progname = NULL;
|
||||
struct _reent reent_data;
|
||||
struct per_process __cygwin_user_data;
|
||||
};
|
||||
|
||||
static void dll_crt0_1 ();
|
||||
|
||||
char *old_title = NULL;
|
||||
char title_buf[TITLESIZE + 1];
|
||||
|
||||
@@ -96,13 +94,12 @@ do_global_ctors (void (**in_pfunc)(), int force)
|
||||
while (--pfunc > in_pfunc)
|
||||
(*pfunc) ();
|
||||
|
||||
if (user_data != (per_process *) &dummy_user_data)
|
||||
if (user_data->magic_biscuit == SIZEOF_PER_PROCESS)
|
||||
atexit (do_global_dtors);
|
||||
}
|
||||
|
||||
/* remember the type of Win32 OS being run for future use. */
|
||||
os_type NO_COPY os_being_run;
|
||||
|
||||
char NO_COPY osname[40];
|
||||
|
||||
/* set_os_type: Set global variable os_being_run with type of Win32
|
||||
@@ -576,7 +573,6 @@ dll_crt0_1 ()
|
||||
be on the stack. */
|
||||
/* FIXME: Verify forked children get their exception handler set up ok. */
|
||||
exception_list cygwin_except_entry;
|
||||
|
||||
do_global_ctors (&__CTOR_LIST__, 1);
|
||||
|
||||
#ifdef DEBUGGING
|
||||
@@ -734,6 +730,10 @@ dll_crt0_1 ()
|
||||
/* Connect to tty. */
|
||||
tty_init ();
|
||||
|
||||
if (user_data->premain[0])
|
||||
for (unsigned int i = 0; i < PREMAIN_LEN / 2; i++)
|
||||
user_data->premain[i] (argc, argv);
|
||||
|
||||
/* Set up standard fds in file descriptor table. */
|
||||
hinfo_init ();
|
||||
|
||||
@@ -758,13 +758,18 @@ dll_crt0_1 ()
|
||||
DllList::the().initAll();
|
||||
|
||||
set_errno (0);
|
||||
debug_printf ("user_data->main %p", user_data->main);
|
||||
|
||||
/* Flush signals and ensure that signal thread is up and running. Can't
|
||||
do this for noncygwin case since the signal thread is blocked due to
|
||||
LoadLibrary serialization. */
|
||||
sig_send (NULL, __SIGFLUSH); /* also initializes uid, gid */
|
||||
|
||||
/* Execute any specified "premain" functions */
|
||||
if (user_data->premain[0])
|
||||
for (unsigned int i = PREMAIN_LEN / 2; i < PREMAIN_LEN; i++)
|
||||
user_data->premain[i] (argc, argv);
|
||||
|
||||
debug_printf ("user_data->main %p", user_data->main);
|
||||
if (user_data->main)
|
||||
exit (user_data->main (argc, argv, *user_data->envptr));
|
||||
}
|
||||
@@ -775,12 +780,20 @@ dll_crt0_1 ()
|
||||
UPTR is a pointer to global data that lives on the libc side of the
|
||||
line [if one distinguishes the application from the dll]. */
|
||||
|
||||
void
|
||||
dll_crt0 (per_process *uptr)
|
||||
void __stdcall
|
||||
dll_crt0 ()
|
||||
{
|
||||
char zeros[sizeof (ciresrv->zero)] = {0};
|
||||
/* Set the local copy of the pointer into the user space. */
|
||||
user_data = uptr;
|
||||
|
||||
#ifdef DEBUGGING
|
||||
char buf[80];
|
||||
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf)))
|
||||
{
|
||||
small_printf ("Sleeping %d, pid %u\n", atoi (buf), GetCurrentProcessId ());
|
||||
Sleep (atoi(buf));
|
||||
}
|
||||
#endif
|
||||
|
||||
user_data->heapbase = user_data->heapptr = user_data->heaptop = NULL;
|
||||
|
||||
set_console_handler ();
|
||||
@@ -845,6 +858,15 @@ dll_crt0 (per_process *uptr)
|
||||
dll_crt0_1 ();
|
||||
}
|
||||
|
||||
void
|
||||
dll_crt0 (per_process *uptr)
|
||||
{
|
||||
/* Set the local copy of the pointer into the user space. */
|
||||
if (uptr)
|
||||
*user_data = *uptr;
|
||||
dll_crt0 ();
|
||||
}
|
||||
|
||||
extern "C" void *export_malloc (unsigned int);
|
||||
extern "C" void export_free (void *);
|
||||
extern "C" void *export_realloc (void *, unsigned int);
|
||||
|
Reference in New Issue
Block a user