function lfds700_freelist_init_valid_on_current_logical_core

From liblfds.org
Jump to navigation Jump to search

Source Files

└───liblfds700
    ├───inc
    │   └───liblfds700
    │           lfds700_freelist.h
    └───src
        └───lfds700_stack
                lfds700_freelist_init.c

Opaque Structures

struct lfds700_freelist_state;

Prototype

void lfds700_freelist_init_valid_on_current_logical_core( struct lfds700_freelist_state *fs, void *user_state );

Parameters

struct lfds700_freelist_state *fs

A pointer to a user-allocated LFDS700_PAL_ATOMIC_ISOLATION_IN_BYTES aligned struct lfds700_freelist_state. Stack declared variables will automatically be correctly aligned by the compiler, due to the information in the structure definitions; nothing has to be done. Heap allocated variables however will by no means be correctly aligned and an aligned malloc must be used.

void *user_state

A void pointer for arbitrary user state. This is stored in the freelist state and can be retrieved later at any time from the stack state using the LFDS700_FREELIST_GET_USER_STATE_FROM_STATE macro, in particular in callbacks, when they receive the freelist state as one of their arguments.

Notes

As the function name indicates, the initialization work performed on the freelist state is only valid on the current logical core. To make this work valid on other logical cores, threads on other cores must call LFDS700_MISC_MAKE_VALID_ON_CURRENT_LOGICAL_CORE_INITS_COMPLETED_BEFORE_NOW_ON_ANY_OTHER_LOGICAL_CORE.

Example

#include "liblfds700.h"

int main()
{
  struct lfds700_freelist_state
    fs;

  lfds700_misc_library_init_valid_on_current_logical_core();

  lfds700_freelist_init_valid_on_current_logical_core( &fs, NULL );

  lfds700_freelist_cleanup( &fs, NULL );

  lfds700_misc_library_cleanup();

  return( EXIT_SUCCESS );
}

See Also