Skip to content

Commit 0e20353

Browse files
committed
- Add logging framework and basic log calls on server init/cleanup
- Add system time macro - Fix key cache label truncation
1 parent 3f2a62b commit 0e20353

File tree

22 files changed

+2950
-42
lines changed

22 files changed

+2950
-42
lines changed

benchmark/config/wolfhsm_cfg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef WOLFHSM_CFG_H_
2626
#define WOLFHSM_CFG_H_
2727

28+
#include "port/posix/posix_time.h"
29+
30+
#define WOLFHSM_CFG_PORT_GETTIME posixGetTime
31+
2832
#define WOLFHSM_CFG_ENABLE_CLIENT
2933
#define WOLFHSM_CFG_ENABLE_SERVER
3034

benchmark/wh_bench_ops.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
#include <stdint.h>
2020
#include <string.h> /* For memset, memcpy */
2121

22-
#if defined(WOLFHSM_CFG_TEST_POSIX)
23-
#include <sys/time.h> /* For gettimeofday and struct timeval */
24-
#endif
25-
2622
#include "wolfhsm/wh_settings.h"
2723
#include "wolfhsm/wh_error.h"
2824
#include "wh_bench_ops.h"
@@ -47,22 +43,7 @@ static uint64_t _benchGetTimeUsDefault(void);
4743
/* Default implementation for getting current time in microseconds */
4844
static uint64_t _benchGetTimeUsDefault(void)
4945
{
50-
uint64_t timeUs = 0;
51-
52-
#if defined(WOLFHSM_CFG_TEST_POSIX)
53-
struct timeval tv;
54-
gettimeofday(&tv, NULL);
55-
timeUs = (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec;
56-
#else
57-
/* Default implementation - should be overridden for actual platform */
58-
/* This is just a placeholder that returns a monotonically increasing value
59-
*/
60-
static uint64_t fakeTime = 0;
61-
fakeTime += 1000; /* Increment by a fake 1ms each call */
62-
timeUs = fakeTime;
63-
#endif
64-
65-
return timeUs;
46+
return WH_GETTIME_US();
6647
}
6748
#endif /* !(WOLFHSM_CFG_BENCH_CUSTOM_TIME_FUNC) */
6849

examples/posix/wh_posix_client/wolfhsm_cfg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef WOLFHSM_CFG_H_
2626
#define WOLFHSM_CFG_H_
2727

28+
#include "port/posix/posix_time.h"
29+
30+
#define WOLFHSM_CFG_PORT_GETTIME posixGetTime
31+
2832
/** wolfHSM settings */
2933
#define WOLFHSM_CFG_ENABLE_CLIENT
3034
#define WOLFHSM_CFG_HEXDUMP

examples/posix/wh_posix_server/wolfhsm_cfg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef WOLFHSM_CFG_H_
2626
#define WOLFHSM_CFG_H_
2727

28+
#include "port/posix/posix_time.h"
29+
30+
#define WOLFHSM_CFG_PORT_GETTIME posixGetTime
31+
2832
/** wolfHSM settings. Simple overrides to show they work */
2933
#define WOLFHSM_CFG_ENABLE_SERVER
3034

0 commit comments

Comments
 (0)