stack limit

Alexandre Julliard julliard at winehq.com
Wed Jun 6 18:00:39 CDT 2001


Stephen Crowley <stephenc at placemark.com> writes:

> On Mon, Jun 04, 2001 at 12:02:09PM -0700, Alexandre Julliard wrote:
> > There is no way to do this at the moment; but it shouldn't be too hard
> > to add support for a 'stack' statement in the application spec file.
> 
> Thanks. Where would I look to change this in the source? I'm using some linear
> regression DLLs under linux and we have to deal with some fairly large
> matrices. 

Try this:

Index: scheduler/process.c
===================================================================
RCS file: /opt/cvs-commit/wine/scheduler/process.c,v
retrieving revision 1.154
diff -u -r1.154 process.c
--- scheduler/process.c	2001/06/06 20:24:13	1.154
+++ scheduler/process.c	2001/06/06 22:46:20
@@ -319,12 +319,6 @@
     LPTHREAD_START_ROUTINE entry;
     WINE_MODREF *wm;
 
-    /* build command line */
-    if (!ENV_BuildCommandLine( main_exe_argv )) goto error;
-
-    /* create 32-bit module for main exe */
-    if (!(current_process.module = BUILTIN32_LoadExeModule( current_process.module ))) goto error;
-
     /* use original argv[0] as name for the main module */
     if (!main_exe_name[0])
     {
@@ -498,7 +492,6 @@
     {
         if (PE_HEADER(current_process.module)->FileHeader.Characteristics & IMAGE_FILE_DLL)
             ExitProcess( ERROR_BAD_EXE_FORMAT );
-        stack_size = PE_HEADER(current_process.module)->OptionalHeader.SizeOfStackReserve;
         goto found;
     }
 
@@ -512,6 +505,13 @@
     _EnterWin16Lock();
 
  found:
+    /* build command line */
+    if (!ENV_BuildCommandLine( main_exe_argv )) goto error;
+
+    /* create 32-bit module for main exe */
+    if (!(current_process.module = BUILTIN32_LoadExeModule( current_process.module ))) goto error;
+    stack_size = PE_HEADER(current_process.module)->OptionalHeader.SizeOfStackReserve;
+
     /* allocate main thread stack */
     if (!THREAD_InitStack( NtCurrentTeb(), stack_size )) goto error;
 
Index: tools/winebuild/README
===================================================================
RCS file: /opt/cvs-commit/wine/tools/winebuild/README,v
retrieving revision 1.4
diff -u -r1.4 README
--- tools/winebuild/README	2000/12/26 01:22:34	1.4
+++ tools/winebuild/README	2001/06/06 22:46:21
@@ -6,6 +6,7 @@
 [file   WINFILENAME]
 [mode	dll|cuiexe|guiexe|cuiexe_unicode|guiexe_unicode]
 [heap   SIZE]
+[stack  SIZE]
 [init	FUNCTION]
 [import [IMP_FLAGS] DLL]
 [rsrc	RESFILE]
@@ -39,6 +40,9 @@
 
 "heap" is the size of the module local heap (only valid for Win16
 modules); default is no local heap.
+
+"stack" is the stack size for Win32 exe modules, in kilobytes; default
+size is 1024 (1Mb stack).
 
 "file" gives the name of the Windows file that is replaced by the
 builtin. <name>.DLL is assumed if none is given. (This is important
Index: tools/winebuild/build.h
===================================================================
RCS file: /opt/cvs-commit/wine/tools/winebuild/build.h,v
retrieving revision 1.17
diff -u -r1.17 build.h
--- tools/winebuild/build.h	2001/05/22 19:55:51	1.17
+++ tools/winebuild/build.h	2001/06/06 22:46:21
@@ -161,6 +161,7 @@
 extern int DLLHeapSize;
 extern int UsePIC;
 extern int debugging;
+extern int stack_size;
 extern int nb_debug_channels;
 extern int nb_lib_paths;
 
Index: tools/winebuild/main.c
===================================================================
RCS file: /opt/cvs-commit/wine/tools/winebuild/main.c,v
retrieving revision 1.17
diff -u -r1.17 main.c
--- tools/winebuild/main.c	2001/05/22 19:55:51	1.17
+++ tools/winebuild/main.c	2001/06/06 22:46:21
@@ -27,6 +27,7 @@
 int Limit = 0;
 int DLLHeapSize = 0;
 int UsePIC = 0;
+int stack_size = 0;
 int nb_entry_points = 0;
 int nb_names = 0;
 int nb_debug_channels = 0;
Index: tools/winebuild/parser.c
===================================================================
RCS file: /opt/cvs-commit/wine/tools/winebuild/parser.c,v
retrieving revision 1.18
diff -u -r1.18 parser.c
--- tools/winebuild/parser.c	2001/05/22 19:55:51	1.18
+++ tools/winebuild/parser.c	2001/06/06 22:46:21
@@ -559,6 +559,12 @@
             if (!IsNumberString(token)) fatal_error( "Expected number after heap\n" );
             DLLHeapSize = atoi(token);
 	}
+        else if (strcmp(token, "stack") == 0)
+        {
+            token = GetToken(0);
+            if (!IsNumberString(token)) fatal_error( "Expected number after stack\n" );
+            stack_size = atoi(token);
+        }
         else if (strcmp(token, "init") == 0)
         {
             if (SpecType == SPEC_WIN16)
Index: tools/winebuild/spec32.c
===================================================================
RCS file: /opt/cvs-commit/wine/tools/winebuild/spec32.c,v
retrieving revision 1.28
diff -u -r1.28 spec32.c
--- tools/winebuild/spec32.c	2001/05/22 19:55:51	1.28
+++ tools/winebuild/spec32.c	2001/06/06 22:46:21
@@ -656,7 +656,10 @@
     fprintf( outfile, "    %ld,\n", page_size );         /* SizeOfHeaders */
     fprintf( outfile, "    0,\n" );                      /* CheckSum */
     fprintf( outfile, "    0x%04x,\n", subsystem );      /* Subsystem */
-    fprintf( outfile, "    0, 0, 0, 0, 0, 0,\n" );
+    fprintf( outfile, "    0,\n" );                      /* DllCharacteristics */
+    fprintf( outfile, "    %d, 0,\n", stack_size*1024 ); /* SizeOfStackReserve/Commit */
+    fprintf( outfile, "    %d, 0,\n", DLLHeapSize*1024 );/* SizeOfHeapReserve/Commit */
+    fprintf( outfile, "    0,\n" );                      /* LoaderFlags */
     fprintf( outfile, "    %d,\n", IMAGE_NUMBEROF_DIRECTORY_ENTRIES );  /* NumberOfRvaAndSizes */
     fprintf( outfile, "    {\n" );
     fprintf( outfile, "      { %s, %d },\n",  /* IMAGE_DIRECTORY_ENTRY_EXPORT */

-- 
Alexandre Julliard
julliard at winehq.com




More information about the wine-devel mailing list