-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is a wrapper around the locks from the omp runtime - was required to be able to easily switch between mutex implementations.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* Copyright 2024. Institute of Biomedical Imaging. TU Graz. | ||
* All rights reserved. Use of this source code is governed by | ||
* a BSD-style license which can be found in the LICENSE file. | ||
* | ||
* Authors: | ||
* 2024 Philip Schaten <philip.schaten@tugraz.at> | ||
*/ | ||
|
||
#ifdef _OPENMP | ||
#include <omp.h> | ||
#endif | ||
|
||
#include "misc/misc.h" | ||
|
||
#include "lock.h" | ||
|
||
struct bart_lock { | ||
#ifdef _OPENMP | ||
omp_lock_t omp; | ||
#else | ||
int dummy; | ||
#endif | ||
}; | ||
|
||
void bart_lock(bart_lock_t* lock) | ||
{ | ||
#ifdef _OPENMP | ||
omp_set_lock(&lock->omp); | ||
#endif | ||
} | ||
|
||
void bart_unlock(bart_lock_t* lock) | ||
{ | ||
#ifdef _OPENMP | ||
omp_unset_lock(&lock->omp); | ||
#endif | ||
} | ||
|
||
bart_lock_t* bart_lock_create(void) | ||
{ | ||
bart_lock_t* lock = xmalloc(sizeof *lock); | ||
|
||
#ifdef _OPENMP | ||
omp_init_lock(&lock->omp); | ||
#endif | ||
return lock; | ||
} | ||
|
||
void bart_lock_destroy(bart_lock_t* lock) | ||
{ | ||
#ifdef _OPENMP | ||
omp_destroy_lock(&lock->omp); | ||
#endif | ||
xfree(lock); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
typedef struct bart_lock bart_lock_t; | ||
|
||
void bart_lock(bart_lock_t* lock); | ||
void bart_unlock(bart_lock_t* lock); | ||
void bart_lock_destroy(bart_lock_t* x); | ||
bart_lock_t* bart_lock_create(void); | ||
|