ntdll/kernel32: #28

Eric Pouech pouech-eric at wanadoo.fr
Sat Jun 21 07:18:09 CDT 2003


- in kernel32, replaced all {Enter|Leave}CriticalSection calls with 
ntdll's counterpart
- {Enter|Leave}CriticalSection is now a pure forward from kernel32 to 
ntdll (we now longer can use {Enter|Leave}CriticalSection in kernel32)
- replaced a few kernel32 heap management calls from ntdll, with 
RtlHeap* equivalent


Note: scheduler/critsection.c can now be moved to dlls/kernel subdirectory.

A+
-- 
Eric Pouech
-------------- next part --------------
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/kernel27/console.c dlls/kernel/console.c
--- dlls/kernel27/console.c	2003-06-21 08:03:38.000000000 +0200
+++ dlls/kernel/console.c	2003-06-21 09:30:12.000000000 +0200
@@ -1303,15 +1303,15 @@
 
         if (!ch) return FALSE;
         ch->handler = func;
-        EnterCriticalSection(&CONSOLE_CritSect);
+        RtlEnterCriticalSection(&CONSOLE_CritSect);
         ch->next = CONSOLE_Handlers;
         CONSOLE_Handlers = ch;
-        LeaveCriticalSection(&CONSOLE_CritSect);
+        RtlLeaveCriticalSection(&CONSOLE_CritSect);
     }
     else
     {
         struct ConsoleHandler**  ch;
-        EnterCriticalSection(&CONSOLE_CritSect);
+        RtlEnterCriticalSection(&CONSOLE_CritSect);
         for (ch = &CONSOLE_Handlers; *ch; *ch = (*ch)->next)
         {
             if ((*ch)->handler == func) break;
@@ -1338,7 +1338,7 @@
             WARN("Attempt to remove non-installed CtrlHandler %p\n", func);
             ret = FALSE;
         }
-        LeaveCriticalSection(&CONSOLE_CritSect);
+        RtlLeaveCriticalSection(&CONSOLE_CritSect);
     }
     return ret;
 }
@@ -1353,13 +1353,13 @@
 {
     struct ConsoleHandler*  ch;
 
-    EnterCriticalSection(&CONSOLE_CritSect);
+    RtlEnterCriticalSection(&CONSOLE_CritSect);
     /* the debugger didn't continue... so, pass to ctrl handlers */
     for (ch = CONSOLE_Handlers; ch; ch = ch->next)
     {
         if (ch->handler((DWORD)pmt)) break;
     }
-    LeaveCriticalSection(&CONSOLE_CritSect);
+    RtlLeaveCriticalSection(&CONSOLE_CritSect);
     return 0;
 }
 
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/kernel27/kernel_main.c dlls/kernel/kernel_main.c
--- dlls/kernel27/kernel_main.c	2003-06-18 20:28:01.000000000 +0200
+++ dlls/kernel/kernel_main.c	2003-06-20 08:07:19.000000000 +0200
@@ -60,12 +60,12 @@
  */
 static void ldt_lock(void)
 {
-    EnterCriticalSection( &ldt_section );
+    RtlEnterCriticalSection( &ldt_section );
 }
 
 static void ldt_unlock(void)
 {
-    LeaveCriticalSection( &ldt_section );
+    RtlLeaveCriticalSection( &ldt_section );
 }
 
 
diff -u -N -r -x '*~' -x '.#*' -x CVS dlls/ntdll27/heap.c dlls/ntdll/heap.c
--- dlls/ntdll27/heap.c	2003-05-22 08:28:27.000000000 +0200
+++ dlls/ntdll/heap.c	2003-05-25 09:47:59.000000000 +0200
@@ -38,6 +38,8 @@
 #include "winnt.h"
 #include "thread.h"
 #include "wine/debug.h"
+#include "winternl.h"
+#include "wine/server_protocol.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(heap);
 
@@ -587,7 +589,15 @@
 
         RtlInitializeCriticalSection( &heap->critSection );
         if (flags & HEAP_SHARED)
