19
19
#include <errno.h>
20
20
#include <fcntl.h>
21
21
#include <sys/stat.h>
22
- #ifndef _WIN32
23
- #include <sys/utsname.h>
24
- #endif
25
- #ifdef __GLIBC__
26
- #include <gnu/libc-version.h>
27
- #endif
28
22
29
23
/* 1000 is an arbitrary limit; FNV64 plus some slashes brings the cap down to
30
24
* 981 for the cache dir */
@@ -205,29 +199,6 @@ bs_compile_option_crc32_set(VALUE self, VALUE crc32_v)
205
199
return Qnil ;
206
200
}
207
201
208
- /*
209
- * We use FNV1a-64 to derive cache paths. The choice is somewhat arbitrary but
210
- * it has several nice properties:
211
- *
212
- * - Tiny implementation
213
- * - No external dependency
214
- * - Solid performance
215
- * - Solid randomness
216
- * - 32 bits doesn't feel collision-resistant enough; 64 is nice.
217
- */
218
- static uint64_t
219
- fnv1a_64_iter_cstr (uint64_t h , const char * str )
220
- {
221
- unsigned char * s = (unsigned char * )str ;
222
-
223
- while (* s ) {
224
- h ^= (uint64_t )* s ++ ;
225
- h += (h << 1 ) + (h << 4 ) + (h << 5 ) + (h << 7 ) + (h << 8 ) + (h << 40 );
226
- }
227
-
228
- return h ;
229
- }
230
-
231
202
static uint64_t
232
203
fnv1a_64_iter (uint64_t h , const VALUE str )
233
204
{
@@ -272,10 +243,6 @@ get_ruby_revision(void)
272
243
/*
273
244
* When ruby's version doesn't change, but it's recompiled on a different OS
274
245
* (or OS version), we need to invalidate the cache.
275
- *
276
- * We actually factor in some extra information here, to be extra confident
277
- * that we don't try to re-use caches that will not be compatible, by factoring
278
- * in utsname.version.
279
246
*/
280
247
static uint32_t
281
248
get_ruby_platform (void )
@@ -285,22 +252,7 @@ get_ruby_platform(void)
285
252
286
253
ruby_platform = rb_const_get (rb_cObject , rb_intern ("RUBY_PLATFORM" ));
287
254
hash = fnv1a_64 (ruby_platform );
288
-
289
- #ifdef _WIN32
290
- return (uint32_t )(hash >> 32 ) ^ (uint32_t )GetVersion ();
291
- #elif defined(__GLIBC__ )
292
- hash = fnv1a_64_iter_cstr (hash , gnu_get_libc_version ());
293
255
return (uint32_t )(hash >> 32 );
294
- #else
295
- struct utsname utsname ;
296
-
297
- /* Not worth crashing if this fails; lose extra cache invalidation potential */
298
- if (uname (& utsname ) >= 0 ) {
299
- hash = fnv1a_64_iter_cstr (hash , utsname .version );
300
- }
301
-
302
- return (uint32_t )(hash >> 32 );
303
- #endif
304
256
}
305
257
306
258
/*
0 commit comments