source: rtems/cpukit/posix/include/rtems/posix/shmimpl.h @ bd9d5eb

5
Last change on this file since bd9d5eb was bd9d5eb, checked in by Gedare Bloom <gedare@…>, on 03/31/17 at 19:23:47

posix/shm: replace threadq with mutex (allocator lock)

Closes #2957.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Private Support Information for POSIX Shared Memory
5 *
6 */
7
8/*
9 * Copyright (c) 2016 Gedare Bloom.
10 *
11 * The license and distribution terms for this file may be
12 * found in the file LICENSE in this distribution or at
13 * http://www.rtems.org/license/LICENSE.
14 */
15
16#ifndef _RTEMS_POSIX_SHMIMPL_H
17#define _RTEMS_POSIX_SHMIMPL_H
18
19#include <rtems/fs.h>
20#include <rtems/libio.h>
21#include <rtems/posix/posixapi.h>
22#include <rtems/posix/shm.h>
23#include <rtems/score/objectimpl.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 * @ingroup POSIXShmPrivate
31 * @{
32 */
33
34extern Objects_Information _POSIX_Shm_Information;
35
36RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Allocate_unprotected( void )
37{
38  return (POSIX_Shm_Control *)
39    _Objects_Allocate_unprotected( &_POSIX_Shm_Information );
40}
41
42/**
43 * @brief POSIX Shared Memory Free
44 *
45 * This routine frees a shm control block.
46 */
47RTEMS_INLINE_ROUTINE void _POSIX_Shm_Free (
48  POSIX_Shm_Control *the_shm
49)
50{
51  _Objects_Free( &_POSIX_Shm_Information, &the_shm->Object );
52}
53
54RTEMS_INLINE_ROUTINE POSIX_Shm_Control *_POSIX_Shm_Get_by_name(
55  const char                *name,
56  size_t                    *name_length_p,
57  Objects_Get_by_name_error *error
58)
59{
60  return (POSIX_Shm_Control *) _Objects_Get_by_name(
61    &_POSIX_Shm_Information,
62    name,
63    name_length_p,
64    error
65  );
66}
67
68RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_atime(
69  POSIX_Shm_Control *shm
70)
71{
72  struct timeval now;
73  gettimeofday( &now, 0 );
74  shm->atime = now.tv_sec;
75}
76
77RTEMS_INLINE_ROUTINE void _POSIX_Shm_Update_mtime_ctime(
78  POSIX_Shm_Control *shm
79)
80{
81  struct timeval now;
82  gettimeofday( &now, 0 );
83  shm->mtime = now.tv_sec;
84  shm->ctime = now.tv_sec;
85}
86
87static inline POSIX_Shm_Control* iop_to_shm( rtems_libio_t *iop )
88{
89  return (POSIX_Shm_Control*) iop->data1;
90}
91
92static inline POSIX_Shm_Control* loc_to_shm(
93    const rtems_filesystem_location_info_t *loc
94)
95{
96  return (POSIX_Shm_Control*) loc->node_access;
97}
98
99/** @} */
100
101#ifdef __cplusplus
102}
103#endif
104
105#endif
Note: See TracBrowser for help on using the repository browser.