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/dev/vmware/vmci/vmci_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) 2018 VMware, Inc.
    3  *
    4  * SPDX-License-Identifier: (BSD-2-Clause OR GPL-2.0)
    5  *
    6  * $FreeBSD$
    7  */
    8 
    9 /* Some common utilities used by the VMCI kernel module. */
   10 
   11 #ifndef _VMCI_UTILS_H_
   12 #define _VMCI_UTILS_H_
   13 
   14 /*
   15  *------------------------------------------------------------------------------
   16  *
   17  * vmci_hash_id --
   18  *
   19  *     Hash function used by the Simple Datagram API. Hashes only a VMCI ID (not
   20  *     the full VMCI handle). Based on the djb2 hash function by Dan Bernstein.
   21  *
   22  * Result:
   23  *     Returns guest call size.
   24  *
   25  * Side effects:
   26  *     None.
   27  *
   28  *------------------------------------------------------------------------------
   29  */
   30 
   31 static inline int
   32 vmci_hash_id(vmci_id id, unsigned size)
   33 {
   34         unsigned i;
   35         int hash = 5381;
   36 
   37         for (i = 0; i < sizeof(id); i++)
   38                 hash = ((hash << 5) + hash) + (uint8_t)(id >> (i * 8));
   39 
   40         return (hash & (size - 1));
   41 }
   42 
   43 #endif /* !_VMCI_UTILS_H_ */

Cache object: ae65eaf6a463aa00121c7affe68b59af


[ 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.