-            MakeCriticalSectionGlobal( &heap->critSection );  /* FIXME: dll separation */
+        {
+            /* let's assume that only one thread at a time will try to do this */
+            HANDLE sem = heap->critSection.LockSemaphore;
+            if (!sem) NtCreateSemaphore( &sem, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 );
+
+            NtDuplicateObject( GetCurrentProcess(), sem, GetCurrentProcess(), &sem, 0, 0,
+                               DUP_HANDLE_MAKE_GLOBAL | DUP_HANDLE_SAME_ACCESS | DUP_HANDLE_CLOSE_SOURCE );
+            heap->critSection.LockSemaphore = sem;
+        }
     }
 
     /* Create the first free block */
diff -u -N -r -x '*~' -x '.#*' -x CVS files27/profile.c files/profile.c
--- files27/profile.c	2003-06-18 20:28:18.000000000 +0200
+++ files/profile.c	2003-06-20 08:07:32.000000000 +0200
@@ -1108,7 +1108,7 @@
     if (!pDefVal)
 	pDefVal = (LPWSTR)def_val;
 
-    EnterCriticalSection( &PROFILE_CritSect );
+    RtlEnterCriticalSection( &PROFILE_CritSect );
 
     if (PROFILE_Open( filename )) {
 	if ((allow_section_name_copy) && (section == NULL))
@@ -1121,7 +1121,7 @@
        ret = strlenW( buffer );
     }
 
-    LeaveCriticalSection( &PROFILE_CritSect );
+    RtlLeaveCriticalSection( &PROFILE_CritSect );
 
     if (pDefVal != def_val) /* allocated */
 	HeapFree(GetProcessHeap(), 0, pDefVal);
@@ -1371,13 +1371,13 @@
 {
     int		ret = 0;
 
-    EnterCriticalSection( &PROFILE_CritSect );
+    RtlEnterCriticalSection( &PROFILE_CritSect );
 
     if (PROFILE_Open( filename ))
         ret = PROFILE_GetSection(CurProfile->section, section, buffer, len,
 				 FALSE, TRUE);
 
-    LeaveCriticalSection( &PROFILE_CritSect );
+    RtlLeaveCriticalSection( &PROFILE_CritSect );
 
     return ret;
 }
@@ -1465,7 +1465,7 @@
 {
     BOOL ret = FALSE;
 
-    EnterCriticalSection( &PROFILE_CritSect );
+    RtlEnterCriticalSection( &PROFILE_CritSect );
 
     if (PROFILE_Open( filename ))
     {
@@ -1485,7 +1485,7 @@
 	}
     }
 
-    LeaveCriticalSection( &PROFILE_CritSect );
+    RtlLeaveCriticalSection( &PROFILE_CritSect );
     return ret;
 }
 
@@ -1534,7 +1534,7 @@
     BOOL ret = FALSE;
     LPWSTR p;
 
-    EnterCriticalSection( &PROFILE_CritSect );
+    RtlEnterCriticalSection( &PROFILE_CritSect );
 
     if (PROFILE_Open( filename )) {
         if (!section && !string)
@@ -1559,7 +1559,7 @@
         }
     }
 
-    LeaveCriticalSection( &PROFILE_CritSect );
+    RtlLeaveCriticalSection( &PROFILE_CritSect );
     return ret;
 }
 
@@ -1686,12 +1686,12 @@
 {
     DWORD ret = 0;
 
-    EnterCriticalSection( &PROFILE_CritSect );
+    RtlEnterCriticalSection( &PROFILE_CritSect );
 
     if (PROFILE_Open( filename ))
         ret = PROFILE_GetSectionNames(buffer, size);
 
-    LeaveCriticalSection( &PROFILE_CritSect );
+    RtlLeaveCriticalSection( &PROFILE_CritSect );
 
     return ret;
 }
