erwin/map.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 #ifdef ERWIN_DEBUG_INCLUDE
53 #warning "Including map.h."
54 #endif
55
56 #ifndef Global_ERWIN_MAP_H
57 #define Global_ERWIN_MAP_H
58
59 #ifdef ERWIN_DEBUG_INCLUDE
60 #warning "First inclusion of map.h."
61 #endif
62
63 #ifdef Global_ERWIN_COMPILING
64 #include "--INCPREF2B--erwin/defs.h"
65 #else
66 #include <--INCPREF2B--erwin/defs.h>
67 #endif
68
69 #ifdef Global_ERWIN_ADAM_NAME
70
71 #COPYNAME char_to_upper
72 #COPYNAME char_to_lower
73 #COPYNAME erwin_random_table
74 #COPYNAME erwin_mapinitialised
75 #COPYNAME char_hash
76 #COPYNAME char_hash2
77 #COPYNAME char_hash3
78 #COPYNAME char_hash4
79 #COPYNAME char_case_hash
80 #COPYNAME char_case_hash2
81 #COPYNAME char_case_hash3
82 #COPYNAME char_case_hash4
83 #COPYNAME long_hash
84 #COPYNAME int_hash
85 #COPYNAME short_hash
86 #COPYNAME hash_voidp
87 #COPYNAME string_hash
88 #COPYNAME string_case_hash
89 #COPYNAME erwininternalmaperrno
90 #COPYNAME erwininternalmapstrerror
91 #COPYNAME ERWININTERNALMAPOK
92 #COPYNAME ERWININTERNALMAPISOK
93 #COPYNAME ERWININTERNALMAPISERROR
94 #COPYNAME ERWININTERNALMAPISWARNING
95 #COPYNAME ERWININTERNALMAPERRNOMEM
96 #COPYNAME ERWININTERNALMAPERRASSERTIONFAILED
97 #COPYNAME ERWININTERNALMAPWARNEMPTY
98 #COPYNAME ERWININTERNALMAPWARNNOMOREELEMS
99 #COPYNAME ERWININTERNALMAPWARNEXISTINGKEY
100 #COPYNAME ERWININTERNALMAPWARNKEYNOTFOUND
101 #COPYNAME ERWININTERNALMAPREHASHNOMEM
102 #COPYNAME ERWININTERNALMAPREHASHDUPLICATEKEY
103 #COPYNAME ERWININTERNALMAPREHASHRECURSION
104
105 #else
106
107 #ifdef __cplusplus
108 extern "C" {
109 #endif
110
111
112 extern char Global_char_to_upper (char) ATTR_CONST;
113 extern char Global_char_to_lower (char) ATTR_CONST;
114
115 #define Global_erwin_toupper Global_char_to_upper
116 #define Global_erwin_tolower Global_char_to_lower
117
118 extern Global_ERWIN_BOOL Global_erwin_mapinitialised;
119
120
121
122 #ifdef Global_ERWIN_REQUIRE_DETERMINISM
123 typedef Global_hashval_t const Global_erwin_random_table_t[256];
124 #else
125 typedef Global_hashval_t Global_erwin_random_table_t[256];
126 #endif
127
128 #if Global_ERWIN_HASH_STRENGTH >= 1
129 extern Global_erwin_random_table_t Global_erwin_random_table;
130 extern Global_erwin_random_table_t Global_erwin_random_table2;
131 #if Global_ERWIN_HASH_STRENGTH >= 3
132 extern Global_erwin_random_table_t Global_erwin_random_table3;
133 extern Global_erwin_random_table_t Global_erwin_random_table4;
134 #endif
135 #endif
136
137
138 #ifdef Global_ERWIN_COMPAT_2_0_236
139 # define Global_hash_char Global_char_hash
140 # define Global_hash_char_case Global_char_case_hash
141 # define Global_hash_long Global_long_hash
142 # define Global_hash_int Global_int_hash
143 # define Global_hash_short Global_short_hash
144 # define Global_hash_string Global_string_hash
145 # define Global_hash_string_case Global_string_case_hash
146 #endif
147
148 #define Global_erwin_hash0(X) (((((Global_hashval_t)(X)) * 3) + \
149 (((Global_hashval_t)(X)) * 7131) + \
150 (((Global_hashval_t)(X)) * 9111371)) ^ \
151 (((Global_hashval_t)(X)) * 755543))
152
153
154 ERWIN_WRAPPER Global_hashval_t Global_char_hash(unsigned char x) ATTR_PURE;
155 ERWIN_WRAPPER Global_hashval_t Global_char_hash(unsigned char x)
156 {
157 #if Global_ERWIN_HASH_STRENGTH >= 1
158 return Global_erwin_random_table[x];
159 #else
160 return Global_erwin_hash0(x);
161 #endif
162 }
163
164 #define Global_unsigned_char_hash Global_char_hash
165 #define Global_signed_char_hash Global_char_hash
166
167 ERWIN_WRAPPER Global_hashval_t Global_char_hash2(unsigned char x) ATTR_PURE;
168 ERWIN_WRAPPER Global_hashval_t Global_char_hash2(unsigned char x)
169 {
170 #if Global_ERWIN_HASH_STRENGTH >= 1
171 return Global_erwin_random_table2[x];
172 #else
173 return Global_char_hash (x);
174 #endif
175 }
176
177 ERWIN_WRAPPER Global_hashval_t Global_char_hash3(unsigned char x) ATTR_PURE;
178 ERWIN_WRAPPER Global_hashval_t Global_char_hash3(unsigned char x)
179 {
180 #if Global_ERWIN_HASH_STRENGTH >= 3
181 return Global_erwin_random_table3[x];
182 #else
183 return Global_char_hash (x);
184 #endif
185 }
186
187 ERWIN_WRAPPER Global_hashval_t Global_char_hash4(unsigned char x) ATTR_PURE;
188 ERWIN_WRAPPER Global_hashval_t Global_char_hash4(unsigned char x)
189 {
190 #if Global_ERWIN_HASH_STRENGTH >= 3
191 return Global_erwin_random_table4[x];
192 #else
193 return Global_char_hash2 (x);
194 #endif
195 }
196
197
198 ERWIN_WRAPPER Global_hashval_t Global_erwin_mul9 (Global_hashval_t x) ATTR_CONST;
199 ERWIN_WRAPPER Global_hashval_t Global_erwin_mul9 (Global_hashval_t x)
200 {
201 return x + (x << 3);
202
203 }
204
205 #ifndef Global_erwin_mul_x1_defined
206
207
208 ERWIN_WRAPPER Global_hashval_t Global_erwin_mul_x1 (Global_hashval_t x) ATTR_CONST;
209 ERWIN_WRAPPER Global_hashval_t Global_erwin_mul_x1 (Global_hashval_t x)
210 {
211 #if Global_SIZEOF_HASHVAL_T == 8 && defined(ERWIN_U64)
212 return x * ERWIN_U64_C(0x0000800200400081);
213 #else
214 return x * 0x400081;
215
216
217
218
219
220 #endif
221 }
222
223 #endif
224
225
226
227
228
229
230
231
232
233 #ifndef Global_erwin_u16_hash_defined
234
235 ERWIN_WRAPPER Global_hashval_t Global_erwin_u16_hash (ERWIN_U16 x) ATTR_PURE;
236 ERWIN_WRAPPER Global_hashval_t Global_erwin_u16_hash (ERWIN_U16 x)
237 {
238 Global_hashval_t y= x;
239
240 y^= Global_erwin_swap16(x) << 1;
241 y+= Global_char_hash ((unsigned char)y);
242 y= Global_erwin_mul_x1 (y);
243 y^= Global_char_hash2 ((unsigned char)(y >> 8));
244
245 return y;
246 }
247
248 #endif
249
250 #ifndef Global_erwin_u32_hash_defined
251
252 ERWIN_WRAPPER Global_hashval_t Global_erwin_u32_hash (ERWIN_U32 x) ATTR_PURE;
253 ERWIN_WRAPPER Global_hashval_t Global_erwin_u32_hash (ERWIN_U32 x)
254 {
255 Global_hashval_t y= x;
256
257 y^= Global_erwin_swap_low32(y) << 1;
258 y+= Global_char_hash ((unsigned char)y);
259 y= Global_erwin_mul_x1 (y);
260 y^= Global_char_hash2 ((unsigned char)(y >> 8));
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289 return y;
290 }
291
292 #endif
293
294 #ifdef ERWIN_U64
295 #ifndef Global_erwin_u64_hash_defined
296
297 ERWIN_WRAPPER Global_hashval_t Global_erwin_u64_hash (ERWIN_U64 x) ATTR_PURE;
298 ERWIN_WRAPPER Global_hashval_t Global_erwin_u64_hash (ERWIN_U64 x)
299 {
300 Global_hashval_t y;
301
302 #if defined(Global_ERWIN_REQUIRE_DETERMINISM)
303
304
305
306
307 y= Global_erwin_u32_hash((ERWIN_U32)x);
308 {
309 ERWIN_U32 x32= (ERWIN_U32)(x >> 32);
310 if (x32 && ~x32) {
311 y^= Global_erwin_swap_low32 (x32) << 1;
312 y+= Global_char_hash3 ((unsigned char)y);
313 y= Global_erwin_mul_x1 (y);
314 y^= Global_char_hash4 ((unsigned char)(y >> 8));
315 }
316 }
317
318 #else
319
320 y= (Global_hashval_t)x;
321
322 #if Global_SIZEOF_HASHVAL_T == 8
323 y^= Global_erwin_swap64(y) << 1;
324 #else
325 y^= Global_erwin_swap_low32(y) << 1;
326 y^= Global_erwin_swap_low32((Global_hashval_t)(x >> 32)) << 3;
327 #endif
328 y+= Global_char_hash ((unsigned char)y);
329 y= Global_erwin_mul_x1 (y);
330 y^= Global_char_hash2 ((unsigned char)(y >> 8));
331
332 #endif
333
334 return y;
335 }
336
337 #endif
338 #endif
339
340 ERWIN_WRAPPER Global_hashval_t Global_short_hash (unsigned short x) ATTR_PURE;
341 ERWIN_WRAPPER Global_hashval_t Global_short_hash (unsigned short x)
342 {
343 return Global_erwin_u16_hash (x);
344 }
345
346 #define Global_unsigned_short_hash Global_short_hash
347
348 ERWIN_WRAPPER Global_hashval_t Global_int_hash(unsigned int x) ATTR_PURE;
349 ERWIN_WRAPPER Global_hashval_t Global_int_hash(unsigned int x)
350 {
351 #if SIZEOF_INT == 8 && defined(ERWIN_U64)
352 return Global_erwin_u64_hash (x);
353 #elif SIZEOF_INT == 2
354 return Global_erwin_u16_hash (x);
355 #else
356 return Global_erwin_u32_hash (x);
357 #endif
358 }
359
360 #define Global_unsigned_hash Global_int_hash
361
362 ERWIN_WRAPPER Global_hashval_t Global_long_hash(unsigned long x) ATTR_PURE;
363 ERWIN_WRAPPER Global_hashval_t Global_long_hash(unsigned long x)
364 {
365 #if SIZEOF_LONG == 8 && defined(ERWIN_U64)
366 return Global_erwin_u64_hash (x);
367 #else
368 return Global_erwin_u32_hash (x);
369 #endif
370 }
371
372 #define Global_unsigned_long_hash Global_long_hash
373
374 #if defined(ERWIN_UNSIGNED_LONG_LONG) && defined(ERWIN_U64)
375
376 ERWIN_WRAPPER Global_hashval_t Global_long_long_hash(ERWIN_UNSIGNED_LONG_LONG x) ATTR_PURE;
377 ERWIN_WRAPPER Global_hashval_t Global_long_long_hash(ERWIN_UNSIGNED_LONG_LONG x)
378 {
379 return Global_erwin_u64_hash (x);
380 }
381
382 #define Global_unsigned_long_long_hash Global_long_long_hash
383
384 #endif
385
386 ERWIN_WRAPPER Global_hashval_t Global_voidp_hash (void const *x) ATTR_PURE;
387 ERWIN_WRAPPER Global_hashval_t Global_voidp_hash (void const *x)
388 {
389 #if SIZEOF_VOIDP == SIZEOF_LONG
390 return Global_long_hash ((unsigned long)x);
391 #else
392 return Global_int_hash ((unsigned int)x);
393 #endif
394 }
395
396 ERWIN_WRAPPER Global_hashval_t Global_size_t_hash(size_t x) ATTR_PURE;
397 ERWIN_WRAPPER Global_hashval_t Global_size_t_hash(size_t x)
398 {
399 #if SIZEOF_SIZE_T == 8 && defined(ERWIN_U64)
400 return Global_erwin_u64_hash (x);
401 #elif SIZEOF_SIZE_T == 2
402 return Global_erwin_u16_hash (x);
403 #else
404 return Global_erwin_u32_hash (x);
405 #endif
406 }
407
408
409
410 ERWIN_WRAPPER Global_hashval_t Global_hash_voidp (void const *x) ATTR_PURE ATTR_DEPRECATED;
411 ERWIN_WRAPPER Global_hashval_t Global_hash_voidp (void const *x)
412 {
413 return Global_voidp_hash (x);
414 }
415
416 ERWIN_WRAPPER Global_hashval_t Global_char_case_hash(unsigned char x) ATTR_PURE;
417 ERWIN_WRAPPER Global_hashval_t Global_char_case_hash(unsigned char x)
418 {
419 return Global_char_hash ((unsigned char)Global_char_to_lower((char)x));
420 }
421
422 #define Global_unsigned_char_case_hash Global_char_case_hash
423 #define Global_signed_char_case_hash Global_char_case_hash
424
425
426 ERWIN_WRAPPER Global_hashval_t Global_char_case_hash2(unsigned char x) ATTR_PURE;
427 ERWIN_WRAPPER Global_hashval_t Global_char_case_hash2(unsigned char x)
428 {
429 return Global_char_hash2 ((unsigned char)Global_char_to_lower((char)x));
430 }
431
432 ERWIN_WRAPPER Global_hashval_t Global_char_case_hash3(unsigned char x) ATTR_PURE;
433 ERWIN_WRAPPER Global_hashval_t Global_char_case_hash3(unsigned char x)
434 {
435 return Global_char_hash3 ((unsigned char)Global_char_to_lower((char)x));
436 }
437
438 ERWIN_WRAPPER Global_hashval_t Global_char_case_hash4(unsigned char x) ATTR_PURE;
439 ERWIN_WRAPPER Global_hashval_t Global_char_case_hash4(unsigned char x)
440 {
441 return Global_char_hash4 ((unsigned char)Global_char_to_lower((char)x));
442 }
443
444 ERWIN_WRAPPER Global_hashval_t Global_erwin_make_hash_result(
445 Global_hashval_t, Global_hashval_t) ATTR_PURE;
446
447 ERWIN_WRAPPER Global_hashval_t Global_erwin_make_hash_result(
448 Global_hashval_t h1, Global_hashval_t h2)
449 {
450 #if Global_SIZEOF_HASHVAL_T == 4 && defined(ERWIN_U64)
451 return Global_erwin_u64_hash (((ERWIN_U64)h1) + (((ERWIN_U64)h2) << 32));
452 #else
453 Global_hashval_t y;
454
455 y= h1;
456 y^= Global_char_hash4 ((unsigned char)(y >> 8));
457 y+= h2;
458 y^= Global_erwin_swap (y) << 1;
459 y+= Global_char_hash3 ((unsigned char)y);
460
461 return y;
462 #endif
463 }
464
465
466
467
468 extern Global_hashval_t Global_erwin_u8_array_hash (ERWIN_U8 const *, size_t) ATTR_PURE;
469 extern Global_hashval_t Global_erwin_u8_array_case_hash (ERWIN_U8 const *, size_t) ATTR_PURE;
470 extern Global_hashval_t Global_erwin_u16_array_hash (ERWIN_U16 const *, size_t) ATTR_PURE;
471 extern Global_hashval_t Global_erwin_u32_array_hash (ERWIN_U32 const *, size_t) ATTR_PURE;
472
473 #ifdef ERWIN_U64
474 extern Global_hashval_t Global_erwin_u64_array_hash (ERWIN_U64 const *, size_t) ATTR_PURE;
475 #endif
476
477 ERWIN_WRAPPER Global_hashval_t Global_erwin_s8_array_hash (ERWIN_S8 const *x, size_t s) ATTR_PURE;
478 ERWIN_WRAPPER Global_hashval_t Global_erwin_s8_array_hash (ERWIN_S8 const *x, size_t s)
479 {
480 return Global_erwin_u8_array_hash((ERWIN_U8*)x,s);
481 }
482
483 ERWIN_WRAPPER Global_hashval_t Global_erwin_s8_array_case_hash (ERWIN_S8 const *x, size_t s) ATTR_PURE;
484 ERWIN_WRAPPER Global_hashval_t Global_erwin_s8_array_case_hash (ERWIN_S8 const *x, size_t s)
485 {
486 return Global_erwin_u8_array_case_hash ((ERWIN_U8*)x,s);
487 }
488
489 ERWIN_WRAPPER Global_hashval_t Global_erwin_s16_array_hash (ERWIN_S16 const *x, size_t s) ATTR_PURE;
490 ERWIN_WRAPPER Global_hashval_t Global_erwin_s16_array_hash (ERWIN_S16 const *x, size_t s)
491 {
492 return Global_erwin_u16_array_hash((ERWIN_U16*)x,s);
493 }
494
495 ERWIN_WRAPPER Global_hashval_t Global_erwin_s32_array_hash (ERWIN_S32 const *x, size_t s) ATTR_PURE;
496 ERWIN_WRAPPER Global_hashval_t Global_erwin_s32_array_hash (ERWIN_S32 const *x, size_t s)
497 {
498 return Global_erwin_u32_array_hash((ERWIN_U32*)x,s);
499 }
500
501 #if defined(ERWIN_U64) && defined(ERWIN_S64)
502 ERWIN_WRAPPER Global_hashval_t Global_erwin_s64_array_hash (ERWIN_S64 const *x, size_t s) ATTR_PURE;
503 ERWIN_WRAPPER Global_hashval_t Global_erwin_s64_array_hash (ERWIN_S64 const *x, size_t s)
504 {
505 return Global_erwin_u64_array_hash((ERWIN_U64*)x,s);
506 }
507 #endif
508
509 ERWIN_WRAPPER Global_hashval_t Global_erwin_u8_hash (ERWIN_S8 x) ATTR_PURE;
510 ERWIN_WRAPPER Global_hashval_t Global_erwin_u8_hash (ERWIN_S8 x)
511 {
512 return Global_char_hash((ERWIN_U8)x);
513 }
514
515 ERWIN_WRAPPER Global_hashval_t Global_erwin_u8_hash_case (ERWIN_S8 x) ATTR_PURE;
516 ERWIN_WRAPPER Global_hashval_t Global_erwin_u8_hash_case (ERWIN_S8 x)
517 {
518 return Global_char_case_hash ((ERWIN_U8)x);
519 }
520
521 ERWIN_WRAPPER Global_hashval_t Global_erwin_s8_hash (ERWIN_S8 x) ATTR_PURE;
522 ERWIN_WRAPPER Global_hashval_t Global_erwin_s8_hash (ERWIN_S8 x)
523 {
524 return Global_char_hash((ERWIN_U8)x);
525 }
526
527 ERWIN_WRAPPER Global_hashval_t Global_erwin_s8_hash_case (ERWIN_S8 x) ATTR_PURE;
528 ERWIN_WRAPPER Global_hashval_t Global_erwin_s8_hash_case (ERWIN_S8 x)
529 {
530 return Global_char_case_hash ((ERWIN_U8)x);
531 }
532
533 ERWIN_WRAPPER Global_hashval_t Global_erwin_s16_hash (ERWIN_S16 x) ATTR_PURE;
534 ERWIN_WRAPPER Global_hashval_t Global_erwin_s16_hash (ERWIN_S16 x)
535 {
536 return Global_erwin_u16_hash((ERWIN_U16)x);
537 }
538
539 ERWIN_WRAPPER Global_hashval_t Global_erwin_s32_hash (ERWIN_S32 x) ATTR_PURE;
540 ERWIN_WRAPPER Global_hashval_t Global_erwin_s32_hash (ERWIN_S32 x)
541 {
542 return Global_erwin_u32_hash((ERWIN_U32)x);
543 }
544
545 #if defined(ERWIN_U64) && defined(ERWIN_S64)
546 ERWIN_WRAPPER Global_hashval_t Global_erwin_s64_hash (ERWIN_S64 const x) ATTR_PURE;
547 ERWIN_WRAPPER Global_hashval_t Global_erwin_s64_hash (ERWIN_S64 const x)
548 {
549 return Global_erwin_u64_hash((ERWIN_U64)x);
550 }
551 #endif
552
553
554 #define Global_erwin_char_array_hash(x,s) Global_erwin_u8_array_hash((ERWIN_U8 const *)x,s)
555
556 #if SIZEOF_SHORT == 2
557 #define Global_erwin_short_array_hash(x,s) Global_erwin_u16_array_hash((ERWIN_U16 const *)x,s)
558 #endif
559
560 #if SIZEOF_INT == 2
561 #define Global_erwin_int_array_hash(x,s) Global_erwin_u16_array_hash((ERWIN_U16 const *)x,s)
562 #elif SIZEOF_INT == 4
563 #define Global_erwin_int_array_hash(x,s) Global_erwin_u32_array_hash((ERWIN_U32 const *)x,s)
564 #elif SIZEOF_INT == 8
565 #define Global_erwin_int_array_hash(x,s) Global_erwin_u64_array_hash((ERWIN_U64 const *)x,s)
566 #endif
567
568 #if SIZEOF_LONG == 4
569 #define Global_erwin_long_array_hash(x,s) Global_erwin_u32_array_hash((ERWIN_U32 const *)x,s)
570 #elif SIZEOF_LONG == 8
571 #define Global_erwin_long_array_hash(x,s) Global_erwin_u64_array_hash((ERWIN_U64 const *)x,s)
572 #endif
573
574
575 #ifdef __cplusplus
576
577 extern "C++" {
578
579 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (bool x) ATTR_PURE;
580 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (bool x)
581 {
582 return Global_char_hash (x);
583 }
584
585 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (char x) ATTR_PURE;
586 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (char x)
587 {
588 return Global_char_hash (x);
589 }
590
591 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (signed char x) ATTR_PURE;
592 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (signed char x)
593 {
594 return Global_char_hash (x);
595 }
596
597 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (unsigned char x) ATTR_PURE;
598 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (unsigned char x)
599 {
600 return Global_char_hash (x);
601 }
602
603 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (short x) ATTR_PURE;
604 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (short x)
605 {
606 return Global_short_hash (x);
607 }
608
609 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (unsigned short x) ATTR_PURE;
610 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (unsigned short x)
611 {
612 return Global_short_hash (x);
613 }
614
615 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (int x) ATTR_PURE;
616 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (int x)
617 {
618 return Global_int_hash (x);
619 }
620
621 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (unsigned x) ATTR_PURE;
622 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (unsigned x)
623 {
624 return Global_int_hash (x);
625 }
626
627 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (long x) ATTR_PURE;
628 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (long x)
629 {
630 return Global_long_hash (x);
631 }
632
633 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (unsigned long x) ATTR_PURE;
634 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (unsigned long x)
635 {
636 return Global_long_hash (x);
637 }
638
639 #ifdef ERWIN_LONG_LONG
640 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (ERWIN_LONG_LONG x) ATTR_PURE;
641 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (ERWIN_LONG_LONG x)
642 {
643 return Global_long_long_hash (x);
644 }
645
646 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (ERWIN_UNSIGNED_LONG_LONG x) ATTR_PURE;
647 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (ERWIN_UNSIGNED_LONG_LONG x)
648 {
649 return Global_long_long_hash (x);
650 }
651 #endif
652
653
654
655 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (void const *x) ATTR_PURE;
656 ERWIN_WRAPPER Global_hashval_t Global_erwin_hash (void const *x)
657 {
658 return Global_voidp_hash (x);
659 }
660
661
662
663
664 }
665 #endif
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761 #if Global_SIZEOF_HASHVAL_T == 8
762 # define ?Global_ERWIN_HASH_INIT Global_HASHVAL_C(0xC90FDAA22168C234)
763 # define ?Global_ERWIN_HASH_INIT2 Global_HASHVAL_C(0xC4C6628B80DC1CD1)
764 # define ?Global_ERWIN_HASH_INIT3 Global_HASHVAL_C(0x29024E088A67CC74)
765 # define ?Global_ERWIN_HASH_INIT4 Global_HASHVAL_C(0x020BBEA63B139B22)
766 # define ?Global_ERWIN_HASH_INIT5 Global_HASHVAL_C(0x514A08798E3404DD)
767 # define ?Global_ERWIN_HASH_INIT6 Global_HASHVAL_C(0xEF9519B3CD3A431B)
768 # define ?Global_ERWIN_HASH_INIT7 Global_HASHVAL_C(0x302B0A6DF25F1437)
769 # define ?Global_ERWIN_HASH_INIT8 Global_HASHVAL_C(0x4FE1356D6D51C245)
770 # define ?Global_ERWIN_HASH_INIT9 Global_HASHVAL_C(0xE485B576625E7EC6)
771 #else
772 # define ?Global_ERWIN_HASH_INIT Global_HASHVAL_C(0xC90FDAA2)
773 # define ?Global_ERWIN_HASH_INIT2 Global_HASHVAL_C(0x2168C234)
774 # define ?Global_ERWIN_HASH_INIT3 Global_HASHVAL_C(0xC4C6628B)
775 # define ?Global_ERWIN_HASH_INIT4 Global_HASHVAL_C(0x80DC1CD1)
776 # define ?Global_ERWIN_HASH_INIT5 Global_HASHVAL_C(0x29024E08)
777 # define ?Global_ERWIN_HASH_INIT6 Global_HASHVAL_C(0x8A67CC74)
778 # define ?Global_ERWIN_HASH_INIT7 Global_HASHVAL_C(0x020BBEA6)
779 # define ?Global_ERWIN_HASH_INIT8 Global_HASHVAL_C(0x3B139B22)
780 # define ?Global_ERWIN_HASH_INIT9 Global_HASHVAL_C(0x514A0879)
781 #endif
782
783
784 #define ?Global_ERWIN_HASH_MIX_ORDERED(h1,h2,newvalue) \
785 do{ \
786 h2^= Global_erwin_ror1(h1) - ((Global_hashval_t)(newvalue)); \
787 h1+= Global_erwin_mul9(h2); \
788 }while(0)
789
790
791 #define ?Global_ERWIN_HASH_MIX_ORDERED2(h1,h2,newvalue1,newvalue2) \
792 do{ \
793 h2^= Global_erwin_ror1(h1) - ((Global_hashval_t)(newvalue1)); \
794 h1+= Global_erwin_mul9(h2) ^ newvalue2; \
795 }while(0)
796
797 #define ?Global_ERWIN_HASH_MIX_ORDERED3(h1,h2,n1,n2,n3) \
798 do{ \
799 Global_ERWIN_HASH_MIX_ORDERED2(h1,h2,n1,n2); \
800 Global_ERWIN_HASH_MIX_ORDERED (h1,h2,n3); \
801 }while(0)
802
803 #define ?Global_ERWIN_HASH_MIX_ORDERED4(h1,h2,n1,n2,n3,n4) \
804 do{ \
805 Global_ERWIN_HASH_MIX_ORDERED2(h1,h2,n1,n2); \
806 Global_ERWIN_HASH_MIX_ORDERED2(h1,h2,n3,n4); \
807 }while(0)
808
809 #define ?Global_ERWIN_HASH_MIX_ORDERED5(h1,h2,n1,n2,n3,n4,n5) \
810 do{ \
811 Global_ERWIN_HASH_MIX_ORDERED3(h1,h2,n1,n2,n3); \
812 Global_ERWIN_HASH_MIX_ORDERED2(h1,h2,n4,n5); \
813 }while(0)
814
815 #define ?Global_ERWIN_HASH_RESULT_ORDERED(h1,h2) \
816 Global_erwin_make_hash_result(h1,h2)
817
818
819
820
821
822
823
824
825
826
827
828
829
830 #define ?Global_ERWIN_HASH_MIX_UNORDERED(h1,h2,newvalue) \
831 do{ \
832 h1^= ((Global_hashval_t)(newvalue)); \
833 }while(0)
834
835
836 #define ?Global_ERWIN_HASH_MIX_UNORDERED2(h1,h2,newvalue1,newvalue2) \
837 do{ \
838 h1^= ((Global_hashval_t)(newvalue1)); \
839 h2+= newvalue2; \
840 }while(0)
841
842 #define ?Global_ERWIN_HASH_MIX_UNORDERED3(h1,h2,n1,n2,n3) \
843 do{ \
844 Global_ERWIN_HASH_MIX_UNORDERED2(h1,h2,n1,n2); \
845 Global_ERWIN_HASH_MIX_UNORDERED (h1,h2,n3); \
846 }while(0)
847
848 #define ?Global_ERWIN_HASH_MIX_UNORDERED4(h1,h2,n1,n2,n3,n4) \
849 do{ \
850 Global_ERWIN_HASH_MIX_UNORDERED2(h1,h2,n1,n2); \
851 Global_ERWIN_HASH_MIX_UNORDERED2(h1,h2,n3,n4); \
852 }while(0)
853
854 #define ?Global_ERWIN_HASH_MIX_UNORDERED5(h1,h2,n1,n2,n3,n4,n5) \
855 do{ \
856 Global_ERWIN_HASH_MIX_UNORDERED3(h1,h2,n1,n2,n3); \
857 Global_ERWIN_HASH_MIX_UNORDERED2(h1,h2,n4,n5); \
858 }while(0)
859
860
861 ;
862 #define ?Global_ERWIN_HASH_RESULT_UNORDERED \
863 Global_ERWIN_HASH_RESULT_ORDERED
864
865
866
867 #define ?Global_ERWIN_STATE_INIT(s) \
868 do{ \
869 s.h1= Global_ERWIN_HASH_INIT2; \
870 s.h2= Global_ERWIN_HASH_INIT3; \
871 }while(0)
872
873 #define ?Global_ERWIN_STATE_INIT_WITH(s,h) \
874 do{ \
875 s.h1= Global_ERWIN_HASH_INIT2 - ((Global_hashval_t)h); \
876 s.h2= Global_ERWIN_HASH_INIT3; \
877 }while(0)
878
879
880 struct Global_erwin_hash_state_t {
881 Global_hashval_t h1;
882 Global_hashval_t h2;
883 };
884
885 #ifndef __cplusplus
886 typedef struct Global_erwin_hash_state_t Global_erwin_hash_state_t;
887 #endif
888
889 #define ?Global_ERWIN_STATE_MIX_ORDERED(s,n1) \
890 Global_ERWIN_HASH_MIX_ORDERED(s.h1,s.h2,n1)
891
892 #define ?Global_ERWIN_STATE_MIX_ORDERED2(s,n1,n2) \
893 Global_ERWIN_HASH_MIX_ORDERED2(s.h1,s.h2,n1,n2)
894
895 #define ?Global_ERWIN_STATE_MIX_ORDERED3(s,n1,n2,n3) \
896 Global_ERWIN_HASH_MIX_ORDERED3(s.h1,s.h2,n1,n2,n3)
897
898 #define ?Global_ERWIN_STATE_MIX_ORDERED4(s,n1,n2,n3,n4) \
899 Global_ERWIN_HASH_MIX_ORDERED4(s.h1,s.h2,n1,n2,n3,n4)
900
901 #define ?Global_ERWIN_STATE_MIX_ORDERED5(s,n1,n2,n3,n4,n5) \
902 Global_ERWIN_HASH_MIX_ORDERED5(s.h1,s.h2,n1,n2,n3,n4,n5)
903
904
905 #define ?Global_ERWIN_STATE_MIX_UNORDERED(s,n1) \
906 Global_ERWIN_HASH_MIX_UNORDERED(s.h1,s.h2,n1)
907
908 #define ?Global_ERWIN_STATE_MIX_UNORDERED2(s,n1,n2) \
909 Global_ERWIN_HASH_MIX_UNORDERED2(s.h1,s.h2,n1,n2)
910
911 #define ?Global_ERWIN_STATE_MIX_UNORDERED3(s,n1,n2,n3) \
912 Global_ERWIN_HASH_MIX_UNORDERED2(s.h1,s.h2,n1,n2,n3)
913
914 #define ?Global_ERWIN_STATE_MIX_UNORDERED4(s,n1,n2,n3,n4) \
915 Global_ERWIN_HASH_MIX_UNORDERED2(s.h1,s.h2,n1,n2,n3,n4)
916
917 #define ?Global_ERWIN_STATE_MIX_UNORDERED5(s,n1,n2,n3,n4,n5) \
918 Global_ERWIN_HASH_MIX_UNORDERED2(s.h1,s.h2,n1,n2,n3,n4,n5)
919
920
921 #define ?Global_ERWIN_STATE_GET_HASHVAL(s) \
922 Global_ERWIN_HASH_RESULT_ORDERED(s.h1,s.h2)
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939 #if !defined(Global_ERWIN_THREAD_SAFE) || Global_ERWIN_USE_THREAD_KEYWORD
940 extern Global_ERWIN_THREAD_LOCAL int Global_erwininternalmaperrno;
941 #elif Global_ERWIN_USE_PTHREAD
942 extern int *Global_erwininternalmaperrnoptr(void);
943 #define Global_erwininternalmaperrno (*Global_erwininternalmaperrnoptr())
944 #endif
945
946 extern char const *Global_erwininternalmapstrerror (int) ATTR_PURE;
947
948 #define Global_ERWININTERNALMAPOK 1
949
950
951
952 #define Global_ERWININTERNALMAPISOK(X) ((X) == Global_ERWININTERNALMAPOK)
953 #define Global_ERWININTERNALMAPISERROR(X) ((X) < Global_ERWININTERNALMAPOK)
954 #define Global_ERWININTERNALMAPISWARNING(X) ((X) > Global_ERWININTERNALMAPOK)
955
956 #define Global_ERWININTERNALMAPERRNOMEM (-2)
957 #define Global_ERWININTERNALMAPERRASSERTIONFAILED (-5)
958
959 #define Global_ERWININTERNALMAPWARNEMPTY 5
960 #define Global_ERWININTERNALMAPWARNNOMOREELEMS 6
961 #define Global_ERWININTERNALMAPWARNEXISTINGKEY 7
962 #define Global_ERWININTERNALMAPWARNKEYNOTFOUND 8
963
964 #define Global_ERWININTERNALMAPREHASHNOMEM 2
965 #define Global_ERWININTERNALMAPREHASHDUPLICATEKEY 3
966 #define Global_ERWININTERNALMAPREHASHRECURSION 4
967
968 #ifdef __cplusplus
969 }
970 #endif
971
972 #endif
973
974 #endif