<commit_before>/*
 * Project:     libFIRM
 * File name:   ir/adt/hashptr.h
 * Purpose:     Hash function for pointers
 * Author:      <NAME>, <NAME>
 * Modified by:
 * Created:     2004
 * CVS-ID:      $Id$
 * Copyright:   (C) 2004 University of Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */
#ifndef __HASHPTR_H__
#define __HASHPTR_H__

/**
 * hash a pointer value: Pointer addresses are mostly aligned to 4
 * or 8 bytes. So we remove the lowest 3 bits
 */
#define HASH_PTR(ptr)    (((char *)ptr - (char *)0) >> 3)

#endif /* __HASHPTR_H__ */<commit_msg>Added proper string hash function.<commit_after>/*
 * Project:     libFIRM
 * File name:   ir/adt/hashptr.h
 * Purpose:     Hash function for pointers
 * Author:      <NAME>, <NAME>
 * Modified by:
 * Created:     2004
 * CVS-ID:      $Id$
 * Copyright:   (C) 2004 University of Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */
#ifndef __HASHPTR_H__
#define __HASHPTR_H__

#include "firm_config.h"

#define _FIRM_FNV_OFFSET_BASIS 2166136261
#define _FIRM_FNV_FNV_PRIME 16777619

static INLINE unsigned firm_fnv_hash(const unsigned char *data, unsigned bytes)
{
	unsigned i;
	unsigned hash = _FIRM_FNV_OFFSET_BASIS;

	for(i = 0; i < bytes; ++i) {
		hash *= _FIRM_FNV_FNV_PRIME;
		hash ^= data[i];
	}

	return hash;
}

/**
 * hash a pointer value: Pointer addresses are mostly aligned to 4
 * or 8 bytes. So we remove the lowest 3 bits
 */
#define HASH_PTR(ptr)    (((char *) (ptr) - (char *)0) >> 3)

/**
 * Hash a string.
 * @param str The string (can be const).
 * @param len The length of the string.
 * @return A hash value for the string.
 */
#define HASH_STR(str,len) firm_fnv_hash((const unsigned char *) (str), (len))

#endif /* __HASHPTR_H__ */
{'fraction_non_alphanumeric': 0.11912751677852348, 'fraction_numerical': 0.025167785234899327, 'mean_word_length': 3.300480769230769, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7082414', 'n_tokens_mistral': 680, 'n_tokens_neox': 631, 'n_words': 208}