From 1d8f28ca1bf41a3a5c53aed7bd9b7fe969672b27 Mon Sep 17 00:00:00 2001 From: John Sanpe Date: Fri, 3 Jan 2025 03:48:13 +0800 Subject: [PATCH] fixup bfdev: fixup some exmaples issue on 32bit machine Signed-off-by: John Sanpe --- examples/hashmap/benchmark.c | 5 +---- examples/ratelimit/simple.c | 3 ++- examples/tokenbucket/simple.c | 3 ++- include/bfdev/callback.h | 11 ++++++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/hashmap/benchmark.c b/examples/hashmap/benchmark.c index e93850dc..c8cfcd1e 100644 --- a/examples/hashmap/benchmark.c +++ b/examples/hashmap/benchmark.c @@ -89,14 +89,11 @@ main(int argc, const char *argv[]) srand(time(NULL)); bfdev_log_info("Generate %u node:\n", TEST_SIZE); for (count = 0; count < TEST_SIZE; ++count) - nodes[count].value = ((uint64_t)rand() << 32) | rand(); + nodes[count].value = count; bfdev_log_info("Insert nodes:\n"); EXAMPLE_TIME_STATISTICAL( for (count = 0; count < TEST_SIZE; ++count) { - value = ((uint64_t)rand() << 32) | rand(); - nodes[count].value = value; - retval = bfdev_hashmap_add(&test_map, &nodes[count].node); if (retval) return retval; diff --git a/examples/ratelimit/simple.c b/examples/ratelimit/simple.c index ff3fa96a..9af92772 100644 --- a/examples/ratelimit/simple.c +++ b/examples/ratelimit/simple.c @@ -19,7 +19,8 @@ current_msec(void) BFDEV_BUG_ON(clock_gettime(CLOCK_REALTIME, &ts)); - return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; + return (bfdev_time_t)ts.tv_sec * 1000 + + ts.tv_nsec / 1000000; } int diff --git a/examples/tokenbucket/simple.c b/examples/tokenbucket/simple.c index 6ee2bebb..5e773bb0 100644 --- a/examples/tokenbucket/simple.c +++ b/examples/tokenbucket/simple.c @@ -19,7 +19,8 @@ current_msec(void) BFDEV_BUG_ON(clock_gettime(CLOCK_REALTIME, &ts)); - return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; + return (bfdev_time_t)ts.tv_sec * 1000 + + ts.tv_nsec / 1000000; } int diff --git a/include/bfdev/callback.h b/include/bfdev/callback.h index 8c117a9b..ec8e2de4 100644 --- a/include/bfdev/callback.h +++ b/include/bfdev/callback.h @@ -10,9 +10,14 @@ BFDEV_BEGIN_DECLS -extern void bfdev_cbfunc_noop(void); -extern long bfdev_cbfunc_ret0(void); -extern long bfdev_cbfunc_ret1(void); +extern void +bfdev_cbfunc_noop(void); + +extern long +bfdev_cbfunc_ret0(void); + +extern long +bfdev_cbfunc_ret1(void); #define bfdev_dummy_noop ((void *)bfdev_cbfunc_noop) #define bfdev_dummy_ret0 ((void *)bfdev_cbfunc_ret0)