qbutil.h.3   qbutil.h.3 
qbutil.h(3) libqb qbutil .h(3) qbutil.h(3) libqb qbutil .h(3)
NAME NAME
qbutil.h - qbutil.h -
SYNOPSIS SYNOPSIS
#include <pthread.h>
#include <stdint.h> #include <stdint.h>
#include <unistd.h> #include <unistd.h>
Typedefs Typedefs
typedef struct qb_thread_lock_s qb_thread_lock_t typedef struct qb_thread_lock_s qb_thread_lock_t
typedef void(* qb_util_log_fn_t )(const char *file_name, int32_t fil e_line, int32_t severity, const char *msg) typedef void(* qb_util_log_fn_t )(const char *file_name, int32_t fil e_line, int32_t severity, const char *msg)
typedef struct qb_util_stopwatch qb_util_stopwatch_t
Enumerations Enumerations
enum qb_thread_lock_type_t { QB_THREAD_LOCK_SHORT, QB_THREAD_LOCK_LO NG } enum qb_thread_lock_type_t { QB_THREAD_LOCK_SHORT, QB_THREAD_LOCK_LO NG }
QB_THREAD_LOCK_SHORT is a short term lock (spinlock if available on your system) QB_THREAD_LOCK_LONG is a mutex. QB_THREAD_LOCK_SHORT is a short term lock (spinlock if available on your system) QB_THREAD_LOCK_LONG is a mutex'.
Functions Functions
qb_thread_lock_t * qb_thread_lock_create (qb_thread_lock_type_t type ) qb_thread_lock_t * qb_thread_lock_create (qb_thread_lock_type_t type )
Create a new lock of the given type. Create a new lock of the given type'.
int32_t qb_thread_lock (qb_thread_lock_t *tl) int32_t qb_thread_lock (qb_thread_lock_t *tl)
Calls either pthread_mutex_lock() or pthread_spin_lock(). Calls either pthread_mutex_lock() or pthread_spin_lock()'.
int32_t qb_thread_trylock (qb_thread_lock_t *tl) int32_t qb_thread_trylock (qb_thread_lock_t *tl)
Calls either pthread_mutex_trylock() or pthread_spin_trylock(). Calls either pthread_mutex_trylock() or pthread_spin_trylock()'.
int32_t qb_thread_unlock (qb_thread_lock_t *tl) int32_t qb_thread_unlock (qb_thread_lock_t *tl)
Calls either pthread_mutex_unlock() or pthread_spin_unlock. Calls either pthread_mutex_unlock() or pthread_spin_unlock'.
int32_t qb_thread_lock_destroy (qb_thread_lock_t *tl) int32_t qb_thread_lock_destroy (qb_thread_lock_t *tl)
Calls either pthread_mutex_destro() or pthread_spin_destroy(). Calls either pthread_mutex_destro() or pthread_spin_destroy()'.
void qb_util_set_log_function (qb_util_log_fn_t fn) void qb_util_set_log_function (qb_util_log_fn_t fn)
Use this function to output libqb internal log message as you wi sh. Use this function to output libqb internal log message as you wi sh'.
void qb_timespec_add_ms (struct timespec *ts, int32_t ms) void qb_timespec_add_ms (struct timespec *ts, int32_t ms)
Add milliseconds onto the timespec. Add milliseconds onto the timespec'.
uint64_t qb_util_nano_current_get (void) uint64_t qb_util_nano_current_get (void)
Get the current number of nano secounds produced by the systems incrementing clock (CLOCK_MONOTOMIC if available). Get the current number of nano secounds produced by the systems incrementing clock (CLOCK_MONOTOMIC if available)'.
uint64_t qb_util_nano_monotonic_hz (void) uint64_t qb_util_nano_monotonic_hz (void)
Get the frequence of the clock used in qb_util_nano_current_get( ). Get the frequence of the clock used in qb_util_nano_current_get( )'.
uint64_t qb_util_nano_from_epoch_get (void) uint64_t qb_util_nano_from_epoch_get (void)
Get the time in nano seconds since epoch. Get the time in nano seconds since epoch'.
void qb_util_timespec_from_epoch_get (struct timespec *ts) void qb_util_timespec_from_epoch_get (struct timespec *ts)
Get the time in timespec since epoch. Get the time in timespec since epoch'.
char * qb_strerror_r (int errnum, char *buf, size_t buflen)
strerror_r replacement'.
qb_util_stopwatch_t * qb_util_stopwatch_create (void)
Create a Stopwatch (to time operations)
void qb_util_stopwatch_free (qb_util_stopwatch_t *sw)
Free the stopwatch'.
void qb_util_stopwatch_start (qb_util_stopwatch_t *sw)
Start the stopwatch'.
void qb_util_stopwatch_stop (qb_util_stopwatch_t *sw)
Stop the stopwatch'.
uint64_t qb_util_stopwatch_us_elapsed_get (qb_util_stopwatch_t *sw)
Get the elapsed time in micro seconds'.
float qb_util_stopwatch_sec_elapsed_get (qb_util_stopwatch_t *sw)
Get the elapsed time in seconds'.
Detailed Description Detailed Description
Author: Author:
Angus Salkeld <asalkeld@redhat.com> Angus Salkeld <asalkeld@redhat.com>
These are some convience functions used throughout libqb. These are some convience functions used throughout libqb'.
Typedef Documentation Typedef Documentation
typedef struct qb_thread_lock_s qb_thread_lock_t typedef struct qb_thread_lock_s qb_thread_lock_t
typedef void(* qb_util_log_fn_t)(const char *file_name, int32_t file_lin e, int32_t severity, const char *msg) typedef void(* qb_util_log_fn_t)(const char *file_name, int32_t file_lin e, int32_t severity, const char *msg)
typedef struct qb_util_stopwatch qb_util_stopwatch_t
Enumeration Type Documentation Enumeration Type Documentation
enum qb_thread_lock_type_t enum qb_thread_lock_type_t
QB_THREAD_LOCK_SHORT is a short term lock (spinlock if available on your system) QB_THREAD_LOCK_LONG is a mutex. QB_THREAD_LOCK_SHORT is a short term lock (spinlock if available on your system) QB_THREAD_LOCK_LONG is a mutex'.
Enumerator: Enumerator:
QB_THREAD_LOCK_SHORT QB_THREAD_LOCK_SHORT
QB_THREAD_LOCK_LONG QB_THREAD_LOCK_LONG
Function Documentation Function Documentation
int32_t qb_thread_lock (qb_thread_lock_t * tl) char* qb_strerror_r (interrnum, char *buf, size_tbuflen)
Calls either pthread_mutex_lock() or pthread_spin_lock(). strerror_r replacement'.
qb_thread_lock_t* qb_thread_lock_create (qb_thread_lock_type_t type) int32_t qb_thread_lock (qb_thread_lock_t *tl)
Create a new lock of the given type. Parameters: Calls either pthread_mutex_lock() or pthread_spin_lock()'.
qb_thread_lock_t* qb_thread_lock_create (qb_thread_lock_type_ttype)
Create a new lock of the given type'. Parameters:
type QB_THREAD_LOCK_SHORT == spinlock (where available, else mut ex) QB_THREAD_LOCK_LONG == mutex type QB_THREAD_LOCK_SHORT == spinlock (where available, else mut ex) QB_THREAD_LOCK_LONG == mutex
Returns: Returns:
pointer to qb_thread_lock_type_t or NULL on error. pointer to qb_thread_lock_type_t or NULL on error'.
int32_t qb_thread_lock_destroy (qb_thread_lock_t * tl) int32_t qb_thread_lock_destroy (qb_thread_lock_t *tl)
Calls either pthread_mutex_destro() or pthread_spin_destroy(). Calls either pthread_mutex_destro() or pthread_spin_destroy()'.
int32_t qb_thread_trylock (qb_thread_lock_t * tl) int32_t qb_thread_trylock (qb_thread_lock_t *tl)
Calls either pthread_mutex_trylock() or pthread_spin_trylock(). Calls either pthread_mutex_trylock() or pthread_spin_trylock()'.
int32_t qb_thread_unlock (qb_thread_lock_t * tl) int32_t qb_thread_unlock (qb_thread_lock_t *tl)
Calls either pthread_mutex_unlock() or pthread_spin_unlock. Calls either pthread_mutex_unlock() or pthread_spin_unlock'.
void qb_timespec_add_ms (struct timespec * ts, int32_t ms) void qb_timespec_add_ms (struct timespec *ts, int32_tms)
Add milliseconds onto the timespec. Parameters: Add milliseconds onto the timespec'. Parameters:
ts the ts to add to ts the ts to add to
ms the amount of milliseconds to increment ts ms the amount of milliseconds to increment ts
uint64_t qb_util_nano_current_get (void) uint64_t qb_util_nano_current_get (void)
Get the current number of nano secounds produced by the systems incr ementing clock (CLOCK_MONOTOMIC if available). Get the current number of nano secounds produced by the systems incr ementing clock (CLOCK_MONOTOMIC if available)'.
uint64_t qb_util_nano_from_epoch_get (void) uint64_t qb_util_nano_from_epoch_get (void)
Get the time in nano seconds since epoch. Get the time in nano seconds since epoch'.
uint64_t qb_util_nano_monotonic_hz (void) uint64_t qb_util_nano_monotonic_hz (void)
Get the frequence of the clock used in qb_util_nano_current_get(). Get the frequence of the clock used in qb_util_nano_current_get()'.
void qb_util_set_log_function (qb_util_log_fn_tfn)
Use this function to output libqb internal log message as you wish'.
qb_util_stopwatch_t* qb_util_stopwatch_create (void)
Create a Stopwatch (to time operations)
void qb_util_stopwatch_free (qb_util_stopwatch_t *sw)
Free the stopwatch'.
float qb_util_stopwatch_sec_elapsed_get (qb_util_stopwatch_t *sw)
Get the elapsed time in seconds'. (it must have been started and sto
pped)'.
void qb_util_stopwatch_start (qb_util_stopwatch_t *sw)
Start the stopwatch'. This also acts as a reset'. Essentially it set
s the starting time'.
void qb_util_stopwatch_stop (qb_util_stopwatch_t *sw)
Stop the stopwatch'. This just allows you to get the elapsed time'.
So you can call this multiple times'. Do not call qb_util_stopwatch_start()
unless you want to reset the stopwatch'.
void qb_util_set_log_function (qb_util_log_fn_t fn) uint64_t qb_util_stopwatch_us_elapsed_get (qb_util_stopwatch_t *sw)
Use this function to output libqb internal log message as you wish. Get the elapsed time in micro seconds'. (it must have been started a
nd stopped)'.
void qb_util_timespec_from_epoch_get (struct timespec * ts) void qb_util_timespec_from_epoch_get (struct timespec *ts)
Get the time in timespec since epoch. Parameters: Get the time in timespec since epoch'. Parameters:
ts (out) the timespec ts (out) the timespec
Returns: Returns:
status (0 == ok, -errno on error) status (0 == ok, -errno on error)
Author Author
Generated automatically by Doxygen for libqb from the source code. Generated automatically by Doxygen for libqb from the source code'.
Version 0.4.1 Mon Jan 31 2011 qbutil .h(3) Version 0.8.1 Thu Jan 5 2012 qbutil .h(3)
 End of changes. 31 change blocks. 
35 lines changed or deleted 78 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/