Release 980118

Sun Jan 18 17:05:58 1998  Alexandre Julliard  <julliard@lrc.epfl.ch>

	* [include/stackframe.h] [tools/build.c]
	Some cleanups in stack frame building.

	* [misc/port.c]
	Implemented clone() wrapper for libc5 users.

	* [scheduler/mutex.c] [scheduler/synchro.c]
	Implemented abandoned mutexes.

	* [scheduler/process.c] [scheduler/thread.c]
	We now create a process and a thread structure as soon as possible
	during initialization.

	* [scheduler/thread.c] [scheduler/sysdeps.c]
	Moved system-specific thread handling to sysdeps.c.

Fri Jan 16 10:45:15 1998  Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>

	* [graphics/ddraw.c][include/ddraw.h]
	Surface handling enhanced. Some stuff already works ;)

	* [multimedia/dsound.c][include/dsound.h]
	Implemented using the Open Sound System.
	Slowly starts to work (sounds terrible for some programs).

	* [configure.in][multimedia/audio.c][include/config.h.in]
	Added check for OpenSoundSystem, fixed -lXxf86dga check.
	Replaced OS #ifdefs by #ifdef HAVE_OSS in mm/audio.c.

	* [if1632/relay.c][relay32/relay386.c]
	Do not print control characters for 'str' or 'wstr' args.

	* [misc/registry.c]
	"" seems to equals NULL in keynames. Replace where needed. Seems
	to help the win95 regedit.exe...

	* [win32/newfns.c]
	Implemented QueryPerformance* using gettimeofday(2)
	(should be done using the pentium timers probably).

	* [tools/ipcl]
	Removed useless open_pipe construct.

Sun Jan 11 17:10:02 1998  Huw D M Davies <h.davies1@physics.oxford.ac.uk>

	* [objects/region.c] [include/region.h] [graphics/x11drv/clipping.c]
	Regions are now internal to Wine. The basis of this code is taken
	from the X11 distribution. GetRegionData() is implemented as is 
	ExtCreateRegion() (without Xforms). CreatePolyPolygonRgn() should
	behave correctly now. 

	* [objects/metafile.c] [graphics/metafiledrv/graphics.c]
	  [graphics/metafiledrv/init.c] [include/metafile.h]
	  [include/metafiledrv.h]
	Playback of META_CREATEREGION should now work. Implemented recording
	of META_CREATEREGION and META_PAINTREGION.

	* [graphics/x11drv/graphics.c]
	FillRgn() (and therefore its friends) respect logical co-ords.

Wed Jan  7 01:21:45 1998  Steinar Hamre  <steinarh@stud.fim.ntnu.no>

	* [configure.in] [include/acconfig.h] [tools/build.c]
	Now checking whether to use .string or .ascii.

	* [configure.in] [include/acconfig.h] [scheduler/critsection.c]
	Defining union semun if this is not available from header files.

	* [misc/lstr.c]
	Moved wine's own header files below <wctype.h> to avoid
	parse error on Solaris.

Sun Jan  4 15:38:07 1998  Andrew Taylor <ataylor@cadvision.com>

	* [multimedia/mmsystem.c] [multimedia/mmio.c]
	Implemented mmioSendMessage and rearranged the mmio
	subsystem in terms of this function.

Wed Dec 24 00:51:29 1997  Charles Duffy <cduffy@bigfoot.com>

	* [windows/clipboard.c] [relay32/user32.spec]
	GetPriorityClipboardFormat32 now has something other than just
	a stub. I have no idea if it works (can't test until
	SetClipboardData is finished) but HEdit likes things a lot more
	this way.
diff --git a/loader/task.c b/loader/task.c
index 110a799..7c31fae 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -56,7 +56,7 @@
 static HGLOBAL16 TASK_CreateDOSEnvironment(void);
 static void	 TASK_YieldToSystem(TDB*);
 
-static THDB TASK_SystemTHDB;
+
 /***********************************************************************
  *           TASK_Init
  */
@@ -64,8 +64,6 @@
 {
     if (!(hDOSEnvironment = TASK_CreateDOSEnvironment()))
         fprintf( stderr, "Not enough memory for DOS Environment\n" );
-    TASK_SystemTHDB.teb_sel = SELECTOR_AllocBlock( &TASK_SystemTHDB, 0x1000, SEGMENT_DATA, TRUE, FALSE );
-    SET_FS( TASK_SystemTHDB.teb_sel );
     return (hDOSEnvironment != 0);
 }
 
@@ -340,6 +338,8 @@
     SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
 
     IF1632_Saved16_ss_sp = pTask->ss_sp;
