Simple Virtual Machine A simple but flexible virtual machine

Loading...
Searching...
No Matches
Functions
SVM memory pointers
SVM memories

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

## Functions
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.
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_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.
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.
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.
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.

## 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | pointer | The 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

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | pointer | The memory zone to build.

Returns
  The memory zone under the pointer.

Exceptions

  MEMORY | interruption when a memory address inside the pointer is not defined.
  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | pointer | The memory zone to check.

Returns
  TRUE when at least an alias has an address in common with the pointer, FALSE otherwise.

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | pointer | The 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_memory_scope_set_local_alias(svm,kernel,*alias);
}
}
SVM_Value_String
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:549
SVM_Value_Pointer
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:571
svm_memory_scope_set_local
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_memory_scope_set_local_alias
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_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.
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.

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

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | pointer | The 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
{
svm_memory_scope_set_local_alias(svm,kernel,*alias);
}
}

Exceptions

  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption 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] | svm | The SVM pointer passed as first argument of the callback function.
  [in] | kernel | The kernel in which the targeted memory is.
  [in] | pointer | The memory zone to alter.
  [in] | zone | The types to use.

Note
  The addresses impacted by the function are defined but no longer initialised after this function call.

Exceptions

  MEMORY | interruption when a memory address inside the pointer is not defined.
  FAILURE | interruption when a parameter is incorrect. (Please refer to the main description page of this API.)
  FAILURE | interruption when the kernel is not owned by our process or is not in a process locked by ours.
  FAILURE | interruption 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