Page MenuHomeFreeBSD

bitset: introduce helpers to allocate a bitset at runtime
ClosedPublic

Authored by royger on May 5 2016, 3:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 12:57 AM
Unknown Object (File)
Fri, Apr 26, 12:57 AM
Unknown Object (File)
Fri, Apr 26, 12:57 AM
Unknown Object (File)
Fri, Apr 26, 12:49 AM
Unknown Object (File)
Fri, Apr 26, 12:49 AM
Unknown Object (File)
Dec 20 2023, 10:24 AM
Unknown Object (File)
Dec 19 2023, 11:45 PM
Unknown Object (File)
Nov 28 2023, 5:14 AM
Subscribers

Details

Summary

Introduce some new helpers to declare and allocate a dynamic bitset, whose
size is not a constant.

Sponsored by: Citrix Systems R&D

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

royger retitled this revision from to bitset: introduce helpers to allocate a bitset at runtime.
royger updated this object.
royger edited the test plan for this revision. (Show Details)
royger added reviewers: jhb, kib.

I would only put BITSET_DEFINE_VAR in _bitset.h (unfortunate to have to split it, but the idea is that _foo.h is the minimum to let you define types so it can be used as a nested include).

I think you don't need BITSET_FREE(). It's not unusual for APIs to return data that the caller knows has to be freed with free() (e.g. strdup() in userland).

royger edited edge metadata.

Remove BITSET_FREE, and move BITSET_ALLOC to bitset.h

kib edited edge metadata.
kib added inline comments.
sys/sys/bitset.h
195 ↗(On Diff #15964)

Why _s, while you use non-prefixed names for other arguments ?

I suggest to put () around flags mf in the malloc.

This revision is now accepted and ready to land.May 6 2016, 10:13 AM
sys/sys/bitset.h
195 ↗(On Diff #15964)

Hm, and why do you need p argument at all ? Why not leave it to the user

p = BITSET_ALLOC(1000, M_TMP, M_WAITOK);
sys/sys/bitset.h
195 ↗(On Diff #15964)

_s is used to keep the consistency between other macros in the file, where _s is also used to describe the size.

195 ↗(On Diff #15964)

This is a remaining of a previous implementation, I will remove p and use an assignment, thanks.

This revision was automatically updated to reflect the committed changes.