@@ -1746,7 +1746,7 @@
 {
     BOOL	ret = FALSE;
 
-    EnterCriticalSection( &PROFILE_CritSect );
+    RtlEnterCriticalSection( &PROFILE_CritSect );
 
     if (PROFILE_Open( filename )) {
         PROFILEKEY *k = PROFILE_Find ( &CurProfile->section, section, key, FALSE, FALSE);
@@ -1806,7 +1806,7 @@
             }
 	}
     }
-    LeaveCriticalSection( &PROFILE_CritSect );
+    RtlLeaveCriticalSection( &PROFILE_CritSect );
 
     return ret;
 }
@@ -1875,14 +1875,14 @@
     *p++ = hex[sum & 0xf];
     *p++ = '\0';
 
-    EnterCriticalSection( &PROFILE_CritSect );
+    RtlEnterCriticalSection( &PROFILE_CritSect );
 
     if (PROFILE_Open( filename )) {
         ret = PROFILE_SetString( section, key, outstring, FALSE);
         PROFILE_FlushFile();
     }
 
-    LeaveCriticalSection( &PROFILE_CritSect );
+    RtlLeaveCriticalSection( &PROFILE_CritSect );
 
     HeapFree( GetProcessHeap(), 0, outstring );
 
@@ -1921,9 +1921,9 @@
  */
 void WINAPI WriteOutProfiles16(void)
 {
-    EnterCriticalSection( &PROFILE_CritSect );
+    RtlEnterCriticalSection( &PROFILE_CritSect );
     PROFILE_FlushFile();
-    LeaveCriticalSection( &PROFILE_CritSect );
+    RtlLeaveCriticalSection( &PROFILE_CritSect );
 }
 
 /***********************************************************************
diff -u -N -r -x '*~' -x '.#*' -x CVS files27/smb.c files/smb.c
--- files27/smb.c	2003-06-21 08:04:07.000000000 +0200
+++ files/smb.c	2003-06-20 08:08:53.000000000 +0200
@@ -107,6 +107,8 @@
 #include "file.h"
 
 #include "smb.h"
+#include "winternl.h"
+#include "ntdll_misc.h"
 
 #include "wine/server.h"
 #include "wine/debug.h"
@@ -379,7 +381,7 @@
 
     rx->len = NBR_GETWORD(&buffer[2]);
 
-    rx->buffer = HeapAlloc(GetProcessHeap(), 0, rx->len);
+    rx->buffer = RtlAllocateHeap(ntdll_get_process_heap(), 0, rx->len);
     if(!rx->buffer)
         return FALSE;
 
@@ -387,7 +389,7 @@
     if(rx->len!=r)
     {
         TRACE("Received %d bytes\n",r);
-        HeapFree(GetProcessHeap(), 0, rx->buffer);
+        RtlFreeHeap(ntdll_get_process_heap(), 0, rx->buffer);
         rx->buffer = 0;
         rx->len = 0;
         return FALSE;
@@ -556,11 +558,11 @@
     if(SMB_GetError(rx.buffer))
     {
         ERR("returned error\n");
-        HeapFree(GetProcessHeap(),0,rx.buffer);
+        RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
         return FALSE;
     }
 
-    HeapFree(GetProcessHeap(),0,rx.buffer);
+    RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
 
     *dialect = 0;
 
@@ -658,11 +660,11 @@
 
     *userid = SMB_GETWORD(&rx.buffer[SMB_USERID]);
 
-    HeapFree(GetProcessHeap(),0,rx.buffer);
+    RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
     return TRUE;
 
 done:
-    HeapFree(GetProcessHeap(),0,rx.buffer);
+    RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
     return FALSE;
 }
 
@@ -716,13 +718,13 @@
 
     if(SMB_GetError(rx.buffer))
     {
-        HeapFree(GetProcessHeap(),0,rx.buffer);
+        RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
         return FALSE;
     }
 
     *treeid = SMB_GETWORD(&rx.buffer[SMB_TREEID]);
 
-    HeapFree(GetProcessHeap(),0,rx.buffer);
+    RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
     TRACE("OK, treeid = %04x\n", *treeid);
 
     return TRUE;
@@ -955,7 +957,7 @@
         user_id, tree_id, file_id, count, offset);
 
     buf_size = count+0x100;
-    tx.buffer = (unsigned char *) HeapAlloc(GetProcessHeap(),0,buf_size);
+    tx.buffer = (unsigned char *) RtlAllocateHeap(ntdll_get_process_heap(),0,buf_size);
 
     memset(tx.buffer,0,buf_size);
 
@@ -973,14 +975,14 @@
     rx.len = 0;
     if(!NB_Transaction(fd, &tx, &rx))
     {
-        HeapFree(GetProcessHeap(),0,tx.buffer);
+        RtlFreeHeap(ntdll_get_process_heap(),0,tx.buffer);
         return FALSE;
     }
 
     if(SMB_GetError(rx.buffer))
     {
-        HeapFree(GetProcessHeap(),0,rx.buffer);
-        HeapFree(GetProcessHeap(),0,tx.buffer);
+        RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
+        RtlFreeHeap(ntdll_get_process_heap(),0,tx.buffer);
         return FALSE;
     }
 
@@ -988,8 +990,8 @@
 
     if( (SMB_HDRSIZE+n*2) > rx.len )
     {
-        HeapFree(GetProcessHeap(),0,rx.buffer);
-        HeapFree(GetProcessHeap(),0,tx.buffer);
+        RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
+        RtlFreeHeap(ntdll_get_process_heap(),0,tx.buffer);
         ERR("Bad parameter count %d\n",n);
         return FALSE;
     }
@@ -1008,8 +1010,8 @@
     TRACE("Read %d bytes\n",n);
     *read = n;
 
-    HeapFree(GetProcessHeap(),0,tx.buffer);
-    HeapFree(GetProcessHeap(),0,rx.buffer);
+    RtlFreeHeap(ntdll_get_process_heap(),0,tx.buffer);
+    RtlFreeHeap(ntdll_get_process_heap(),0,rx.buffer);
 
     return TRUE;
 }
@@ -1051,7 +1053,7 @@
     BOOL ret = FALSE;
 
     buf_size = 0x100 + send->setup_count*2 + send->param_count + send->data_count ;
-    tx.buffer = (unsigned char *) HeapAlloc(GetProcessHeap(),0,buf_size);
+    tx.buffer = (unsigned char *) RtlAllocateHeap(ntdll_get_process_heap(),0,buf_size);
 
     tx.len = SMB_Header(tx.buffer, SMB_COM_TRANSACTION2, tree_id, user_id);
 
@@ -1153,7 +1155,7 @@
 
 done:
     if(tx.buffer)
-        HeapFree(GetProcessHeap(),0,tx.buffer);
+        RtlFreeHeap(ntdll_get_process_heap(),0,tx.buffer);
 
     return ret;
 }
@@ -1170,15 +1172,15 @@
     memset(send,0,sizeof(send));
 
     send->setup_count = 1;
-    send->setup = HeapAlloc(GetProcessHeap(),0,send->setup_count*2);
+    send->setup = RtlAllocateHeap(ntdll_get_process_heap(),0,send->setup_count*2);
     if(!send->setup)
         return FALSE;
 
-    buf_size = 0x10 + lstrlenA(filename);
-    send->params = HeapAlloc(GetProcessHeap(),0,buf_size);
+    buf_size = 0x10 + strlen(filename);
+    send->params = RtlAllocateHeap(ntdll_get_process_heap(),0,buf_size);
     if(!send->params)
     {
-        HeapFree(GetProcessHeap(),0,send->setup);
+        RtlFreeHeap(ntdll_get_process_heap(),0,send->setup);
         return FALSE;
     }
 
@@ -1193,7 +1195,7 @@
     SMB_ADDDWORD(&send->params[len],storagetype); len += 4;
 
     strcpy(&send->params[len],filename);
-    len += lstrlenA(filename)+1;
+    len += strlen(filename)+1;
 
     send->param_count = len;
     send->data = NULL;
@@ -1219,8 +1221,8 @@
     memset(&recv,0,sizeof(recv));
 
     ret = SMB_Transaction2(fd, tree_id, user_id, &send, &recv);
-    HeapFree(GetProcessHeap(),0,send.params);
-    HeapFree(GetProcessHeap(),0,send.setup);
+    RtlFreeHeap(ntdll_get_process_heap(),0,send.params);
+    RtlFreeHeap(ntdll_get_process_heap(),0,send.setup);
 
     if(!ret)
         goto done;
@@ -1237,14 +1239,14 @@
     if(SMB_GETWORD(&recv.params[4]))
         FIXME("need to read more!\n");
 
-    smbdir = HeapAlloc(GetProcessHeap(),0,sizeof(*smbdir));
+    smbdir = RtlAllocateHeap(ntdll_get_process_heap(),0,sizeof(*smbdir));
     if(smbdir)
     {
         int i, ofs=0;
 
         smbdir->current = 0;
         smbdir->num_entries = num;
-        smbdir->entries = HeapAlloc(GetProcessHeap(), 0, sizeof(unsigned char*)*num);
+        smbdir->entries = RtlAllocateHeap(ntdll_get_process_heap(), 0, sizeof(unsigned char*)*num);
         if(!smbdir->entries)
             goto done;
         smbdir->buffer = recv.buf.buffer; /* save to free later */
