Simple Virtual Machine
A simple but flexible virtual machine
SVM memory pointers

This module contains API functions to handle SVM memory pointers. More...

Functions

SVM_FUNCTION SVM_Value_Pointersvm_memory_pointer_list_accessible (const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
 This function extracts all memory zones recursively accessible from a pointer in a memory. More...
 
SVM_FUNCTION SVM_Value_Stringsvm_memory_pointer_list_alias (const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
 This function extracts all alias having their pointer within a memory zone. More...
 
SVM_FUNCTION SVM_Value_Stringsvm_memory_pointer_expand_alias (const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
 This function extracts all alias having their pointer intersecting with a memory zone. More...
 
SVM_FUNCTION SVM_Boolean svm_memory_pointer_has_alias (const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
 This function checks whether an alias pointer has an intersection with a memory zone. More...
 
SVM_FUNCTION SVM_Memory_Zone svm_memory_pointer_get_zone (const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
 This function creates a memory zone corresponding to the pointer. More...
 
SVM_FUNCTION void svm_memory_pointer_set_zone (const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer, const SVM_Memory_Zone zone)
 This function changes the memory under the pointer to the types of the zone. More...
 

Detailed Description

This module contains API functions to handle SVM memory pointers.

Function Documentation

◆ svm_memory_pointer_expand_alias()

SVM_FUNCTION SVM_Value_String * svm_memory_pointer_expand_alias ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Value_Pointer  pointer 
)

This function extracts all alias having their pointer intersecting with a memory zone.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]pointerThe memory zone to check.

The returned alias have their pointer intersecting in the given memory zone. Each returned alias has at least one address in common with the input pointer, but can have adresses outside the input pointer.

Returns
A NULL terminated array of string values containing the aliases.
Note
The returned array is a valid SVM variable: its scope can be changed if needed, and the pointer shall not be freed explicitely.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_memory_pointer_get_zone()

SVM_FUNCTION SVM_Memory_Zone svm_memory_pointer_get_zone ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Value_Pointer  pointer 
)

This function creates a memory zone corresponding to the pointer.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]pointerThe memory zone to build.
Returns
The memory zone under the pointer.
Exceptions
MEMORYinterruption when a memory address inside the pointer is not defined.
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current
svm_memory_zone_new
svm_memory_allocate

◆ svm_memory_pointer_has_alias()

SVM_FUNCTION SVM_Boolean svm_memory_pointer_has_alias ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Value_Pointer  pointer 
)

This function checks whether an alias pointer has an intersection with a memory zone.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]pointerThe memory zone to check.
Returns
TRUE when at least an alias has an address in common with the pointer, FALSE otherwise.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current
svm_memory_pointer_expand_alias

◆ svm_memory_pointer_list_accessible()

SVM_FUNCTION SVM_Value_Pointer * svm_memory_pointer_list_accessible ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Value_Pointer  pointer 
)

This function extracts all memory zones recursively accessible from a pointer in a memory.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]pointerThe pointer locating the first memory zone.
Note
The returned values are optimised out: the memory zones graph is flatten and contiguous zones are merged to ensure every address is represented only once in the result.
The input pointer is always placed on the first element of the reply regardless the merge of the accessible zones.

Usage example:

SVM_Value_Pointer *pointer = svm_memory_pointer_list_accessible(svm,kernel,initial_pointer);
for( ; *pointer ; ++pointer) // we don't need to keep pointer on the first pointer
{
svm_memory_scope_set_local(svm,kernel,*pointer);
SVM_Value_String *alias = svm_memory_pointer_list_alias(svm,kernel,*pointer);
for( ; *alias ; ++alias) // we don't need to keep alias on the first alias
{
}
}
SVM_TYPE typedef const void * SVM_Value_String
This type is used to represent a string the SVM can store in one of its memories.
Definition: svm.h:548
SVM_TYPE typedef const void * SVM_Value_Pointer
This type is used to represent a pointer the SVM can store in one of its memories.
Definition: svm.h:570
SVM_FUNCTION void svm_memory_scope_set_local(const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
This function changes the scope of a memory zone.
SVM_FUNCTION void svm_memory_scope_set_local_alias(const void *svm, const SVM_Kernel kernel, const SVM_Value_String alias)
This function changes the scope of a memory alias from a string value.
SVM_FUNCTION SVM_Value_String * svm_memory_pointer_list_alias(const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
This function extracts all alias having their pointer within a memory zone.
SVM_FUNCTION SVM_Value_Pointer * svm_memory_pointer_list_accessible(const void *svm, const SVM_Kernel kernel, const SVM_Value_Pointer pointer)
This function extracts all memory zones recursively accessible from a pointer in a memory.
Returns
A NULL terminated array of pointer values locating all accessible memory.
Note
The returned array is a valid SVM variable: its scope can be changed if needed, and the pointer shall not be freed explicitely.
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_memory_pointer_list_alias()

SVM_FUNCTION SVM_Value_String * svm_memory_pointer_list_alias ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Value_Pointer  pointer 
)

This function extracts all alias having their pointer within a memory zone.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]pointerThe memory zone to check.

The returned alias have their pointer included in the given memory zone. If an alias has at least one address outside this zone, it will not be retrieved by this API function.

Returns
A NULL terminated array of string values containing the aliases.
Note
The returned array is a valid SVM variable: its scope can be changed if needed, and the pointer shall not be freed explicitely.

Usage example:

SVM_Value_Pointer *pointer = svm_memory_pointer_list_accessible(svm,kernel,initial_pointer);
for( ; *pointer ; ++pointer) // we don't need to keep pointer on the first pointer
{
svm_memory_scope_set_local(svm,kernel,*pointer);
SVM_Value_String *alias = svm_memory_pointer_list_alias(svm,kernel,*pointer);
for( ; *alias ; ++alias) // we don't need to keep alias on the first alias
{
}
}
Exceptions
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
See also
svm_process_ownership_lock
svm_kernel_get_current

◆ svm_memory_pointer_set_zone()

SVM_FUNCTION void svm_memory_pointer_set_zone ( const void *  svm,
const SVM_Kernel  kernel,
const SVM_Value_Pointer  pointer,
const SVM_Memory_Zone  zone 
)

This function changes the memory under the pointer to the types of the zone.

Parameters
[in]svmThe SVM pointer passed as first argument of the callback function.
[in]kernelThe kernel in which the targeted memory is.
[in]pointerThe memory zone to alter.
[in]zoneThe types to use.
Note
The addresses impacted by the function are defined but no longer initialised after this function call.
Exceptions
MEMORYinterruption when a memory address inside the pointer is not defined.
FAILUREinterruption when a parameter is incorrect. (Please refer to the main description page of this API.)
FAILUREinterruption when the kernel is not owned by our process or is not in a process locked by ours.
FAILUREinterruption when the zone and the pointer have different sizes.
See also
svm_process_ownership_lock
svm_kernel_get_current
svm_memory_zone_new
svm_memory_allocate