Motr  M0
mutex.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2011-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #include <linux/version.h> /* LINUX_VERSION_CODE */
24 #include <linux/module.h>
25 #include <asm/current.h>
26 
27 #include "lib/mutex.h"
28 #include "lib/misc.h" /* M0_EXPORTED */
29 
38 M0_INTERNAL void m0_arch_mutex_init(struct m0_arch_mutex *mutex)
39 {
40  mutex_init(&mutex->m_mutex);
41 }
42 M0_EXPORTED(m0_arch_mutex_init);
43 
44 M0_INTERNAL void m0_arch_mutex_fini(struct m0_arch_mutex *mutex)
45 {
46  mutex_destroy(&mutex->m_mutex);
47 }
48 M0_EXPORTED(m0_arch_mutex_fini);
49 
50 M0_INTERNAL void m0_arch_mutex_lock(struct m0_arch_mutex *mutex)
51 {
52  mutex_lock(&mutex->m_mutex);
53 }
54 M0_EXPORTED(m0_arch_mutex_lock);
55 
56 M0_INTERNAL int m0_arch_mutex_trylock(struct m0_arch_mutex *mutex)
57 {
58  return mutex_trylock(&mutex->m_mutex);
59 }
60 
61 M0_INTERNAL void m0_arch_mutex_unlock(struct m0_arch_mutex *mutex)
62 {
63  mutex_unlock(&mutex->m_mutex);
64 }
65 M0_EXPORTED(m0_arch_mutex_unlock);
66 
69 /*
70  * Local variables:
71  * c-indentation-style: "K&R"
72  * c-basic-offset: 8
73  * tab-width: 8
74  * fill-column: 80
75  * scroll-step: 1
76  * End:
77  */
M0_INTERNAL void m0_arch_mutex_init(struct m0_arch_mutex *mutex)
Definition: mutex.c:38
M0_INTERNAL void m0_arch_mutex_lock(struct m0_arch_mutex *mutex)
Definition: mutex.c:50
struct m0_mutex mutex
Definition: format.h:170
M0_INTERNAL void m0_arch_mutex_unlock(struct m0_arch_mutex *mutex)
Definition: mutex.c:61
M0_INTERNAL int m0_arch_mutex_trylock(struct m0_arch_mutex *mutex)
Definition: mutex.c:56
M0_INTERNAL void m0_arch_mutex_fini(struct m0_arch_mutex *mutex)
Definition: mutex.c:44