Annotation of Gnu-Mach/include/mach/proc_ops.h, revision 1.1

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: /*
        !            21:  * Simple operations that don't exist as primitives in C,
        !            22:  * but which processors often implement directly.
        !            23:  * This file contains default, "dumb" implementations;
        !            24:  * machine-independent code can override these with smarter implementations.
        !            25:  */
        !            26: #ifndef _MACH_PROC_OPS_H_
        !            27: #define _MACH_PROC_OPS_H_
        !            28: 
        !            29: #include <mach/machine/vm_types.h>
        !            30: #include <mach/inline.h>
        !            31: 
        !            32: /* Returns the bit number of the most-significant set bit in `val',
        !            33:    e.g. 0 for 1, 1 for 2-3, 2 for 4-7, etc.
        !            34:    If `val' is 0 (i.e. no bits are set), the behavior is undefined.  */
        !            35: MACH_INLINE int find_msb_set(natural_t val)
        !            36: {
        !            37:        int msb;
        !            38:        for (msb = sizeof(val)*8-1; (val & ((natural_t)1 << msb)) == 0; msb--);
        !            39:        return msb;
        !            40: }
        !            41: 
        !            42: /* Returns the bit number of the least-significant set bit in `val'.
        !            43:    If `val' is 0 (i.e. no bits are set), the behavior is undefined.  */
        !            44: MACH_INLINE int find_lsb_set(natural_t val)
        !            45: {
        !            46:        int lsb;
        !            47:        for (lsb = 0; (val & ((natural_t)1 << lsb)) == 0; lsb++);
        !            48:        return lsb;
        !            49: }
        !            50: 
        !            51: #endif _MACH_PROC_OPS_H_

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.