Commit 12f96cf9 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

Added utilities to format and print current time.

git-svn-id: file:///svn/toku/tokudb@21083 c7de825b-a66e-492c-adef-691d508d4ae1
parent dfdaee29
...@@ -20,6 +20,7 @@ extern "C" { ...@@ -20,6 +20,7 @@ extern "C" {
#include "toku_htonl.h" #include "toku_htonl.h"
#include "toku_assert.h" #include "toku_assert.h"
#include <signal.h> #include <signal.h>
#include <time.h>
#if defined(USE_TDB) #if defined(USE_TDB)
#include "ydb.h" #include "ydb.h"
//TDB uses DB_NOTFOUND for c_del and DB_CURRENT errors. //TDB uses DB_NOTFOUND for c_del and DB_CURRENT errors.
...@@ -217,6 +218,31 @@ double get_tdiff(void) { ...@@ -217,6 +218,31 @@ double get_tdiff(void) {
} }
} }
static __attribute__((__unused__))
void format_time(const time_t *timer, char *buf) {
ctime_r(timer, buf);
size_t len = strlen(buf);
assert(len < 26);
char end;
assert(len>=1);
end = buf[len-1];
while (end == '\n' || end == '\r') {
buf[len-1] = '\0';
len--;
assert(len>=1);
end = buf[len-1];
}
}
static __attribute__((__unused__))
void print_time_now(void) {
char timestr[80];
time_t now = time(NULL);
format_time(&now, timestr);
printf(timestr);
}
//Simulate as hard a crash as possible. //Simulate as hard a crash as possible.
//Choices: //Choices:
// raise(SIGABRT) // raise(SIGABRT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment