The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/mips/rmi/perfmon_utils.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2003-2009 RMI Corporation
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 3. Neither the name of RMI Corporation, nor the names of its contributors,
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * RMI_BSD */
   30 
   31 #ifndef UTILS_H
   32 #define UTILS_H
   33 
   34 #include <machine/stdarg.h>     /* variable args */
   35 
   36 /* TODO optimize of mips, even i & (i-1) is better */
   37 
   38 static int __inline__ 
   39 get_set_bit_count64(uint64_t value)
   40 {
   41         int i, result = 0;
   42 
   43         for (i = 0; i < sizeof(value) * 8; i++)
   44                 if (value & (1ULL << i))
   45                         result++;
   46 
   47         return result;
   48 }
   49 
   50 static int __inline__ 
   51 find_first_set_bit64(uint64_t value)
   52 {
   53         int i;
   54 
   55         for (i = 0; i < sizeof(value) * 8; i++)
   56                 if (value & (1ULL << i))
   57                         return i;
   58 
   59         return -1;
   60 }
   61 
   62 static int __inline__ 
   63 find_next_set_bit64(uint64_t value, int pos)
   64 {
   65         int i;
   66 
   67         for (i = pos + 1; i < sizeof(value) * 8; i++)
   68                 if (value & (1ULL << i))
   69                         return i;
   70 
   71         return -1;
   72 }
   73 
   74 /** ---  **/
   75 
   76 static int __inline__ 
   77 get_set_bit_count(uint32_t value)
   78 {
   79         int i, result = 0;
   80 
   81         for (i = 0; i < sizeof(value) * 8; i++)
   82                 if (value & (1U << i))
   83                         result++;
   84 
   85         return result;
   86 }
   87 
   88 static int __inline__ 
   89 find_first_set_bit(uint32_t value)
   90 {
   91         int i;
   92 
   93         for (i = 0; i < sizeof(value) * 8; i++)
   94                 if (value & (1U << i))
   95                         return i;
   96 
   97         return -1;
   98 }
   99 
  100 static int __inline__ 
  101 find_next_set_bit(uint32_t value, int pos)
  102 {
  103         int i;
  104 
  105         for (i = pos + 1; i < sizeof(value) * 8; i++)
  106                 if (value & (1U << i))
  107                         return i;
  108 
  109         return -1;
  110 }
  111 
  112 #ifdef DEBUG
  113 void abort();
  114 
  115 #define DPUTC(c)         (putchar(c) && fflush(stdout))
  116 #define DPRINT(fmt, ...) printf(fmt "\n", __VA_ARGS__)
  117 #define ASSERT(x)   ((x) || ({ printf("%s failed at (%s:%d)", #x, __FILE__, __LINE__) ; abort(); 0; }) )
  118 #else
  119 #define DPUTC(c)
  120 #define DPRINT(fmt, ...)
  121 #define ASSERT(x)
  122 #endif
  123 
  124 void xlr_send_sample(uint32_t tag, uint32_t value, uint32_t ts, uint32_t td);
  125 
  126 #endif

Cache object: 8c693f236f122d958b6394426e7a424f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.