@@ -1274,12 +1276,12 @@
     if(!ret)
     {
         if( recv.buf.buffer )
-            HeapFree(GetProcessHeap(),0,recv.buf.buffer);
+            RtlFreeHeap(ntdll_get_process_heap(),0,recv.buf.buffer);
         if( smbdir )
         {
             if( smbdir->entries )
-                HeapFree(GetProcessHeap(),0,smbdir->entries);
-            HeapFree(GetProcessHeap(),0,smbdir);
+                RtlFreeHeap(ntdll_get_process_heap(),0,smbdir->entries);
+            RtlFreeHeap(ntdll_get_process_heap(),0,smbdir);
         }
         smbdir = NULL;
     }
@@ -1346,14 +1348,14 @@
     if(!SMB_SessionSetup(fd, user_id))
         return FALSE;
 
-    name = HeapAlloc(GetProcessHeap(),0,strlen(host)+strlen(share)+5);
+    name = RtlAllocateHeap(ntdll_get_process_heap(),0,strlen(host)+strlen(share)+5);
     if(!name)
         return FALSE;
 
     sprintf(name,"\\\\%s\\%s",host,share);
     if(!SMB_TreeConnect(fd,*user_id,name,tree_id))
     {
-        HeapFree(GetProcessHeap(),0,name);
+        RtlFreeHeap(ntdll_get_process_heap(),0,name);
         return FALSE;
     }
 
