]> www.ginac.de Git - cln.git/blob - src/base/symbol/cl_sy_hashcode.cc
Remove cl_null_string defintion.
[cln.git] / src / base / symbol / cl_sy_hashcode.cc
1 // cln/symbol.hashcode().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/symbol.h"
8
9
10 // Implementation.
11
12 #include "base/cl_offsetof.h"
13
14 namespace cln {
15
16 #define declare_alignof(where,type)  \
17   struct CONCAT(aligndummy,__LINE__) { char slot1; type slot2; }; \
18   const unsigned long where = offsetof(CONCAT(aligndummy,__LINE__), slot2);
19
20 unsigned long hashcode (const cl_symbol& s)
21 {
22         // Strings don't move in memory, so we can just take the address.
23         declare_alignof(string_alignment,cl_heap_string);
24         return (unsigned long)(s.pointer)
25                / (string_alignment & -string_alignment); // divide by power of 2
26 }
27
28 }  // namespace cln