Motr  M0
misc.h File Reference
#include <string.h>
#include <limits.h>
#include "lib/user_space/misc.h"
#include "lib/types.h"
#include "lib/assert.h"
#include "lib/buf.h"
Include dependency graph for misc.h:

Go to the source code of this file.

Data Structures

struct  m0_key_val
 

Macros

#define __MOTR_LIB_MISC_H__
 
#define _QUOTE(s)   #s
 
#define M0_QUOTE(s)   _QUOTE(s)
 
#define M0_SRC_PATH(name)   M0_QUOTE(M0_SRC_DIR) "/" name
 
#define M0_MEMBER_SIZE(type, member)   sizeof(((type *)0)->member)
 
#define M0_SET0(obj)
 
#define M0_IS0(obj)   m0_forall(i, sizeof *(obj), ((char *)obj)[i] == 0)
 
#define M0_SET_ARR0(arr)
 
#define m0_count(var, nr, ...)
 
#define m0_forall(var, nr, ...)
 
#define m0_exists(var, nr, ...)   !m0_forall(var, (nr), !(__VA_ARGS__))
 
#define M0_BITS(...)   M0_CAT(__M0_BITS_, M0_COUNT_PARAMS(__VA_ARGS__))(__VA_ARGS__)
 
#define __M0_BITS_0(i)   (1ULL << (i))
 
#define __M0_BITS_1(i, ...)   ((1ULL << (i)) | __M0_BITS_0(__VA_ARGS__))
 
#define __M0_BITS_2(i, ...)   ((1ULL << (i)) | __M0_BITS_1(__VA_ARGS__))
 
#define __M0_BITS_3(i, ...)   ((1ULL << (i)) | __M0_BITS_2(__VA_ARGS__))
 
#define __M0_BITS_4(i, ...)   ((1ULL << (i)) | __M0_BITS_3(__VA_ARGS__))
 
#define __M0_BITS_5(i, ...)   ((1ULL << (i)) | __M0_BITS_4(__VA_ARGS__))
 
#define __M0_BITS_6(i, ...)   ((1ULL << (i)) | __M0_BITS_5(__VA_ARGS__))
 
#define __M0_BITS_7(i, ...)   ((1ULL << (i)) | __M0_BITS_6(__VA_ARGS__))
 
#define __M0_BITS_8(i, ...)   ((1ULL << (i)) | __M0_BITS_7(__VA_ARGS__))
 
#define ergo(a, b)   (!(a) || (b))
 
#define equi(a, b)   (!(a) == !(b))
 
#define AND_NOTHING_ELSE   else __dummy_function();
 
#define m0_is_array(x)   (!__builtin_types_compatible_p(typeof(&(x)[0]), typeof(x)))
 
#define IS_IN_ARRAY(idx, array)
 
#define M0_AMB(obj, ptr, field)   (container_of((ptr), typeof(*(obj)), field))
 
#define M0_MEMBER_PTR(ptr, member)
 
#define M0_MEMBER(ptr, member)
 
#define M0_FIELD_VALUE(type, field)   (((type *)0)->field)
 
#define M0_HAS_TYPE(expr, type)   __builtin_types_compatible_p(typeof(expr), type)
 
#define M0_FIELD_IS(type, field, ftype)   M0_HAS_TYPE(M0_FIELD_VALUE(type, field), ftype)
 
#define M0_MAGIX_OFFSET(type, field)
 
#define M0_COUNT_PARAMS(...)   M0_COUNT_PARAMS2(__VA_ARGS__, 9,8,7,6,5,4,3,2,1,0)
 
#define M0_COUNT_PARAMS2(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _, ...)   _
 
#define M0_CAT(A, B)   M0_CAT2(A, B)
 
#define M0_CAT2(A, B)   A ## B
 
#define M0_UNUSED   __attribute__((unused))
 
#define M0_CIRCULAR_SHIFT_LEFT(val, bits)
 
#define M0_BYTES(bits_nr)   ((bits_nr + 7) / 8)
 

Enumerations

enum  { UINT32_STR_LEN = 64 }
 

Functions

M0_INTERNAL uint64_t m0_round_up (uint64_t val, uint64_t size)
 
M0_INTERNAL uint64_t m0_round_down (uint64_t val, uint64_t size)
 
M0_INTERNAL const char * m0_bool_to_str (bool b)
 
M0_INTERNAL const char * m0_short_file_name (const char *fname)
 
