}
 
        notes = symbol__annotation(sym);
-       pthread_mutex_lock(¬es->lock);
+       mutex_lock(¬es->lock);
 
        if (!symbol__hists(sym, top->evlist->core.nr_entries)) {
-               pthread_mutex_unlock(¬es->lock);
+               mutex_unlock(¬es->lock);
                pr_err("Not enough memory for annotating '%s' symbol!\n",
                       sym->name);
                sleep(1);
                pr_err("Couldn't annotate %s: %s\n", sym->name, msg);
        }
 
-       pthread_mutex_unlock(¬es->lock);
+       mutex_unlock(¬es->lock);
        return err;
 }
 
 
        notes = symbol__annotation(sym);
 
-       if (pthread_mutex_trylock(¬es->lock))
+       if (!mutex_trylock(¬es->lock))
                return;
 
        err = hist_entry__inc_addr_samples(he, sample, evsel, ip);
 
-       pthread_mutex_unlock(¬es->lock);
+       mutex_unlock(¬es->lock);
 
        if (unlikely(err)) {
                /*
        symbol = he->ms.sym;
        notes = symbol__annotation(symbol);
 
-       pthread_mutex_lock(¬es->lock);
+       mutex_lock(¬es->lock);
 
        symbol__calc_percent(symbol, evsel);
 
        if (more != 0)
                printf("%d lines not displayed, maybe increase display entries [e]\n", more);
 out_unlock:
-       pthread_mutex_unlock(¬es->lock);
+       mutex_unlock(¬es->lock);
 }
 
 static void perf_top__resort_hists(struct perf_top *t)
 
 
        browser->entries = RB_ROOT;
 
-       pthread_mutex_lock(¬es->lock);
+       mutex_lock(¬es->lock);
 
        symbol__calc_percent(sym, evsel);
 
                }
                disasm_rb_tree__insert(browser, &pos->al);
        }
-       pthread_mutex_unlock(¬es->lock);
+       mutex_unlock(¬es->lock);
 
        browser->curr_hot = rb_last(&browser->entries);
 }
        }
 
        notes = symbol__annotation(dl->ops.target.sym);
-       pthread_mutex_lock(¬es->lock);
+       mutex_lock(¬es->lock);
 
        if (!symbol__hists(dl->ops.target.sym, evsel->evlist->core.nr_entries)) {
-               pthread_mutex_unlock(¬es->lock);
+               mutex_unlock(¬es->lock);
                ui__warning("Not enough memory for annotating '%s' symbol!\n",
                            dl->ops.target.sym->name);
                return true;
        target_ms.maps = ms->maps;
        target_ms.map = ms->map;
        target_ms.sym = dl->ops.target.sym;
-       pthread_mutex_unlock(¬es->lock);
+       mutex_unlock(¬es->lock);
        symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts);
        sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type);
        ui_browser__show_title(&browser->b, title);
 
 #include "arch/common.h"
 #include "namespaces.h"
 #include <regex.h>
-#include <pthread.h>
 #include <linux/bitops.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 {
        struct annotation *notes = symbol__annotation(sym);
 
-       pthread_mutex_lock(¬es->lock);
+       mutex_lock(¬es->lock);
        if (notes->src != NULL) {
                memset(notes->src->histograms, 0,
                       notes->src->nr_histograms * notes->src->sizeof_sym_hist);
                        memset(notes->src->cycles_hist, 0,
                                symbol__size(sym) * sizeof(struct cyc_hist));
        }
-       pthread_mutex_unlock(¬es->lock);
+       mutex_unlock(¬es->lock);
 }
 
 static int __symbol__account_cycles(struct cyc_hist *ch,
        notes->hit_insn = 0;
        notes->cover_insn = 0;
 
-       pthread_mutex_lock(¬es->lock);
+       mutex_lock(¬es->lock);
        for (offset = size - 1; offset >= 0; --offset) {
                struct cyc_hist *ch;
 
                        notes->have_cycles = true;
                }
        }
-       pthread_mutex_unlock(¬es->lock);
+       mutex_unlock(¬es->lock);
 }
 
 int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
 
 void annotation__init(struct annotation *notes)
 {
-       pthread_mutex_init(¬es->lock, NULL);
+       mutex_init(¬es->lock);
 }
 
 void annotation__exit(struct annotation *notes)
 {
        annotated_source__delete(notes->src);
-       pthread_mutex_destroy(¬es->lock);
+       mutex_destroy(¬es->lock);
 }
 
 static void annotation_line__add(struct annotation_line *al, struct list_head *head)
 
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/rbtree.h>
-#include <pthread.h>
 #include <asm/bug.h>
 #include "symbol_conf.h"
+#include "mutex.h"
 #include "spark.h"
 
 struct hist_browser_timer;
 };
 
 struct annotation {
-       pthread_mutex_t         lock;
+       struct mutex lock;
        u64                     max_coverage;
        u64                     start;
        u64                     hit_cycles;