1139825Simp/*-
297261Sjake * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org>
397261Sjake * All rights reserved.
497261Sjake *
597261Sjake * Redistribution and use in source and binary forms, with or without
697261Sjake * modification, are permitted provided that the following conditions
797261Sjake * are met:
897261Sjake * 1. Redistributions of source code must retain the above copyright
997261Sjake *    notice, this list of conditions and the following disclaimer.
1097261Sjake * 2. Redistributions in binary form must reproduce the above copyright
1197261Sjake *    notice, this list of conditions and the following disclaimer in the
1297261Sjake *    documentation and/or other materials provided with the distribution.
1397261Sjake *
1497261Sjake * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1597261Sjake * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1697261Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1797261Sjake * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1897261Sjake * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1997261Sjake * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2097261Sjake * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2197261Sjake * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2297261Sjake * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2397261Sjake * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2497261Sjake * SUCH DAMAGE.
2597261Sjake *
2697261Sjake * $FreeBSD: releng/11.0/sys/sparc64/include/runq.h 139825 2005-01-07 02:29:27Z imp $
2797261Sjake */
2897261Sjake
2997261Sjake#ifndef	_MACHINE_RUNQ_H_
3097261Sjake#define	_MACHINE_RUNQ_H_
3197261Sjake
3297261Sjake#define	RQB_LEN		(1UL)		/* Number of priority status words. */
3397261Sjake#define	RQB_L2BPW	(6UL)		/* Log2(sizeof(rqb_word_t) * NBBY)). */
3497261Sjake#define	RQB_BPW		(1UL<<RQB_L2BPW)	/* Bits in an rqb_word_t. */
3597261Sjake
3697261Sjake#define	RQB_BIT(pri)	(1UL << ((pri) & (RQB_BPW - 1)))
3797261Sjake#define	RQB_WORD(pri)	((pri) >> RQB_L2BPW)
3897261Sjake
3998469Speter#define	RQB_FFS(word)	(ffs64(word) - 1)
4097261Sjake
4197261Sjake/*
4297261Sjake * Type of run queue status word.
4397261Sjake */
4497261Sjaketypedef	u_int64_t	rqb_word_t;
4597261Sjake
4697261Sjakestatic __inline u_long
4797261Sjakeffs64(u_long mask)
4897261Sjake{
4997261Sjake	u_long bit;
5097261Sjake
5197261Sjake	if (mask == 0)
5297261Sjake		return (0);
5397261Sjake	for (bit = 1; (mask & 1UL) == 0; bit++)
5497261Sjake		mask >>= 1UL;
5597261Sjake	return (bit);
5697261Sjake}
5797261Sjake
5897261Sjake#endif
59