MentOS  0.8.0
The Mentoring Operating System
Macros
stack_helper.h File Reference

Couple of macros that help accessing the stack. More...

Go to the source code of this file.

Macros

#define __ACCESS_PTR(type, ptr)   (*(type *)(ptr))
 Access the value of the pointer.
 
#define __MOVE_PTR_DOWN(type, ptr)   ((ptr) -= sizeof(type))
 Moves the pointer down.
 
#define __MOVE_PTR_UP(type, ptr)   ((ptr) += sizeof(type))
 Moves the pointer up.
 
#define PUSH_VALUE_ON_STACK(ptr, value)   (__ACCESS_PTR(__typeof__(value), __MOVE_PTR_DOWN(__typeof__(value), ptr)) = (value))
 First, it moves the pointer down, and then it pushes the value at that memory location.
 
#define POP_VALUE_FROM_STACK(value, ptr)   ({value = __ACCESS_PTR(__typeof__(value), ptr); __MOVE_PTR_UP(__typeof__(value), ptr); })
 First, it access the value at the given memory location, and then it moves the pointer up.
 

Detailed Description

Couple of macros that help accessing the stack.