source: rtems/cpukit/include/rtems/posix/shmimpl.h @ 0f5b2c09

5
Last change on this file since 0f5b2c09 was 2afb22b, checked in by Chris Johns <chrisj@…>, on 12/23/17 at 07:18:56

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

  • Property mode set to 100644
File size: 2.7 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
99static inline int POSIX_Shm_Attempt_delete(
100    POSIX_Shm_Control* shm
101)
102{
103  Objects_Control       *obj;
104  ISR_lock_Context       lock_ctx;
105  int err;
106
107  err = 0;
108
109  _Objects_Allocator_lock();
110  --shm->reference_count;
111  if ( shm->reference_count == 0 ) {
112    if ( (*shm->shm_object.ops->object_delete)( &shm->shm_object ) != 0 ) {
113      err = EIO;
114    }
115  }
116  /* check if the object has been unlinked yet. */
117  obj = _Objects_Get( shm->Object.id, &lock_ctx, &_POSIX_Shm_Information );
118  if ( obj == NULL ) {
119    /* if it was unlinked, then it can be freed. */
120    _POSIX_Shm_Free( shm );
121  } else {
122    /* it will be freed when it is unlinked. */
123    _ISR_lock_ISR_enable( &lock_ctx );
124  }
125  _Objects_Allocator_unlock();
126  return err;
127}
128
129/** @} */
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif
Note: See TracBrowser for help on using the repository browser.