qbutil.h | qbutil.h | |||
---|---|---|---|---|
skipping to change at line 23 | skipping to change at line 23 | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Lesser General Public License for more details. | * GNU Lesser General Public License for more details. | |||
* | * | |||
* You should have received a copy of the GNU Lesser General Public License | * You should have received a copy of the GNU Lesser General Public License | |||
* along with libqb. If not, see <http://www.gnu.org/licenses/>. | * along with libqb. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | */ | |||
#ifndef QB_UTIL_H_DEFINED | #ifndef QB_UTIL_H_DEFINED | |||
#define QB_UTIL_H_DEFINED | #define QB_UTIL_H_DEFINED | |||
/* *INDENT-OFF* */ | ||||
#ifdef __cplusplus | ||||
extern "C" { | ||||
#endif | ||||
/* *INDENT-ON* */ | ||||
#include <pthread.h> | ||||
#include <stdint.h> | #include <stdint.h> | |||
#ifndef S_SPLINT_S | #ifndef S_SPLINT_S | |||
#include <unistd.h> | #include <unistd.h> | |||
#endif /* S_SPLINT_S */ | #endif /* S_SPLINT_S */ | |||
/** | /** | |||
* @file qbutil.h | * @file qbutil.h | |||
* @author Angus Salkeld <asalkeld@redhat.com> | * @author Angus Salkeld <asalkeld@redhat.com> | |||
* | * | |||
* These are some convience functions used throughout libqb. | * These are some convience functions used throughout libqb. | |||
*/ | */ | |||
/* *INDENT-OFF* */ | ||||
#ifdef __cplusplus | ||||
extern "C" { | ||||
#endif | ||||
/* *INDENT-ON* */ | ||||
/** | /** | |||
* @typedef qb_thread_lock_type_t | * @typedef qb_thread_lock_type_t | |||
* QB_THREAD_LOCK_SHORT is a short term lock (spinlock if available on your system) | * 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_LONG is a mutex | |||
*/ | */ | |||
typedef enum { | typedef enum { | |||
QB_THREAD_LOCK_SHORT, | QB_THREAD_LOCK_SHORT, | |||
QB_THREAD_LOCK_LONG, | QB_THREAD_LOCK_LONG, | |||
} qb_thread_lock_type_t; | } qb_thread_lock_type_t; | |||
skipping to change at line 123 | skipping to change at line 125 | |||
*/ | */ | |||
uint64_t qb_util_nano_from_epoch_get(void); | uint64_t qb_util_nano_from_epoch_get(void); | |||
/** | /** | |||
* Get the time in timespec since epoch. | * Get the time in timespec since epoch. | |||
* @param ts (out) the timespec | * @param ts (out) the timespec | |||
* @return status (0 == ok, -errno on error) | * @return status (0 == ok, -errno on error) | |||
*/ | */ | |||
void qb_util_timespec_from_epoch_get(struct timespec *ts); | void qb_util_timespec_from_epoch_get(struct timespec *ts); | |||
/** | ||||
* strerror_r replacement. | ||||
*/ | ||||
char *qb_strerror_r(int errnum, char *buf, size_t buflen); | ||||
typedef struct qb_util_stopwatch qb_util_stopwatch_t; | ||||
/** | ||||
* Create a Stopwatch (to time operations) | ||||
*/ | ||||
qb_util_stopwatch_t * qb_util_stopwatch_create(void); | ||||
/** | ||||
* Free the stopwatch | ||||
*/ | ||||
void qb_util_stopwatch_free(qb_util_stopwatch_t *sw); | ||||
/** | ||||
* Start the stopwatch | ||||
* | ||||
* This also acts as a reset. Essentially it sets the | ||||
* starting time. | ||||
*/ | ||||
void qb_util_stopwatch_start(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_stopwatch_stop(qb_util_stopwatch_t *sw); | ||||
/** | ||||
* Get the elapsed time in micro seconds. | ||||
* | ||||
* (it must have been started and stopped). | ||||
*/ | ||||
uint64_t qb_util_stopwatch_us_elapsed_get(qb_util_stopwatch_t *sw); | ||||
/** | ||||
* Get the elapsed time in seconds. | ||||
* | ||||
* (it must have been started and stopped). | ||||
*/ | ||||
float qb_util_stopwatch_sec_elapsed_get(qb_util_stopwatch_t *sw); | ||||
/* *INDENT-OFF* */ | /* *INDENT-OFF* */ | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif /* __cplusplus */ | #endif /* __cplusplus */ | |||
/* *INDENT-ON* */ | /* *INDENT-ON* */ | |||
#endif /* QB_UTIL_H_DEFINED */ | #endif /* QB_UTIL_H_DEFINED */ | |||
End of changes. 3 change blocks. | ||||
6 lines changed or deleted | 56 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/ |