source: rtems/cpukit/libfs/src/rfs/rtems-rfs-mutex.h @ 1d539c0

4.104.115
Last change on this file since 1d539c0 was a9fa9b7, checked in by Chris Johns <chrisj@…>, on 02/18/10 at 00:24:25

2010-02-18 Chris Johns <chrisj@…>

  • libfs/src/rfs/rtems-rfs-bitmaps.c, libfs/src/rfs/rtems-rfs-bitmaps.h, libfs/src/rfs/rtems-rfs-bitmaps-ut.c, libfs/src/rfs/rtems-rfs-block.c, libfs/src/rfs/rtems-rfs-block.h, libfs/src/rfs/rtems-rfs-block-pos.h, libfs/src/rfs/rtems-rfs-buffer-bdbuf.c, libfs/src/rfs/rtems-rfs-buffer.c, libfs/src/rfs/rtems-rfs-buffer-devio.c, libfs/src/rfs/rtems-rfs-buffer.h, libfs/src/rfs/rtems-rfs-data.h, libfs/src/rfs/rtems-rfs-dir.c, libfs/src/rfs/rtems-rfs-dir.h, libfs/src/rfs/rtems-rfs-dir-hash.c, libfs/src/rfs/rtems-rfs-dir-hash.h, libfs/src/rfs/rtems-rfs-file.c, libfs/src/rfs/rtems-rfs-file.h, libfs/src/rfs/rtems-rfs-file-system.c, libfs/src/rfs/rtems-rfs-file-system-fwd.h, libfs/src/rfs/rtems-rfs-file-system.h, libfs/src/rfs/rtems-rfs-format.c, libfs/src/rfs/rtems-rfs-format.h, libfs/src/rfs/rtems-rfs-group.c, libfs/src/rfs/rtems-rfs-group.h, libfs/src/rfs/rtems-rfs.h, libfs/src/rfs/rtems-rfs-inode.c, libfs/src/rfs/rtems-rfs-inode.h, libfs/src/rfs/rtems-rfs-link.c, libfs/src/rfs/rtems-rfs-link.h, libfs/src/rfs/rtems-rfs-mutex.c, libfs/src/rfs/rtems-rfs-mutex.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems-dev.c, libfs/src/rfs/rtems-rfs-rtems-dir.c, libfs/src/rfs/rtems-rfs-rtems-file.c, libfs/src/rfs/rtems-rfs-rtems.h, libfs/src/rfs/rtems-rfs-rtems-utils.c, libfs/src/rfs/rtems-rfs-shell.c, libfs/src/rfs/rtems-rfs-shell.h, libfs/src/rfs/rtems-rfs-trace.c, libfs/src/rfs/rtems-rfs-trace.h: New.
  • Makefile.am, preinstall.am, libfs/Makefile.am, wrapup/Makefile.am: Updated with the RFS support.
  • libfs/README: Updated after 10 years.
  • libblock/src/flashdisk.c, libblock/src/nvdisk.c, libblock/src/ramdisk-driver.c: Updated to the new error reporting in libblock.
  • libmisc/shell/main_ls.c, libmisc/shell/print-ls.c: Fix printing the size in long mode.
  • libnetworking/nfs/bootp_subr.c, libnetworking/rtems/rtems_bootp.c, libnetworking/rtems/rtems_bsdnet_internal.h: Return the BOOTP/DHCP to the forever behaviour of 4.9 with the ability to call BOOTP and control the process if required.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10/**
11 * @file
12 *
13 * @ingroup rtems-rfs
14 *
15 * RTEMS File System Mutex.
16 *
17 * It may be suprising we abstract this for the RTEMS file system but this code
18 * is designed to be run on host operating systems.
19 */
20
21#if !defined (_RTEMS_RFS_MUTEX_H_)
22#define _RTEMS_RFS_MUTEX_H_
23
24#include <errno.h>
25
26#include <rtems/rfs/rtems-rfs-trace.h>
27
28#if __rtems__
29#include <rtems.h>
30#include <rtems/error.h>
31#endif
32
33/**
34 * RFS Mutex type.
35 */
36#if __rtems__
37typedef rtems_id rtems_rfs_mutex;
38#else
39typedef uint32_t rtems_rfs_mutex; /* place holder */
40#endif
41
42/**
43 * Create the mutex.
44 *
45 * @param mutex Reference to the mutex handle returned to the caller.
46 * @return int The error number (errno). No error if 0.
47 */
48int rtems_rfs_mutex_create (rtems_rfs_mutex* mutex);
49
50/**
51 * Create the mutex.
52 *
53 * @param mutex Reference to the mutex handle returned to the caller.
54 * @return int The error number (errno). No error if 0.
55 */
56int rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex);
57
58/**
59 * Lock the mutex.
60 *
61 * @param mutex The mutex to lock.
62 * @retval true The mutex is locked.
63 * @retval false The mutex could not be locked.
64 */
65static inline int
66rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex)
67{
68#if __rtems__
69  rtems_status_code sc = rtems_semaphore_obtain (*mutex, RTEMS_WAIT, 0);
70  if (sc != RTEMS_SUCCESSFUL)
71  {
72#if RTEMS_RFS_TRACE
73    if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
74      printf ("rtems-rfs: mutex: obtain failed: %s\n",
75              rtems_status_text (sc));
76#endif
77    return EIO;
78  }
79#endif
80  return 0;
81}
82
83/**
84 * Unlock the mutex.
85 *
86 * @param mutex The mutex to unlock.
87 * @retval true The mutex is unlocked.
88 * @retval false The mutex could not be unlocked.
89 */
90static inline int
91rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex)
92{
93#if __rtems__
94  rtems_status_code sc = rtems_semaphore_release (*mutex);
95  if (sc != RTEMS_SUCCESSFUL)
96  {
97#if RTEMS_RFS_TRACE
98    if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
99      printf ("rtems-rfs: mutex: release failed: %s\n",
100              rtems_status_text (sc));
101#endif
102    return EIO;
103  }
104#endif
105  return 0;
106}
107
108#endif
Note: See TracBrowser for help on using the repository browser.