Line data Source code
1 : #ifndef HEADER_fd_src_util_racesan_fd_racesan_base_h 2 : #define HEADER_fd_src_util_racesan_fd_racesan_base_h 3 : 4 : #include "../../util/fd_util_base.h" 5 : 6 : #ifndef FD_HAS_RACESAN 7 : #define FD_HAS_RACESAN 0 8 : #endif 9 : 10 : /* FIXME Check for FD_HAS_UCONTEXT */ 11 : 12 : struct fd_racesan; 13 : typedef struct fd_racesan fd_racesan_t; 14 : 15 : FD_PROTOTYPES_BEGIN 16 : 17 : /* fd_racesan_strhash is a FNV-1a for 64-bit implementation of string 18 : hashing. Used to hash racesan hook names to integers. The compiler 19 : can typically evaluate the following at compile time: 20 : 21 : ulong x = fd_racesan_strhash( "hello", sizeof("hello")-1 ); 22 : ... x is resolved at compile time ... */ 23 : 24 : static inline ulong 25 : fd_racesan_strhash( char const * s, 26 0 : ulong len ) { 27 0 : ulong x = 0xCBF29CE484222325UL; 28 0 : for( ; len; len--, s++ ) { 29 0 : x ^= (ulong)(uchar)( *s ); 30 0 : x *= 0x100000001B3UL; 31 0 : } 32 0 : return x; 33 0 : } 34 : 35 : FD_PROTOTYPES_END 36 : 37 : #endif /* HEADER_fd_src_util_racesan_fd_racesan_base_h */