Skip to content

Commit

Permalink
Add lock helper macros
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Aug 4, 2017
1 parent 2ae5ce3 commit 6f51a47
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#define must_check __attribute__((warn_unused_result))

// types
// word_t will be 64-bit to read 64-bit elves
typedef uint64_t qword_t;
typedef uint32_t dword_t;
typedef int32_t sdword_t;
Expand All @@ -46,4 +45,9 @@ typedef sdword_t int_t;
#define uint(size) CONCAT3(uint,size,_t)
#define sint(size) CONCAT3(int,size,_t)

#define lock(thing) pthread_mutex_lock(&(thing)->lock)
#define unlock(thing) pthread_mutex_unlock(&(thing)->lock)
#define wait_for(thing, what) pthread_cond_wait(&(thing)->what, &(thing)->lock)
#define signal(thing, what) pthread_cond_broadcast(&(thing)->what)

#endif

0 comments on commit 6f51a47

Please sign in to comment.