source: rtems/cpukit/score/inline/rtems/score/address.inl @ 14426c8f

4.104.114.84.95
Last change on this file since 14426c8f was 14426c8f, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/24/05 at 15:05:14

2005-01-24 Ralf Corsepius <ralf.corsepius@…>

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