diff options
Diffstat (limited to 'examples/redis-unstable/src/release.c')
| -rw-r--r-- | examples/redis-unstable/src/release.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/examples/redis-unstable/src/release.c b/examples/redis-unstable/src/release.c new file mode 100644 index 0000000..11f7f51 --- /dev/null +++ b/examples/redis-unstable/src/release.c | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2009-Present, Redis Ltd. | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * Licensed under your choice of (a) the Redis Source Available License 2.0 | ||
| 6 | * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the | ||
| 7 | * GNU Affero General Public License v3 (AGPLv3). | ||
| 8 | */ | ||
| 9 | |||
| 10 | /* Every time the Redis Git SHA1 or Dirty status changes only this small | ||
| 11 | * file is recompiled, as we access this information in all the other | ||
| 12 | * files using this functions. */ | ||
| 13 | |||
| 14 | #include <string.h> | ||
| 15 | #include <stdio.h> | ||
| 16 | |||
| 17 | #include "release.h" | ||
| 18 | #include "crc64.h" | ||
| 19 | |||
| 20 | char *redisGitSHA1(void) { | ||
| 21 | return REDIS_GIT_SHA1; | ||
| 22 | } | ||
| 23 | |||
| 24 | char *redisGitDirty(void) { | ||
| 25 | return REDIS_GIT_DIRTY; | ||
| 26 | } | ||
| 27 | |||
| 28 | const char *redisBuildIdRaw(void) { | ||
| 29 | return REDIS_BUILD_ID_RAW; | ||
| 30 | } | ||
| 31 | |||
| 32 | uint64_t redisBuildId(void) { | ||
| 33 | char *buildid = REDIS_BUILD_ID_RAW; | ||
| 34 | |||
| 35 | return crc64(0,(unsigned char*)buildid,strlen(buildid)); | ||
| 36 | } | ||
| 37 | |||
| 38 | /* Return a cached value of the build string in order to avoid recomputing | ||
| 39 | * and converting it in hex every time: this string is shown in the INFO | ||
| 40 | * output that should be fast. */ | ||
| 41 | char *redisBuildIdString(void) { | ||
| 42 | static char buf[32]; | ||
| 43 | static int cached = 0; | ||
| 44 | if (!cached) { | ||
| 45 | snprintf(buf,sizeof(buf),"%llx",(unsigned long long) redisBuildId()); | ||
| 46 | cached = 1; | ||
| 47 | } | ||
| 48 | return buf; | ||
| 49 | } | ||
