[virglrenderer-devel] [PATCH 2/5] utils: added some macros for future implems

Marc-André Lureau marcandre.lureau at redhat.com
Tue Jul 24 14:25:49 UTC 2018


On Tue, Jul 24, 2018 at 3:32 PM, Nathan Gauer <nathan at gauer.org> wrote:
> This commit adds some macros designed for a future use:
> ARRAY_SIZE: gives the size of an array
> UNUSED_PARAMETER: cast a parameter to void. Only a bit more explicit.
> TRACE_IN/TRACE_OUT: macros available in debug builds. Inspired from
> virtio-gpu ones.
>
> RETURN: encapsulates a return and a TRACE_OUT.
>
> Signed-off-by: Nathan Gauer <nathan at gauer.org>
> ---
>  src/util/macros.h | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>  create mode 100644 src/util/macros.h
>
> diff --git a/src/util/macros.h b/src/util/macros.h
> new file mode 100644
> index 0000000..7931d7a
> --- /dev/null
> +++ b/src/util/macros.h
> @@ -0,0 +1,26 @@
> +#ifndef UTIL_MACRO_H
> +#define UTIL_MACRO_H
> +
> +#define UNUSED_PARAMETER(Param) (void)(Param)

UNUSED from:
src/gallium/auxiliary/os/os_misc.h

> +#define ARRAY_SIZE(Array) (sizeof(Array) / sizeof((Array)[0]))

Already available in:
src/gallium/auxiliary/util/u_memory.h

> +
> +#ifdef DEBUG
> +
> +#define TRACE_IN() fprintf(stderr, "server: --> %s\n", __func__)

This doesn't look generic enough to be in a global macros.h. Move it
closer to where it is being used?

> +
> +#define TRACE_OUT(Value)                                             \
> +   do {                                                              \
> +      fprintf(stderr, "%s: server: <-- (%d)\n", __func__, Value);    \
> +   } while (0)
> +#else
> +
> +#define TRACE_IN()
> +#define TRACE_OUT(Value)
> +
> +#endif
> +
> +#define RETURN(Value)   \
> +   TRACE_OUT(Value);    \
> +   return Value;

This is unlikely to be acceptable upstream, as it clutters the code.

Either errors are being handled (silently) or are reported with
meaningful messages.


More information about the virglrenderer-devel mailing list