| 28 | namespace singa { |
| 29 | |
| 30 | static uint64_t getHostHash(const char *string) { |
| 31 | // Based on DJB2, result = result * 33 + char |
| 32 | uint64_t result = 5381; |
| 33 | for (int c = 0; string[c] != '\0'; c++) { |
| 34 | result = ((result << 5) + result) + string[c]; |
| 35 | } |
| 36 | return result; |
| 37 | } |
| 38 | |
| 39 | static void getHostName(char *hostname, int maxlen) { |
| 40 | gethostname(hostname, maxlen); |