From 86e3395c117d9450d52ee3ebbc62c386d11f1b79 Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Sun, 13 Dec 2020 17:09:54 +0200 Subject: [PATCH] Several (mostly Solaris-related) cleanups (#8171) * Allow runtest-moduleapi use a different 'make', for systems where GNU Make is 'gmake'. * Fix issue with builds on Solaris re-building everything from scratch due to CFLAGS/LDFLAGS not stored. * Fix compile failure on Solaris due to atomicvar and a bunch of warnings. * Fix garbled log timestamps on Solaris. --- runtest-moduleapi | 3 ++- src/Makefile | 8 +++++--- src/ae_evport.c | 8 +++++--- src/aof.c | 2 +- src/atomicvar.h | 2 +- src/cluster.c | 2 ++ src/config.c | 2 +- src/debug.c | 2 +- src/module.c | 6 +++--- src/rdb.c | 6 +++--- src/util.c | 3 +-- src/zmalloc.c | 11 +++-------- tests/modules/Makefile | 9 ++++----- 13 files changed, 32 insertions(+), 32 deletions(-) diff --git a/runtest-moduleapi b/runtest-moduleapi index da4c815d..9a48867d 100755 --- a/runtest-moduleapi +++ b/runtest-moduleapi @@ -1,6 +1,7 @@ #!/bin/sh TCL_VERSIONS="8.5 8.6" TCLSH="" +[ -z "$MAKE" ] && MAKE=make for VERSION in $TCL_VERSIONS; do TCL=`which tclsh$VERSION 2>/dev/null` && TCLSH=$TCL @@ -12,7 +13,7 @@ then exit 1 fi -make -C tests/modules && \ +$MAKE -C tests/modules && \ $TCLSH tests/test_helper.tcl \ --single unit/moduleapi/commandfilter \ --single unit/moduleapi/fork \ diff --git a/src/Makefile b/src/Makefile index 653a6e6b..0329da8c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -99,9 +99,11 @@ endif ifeq ($(uname_S),SunOS) # SunOS - ifneq ($(@@),32bit) - CFLAGS+= -m64 - LDFLAGS+= -m64 + ifeq ($(findstring -m32,$(FINAL_CFLAGS)),) + CFLAGS+=-m64 + endif + ifeq ($(findstring -m32,$(FINAL_LDFLAGS)),) + LDFLAGS+=-m64 endif DEBUG=-g DEBUG_FLAGS=-g diff --git a/src/ae_evport.c b/src/ae_evport.c index b79ed9bc..4e254b60 100644 --- a/src/ae_evport.c +++ b/src/ae_evport.c @@ -67,7 +67,7 @@ static int evport_debug = 0; typedef struct aeApiState { int portfd; /* event port */ - int npending; /* # of pending fds */ + uint_t npending; /* # of pending fds */ int pending_fds[MAX_EVENT_BATCHSZ]; /* pending fds */ int pending_masks[MAX_EVENT_BATCHSZ]; /* pending fds' masks */ } aeApiState; @@ -95,6 +95,8 @@ static int aeApiCreate(aeEventLoop *eventLoop) { } static int aeApiResize(aeEventLoop *eventLoop, int setsize) { + (void) eventLoop; + (void) setsize; /* Nothing to resize here. */ return 0; } @@ -107,7 +109,7 @@ static void aeApiFree(aeEventLoop *eventLoop) { } static int aeApiLookupPending(aeApiState *state, int fd) { - int i; + uint_t i; for (i = 0; i < state->npending; i++) { if (state->pending_fds[i] == fd) @@ -243,7 +245,7 @@ static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) { static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) { aeApiState *state = eventLoop->apidata; struct timespec timeout, *tsp; - int mask, i; + uint_t mask, i; uint_t nevents; port_event_t event[MAX_EVENT_BATCHSZ]; diff --git a/src/aof.c b/src/aof.c index d3cac451..79b2f128 100644 --- a/src/aof.c +++ b/src/aof.c @@ -1728,7 +1728,7 @@ int rewriteAppendOnlyFileBackground(void) { return C_ERR; } serverLog(LL_NOTICE, - "Background append only file rewriting started by pid %d",childpid); + "Background append only file rewriting started by pid %ld",(long) childpid); server.aof_rewrite_scheduled = 0; server.aof_rewrite_time_start = time(NULL); server.aof_child_pid = childpid; diff --git a/src/atomicvar.h b/src/atomicvar.h index 6ac04c60..222b8269 100644 --- a/src/atomicvar.h +++ b/src/atomicvar.h @@ -105,7 +105,7 @@ atomic_store_explicit(&var,value,memory_order_seq_cst) #define REDIS_ATOMIC_API "c11-builtin" -#elif !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && !defined(__sun) && \ +#elif !defined(__ATOMIC_VAR_FORCE_SYNC_MACROS) && \ (!defined(__clang__) || !defined(__APPLE__) || __apple_build_version__ > 4210057) && \ defined(__ATOMIC_RELAXED) && defined(__ATOMIC_SEQ_CST) /* Implementation using __atomic macros. */ diff --git a/src/cluster.c b/src/cluster.c index ef73b109..8651a81d 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -430,6 +430,8 @@ int clusterLockConfig(char *filename) { * (redis-aof-rewrite) is still alive, the fd(lock) will still be held by the * child process, and the main process will fail to get lock, means fail to start. */ server.cluster_config_file_lock_fd = fd; +#else + UNUSED(filename); #endif /* __sun */ return C_OK; diff --git a/src/config.c b/src/config.c index 28b756b5..c858df3f 100644 --- a/src/config.c +++ b/src/config.c @@ -1002,7 +1002,7 @@ void configGetCommand(client *c) { } if (stringmatch(pattern,"unixsocketperm",1)) { char buf[32]; - snprintf(buf,sizeof(buf),"%o",server.unixsocketperm); + snprintf(buf,sizeof(buf),"%lo",(unsigned long) server.unixsocketperm); addReplyBulkCString(c,"unixsocketperm"); addReplyBulkCString(c,buf); matches++; diff --git a/src/debug.c b/src/debug.c index 7cc3c15a..6ce8b3bd 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1757,7 +1757,7 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) { "Accessing address: %p", (void*)info->si_addr); } if (info->si_pid != -1) { - serverLog(LL_WARNING, "Killed by PID: %d, UID: %d", info->si_pid, info->si_uid); + serverLog(LL_WARNING, "Killed by PID: %ld, UID: %d", (long) info->si_pid, info->si_uid); } #ifdef HAVE_BACKTRACE diff --git a/src/module.c b/src/module.c index 29e44aa7..da9ac29e 100644 --- a/src/module.c +++ b/src/module.c @@ -7084,7 +7084,7 @@ int RM_Fork(RedisModuleForkDoneHandler cb, void *user_data) { moduleForkInfo.done_handler = cb; moduleForkInfo.done_handler_user_data = user_data; updateDictResizePolicy(); - serverLog(LL_VERBOSE, "Module fork started pid: %d ", childpid); + serverLog(LL_VERBOSE, "Module fork started pid: %ld ", (long) childpid); } return childpid; } @@ -7134,8 +7134,8 @@ int RM_KillForkChild(int child_pid) { void ModuleForkDoneHandler(int exitcode, int bysignal) { serverLog(LL_NOTICE, - "Module fork exited pid: %d, retcode: %d, bysignal: %d", - server.module_child_pid, exitcode, bysignal); + "Module fork exited pid: %ld, retcode: %d, bysignal: %d", + (long) server.module_child_pid, exitcode, bysignal); if (moduleForkInfo.done_handler) { moduleForkInfo.done_handler(exitcode, bysignal, moduleForkInfo.done_handler_user_data); diff --git a/src/rdb.c b/src/rdb.c index 0878be83..46f78e75 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1432,7 +1432,7 @@ int rdbSaveBackground(char *filename, rdbSaveInfo *rsi) { strerror(errno)); return C_ERR; } - serverLog(LL_NOTICE,"Background saving started by pid %d",childpid); + serverLog(LL_NOTICE,"Background saving started by pid %ld",(long) childpid); server.rdb_save_time_start = time(NULL); server.rdb_child_pid = childpid; server.rdb_child_type = RDB_CHILD_TYPE_DISK; @@ -2826,8 +2826,8 @@ int rdbSaveToSlavesSockets(rdbSaveInfo *rsi) { server.rdb_pipe_numconns_writing = 0; closeChildInfoPipe(); } else { - serverLog(LL_NOTICE,"Background RDB transfer started by pid %d", - childpid); + serverLog(LL_NOTICE,"Background RDB transfer started by pid %ld", + (long) childpid); server.rdb_save_time_start = time(NULL); server.rdb_child_pid = childpid; server.rdb_child_type = RDB_CHILD_TYPE_SOCKET; diff --git a/src/util.c b/src/util.c index 0d48f570..eca212e5 100644 --- a/src/util.c +++ b/src/util.c @@ -749,9 +749,8 @@ sds getAbsolutePath(char *filename) { * Gets the proper timezone in a more portable fashion * i.e timezone variables are linux specific. */ - unsigned long getTimeZone(void) { -#ifdef __linux__ +#if defined(__linux__) || defined(__sun) return timezone; #else struct timeval tv; diff --git a/src/zmalloc.c b/src/zmalloc.c index 2f9b4029..86b15b0e 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -31,6 +31,7 @@ #include #include #include +#include /* This function provide us access to the original libc free(). This is useful * for instance to free results obtained by backtrace_symbols(). We need @@ -333,7 +334,6 @@ void zmalloc_set_oom_handler(void (*oom_handler)(size_t)) { * version of the function. */ #if defined(HAVE_PROC_STAT) -#include #include #include #include @@ -346,7 +346,7 @@ size_t zmalloc_get_rss(void) { int fd, count; char *p, *x; - snprintf(filename,256,"/proc/%d/stat",getpid()); + snprintf(filename,256,"/proc/%ld/stat",(long) getpid()); if ((fd = open(filename,O_RDONLY)) == -1) return 0; if (read(fd,buf,4096) <= 0) { close(fd); @@ -370,9 +370,6 @@ size_t zmalloc_get_rss(void) { return rss; } #elif defined(HAVE_TASKINFO) -#include -#include -#include #include #include #include @@ -393,7 +390,6 @@ size_t zmalloc_get_rss(void) { #include #include #include -#include size_t zmalloc_get_rss(void) { struct kinfo_proc info; @@ -416,7 +412,6 @@ size_t zmalloc_get_rss(void) { #elif defined(__NetBSD__) #include #include -#include size_t zmalloc_get_rss(void) { struct kinfo_proc2 info; @@ -443,7 +438,7 @@ size_t zmalloc_get_rss(void) { char filename[256]; int fd; - snprintf(filename,256,"/proc/%d/psinfo",getpid()); + snprintf(filename,256,"/proc/%ld/psinfo",(long) getpid()); if ((fd = open(filename,O_RDONLY)) == -1) return 0; if (ioctl(fd, PIOCPSINFO, &info) == -1) { diff --git a/tests/modules/Makefile b/tests/modules/Makefile index 5b2c30c1..7363c98b 100644 --- a/tests/modules/Makefile +++ b/tests/modules/Makefile @@ -2,13 +2,12 @@ # find the OS uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') -# Compile flags for linux / osx -ifeq ($(uname_S),Linux) - SHOBJ_CFLAGS ?= -W -Wall -fno-common -g -ggdb -std=c99 -O2 - SHOBJ_LDFLAGS ?= -shared -else +ifeq ($(uname_S),Darwin) SHOBJ_CFLAGS ?= -W -Wall -dynamic -fno-common -g -ggdb -std=c99 -O2 SHOBJ_LDFLAGS ?= -bundle -undefined dynamic_lookup +else # Linux, others + SHOBJ_CFLAGS ?= -W -Wall -fno-common -g -ggdb -std=c99 -O2 + SHOBJ_LDFLAGS ?= -shared endif TEST_MODULES = \