aboutsummaryrefslogtreecommitdiff
path: root/ubifs-utils/common/rwsem.h
blob: 3761724b4db9eb1f2661e259fa3c6a8d96ce575e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_RWSEM_H_
#define __LINUX_RWSEM_H_

#include <pthread.h>

struct rw_semaphore {
	pthread_mutex_t lock;
};

#define init_rwsem(x)			pthread_mutex_init(&(x)->lock, NULL)

#define down_read(x)			pthread_mutex_lock(&(x)->lock)
#define down_write(x)			pthread_mutex_lock(&(x)->lock)
#define up_read(x)			pthread_mutex_unlock(&(x)->lock)
#define up_write(x)			pthread_mutex_unlock(&(x)->lock)
#define down_write_trylock(x)		(pthread_mutex_trylock(&(x)->lock) == 0)

#endif