Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
h_func.c File Reference
#include "watcomfx.h"
#include <sys/types.h>
#include "mcom_db.h"
#include "hash.h"
#include "page.h"

Go to the source code of this file.

Defines

#define PRIME1   37
#define PRIME2   1048583
#define HASH4a   h = (h << 5) - h + *key++;
#define HASH4b   h = (h << 5) + h + *key++;
#define HASH4   HASH4b

Functions

static uint32 hash4 __P ((const void *, size_t)) = hash4
static uint32 hash4 (const void *keyarg, register size_t len)

Define Documentation

#define HASH4a   h = (h << 5) - h + *key++;
#define HASH4b   h = (h << 5) + h + *key++;
#define PRIME1   37

Definition at line 68 of file h_func.c.

#define PRIME2   1048583

Definition at line 69 of file h_func.c.


Function Documentation

uint32 __default_hash __P ( (const void *, size_t)  ) = hash4 [static]
static uint32 hash4 ( const void keyarg,
register size_t  len 
) [static]

Definition at line 165 of file h_func.c.

{
       register const uint8 *key;
       register size_t loop;
       register uint32 h;

#define HASH4a   h = (h << 5) - h + *key++;
#define HASH4b   h = (h << 5) + h + *key++;
#define HASH4 HASH4b

       h = 0;
       key = (const uint8 *)keyarg;
       if (len > 0) {
              loop = (len + 8 - 1) >> 3;

              switch (len & (8 - 1)) {
              case 0:
                     do {
                            HASH4;
                            /* FALLTHROUGH */
              case 7:
                            HASH4;
                            /* FALLTHROUGH */
              case 6:
                            HASH4;
                            /* FALLTHROUGH */
              case 5:
                            HASH4;
                            /* FALLTHROUGH */
              case 4:
                            HASH4;
                            /* FALLTHROUGH */
              case 3:
                            HASH4;
                            /* FALLTHROUGH */
              case 2:
                            HASH4;
                            /* FALLTHROUGH */
              case 1:
                            HASH4;
                     } while (--loop);
              }
       }
       return (h);
}

Here is the call graph for this function: