Blender  V3.3
blf_util.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13 
14 #include "BLI_utildefines.h"
15 
16 #include "blf_internal.h"
17 
18 unsigned int blf_next_p2(unsigned int x)
19 {
20  x -= 1;
21  x |= (x >> 16);
22  x |= (x >> 8);
23  x |= (x >> 4);
24  x |= (x >> 2);
25  x |= (x >> 1);
26  x += 1;
27  return x;
28 }
29 
30 unsigned int blf_hash(unsigned int val)
31 {
32  unsigned int key;
33 
34  key = val;
35  key += ~(key << 16);
36  key ^= (key >> 5);
37  key += (key << 3);
38  key ^= (key >> 13);
39  key += ~(key << 9);
40  key ^= (key >> 17);
41  return key % 257;
42 }
unsigned int blf_next_p2(unsigned int x)
Definition: blf_util.c:18
unsigned int blf_hash(unsigned int val)
Definition: blf_util.c:30