summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/context.c16
-rw-r--r--src/mesa/main/hash.c14
-rw-r--r--src/mesa/main/texobj.c6
3 files changed, 31 insertions, 5 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 4525d45c86..881dc0f093 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.36 2000/01/28 20:17:42 brianp Exp $ */
+/* $Id: context.c,v 1.37 2000/01/31 23:11:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -44,6 +44,7 @@
#include "get.h"
#include "glapi.h"
#include "glapinoop.h"
+#include "glthread.h"
#include "hash.h"
#include "light.h"
#include "lines.h"
@@ -424,12 +425,16 @@ void gl_destroy_framebuffer( GLframebuffer *buffer )
/**********************************************************************/
+_glthread_DECLARE_STATIC_MUTEX(OneTimeLock);
+
+
/*
* This function just calls all the various one-time-init functions in Mesa.
*/
static void one_time_init( void )
{
static GLboolean alreadyCalled = GL_FALSE;
+ _glthread_LOCK_MUTEX(OneTimeLock);
if (!alreadyCalled) {
/* do some implementation tests */
assert( sizeof(GLbyte) == 1 );
@@ -465,6 +470,7 @@ static void one_time_init( void )
alreadyCalled = GL_TRUE;
}
+ _glthread_UNLOCK_MUTEX(OneTimeLock);
}
@@ -1325,7 +1331,9 @@ GLboolean gl_initialize_context_data( GLcontext *ctx,
return GL_FALSE;
}
}
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount++;
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
init_attrib_groups( ctx );
@@ -1434,9 +1442,11 @@ void gl_free_context_data( GLcontext *ctx )
gl_vb_free( ctx->VB );
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount--;
- assert(ctx->Shared->RefCount>=0);
- if (ctx->Shared->RefCount==0) {
+ assert(ctx->Shared->RefCount >= 0);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+ if (ctx->Shared->RefCount == 0) {
/* free shared state */
free_shared_state( ctx, ctx->Shared );
}
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
index a7364b4dac..88e94e7884 100644
--- a/src/mesa/main/hash.c
+++ b/src/mesa/main/hash.c
@@ -1,4 +1,4 @@
-/* $Id: hash.c,v 1.6 2000/01/24 16:19:54 brianp Exp $ */
+/* $Id: hash.c,v 1.7 2000/01/31 23:11:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -29,6 +29,7 @@
#include "all.h"
#else
#include "glheader.h"
+#include "glthread.h"
#include "hash.h"
#include "mem.h"
#endif
@@ -53,6 +54,7 @@ struct HashEntry {
struct _mesa_HashTable {
struct HashEntry *Table[TABLE_SIZE];
GLuint MaxKey;
+ _glthread_Mutex Mutex;
};
@@ -130,6 +132,8 @@ void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data)
assert(table);
assert(key);
+ _glthread_LOCK_MUTEX(table->Mutex);
+
if (key > table->MaxKey)
table->MaxKey = key;
@@ -139,6 +143,7 @@ void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data)
if (entry->Key == key) {
/* replace entry's data */
entry->Data = data;
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return;
}
entry = entry->Next;
@@ -150,6 +155,8 @@ void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data)
entry->Data = data;
entry->Next = table->Table[pos];
table->Table[pos] = entry;
+
+ _glthread_UNLOCK_MUTEX(table->Mutex);
}
@@ -167,6 +174,8 @@ void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
assert(table);
assert(key);
+ _glthread_LOCK_MUTEX(table->Mutex);
+
pos = key & (TABLE_SIZE-1);
prev = NULL;
entry = table->Table[pos];
@@ -180,11 +189,14 @@ void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
table->Table[pos] = entry->Next;
}
FREE(entry);
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return;
}
prev = entry;
entry = entry->Next;
}
+
+ _glthread_UNLOCK_MUTEX(table->Mutex);
}
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 471ed75b14..b24470e893 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1,4 +1,4 @@
-/* $Id: texobj.c,v 1.12 2000/01/24 20:53:32 brianp Exp $ */
+/* $Id: texobj.c,v 1.13 2000/01/31 23:11:39 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -84,8 +84,10 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name,
/* insert into linked list */
if (shared) {
+ _glthread_LOCK_MUTEX(shared->Mutex);
obj->Next = shared->TexObjectList;
shared->TexObjectList = obj;
+ _glthread_UNLOCK_MUTEX(shared->Mutex);
}
if (name > 0) {
@@ -118,6 +120,7 @@ void gl_free_texture_object( struct gl_shared_state *shared,
/* unlink t from the linked list */
if (shared) {
+ _glthread_LOCK_MUTEX(shared->Mutex);
tprev = NULL;
tcurr = shared->TexObjectList;
while (tcurr) {
@@ -133,6 +136,7 @@ void gl_free_texture_object( struct gl_shared_state *shared,
tprev = tcurr;
tcurr = tcurr->Next;
}
+ _glthread_UNLOCK_MUTEX(shared->Mutex);
}
if (t->Name) {