uint64_t m0_strtou64 (const char *str, char **endptr, int base)
 
uint32_t m0_strtou32 (const char *str, char **endptr, int base)
 
void __dummy_function (void)
 
M0_INTERNAL bool m0_elems_are_unique (const void *array, unsigned nr_elems, size_t elem_size)
 
M0_INTERNAL uint32_t m0_no_of_bits_set (uint64_t val)
 
M0_INTERNAL unsigned int m0_full_name_hash (const unsigned char *name, unsigned int len)
 
M0_INTERNAL uint64_t m0_ptr_wrap (const void *p)
 
M0_INTERNAL const void * m0_ptr_unwrap (uint64_t val)
 
M0_INTERNAL void m0_permute (uint64_t n, uint64_t *k, uint64_t *s, uint64_t *r)
 
M0_INTERNAL void m0_array_sort (uint64_t *arr, uint64_t arr_len)
 
M0_INTERNAL bool m0_bit_get (void *buffer, m0_bcount_t i)
 
M0_INTERNAL void m0_bit_set (void *buffer, m0_bcount_t i, bool val)
 
M0_INTERNAL void m0_key_val_init (struct m0_key_val *kv, const struct m0_buf *key, const struct m0_buf *val)
 
M0_INTERNAL void * m0_vote_majority_get (struct m0_key_val *arr, uint32_t len, bool(*cmp)(const struct m0_buf *, const struct m0_buf *), uint32_t *vote_nr)
 
M0_INTERNAL bool m0_key_val_is_null (struct m0_key_val *kv)
 
M0_INTERNAL void m0_key_val_null_set (struct m0_key_val *kv)
 
M0_INTERNAL uint64_t m0_dummy_id_generate (void)
 

Variables

M0_EXTERN const struct m0_key_val M0_KEY_VAL_NULL
 

Macro Definition Documentation

◆ __M0_BITS_0

#define __M0_BITS_0 (   i)    (1ULL << (i))

Definition at line 239 of file misc.h.

◆ __M0_BITS_1

#define __M0_BITS_1 (   i,
  ... 
)    ((1ULL << (i)) | __M0_BITS_0(__VA_ARGS__))

Definition at line 240 of file misc.h.

◆ __M0_BITS_2

#define __M0_BITS_2 (   i,
  ... 
)    ((1ULL << (i)) | __M0_BITS_1(__VA_ARGS__))

Definition at line 241 of file misc.h.

◆ __M0_BITS_3

#define __M0_BITS_3 (   i,
  ... 
)    ((1ULL << (i)) | __M0_BITS_2(__VA_ARGS__))

Definition at line 242 of file misc.h.

◆ __M0_BITS_4

#define __M0_BITS_4 (   i,
  ... 
)    ((1ULL << (i)) | __M0_BITS_3(__VA_ARGS__))

Definition at line 243 of file misc.h.

◆ __M0_BITS_5

#define __M0_BITS_5 (   i,
  ... 
)    ((1ULL << (i)) | __M0_BITS_4(__VA_ARGS__))

Definition at line 244 of file misc.h.

◆ __M0_BITS_6

#define __M0_BITS_6 (   i,
  ... 
)    ((1ULL << (i)) | __M0_BITS_5(__VA_ARGS__))

Definition at line 245 of file misc.h.

◆ __M0_BITS_7

#define __M0_BITS_7 (   i,
  ... 
)    ((1ULL << (i)) | __M0_BITS_6(__VA_ARGS__))

Definition at line 246 of file misc.h.

◆ __M0_BITS_8

#define __M0_BITS_8 (   i,
  ... 
)    ((1ULL << (i)) | __M0_BITS_7(__VA_ARGS__))

Definition at line 247 of file misc.h.

◆ __MOTR_LIB_MISC_H__

#define __MOTR_LIB_MISC_H__

Definition at line 25 of file misc.h.

◆ _QUOTE

#define _QUOTE (   s)    #s

Definition at line 40 of file misc.h.

◆ AND_NOTHING_ELSE

#define AND_NOTHING_ELSE   else __dummy_function();

A macro used with if-statements without ‘else’ clause to assure proper coverage analysis.

Definition at line 306 of file misc.h.

◆ equi

#define equi (   a,
 
)    (!(a) == !(b))

Definition at line 297 of file misc.h.

◆ ergo

#define ergo (   a,
 
)    (!(a) || (b))

Definition at line 293 of file misc.h.

◆ IS_IN_ARRAY

