Skip to content

Commit 17772de

Browse files
authored
ModuleSDK update + C++-related changes (#525)
* Updated redismodule.h * C++-related changes * Small fix in torch_c.cpp * Added REDISMODULE_MAIN to backends
1 parent 937604a commit 17772de

File tree

12 files changed

+467
-600
lines changed

12 files changed

+467
-600
lines changed

src/backends/onnxruntime.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include <cuda_provider_factory.h>
23
#include "backends/onnxruntime.h"
34
#include "backends/util.h"

src/backends/tensorflow.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include "backends/tensorflow.h"
23
#include "backends/util.h"
34
#include "tensor.h"

src/backends/tflite.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include "backends/tflite.h"
23
#include "backends/util.h"
34
#include "tensor.h"

src/backends/torch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include "backends/torch.h"
23
#include "backends/util.h"
34
#include "tensor.h"

src/background_workers.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
*
1010
*/
1111

12-
#if defined(__linux__)
13-
#define _GNU_SOURCE
14-
#endif
15-
1612
#ifndef SRC_BACKGROUND_WORKERS_H_
1713
#define SRC_BACKGROUND_WORKERS_H_
1814

15+
#if defined(__linux__) && !defined(_GNU_SOURCE)
16+
#define _GNU_SOURCE
17+
#endif
18+
1919
#include <pthread.h>
2020

2121
#include "config.h"

src/redisai.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define REDISMODULE_MAIN
12
#include "redismodule.h"
23
#include "tensor.h"
34

src/redisai.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,22 @@ RedisModuleType *MODULE_API_FUNC(RedisAI_ScriptRedisType)(void);
118118

119119
int MODULE_API_FUNC(RedisAI_GetLLAPIVersion)();
120120

121+
#ifndef __cplusplus
121122
#define REDISAI_MODULE_INIT_FUNCTION(ctx, name) \
122123
RedisAI_##name = RedisModule_GetSharedAPI(ctx, "RedisAI_" #name); \
123124
if (!RedisAI_##name) { \
124125
RedisModule_Log(ctx, "warning", "could not initialize RedisAI_" #name "\r\n"); \
125126
return REDISMODULE_ERR; \
126127
}
128+
#else
129+
#define REDISAI_MODULE_INIT_FUNCTION(ctx, name) \
130+
RedisAI_##name = reinterpret_cast<decltype(RedisAI_##name)>( \
131+
RedisModule_GetSharedAPI((RedisModuleCtx *)(ctx), "RedisAI_" #name)); \
132+
if (!RedisAI_##name) { \
133+
RedisModule_Log(ctx, "warning", "could not initialize RedisAI_" #name "\r\n"); \
134+
return REDISMODULE_ERR; \
135+
}
136+
#endif
127137

128138
static int RedisAI_Initialize(RedisModuleCtx *ctx) {
129139

0 commit comments

Comments
 (0)