@@ -1399,7 +1401,7 @@
     INT len;
 
     len = WideCharToMultiByte(CP_ACP, 0, uncname, -1, NULL, 0, NULL, NULL);
-    name = HeapAlloc(GetProcessHeap(), 0, len);
+    name = RtlAllocateHeap(ntdll_get_process_heap(), 0, len);
     if(!name)
         return handle;
 
@@ -1407,7 +1409,7 @@
 
     if( !UNC_SplitName(name, &host, &share, &file) )
     {
-        HeapFree(GetProcessHeap(),0,name);
+        RtlFreeHeap(ntdll_get_process_heap(),0,name);
         return handle;
     }
 
@@ -1445,7 +1447,7 @@
     }
 
 done:
-    HeapFree(GetProcessHeap(),0,name);
+    RtlFreeHeap(ntdll_get_process_heap(),0,name);
     return handle;
 }
 
@@ -1555,7 +1557,7 @@
     TRACE("Find %s\n",debugstr_w(name));
 
     len = WideCharToMultiByte( CP_ACP, 0, name, -1, NULL, 0, NULL, NULL );
-    filename = HeapAlloc(GetProcessHeap(),0,len);
+    filename = RtlAllocateHeap(ntdll_get_process_heap(),0,len);
     if(!filename)
         return ret;
     WideCharToMultiByte( CP_ACP, 0, name, -1, filename, len, NULL, NULL );
