From 3cd38e86e5007350d8d4203cba0a6912e45b3fea Mon Sep 17 00:00:00 2001 From: Varun Rapelly Date: Thu, 8 Aug 2024 05:36:30 +0000 Subject: [PATCH] vppinfra: export utils for non vppinfra clib users Exports below functions for non src/vppinfra clib users: 1. clib_file_n_bytes 2. sprintf_clib_timebase_time Type: improvement JIRA: https://essjira.marvell.com/browse/IPBUSW-50810 Signed-off-by: Varun Rapelly Change-Id: Ia8356e15559290625b4ef0e22507d112abf9b900 Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/toolkits/vpp/+/133076 Tested-by: sa_ip-sw-jenkins Reviewed-by: Venkata Ravichandra Mynidi Reviewed-by: Monendra Singh Kushwaha (cherry picked from commit 342e3cb50e02a02a6476e275ecc33c39fc4c331f) Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/toolkits/vpp/+/134725 Reviewed-by: Nithinsen Kaithakadan --- src/vppinfra/time_range.c | 13 +++++++++++++ src/vppinfra/time_range.h | 2 ++ src/vppinfra/unix-misc.c | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/vppinfra/time_range.c b/src/vppinfra/time_range.c index 4b5e130376..076832b271 100644 --- a/src/vppinfra/time_range.c +++ b/src/vppinfra/time_range.c @@ -272,6 +272,19 @@ format_clib_timebase_time (u8 * s, va_list * args) return (s); } +__clib_export void +sprintf_clib_timebase_time (u8 *s, f64 now) +{ + clib_timebase_component_t _c, *cp = &_c; + + clib_timebase_time_to_components (now, cp); + + sprintf ((char *) s, "%s, %u %s %u %u:%02u:%02u", + day_names_epoch_order[cp->day_name_index], cp->day, + month_short_names[cp->month], cp->year, cp->hour, cp->minute, + cp->second); +} + uword unformat_clib_timebase_range_hms (unformat_input_t * input, va_list * args) { diff --git a/src/vppinfra/time_range.h b/src/vppinfra/time_range.h index 993bf9c360..7e95dcb398 100644 --- a/src/vppinfra/time_range.h +++ b/src/vppinfra/time_range.h @@ -68,6 +68,8 @@ unformat_function_t unformat_clib_timebase_range_hms; unformat_function_t unformat_clib_timebase_range_vector; format_function_t format_clib_timebase_time; +void sprintf_clib_timebase_time (u8 *s, f64 now); +#define CLIB_TIMEBASE_STR_MAX_SZ 60 static inline f64 clib_timebase_summer_offset_fastpath (clib_timebase_t * tb, f64 now) diff --git a/src/vppinfra/unix-misc.c b/src/vppinfra/unix-misc.c index 6a7328bd87..e158526ecc 100644 --- a/src/vppinfra/unix-misc.c +++ b/src/vppinfra/unix-misc.c @@ -50,8 +50,8 @@ __clib_export __thread uword __os_thread_index = 0; __clib_export __thread uword __os_numa_index = 0; -clib_error_t * -clib_file_n_bytes (char *file, uword * result) +__clib_export clib_error_t * +clib_file_n_bytes (char *file, uword *result) { struct stat s;