Process.st
branchjv
changeset 19302 68355697fc84
parent 18192 32a7c53ef4d0
parent 19297 674bdfe7b7ed
child 19410 f9d7cb8bd74c
--- a/Process.st	Thu Mar 03 09:51:06 2016 +0000
+++ b/Process.st	Mon Mar 07 08:08:02 2016 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1992 by Claus Gittinger
 	      All Rights Reserved
@@ -14,11 +16,11 @@
 "{ NameSpace: Smalltalk }"
 
 Link subclass:#Process
-	instanceVariableNames:'id lookupActivations lookupDisabled prio state startBlock name restartable
-		interruptActions exitActions suspendSemaphore singleStepping
-		emergencySignalHandler suspendActions creatorId processGroupId
-		interruptsDisabled priorityRange exceptionHandlerSet processType
-		environment'
+	instanceVariableNames:'id lookupActivations lookupDisabled prio state startBlock name
+		restartable interruptActions exitActions suspendSemaphore
+		singleStepping emergencySignalHandler suspendActions creatorId
+		processGroupId interruptsDisabled priorityRange
+		exceptionHandlerSet processType environment'
 	classVariableNames:'TerminateSignal RestartSignal CaughtSignals'
 	poolDictionaries:''
 	category:'Kernel-Processes'
@@ -377,9 +379,10 @@
     "return the default max stack size. All new processes get
      this limit initially.
      It may be changed for individual processes with:
-	aProcess setMaximumStackSize:limit"
+        aProcess setMaximumStackSize:limit"
 
 %{  /* NOCONTEXT */
+    extern INT __defaultThreadMaxStackSize();
 
     RETURN ( __mkSmallInteger( __defaultThreadMaxStackSize() ));
 %}
@@ -395,15 +398,16 @@
     "set the default max stack size, return the previous value.
      All new processes get this stack limit initially.
      It may be changed for individual processes with:
-	aProcess setMaximumStackSize:limit
+        aProcess setMaximumStackSize:limit
      Notice:
-	There is seldom any need to change the default setting,
-	except for highly recursive programs."
+        There is seldom any need to change the default setting,
+        except for highly recursive programs."
 
 %{  /* NOCONTEXT */
+    extern INT __threadSetDefaultMaxStackSize();
 
     if (__isSmallInteger(numberOfBytes)) {
-	RETURN ( __mkSmallInteger(__threadSetDefaultMaxStackSize(__intVal(numberOfBytes)) ));
+        RETURN ( __mkSmallInteger(__threadSetDefaultMaxStackSize(__intVal(numberOfBytes)) ));
     }
 %}
 
@@ -412,6 +416,51 @@
     "
 
     "Modified: 8.5.1996 / 10:23:26 / cg"
+!
+
+wrapStackSize
+    "return the wrap stack size. 
+     Under windows, blocking API calls are executed on a separate stack with this size.
+     If you ever encounter that a call to n external library function requires more stack than
+     this, you may change this size in your startup (or programmatically) during early startup.
+     Returns nil on non-windows machines."
+
+%{  /* NOCONTEXT */
+    INT sz = 0;
+
+#ifdef WIN32
+    extern INT __getWrapStackSize();
+
+    sz = __getWrapStackSize();
+#endif
+    RETURN (__MKINT(sz));
+%}
+!
+
+wrapStackSize:newSize
+    "set the wrap stack size. 
+     Under windows, blocking API calls are executed on a separate stack with this size.
+     If you ever encounter that a call to n external library function requires more stack than
+     this, you may change this size in your startup (or programmatically) during early startup.
+     An argument of 0 changes the size back to the default.
+     Returns the previous size."
+
+%{  /* NOCONTEXT */
+    INT __oldSize = 0;
+
+    if (__isSmallInteger(newSize)) {
+        INT __newSize = __intVal(newSize);
+
+        if (__newSize >= 0) {
+#ifdef WIN32
+            extern INT __setWrapStackSize(INT);
+
+            __oldSize = __setWrapStackSize(__newSize);
+#endif
+        }
+    }
+    RETURN (__MKINT(__oldSize));
+%}
 ! !
 
 !Process class methodsFor:'instance retrieval'!
@@ -477,7 +526,6 @@
     "Created: 15.11.1996 / 11:41:06 / cg"
 ! !
 
-
 !Process methodsFor:'accessing'!
 
 beGUIProcess
