Motr  M0
varr.c File Reference
#include "lib/vec.h"
#include "lib/memory.h"
#include "lib/misc.h"
#include "lib/arith.h"
#include "lib/ub.h"
#include "ut/ut.h"
#include "lib/time.h"
#include "lib/varr.h"
#include "lib/varr_private.h"
#include "lib/finject.h"
#include <limits.h>
Include dependency graph for varr.c:

Go to the source code of this file.

Data Structures

struct  po2
 
struct  non_po2
 

Macros

#define test_iterate(varr, ele, dt, buff_nr)
 

Enumerations

enum  data_types { DT_ATOMIC_8, DT_ATOMIC_64, DT_POWTWO, DT_NON_POWTWO }
 
enum  sizes_and_shifts {
  BUFF_SIZE = 32, BUFF_SHIFT = 5, DT_ATOMIC_8_SHIFT = 0, DT_ATOMIC_64_SHIFT = 3,
  DT_POWTWO_SHIFT = 4, DT_NON_POWTWO_SHIFT = BUFF_SHIFT
}
 
enum  misc_params { MAX_DEPTH = 11, MAX_OBJ_NR = 26000, MAX_TEST_DEPTH = 6, MAX_BUFFERS = 4096 }
 
enum  { UB_ITER = 1 }
 

Functions

 M0_BASSERT (sizeof(uint64_t)==M0_BITS(DT_ATOMIC_64_SHIFT))
 
 M0_BASSERT (sizeof(uint8_t)==M0_BITS(DT_ATOMIC_8_SHIFT))
 
 M0_BASSERT (BUFF_SIZE==M0_BITS(BUFF_SHIFT))
 
 M0_BASSERT ((int) M0_0VEC_ALIGN >(int) BUFF_SIZE)
 
 M0_BASSERT (!(M0_0VEC_ALIGN &(M0_0VEC_ALIGN - 1)))
 
 M0_BASSERT (sizeof(struct po2)==M0_BITS(DT_POWTWO_SHIFT))
 
 M0_BASSERT (sizeof(struct non_po2)< BUFF_SIZE &&sizeof(struct non_po2) > M0_BITS(BUFF_SHIFT - 1))
 
static void test_init (void)
 
static void test_size (void)
 
static void test_depth (uint32_t max_depth)
 
static void test_cache (void)
 
static void test_ut_iterate (uint64_t nr)
 
static void obj_init (void *obj, uint64_t data, enum data_types dt)
 
static void obj_sanity_check (const void *obj, uint64_t data, enum data_types dt)
 
static size_t size_get (enum data_types dt)
 
static uint16_t int_summation (uint8_t n)
 
uint64_t array_len_compute (uint64_t buff_nr, enum data_types dt)
 
uint32_t shift_get (enum data_types dt)
 
static void tree_sanity_check (const struct m0_varr *varr, uint32_t depth)
 
void test_varr (void)
 
void test_ub_iterate (void)
 
static void varr_ub (int i)
 

Variables

struct m0_ub_set m0_varr_ub
 

Macro Definition Documentation

◆ test_iterate

