Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for netbsd #735

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/hiredis/fmacros.h
Expand Up @@ -7,7 +7,7 @@

#if defined(__sun__)
#define _POSIX_C_SOURCE 200112L
#elif defined(__linux__)
#elif defined(__linux__) || defined(__NetBSD__)
#define _XOPEN_SOURCE 600
#else
#define _XOPEN_SOURCE
Expand Down
4 changes: 2 additions & 2 deletions src/bitops.c
Expand Up @@ -28,7 +28,7 @@ static int getBitOffsetFromArgument(redisClient *c, robj *o, size_t *offset) {
/* Count number of bits set in the binary array pointed by 's' and long
* 'count' bytes. The implementation of this function is required to
* work with a input string length up to 512 MB. */
long popcount(void *s, long count) {
long popcount_binary(void *s, long count) {
long bits = 0;
unsigned char *p;
uint32_t *p4 = s;
Expand Down Expand Up @@ -374,6 +374,6 @@ void bitcountCommand(redisClient *c) {
} else {
long bytes = end-start+1;

addReplyLongLong(c,popcount(p+start,bytes));
addReplyLongLong(c,popcount_binary(p+start,bytes));
}
}
4 changes: 2 additions & 2 deletions src/config.c
Expand Up @@ -833,8 +833,8 @@ void configGetCommand(redisClient *c) {
int j;

for (j = 0; j < server.saveparamslen; j++) {
buf = sdscatprintf(buf,"%ld %d",
server.saveparams[j].seconds,
buf = sdscatprintf(buf,"%jd %d",
(intmax_t)server.saveparams[j].seconds,
server.saveparams[j].changes);
if (j != server.saveparamslen-1)
buf = sdscatlen(buf," ",1);
Expand Down
5 changes: 4 additions & 1 deletion src/debug.c
Expand Up @@ -298,8 +298,11 @@ void debugCommand(redisClient *c) {
} else if (!strcasecmp(c->argv[1]->ptr,"sleep") && c->argc == 3) {
double dtime = strtod(c->argv[2]->ptr,NULL);
long long utime = dtime*1000000;
struct timespec tv;

usleep(utime);
tv.tv_sec = utime / 1000000;
tv.tv_nsec = (utime % 1000000) * 1000;
nanosleep(&tv, NULL);
addReply(c,shared.ok);
} else {
addReplyError(c,
Expand Down
6 changes: 5 additions & 1 deletion src/fmacros.h
Expand Up @@ -9,7 +9,11 @@

#if defined(__linux__) || defined(__OpenBSD__)
#define _XOPEN_SOURCE 700
#else
/*
* On NetBSD, _XOPEN_SOURCE undefines _NETBSD_SOURCE and
* thus hides inet_aton etc.
*/
#elif !defined(__NetBSD__)
#define _XOPEN_SOURCE
#endif

Expand Down
44 changes: 22 additions & 22 deletions src/redis.c
Expand Up @@ -1897,8 +1897,8 @@ sds genRedisInfoString(char *section) {
"process_id:%ld\r\n"
"run_id:%s\r\n"
"tcp_port:%d\r\n"
"uptime_in_seconds:%ld\r\n"
"uptime_in_days:%ld\r\n"
"uptime_in_seconds:%jd\r\n"
"uptime_in_days:%jd\r\n"
"lru_clock:%ld\r\n",
REDIS_VERSION,
redisGitSHA1(),
Expand All @@ -1915,8 +1915,8 @@ sds genRedisInfoString(char *section) {
(long) getpid(),
server.runid,
server.port,
uptime,
uptime/(3600*24),
(intmax_t)uptime,
(intmax_t)(uptime/(3600*24)),
(unsigned long) server.lruclock);
}

Expand Down Expand Up @@ -1971,30 +1971,30 @@ sds genRedisInfoString(char *section) {
"loading:%d\r\n"
"rdb_changes_since_last_save:%lld\r\n"
"rdb_bgsave_in_progress:%d\r\n"
"rdb_last_save_time:%ld\r\n"
"rdb_last_save_time:%jd\r\n"
"rdb_last_bgsave_status:%s\r\n"
"rdb_last_bgsave_time_sec:%ld\r\n"
"rdb_current_bgsave_time_sec:%ld\r\n"
"rdb_last_bgsave_time_sec:%jd\r\n"
"rdb_current_bgsave_time_sec:%jd\r\n"
"aof_enabled:%d\r\n"
"aof_rewrite_in_progress:%d\r\n"
"aof_rewrite_scheduled:%d\r\n"
"aof_last_rewrite_time_sec:%ld\r\n"
"aof_current_rewrite_time_sec:%ld\r\n"
"aof_last_rewrite_time_sec:%jd\r\n"
"aof_current_rewrite_time_sec:%jd\r\n"
"aof_last_bgrewrite_status:%s\r\n",
server.loading,
server.dirty,
server.rdb_child_pid != -1,
server.lastsave,
(intmax_t)server.lastsave,
(server.lastbgsave_status == REDIS_OK) ? "ok" : "err",
server.rdb_save_time_last,
(server.rdb_child_pid == -1) ?
-1 : time(NULL)-server.rdb_save_time_start,
(intmax_t)server.rdb_save_time_last,
(intmax_t)((server.rdb_child_pid == -1) ?
-1 : time(NULL)-server.rdb_save_time_start),
server.aof_state != REDIS_AOF_OFF,
server.aof_child_pid != -1,
server.aof_rewrite_scheduled,
server.aof_rewrite_time_last,
(server.aof_child_pid == -1) ?
-1 : time(NULL)-server.aof_rewrite_time_start,
(intmax_t)server.aof_rewrite_time_last,
(intmax_t)((server.aof_child_pid == -1) ?
-1 : time(NULL)-server.aof_rewrite_time_start),
(server.aof_lastbgrewrite_status == REDIS_OK) ? "ok" : "err");

if (server.aof_state != REDIS_AOF_OFF) {
Expand Down Expand Up @@ -2033,16 +2033,16 @@ sds genRedisInfoString(char *section) {
}

info = sdscatprintf(info,
"loading_start_time:%ld\r\n"
"loading_start_time:%jd\r\n"
"loading_total_bytes:%llu\r\n"
"loading_loaded_bytes:%llu\r\n"
"loading_loaded_perc:%.2f\r\n"
"loading_eta_seconds:%ld\r\n"
,(unsigned long) server.loading_start_time,
"loading_eta_seconds:%jd\r\n",
(intmax_t) server.loading_start_time,
(unsigned long long) server.loading_total_bytes,
(unsigned long long) server.loading_loaded_bytes,
perc,
eta
(intmax_t)eta
);
}
}
Expand Down Expand Up @@ -2111,8 +2111,8 @@ sds genRedisInfoString(char *section) {

if (server.repl_state != REDIS_REPL_CONNECTED) {
info = sdscatprintf(info,
"master_link_down_since_seconds:%ld\r\n",
(long)server.unixtime-server.repl_down_since);
"master_link_down_since_seconds:%jd\r\n",
(intmax_t)server.unixtime-server.repl_down_since);
}
info = sdscatprintf(info,
"slave_priority:%d\r\n"
Expand Down