Motr  M0
st_misc.h File Reference
#include <ctype.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for st_misc.h:

Go to the source code of this file.

Macros

#define __MOTR_ST_ST_MISC_H__
 
#define str_dup(s)   strdup((s))
 
#define LOG_PREFIX
 
#define str_eq(a, b)   (strcmp((a), (b)) == 0)
 
#define MEM_ALLOC_ARR(arr, nr)   ((arr) = mem_alloc((nr) * sizeof ((arr)[0])))
 
#define MEM_ALLOC_PTR(arr)   MEM_ALLOC_ARR(arr, 1)
 

Enumerations

enum  { TIME_ONE_SECOND = 1000000000ULL, TIME_ONE_MSEC = TIME_ONE_SECOND / 1000 }
 

Functions

pid_t get_tid (void)
 
void console_printf (const char *fmt,...)
 
uint32_t generate_random (uint32_t max)
 
uint64_t time_now (void)
 
uint64_t time_from_now (uint64_t secs, uint64_t ns)
 
uint64_t time_seconds (const uint64_t time)
 
uint64_t time_nanoseconds (const uint64_t time)
 
void * mem_alloc (size_t size)
 
void mem_free (void *p)
 

Macro Definition Documentation

◆ __MOTR_ST_ST_MISC_H__

#define __MOTR_ST_ST_MISC_H__

Definition at line 26 of file st_misc.h.

◆ LOG_PREFIX

#define LOG_PREFIX

Definition at line 54 of file st_misc.h.

◆ MEM_ALLOC_ARR

#define MEM_ALLOC_ARR (   arr,
  nr 
)    ((arr) = mem_alloc((nr) * sizeof ((arr)[0])))

Definition at line 80 of file st_misc.h.

◆ MEM_ALLOC_PTR

#define MEM_ALLOC_PTR (   arr)    MEM_ALLOC_ARR(arr, 1)

Definition at line 81 of file st_misc.h.

◆ str_dup

#define str_dup (   s)    strdup((s))

Definition at line 52 of file st_misc.h.

◆ str_eq

#define str_eq (   a,
 
)    (strcmp((a), (b)) == 0)

Definition at line 58 of file st_misc.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
TIME_ONE_SECOND 
TIME_ONE_MSEC 

Definition at line 60 of file st_misc.h.

Function Documentation

◆ console_printf()

void console_printf ( const char *  fmt,
  ... 
)

Definition at line 155 of file st_misc.c.

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

◆ generate_random()

uint32_t generate_random ( uint32_t  max)

Definition at line 164 of file st_misc.c.

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

◆ get_tid()

pid_t get_tid ( void  )

Helper functions

Definition at line 150 of file st_misc.c.

Here is the caller graph for this function:

◆ mem_alloc()

void* mem_alloc ( size_t  size)

Definition at line 99 of file st_misc.c.

Here is the call graph for this function:

◆ mem_free()

void mem_free ( void *  p)

Definition at line 113 of file st_misc.c.

Here is the call graph for this function:

◆ time_from_now()

uint64_t time_from_now ( uint64_t  secs,
uint64_t  ns 
)

Definition at line 89 of file st_misc.c.

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

◆ time_nanoseconds()

uint64_t time_nanoseconds ( const uint64_t  time)

Definition at line 84 of file st_misc.c.

Here is the caller graph for this function:

◆ time_now()

uint64_t time_now ( void  )

Helper functions for Client ST in both user space and kernel

Definition at line 69 of file st_misc.c.

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

◆ time_seconds()

uint64_t time_seconds ( const uint64_t  time)

Definition at line 79 of file st_misc.c.

Here is the caller graph for this function: