Hi and thanks.
Attached the patch with the related changes.

> Great. I just spotted this, are you sure there isn't a mistake ?
>
>
It is indeed :), my initial plan was (64 - ARGM_BITS) / sizeof(int) which
is still wrong althought I assumed wrongly apparently the result
represented all the bits included the ones not used.


>
>
> I remember that we always reserve one entry for ARGT_STOP, so the max
> usable number of args is 14 here. What do you think ?
>
> Just another detail here :
>
> -       unsigned int arg_mask;                    /* arguments (ARG*()) */
> +       int64_t arg_mask;                         /* arguments (ARG*()) */
>
> It's nicer to leave it unsigned (uint64_t), as seeing negative numbers for
> bitfields it really annoying when debugging.
>
>
Ok no problems.


> Thanks!
> willy
>
>
From bde853a0702e12447b48789ba8c6d456a7a287a2 Mon Sep 17 00:00:00 2001
From: David Carlier <devne...@gmail.com>
Date: Tue, 15 Mar 2016 19:00:35 +0000
Subject: [PATCH] MINOR: sample: Moves ARGS underlying type from 32 to 64 bits.

ARG# macros allow to create a list up to 7 in theory but 5 in
practice. The change to a guaranteed 64 bits type increase to
up to 12.
---
 include/proto/arg.h    | 35 ++++++++++++++++++++++++++++-------
 include/types/arg.h    |  6 +++---
 include/types/sample.h |  4 ++--
 src/arg.c              |  2 +-
 4 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/include/proto/arg.h b/include/proto/arg.h
index 91c1acd..0fe5472 100644
--- a/include/proto/arg.h
+++ b/include/proto/arg.h
@@ -31,22 +31,43 @@
  * the number of mandatory arguments in a mask.
  */
 #define ARGM(m) \
-	(m & ARGM_MASK)
+	(int64_t)(m & ARGM_MASK)
 
 #define ARG1(m, t1) \