#define IS_IN_ARRAY (   idx,
  array 
)
Value:
({ \
M0_CASSERT(m0_is_array(array)); \
((unsigned long)(idx)) < ARRAY_SIZE(array); \
})
#define m0_is_array(x)
Definition: misc.h:308
#define ARRAY_SIZE(a)
Definition: misc.h:45

Definition at line 311 of file misc.h.

◆ M0_AMB

#define M0_AMB (   obj,
  ptr,
  field 
)    (container_of((ptr), typeof(*(obj)), field))

Definition at line 320 of file misc.h.

◆ M0_BITS

#define M0_BITS (   ...)    M0_CAT(__M0_BITS_, M0_COUNT_PARAMS(__VA_ARGS__))(__VA_ARGS__)

Reduces ("aggregates") given expression over an interval.

See also
http://en.wikipedia.org/wiki/Fold_(higher-order_function)

Example uses

sum = m0_reduce(i, ARRAY_SIZE(a), 0, + a[i]);
product = m0_reduce(i, ARRAY_SIZE(b), 1, * b[i]);
@encode
@see m0_fold(), m0_tl_reduce()
/
#define m0_reduce(var, nr, init, exp) \
({ \
unsigned __nr = (nr); \
unsigned var; \
typeof(init) __accum = (init); \
\
for (var = 0; var < __nr; ++var) { \
__accum = __accum exp; \
} \
__accum; \
})
#define m0_fold(var, accum, nr, init, exp) \
({ \
unsigned __nr = (nr); \
unsigned var; \
typeof(init) accum = (init); \
\
for (var = 0; var < __nr; ++var) { \
accum = exp; \
} \
accum; \
})
#define M0_IN(x, set) \
({ typeof (x) __x = (x); \
M0_IN0(__x, M0_UNPACK set); })
#define M0_UNPACK(...) __VA_ARGS__
#define M0_IN0(...) \
M0_CAT(M0_IN_, M0_COUNT_PARAMS(__VA_ARGS__))(__VA_ARGS__)
#define M0_IN_1(x, v) ((x) == (v))
#define M0_IN_2(x, v, ...) ((x) == (v) || M0_IN_1(x, __VA_ARGS__))
#define M0_IN_3(x, v, ...) ((x) == (v) || M0_IN_2(x, __VA_ARGS__))
#define M0_IN_4(x, v, ...) ((x) == (v) || M0_IN_3(x, __VA_ARGS__))
#define M0_IN_5(x, v, ...) ((x) == (v) || M0_IN_4(x, __VA_ARGS__))
#define M0_IN_6(x, v, ...) ((x) == (v) || M0_IN_5(x, __VA_ARGS__))
#define M0_IN_7(x, v, ...) ((x) == (v) || M0_IN_6(x, __VA_ARGS__))
#define M0_IN_8(x, v, ...) ((x) == (v) || M0_IN_7(x, __VA_ARGS__))
#define M0_IN_9(x, v, ...) ((x) == (v) || M0_IN_8(x, __VA_ARGS__))

then

M0_BITS(FOO_ACTIVE, FOO_FAILED)

returns

(1ULL << FOO_ACTIVE) | (1ULL << FOO_FAILED)
Note
M0_BITS() macro with no parameters causes compilation failure.

Definition at line 236 of file misc.h.

◆ M0_BYTES

#define M0_BYTES (   bits_nr)    ((bits_nr + 7) / 8)

Get number of complete bytes from provided bits number.

Definition at line 442 of file misc.h.

◆ M0_CAT

#define M0_CAT (   A,
  B 
)    M0_CAT2(A, B)

Concatenates two arguments to produce a single token.

Definition at line 377 of file misc.h.

◆ M0_CAT2

#define M0_CAT2 (   A,
  B 
)    A ## B

Definition at line 378 of file misc.h.

◆ M0_CIRCULAR_SHIFT_LEFT

#define M0_CIRCULAR_SHIFT_LEFT (   val,
  bits 
)
Value:
({ \
typeof(val) __v = (val); \
typeof(bits) __b = (bits); \
\
(__v << __b) | (__v >> (sizeof(__v) * CHAR_BIT - __b)); \
})
Definition: idx_mock.c:52
#define CHAR_BIT
Definition: misc.h:32

Val should be of unsigned type.

Definition at line 403 of file misc.h.

◆ m0_count

