Windows: remove the {Enter,Leave}CricialSection wrappers
authorSimon Marlow <simonmar@microsoft.com>
Wed, 29 Aug 2007 10:48:11 +0000 (10:48 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Wed, 29 Aug 2007 10:48:11 +0000 (10:48 +0000)
The C-- parser was missing the "stdcall" calling convention for
foreign calls, but once added we can call {Enter,Leave}CricialSection
directly.

compiler/cmm/CmmParse.y
includes/OSThreads.h
rts/HeapStackCheck.cmm
rts/PrimOps.cmm
rts/StgMiscClosures.cmm
rts/win32/OSThreads.c

index 50f2c8b..87410fe 100644 (file)
@@ -891,6 +891,7 @@ foreignCall
 foreignCall conv_string results_code expr_code args_code vols safety ret
   = do  convention <- case conv_string of
           "C" -> return CCallConv
+          "stdcall" -> return StdCallConv
           "C--" -> return CmmCallConv
           _ -> fail ("unknown calling convention: " ++ conv_string)
        return $ do
index dd7f91a..d79b9af 100644 (file)
@@ -16,8 +16,8 @@
 
 #if CMINUSMINUS
 
-#define ACQUIRE_LOCK(mutex) pthread_mutex_lock(mutex)
-#define RELEASE_LOCK(mutex) pthread_mutex_unlock(mutex)
+#define ACQUIRE_LOCK(mutex) foreign "C" pthread_mutex_lock(mutex)
+#define RELEASE_LOCK(mutex) foreign "C" pthread_mutex_unlock(mutex)
 #define ASSERT_LOCK_HELD(mutex) /* nothing */
 
 #else
@@ -85,8 +85,8 @@ typedef pthread_key_t   ThreadLocalKey;
 /* We jump through a hoop here to get a CCall EnterCriticalSection
    and LeaveCriticalSection, as that's what C-- wants. */
 
-#define ACQUIRE_LOCK(mutex) CCallEnterCriticalSection(mutex)
-#define RELEASE_LOCK(mutex) CCallLeaveCriticalSection(mutex)
+#define ACQUIRE_LOCK(mutex) foreign "stdcall" EnterCriticalSection(mutex)
+#define RELEASE_LOCK(mutex) foreign "stdcall" LeaveCriticalSection(mutex)
 #define ASSERT_LOCK_HELD(mutex) /* nothing */
 
 #else
index a4fb5c0..753e671 100644 (file)
@@ -873,7 +873,7 @@ stg_block_blackhole_finally
     // The last thing we do is release sched_lock, which is
     // preventing other threads from accessing blackhole_queue and
     // picking up this thread before we are finished with it.
-    foreign "C" RELEASE_LOCK(sched_mutex "ptr");
+    RELEASE_LOCK(sched_mutex "ptr");
 #endif
     jump StgReturn;
 }
index f3f23d6..d465709 100644 (file)
@@ -229,7 +229,7 @@ atomicModifyMutVarzh_fast
    HP_CHK_GEN_TICKY(SIZE, R1_PTR & R2_PTR, atomicModifyMutVarzh_fast);
 
 #if defined(THREADED_RTS)
-    foreign "C" ACQUIRE_LOCK(atomic_modify_mutvar_mutex "ptr") [R1,R2];
+    ACQUIRE_LOCK(atomic_modify_mutvar_mutex "ptr") [R1,R2];
 #endif
 
    x = StgMutVar_var(R1);
@@ -260,7 +260,7 @@ atomicModifyMutVarzh_fast
    StgThunk_payload(r,0) = z;
 
 #if defined(THREADED_RTS)
-    foreign "C" RELEASE_LOCK(atomic_modify_mutvar_mutex "ptr") [];
+    RELEASE_LOCK(atomic_modify_mutvar_mutex "ptr") [];
 #endif
 
    RET_P(r);
index 9e1eaf9..43efa78 100644 (file)
@@ -304,7 +304,7 @@ INFO_TABLE(stg_BLACKHOLE,0,1,BLACKHOLE,"BLACKHOLE","BLACKHOLE")
     LDV_ENTER(R1);
 
 #if defined(THREADED_RTS)
-    foreign "C" ACQUIRE_LOCK(sched_mutex "ptr");
+    ACQUIRE_LOCK(sched_mutex "ptr");
     // released in stg_block_blackhole_finally
 #endif
 
@@ -369,7 +369,7 @@ INFO_TABLE(stg_CAF_BLACKHOLE,0,1,CAF_BLACKHOLE,"CAF_BLACKHOLE","CAF_BLACKHOLE")
 #endif
 
 #if defined(THREADED_RTS)
-    foreign "C" ACQUIRE_LOCK(sched_mutex "ptr");
+    ACQUIRE_LOCK(sched_mutex "ptr");
     // released in stg_block_blackhole_finally
 #endif
 
index 13a3666..ed5c968 100644 (file)
@@ -232,14 +232,6 @@ forkOS_createThread ( HsStablePtr entry )
                           (unsigned*)&pId) == 0);
 }
 
-void CCallEnterCriticalSection(LPCRITICAL_SECTION s) {
-    EnterCriticalSection(s);
-}
-
-void CCallLeaveCriticalSection(LPCRITICAL_SECTION s) {
-    LeaveCriticalSection(s);
-}
-
 #else /* !defined(THREADED_RTS) */
 
 int