RTEMS  5.0.0
address.h
Go to the documentation of this file.
1 
10 /*
11  * COPYRIGHT (c) 1989-2006.
12  * On-Line Applications Research Corporation (OAR).
13  *
14  * The license and distribution terms for this file may be
15  * found in the file LICENSE in this distribution or at
16  * http://www.rtems.org/license/LICENSE.
17  */
18 
19 #ifndef _RTEMS_SCORE_ADDRESS_H
20 #define _RTEMS_SCORE_ADDRESS_H
21 
22 #include <rtems/score/cpu.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
51  const void *base,
52  uintptr_t offset
53 )
54 {
55  return (void *)((uintptr_t)base + offset);
56 }
57 
72  const void *base,
73  uintptr_t offset
74 )
75 {
76  return (void *)((uintptr_t)base - offset);
77 }
78 
91  const void *left,
92  const void *right
93 )
94 {
95  return (intptr_t) ( (const char *) left - (const char *) right );
96 }
97 
111  const void *address
112 )
113 {
114  return ( (uintptr_t) address % CPU_ALIGNMENT ) == 0;
115 }
116 
134  const void *address,
135  const void *base,
136  const void *limit
137 )
138 {
139  return (address >= base && address <= limit);
140 }
141 
156  void *address,
157  size_t alignment
158 )
159 {
160  uintptr_t mask = alignment - (uintptr_t)1;
161  return (void*)(((uintptr_t)address + mask) & ~mask);
162 }
163 
178  void *address,
179  size_t alignment
180 )
181 {
182  uintptr_t mask = alignment - (uintptr_t)1;
183  return (void*)((uintptr_t)address & ~mask);
184 }
185 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif
193 /* end of include file */
RTEMS_INLINE_ROUTINE intptr_t _Addresses_Subtract(const void *left, const void *right)
Subtract two addresses.
Definition: address.h:90
RTEMS_INLINE_ROUTINE void * _Addresses_Subtract_offset(const void *base, uintptr_t offset)
Subtract offset from offset.
Definition: address.h:71
RTEMS_INLINE_ROUTINE void * _Addresses_Align_down(void *address, size_t alignment)
Align address to nearest multiple of alignment, truncating.
Definition: address.h:177
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
RTEMS_INLINE_ROUTINE void * _Addresses_Add_offset(const void *base, uintptr_t offset)
Add offset to an address.
Definition: address.h:50
RTEMS_INLINE_ROUTINE bool _Addresses_Is_aligned(const void *address)
Is address aligned.
Definition: address.h:110
RTEMS_INLINE_ROUTINE void * _Addresses_Align_up(void *address, size_t alignment)
Align address to nearest multiple of alignment, rounding up.
Definition: address.h:155
RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range(const void *address, const void *base, const void *limit)
Is address in range.
Definition: address.h:133