#define m0_count (   var,
  nr,
  ... 
)
Value:
({ \
unsigned __nr = (nr); \
unsigned var; \
unsigned count; \
\
for (count = var = 0; var < __nr; ++var) { \
if (__VA_ARGS__) \
++count; \
} \
count; \
})
static size_t nr
Definition: dump.c:1505
static m0_bcount_t count
Definition: xcode.c:167

Returns the number of array elements that satisfy given criteria.

Definition at line 79 of file misc.h.

◆ M0_COUNT_PARAMS

#define M0_COUNT_PARAMS (   ...)    M0_COUNT_PARAMS2(__VA_ARGS__, 9,8,7,6,5,4,3,2,1,0)

Returns the number of parameters given to this variadic macro (up to 9 parameters are supported)

Note
M0_COUNT_PARAMS() returns max(number_of_parameters - 1, 0) e.g. M0_COUNT_PARAMS() -> 0 M0_COUNT_PARAMS(x) -> 0 M0_COUNT_PARAMS(x, y) -> 1 M0_COUNT_PARAMS(x, y, z) -> 2

Definition at line 370 of file misc.h.

◆ M0_COUNT_PARAMS2

#define M0_COUNT_PARAMS2 (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _,
  ... 
)    _

Definition at line 372 of file misc.h.

◆ m0_exists

#define m0_exists (   var,
  nr,
  ... 
)    !m0_forall(var, (nr), !(__VA_ARGS__))

Returns a disjunction (logical OR) of an expression evaluated over a range.

bool haystack_contains(int needle)
{
return m0_exists(i, ARRAY_SIZE(haystack), haystack[i] == needle);
}
See also
m0_forall()

Definition at line 134 of file misc.h.

◆ M0_FIELD_IS

#define M0_FIELD_IS (   type,
  field,
  ftype 
)    M0_HAS_TYPE(M0_FIELD_VALUE(type, field), ftype)

True iff type::field is of type "ftype".

Definition at line 349 of file misc.h.

◆ M0_FIELD_VALUE

#define M0_FIELD_VALUE (   type,
  field 
)    (((type *)0)->field)

Produces an expression having the same type as a given field in a given struct or union. Suitable to be used as an argument to sizeof() or typeof().

Definition at line 339 of file misc.h.

◆ m0_forall

#define m0_forall (   var,
  nr,
  ... 
)
Value:
({ \
unsigned __nr = (nr); \
unsigned var; \
\
for (var = 0; var < __nr && ({ __VA_ARGS__ ; }); ++var) \
; \
var == __nr; \
})
static size_t nr
Definition: dump.c:1505

Returns a conjunction (logical AND) of an expression evaluated over a range

Declares an unsigned integer variable named "var" in a new scope and evaluates user-supplied expression (the last argument) with "var" iterated over successive elements of [0 .. NR - 1] range, while this expression returns true. Returns true iff the whole range was iterated over.

This function is useful for invariant checking.

bool foo_invariant(const struct foo *f)
{
return m0_forall(i, ARRAY_SIZE(f->f_nr_bar), f->f_bar[i].b_count > 0);
}
See also
m0_tlist_forall(), m0_tl_forall(), m0_list_forall().
m0_list_entry_forall().

Definition at line 112 of file misc.h.

◆ M0_HAS_TYPE

#define M0_HAS_TYPE (   expr,
  type 
)    __builtin_types_compatible_p(typeof(expr), type)

True if an expression has a given type.

Definition at line 344 of file misc.h.

◆ M0_IS0

#define M0_IS0 (   obj)    m0_forall(i, sizeof *(obj), ((char *)obj)[i] == 0)

Definition at line 70 of file misc.h.

◆ m0_is_array

#define m0_is_array (   x)    (!__builtin_types_compatible_p(typeof(&(x)[0]), typeof(x)))

Definition at line 308 of file misc.h.

◆ M0_MAGIX_OFFSET

#define M0_MAGIX_OFFSET (   type,
  field 
)
Value:
M0_FIELD_IS(type, field, uint64_t) ? \
offsetof(type, field) : \
sizeof(char [M0_FIELD_IS(type, field, uint64_t) - 1])
static int field(struct ff2c_context *ctx, struct ff2c_term *term)
Definition: parser.c:84
#define M0_FIELD_IS(type, field, ftype)
Definition: misc.h:349
int type
Definition: dir.c:1031

Computes offset of "magix" field, iff magix field is of type uint64_t. Otherwise causes compilation failure.

Definition at line 356 of file misc.h.

