summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-06-07 00:55:55 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-06-07 00:55:55 +0000
commitf35b954b3d6b8272e760164c31786b293ee27e9b (patch)
treea538222ac0c5e3974b624406a4c89a883512f74d /loader
parent654a6f977134537a4d79b135f83cc4ecd3bce2a8 (diff)
downloadmpv-f35b954b3d6b8272e760164c31786b293ee27e9b.tar.bz2
mpv-f35b954b3d6b8272e760164c31786b293ee27e9b.tar.xz
new (cleaner, nore robust) critsect code by Zdenek Kabelac <kabi@informatics.muni.cz>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6322 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'loader')
-rw-r--r--loader/win32.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/loader/win32.c b/loader/win32.c
index 291f111b1f..42bf21ddd4 100644
--- a/loader/win32.c
+++ b/loader/win32.c
@@ -335,6 +335,7 @@ struct CRITSECT
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 @@ static void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
}
#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 @@ static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
#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 @@ static void WINAPI expEnterCriticalSection(CRITICAL_SECTION* c)
#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 @@ static void WINAPI expLeaveCriticalSection(CRITICAL_SECTION* c)
#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 @@ static void WINAPI expDeleteCriticalSection(CRITICAL_SECTION *c)
#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);