![]() |
|
|||
File indexing completed on 2025-05-11 08:24:12
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @brief RTEMS File System Mutex 0007 * 0008 * @ingroup rtems_rfs 0009 * 0010 * RTEMS File System Mutex. 0011 * 0012 * It may be suprising we abstract this for the RTEMS file system but this code 0013 * is designed to be run on host operating systems. 0014 */ 0015 0016 /* 0017 * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org> 0018 * 0019 * Redistribution and use in source and binary forms, with or without 0020 * modification, are permitted provided that the following conditions 0021 * are met: 0022 * 1. Redistributions of source code must retain the above copyright 0023 * notice, this list of conditions and the following disclaimer. 0024 * 2. Redistributions in binary form must reproduce the above copyright 0025 * notice, this list of conditions and the following disclaimer in the 0026 * documentation and/or other materials provided with the distribution. 0027 * 0028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0029 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0030 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0031 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0032 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0033 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0034 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0035 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0036 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0037 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0038 * POSSIBILITY OF SUCH DAMAGE. 0039 */ 0040 0041 #if !defined (_RTEMS_RFS_MUTEX_H_) 0042 #define _RTEMS_RFS_MUTEX_H_ 0043 0044 #include <errno.h> 0045 0046 #include <rtems/rfs/rtems-rfs-trace.h> 0047 0048 #if __rtems__ 0049 #include <rtems.h> 0050 #include <rtems/error.h> 0051 #include <rtems/thread.h> 0052 #endif 0053 0054 /** 0055 * RFS Mutex type. 0056 */ 0057 #if __rtems__ 0058 typedef rtems_recursive_mutex rtems_rfs_mutex; 0059 #else 0060 typedef uint32_t rtems_rfs_mutex; /* place holder */ 0061 #endif 0062 0063 /** 0064 * @brief Create the mutex. 0065 * 0066 * @param [in] mutex is pointer to the mutex handle returned to the caller. 0067 * 0068 * @retval 0 Successful operation. 0069 * @retval EIO An error occurred. 0070 * 0071 */ 0072 int rtems_rfs_mutex_create (rtems_rfs_mutex* mutex); 0073 0074 /** 0075 * @brief Destroy the mutex. 0076 * 0077 * @param[in] mutex Reference to the mutex handle returned to the caller. 0078 * 0079 * @retval 0 Successful operation. 0080 * @retval EIO An error occurred. 0081 */ 0082 int rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex); 0083 0084 /** 0085 * @brief Lock the mutex. 0086 * 0087 * @param[in] mutex is a pointer to the mutex to lock. 0088 * 0089 * @retval 0 Successful operation. 0090 * @retval EIO An error occurred. 0091 */ 0092 static inline int 0093 rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex) 0094 { 0095 #if __rtems__ 0096 rtems_recursive_mutex_lock(mutex); 0097 #endif 0098 return 0; 0099 } 0100 0101 /** 0102 * @brief Unlock the mutex. 0103 * 0104 * @param[in] mutex is a pointer to the mutex to unlock. 0105 * 0106 * @retval 0 Successful operation. 0107 * @retval EIO An error occurred. 0108 */ 0109 static inline int 0110 rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex) 0111 { 0112 #if __rtems__ 0113 rtems_recursive_mutex_unlock(mutex); 0114 #endif 0115 return 0; 0116 } 0117 0118 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |