Supports extracting and adding bits to pointers. Aligned pointers do not need all bits in their integer representation. This module allows to modify unused bits to encode additional information. For example the type of memory the pointer points to could be encoded.
MemoryPointer | Supports extracting and adding bits to pointers. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file MemoryPointer. |
C-kern/ | Implementation file MemoryPointer impl. |
Types | |
struct ptr_t | Export ptr_t into global namespace. |
Functions | |
test | |
unittest_memory_ptr | Test ptr_t and <ptrf_t> functionality. |
ptr_t | Defines generic pointer type which points to data in memory. |
lifetime | |
ptr_FREE | Static initializer. |
query | |
isaligned_ptr | Returns true if all nrbits least significant bits of ptr are zero. |
lsbits_ptr | Returns the value of all nrbits least significant bits of ptr. |
update | |
clearlsbits_ptr | Sets all nrbits least significant bits of ptr to zero. |
orlsbits_ptr | The value of all nrbits least significant bits of value are ored into ptr. |
inline implementation | |
Macros | |
clearlsbits_ptr | Implements ptr_t.clearlsbits_ptr. |
isaligned_ptr | Implements ptr_t.isaligned_ptr. |
lsbits_ptr | Implements ptr_t.lsbits_ptr. |
orlsbits_ptr | Implements ptr_t.orlsbits_ptr. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2014 Jörg Seebohn
Header file MemoryPointer.
Implementation file MemoryPointer impl.
Export ptr_t into global namespace.
test | |
unittest_memory_ptr | Test ptr_t and <ptrf_t> functionality. |
int unittest_memory_ptr( void )
Test ptr_t and <ptrf_t> functionality.
typedef void * ptr_t
Defines generic pointer type which points to data in memory.
lifetime | |
ptr_FREE | Static initializer. |
query | |
isaligned_ptr | Returns true if all nrbits least significant bits of ptr are zero. |
lsbits_ptr | Returns the value of all nrbits least significant bits of ptr. |
update | |
clearlsbits_ptr | Sets all nrbits least significant bits of ptr to zero. |
orlsbits_ptr | The value of all nrbits least significant bits of value are ored into ptr. |
Macros | |
clearlsbits_ptr | Implements ptr_t.clearlsbits_ptr. |
isaligned_ptr | Implements ptr_t.isaligned_ptr. |
lsbits_ptr | Implements ptr_t.lsbits_ptr. |
orlsbits_ptr | Implements ptr_t.orlsbits_ptr. |
Implements ptr_t.clearlsbits_ptr.
#define isaligned_ptr( ptr, nrbits ) (0 == lsbits_ptr(ptr, nrbits))
Implements ptr_t.isaligned_ptr.
Implements ptr_t.lsbits_ptr.
Implements ptr_t.orlsbits_ptr.
Defines generic pointer type which points to data in memory.
typedef void * ptr_t
Test ptr_t and ptrf_t functionality.
int unittest_memory_ptr( void )
Static initializer.
#define ptr_FREE { 0 }
Returns true if all nrbits least significant bits of ptr are zero.
int isaligned_ptr( const ptr_t ptr, unsigned nrbits )
Returns the value of all nrbits least significant bits of ptr.
int lsbits_ptr( const ptr_t ptr, unsigned nrbits )
Sets all nrbits least significant bits of ptr to zero.
ptr_t clearlsbits_ptr( const ptr_t ptr, unsigned nrbits )
The value of all nrbits least significant bits of value are ored into ptr.
ptr_t orlsbits_ptr( const ptr_t ptr, unsigned nrbits, uintptr_t value )
Implements ptr_t.isaligned_ptr.
#define isaligned_ptr( ptr, nrbits ) (0 == lsbits_ptr(ptr, nrbits))