File indexing completed on 2025-05-11 08:24:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef _RTEMS_POSIX_SHMIMPL_H
0036 #define _RTEMS_POSIX_SHMIMPL_H
0037
0038 #include <rtems/fs.h>
0039 #include <rtems/libio.h>
0040 #include <rtems/posix/posixapi.h>
0041 #include <rtems/posix/shm.h>
0042 #include <rtems/score/objectimpl.h>
0043
0044 #ifdef __cplusplus
0045 extern "C" {
0046 #endif
0047
0048
0049
0050
0051
0052
0053 static inline POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void )
0054 {
0055 return (POSIX_Shm_Control *)
0056 _Objects_Allocate_unprotected( &_POSIX_Shm_Information );
0057 }
0058
0059
0060
0061
0062
0063
0064 static inline void _POSIX_Shm_Free (
0065 POSIX_Shm_Control *the_shm
0066 )
0067 {
0068 _Objects_Free( &_POSIX_Shm_Information, &the_shm->Object );
0069 }
0070
0071 static inline POSIX_Shm_Control *_POSIX_Shm_Get_by_name(
0072 const char *name,
0073 size_t *name_length_p,
0074 Objects_Get_by_name_error *error
0075 )
0076 {
0077 return (POSIX_Shm_Control *) _Objects_Get_by_name(
0078 &_POSIX_Shm_Information,
0079 name,
0080 name_length_p,
0081 error
0082 );
0083 }
0084
0085 static inline void _POSIX_Shm_Update_atime(
0086 POSIX_Shm_Control *shm
0087 )
0088 {
0089 struct timeval now;
0090 gettimeofday( &now, 0 );
0091 shm->atime = now.tv_sec;
0092 }
0093
0094 static inline void _POSIX_Shm_Update_mtime_ctime(
0095 POSIX_Shm_Control *shm
0096 )
0097 {
0098 struct timeval now;
0099 gettimeofday( &now, 0 );
0100 shm->mtime = now.tv_sec;
0101 shm->ctime = now.tv_sec;
0102 }
0103
0104 static inline POSIX_Shm_Control* iop_to_shm( rtems_libio_t *iop )
0105 {
0106 return (POSIX_Shm_Control*) iop->data1;
0107 }
0108
0109 static inline POSIX_Shm_Control* loc_to_shm(
0110 const rtems_filesystem_location_info_t *loc
0111 )
0112 {
0113 return (POSIX_Shm_Control*) loc->node_access;
0114 }
0115
0116 static inline int POSIX_Shm_Attempt_delete(
0117 POSIX_Shm_Control* shm
0118 )
0119 {
0120 Objects_Control *obj;
0121 ISR_lock_Context lock_ctx;
0122 int err;
0123
0124 err = 0;
0125
0126 _Objects_Allocator_lock();
0127 --shm->reference_count;
0128 if ( shm->reference_count == 0 ) {
0129 if ( (*shm->shm_object.ops->object_delete)( &shm->shm_object ) != 0 ) {
0130 err = EIO;
0131 }
0132 }
0133
0134 obj = _Objects_Get( shm->Object.id, &lock_ctx, &_POSIX_Shm_Information );
0135 if ( obj == NULL ) {
0136
0137 _POSIX_Shm_Free( shm );
0138 } else {
0139
0140 _ISR_lock_ISR_enable( &lock_ctx );
0141 }
0142 _Objects_Allocator_unlock();
0143 return err;
0144 }
0145
0146
0147
0148 #ifdef __cplusplus
0149 }
0150 #endif
0151
0152 #endif