Skip to content

Commit

Permalink
Rename VMA_ back to VM_ArgPtr (issue #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnz committed Sep 22, 2018
1 parent 5d4732e commit a18c027
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/vm/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ void VM_Free(vm_t* vm)
Com_Memset(vm, 0, sizeof(*vm));
}

void* VMA_(intptr_t vmAddr, vm_t* vm)
void* VM_ArgPtr(intptr_t vmAddr, vm_t* vm)
{
if (!vmAddr)
{
Expand Down
14 changes: 7 additions & 7 deletions src/vm/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
#define Com_Memcpy memcpy

/** Translate from virtual machine memory to real machine memory. */
#define VMA(x, vm) VMA_(args[x], vm)
#define VMA(x, vm) VM_ArgPtr(args[x], vm)

/** Get float argument in syscall (used in system calls) and don't cast it */
/** Get argument in syscall and interpret it bit by bit as IEEE 754 float */
#define VMF(x) VM_IntToFloat(args[x])

/******************************************************************************
Expand Down Expand Up @@ -203,20 +203,20 @@ intptr_t VM_Call(vm_t* vm, int command, ...);
* @param[in] vmAddr Address in virtual machine memory
* @param[in,out] vm Current VM
* @return translated address. */
void* VMA_(intptr_t vmAddr, vm_t* vm);
void* VM_ArgPtr(intptr_t vmAddr, vm_t* vm);

/** Helper function for syscalls VMF(x) macro:
* Get float argument in syscall (used in system calls) and don't cast it.
* E.g. if the VM calls a native function with a float argument: don't
* Get argument in syscall and interpret it bit by bit as IEEE 754 float.
* That is: just put the int in a float/int union and return the float.
* If the VM calls a native function with a float argument: don't
* cast the int argument to a float, but rather interpret it directly
* as a floating point variable.
* @param[in] x Argument on call stack.
* @return Value as float. */
float VM_IntToFloat(int32_t x);

/** Helper function for syscalls:
* Convert a 32-bit floating point variable to an integer variable without
* converting it.
* Just put the float in a float/int union and return the int.
* @param[in] f Floating point number.
* @return Floating point number as integer */
int32_t VM_FloatToInt(float f);
Expand Down
4 changes: 2 additions & 2 deletions test/q3vm_test/q3vm_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ void testArguments(void)
vm.codeLength = 0;
VM_Call(&vm, 0);

VMA_(0, NULL);
VMA_(1, NULL);
VM_ArgPtr(0, NULL);
VM_ArgPtr(1, NULL);
VM_MemoryRangeValid(0, 0, NULL);
loadImage(NULL, &imageSize);
loadImage("invalidpathfoobar", &imageSize);
Expand Down

0 comments on commit a18c027

Please sign in to comment.