◆ M0_MEMBER

#define M0_MEMBER (   ptr,
  member 
)
Value:
({ \
typeof(ptr) __ptr = (ptr); \
__ptr == NULL ? NULL : __ptr->member; \
})
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:440
#define NULL
Definition: misc.h:38

Definition at line 329 of file misc.h.

◆ M0_MEMBER_PTR

#define M0_MEMBER_PTR (   ptr,
  member 
)
Value:
({ \
typeof(ptr) __ptr = (ptr); \
__ptr == NULL ? NULL : &__ptr->member; \
})
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:440
#define NULL
Definition: misc.h:38

Definition at line 323 of file misc.h.

◆ M0_MEMBER_SIZE

#define M0_MEMBER_SIZE (   type,
  member 
)    sizeof(((type *)0)->member)

Definition at line 62 of file misc.h.

◆ M0_QUOTE

#define M0_QUOTE (   s)    _QUOTE(s)

Definition at line 41 of file misc.h.

◆ M0_SET0

#define M0_SET0 (   obj)
Value:
({ \
M0_CASSERT(!m0_is_array(obj)); \
memset((obj), 0, sizeof *(obj)); \
})
static struct foo * obj
Definition: tlist.c:302
#define m0_is_array(x)
Definition: misc.h:308

Definition at line 64 of file misc.h.

◆ M0_SET_ARR0

#define M0_SET_ARR0 (   arr)
Value:
({ \
M0_CASSERT(m0_is_array(arr)); \
memset((arr), 0, sizeof (arr)); \
})
#define m0_is_array(x)
Definition: misc.h:308

Definition at line 72 of file misc.h.

◆ M0_SRC_PATH

#define M0_SRC_PATH (   name)    M0_QUOTE(M0_SRC_DIR) "/" name

The absolute path to a file in Motr sources directory.

M0_SRC_DIR is defined in configure.ac.

Definition at line 48 of file misc.h.

◆ M0_UNUSED

#define M0_UNUSED   __attribute__((unused))

Definition at line 380 of file misc.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UINT32_STR_LEN 

Definition at line 411 of file misc.h.

Function Documentation

◆ __dummy_function()

void __dummy_function ( void  )

Definition at line 32 of file misc.c.

◆ m0_array_sort()

M0_INTERNAL void m0_array_sort ( uint64_t *  arr,
uint64_t  arr_len 
)

Sorts an array of integers in ascending order.

Definition at line 325 of file misc.c.

Here is the caller graph for this function:

◆ m0_bit_get()

M0_INTERNAL bool m0_bit_get ( void *  buffer,
m0_bcount_t  i 
)

Get i-th bit value from the buffer.

Definition at line 340 of file misc.c.

Here is the caller graph for this function:

◆ m0_bit_set()

M0_INTERNAL void m0_bit_set ( void *  buffer,
m0_bcount_t  i,
bool  val 
)

Set i-th bit value in the buffer.

Definition at line 349 of file misc.c.

Here is the caller graph for this function:

◆ m0_bool_to_str()

M0_INTERNAL const char* m0_bool_to_str ( bool  b)

Definition at line 207 of file misc.c.

Here is the caller graph for this function:

◆ m0_dummy_id_generate()

M0_INTERNAL uint64_t m0_dummy_id_generate ( void  )

Generates process-uinque identifier. WARN: Atomic based.

Definition at line 425 of file misc.c.

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

◆ m0_elems_are_unique()

M0_INTERNAL bool m0_elems_are_unique ( const void *  array,
unsigned  nr_elems,
size_t  elem_size 
)

Definition at line 257 of file misc.c.

Here is the caller graph for this function:

◆ m0_full_name_hash()

M0_INTERNAL unsigned int m0_full_name_hash ( const unsigned char *  name,
unsigned int  len 
)

Definition at line 266 of file misc.c.

Here is the caller graph for this function:

◆ m0_key_val_init()

M0_INTERNAL void m0_key_val_init ( struct m0_key_val kv,
const struct m0_buf key,
const struct m0_buf val 
)

Initialises a key value pair.

Definition at line 369 of file misc.c.

Here is the caller graph for this function:

◆ m0_key_val_is_null()

M0_INTERNAL bool m0_key_val_is_null ( struct m0_key_val kv)

Returns true iff it's M0_KEY_VAL_NULL.

Definition at line 363 of file misc.c.

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

◆ m0_key_val_null_set()

