[Intel-gfx] [PATCH i-g-t v2] tests/i915/gem_ctx_switch: Update with engine discovery

Chris Wilson chris at chris-wilson.co.uk
Thu Jun 27 20:24:09 UTC 2019


Quoting Andi Shyti (2019-06-27 21:15:30)
> > +bool gem_context_has_engine_map(int fd, uint32_t ctx)
> > +{
> > +     struct drm_i915_gem_context_param param = {
> > +             .param = I915_CONTEXT_PARAM_ENGINES,
> > +             .ctx_id = ctx
> > +     };
> > +     int ret;
> > +
> > +     ret = __gem_context_get_param(fd, &param);
> > +     igt_assert_eq(ret, 0);
> > +
> > +     return param.size;
> 
> a small nitpick: bool to me means '0' or '1'.
> 
> So, if you do 'return param.size', I would call the function
> gem_context_get_param_size, otherwise I would return
> '!!param.size' and keep it bool.

An integer in boolean context is 0 or 1, the !! is implicit. We use that
quite frequently, e.g. bool has_ptr(void **x) { return *x; }
 
> (We are also somehow abusing on the size definition of bool in
> C99/C17 or previous.)

I hope we never assume the size or alignment of bool. I always hope the
compiler will just reduce it to the control flags for inline predicates.
-Chris


More information about the Intel-gfx mailing list