RTEMS CPU Kit with SuperCore  4.11.2
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 
94  const void *left,
95  const void *right
96 )
97 {
98  return (int32_t) ((const char *) left - (const char *) right);
99 }
100 
114  const void *address
115 )
116 {
117 #if (CPU_ALIGNMENT == 0)
118  return true;
119 #else
120  return (((uintptr_t)address % CPU_ALIGNMENT) == 0);
121 #endif
122 }
123 
141  const void *address,
142  const void *base,
143  const void *limit
144 )
145 {
146  return (address >= base && address <= limit);
147 }
148 
163  void *address,
164  size_t alignment
165 )
166 {
167  uintptr_t mask = alignment - (uintptr_t)1;
168  return (void*)(((uintptr_t)address + mask) & ~mask);
169 }
170 
185  void *address,
186  size_t alignment
187 )
188 {
189  uintptr_t mask = alignment - (uintptr_t)1;
190  return (void*)((uintptr_t)address & ~mask);
191 }
192 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif
200 /* end of include file */
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:184
RTEMS_INLINE_ROUTINE int32_t _Addresses_Subtract(const void *left, const void *right)
Subtract two offsets.
Definition: address.h:93
#define RTEMS_INLINE_ROUTINE
The following (in conjunction with compiler arguments) are used to choose between the use of static i...
Definition: basedefs.h:135
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:113
RTEMS_INLINE_ROUTINE void * _Addresses_Align_up(void *address, size_t alignment)
Align address to nearest multiple of alignment, rounding up.
Definition: address.h:162
RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range(const void *address, const void *base, const void *limit)
Is address in range.
Definition: address.h:140