@@ -785,11 +833,11 @@
      needs more stack (in bytes) than this number"
 
 %{  /* NOCONTEXT */
-    extern int __threadMaxStackSize();
+    extern INT __threadMaxStackSize();
     OBJ i;
 
     if (__isSmallInteger(i = __INST(id))) {
-	RETURN( __mkSmallInteger(__threadMaxStackSize(__intVal(i))) );
+        RETURN( __MKINT(__threadMaxStackSize(__intVal(i))) );
     }
 %}.
     ^ nil
@@ -802,12 +850,12 @@
      Returns the old value."
 
 %{  /* NOCONTEXT */
-    extern int __threadSetMaxStackSize();
+    extern INT __threadSetMaxStackSize(int, unsigned INT);
     OBJ i;
 
     if (__isSmallInteger(i = __INST(id))
      && __isSmallInteger(limit) ) {
-	RETURN ( __mkSmallInteger(__threadSetMaxStackSize(__intVal(i), __intVal(limit))) );
+        RETURN ( __MKINT(__threadSetMaxStackSize(__intVal(i), __intVal(limit))) );
     }
 %}.
     ^ nil
@@ -818,14 +866,15 @@
      and stackIncrement-parameters. Not for normal use."
 
 %{  /* NOCONTEXT */
-    extern int __threadSetJunkSizes();
+    extern INT __threadSetJunkSizes(int, unsigned INT, unsigned INT, unsigned INT);
+
     OBJ i;
 
     if (__isSmallInteger(i = __INST(id))
      && __isSmallInteger(initial)
      && __isSmallInteger(increment)
      && __isSmallInteger(safe)) {
-	RETURN ( __threadSetJunkSizes(__intVal(i), __intVal(initial), __intVal(increment), __intVal(safe)) ? true : false );
+        RETURN ( __threadSetJunkSizes(__intVal(i), __intVal(initial), __intVal(increment), __intVal(safe)) ? true : false );
     }
 %}.
     ^ false
@@ -1025,14 +1074,14 @@
     "internal monitoring only - will vanish"
 
 %{  /* NOCONTEXT */
-    extern int __threadNumberOfStackBoundaryHits();
-    int n;
+    extern INT __threadNumberOfStackBoundaryHits();
+    INT n;
     OBJ i;
 
     if (__isSmallInteger(i = __INST(id))) {
-	n = __threadNumberOfStackBoundaryHits(__intVal(i));
-	n &= _MAX_INT;
-	RETURN( __mkSmallInteger(n) );
+        n = __threadNumberOfStackBoundaryHits(__intVal(i));
+        n &= _MAX_INT;
+        RETURN( __mkSmallInteger(n) );
     }
 %}.
     ^ nil
@@ -1043,11 +1092,11 @@
      This method is for monitoring purposes only - it may vanish."
 
 %{  /* NOCONTEXT */
-    extern int __threadTotalStackSize();
+    extern int __threadStackSegments();
     OBJ i;
 
     if (__isSmallInteger(i = __INST(id))) {
-	RETURN( __mkSmallInteger((INT)__threadStackSegments(__intVal(i))) );
+        RETURN( __mkSmallInteger((INT)__threadStackSegments(__intVal(i))) );
     }
 %}.
     ^ nil
@@ -1058,11 +1107,11 @@
      This method is for monitoring purposes only - it may vanish."
 
 %{  /* NOCONTEXT */
-    extern int __threadTotalStackSize();
+    extern INT __threadTotalStackSize();
     OBJ i;
 
     if (__isSmallInteger(i = __INST(id))) {
-	RETURN( __mkSmallInteger(__threadTotalStackSize(__intVal(i))) );
+        RETURN( __MKINT(__threadTotalStackSize(__intVal(i))) );
     }
 %}.
     ^ nil
@@ -1077,7 +1126,7 @@
     OBJ i;
 
     if (__isSmallInteger(i = __INST(id))) {
-	RETURN( __mkSmallInteger(__threadUsedStackSize(__intVal(i))) );
+        RETURN( __MKINT(__threadUsedStackSize(__intVal(i))) );
     }
 %}.
     ^ nil
@@ -2047,7 +2096,6 @@
     "Created: 28.10.1996 / 20:44:07 / cg"
 ! !
 
-
 !Process methodsFor:'thread local storage'!
 
 environmentAt:aKey
@@ -2146,9 +2194,12 @@
 
 !Process class methodsFor:'documentation'!
 
+version
+    ^ '$Header$'
+!
+
 version_CVS
-
-    ^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.191 2015-04-07 10:52:50 cg Exp $'
+    ^ '$Header$'
 !
 
 version_SVN