macro LFDS711_STACK_GET_VALUE_FROM_ELEMENT
Jump to navigation
Jump to search
Source Files
└───liblfds711 └───inc └───liblfds711 lfds711_stack.h
Opaque Structures
struct lfds711_stack_element;
Macro
#define LFDS711_STACK_GET_VALUE_FROM_ELEMENT( stack_element )
Parameters
stack_element
- A struct lfds711_stack_element. Not a pointer to it - the struct itself.
Return Value
Returns a void pointer, the value from the element.
Notes
The value set into a stack element is only guranteed to be visible to another logical core once the element has been popped by a thread running on that logical core.
So, for example, if there was a globally allocated stack element, where a thread on logical core A set a value nd then pushed the element to the stack, a thread on logical core B would only be guaranteed to see the value set by the other thread once it pops the element from the stack.
As with all liblfds macros, the macro operates on the structure itself, not a pointer to it.
Example
#include <stdio.h> #include "liblfds711.h" int main() { char stack_element_name[64] = "Legion", *stack_element_name_temp; struct lfds711_misc_prng_state ps; struct lfds711_stack_element se, *se_temp; struct lfds711_stack_state ss; lfds711_misc_library_init_valid_on_current_logical_core(); lfds711_misc_prng_init( &ps ); lfds711_stack_init_valid_on_current_logical_core( &ss, NULL ); LFDS711_STACK_SET_VALUE_IN_ELEMENT( &se, (void *) stack_element_name ); lfds711_stack_push( &ss, &se, &ps ); lfds711_stack_pop( &ss, &se_temp, &ps ); stack_element_name_temp = (char *) LFDS711_STACK_GET_VALUE_FROM_ELEMENT( *ss_temp ); printf( "stack element name is \"%s\"\n", (char *) stack_element_name_temp ); lfds711_stack_cleanup( &ss, NULL ); lfds711_misc_library_cleanup(); return( EXIT_SUCCESS ); }