util: crib SWAP macro from freedreno

we have a bunch of copies across the tree, unify them.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mel Henning <mhenning@darkrefraction.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36257>
This commit is contained in:
Alyssa Rosenzweig 2025-07-15 16:43:50 -04:00 committed by Marge Bot
parent 7ce8369985
commit ecfca8ec6f
5 changed files with 14 additions and 38 deletions

View file

@ -7,6 +7,7 @@
#define FREEDRENO_COMMON_H_
#include "util/u_atomic.h"
#include "util/macros.h"
#ifdef __cplusplus
@ -137,16 +138,6 @@ struct BitmaskEnum {
# define ENDC
#endif
/*
* SWAP - swap value of @a and @b
*/
#define SWAP(a, b) \
do { \
__typeof(a) __tmp = (a); \
(a) = (b); \
(b) = __tmp; \
} while (0)
/* for conditionally setting boolean flag(s): */
#define COND(bool, val) ((bool) ? (val) : 0)

View file

@ -8,20 +8,11 @@
#include "pipe/p_state.h"
#include "util/u_dynarray.h"
#include "util/macros.h"
#include "etnaviv_context.h"
#define MAX_CONFIG_BOS 4
/*
* SWAP - swap value of @a and @b
*/
#define SWAP(a, b) \
do { \
__typeof(a) __tmp = (a); \
(a) = (b); \
(b) = __tmp; \
} while (0)
enum etna_job_type {
ETNA_JOB_TYPE_NN,
ETNA_JOB_TYPE_TP,

View file

@ -50,6 +50,7 @@
#include "brw_shader.h"
#include "brw_cfg.h"
#include "util/macros.h"
#ifdef __SSE2__
@ -256,15 +257,6 @@ namespace {
#endif
/**
* Swap \p x and \p y.
*/
#define SWAP(x, y) do { \
__typeof(y) _swap_tmp = y; \
y = x; \
x = _swap_tmp; \
} while (0)
namespace {
/**
* Variable-length vector type intended to represent cycle-count costs for

View file

@ -50,6 +50,7 @@
#include "elk_fs.h"
#include "elk_cfg.h"
#include "util/macros.h"
#ifdef __SSE2__
@ -256,15 +257,6 @@ namespace {
#endif
/**
* Swap \p x and \p y.
*/
#define SWAP(x, y) do { \
__typeof(y) _swap_tmp = y; \
y = x; \
x = _swap_tmp; \
} while (0)
namespace {
/**
* Variable-length vector type intended to represent cycle-count costs for

View file

@ -519,4 +519,14 @@ typedef int lock_cap_t;
#define PRAGMA_POISON
#endif
/*
* SWAP - swap value of @a and @b
*/
#define SWAP(a, b) \
do { \
__typeof(a) __tmp = (a); \
(a) = (b); \
(b) = __tmp; \
} while (0)
#endif /* UTIL_MACROS_H */