Skip to content

Commit

Permalink
Merge pull request #3072 from stan-dev/sundials-hashmap-win
Browse files Browse the repository at this point in the history
Backport SUNDIALS bugfix for hashmap int overflow
  • Loading branch information
SteveBronder authored May 20, 2024
2 parents 814d915 + e8de696 commit b12cfbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/sundials_6.1.1/STAN_CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This file documents changes done for the stan-math project

- Backported bugfix for hashmap int overflow on Windows (https://github.com/LLNL/sundials/pull/421)
7 changes: 4 additions & 3 deletions lib/sundials_6.1.1/src/sundials/sundials_hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef _SUNDIALS_HASHMAP_H
#define _SUNDIALS_HASHMAP_H

#include <stdint.h>
#include <string.h>
#include <stdlib.h>

Expand All @@ -30,10 +31,10 @@
This is a 64-bit implementation of the 'a' modification of the
Fowler–Noll–Vo hash (i.e., FNV1-a).
*/
static unsigned long fnv1a_hash(const char* str)
static uint64_t fnv1a_hash(const char* str)
{
const unsigned long prime = 14695981039346656037U; /* prime */
unsigned long hash = 1099511628211U; /* offset basis */
const uint64_t prime = 14695981039346656037U; /* prime */
uint64_t hash = 1099511628211U; /* offset basis */
char c;
while ((c = *str++))
hash = (hash^c) * prime;
Expand Down

0 comments on commit b12cfbd

Please sign in to comment.