NewMadeleine

Documentation

« back to PM2 home.
nm_data.h File Reference

High-level data manipulation through iterators. More...

#include <assert.h>
#include <string.h>
#include <Padico/Puk.h>
#include <nm_config.h>
Include dependency graph for nm_data.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  nm_data_generator_s
 state of a data generator More...
 
struct  nm_data_chunk_s
 chunk of data returned by generators More...
 
struct  nm_data_properties_s
 block of static properties for a given data descriptor More...
 
struct  nm_data_ops_s
 set of operations available on data type. More...
 
struct  nm_data_s
 a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers More...
 
struct  nm_datav_s
 encapsulate a dynamic vector of nm_data More...
 
struct  nm_data_null_s
 data descriptor for 'null' data More...
 
struct  nm_data_contiguous_s
 data descriptor for contiguous data More...
 
struct  nm_data_iov_s
 data descriptor for iov data (embedd iovec in nm_data) More...
 
struct  nm_data_datav_s
 data descriptor for datav in a nm_data (embedd a vector of nm_data in nm_data) More...
 
struct  nm_data_excerpt_s
 data as an excerpt of another data. More...
 
struct  nm_data_slicer_s
 internal state of a data slicer. More...
 

Macros

#define _NM_DATA_CONTENT_SIZE   64
 maximum size of content descriptor for nm_data
 
#define _NM_DATA_GENERATOR_SIZE   64
 maximum content size for generators
 
#define NM_DATA_USE_COROUTINE_GENERATOR
 whether to use coroutine-based generators
 
#define NM_DATA_USE_COROUTINE_SLICER
 whether to use coroutine-based slicers
 
#define NM_DATA_CHUNK_NULL   ((struct nm_data_chunk_s){ .ptr = NULL, .len = 0 })
 
#define nm_data_generator_default_init   &nm_data_generator_coroutine_init
 
#define nm_data_generator_default_next   &nm_data_generator_coroutine_next
 
#define nm_data_generator_default_destroy   &nm_data_generator_coroutine_destroy
 
#define NM_DATA_TYPE(ENAME, CONTENT_TYPE, OPS)
 macro to generate typed functions to init/access data fields.
 
#define NM_DATAV_INIT_SIZE   4
 initial size of an nm_datav
 
#define NM_DATA_SLICER_NULL   ((struct nm_data_slicer_s){ .kind = NM_DATA_SLICER_NONE })
 a slicer attached to no data
 

Typedefs

typedef void(* nm_data_apply_t) (void *ptr, nm_len_t len, void *_context)
 function to apply to each data chunk upon traversal
 
typedef void(* nm_data_traversal_t) (const void *_content, const nm_data_apply_t apply, void *_context)
 funtion to traverse data with app layout, i.e.
 
