VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/include/private/dict.h@ 107935

Last change on this file since 107935 was 105420, checked in by vboxsync, 8 months ago

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

File size: 1.7 KB
Line 
1#ifndef XML_DICT_H_PRIVATE__
2#define XML_DICT_H_PRIVATE__
3
4#include <libxml/dict.h>
5
6/*
7 * Values are ANDed with 0xFFFFFFFF to support platforms where
8 * unsigned is larger than 32 bits. With 32-bit unsigned values,
9 * modern compilers should optimize the operation away.
10 */
11
12#define HASH_ROL(x,n) ((x) << (n) | ((x) & 0xFFFFFFFF) >> (32 - (n)))
13#define HASH_ROR(x,n) (((x) & 0xFFFFFFFF) >> (n) | (x) << (32 - (n)))
14
15/*
16 * GoodOAAT: One of a smallest non-multiplicative One-At-a-Time functions
17 * that passes SMHasher.
18 *
19 * Author: Sokolov Yura aka funny-falcon
20 */
21
22#define HASH_INIT(h1, h2, seed) \
23 do { \
24 h1 = seed ^ 0x3b00; \
25 h2 = HASH_ROL(seed, 15); \
26 } while (0)
27
28#define HASH_UPDATE(h1, h2, ch) \
29 do { \
30 h1 += ch; \
31 h1 += h1 << 3; \
32 h2 += h1; \
33 h2 = HASH_ROL(h2, 7); \
34 h2 += h2 << 2; \
35 } while (0)
36
37/* Result is in h2 */
38#define HASH_FINISH(h1, h2) \
39 do { \
40 h1 ^= h2; \
41 h1 += HASH_ROL(h2, 14); \
42 h2 ^= h1; h2 += HASH_ROR(h1, 6); \
43 h1 ^= h2; h1 += HASH_ROL(h2, 5); \
44 h2 ^= h1; h2 += HASH_ROR(h1, 8); \
45 h2 &= 0xFFFFFFFF; \
46 } while (0)
47
48typedef struct {
49 unsigned hashValue;
50 const xmlChar *name;
51} xmlHashedString;
52
53XML_HIDDEN void
54xmlInitDictInternal(void);
55XML_HIDDEN void
56xmlCleanupDictInternal(void);
57
58XML_HIDDEN unsigned
59xmlDictComputeHash(const xmlDict *dict, const xmlChar *string);
60XML_HIDDEN unsigned
61xmlDictCombineHash(unsigned v1, unsigned v2);
62XML_HIDDEN xmlHashedString
63xmlDictLookupHashed(xmlDictPtr dict, const xmlChar *name, int len);
64
65XML_HIDDEN void
66xmlInitRandom(void);
67XML_HIDDEN void
68xmlCleanupRandom(void);
69XML_HIDDEN unsigned
70xmlGlobalRandom(void);
71XML_HIDDEN unsigned
72xmlRandom(void);
73
74#endif /* XML_DICT_H_PRIVATE__ */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette