RTEMS CPU Kit with SuperCore  4.11.3
rtems-rfs-mutex.h
Go to the documentation of this file.
1 
14 /*
15  * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
16  *
17  * The license and distribution terms for this file may be
18  * found in the file LICENSE in this distribution or at
19  * http://www.rtems.org/license/LICENSE.
20  */
21 
22 #if !defined (_RTEMS_RFS_MUTEX_H_)
23 #define _RTEMS_RFS_MUTEX_H_
24 
25 #include <errno.h>
26 
27 #include <rtems/rfs/rtems-rfs-trace.h>
28 
29 #if __rtems__
30 #include <rtems.h>
31 #include <rtems/error.h>
32 #endif
33 
37 #if __rtems__
39 #else
40 typedef uint32_t rtems_rfs_mutex; /* place holder */
41 #endif
42 
52 int rtems_rfs_mutex_create (rtems_rfs_mutex* mutex);
53 
62 int rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex);
63 
72 static inline int
73 rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex)
74 {
75 #if __rtems__
77  if (sc != RTEMS_SUCCESSFUL)
78  {
79 #if RTEMS_RFS_TRACE
80  if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
81  printf ("rtems-rfs: mutex: obtain failed: %s\n",
82  rtems_status_text (sc));
83 #endif
84  return EIO;
85  }
86 #endif
87  return 0;
88 }
89 
98 static inline int
99 rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex)
100 {
101 #if __rtems__
103  if (sc != RTEMS_SUCCESSFUL)
104  {
105 #if RTEMS_RFS_TRACE
106  if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
107  printf ("rtems-rfs: mutex: release failed: %s\n",
108  rtems_status_text (sc));
109 #endif
110  return EIO;
111  }
112 #endif
113  return 0;
114 }
115 
116 #endif
This is the status to indicate successful completion.
Definition: status.h:50
Objects_Id rtems_id
Used to manage and manipulate RTEMS object identifiers.
Definition: types.h:80
int rtems_rfs_mutex_create(rtems_rfs_mutex *mutex)
Create the mutex.
Definition: rtems-rfs-mutex.c:31
uint32_t rtems_rfs_mutex
RFS Mutex type.
Definition: rtems-rfs-mutex.h:40
RTEMS Error Reporting.
bool rtems_rfs_trace(rtems_rfs_trace_mask mask)
Call to check if this part is bring traced.
rtems_status_code
Classic API Status.
Definition: status.h:46
rtems_status_code rtems_semaphore_release(rtems_id id)
RTEMS Semaphore Release.
Definition: semrelease.c:56
rtems_status_code rtems_semaphore_obtain(rtems_id id, rtems_option option_set, rtems_interval timeout)
RTEMS Obtain Semaphore.
Definition: semobtain.c:34
#define RTEMS_WAIT
This option constants indicates that the task is to wait on resource.
Definition: options.h:56
const char * rtems_status_text(rtems_status_code code)
Returns a text for a status code.
Definition: statustext.c:59
int rtems_rfs_mutex_destroy(rtems_rfs_mutex *mutex)
Destroy the mutex.
Definition: rtems-rfs-mutex.c:50