[Mplayer-cvslog] CVS: main/loader win32.c,1.57,1.58

Arpi of Ize arpi at mplayerhq.hu
Fri Jun 7 02:55:57 CEST 2002


Update of /cvsroot/mplayer/main/loader
In directory mail:/var/tmp.root/cvs-serv5463

Modified Files:
	win32.c 
Log Message:
new (cleaner, nore robust) critsect code by Zdenek Kabelac <kabi at informatics.muni.cz>


Index: win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- win32.c	27 Apr 2002 22:42:26 -0000	1.57
+++ win32.c	7 Jun 2002 00:55:55 -0000	1.58
@@ -335,6 +335,7 @@
     pthread_t id;
     pthread_mutex_t mutex;
     int locked;
+    long deadbeef;
 };
 
 void* mreq_private(int size, int to_zero, int type);
@@ -1232,10 +1233,12 @@
     }
 #else
     {
-	struct CRITSECT* cs = mreq_private(sizeof(struct CRITSECT), 0, AREATYPE_CRITSECT);
+	struct CRITSECT* cs = mreq_private(sizeof(struct CRITSECT) + sizeof(CRITICAL_SECTION),
+					   0, AREATYPE_CRITSECT);
 	pthread_mutex_init(&cs->mutex, NULL);
 	cs->locked=0;
-	*(void**)c = cs;
+        cs->deadbeef = 0xdeadbeef;
+	*(void**)c = cs + 1;
     }
 #endif
     return;
@@ -1246,9 +1249,10 @@
 #ifdef CRITSECS_NEWTYPE
     struct CRITSECT* cs = critsecs_get_unix(c);
 #else
-    struct CRITSECT* cs=*(struct CRITSECT**)c;
+    struct CRITSECT* cs = (*(struct CRITSECT**)c) - 1;
+
 #endif
-    dbgprintf("EnterCriticalSection(0x%x)\n",c);
+    dbgprintf("EnterCriticalSection(0x%x) %p maso:0x%x\n",c, cs, cs->deadbeef);
     if (!cs)
     {
 	dbgprintf("entered uninitialized critisec!\n");
@@ -1256,7 +1260,7 @@
 #ifdef CRITSECS_NEWTYPE
 	cs=critsecs_get_unix(c);
 #else
-	cs=*(struct CRITSECT**)c;
+	cs = (*(struct CRITSECT**)c) - 1;
 #endif
 	printf("Win32 Warning: Accessed uninitialized Critical Section (%p)!\n", c);
     }
@@ -1273,10 +1277,10 @@
 #ifdef CRITSECS_NEWTYPE
     struct CRITSECT* cs = critsecs_get_unix(c);
 #else
-    struct CRITSECT* cs=*(struct CRITSECT**)c;
+    struct CRITSECT* cs = (*(struct CRITSECT**)c) - 1;
 #endif
     //    struct CRITSECT* cs=(struct CRITSECT*)c;
-    dbgprintf("LeaveCriticalSection(0x%x)\n",c);
+    dbgprintf("LeaveCriticalSection(0x%x) 0x%x\n",c, cs->deadbeef);
     if (!cs)
     {
 	printf("Win32 Warning: Leaving uninitialized Critical Section %p!!\n", c);
@@ -1291,7 +1295,7 @@
 #ifdef CRITSECS_NEWTYPE
     struct CRITSECT* cs = critsecs_get_unix(c);
 #else
-    struct CRITSECT* cs=*(struct CRITSECT**)c;
+    struct CRITSECT* cs= (*(struct CRITSECT**)c) - 1;
 #endif
     //    struct CRITSECT* cs=(struct CRITSECT*)c;
     dbgprintf("DeleteCriticalSection(0x%x)\n",c);




More information about the MPlayer-cvslog mailing list