Skip to content

Commit e8de696

Browse files
committed
Backport SUNDIALS bugfix for hashmap int overflow
1 parent 814d915 commit e8de696

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/sundials_6.1.1/STAN_CHANGES

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file documents changes done for the stan-math project
2+
3+
- Backported bugfix for hashmap int overflow on Windows (https://github.com/LLNL/sundials/pull/421)

lib/sundials_6.1.1/src/sundials/sundials_hashmap.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef _SUNDIALS_HASHMAP_H
2121
#define _SUNDIALS_HASHMAP_H
2222

23+
#include <stdint.h>
2324
#include <string.h>
2425
#include <stdlib.h>
2526

@@ -30,10 +31,10 @@
3031
This is a 64-bit implementation of the 'a' modification of the
3132
Fowler–Noll–Vo hash (i.e., FNV1-a).
3233
*/
33-
static unsigned long fnv1a_hash(const char* str)
34+
static uint64_t fnv1a_hash(const char* str)
3435
{
35-
const unsigned long prime = 14695981039346656037U; /* prime */
36-
unsigned long hash = 1099511628211U; /* offset basis */
36+
const uint64_t prime = 14695981039346656037U; /* prime */
37+
uint64_t hash = 1099511628211U; /* offset basis */
3738
char c;
3839
while ((c = *str++))
3940
hash = (hash^c) * prime;

0 commit comments

Comments
 (0)