kernel, db: add hweight() functions to the database