gallium/util: libunwind support
[mesa.git] / src / gallium / auxiliary / util / u_debug_flush.c
index 6a8a91d3130921d96d3418ec05fa997eb9604045..06d0cfafa822fa946ca1cc1d03264a0bc1556ce7 100644 (file)
@@ -77,7 +77,7 @@ struct debug_flush_ctx {
    struct list_head head;
 };
 
-pipe_static_mutex(list_mutex);
+static mtx_t list_mutex = _MTX_INITIALIZER_NP;
 static struct list_head ctx_list = {&ctx_list, &ctx_list};
 
 static struct debug_stack_frame *
@@ -116,7 +116,7 @@ debug_flush_buf_create(boolean supports_unsync, unsigned bt_depth)
    fbuf->supports_unsync = supports_unsync;
    fbuf->bt_depth = bt_depth;
    pipe_reference_init(&fbuf->reference, 1);
-   pipe_mutex_init(fbuf->mutex);
+   (void) mtx_init(&fbuf->mutex, mtx_plain);
 
    return fbuf;
 out_no_buf:
@@ -165,9 +165,9 @@ debug_flush_ctx_create(boolean catch_reference_of_mapped, unsigned bt_depth)
       goto out_no_ref_hash;
 
    fctx->bt_depth = bt_depth;
-   pipe_mutex_lock(list_mutex);
+   mtx_lock(&list_mutex);
    list_addtail(&fctx->head, &ctx_list);
-   pipe_mutex_unlock(list_mutex);
+   mtx_unlock(&list_mutex);
 
    return fctx;
 
@@ -215,7 +215,7 @@ debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags)
    if (!fbuf)
       return;
 
-   pipe_mutex_lock(fbuf->mutex);
+   mtx_lock(&fbuf->mutex);
    if (fbuf->mapped) {
       debug_flush_alert("Recursive map detected.", "Map",
                         2, fbuf->bt_depth, TRUE, TRUE, NULL);
@@ -227,12 +227,12 @@ debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags)
    }
    fbuf->map_frame = debug_flush_capture_frame(1, fbuf->bt_depth);
    fbuf->mapped = TRUE;
-   pipe_mutex_unlock(fbuf->mutex);
+   mtx_unlock(&fbuf->mutex);
 
    if (mapped_sync) {
       struct debug_flush_ctx *fctx;
 
-      pipe_mutex_lock(list_mutex);
+      mtx_lock(&list_mutex);
       LIST_FOR_EACH_ENTRY(fctx, &ctx_list, head) {
          struct debug_flush_item *item =
             util_hash_table_get(fctx->ref_hash, fbuf);
@@ -244,7 +244,7 @@ debug_flush_map(struct debug_flush_buf *fbuf, unsigned flags)
                               FALSE, FALSE, item->ref_frame);
          }
       }
-      pipe_mutex_unlock(list_mutex);
+      mtx_unlock(&list_mutex);
    }
 }
 
@@ -254,7 +254,7 @@ debug_flush_unmap(struct debug_flush_buf *fbuf)
    if (!fbuf)
       return;
 
-   pipe_mutex_lock(fbuf->mutex);
+   mtx_lock(&fbuf->mutex);
    if (!fbuf->mapped)
       debug_flush_alert("Unmap not previously mapped detected.", "Map",
                         2, fbuf->bt_depth, FALSE, TRUE, NULL);
@@ -263,7 +263,7 @@ debug_flush_unmap(struct debug_flush_buf *fbuf)
    fbuf->mapped = FALSE;
    FREE(fbuf->map_frame);
    fbuf->map_frame = NULL;
-   pipe_mutex_unlock(fbuf->mutex);
+   mtx_unlock(&fbuf->mutex);
 }
 
 void
@@ -277,14 +277,14 @@ debug_flush_cb_reference(struct debug_flush_ctx *fctx,
 
    item = util_hash_table_get(fctx->ref_hash, fbuf);
 
-   pipe_mutex_lock(fbuf->mutex);
+   mtx_lock(&fbuf->mutex);
    if (fbuf->mapped_sync) {
       debug_flush_alert("Reference of mapped buffer detected.", "Reference",
                         2, fctx->bt_depth, TRUE, TRUE, NULL);
       debug_flush_alert(NULL, "Map", 0, fbuf->bt_depth, FALSE,
                         FALSE, fbuf->map_frame);
    }
-   pipe_mutex_unlock(fbuf->mutex);
+   mtx_unlock(&fbuf->mutex);
 
    if (!item) {
       item = CALLOC_STRUCT(debug_flush_item);
@@ -320,7 +320,7 @@ debug_flush_might_flush_cb(void *key, void *value, void *data)
    util_snprintf(message, sizeof(message),
                  "%s referenced mapped buffer detected.", reason);
 
-   pipe_mutex_lock(fbuf->mutex);
+   mtx_lock(&fbuf->mutex);
    if (fbuf->mapped_sync) {
       debug_flush_alert(message, reason, 3, item->bt_depth, TRUE, TRUE, NULL);
       debug_flush_alert(NULL, "Map", 0, fbuf->bt_depth, TRUE, FALSE,
@@ -328,7 +328,7 @@ debug_flush_might_flush_cb(void *key, void *value, void *data)
       debug_flush_alert(NULL, "First reference", 0, item->bt_depth, FALSE,
                         FALSE, item->ref_frame);
    }
-   pipe_mutex_unlock(fbuf->mutex);
+   mtx_unlock(&fbuf->mutex);
 
    return PIPE_OK;
 }