source: rtems/cpukit/score/inline/rtems/score/address.inl @ d8dbdc0

4.104.114.84.95
Last change on this file since d8dbdc0 was d6154c7, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/29/04 at 16:41:13

2004-03-29 Ralf Corsepius <ralf_corsepius@…>

  • score/include/rtems/debug.h, score/include/rtems/score/bitfield.h, score/include/rtems/score/chain.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h, score/include/rtems/score/heap.h, score/include/rtems/score/interr.h, score/include/rtems/score/isr.h, score/include/rtems/score/mpci.h, score/include/rtems/score/mppkt.h, score/include/rtems/score/object.h, score/include/rtems/score/objectmp.h, score/include/rtems/score/priority.h, score/include/rtems/score/stack.h, score/include/rtems/score/states.h, score/include/rtems/score/thread.h, score/include/rtems/score/threadmp.h, score/include/rtems/score/threadq.h, score/include/rtems/score/tod.h, score/include/rtems/score/tqdata.h, score/include/rtems/score/userext.h, score/include/rtems/score/watchdog.h, score/include/rtems/score/wkspace.h, score/inline/rtems/score/address.inl, score/inline/rtems/score/coremsg.inl, score/inline/rtems/score/coresem.inl, score/inline/rtems/score/heap.inl, score/inline/rtems/score/isr.inl, score/inline/rtems/score/object.inl, score/inline/rtems/score/priority.inl, score/inline/rtems/score/stack.inl, score/inline/rtems/score/thread.inl, score/inline/rtems/score/tqdata.inl, score/inline/rtems/score/userext.inl, score/inline/rtems/score/wkspace.inl, score/macros/rtems/score/address.inl, score/macros/rtems/score/heap.inl, score/macros/rtems/score/object.inl, score/macros/rtems/score/priority.inl, score/macros/rtems/score/userext.inl: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*  inline/address.inl
2 *
3 *  This include file contains the bodies of the routines
4 *  about addresses which are inlined.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#ifndef __INLINE_ADDRESSES_inl
17#define __INLINE_ADDRESSES_inl
18
19/*PAGE
20 *
21 *  _Addresses_Add_offset
22 *
23 *  DESCRIPTION:
24 *
25 *  This function is used to add an offset to a base address.
26 *  It returns the resulting address.  This address is typically
27 *  converted to an access type before being used further.
28 */
29
30RTEMS_INLINE_ROUTINE void *_Addresses_Add_offset (
31  void       *base,
32  uint32_t    offset
33)
34{
35  return (void *)((char *)base + offset);
36}
37
38/*PAGE
39 *
40 *  _Addresses_Subtract_offset
41 *
42 *  DESCRIPTION:
43 *
44 *  This function is used to subtract an offset from a base
45 *  address.  It returns the resulting address.  This address is
46 *  typically converted to an access type before being used further.
47 */
48
49RTEMS_INLINE_ROUTINE void *_Addresses_Subtract_offset (
50  void       *base,
51  uint32_t    offset
52)
53{
54  return (void *)((char *)base - offset);
55}
56
57/*PAGE
58 *
59 *  _Addresses_Subtract
60 *
61 *  DESCRIPTION:
62 *
63 *  This function is used to subtract two addresses.  It returns the
64 *  resulting offset.
65 *
66 *  NOTE:  The cast of an address to an uint32_t   makes this code
67 *         dependent on an addresses being thirty two bits.
68 */
69
70RTEMS_INLINE_ROUTINE uint32_t   _Addresses_Subtract (
71  void *left,
72  void *right
73)
74{
75  return ((char *) left - (char *) right);
76}
77
78/*PAGE
79 *
80 *  _Addresses_Is_aligned
81 *
82 *  DESCRIPTION:
83 *
84 *  This function returns TRUE if the given address is correctly
85 *  aligned for this processor and FALSE otherwise.  Proper alignment
86 *  is based on correctness and efficiency.
87 */
88
89RTEMS_INLINE_ROUTINE boolean _Addresses_Is_aligned (
90  void *address
91)
92{
93#if (CPU_ALIGNMENT == 0)
94    return TRUE;
95#elif defined(RTEMS_CPU_HAS_16_BIT_ADDRESSES)
96    return ( ( (unsigned short)address % CPU_ALIGNMENT ) == 0 );
97#else
98    return ( ( (uint32_t  )address % CPU_ALIGNMENT ) == 0 );
99#endif
100}
101
102/*PAGE
103 *
104 *  _Addresses_Is_in_range
105 *
106 *  DESCRIPTION:
107 *
108 *  This function returns TRUE if the given address is within the
109 *  memory range specified and FALSE otherwise.  base is the address
110 *  of the first byte in the memory range and limit is the address
111 *  of the last byte in the memory range.  The base address is
112 *  assumed to be lower than the limit address.
113 */
114
115RTEMS_INLINE_ROUTINE boolean _Addresses_Is_in_range (
116  void *address,
117  void *base,
118  void *limit
119)
120{
121  return ( address >= base && address <= limit );
122}
123
124#endif
125/* end of include file */
Note: See TracBrowser for help on using the repository browser.