RTEMS: cpukit/include/rtems/score/address.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
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
27extern "C" {
28#endif
29
55 RTEMS_INLINE_ROUTINE void *_Addresses_Add_offset (
56 const void *base,
57 uintptr_t offset
58)
59{
60 return (void *)((uintptr_t)base + offset);
61}
62
76 RTEMS_INLINE_ROUTINE void *_Addresses_Subtract_offset (
77 const void *base,
78 uintptr_t offset
79)
80{
81 return (void *)((uintptr_t)base - offset);
82}
83
95 RTEMS_INLINE_ROUTINE intptr_t _Addresses_Subtract(
96 const void *left,
97 const void *right
98)
99{
100 return (intptr_t) ( (const char *) left - (const char *) right );
101}
102
115 RTEMS_INLINE_ROUTINE bool _Addresses_Is_aligned(
116 const void *address
117)
118{
119 return ( (uintptr_t) address % CPU_ALIGNMENT ) == 0;
120}
121
138 RTEMS_INLINE_ROUTINE bool _Addresses_Is_in_range (
139 const void *address,
140 const void *base,
141 const void *limit
142)
143{
144 return (address >= base && address <= limit);
145}
146
160 RTEMS_INLINE_ROUTINE void *_Addresses_Align_up(
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
182 RTEMS_INLINE_ROUTINE void *_Addresses_Align_down(
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 */
_Addresses_Subtract_offset
RTEMS_INLINE_ROUTINE void * _Addresses_Subtract_offset(const void *base, uintptr_t offset)
Subtracts offset from an address.
Definition: address.h:76
_Addresses_Add_offset
RTEMS_INLINE_ROUTINE void * _Addresses_Add_offset(const void *base, uintptr_t offset)
Adds offset to an address.
Definition: address.h:55
_Addresses_Subtract
RTEMS_INLINE_ROUTINE intptr_t _Addresses_Subtract(const void *left, const void *right)
Subtracts two addresses.
Definition: address.h:95
_Addresses_Align_down
RTEMS_INLINE_ROUTINE void * _Addresses_Align_down(void *address, size_t alignment)
Aligns address to nearest multiple of alignment, truncating.
Definition: address.h:182
_Addresses_Is_in_range
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
_Addresses_Is_aligned
RTEMS_INLINE_ROUTINE bool _Addresses_Is_aligned(const void *address)
Checks if address is aligned.
Definition: address.h:115
_Addresses_Align_up
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
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66