Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / mapi / stub.c
index dfadbe1a5d312da1476c5bd74a7f9bb915299fab..45e4f7dc69e6d5454fa0ca40b803ef8d95710b1f 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+#include "c11/threads.h"
 
+#include "util/macros.h"
 #include "u_current.h"
-#include "u_thread.h"
 #include "entry.h"
 #include "stub.h"
 #include "table.h"
 
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
 
 struct mapi_stub {
    const void *name;
@@ -54,16 +54,8 @@ static int next_dynamic_slot = MAPI_TABLE_NUM_STATIC;
 void
 stub_init_once(void)
 {
-#ifdef HAVE_PTHREAD
-   static pthread_once_t once = PTHREAD_ONCE_INIT;
-   pthread_once(&once, entry_patch_public);
-#else
-   static int first = 1;
-   if (first) {
-      first = 0;
-      entry_patch_public();
-   }
-#endif
+   static once_flag flag = ONCE_FLAG_INIT;
+   call_once(&flag, entry_patch_public);
 }
 
 static int
@@ -110,7 +102,7 @@ stub_add_dynamic(const char *name)
    if (!stub->addr)
       return NULL;
 
-   stub->name = (const void *) name;
+   stub->name = (const void *) strdup(name);
    /* to be fixed later */
    stub->slot = -1;