OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [inline/] [rtems/] [score/] [address.inl] - Blame information for rev 30

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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.OARcorp.com/rtems/license.html.
12
 *
13
 *  $Id: address.inl,v 1.2 2001-09-27 11:59:34 chris Exp $
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
 
30
RTEMS_INLINE_ROUTINE void *_Addresses_Add_offset (
31
  void       *base,
32
  unsigned32  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
 
49
RTEMS_INLINE_ROUTINE void *_Addresses_Subtract_offset (
50
  void       *base,
51
  unsigned32  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 unsigned32 makes this code
67
 *         dependent on an addresses being thirty two bits.
68
 */
69
 
70
RTEMS_INLINE_ROUTINE unsigned32 _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
 
89
RTEMS_INLINE_ROUTINE boolean _Addresses_Is_aligned (
90
  void *address
91
)
92
{
93
    return ( ( (unsigned32)address % CPU_ALIGNMENT ) == 0 );
94
}
95
 
96
/*PAGE
97
 *
98
 *  _Addresses_Is_in_range
99
 *
100
 *  DESCRIPTION:
101
 *
102
 *  This function returns TRUE if the given address is within the
103
 *  memory range specified and FALSE otherwise.  base is the address
104
 *  of the first byte in the memory range and limit is the address
105
 *  of the last byte in the memory range.  The base address is
106
 *  assumed to be lower than the limit address.
107
 */
108
 
109
RTEMS_INLINE_ROUTINE boolean _Addresses_Is_in_range (
110
  void *address,
111
  void *base,
112
  void *limit
113
)
114
{
115
  return ( address >= base && address <= limit );
116
}
117
 
118
#endif
119
/* end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.