mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
vmbus: Avoid gratuitous ifdef and use more generic implementation instead
Checking for __LP64__ is non-portable as it assumes that ILP32 and LP64 are the only two ABIs that exist, but CheriBSD supports an additional ABI where long is still 64-bit but pointers are 128-bit capabilities, and thus __LP64__ is not defined. We could change this to check the value of __SIZEOF_LONG__, since the code here only cares about that aspect of the ABI, however in this instance, the only real reason an ifdef is used at all is to be able to get log2(sizeof(u_long)), but if we instead multiply and divide rather than shift, and let the compiler optimise that to a shift, we can just use sizeof(u_long) instead. Note also that VMBUS_EVTFLAGS_MAX could always just have been defined as VMBUS_EVTFLAGS_SIZE / sizeof(u_long). Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D50630
This commit is contained in:
parent
2c444fdb0c
commit
cb75bb5126
2 changed files with 5 additions and 11 deletions
|
|
@ -1555,7 +1555,7 @@ vmbus_event_flags_proc(struct vmbus_softc *sc, volatile u_long *event_flags,
|
|||
continue;
|
||||
|
||||
flags = atomic_swap_long(&event_flags[f], 0);
|
||||
chid_base = f << VMBUS_EVTFLAG_SHIFT;
|
||||
chid_base = f * VMBUS_EVTFLAG_LEN;
|
||||
|
||||
while ((chid_ofs = ffsl(flags)) != 0) {
|
||||
struct vmbus_channel *chan;
|
||||
|
|
@ -1599,7 +1599,7 @@ vmbus_event_proc_compat(struct vmbus_softc *sc, int cpu)
|
|||
eventf = VMBUS_PCPU_GET(sc, event_flags, cpu) + VMBUS_SINT_MESSAGE;
|
||||
if (atomic_testandclear_long(&eventf->evt_flags[0], 0)) {
|
||||
vmbus_event_flags_proc(sc, sc->vmbus_rx_evtflags,
|
||||
VMBUS_CHAN_MAX_COMPAT >> VMBUS_EVTFLAG_SHIFT);
|
||||
VMBUS_CHAN_MAX_COMPAT / VMBUS_EVTFLAG_LEN);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1903,7 +1903,7 @@ vmbus_chan_msgproc_choffer(struct vmbus_softc *sc,
|
|||
* Setup event flag.
|
||||
*/
|
||||
chan->ch_evtflag =
|
||||
&sc->vmbus_tx_evtflags[chan->ch_id >> VMBUS_EVTFLAG_SHIFT];
|
||||
&sc->vmbus_tx_evtflags[chan->ch_id / VMBUS_EVTFLAG_LEN];
|
||||
chan->ch_evtflag_mask = 1UL << (chan->ch_id & VMBUS_EVTFLAG_MASK);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -60,16 +60,10 @@ CTASSERT(sizeof(struct vmbus_message) == VMBUS_MSG_SIZE);
|
|||
* Hyper-V SynIC event flags
|
||||
*/
|
||||
|
||||
#ifdef __LP64__
|
||||
#define VMBUS_EVTFLAGS_MAX 32
|
||||
#define VMBUS_EVTFLAG_SHIFT 6
|
||||
#else
|
||||
#define VMBUS_EVTFLAGS_MAX 64
|
||||
#define VMBUS_EVTFLAG_SHIFT 5
|
||||
#endif
|
||||
#define VMBUS_EVTFLAG_LEN (1 << VMBUS_EVTFLAG_SHIFT)
|
||||
#define VMBUS_EVTFLAG_LEN (sizeof(u_long) * 8)
|
||||
#define VMBUS_EVTFLAG_MASK (VMBUS_EVTFLAG_LEN - 1)
|
||||
#define VMBUS_EVTFLAGS_SIZE 256
|
||||
#define VMBUS_EVTFLAGS_MAX (VMBUS_EVTFLAGS_SIZE / sizeof(u_long))
|
||||
|
||||
struct vmbus_evtflags {
|
||||
u_long evt_flags[VMBUS_EVTFLAGS_MAX];
|
||||
|
|
|
|||
Loading…
Reference in a new issue