diff options
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/common-utils.c | 15 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index de0cb774b74..3f52a90a010 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -56,6 +56,21 @@ struct dnscache6 { struct addrinfo *next; }; + +int +gf_log2 (unsigned long x) +{ + int val = 0; + + while (x != 1) { + x /= 2; + val++; + } + + return val; +} + + int32_t gf_resolve_ip6 (const char *hostname, uint16_t port, diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index c5869f4a424..48788d29545 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -330,6 +330,7 @@ int gf_lockfd (int fd); int gf_unlockfd (int fd); int get_checksum_for_file (int fd, uint32_t *checksum); +int gf_log2 (unsigned long x); #endif /* _COMMON_UTILS_H */ |