@@ -1580,7 +1582,7 @@
         close(fd);
 
     if(filename)
-        HeapFree(GetProcessHeap(),0,filename);
+        RtlFreeHeap(ntdll_get_process_heap(),0,filename);
 
     return ret;
 }
@@ -1630,9 +1632,9 @@
 
 BOOL WINAPI SMB_CloseDir(SMB_DIR *dir)
 {
-    HeapFree(GetProcessHeap(),0,dir->buffer);
-    HeapFree(GetProcessHeap(),0,dir->entries);
+    RtlFreeHeap(ntdll_get_process_heap(),0,dir->buffer);
+    RtlFreeHeap(ntdll_get_process_heap(),0,dir->entries);
     memset(dir,0,sizeof(*dir));
-    HeapFree(GetProcessHeap(),0,dir);
+    RtlFreeHeap(ntdll_get_process_heap(),0,dir);
     return TRUE;
 }
diff -u -N -r -x '*~' -x '.#*' -x CVS memory27/heap.c memory/heap.c
--- memory27/heap.c	2003-05-22 08:28:32.000000000 +0200
+++ memory/heap.c	2003-05-25 08:39:54.000000000 +0200
@@ -261,22 +261,3 @@
     return RtlSizeHeap( heap, flags, ptr );
 }
 
-void WINAPI EnterCriticalSection( CRITICAL_SECTION *crit )
-{
-    RtlEnterCriticalSection( crit );
-}
-
-BOOL WINAPI TryEnterCriticalSection( CRITICAL_SECTION *crit )
-{
-    return RtlTryEnterCriticalSection( crit );
-}
-
-void WINAPI DeleteCriticalSection( CRITICAL_SECTION *crit )
-{
-    RtlDeleteCriticalSection( crit );
-}
-
-void WINAPI LeaveCriticalSection( CRITICAL_SECTION *crit )
-{
-    RtlLeaveCriticalSection( crit );
-}
diff -u -N -r -x '*~' -x '.#*' -x CVS scheduler27/pthread.c scheduler/pthread.c
--- scheduler27/pthread.c	2003-04-03 21:57:49.000000000 +0200
+++ scheduler/pthread.c	2003-05-25 08:27:51.000000000 +0200
@@ -236,13 +236,13 @@
 		     void (*parent)(void),
 		     void (*child)(void))
 {
-    if (init_done) EnterCriticalSection( &atfork_section );
+    if (init_done) RtlEnterCriticalSection( &atfork_section );
     assert( atfork_count < MAX_ATFORK );
     atfork_prepare[atfork_count] = prepare;
     atfork_parent[atfork_count] = parent;
     atfork_child[atfork_count] = child;
     atfork_count++;
-    if (init_done) LeaveCriticalSection( &atfork_section );
+    if (init_done) RtlLeaveCriticalSection( &atfork_section );
     return 0;
 }
 strong_alias(__pthread_atfork, pthread_atfork);
@@ -257,18 +257,18 @@
         libc_fork = dlsym( RTLD_NEXT, "fork" );
         assert( libc_fork );
     }
-    EnterCriticalSection( &atfork_section );
+    RtlEnterCriticalSection( &atfork_section );
     /* prepare handlers are called in reverse insertion order */
     for (i = atfork_count - 1; i >= 0; i--) if (atfork_prepare[i]) atfork_prepare[i]();
     if (!(pid = libc_fork()))
     {
-        InitializeCriticalSection( &atfork_section );
+        RtlInitializeCriticalSection( &atfork_section );
         for (i = 0; i < atfork_count; i++) if (atfork_child[i]) atfork_child[i]();
     }
     else
     {
         for (i = 0; i < atfork_count; i++) if (atfork_parent[i]) atfork_parent[i]();
-        LeaveCriticalSection( &atfork_section );
+        RtlLeaveCriticalSection( &atfork_section );
     }
     return pid;
 }
