Don't use LP64 to decide the value, as it gives the wrong result on
CHERI platforms. Just define it in terms of sizeof(long).
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Note, there are quite a few other definitions of BITS_PER_LONG that have similar problems, but they're mostly in obsolete or unmaintained drivers. I'm not sure whether to sweep through and fix them too.
I'm not sure whether to sweep through and fix them too.
I'd be inclined to just leave them unless they come up in a CHERI context.
This is fine too. We do have some existing cases using sizeof, e.g.
sys/dev/drm2/drm_atomic.h:#define NB_BITS_PER_LONG (sizeof(long) * NBBY) sys/dev/axgbe/xgbe_osdep.h:#define BITS_PER_LONG (sizeof(long) * CHAR_BIT)
| sys/compat/linuxkpi/common/include/linux/bitops.h | ||
|---|---|---|
| 41 | I have a rather bad feeling about CHAR_BITS but maybe that stems from the fact that I used to write code for a 7bbit system before. I think the general FreeBSD usage was * NBBY. | |
The point was made elsewhere that we might want the value to be an int rather than a size_t, which would have been the case with the old version.
| sys/compat/linuxkpi/common/include/linux/bitops.h | ||
|---|---|---|
| 41 | I think it's safe to assume that CHAR_BIT (I made a typo before) and NBBY agree with each other. Probably NBBY should be defined in terms of the former, but that's not within the scope of this change. | |
| sys/compat/linuxkpi/common/include/linux/bitops.h | ||
|---|---|---|
| 41 | We have one use of CHAR_BIT in a tree from a few days ago in sys/ ; more than 240 of NBBY (incl. in cddl); I am happy here either way and if NBBY is a FreeBSD-ism (I don't know) maybe we should clean it up. I just prefer to have one way and not multiple. | |