#define test_iterate (   varr,
  ele,
  dt,
  buff_nr 
)
Value:
({ \
struct m0_varr *__varr_ = (varr); \
typeof(ele) __ele; \
uint64_t __buff_nr = (buff_nr); \
uint64_t __nr; \
int __rc; \
uint64_t __step; \
uint32_t __dt = dt; \
M0_ASSERT(size_get(__dt) == sizeof __ele); \
M0_SET0(__varr_); \
__nr = array_len_compute(__buff_nr, __dt); \
__rc = m0_varr_init(__varr_, __nr, size_get(__dt), BUFF_SIZE); \
M0_ASSERT(__rc == 0); \
m0_varr_iter(__varr_, typeof(__ele), i, obj, 0, \
m0_varr_size(__varr_), 1) { \
obj_init((void*)obj, i, __dt); \
m0_varr_for (__varr_, typeof(__ele), i, obj) { \
obj_sanity_check(obj, i, __dt); \
for (__step = 2; __step <= __nr; ++__step) { \
m0_varr_iter(__varr_, typeof(__ele), i, obj, 0, \
m0_varr_size(__varr_), __step) { \
obj_sanity_check((void *)obj, i, __dt); \
} \
m0_varr_fini(__varr_); \
})
static size_t size_get(enum data_types dt)
Definition: varr.c:204
#define m0_varr_endfor
Definition: varr.h:264
static struct foo * obj
Definition: tlist.c:302
int i
Definition: dir.c:1033
M0_INTERNAL uint64_t m0_varr_size(const struct m0_varr *arr)
Definition: varr.c:567
#define M0_ASSERT(cond)
M0_INTERNAL int m0_varr_init(struct m0_varr *arr, uint64_t nr, size_t size, size_t bufsize)
Definition: varr.c:114
#define m0_varr_enditer
Definition: varr.h:256
Definition: varr.h:121
Definition: varr.c:48
uint64_t array_len_compute(uint64_t buff_nr, enum data_types dt)
Definition: varr.c:335

Definition at line 94 of file varr.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UB_ITER 

Definition at line 412 of file varr.c.

◆ data_types

enum data_types
Enumerator
DT_ATOMIC_8 
DT_ATOMIC_64 
DT_POWTWO 
DT_NON_POWTWO 

Definition at line 40 of file varr.c.

◆ misc_params

Enumerator
MAX_DEPTH 
MAX_OBJ_NR 
MAX_TEST_DEPTH 
MAX_BUFFERS 

Definition at line 59 of file varr.c.

◆ sizes_and_shifts

Enumerator
BUFF_SIZE 
BUFF_SHIFT 
DT_ATOMIC_8_SHIFT 
DT_ATOMIC_64_SHIFT 
DT_POWTWO_SHIFT 
DT_NON_POWTWO_SHIFT 

Definition at line 47 of file varr.c.

Function Documentation

◆ array_len_compute()

uint64_t array_len_compute ( uint64_t  buff_nr,
enum data_types  dt 
)

Definition at line 335 of file varr.c.

Here is the call graph for this function:

◆ int_summation()

static uint16_t int_summation ( uint8_t  n)
static

Definition at line 290 of file varr.c.

Here is the caller graph for this function:

◆ M0_BASSERT() [1/7]

M0_BASSERT ( sizeof(uint64_t)  = =M0_BITS(DT_ATOMIC_64_SHIFT))

◆ M0_BASSERT() [2/7]

M0_BASSERT ( sizeof(uint8_t)  = =M0_BITS(DT_ATOMIC_8_SHIFT))

◆ M0_BASSERT() [3/7]

M0_BASSERT ( BUFF_SIZE  = =M0_BITS(BUFF_SHIFT))

◆ M0_BASSERT() [4/7]

M0_BASSERT ( (int)  M0_0VEC_ALIGN,
(int)  BUFF_SIZE 
)

◆ M0_BASSERT() [5/7]

M0_BASSERT ( M0_0VEC_ALIGN &(M0_0VEC_ALIGN - 1))

◆ M0_BASSERT() [6/7]

M0_BASSERT ( sizeof(struct po2 = =M0_BITS(DT_POWTWO_SHIFT))

◆ M0_BASSERT() [7/7]

M0_BASSERT ( sizeof(struct non_po2)< BUFF_SIZE &&sizeof(struct non_po2) > M0_BITS(BUFF_SHIFT - 1)  )

◆ obj_init()

static void obj_init ( void *  obj,
uint64_t  data,
enum data_types  dt 
)
static

Definition at line 357 of file varr.c.

◆ obj_sanity_check()

static void obj_sanity_check ( const void *  obj,
uint64_t  data,
enum data_types  dt 
)
static

Definition at line 387 of file varr.c.

Here is the call graph for this function:

◆ shift_get()

uint32_t shift_get ( enum data_types  dt)

Definition at line 342 of file varr.c.

Here is the caller graph for this function:

◆ size_get()

static size_t size_get ( enum data_types  dt)
static

Definition at line 204 of file varr.c.

Here is the caller graph for this function:

◆ test_cache()

static void test_cache ( void  )
static

Definition at line 269 of file varr.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_depth()

static void test_depth ( uint32_t  max_depth)
static

Definition at line 244 of file varr.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_init()

static void test_init ( void  )
static

Definition at line 155 of file varr.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_size()

static void test_size ( void  )
static

Definition at line 180 of file varr.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_ub_iterate()

void test_ub_iterate ( void  )

Definition at line 314 of file varr.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_ut_iterate()

void test_ut_iterate ( uint64_t  nr)
static

Definition at line 295 of file varr.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_varr()

void test_varr ( void  )

Definition at line 146 of file varr.c.

Here is the call graph for this function:

◆ tree_sanity_check()

static void tree_sanity_check ( const struct m0_varr varr,
uint32_t  depth 
)
static

Definition at line 220 of file varr.c.

Here is the caller graph for this function:

◆ varr_ub()

static void varr_ub ( int  i)
static

Definition at line 416 of file varr.c.

Here is the call graph for this function:

Variable Documentation

◆ m0_varr_ub

struct m0_ub_set m0_varr_ub
Initial value:
= {
.us_name = "varr-ub",
.us_init = NULL,
.us_fini = NULL,
.us_run = {
{ .ub_name = "varr",
.ub_iter = UB_ITER,
.ub_round = varr_ub },
{.ub_name = NULL }
}
}
#define NULL
Definition: misc.h:38
Definition: varr.c:413
static void varr_ub(int i)
Definition: varr.c:416

Definition at line 421 of file varr.c.