@@ -293,11 +293,11 @@
 static void mutex_real_init( pthread_mutex_t *mutex )
 {
   CRITICAL_SECTION *critsect = HeapAlloc(GetProcessHeap(), 0, sizeof(CRITICAL_SECTION));
-  InitializeCriticalSection(critsect);
+  RtlInitializeCriticalSection(critsect);
 
   if (InterlockedCompareExchangePointer((void**)&(((wine_mutex)mutex)->critsect),critsect,NULL) != NULL) {
     /* too late, some other thread already did it */
-    DeleteCriticalSection(critsect);
+    RtlDeleteCriticalSection(critsect);
     HeapFree(GetProcessHeap(), 0, critsect);
   }
 }
@@ -308,7 +308,7 @@
   if (!((wine_mutex)mutex)->critsect)
     mutex_real_init( mutex );
 
-  EnterCriticalSection(((wine_mutex)mutex)->critsect);
+  RtlEnterCriticalSection(((wine_mutex)mutex)->critsect);
   return 0;
 }
 strong_alias(__pthread_mutex_lock, pthread_mutex_lock);
@@ -319,7 +319,7 @@
   if (!((wine_mutex)mutex)->critsect)
     mutex_real_init( mutex );
 
-  if (!TryEnterCriticalSection(((wine_mutex)mutex)->critsect)) {
+  if (!RtlTryEnterCriticalSection(((wine_mutex)mutex)->critsect)) {
     errno = EBUSY;
     return -1;
   }
@@ -330,7 +330,7 @@
 int __pthread_mutex_unlock(pthread_mutex_t *mutex)
 {
   if (!((wine_mutex)mutex)->critsect) return 0;
-  LeaveCriticalSection(((wine_mutex)mutex)->critsect);
+  RtlLeaveCriticalSection(((wine_mutex)mutex)->critsect);
   return 0;
 }
 strong_alias(__pthread_mutex_unlock, pthread_mutex_unlock);
@@ -343,10 +343,10 @@
     return EBUSY;
 #else
     while (((wine_mutex)mutex)->critsect->RecursionCount)
-      LeaveCriticalSection(((wine_mutex)mutex)->critsect);
+      RtlLeaveCriticalSection(((wine_mutex)mutex)->critsect);
 #endif
   }
-  DeleteCriticalSection(((wine_mutex)mutex)->critsect);
+  RtlDeleteCriticalSection(((wine_mutex)mutex)->critsect);
   HeapFree(GetProcessHeap(), 0, ((wine_mutex)mutex)->critsect);
   return 0;
 }
diff -u -N -r -x '*~' -x '.#*' -x CVS scheduler27/syslevel.c scheduler/syslevel.c
--- scheduler27/syslevel.c	2002-11-25 18:41:55.000000000 +0100
+++ scheduler/syslevel.c	2003-05-25 08:28:55.000000000 +0200
@@ -67,7 +67,7 @@
  */
 VOID WINAPI _CreateSysLevel(SYSLEVEL *lock, INT level)
 {
-    InitializeCriticalSection( &lock->crst );
+    RtlInitializeCriticalSection( &lock->crst );
     lock->level = level;
 
     TRACE("(%p, %d): handle is %p\n",
@@ -94,7 +94,7 @@
                         lock, lock->level, teb->sys_mutex[i], i );
         }
 
-    EnterCriticalSection( &lock->crst );
+    RtlEnterCriticalSection( &lock->crst );
 
     teb->sys_count[lock->level]++;
     teb->sys_mutex[lock->level] = lock;
@@ -131,7 +131,7 @@
             teb->sys_mutex[lock->level] = NULL;
     }
 
-    LeaveCriticalSection( &lock->crst );
+    RtlLeaveCriticalSection( &lock->crst );
 
     TRACE("(%p, level %d): thread %lx (fs %04x, pid %ld) count after  %ld\n",
                   lock, lock->level, teb->tid, teb->teb_sel, (long) getpid(),


More information about the wine-patches mailing list