|
|
1.1 root 1: /*
2: * Copyright (c) 1994 The University of Utah and
3: * the Center for Software Science (CSS). All rights reserved.
4: *
5: * Permission to use, copy, modify and distribute this software and its
6: * documentation is hereby granted, provided that both the copyright
7: * notice and this permission notice appear in all copies of the
8: * software, derivative works or modified versions, and any portions
9: * thereof, and that both notices appear in supporting documentation.
10: *
11: * THE UNIVERSITY OF UTAH AND CSS ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
12: * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSS DISCLAIM ANY LIABILITY OF
13: * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
14: *
15: * CSS requests users of this software to return to [email protected] any
16: * improvements that they make and grant CSS redistribution rights.
17: *
18: * Author: Bryan Ford, University of Utah CSS
19: */
20: #ifndef _MACH_I386_PROC_OPS_H_
21: #define _MACH_I386_PROC_OPS_H_
22:
23: #include <mach/machine/vm_types.h>
24: #include <mach/inline.h>
25:
26: /* Returns the bit number of the most-significant set bit in `val',
27: e.g. 0 for 1, 1 for 2-3, 2 for 4-7, etc.
28: If `val' is 0 (i.e. no bits are set), the behavior is undefined. */
29: MACH_INLINE int find_msb_set(natural_t val)
30: {
31: int msb;
32:
33: asm("
34: bsr %0,%0
35: " : "=r" (msb) : "0" (val));
36:
37: return msb;
38: }
39:
40: #endif _MACH_I386_PROC_OPS_H_
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.