-	(ARGM(m) + (ARGT_##t1 << (ARGM_BITS)))
+	(ARGM(m) + ((int64_t)ARGT_##t1 << (ARGM_BITS)))
 
 #define ARG2(m, t1, t2) \
-	(ARG1(m, t1) + (ARGT_##t2 << (ARGM_BITS + ARGT_BITS)))
+	(ARG1(m, t1) + ((int64_t)ARGT_##t2 << (ARGM_BITS + ARGT_BITS)))
 
 #define ARG3(m, t1, t2, t3) \
-	(ARG2(m, t1, t2) + (ARGT_##t3 << (ARGM_BITS + ARGT_BITS * 2)))
+	(ARG2(m, t1, t2) + ((int64_t)ARGT_##t3 << (ARGM_BITS + ARGT_BITS * 2)))
 
 #define ARG4(m, t1, t2, t3, t4) \
-	(ARG3(m, t1, t2, t3) + (ARGT_##t4 << (ARGM_BITS + ARGT_BITS * 3)))
+	(ARG3(m, t1, t2, t3) + ((int64_t)ARGT_##t4 << (ARGM_BITS + ARGT_BITS * 3)))
 
 #define ARG5(m, t1, t2, t3, t4, t5) \
-	(ARG4(m, t1, t2, t3, t4) + (ARGT_##t5 << (ARGM_BITS + ARGT_BITS * 4)))
+	(ARG4(m, t1, t2, t3, t4) + ((int64_t)ARGT_##t5 << (ARGM_BITS + ARGT_BITS * 4)))
+
+#define ARG6(m, t1, t2, t3, t4, t5, t6) \
+	(ARG5(m, t1, t2, t3, t4, t5) + ((int64_t)ARGT_##t6 << (ARGM_BITS + ARGT_BITS * 5)))
+
+#define ARG7(m, t1, t2, t3, t4, t5, t6, t7) \
+	(ARG6(m, t1, t2, t3, t4, t5, t6) + ((int64_t)ARGT_##t7 << (ARGM_BITS + ARGT_BITS * 6)))
+
+#define ARG8(m, t1, t2, t3, t4, t5, t6, t7, t8) \
+	(ARG7(m, t1, t2, t3, t4, t5, t6, t7) + ((int64_t)ARGT_##t8 << (ARGM_BITS + ARGT_BITS * 7)))
+
+#define ARG9(m, t1, t2, t3, t4, t5, t6, t7, t8, t9) \
+	(ARG8(m, t1, t2, t3, t4, t5, t6, t7, t8) + ((int64_t)ARGT_##t9 << (ARGM_BITS + ARGT_BITS * 8)))
+
+#define ARG10(m, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) \
+	(ARG9(m, t1, t2, t3, t4, t5, t6, t7, t8, t9) + ((int64_t)ARGT_##t10 << (ARGM_BITS + ARGT_BITS * 9)))
+
+#define ARG11(m, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) \
+	(ARG10(m, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) + ((int64_t)ARGT_##t11 << (ARGM_BITS + ARGT_BITS * 10)))
+
+#define ARG12(m, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) \
+	(ARG11(m, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) + ((int64_t)ARGT_##t12 << (ARGM_BITS + ARGT_BITS * 11)))
 
 /* Mapping between argument number and literal description. */
 extern const char *arg_type_names[];
@@ -58,7 +79,7 @@ extern struct arg empty_arg_list[ARGM_NBARGS];
 
 struct arg_list *arg_list_clone(const struct arg_list *orig);
 struct arg_list *arg_list_add(struct arg_list *orig, struct arg *arg, int pos);
-int make_arg_list(const char *in, int len, unsigned int mask, struct arg **argp,
+int make_arg_list(const char *in, int len, int64_t mask, struct arg **argp,
                   char **err_msg, const char **err_ptr, int *err_arg,
                   struct arg_list *al);
 
diff --git a/include/types/arg.h b/include/types/arg.h
index 5430de7..d0dbf7a 100644
--- a/include/types/arg.h
+++ b/include/types/arg.h
@@ -35,12 +35,12 @@
 #define ARGT_NBTYPES   (1 << ARGT_BITS)
 #define ARGT_MASK      (ARGT_NBTYPES - 1)
 
-/* encoding of the arg count : up to 5 args are possible. 4 bits are left
+/* encoding of the arg count : up to 12 args are possible. 4 bits are left
  * unused at the top.
  */
 #define ARGM_MASK      ((1 << ARGM_BITS) - 1)
-#define ARGM_BITS      3
-#define ARGM_NBARGS    (32 - ARGM_BITS) / sizeof(int)
+#define ARGM_BITS      4
+#define ARGM_NBARGS    (sizeof(int64_t) * 8 - ARGM_BITS) / ARGT_BITS
 
 enum {
 	ARGT_STOP = 0, /* end of the arg list */
diff --git a/include/types/sample.h b/include/types/sample.h
index 4a46be8..955f9bd 100644
--- a/include/types/sample.h
+++ b/include/types/sample.h
@@ -280,7 +280,7 @@ struct sample_conv {
 	int (*process)(const struct arg *arg_p,
 	               struct sample *smp,
 	               void *private);            /* process function */
-	unsigned int arg_mask;                    /* arguments (ARG*()) */
+	uint64_t arg_mask;                        /* arguments (ARG*()) */
 	int (*val_args)(struct arg *arg_p,
 	                struct sample_conv *smp_conv,
 	                const char *file, int line,
@@ -304,7 +304,7 @@ struct sample_fetch {
 	               struct sample *smp,
 	               const char *kw,            /* fetch processing function */
 	               void *private);            /* private value. */
-	unsigned int arg_mask;                    /* arguments (ARG*()) */
+	uint64_t arg_mask;                        /* arguments (ARG*()) */
 	int (*val_args)(struct arg *arg_p,
 			char **err_msg);          /* argument validation function */
 	unsigned long out_type;                   /* output sample type */
diff --git a/src/arg.c b/src/arg.c
index 7248c54..1781d23 100644
--- a/src/arg.c
+++ b/src/arg.c
@@ -91,7 +91,7 @@ struct arg_list *arg_list_add(struct arg_list *orig, struct arg *arg, int pos)
  * argument type in each subsequent ARGT_BITS-bit sblock. If <err_msg> is not
  * NULL, it must point to a freeable or NULL pointer.
  */
-int make_arg_list(const char *in, int len, unsigned int mask, struct arg **argp,
+int make_arg_list(const char *in, int len, int64_t mask, struct arg **argp,
                   char **err_msg, const char **err_ptr, int *err_arg,
                   struct arg_list *al)
 {
-- 
2.7.2

Reply via email to