]> git.saurik.com Git - apple/hfs.git/blame - livefiles_hfs_plugin/lf_hfs_locks.h
hfs-522.100.5.tar.gz
[apple/hfs.git] / livefiles_hfs_plugin / lf_hfs_locks.h
CommitLineData
de8ee011
A
1/* Copyright © 2017-2018 Apple Inc. All rights reserved.
2 *
3 * lf_hfs_locks.h
4 * livefiles_hfs
5 *
6 * Created by Or Haimovich on 18/3/18.
7 */
8
9#ifndef lf_hfs_locks_h
10#define lf_hfs_locks_h
11
12#include <stdio.h>
13#include <stdint.h>
14#include <stdbool.h>
15#include <pthread.h>
16
17typedef enum
18{
19 LCK_RW_TYPE_SHARED,
20 LCK_RW_TYPE_EXCLUSIVE
21
22} lck_rwlock_type_e;
23
24typedef uint8_t lck_attr_t;
25typedef uint8_t lck_grp_attr_t;
26typedef uint8_t lck_grp_t;
27
28// Read/Write locks.
29void lf_lck_rw_init ( pthread_rwlock_t* lck );
30void lf_lck_rw_destroy ( pthread_rwlock_t* lck );
31void lf_lck_rw_unlock_shared ( pthread_rwlock_t* lck );
32void lf_lck_rw_lock_shared ( pthread_rwlock_t* lck );
33void lf_lck_rw_lock_exclusive ( pthread_rwlock_t* lck );
34void lf_lck_rw_unlock_exclusive ( pthread_rwlock_t* lck );
35bool lf_lck_rw_try_lock ( pthread_rwlock_t* lck, lck_rwlock_type_e which );
36void lf_lck_rw_lock_exclusive_to_shared ( pthread_rwlock_t* lck);
37bool lf_lck_rw_lock_shared_to_exclusive ( pthread_rwlock_t* lck);
38
39// Mutex locks.
40void lf_lck_mtx_init ( pthread_mutex_t* lck );
41void lf_lck_mtx_destroy ( pthread_mutex_t *lck );
42void lf_lck_mtx_lock ( pthread_mutex_t* lck );
43void lf_lck_mtx_unlock ( pthread_mutex_t* lck );
44void lf_lck_mtx_lock_spin ( pthread_mutex_t *lck );
45int lf_lck_mtx_try_lock ( pthread_mutex_t *lck );
46void lf_lck_mtx_convert_spin ( pthread_mutex_t *lck );
47
48//Cond
49void lf_cond_destroy( pthread_cond_t* cond );
50void lf_cond_init( pthread_cond_t* cond );
51int lf_cond_wait_relative(pthread_cond_t *pCond, pthread_mutex_t *pMutex, struct timespec *pTime);
52void lf_cond_wakeup(pthread_cond_t *pCond);
53
54// Spin locks.
55void lf_lck_spin_init ( pthread_mutex_t *lck );
56void lf_lck_spin_destroy ( pthread_mutex_t *lck );
57void lf_lck_spin_lock ( pthread_mutex_t *lck );
58void lf_lck_spin_unlock ( pthread_mutex_t *lck );
59
60// Init
61lck_attr_t *lf_lck_attr_alloc_init ( void );
62lck_grp_attr_t *lf_lck_grp_attr_alloc_init ( void );
63lck_grp_t *lf_lck_grp_alloc_init ( void );
64
65#endif /* lf_hfs_locks_h */