+    /* Terminate the stack frame */
+    CURRENT_STACK16->frame32 = NULL;
     SET_CUR_THREAD( pTask->thdb );
     if (pModule->flags & NE_FFLAGS_WIN32)
     {
@@ -347,11 +347,11 @@
 
         extern void InitTask( CONTEXT *context );
 
-        FARPROC32 entry = (FARPROC32)RVA_PTR( pCurrentProcess->exe_modref->module, OptionalHeader.AddressOfEntryPoint );
+        FARPROC32 entry = (FARPROC32)RVA_PTR( PROCESS_Current()->exe_modref->module, OptionalHeader.AddressOfEntryPoint );
 
         InitTask( NULL );
         InitApp( pTask->hModule );
-        PE_InitializeDLLs( pCurrentProcess, DLL_PROCESS_ATTACH, (LPVOID)-1 );
+        PE_InitializeDLLs( PROCESS_Current(), DLL_PROCESS_ATTACH, (LPVOID)-1 );
         dprintf_relay( stddeb, "CallTo32(entryproc=%p)\n", entry );
         exit_code = entry();
         TASK_KillCurrentTask( exit_code );
@@ -514,7 +514,7 @@
 
     /* Create the Win32 part of the task */
 
-    pCurrentProcess = pdb32 = PROCESS_Create( pTask, cmdLine );
+    pdb32 = PROCESS_Create( pTask, cmdLine );
     /* FIXME: check for pdb32 == NULL.  */
     pdb32->task = hTask;
     if (pModule->flags & NE_FFLAGS_WIN32)
@@ -522,8 +522,8 @@
     /*
         LPTHREAD_START_ROUTINE start =
             (LPTHREAD_START_ROUTINE)(
-	    	pCurrentProcess->exe_modref->load_addr +
-		pCurrentProcess->exe_modref->pe_module->pe_header->OptionalHeader.AddressOfEntryPoint);
+	    	PROCESS_Current()->exe_modref->load_addr +
+		PROCESS_Current()->exe_modref->pe_module->pe_header->OptionalHeader.AddressOfEntryPoint);
      */
         pTask->thdb = THREAD_Create( pdb32,
           PE_HEADER(pModule->module32)->OptionalHeader.SizeOfStackReserve,
@@ -541,11 +541,11 @@
 
     stack32Top = (char*)pTask->thdb->teb.stack_top;
     frame32 = (STACK32FRAME *)stack32Top - 1;
-    frame32->edi = 0;
-    frame32->esi = 0;
-    frame32->edx = 0;
-    frame32->ecx = 0;
-    frame32->ebx = 0;
+    frame32->edi     = 0;
+    frame32->esi     = 0;
+    frame32->edx     = 0;
+    frame32->ecx     = 0;
+    frame32->ebx     = 0;
     frame32->retaddr = (DWORD)TASK_CallToStart;
     /* The remaining fields will be initialized in TASK_Reschedule */
 
@@ -555,9 +555,9 @@
         sp = pSegTable[pModule->ss-1].minsize + pModule->stack_size;
     sp &= ~1;
     pTask->ss_sp = PTR_SEG_OFF_TO_SEGPTR( hInstance, sp );
-    pTask->ss_sp -= sizeof(STACK16FRAME) + sizeof(DWORD) /* for saved %esp */;
+    pTask->ss_sp -= sizeof(STACK16FRAME);
     frame16 = (STACK16FRAME *)PTR_SEG_TO_LIN( pTask->ss_sp );
-    frame16->saved_ss_sp = 0;
+    frame16->frame32 = frame32;
     frame16->ebp = sp + (int)&((STACK16FRAME *)0)->bp;
     frame16->bp = LOWORD(frame16->ebp);
     frame16->ds = frame16->es = pTask->hInstance;
@@ -565,8 +565,6 @@
     frame16->entry_cs = 0;
     /* The remaining fields will be initialized in TASK_Reschedule */
 
-    *(STACK32FRAME **)(frame16 + 1) = frame32; /* Store the 32-bit %esp */
-
       /* If there's no 16-bit stack yet, use a part of the new task stack */
       /* This is only needed to have a stack to switch from on the first  */
       /* call to DirectedYield(). */
@@ -775,8 +773,8 @@
     if (!newframe16->entry_cs)
     {
         STACK16FRAME *oldframe16 = CURRENT_STACK16;
-        STACK32FRAME *oldframe32 = *(STACK32FRAME **)(oldframe16 + 1);
-        STACK32FRAME *newframe32 = *(STACK32FRAME **)(newframe16 + 1);
+        STACK32FRAME *oldframe32 = oldframe16->frame32;
+        STACK32FRAME *newframe32 = newframe16->frame32;
         newframe16->entry_ip     = oldframe16->entry_ip;
         newframe16->entry_cs     = oldframe16->entry_cs;
         newframe16->ip           = oldframe16->ip;
@@ -790,7 +788,6 @@
 
     hCurrentTask = hTask;
     SET_CUR_THREAD( pNewTask->thdb );
-    pCurrentProcess = pNewTask->thdb->process;
     IF1632_Saved16_ss_sp = pNewTask->ss_sp;
 }
 
@@ -1197,7 +1194,7 @@
     /* Build a stack frame for the return */
 
     newFrame = CURRENT_STACK16;
-    newFrame->saved_ss_sp = oldFrame->saved_ss_sp;
+    newFrame->frame32 = oldFrame->frame32;
     if (debugging_relay)
     {
         newFrame->entry_ip = oldFrame->entry_ip;