RTEMS  5.1
address.h
Go to the documentation of this file.
1 
12 /*
13  * COPYRIGHT (c) 1989-2006.
14  * On-Line Applications Research Corporation (OAR).
15  *
16  * The license and distribution terms for this file may be
17  * found in the file LICENSE in this distribution or at
18  * http://www.rtems.org/license/LICENSE.
19  */
20 
21 #ifndef _RTEMS_SCORE_ADDRESS_H
22 #define _RTEMS_SCORE_ADDRESS_H
23 
24 #include <rtems/score/cpu.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
56  const void *base,
57  uintptr_t offset
58 )
59 {
60  return (void *)((uintptr_t)base + offset);
61 }
62 
77  const void *base,
78  uintptr_t offset
79 )
80 {
81  return (void *)((uintptr_t)base - offset);
82 }
83 
96  const void *left,
97  const void *right
98 )
99 {
100  return (intptr_t) ( (const char *) left - (const char *) right );
101 }
102 
116  const void *address
117 )
118 {
119  return ( (uintptr_t) address % CPU_ALIGNMENT ) == 0;
120 }
121 
139  const void *address,
140  const void *base,
141  const void *limit
142 )
143 {
144  return (address >= base && address <= limit);
145 }
146 
161  void *address,
162  size_t alignment
163 )
164 {
165  uintptr_t mask = alignment - (uintptr_t)1;
166  return (void*)(((uintptr_t)address + mask) & ~mask);
167 }
168 
183  void *address,
184  size_t alignment
185 )
186 {
187  uintptr_t mask = alignment - (uintptr_t)1;
188  return (void*)((uintptr_t)address & ~mask);
189 }
190 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif
198 /* end of include file */
RTEMS_INLINE_ROUTINE void * _Addresses_Align_down(void *address, size_t alignment)
Aligns address to nearest multiple of alignment, truncating.
Definition: address.h:182
RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range(const void *address, const void *base, const void *limit)
Checks if address is in range.
Definition: address.h:138
RTEMS_INLINE_ROUTINE intptr_t _Addresses_Subtract(const void *left, const void *right)
Subtracts two addresses.
Definition: address.h:95
RTEMS_INLINE_ROUTINE void * _Addresses_Subtract_offset(const void *base, uintptr_t offset)
Subtracts offset from an address.
Definition: address.h:76
RTEMS_INLINE_ROUTINE void * _Addresses_Align_up(void *address, size_t alignment)
Aligns address to nearest multiple of alignment, rounding up.
Definition: address.h:160
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE bool _Addresses_Is_aligned(const void *address)
Checks if address is aligned.
Definition: address.h:115
RTEMS_INLINE_ROUTINE void * _Addresses_Add_offset(const void *base, uintptr_t offset)
Adds offset to an address.
Definition: address.h:55