remove final imports.h and imports.c bits
[mesa.git] / src / mesa / main / execmem.c
index d63bb4a4e56d5a15f1111fc3014e0437f04e5389..b2018b5e767387d1128f4b7bd29c70e464a43127 100644 (file)
  */
 
 
-#include "imports.h"
-#include "glapi/glthread.h"
-
+#include <stdio.h>
+#include "main/glheader.h"
+#include "execmem.h"
+#include "c11/threads.h"
 
 
 #if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__)
@@ -45,7 +46,7 @@
 
 #include <unistd.h>
 #include <sys/mman.h>
-#include "mm.h"
+#include "util/u_mm.h"
 
 #ifdef MESA_SELINUX
 #include <selinux/selinux.h>
@@ -59,7 +60,7 @@
 
 #define EXEC_HEAP_SIZE (10*1024*1024)
 
-_glthread_DECLARE_STATIC_MUTEX(exec_mutex);
+static mtx_t exec_mutex = _MTX_INITIALIZER_NP;
 
 static struct mem_block *exec_heap = NULL;
 static unsigned char *exec_mem = NULL;
@@ -77,57 +78,57 @@ init_heap(void)
 #endif
 
    if (!exec_heap)
-      exec_heap = mmInit( 0, EXEC_HEAP_SIZE );
-   
+      exec_heap = u_mmInit( 0, EXEC_HEAP_SIZE );
+
    if (!exec_mem)
       exec_mem = mmap(NULL, EXEC_HEAP_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE,
-                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+                      MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 
    return (exec_mem != MAP_FAILED);
 }
 
 
 void *
-_mesa_exec_malloc(GLuint size)
+_mesa_exec_malloc(unsigned size)
 {
    struct mem_block *block = NULL;
    void *addr = NULL;
 
-   _glthread_LOCK_MUTEX(exec_mutex);
+   mtx_lock(&exec_mutex);
 
    if (!init_heap())
       goto bail;
 
    if (exec_heap) {
       size = (size + 31) & ~31;
-      block = mmAllocMem( exec_heap, size, 32, 0 );
+      block = u_mmAllocMem(exec_heap, size, 5, 0);
    }
 
    if (block)
       addr = exec_mem + block->ofs;
-   else 
+   else
       printf("_mesa_exec_malloc failed\n");
 
 bail:
-   _glthread_UNLOCK_MUTEX(exec_mutex);
-   
+   mtx_unlock(&exec_mutex);
+
    return addr;
 }
 
-void 
+
+void
 _mesa_exec_free(void *addr)
 {
-   _glthread_LOCK_MUTEX(exec_mutex);
+   mtx_lock(&exec_mutex);
 
    if (exec_heap) {
-      struct mem_block *block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);
-   
+      struct mem_block *block = u_mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);
+
       if (block)
-        mmFreeMem(block);
+        u_mmFreeMem(block);
    }
 
-   _glthread_UNLOCK_MUTEX(exec_mutex);
+   mtx_unlock(&exec_mutex);
 }
 
 
@@ -138,13 +139,13 @@ _mesa_exec_free(void *addr)
  */
 
 void *
-_mesa_exec_malloc(GLuint size)
+_mesa_exec_malloc(unsigned size)
 {
    return malloc( size );
 }
 
-void 
+
+void
 _mesa_exec_free(void *addr)
 {
    free(addr);