From 4830c346487d0f10f6ee751a4b5951e6e6688d03 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 20 Jun 2002 06:21:20 +0000 Subject: [PATCH] Move the "- 1" into the RQB_FFS(mask) macro itself so that implementations can provide a base zero ffs function if they wish. This changes #define RQB_FFS(mask) (ffs64(mask)) foo = RQB_FFS(mask) - 1; to #define RQB_FFS(mask) (ffs64(mask) - 1) foo = RQB_FFS(mask); On some platforms we can get the "- 1" for free, eg: those that use the C code for ffs64(). Reviewed by: jake (in principle) --- sys/alpha/include/runq.h | 2 +- sys/amd64/include/runq.h | 2 +- sys/i386/include/runq.h | 2 +- sys/ia64/include/runq.h | 2 +- sys/kern/kern_switch.c | 3 +-- sys/powerpc/include/runq.h | 2 +- sys/sparc64/include/runq.h | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sys/alpha/include/runq.h b/sys/alpha/include/runq.h index 3fc658afaa22..9f844b69fe5f 100644 --- a/sys/alpha/include/runq.h +++ b/sys/alpha/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1UL << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs64(word)) +#define RQB_FFS(word) (ffs64(word) - 1) /* * Type of run queue status word. diff --git a/sys/amd64/include/runq.h b/sys/amd64/include/runq.h index 1ea7735631bc..2a21bfa4ca29 100644 --- a/sys/amd64/include/runq.h +++ b/sys/amd64/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs(word)) +#define RQB_FFS(word) (ffs(word) - 1) /* * Type of run queue status word. diff --git a/sys/i386/include/runq.h b/sys/i386/include/runq.h index 1ea7735631bc..2a21bfa4ca29 100644 --- a/sys/i386/include/runq.h +++ b/sys/i386/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs(word)) +#define RQB_FFS(word) (ffs(word) - 1) /* * Type of run queue status word. diff --git a/sys/ia64/include/runq.h b/sys/ia64/include/runq.h index 3fc658afaa22..9f844b69fe5f 100644 --- a/sys/ia64/include/runq.h +++ b/sys/ia64/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1UL << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs64(word)) +#define RQB_FFS(word) (ffs64(word) - 1) /* * Type of run queue status word. diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index 2c6e6f62aa6c..2b531c0dae3d 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -129,8 +129,7 @@ runq_findbit(struct runq *rq) rqb = &rq->rq_status; for (i = 0; i < RQB_LEN; i++) if (rqb->rqb_bits[i]) { - pri = (RQB_FFS(rqb->rqb_bits[i]) - 1) + - (i << RQB_L2BPW); + pri = RQB_FFS(rqb->rqb_bits[i]) + (i << RQB_L2BPW); CTR3(KTR_RUNQ, "runq_findbit: bits=%#x i=%d pri=%d", rqb->rqb_bits[i], i, pri); return (pri); diff --git a/sys/powerpc/include/runq.h b/sys/powerpc/include/runq.h index 1ea7735631bc..2a21bfa4ca29 100644 --- a/sys/powerpc/include/runq.h +++ b/sys/powerpc/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs(word)) +#define RQB_FFS(word) (ffs(word) - 1) /* * Type of run queue status word. diff --git a/sys/sparc64/include/runq.h b/sys/sparc64/include/runq.h index 3fc658afaa22..9f844b69fe5f 100644 --- a/sys/sparc64/include/runq.h +++ b/sys/sparc64/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1UL << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs64(word)) +#define RQB_FFS(word) (ffs64(word) - 1) /* * Type of run queue status word.