[PATCH 1/4] drm/mm: add "best_match" flag to drm_mm_insert_node()

Daniel Vetter daniel at ffwll.ch
Tue Aug 6 04:03:53 PDT 2013


On Tue, Aug 6, 2013 at 11:39 AM, David Herrmann <dh.herrmann at gmail.com> wrote:
>
> On Mon, Aug 5, 2013 at 9:46 AM, Daniel Vetter <daniel at ffwll.ch> wrote:
>> On Sat, Jul 27, 2013 at 01:36:27PM +0200, David Herrmann wrote:
>>> Add a "best_match" flag similar to the drm_mm_search_*() helpers so we
>>> can convert TTM to use them in follow up patches. We can also inline the
>>> non-generic helpers and move them into the header to allow compile-time
>>> optimizations.
>>>
>>> To make calls to drm_mm_{search,insert}_node() more readable, this
>>> converts the boolean argument to a flagset. There are pending patches that
>>> add additional flags for top-down allocators and more.
>>>
>>> v2:
>>>  - use flag parameter instead of boolean "best_match"
>>>  - convert *_search_free() helpers to also use flags argument
>>>
>>> Signed-off-by: David Herrmann <dh.herrmann at gmail.com>
>>
>> I'm not sure whether the use of an enum here is proper C style (usually
>> bitflag arguments tend to be unsigned ints), but that's a bikeshed. So
>
> I saw it used in libxkbcommon and it's actually pretty nice because
> gcc supports some type-safety for it. It checks whether the passed
> flags are really from the enum (even if OR/AND-combined). And as it is
> no external API, we have no problems with the "enum resizing" once you
> add more flags.

Hm, I didn't know that gcc checks enums even when they're used as
flags with bitwise ops. That makes an enum indeed useful and the
better option.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the dri-devel mailing list