提交 f6a21370 编写于 作者: A Alexis Campailla

Portability fixes

Add WIN_PORT_FIX macro
Fixed debug oom command
上级 642df0ee
......@@ -610,9 +610,6 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP
#include <sys/types.h> /* For size_t */
#endif /* LACKS_SYS_TYPES_H */
/* The maximum possible size_t value has all bits set */
#define MAX_SIZE_T (~(size_t)0)
#define USE_LOCKS 1
#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */
......
......@@ -38,3 +38,8 @@ typedef long _off_t;
#define _OFF_T_DEFINED
#endif
/* The maximum possible size_t value has all bits set */
#define MAX_SIZE_T (~(size_t)0)
......@@ -28,7 +28,7 @@ extern "C"
#endif
/* Sometimes in the Windows port we make changes from:
/* Sometimes in the Windows port we make changes from:
antirez_redis_statement();
to:
#ifdef _WIN32
......@@ -52,9 +52,15 @@ extern "C"
Don't use any parenthesis or semi-colon after INDUCE_MERGE_CONFLICT.
Use it at the end of a line to preserve the original indentation.
*/
#define INDUCE_MERGE_CONFLICT
/* Use WIN_PORT_FIX at the end of a line to mark places where we make changes to the code
without using #ifdefs. Useful to keep the code more legible. Mainly intended for replacing
the use of long (which is 64-bit on 64-bit Unix and 32-bit on 64-bit Windows) to portable types.
In order to be eligible for an inline fix (without #ifdef), the change should be portable back to the Posix version.
*/
#define WIN_PORT_FIX
#ifdef _WIN32
#define IF_WIN32(x, y) x
#define WIN32_ONLY(x) x
......
......@@ -33,6 +33,8 @@
#ifndef _WIN32
#include <arpa/inet.h>
#else
#include "win32_interop/win32_util.h"
#endif
#include <signal.h>
......@@ -258,7 +260,7 @@ void debugCommand(redisClient *c) {
if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
*((char*)-1) = 'x';
} else if (!strcasecmp(c->argv[1]->ptr,"oom")) {
void *ptr = zmalloc(ULONG_MAX); /* Should trigger an out of memory. */
void *ptr = zmalloc(MAX_SIZE_T); /* Should trigger an out of memory. */ WIN_PORT_FIX
zfree(ptr);
addReply(c,shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr,"assert")) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册