M0_INTERNAL void m0_key_val_null_set ( struct m0_key_val kv)

Initialises a key to M0_KEY_VAL_NULL.

Definition at line 378 of file misc.c.

Here is the call graph for this function:

◆ m0_no_of_bits_set()

M0_INTERNAL uint32_t m0_no_of_bits_set ( uint64_t  val)

Definition at line 227 of file misc.c.

Here is the caller graph for this function:

◆ m0_permute()

M0_INTERNAL void m0_permute ( uint64_t  n,
uint64_t *  k,
uint64_t *  s,
uint64_t *  r 
)

Apply a permutation given by its Lehmer code in k[] to a set s[] of n elements and build inverse permutation in r[].

Parameters
n- number of elements in k[], s[] and r[]
k- Lehmer code of the permutation
s- an array to permute
r- an array to build inverse permutation in
Precondition
m0_forall(i, n, k[i] + i < n)
m0_forall(i, n, s[i] < n && ergo(s[i] == s[j], i == j))
Postcondition
m0_forall(i, n, s[i] < n && ergo(s[i] == s[j], i == j))
m0_forall(i, n, s[r[i]] == i && r[s[i]] == i)

Definition at line 288 of file misc.c.

Here is the caller graph for this function:

◆ m0_ptr_unwrap()

M0_INTERNAL const void* m0_ptr_unwrap ( uint64_t  val)

Definition at line 282 of file misc.c.

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

◆ m0_ptr_wrap()

M0_INTERNAL uint64_t m0_ptr_wrap ( const void *  p)

Converts Motr function pointer in a form that can be stored somewhere (e.g., in a trace log or addb2 record) and later decoded back into original pointer.

Such transformation is needed, because function pointers depend on the address at which Motr library is loaded.

Precondition
"p" must be a pointer to Motr executable code or NULL.

Definition at line 277 of file misc.c.

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

◆ m0_round_down()

M0_INTERNAL uint64_t m0_round_down ( uint64_t  val,
uint64_t  size 
)

Returns rounded down value of in chunks of .

Precondition
m0_is_po2(size)

Definition at line 187 of file misc.c.

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

◆ m0_round_up()

M0_INTERNAL uint64_t m0_round_up ( uint64_t  val,
uint64_t  size 
)

Returns rounded up value of in chunks of .

Precondition
m0_is_po2(size)

Definition at line 181 of file misc.c.

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

◆ m0_short_file_name()

M0_INTERNAL const char* m0_short_file_name ( const char *  fname)

Extracts the file name, relative to a motr sources directory, from a full-path file name. A motr source directory is detected by a name "motr/".

For example, given the following full-path file name:

/path/to/motr/lib/ut/finject.c

A short file name, relative to the "motr/" directory, is:

lib/ut/finject.c
Bug:
{ This function doesn't search for the rightmost occurrence of "motr/" in a file path, if "motr/" encounters several times in the path the first one will be picked up:
  /path/to/motr/fs/motr/lib/misc.h => fs/motr/lib/misc.h

}

Parameters
fnamefull path
Returns
short file name - a pointer inside fname string to the remaining file path, after motr source directory; if short file name cannot be found, then full fname is returned.

Definition at line 212 of file misc.c.

Here is the caller graph for this function:

◆ m0_strtou32()

uint32_t m0_strtou32 ( const char *  str,
char **  endptr,
int  base 
)

Definition at line 32 of file kmisc.c.

Here is the caller graph for this function:

◆ m0_strtou64()

uint64_t m0_strtou64 ( const char *  str,
char **  endptr,
int  base 
)

Definition at line 26 of file kmisc.c.

Here is the caller graph for this function:

◆ m0_vote_majority_get()

M0_INTERNAL void* m0_vote_majority_get ( struct m0_key_val arr,
uint32_t  len,
bool(*)(const struct m0_buf *, const struct m0_buf *)  cmp,
uint32_t *  vote_nr 
)

This API implements Boyer-Moore Voting Algorithm. Returns the majority element present in an input array. The majority element of an array, if present, is the element that occurs more than n/2 times in the array of length n. It has been assumed that members of the array can be compared for equality and method for the same needs to be provided by the user of the API. Returns null if there is no majority element.

Definition at line 383 of file misc.c.

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

Variable Documentation

◆ M0_KEY_VAL_NULL

M0_EXTERN const struct m0_key_val M0_KEY_VAL_NULL

Definition at line 478 of file misc.h.