diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-03-04 10:19:38 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-03-08 09:57:33 +0000 |
commit | 697c3f5550d8a58901c010635ecb7a76a524d296 (patch) | |
tree | f7c91a895d10d6d5b210023c5258b21dc2f6e725 | |
parent | 60eafc548911d8625d20443a203c5aff3662c39a (diff) |
lib: Magic for_each_engine() macro to iterate over available engines
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | lib/igt_gt.h | 9 | ||||
-rw-r--r-- | tests/gem_exec_suspend.c | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/igt_gt.h b/lib/igt_gt.h index ad993c1b..dfe1cfb3 100644 --- a/lib/igt_gt.h +++ b/lib/igt_gt.h @@ -100,4 +100,13 @@ extern const struct intel_execution_engine { unsigned flags; } intel_execution_engines[]; +#define for_if(expr__) if (!(expr__)) {} else + +#define for_each_engine(fd__, flags__) \ + for (const struct intel_execution_engine *e__ = intel_execution_engines;\ + e__->name; \ + e__++) \ + for_if (gem_has_ring(fd, flags__ = e__->exec_id | e__->flags)) + + #endif /* IGT_GT_H */ diff --git a/tests/gem_exec_suspend.c b/tests/gem_exec_suspend.c index f468ff4a..86cf644a 100644 --- a/tests/gem_exec_suspend.c +++ b/tests/gem_exec_suspend.c @@ -53,10 +53,10 @@ static void check_bo(int fd, uint32_t handle) static void test_all(int fd) { - const struct intel_execution_engine *e; - for (e = intel_execution_engines; e->name; e++) - if (gem_has_ring(fd, e->exec_id | e->flags)) - run_test(fd, e->exec_id | e->flags, NOSLEEP); + unsigned engine; + + for_each_engine(fd, engine) + run_test(fd, engine, NOSLEEP); } static void run_test(int fd, unsigned ring, enum mode mode) |