Page MenuHomeFreeBSD

hash(9): introduce hashalloc()/hashfree() KPI
AcceptedPublic

Authored by glebius on Tue, Mar 17, 7:27 PM.

Details

Reviewers
gallatin
pouria
Group Reviewers
Src Committers
Doc Committers
Summary

This is a more extendable version than traditional hashinit(9). It allows
different kinds of slot headers with optional locks.

Implement traditional hashinit()/hashdestroy() on top of it.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 71489
Build 68372: arc lint + arc unit

Event Timeline

Last minute change before sharing of course had a small mistake :)

This is really clever. What about other lock types (rm / rms, sx, etc)?

I'll see if rmlock(9) and sx(9) can be added and update.

Do you need to validate the enum value is know?

Can the lock and list types be automatically detected with _Generic somehow?

In D55904#1279057, @imp wrote:

Do you need to validate the enum value is know?

Do you mean if somebody passes a numeric instead of one of enum values? I think our compiler flags will forbid that.

Can the lock and list types be automatically detected with _Generic somehow?

I don't see a way to use _Generic facing outside of the KPI. It might be possible to make some use of it internally, I'll look into that.

Add sx(9) and rmlock(9) support.

In D55904#1279057, @imp wrote:

Do you need to validate the enum value is know?

Do you mean if somebody passes a numeric instead of one of enum values? I think our compiler flags will forbid that.

I'm thinking default: would make sure.

Can the lock and list types be automatically detected with _Generic somehow?

I don't see a way to use _Generic facing outside of the KPI. It might be possible to make some use of it internally, I'll look into that.

Sure.

Some additions to the manual page.

This revision is now accepted and ready to land.Wed, Mar 18, 5:28 PM
sys/kern/subr_hash.c
160–162

Why <= then >>=?
why not just <?

share/man/man9/hashinit.9
47–52

Are we going to remove hashinit_flags and hashdestroy as well?
We just updated them to use the new KPI, and we inform users that we plan to obsolete them at the same time.
If that's not the case, IMHO, we should include them in the new manual.
Otherwise, we should put a deprecation warning above their functions.

sys/kern/subr_hash.c
180

style?

284

style?

share/man/man9/hashalloc.9
1–2

SPDX tag?