summaryrefslogtreecommitdiffstats
path: root/osdep/threads.h
blob: bfa3815fe695b656242a39f3721703633b118522 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef MP_OSDEP_THREADS_H_
#define MP_OSDEP_THREADS_H_

#include <pthread.h>

#include "config.h"

// Helper to reduce boiler plate.
int mpthread_mutex_init_recursive(pthread_mutex_t *mutex);

// Set thread name (for debuggers).
void mpthread_set_name(const char *name);

enum mp_mutex_type {
    MP_MUTEX_NORMAL = 0,
    MP_MUTEX_RECURSIVE,
};

#define mp_mutex_init(mutex) \
    mp_mutex_init_type(mutex, MP_MUTEX_NORMAL)

#define mp_mutex_init_type(mutex, mtype) \
    assert(!mp_mutex_init_type_internal(mutex, mtype))

#if HAVE_WIN32_THREADS
#include "threads-win32.h"
#else
#include "threads-posix.h"
#endif

#endif