24 |
#include <string.h> |
#include <string.h> |
25 |
#include <stdlib.h> |
#include <stdlib.h> |
26 |
#include <limits.h> |
#include <limits.h> |
27 |
|
#include <stdint.h> |
28 |
#include <assert.h> |
#include <assert.h> |
29 |
|
|
30 |
#include <hurd/ihash.h> |
#include <hurd/ihash.h> |
32 |
|
|
33 |
/* The odd prime numbers greater than twice the last and less than |
/* The odd prime numbers greater than twice the last and less than |
34 |
2^40 (nobody needs more than 640 GB of memory). */ |
2^40 (nobody needs more than 640 GB of memory). */ |
35 |
static const unsigned int ihash_sizes[] = |
static const uint64_t ihash_sizes[] = |
36 |
{ |
{ |
37 |
3, |
3, |
38 |
7, |
7, |
63 |
359339171, |
359339171, |
64 |
718678369, |
718678369, |
65 |
1437356741, |
1437356741, |
66 |
2874713497, |
UINT64_C (2874713497), |
67 |
5749427029, |
UINT64_C (5749427029), |
68 |
11498854069, |
UINT64_C (11498854069), |
69 |
22997708177, |
UINT64_C (22997708177), |
70 |
45995416409, |
UINT64_C (45995416409), |
71 |
91990832831, |
UINT64_C (91990832831), |
72 |
183981665689, |
UINT64_C (183981665689), |
73 |
367963331389, |
UINT64_C (367963331389), |
74 |
735926662813 |
UINT64_C (735926662813) |
75 |
}; |
}; |
76 |
|
|
77 |
|
|
283 |
for (i = 0; i < ihash_nsizes; i++) |
for (i = 0; i < ihash_nsizes; i++) |
284 |
if (ihash_sizes[i] > old_ht.size) |
if (ihash_sizes[i] > old_ht.size) |
285 |
break; |
break; |
286 |
if (i == ihash_nsizes) |
if (i == ihash_nsizes |
287 |
|
|| ihash_sizes[i] > SIZE_MAX / sizeof (hurd_ihash_value_t) |
288 |
|
|| ihash_sizes[i] > SIZE_MAX / sizeof (hurd_ihash_key_t) |
289 |
|
|| ihash_sizes[i] > SIZE_MAX / sizeof (hurd_ihash_locp_t *)) |
290 |
return ENOMEM; /* Surely will be true momentarily. */ |
return ENOMEM; /* Surely will be true momentarily. */ |
291 |
|
|
292 |
ht->size = ihash_sizes[i]; |
ht->size = ihash_sizes[i]; |