| 109 | -------------------------------------------------------------------------*/ |
| 110 | |
| 111 | int32_t |
| 112 | LogFormat::id_from_name(const char *name) |
| 113 | { |
| 114 | int32_t id = 0; |
| 115 | if (name) { |
| 116 | CryptoHash hash; |
| 117 | CryptoContext().hash_immediate(hash, name, static_cast<int>(strlen(name))); |
| 118 | #if defined(__linux__) |
| 119 | /* Mask most significant bit so that return value of this function |
| 120 | * is not sign extended to be a negative number. |
| 121 | * This problem is only known to occur on Linux which |
| 122 | * is a 32-bit OS. |
| 123 | */ |
| 124 | id = static_cast<int32_t>(hash.fold()) & 0x7fffffff; |
| 125 | #else |
| 126 | id = (int32_t)hash.fold(); |
| 127 | #endif |
| 128 | } |
| 129 | return id; |
| 130 | } |
| 131 | |
| 132 | /*------------------------------------------------------------------------- |
| 133 | LogFormat::init_variables |
nothing calls this directly
no test coverage detected