NewMadeleine

Documentation

« back to PM2 home.
nm_data.h
Go to the documentation of this file.
1/*
2 * NewMadeleine
3 * Copyright (C) 2015-2025 (see AUTHORS file)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULA R PURPOSE. See the GNU
13 * General Public License for more details.
14 */
15
21#ifndef NM_DATA_H
22#define NM_DATA_H
23
24#include <assert.h>
25#include <string.h>
26
27#include <Padico/Puk.h>
28
29#include <nm_config.h>
30
71/* ** Data descriptor ************************************** */
72
74#define _NM_DATA_CONTENT_SIZE 64
76#define _NM_DATA_GENERATOR_SIZE 64
77
78#ifndef __ia64__
79#ifdef _FORTIFY_SOURCE
80#define NM_DATA_USE_UCONTEXT_SLICER
81#else
83#define NM_DATA_USE_COROUTINE_GENERATOR
85#define NM_DATA_USE_COROUTINE_SLICER
86#endif
87#else
88/* setjmp/longjmp is not properly supported on Itanium.
89 * It works ok to unwind on the same stack but not for stack jumping.
90 * (register stack is not saved/restored)
91 */
92#define NM_DATA_USE_UCONTEXT_GENERATOR
93#endif
94
95/* forward declaration so that operators declared inside struct nm_data_s may
96 * take struct nm_data_s* as parameters
97 */
98struct nm_data_s;
99
101typedef void (*nm_data_apply_t)(void*ptr, nm_len_t len, void*_context);
102
108typedef void (*nm_data_traversal_t)(const void*_content, const nm_data_apply_t apply, void*_context);
109
116
118typedef void (*nm_data_generator_init_t)(const struct nm_data_s*p_data, void*_generator);
121{
122 void*ptr;
124};
125#define NM_DATA_CHUNK_NULL ((struct nm_data_chunk_s){ .ptr = NULL, .len = 0 })
126static inline int nm_data_chunk_isnull(const struct nm_data_chunk_s*p_chunk)
127{
128 return (p_chunk->ptr == NULL);
129}
130
135typedef struct nm_data_chunk_s (*nm_data_generator_next_t)(const struct nm_data_s*p_data, void*_generator);
136
138typedef void (*nm_data_generator_destroy_t)(const struct nm_data_s*p_data, void*_generator);
139
141void nm_data_generator_coroutine_init(const struct nm_data_s*p_data, void*_generator);
143struct nm_data_chunk_s nm_data_generator_coroutine_next(const struct nm_data_s*p_data, void*_generator);
145void nm_data_generator_coroutine_destroy(const struct nm_data_s*p_data, void*_generator);
146
148void nm_data_generator_generic_init(const struct nm_data_s*p_data, void*_generator);
150struct nm_data_chunk_s nm_data_generator_generic_next(const struct nm_data_s*p_data, void*_generator);
151
152#ifdef NM_DATA_USE_COROUTINE_GENERATOR
153#define nm_data_generator_default_init &nm_data_generator_coroutine_init
154#define nm_data_generator_default_next &nm_data_generator_coroutine_next
155#define nm_data_generator_default_destroy &nm_data_generator_coroutine_destroy
156#else /* NM_DATA_USE_COROUTINE_GENERATOR */
157#define nm_data_generator_default_init &nm_data_generator_generic_init
158#define nm_data_generator_default_next &nm_data_generator_generic_next
159#define nm_data_generator_default_destroy NULL
160#endif /* NM_DATA_USE_COROUTINE_GENERATOR */
161
164{
168#ifdef NMAD_CUDA
169 int is_cuda;
170#endif /* NMAD_CUDA */
171#ifdef NMAD_HIP
172 int is_hip;
173#endif /* NMAD_HIP */
174};
175
177typedef void (*nm_data_properties_compute_t)(struct nm_data_s*p_data);
178
189
193
201
203static inline void nm_data_propertie_gpu_preinit(struct nm_data_properties_s*p_props)
204{
205 (void) p_props;
206#ifdef NMAD_CUDA
207 p_props->is_cuda = -1;
208#endif /* NMAD_CUDA */
209#ifdef NMAD_HIP
210 p_props->is_hip = -1;
211#endif /* NMAD_HIP */
212}
213
216static inline void nm_data_propertie_gpu_postinit(const struct nm_data_properties_s*p_props)
217{
218 (void) p_props;
219#ifdef NMAD_CUDA
220 if(p_props->is_cuda == -1)
221 {
222 NM_FATAL("incorrect data properties: is_cuda = %d (should be either 0 or 1)\n", p_props->is_cuda);
223 }
224#endif /* NMAD_CUDA */
225#ifdef NMAD_HIP
226 if(p_props->is_hip == -1)
227 {
228 NM_FATAL("incorrect data properties: is_hip = %d (should be either 0 or 1)\n", p_props->is_hip);
229 }
230#endif /* NMAD_HIP */
231}
232
240#define NM_DATA_TYPE(ENAME, CONTENT_TYPE, OPS) \
241 static inline void nm_data_##ENAME##_set(struct nm_data_s*p_data, CONTENT_TYPE value) \
242 { \
243 p_data->ops = *(OPS); \
244 assert(p_data->ops.p_traversal != NULL); \
245 if(p_data->ops.p_properties_compute == NULL) \
246 { \
247 p_data->ops.p_properties_compute = nm_data_default_properties_compute; \
248 } \
249 assert(sizeof(CONTENT_TYPE) <= _NM_DATA_CONTENT_SIZE); \
250 CONTENT_TYPE*p_content = (CONTENT_TYPE*)&p_data->_content[0]; \
251 *p_content = value; \
252 p_data->props.blocks = -1; \
253 nm_data_propertie_gpu_preinit(&p_data->props); \
254 (*p_data->ops.p_properties_compute)(p_data); \
255 nm_data_propertie_gpu_postinit(&p_data->props); \
256 if(p_data->ops.p_generator_init == NULL) \
257 { \
258 if(p_data->props.is_contig) \
259 { \
260 /* use default generator for contig types- no need to create contexts since we know there is a single chunk */ \
261 p_data->ops.p_generator_init = &nm_data_generator_generic_init; \
262 p_data->ops.p_generator_next = &nm_data_generator_generic_next; \
263 p_data->ops.p_generator_destroy = NULL; \
264 } \
265 else \
266 { \
267 p_data->ops.p_generator_init = nm_data_generator_default_init; \
268 p_data->ops.p_generator_next = nm_data_generator_default_next; \
269 p_data->ops.p_generator_destroy = nm_data_generator_default_destroy; \
270 } \
271 } \
272 } \
273 static inline CONTENT_TYPE*nm_data_##ENAME##_content(const struct nm_data_s*p_data) \
274 { \
275 return (CONTENT_TYPE*)p_data->_content; \
276 }
277
278/* ** datav data (dynamic vector of nm_data)
279 */
280
282#define NM_DATAV_INIT_SIZE 4
283
293
295static inline void nm_datav_init(struct nm_datav_s*p_datav);
297static inline void nm_datav_destroy(struct nm_datav_s*p_datav);
299static inline void nm_datav_add_chunk_data(struct nm_datav_s*p_datav, const struct nm_data_s*p_data);
301static inline void nm_datav_add_chunk(struct nm_datav_s*p_datav, const void*ptr, nm_len_t len);
303static inline nm_len_t nm_datav_size(struct nm_datav_s*p_datav);
306static inline void nm_datav_uncommit(struct nm_datav_s*p_datav);
307
310/* ** Built-in data types ********************************** */
311
329{
330 int dummy;
331};
332extern const struct nm_data_ops_s nm_data_ops_null;
334static inline void nm_data_null_build(struct nm_data_s*p_data)
335{
336 struct nm_data_null_s n = { 0 };
337 nm_data_null_set(p_data, n);
338}
339static inline int nm_data_isnull(struct nm_data_s*p_data)
340{
341 return (p_data->ops.p_traversal == nm_data_ops_null.p_traversal);
342}
343
352extern const struct nm_data_ops_s nm_data_ops_contiguous;
354
355static inline void nm_data_contiguous_build(struct nm_data_s*p_data, void*ptr, nm_len_t len)
356{
357 struct nm_data_contiguous_s dc;
358 dc.ptr = ptr;
359 dc.len = len;
360 nm_data_contiguous_set(p_data, dc);
361}
362
367{
368 const struct iovec*v;
369 int n;
370};
371extern const struct nm_data_ops_s nm_data_ops_iov;
373
374static inline void nm_data_iov_build(struct nm_data_s*p_data, const struct iovec*v, int n)
375{
376 struct nm_data_iov_s di;
377 di.v = v;
378 di.n = n;
379 nm_data_iov_set(p_data, di);
380}
381
386{
388};
389extern const struct nm_data_ops_s nm_data_ops_datav;
391
393static inline void nm_data_datav_build(struct nm_data_s*p_datav_data, struct nm_datav_s*p_datav)
394{
395 p_datav->commited = 1;
396 struct nm_data_datav_s dv;
397 dv.p_datav = p_datav;
398 nm_data_datav_set(p_datav_data, dv);
399}
400
410extern const struct nm_data_ops_s nm_data_ops_excerpt;
412
415static inline void nm_data_excerpt_build(struct nm_data_s*p_data, struct nm_data_s*p_inner_data,
417{
418 struct nm_data_excerpt_s de;
420 de.chunk_len = chunk_len;
421 de.p_data = p_inner_data;
423}
424
425
426/* ** Helper functions ************************************* */
427
440static inline void nm_data_traversal_apply(const struct nm_data_s*p_data, nm_data_apply_t apply, void*_context)
441{
442 assert(p_data->ops.p_traversal != NULL);
443 (*p_data->ops.p_traversal)((void*)p_data->_content, apply, _context);
444}
445
446/* ** helper functions for generator */
447
449static inline void nm_data_generator_init(const struct nm_data_s*p_data, struct nm_data_generator_s*p_generator)
450{
451 assert(p_data->ops.p_generator_init != NULL);
452 p_generator->p_data = p_data;
453 (*p_data->ops.p_generator_init)(p_data, &p_generator->_bytes);
454}
455
457static inline struct nm_data_chunk_s nm_data_generator_next(struct nm_data_generator_s*p_generator)
458{
459 assert(p_generator->p_data->ops.p_generator_next != NULL);
460 const struct nm_data_chunk_s chunk = (*p_generator->p_data->ops.p_generator_next)(p_generator->p_data, &p_generator->_bytes);
461 return chunk;
462}
463
465static inline void nm_data_generator_destroy(struct nm_data_generator_s*p_generator)
466{
467 if(p_generator->p_data->ops.p_generator_destroy)
468 (*p_generator->p_data->ops.p_generator_destroy)(p_generator->p_data, &p_generator->_bytes);
469}
470
472 nm_data_apply_t apply, void*_context);
473
474void nm_data_aggregator_traversal(const struct nm_data_s*p_data, nm_data_apply_t apply, void*_context);
475
477static inline const struct nm_data_properties_s*nm_data_properties_get(const struct nm_data_s*p_data)
478{
479 return &p_data->props;
480}
481
483static inline nm_len_t nm_data_size(const struct nm_data_s*p_data)
484{
485 const struct nm_data_properties_s*p_props = nm_data_properties_get((struct nm_data_s*)p_data);
486 return p_props->size;
487}
488
490void*nm_data_baseptr_get(const struct nm_data_s*p_data);
491
494
497 struct nm_data_properties_s*p_props);
498
500uint32_t nm_data_checksum(const struct nm_data_s*p_data);
501
503void nm_data_copy_from(const struct nm_data_s*p_data, nm_len_t offset, nm_len_t len, void*destbuf);
504
506void nm_data_copy_to(const struct nm_data_s*p_data, nm_len_t offset, nm_len_t len, const void*srcbuf);
507
509void nm_data_copy(struct nm_data_s*p_dest, struct nm_data_s*p_from);
510
513/* ** Data slicer ****************************************** */
514
540
542typedef struct nm_data_slicer_s
543{
545 union
546 {
547 struct nm_data_slicer_generator_s*p_generator;
548 struct nm_data_slicer_coroutine_s*p_coroutine;
549 struct nm_data_slicer_ucontext_s*p_uslicer;
550 };
552
560
562#define NM_DATA_SLICER_NULL ((struct nm_data_slicer_s){ .kind = NM_DATA_SLICER_NONE })
563
565static inline int nm_data_slicer_isnull(const nm_data_slicer_t*p_slicer)
566{
567 return (p_slicer->kind == NM_DATA_SLICER_NONE);
568}
569
570void nm_data_slicer_coroutine_init(nm_data_slicer_t*p_slicer, const struct nm_data_s*p_data);
573
574void nm_data_slicer_generator_init(nm_data_slicer_t*p_slicer, const struct nm_data_s*p_data);
577
578void nm_data_slicer_ucontext_init(nm_data_slicer_t*p_slicer, const struct nm_data_s*p_data);
581
582void nm_data_slicer_init(nm_data_slicer_t*p_slicer, const struct nm_data_s*p_data);
584void nm_data_slicer_copy_from(nm_data_slicer_t*p_slicer, void*dest_ptr, nm_len_t slice_len);
585void nm_data_slicer_copy_to(nm_data_slicer_t*p_slicer, const void*src_ptr, nm_len_t slice_len);
588
589
593/* ********************************************************* */
594
595/* inline functions */
596
597static inline void nm_datav_init(struct nm_datav_s*p_datav)
598{
599 p_datav->p_data = &p_datav->data[0];
600 p_datav->n_data = 0;
601 p_datav->allocated = 0;
602 p_datav->commited = 0;
603}
604
605static inline void nm_datav_destroy(struct nm_datav_s*p_datav)
606{
607 assert(p_datav->p_data != NULL);
608 if(p_datav->p_data != &p_datav->data[0])
609 {
610 padico_free(p_datav->p_data);
611 p_datav->p_data = NULL;
612 }
613 }
614
615static inline void nm_datav_add_chunk_data(struct nm_datav_s*p_datav, const struct nm_data_s*p_data)
616{
617 assert(!p_datav->commited); /* cannot modify datav once it is used as a nm_data */
618 if(p_datav->n_data == NM_DATAV_INIT_SIZE)
619 {
620 assert(p_datav->p_data == &p_datav->data[0]);
621 p_datav->allocated = NM_DATAV_INIT_SIZE * 2;
622 p_datav->p_data = (struct nm_data_s*)padico_malloc(p_datav->allocated * sizeof(struct nm_data_s));
623 memcpy(p_datav->p_data, &p_datav->data[0], p_datav->n_data * sizeof(struct nm_data_s));
624 }
625 else if((p_datav->n_data > NM_DATAV_INIT_SIZE) &&
626 (p_datav->n_data > p_datav->allocated - 1))
627 {
628 assert(p_datav->p_data != &p_datav->data[0]);
629 p_datav->allocated *= 2;
630 p_datav->p_data = (struct nm_data_s*)padico_realloc(p_datav->p_data, p_datav->allocated * sizeof(struct nm_data_s));
631 }
632 p_datav->p_data[p_datav->n_data] = *p_data;
633 p_datav->n_data++;
634}
635
636static inline void nm_datav_add_chunk(struct nm_datav_s*p_datav, const void*ptr, nm_len_t len)
637{
638 struct nm_data_s data;
639 nm_data_contiguous_build(&data, (void*)ptr, len);
640 nm_datav_add_chunk_data(p_datav, &data);
641}
642
643static inline nm_len_t nm_datav_size(struct nm_datav_s*p_datav)
644{
645 nm_len_t size = 0;
646 int i;
647 for(i = 0; i < p_datav->n_data; i++)
648 {
649 size += nm_data_size(&p_datav->p_data[i]);
650 }
651 return size;
652}
653
654static inline void nm_datav_uncommit(struct nm_datav_s*p_datav)
655{
656 assert(p_datav->commited);
657 p_datav->commited = 0;
658}
659
660#endif /* NM_DATA_H */
#define _NM_DATA_CONTENT_SIZE
maximum size of content descriptor for nm_data
Definition nm_data.h:74
struct nm_data_chunk_s nm_data_generator_generic_next(const struct nm_data_s *p_data, void *_generator)
void nm_data_generator_generic_init(const struct nm_data_s *p_data, void *_generator)
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.
Definition nm_data.h:654
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.
Definition nm_data.h:135
#define NM_DATAV_INIT_SIZE
initial size of an nm_datav
Definition nm_data.h:282
static void nm_data_propertie_gpu_preinit(struct nm_data_properties_s *p_props)
pre-init GPU part of data properties
Definition nm_data.h:203
void(* nm_data_generator_destroy_t)(const struct nm_data_s *p_data, void *_generator)
destroys resources allocated by generator
Definition nm_data.h:138
struct nm_data_chunk_s nm_data_generator_coroutine_next(const struct nm_data_s *p_data, void *_generator)
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
Definition nm_data.h:643
static int nm_data_chunk_isnull(const struct nm_data_chunk_s *p_chunk)
Definition nm_data.h:126
void(* nm_data_generator_init_t)(const struct nm_data_s *p_data, void *_generator)
initializes a generator (i.e.
Definition nm_data.h:118
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
Definition nm_data.h:636
void nm_data_generator_coroutine_init(const struct nm_data_s *p_data, void *_generator)
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.
Definition nm_data.h:108
void(* nm_data_apply_t)(void *ptr, nm_len_t len, void *_context)
function to apply to each data chunk upon traversal
Definition nm_data.h:101
void(* nm_data_properties_compute_t)(struct nm_data_s *p_data)
function to compute data properties
Definition nm_data.h:177
#define NM_DATA_TYPE(ENAME, CONTENT_TYPE, OPS)
macro to generate typed functions to init/access data fields.
Definition nm_data.h:240
static void nm_datav_init(struct nm_datav_s *p_datav)
initialize a datav
Definition nm_data.h:597
void nm_data_default_properties_compute(struct nm_data_s *p_data)
#define _NM_DATA_GENERATOR_SIZE
maximum content size for generators
Definition nm_data.h:76
void nm_data_generator_coroutine_destroy(const struct nm_data_s *p_data, void *_generator)
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 G...
Definition nm_data.h:216
static void nm_datav_destroy(struct nm_datav_s *p_datav)
destroys a datav
Definition nm_data.h:605
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.
Definition nm_data.h:615
static void nm_data_generator_destroy(struct nm_data_generator_s *p_generator)
destroy the generator after use
Definition nm_data.h:465
static nm_len_t nm_data_size(const struct nm_data_s *p_data)
returns the amount of data contained in the descriptor
Definition nm_data.h:483
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
Definition nm_data.h:449
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)
void nm_data_copy(struct nm_data_s *p_dest, struct nm_data_s *p_from)
copy from nm_data to another nm_data
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
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
Definition nm_data.h:440
static struct nm_data_chunk_s nm_data_generator_next(struct nm_data_generator_s *p_generator)
get the next chunk of data
Definition nm_data.h:457
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_baseptr_get(const struct nm_data_s *p_data)
find base pointer for a data known to be contiguous
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
static const struct nm_data_properties_s * nm_data_properties_get(const struct nm_data_s *p_data)
returns the properties block for the data
Definition nm_data.h:477
uint32_t nm_data_checksum(const struct nm_data_s *p_data)
checksum data
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_slicer_ucontext_init(nm_data_slicer_t *p_slicer, const struct nm_data_s *p_data)
static int nm_data_slicer_isnull(const nm_data_slicer_t *p_slicer)
tests whether a slicer is null
Definition nm_data.h:565
struct nm_data_slicer_s nm_data_slicer_t
internal state of a data slicer.
void nm_data_slicer_forward(nm_data_slicer_t *p_slicer, nm_len_t offset)
void nm_data_slicer_generator_destroy(nm_data_slicer_t *p_slicer)
nm_data_slicer_kind_t
various kinds of slicer implementations
Definition nm_data.h:534
void nm_data_slicer_generator_init(nm_data_slicer_t *p_slicer, const struct nm_data_s *p_data)
enum nm_data_slicer_op_e nm_data_slicer_op_t
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_copy_to(nm_data_slicer_t *p_slicer, const void *src_ptr, nm_len_t slice_len)
void nm_data_slicer_destroy(nm_data_slicer_t *p_slicer)
void nm_data_slicer_copy_from(nm_data_slicer_t *p_slicer, void *dest_ptr, nm_len_t slice_len)
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_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_coroutine_destroy(nm_data_slicer_t *p_slicer)
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)
nm_data_slicer_op_e
Definition nm_data.h:554
void nm_data_slicer_op(nm_data_slicer_t *p_slicer, void *ptr, nm_len_t len, nm_data_slicer_op_t op)
@ NM_DATA_SLICER_UCONTEXT
ucontext-based coroutine slicer, when stack jumping is not available through longjmp
Definition nm_data.h:538
@ NM_DATA_SLICER_NONE
Definition nm_data.h:535
@ NM_DATA_SLICER_GENERATOR
generator-based slicer, optimal for types with a dedicated generator; slow otherwise
Definition nm_data.h:536
@ NM_DATA_SLICER_COROUTINE
coroutine longjmp-based slicer, optimal for types without generator, when stack jumping is possible w...
Definition nm_data.h:537
@ NM_SLICER_OP_FORWARD
fast forward in slicer
Definition nm_data.h:556
@ NM_SLICER_OP_NONE
no operation selected
Definition nm_data.h:555
@ NM_SLICER_OP_COPY_FROM
copy from iterator to user buffer
Definition nm_data.h:557
@ NM_SLICER_OP_COPY_TO
copy to iterator, from user buffer
Definition nm_data.h:558
const struct nm_data_ops_s nm_data_ops_excerpt
static void nm_data_contiguous_build(struct nm_data_s *p_data, void *ptr, nm_len_t len)
Definition nm_data.h:355
static void nm_data_excerpt_set(struct nm_data_s *p_data, struct nm_data_excerpt_s value)
Definition nm_data.h:411
static void nm_data_iov_build(struct nm_data_s *p_data, const struct iovec *v, int n)
Definition nm_data.h:374
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
Definition nm_data.h:393
static void nm_data_datav_set(struct nm_data_s *p_data, struct nm_data_datav_s value)
Definition nm_data.h:390
const struct nm_data_ops_s nm_data_ops_null
const struct nm_data_ops_s nm_data_ops_iov
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.
Definition nm_data.h:415
static void nm_data_iov_set(struct nm_data_s *p_data, struct nm_data_iov_s value)
Definition nm_data.h:372
static void nm_data_null_set(struct nm_data_s *p_data, struct nm_data_null_s value)
Definition nm_data.h:333
static int nm_data_isnull(struct nm_data_s *p_data)
Definition nm_data.h:339
static void nm_data_null_build(struct nm_data_s *p_data)
Definition nm_data.h:334
const struct nm_data_ops_s nm_data_ops_contiguous
static void nm_data_contiguous_set(struct nm_data_s *p_data, struct nm_data_contiguous_s value)
Definition nm_data.h:353
const struct nm_data_ops_s nm_data_ops_datav
uint16_t len
chunk len
Definition nm_headers.h:0
nm_len_t chunk_len
length of this chunk
Definition nm_headers.h:4
nm_len_t chunk_offset
offset of the enclosed chunk
Definition nm_headers.h:4
#define NM_FATAL(format,...)
Definition nm_log.h:36
nm_len_t size
size of the onsided data (not incuding target-side completion)
uint64_t nm_len_t
data length used by nmad
Definition nm_types.h:68
chunk of data returned by generators
Definition nm_data.h:121
nm_len_t len
length of chunk
Definition nm_data.h:123
void * ptr
pointer to chunk
Definition nm_data.h:122
data descriptor for contiguous data
Definition nm_data.h:348
nm_len_t len
data length
Definition nm_data.h:350
void * ptr
base pointer for block
Definition nm_data.h:349
data descriptor for datav in a nm_data (embedd a vector of nm_data in nm_data)
Definition nm_data.h:386
struct nm_datav_s * p_datav
Definition nm_data.h:387
data as an excerpt of another data.
Definition nm_data.h:405
nm_len_t chunk_offset
Definition nm_data.h:406
nm_len_t chunk_len
Definition nm_data.h:407
struct nm_data_s * p_data
Definition nm_data.h:408
state of a data generator
Definition nm_data.h:112
const struct nm_data_s * p_data
Definition nm_data.h:113
data descriptor for iov data (embedd iovec in nm_data)
Definition nm_data.h:367
const struct iovec * v
Definition nm_data.h:368
data descriptor for 'null' data
Definition nm_data.h:329
int dummy
unused, to avoid non-portable empty structure
Definition nm_data.h:330
set of operations available on data type.
Definition nm_data.h:182
nm_data_generator_next_t p_generator_next
get next chunk from generator (optionnal)
Definition nm_data.h:185
nm_data_properties_compute_t p_properties_compute
optimized function to compute data properties (optionnal)
Definition nm_data.h:187
nm_data_generator_destroy_t p_generator_destroy
destroy a generator after use (optionnal, may be NULL even if p_generator_init != NULL)
Definition nm_data.h:186
nm_data_generator_init_t p_generator_init
initializes a new generator (chunks enumerator) (optionnal)
Definition nm_data.h:184
nm_data_traversal_t p_traversal
operation to apply a given function to all chunks of data (required)
Definition nm_data.h:183
block of static properties for a given data descriptor
Definition nm_data.h:164
nm_len_t size
total size in bytes (accumulator)
Definition nm_data.h:166
int is_contig
data is contiguous; data may be contiguous even with blocks > 1, if blocks are next to each other
Definition nm_data.h:167
nm_len_t blocks
number of blocks; -1 if properties are not initialized
Definition nm_data.h:165
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Definition nm_data.h:196
struct nm_data_ops_s ops
collection of iterators
Definition nm_data.h:197
struct nm_data_properties_s props
cache for properties
Definition nm_data.h:198
char _content[64]
placeholder for type-dependant content
Definition nm_data.h:199
internal state of a data slicer.
Definition nm_data.h:543
struct nm_data_slicer_ucontext_s * p_uslicer
Definition nm_data.h:549
struct nm_data_slicer_coroutine_s * p_coroutine
Definition nm_data.h:548
struct nm_data_slicer_generator_s * p_generator
Definition nm_data.h:547
nm_data_slicer_kind_t kind
Definition nm_data.h:544
encapsulate a dynamic vector of nm_data
Definition nm_data.h:286
int commited
Definition nm_data.h:291
struct nm_data_s data[4]
vector of data
Definition nm_data.h:288
int n_data
number of entries actually used in the above array
Definition nm_data.h:289
struct nm_data_s * p_data
vector of nm_data; either dynamically allocated, or points to data[0]
Definition nm_data.h:287
int allocated
allocated number of entries in p_data
Definition nm_data.h:290