typedef void(* nm_data_generator_init_t) (const struct nm_data_s *p_data, void *_generator)
 initializes a generator (i.e.
 
typedef struct nm_data_chunk_s(* nm_data_generator_next_t) (const struct nm_data_s *p_data, void *_generator)
 returns next data chunk for the given generator.
 
typedef void(* nm_data_generator_destroy_t) (const struct nm_data_s *p_data, void *_generator)
 destroys resources allocated by generator
 
typedef void(* nm_data_properties_compute_t) (struct nm_data_s *p_data)
 function to compute data properties
 
typedef struct nm_data_slicer_s nm_data_slicer_t
 internal state of a data slicer.
 
typedef enum nm_data_slicer_op_e nm_data_slicer_op_t
 

Enumerations

enum  nm_data_slicer_kind_t { NM_DATA_SLICER_NONE = 0 , NM_DATA_SLICER_GENERATOR , NM_DATA_SLICER_COROUTINE , NM_DATA_SLICER_UCONTEXT }
 various kinds of slicer implementations More...
 
enum  nm_data_slicer_op_e { NM_SLICER_OP_NONE = 0 , NM_SLICER_OP_FORWARD , NM_SLICER_OP_COPY_FROM , NM_SLICER_OP_COPY_TO }
 

Functions

static int nm_data_chunk_isnull (const struct nm_data_chunk_s *p_chunk)
 
void nm_data_generator_coroutine_init (const struct nm_data_s *p_data, void *_generator)
 
struct nm_data_chunk_s nm_data_generator_coroutine_next (const struct nm_data_s *p_data, void *_generator)
 
void nm_data_generator_coroutine_destroy (const struct nm_data_s *p_data, void *_generator)
 
void nm_data_generator_generic_init (const struct nm_data_s *p_data, void *_generator)
 
struct nm_data_chunk_s nm_data_generator_generic_next (const struct nm_data_s *p_data, void *_generator)
 
void nm_data_default_properties_compute (struct nm_data_s *p_data)
 
static void nm_data_propertie_gpu_preinit (struct nm_data_properties_s *p_props)
 pre-init GPU part of data properties
 
static void nm_data_propertie_gpu_postinit (const struct nm_data_properties_s *p_props)
 post-init GPU part of data properties: check that p_properties_compute function actually filled the GPU part.
 
static void nm_datav_init (struct nm_datav_s *p_datav)
 initialize a datav
 
static void nm_datav_destroy (struct nm_datav_s *p_datav)
 destroys a datav
 
static void nm_datav_add_chunk_data (struct nm_datav_s *p_datav, const struct nm_data_s *p_data)
 add a chunk of data to datav; given p_data content is copied.
 
static void nm_datav_add_chunk (struct nm_datav_s *p_datav, const void *ptr, nm_len_t len)
 add a chunk of contiguous data to a datav
 
static nm_len_t nm_datav_size (struct nm_datav_s *p_datav)
 get the size (number of bytes) of data contained in the datav
 
static void nm_datav_uncommit (struct nm_datav_s *p_datav)
 'uncommit' a datav: explicitely declare that nm_data pointing to this datav has been destroyed.
 
static void nm_data_null_set (struct nm_data_s *p_data, struct nm_data_null_s value)
 
static struct nm_data_null_snm_data_null_content (const struct nm_data_s *p_data)
 
static void nm_data_null_build (struct nm_data_s *p_data)
 
static int nm_data_isnull (struct nm_data_s *p_data)
 
static void nm_data_contiguous_set (struct nm_data_s *p_data, struct nm_data_contiguous_s value)
 
static struct nm_data_contiguous_snm_data_contiguous_content (const struct nm_data_s *p_data)
 
static void nm_data_contiguous_build (struct nm_data_s *p_data, void *ptr, nm_len_t len)
 
static void nm_data_iov_set (struct nm_data_s *p_data, struct nm_data_iov_s value)
 
static struct nm_data_iov_snm_data_iov_content (const struct nm_data_s *p_data)
 
static void nm_data_iov_build (struct nm_data_s *p_data, const struct iovec *v, int n)
 
static void nm_data_datav_set (struct nm_data_s *p_data, struct nm_data_datav_s value)
 
static struct nm_data_datav_snm_data_datav_content (const struct nm_data_s *p_data)
 
static void nm_data_datav_build (struct nm_data_s *p_datav_data, struct nm_datav_s *p_datav)
 frontend to build a nm_data from a datav
 
static void nm_data_excerpt_set (struct nm_data_s *p_data, struct nm_data_excerpt_s value)
 
static struct nm_data_excerpt_snm_data_excerpt_content (const struct nm_data_s *p_data)
 
static void nm_data_excerpt_build (struct nm_data_s *p_data, struct nm_data_s *p_inner_data, nm_len_t chunk_offset, nm_len_t chunk_len)
 build a data descriptor as an excerpt of another data.
 
static void nm_data_traversal_apply (const struct nm_data_s *p_data, nm_data_apply_t apply, void *_context)
 helper function to apply iterator to data
 
static void nm_data_generator_init (const struct nm_data_s *p_data, struct nm_data_generator_s *p_generator)
 build a new generator for the given data type
 
static struct nm_data_chunk_s nm_data_generator_next (struct nm_data_generator_s *p_generator)
 get the next chunk of data
 
static void nm_data_generator_destroy (struct nm_data_generator_s *p_generator)
 destroy the generator after use
 
void nm_data_chunk_extractor_traversal (const struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len, nm_data_apply_t apply, void *_context)
 
void nm_data_aggregator_traversal (const struct nm_data_s *p_data, nm_data_apply_t apply, void *_context)
 
static const struct nm_data_properties_snm_data_properties_get (const struct nm_data_s *p_data)
 returns the properties block for the data
 
static nm_len_t nm_data_size (const struct nm_data_s *p_data)
 returns the amount of data contained in the descriptor
 
void * nm_data_baseptr_get (const struct nm_data_s *p_data)
 find base pointer for a data known to be contiguous
 
void * nm_data_chunk_baseptr_get (const struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len)
 find base pointer for a data chunk known to be contiguous
 
void nm_data_chunk_properties_compute (const struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len, struct nm_data_properties_s *p_props)
 compute properties of the given chunk inside the data
 
uint32_t nm_data_checksum (const struct nm_data_s *p_data)
 checksum data

 
void nm_data_copy_from (const struct nm_data_s *p_data, nm_len_t offset, nm_len_t len, void *destbuf)
 copy chunk of data from user layout to contiguous buffer
 
void nm_data_copy_to (const struct nm_data_s *p_data, nm_len_t offset, nm_len_t len, const void *srcbuf)
 copy chunk of data from contiguous buffer to user layout
 
void nm_data_copy (struct nm_data_s *p_dest, struct nm_data_s *p_from)
 copy from nm_data to another nm_data
 
static int nm_data_slicer_isnull (const nm_data_slicer_t *p_slicer)
 tests whether a slicer is null
 
void nm_data_slicer_coroutine_init (nm_data_slicer_t *p_slicer, const struct nm_data_s *p_data)
 
void nm_data_slicer_coroutine_op (nm_data_slicer_t *p_slicer, void *ptr, nm_len_t len, nm_data_slicer_op_t op)
 
void nm_data_slicer_coroutine_destroy (nm_data_slicer_t *p_slicer)
 
void nm_data_slicer_generator_init (nm_data_slicer_t *p_slicer, const struct nm_data_s *p_data)
 
void nm_data_slicer_generator_op (nm_data_slicer_t *p_slicer, void *ptr, nm_len_t slice_len, nm_data_slicer_op_t op)
 
void nm_data_slicer_generator_destroy (nm_data_slicer_t *p_slicer)
 
void nm_data_slicer_ucontext_init (nm_data_slicer_t *p_slicer, const struct nm_data_s *p_data)
 
void nm_data_slicer_ucontext_op (nm_data_slicer_t *p_slicer, void *ptr, nm_len_t len, nm_data_slicer_op_t op)
 
void nm_data_slicer_ucontext_destroy (nm_data_slicer_t *p_slicer)
 
void nm_data_slicer_init (nm_data_slicer_t *p_slicer, const struct nm_data_s *p_data)
 
void nm_data_slicer_op (nm_data_slicer_t *p_slicer, void *ptr, nm_len_t len, nm_data_slicer_op_t op)
 
void nm_data_slicer_copy_from (nm_data_slicer_t *p_slicer, void *dest_ptr, nm_len_t slice_len)
 
void nm_data_slicer_copy_to (nm_data_slicer_t *p_slicer, const void *src_ptr, nm_len_t slice_len)
 
void nm_data_slicer_forward (nm_data_slicer_t *p_slicer, nm_len_t offset)
 
void nm_data_slicer_destroy (nm_data_slicer_t *p_slicer)
 

Variables

const struct nm_data_ops_s nm_data_ops_null
 
const struct nm_data_ops_s nm_data_ops_contiguous
 
const struct nm_data_ops_s nm_data_ops_iov
 
const struct nm_data_ops_s nm_data_ops_datav
 
const struct nm_data_ops_s nm_data_ops_excerpt
 

Detailed Description

High-level data manipulation through iterators.

Definition in file nm_data.h.

Function Documentation

◆ nm_data_contiguous_build()

static void nm_data_contiguous_build ( struct nm_data_s p_data,
void *  ptr,
nm_len_t  len 
)
inlinestatic

◆ nm_data_contiguous_content()

static struct nm_data_contiguous_s * nm_data_contiguous_content ( const struct nm_data_s p_data)
inlinestatic

Definition at line 353 of file nm_data.h.

◆ nm_data_contiguous_set()

static void nm_data_contiguous_set ( struct nm_data_s p_data,
struct nm_data_contiguous_s  value 
)
inlinestatic

Definition at line 353 of file nm_data.h.

Referenced by nm_data_contiguous_build().

◆ nm_data_datav_build()

static void nm_data_datav_build ( struct nm_data_s p_datav_data,
struct nm_datav_s p_datav 
)
inlinestatic

frontend to build a nm_data from a datav

Definition at line 393 of file nm_data.h.

References nm_datav_s::commited, nm_data_datav_set(), and nm_data_datav_s::p_datav.

Referenced by nm_rpc_recv_header_data().

Here is the call graph for this function:

◆ nm_data_datav_content()

static struct nm_data_datav_s * nm_data_datav_content ( const struct nm_data_s p_data)
inlinestatic

Definition at line 390 of file nm_data.h.

◆ nm_data_datav_set()

static void nm_data_datav_set ( struct nm_data_s p_data,
struct nm_data_datav_s  value 
)
inlinestatic

Definition at line 390 of file nm_data.h.

Referenced by nm_data_datav_build().

◆ nm_data_excerpt_build()

static void nm_data_excerpt_build ( struct nm_data_s p_data,
struct nm_data_s p_inner_data,
nm_len_t  chunk_offset,
nm_len_t  chunk_len 
)
inlinestatic

build a data descriptor as an excerpt of another data.

Note
p_inner_data is not copied; it must stay allocated as long as the excerpt

Definition at line 415 of file nm_data.h.

References nm_data_excerpt_s::chunk_len, chunk_len, nm_data_excerpt_s::chunk_offset, chunk_offset, nm_data_excerpt_set(), and nm_data_excerpt_s::p_data.

Here is the call graph for this function:

◆ nm_data_excerpt_content()

static struct nm_data_excerpt_s * nm_data_excerpt_content ( const struct nm_data_s p_data)
inlinestatic

Definition at line 411 of file nm_data.h.

◆ nm_data_excerpt_set()

static void nm_data_excerpt_set ( struct nm_data_s p_data,
struct nm_data_excerpt_s  value 
)
inlinestatic

Definition at line 411 of file nm_data.h.

Referenced by nm_data_excerpt_build().

◆ nm_data_iov_build()

static void nm_data_iov_build ( struct nm_data_s p_data,
const struct iovec *  v,
int  n 
)
inlinestatic

Definition at line 374 of file nm_data.h.

References nm_data_iov_s::n, nm_data_iov_set(), and nm_data_iov_s::v.

Referenced by nm_sr_recv_unpack_iov(), and nm_sr_send_pack_iov().

Here is the call graph for this function:

◆ nm_data_iov_content()

static struct nm_data_iov_s * nm_data_iov_content ( const struct nm_data_s p_data)
inlinestatic

Definition at line 372 of file nm_data.h.

◆ nm_data_iov_set()

static void nm_data_iov_set ( struct nm_data_s p_data,
struct nm_data_iov_s  value 
)
inlinestatic

Definition at line 372 of file nm_data.h.

Referenced by nm_data_iov_build().

◆ nm_data_isnull()

static int nm_data_isnull ( struct nm_data_s p_data)
inlinestatic

Definition at line 339 of file nm_data.h.

References nm_data_ops_null, nm_data_s::ops, and nm_data_ops_s::p_traversal.

◆ nm_data_null_build()

static void nm_data_null_build ( struct nm_data_s p_data)
inlinestatic

Definition at line 334 of file nm_data.h.

References nm_data_null_set().

Here is the call graph for this function:

◆ nm_data_null_content()

static struct nm_data_null_s * nm_data_null_content ( const struct nm_data_s p_data)
inlinestatic

Definition at line 333 of file nm_data.h.

◆ nm_data_null_set()

static void nm_data_null_set ( struct nm_data_s p_data,
struct nm_data_null_s  value 
)
inlinestatic

Definition at line 333 of file nm_data.h.

Referenced by nm_data_null_build().

Variable Documentation

◆ nm_data_ops_contiguous

const struct nm_data_ops_s nm_data_ops_contiguous
extern

◆ nm_data_ops_datav

const struct nm_data_ops_s nm_data_ops_datav
extern

◆ nm_data_ops_excerpt

const struct nm_data_ops_s nm_data_ops_excerpt
extern

◆ nm_data_ops_iov

const struct nm_data_ops_s nm_data_ops_iov
extern

◆ nm_data_ops_null

const struct nm_data_ops_s nm_data_ops_null
extern

Referenced by nm_data_isnull().