]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/uklibparam: `UK_LIBPARAM_PARAM_ALIAS()`,`UK_LIBPARAM_PARAM_ARR_ALIAS()`
authorSimon Kuenzer <simon@unikraft.io>
Fri, 24 Feb 2023 00:42:55 +0000 (01:42 +0100)
committerUnikraft <monkey@unikraft.io>
Sun, 7 May 2023 16:44:41 +0000 (16:44 +0000)
This commit provides `UK_LIBPARAM_PARAM_ALIAS()` and
`UK_LIBPARAM_PARAM_ARR_ALIAS()` which are variants of `UK_LIBPARAM_PARAM()`
and `UK_LIBPARAM_PARAM_ARR()`. These registration macros allow to set a
custom parameter name instead of deriving it from the variable name.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

lib/uklibparam/include/uk/libparam.h

index c635cef61d634e167ffd174dbd13c955bb9df160..22354835093283b1dce5f23f56bb0bddcd49b5f6 100644 (file)
@@ -263,6 +263,22 @@ int uk_libparam_parse(int argc, char **argv, int flags);
 #define UK_LIBPARAM_PARAM(var, type, desc) \
        _UK_LIBPARAM_PARAM_DEFINE(var, &var, type, 1, desc)
 
+/*
+ * Register a single parameter with a custom name
+ *
+ * @param name
+ *      Name used for library parameter
+ * @param addr
+ *      Reference to variable/memory address of parameter
+ * @param type
+ *      Data type: bool, char, uchar, int, uint, charp, __s8, __u8, __s16,
+ *                 __u16, __s32, __u32, __s64, __u64, __uptr
+ * @param desc
+ *      C string with parameter description. Optional, can be __NULL.
+ */
+#define UK_LIBPARAM_PARAM_ALIAS(name, addr, type, desc)                \
+       _UK_LIBPARAM_PARAM_DEFINE(name, (addr), type, 1, desc)
+
 /*
  * Register a parameter array
  *
@@ -280,6 +296,25 @@ int uk_libparam_parse(int argc, char **argv, int flags);
 #define UK_LIBPARAM_PARAM_ARR(var, type, count, desc) \
        _UK_LIBPARAM_PARAM_DEFINE(var, &var, type, (count), desc)
 
+/*
+ * Register a parameter array with a custom name
+ *
+ * @param name
+ *      Name used for library parameter
+ * @param addr
+ *      Reference to first array element/memory address of parameter
+ * @param type
+ *      Data type of array elements: bool, char, uchar, int, uint, charp, __s8,
+ *                                   __u8, __s16, __u16, __s32, __u32, __s64,
+ *                                   __u64, __uptr
+ * @param count
+ *      Number of elements in the array that can be filled (<= array size)
+ * @param desc
+ *      C string with parameter description. Optional, can be __NULL.
+ */
+#define UK_LIBPARAM_PARAM_ARR_ALIAS(name, addr, type, count, desc)     \
+       _UK_LIBPARAM_PARAM_DEFINE(name, (addr), type, (count), desc)
+
 /* Deprecated registration macros */
 /* WARNING: These interfaces are here for backwards compatibility and will be
  *          removed in the near future.